Package jminusminus

Class JVariableDeclarator

java.lang.Object
jminusminus.JAST
jminusminus.JVariableDeclarator

class JVariableDeclarator extends JAST
The AST node for a variable declarator, which declares a name, its type and (possibly) provides an initialization.
  • Constructor Details

    • JVariableDeclarator

      public JVariableDeclarator(int line, String name, Type type, JExpression initializer)
      Constructs an AST node for a variable declarator.
      Parameters:
      line - line in which the variable occurs in the source file.
      name - variable name.
      type - variable type.
      initializer - initializer.
  • Method Details

    • name

      public String name()
      Returns the variable name.
      Returns:
      the variable name.
    • type

      public Type type()
      Returns the variable type.
      Returns:
      the variable type.
    • setType

      public void setType(Type type)
      Sets the variable type.
      Parameters:
      type - the type
    • initializer

      public JExpression initializer()
      Returns the variable initializer.
      Returns:
      the variable initializer.
    • setInitializer

      public void setInitializer(JExpression initializer)
      Sets the variable initializer.
      Parameters:
      initializer - the initializer.
    • analyze

      public JVariableDeclarator 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.