Package jminusminus

Class JAST

java.lang.Object
jminusminus.JAST
Direct Known Subclasses:
JClassDeclaration, JCompilationUnit, JFieldDeclaration, JFormalParameter, JInterfaceDeclaration, JMethodDeclaration, JStatement, JVariableDeclarator

abstract class JAST extends Object
JAST is the abstract superclass of all nodes in the abstract syntax tree (AST).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Current compilation unit (set in JCompilationUnit()).
    protected int
    Line in which the source for the AST was found.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    JAST(int line)
    Constructs an AST node the given its line number in the source file.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract JAST
    analyze(Context context)
    Performs semantic analysis on this AST and returns the (possibly modified) AST.
    abstract void
    Performs code generation for this AST.
    int
    Returns the line in which the source for the AST was found.
    void
    partialCodegen(Context context, CLEmitter partial)
    Generates a partial class for a type, reflecting only the member information required to do analysis.
    void
    Stores information about this AST in JSON format.
    static String
    Unescapes the escaped characters in the specified string and returns the unescaped string.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • compilationUnit

      public static JCompilationUnit compilationUnit
      Current compilation unit (set in JCompilationUnit()).
    • line

      protected int line
      Line in which the source for the AST was found.
  • Constructor Details

    • JAST

      protected JAST(int line)
      Constructs an AST node the given its line number in the source file.
      Parameters:
      line - line in which the source for the AST was found.
  • Method Details

    • line

      public int line()
      Returns the line in which the source for the AST was found.
      Returns:
      the line in which the source for the AST was found.
    • analyze

      public abstract JAST analyze(Context context)
      Performs semantic analysis on this AST and returns the (possibly modified) AST.
      Parameters:
      context - the environment (scope) in which code is analyzed.
      Returns:
      the (possibly modified) AST.
    • partialCodegen

      public void partialCodegen(Context context, CLEmitter partial)
      Generates a partial class for a type, reflecting only the member information required to do analysis.
      Parameters:
      context - the parent (class) context.
      partial - the code emitter.
    • codegen

      public abstract void codegen(CLEmitter output)
      Performs code generation for this AST.
      Parameters:
      output - the code emitter.
    • toJSON

      public void toJSON(JSONElement json)
      Stores information about this AST in JSON format.
      Parameters:
      json - the JSON emitter.
    • unescape

      public static String unescape(String s)
      Unescapes the escaped characters in the specified string and returns the unescaped string.
      Parameters:
      s - string to unescape.
      Returns:
      the unescaped string.