Class SourceFile

java.lang.Object
com.jozufozu.flywheel.backend.glsl.SourceFile
All Implemented Interfaces:
SourceComponent

public class SourceFile extends Object implements SourceComponent
Immutable class representing a shader file.

This class parses shader files and generates what is effectively a high level AST of the source.

  • Field Details

    • name

      public final net.minecraft.resources.ResourceLocation name
    • source

      public final SourceLines source
    • functions

      public final com.google.common.collect.ImmutableMap<String,ShaderFunction> functions
      Function lookup by name.
    • structs

      public final com.google.common.collect.ImmutableMap<String,ShaderStruct> structs
      Struct lookup by name.
    • imports

      public final com.google.common.collect.ImmutableList<Import> imports
      Includes ordered as defined in the source.
    • fields

      public final com.google.common.collect.ImmutableMap<String,ShaderField> fields
    • included

      public final List<SourceFile> included
    • finalSource

      public final String finalSource
  • Method Details

    • empty

      public static LoadResult empty(net.minecraft.resources.ResourceLocation name)
    • parse

      public static LoadResult parse(ShaderSources sourceFinder, net.minecraft.resources.ResourceLocation name, String stringSource)
    • included

      public Collection<? extends SourceComponent> included()
      Specified by:
      included in interface SourceComponent
    • source

      public String source()
      Specified by:
      source in interface SourceComponent
    • name

      public String name()
      Specified by:
      name in interface SourceComponent
    • getLineSpan

      public Span getLineSpan(int lineNo)
    • getLineSpanNoWhitespace

      public Span getLineSpanNoWhitespace(int line)
    • getLineSpanMatching

      public Span getLineSpanMatching(int line, @Nullable @Nullable String match)
    • findStructByName

      public Optional<ShaderStruct> findStructByName(String name)
      Search this file and recursively search all imports to find a struct definition matching the given name.
      Parameters:
      name - The name of the struct to find.
      Returns:
      null if no definition matches the name.
    • findFunction

      public Optional<ShaderFunction> findFunction(String name)
      Search this file and recursively search all imports to find a function definition matching the given name.
      Parameters:
      name - The name of the function to find.
      Returns:
      Optional#empty() if no definition matches the name.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object