Flywheel/src/main/java/com/jozufozu/flywheel/glsl/LoadResult.java
Jozufozu 1f484da50b A lot to unwrap
- 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
2023-05-08 22:43:55 -07:00

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;
}
}
}