Module rgg

Class XLFilter

java.lang.Object
de.grogra.pf.io.FilterBase
de.grogra.rgg.model.XLFilter
All Implemented Interfaces:
Filter, FilterSource, ObjectSource, RegistryContext, Map
Direct Known Subclasses:
JavaFilter, LSYFilter, RGGFilter

public class XLFilter extends FilterBase implements ObjectSource
An XLFilter parses a character stream representing XL source code into a CompilationUnit. The auxiliary method compile() automatically compiles the resulting compilation unit into the contained types.
Author:
Ole Kniemeyer
  • Field Details

    • DUMP_TREE

      public static boolean DUMP_TREE
  • Constructor Details

    • XLFilter

      public XLFilter(FilterItem item, ReaderSource source)
      Constructs a new filter which transforms the input source into an instance of CompilationUnit which can be compiled afterwards.
      Parameters:
      item - the defining item for this filter within the registry, may be null
      source - the source from which the input stream of characters will be read
      See Also:
  • Method Details

    • getClassName

      protected String getClassName()
      Derives a legal class name from the sytem id of the source. May be used in subclasses which implicitly generate such a class name.
      Returns:
      class name derived from system id of the source
    • createTokenizer

      protected Tokenizer createTokenizer()
      Creates the tokenizer to be used for scanning of the source.
      Returns:
      tokenizer instance
    • createParser

      protected Parser createParser(Tokenizer t)
      Creates the parser which will subsequently be used to parse the token stream resulting from t into an abstract syntax tree.
      Parameters:
      t - token stream input
      Returns:
      parser which parses token stream of t
    • getPackageImports

      protected String[] getPackageImports()
      Defines the automatic package imports (e.g., import java.lang.*;). The implementation of XLFilter returns {"java.lang"}.
      Returns:
      automatic package imports
    • getMemberTypeImports

      protected Class[] getMemberTypeImports()
      Defines the automatic member type imports (e.g., import java.awt.PageAttributes.*;).
      Returns:
      types whose member types are imported automatically
    • getSingleTypeImports

      protected Class[] getSingleTypeImports() throws ClassNotFoundException
      Defines the automatic single type imports (e.g., import java.util.Map;).
      Returns:
      types which are imported automatically
      Throws:
      ClassNotFoundException
    • getStaticTypeImports

      protected Class[] getStaticTypeImports() throws ClassNotFoundException
      Defines the automatic static type imports (e.g., import static java.lang.Math.*;).
      Returns:
      types whose static members are imported automatically
      Throws:
      ClassNotFoundException
    • getEnclosingAnnotations

      protected ObjectList<Annotation> getEnclosingAnnotations()
    • isD2FWidening

      protected boolean isD2FWidening()
      Defines whether the conversion from double to float should be considered as widening, i.e., should be done automatically if required.
      Returns:
      implicit conversion from double to float?
    • getLoaderForRegistry

      public static ASMTypeLoader getLoaderForRegistry(RegistryContext ctx)
    • getImports

      protected Scope getImports(ClassPath path) throws ClassNotFoundException
      Constructs the scope which includes all automatic imports.
      Parameters:
      path - class path which defines the existing classes and interfaces
      Returns:
      scope including automatic imports based on path
      Throws:
      ClassNotFoundException
      See Also:
    • getObject

      public CompilationUnit getObject() throws IOException
      Description copied from interface: ObjectSource
      Returns the data as an object of a class which is compatible which the flavor.
      Specified by:
      getObject in interface ObjectSource
      Returns:
      the data
      Throws:
      IOException
    • compile

      public Type[] compile() throws IOException
      Compiles the source of this filter into an array of the types which are declared by the source. This included top-level types, nested types, and local and anonymous classes. The returned types are wrappers for true Class objects, i.e., they represent true classes loaded by the Java virtual machine.
      Returns:
      array of compiled, declared types of the source code
      Throws:
      IOException - if source cannot be read or if there is a lexical, syntactic or semantic error
    • compile

      public static Type[] compile(Reader input, String systemId) throws IOException
      This auxiliary method compiles the source code of input to an array of types
      Parameters:
      input -
      systemId -
      Returns:
      array of compiled, declared types of the source code
      Throws:
      IOException - if source cannot be read or if there is a lexical, syntactic or semantic error
      See Also:
    • getLoaderForAll

      public static ASMTypeLoader getLoaderForAll()