Package jminusminus

Class JVariableDeclaration

java.lang.Object
jminusminus.JAST
jminusminus.JStatement
jminusminus.JVariableDeclaration

class JVariableDeclaration extends JStatement
The AST node for a local variable declaration. Local variables are declared by its analyze() method, which also re-writes any initializations as assignment statements, in turn generated by its codegen() method.
  • Constructor Details

    • JVariableDeclaration

      public JVariableDeclaration(int line, ArrayList<JVariableDeclarator> decls)
      Constructs an AST node for a variable declaration.
      Parameters:
      line - line in which the variable declaration occurs in the source file.
      decls - variable declarators.
  • Method Details

    • analyze

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

      public void codegen(CLEmitter output)
      Performs code generation for this AST.
      Specified by:
      codegen in class JAST
      Parameters:
      output - the code emitter.
    • toJSON

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