mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-09 22:06:09 +01:00
1f484da50b
- Make ShaderSources return a LoadResult - Refactor SourceFile loading to do all parsing outside the ctor - Don't immediately swallow import errors, instead forward them - Change Span to reference SourceLines instead of SourceFile - Still WIP, but functional at this stage
39 lines
853 B
Java
39 lines
853 B
Java
package com.jozufozu.flywheel.glsl;
|
|
|
|
import java.io.IOException;
|
|
import java.util.List;
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
import net.minecraft.resources.ResourceLocation;
|
|
|
|
public sealed interface LoadResult {
|
|
static LoadResult success(SourceFile sourceFile) {
|
|
return new Success(sourceFile);
|
|
}
|
|
|
|
@Nullable SourceFile unwrap();
|
|
|
|
record Success(SourceFile source) implements LoadResult {
|
|
@Override
|
|
@NotNull
|
|
public SourceFile unwrap() {
|
|
return source;
|
|
}
|
|
}
|
|
|
|
record IOError(ResourceLocation location, IOException exception) implements LoadResult {
|
|
@Override
|
|
public SourceFile unwrap() {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
record IncludeError(ResourceLocation location, List<LoadResult> innerFailures) implements LoadResult {
|
|
@Override
|
|
public SourceFile unwrap() {
|
|
return null;
|
|
}
|
|
}
|
|
}
|