Package jminusminus

Class JClassDeclaration

java.lang.Object
jminusminus.JAST
jminusminus.JClassDeclaration
All Implemented Interfaces:
JTypeDecl

class JClassDeclaration extends JAST implements JTypeDecl
A representation of a class declaration.
  • Constructor Details

    • JClassDeclaration

      public JClassDeclaration(int line, ArrayList<String> mods, String name, Type superType, ArrayList<TypeName> superInterfaces, ArrayList<JMember> classBlock)
      Constructs an AST node for a class declaration.
      Parameters:
      line - line in which the class declaration occurs in the source file.
      mods - class modifiers.
      name - class name.
      superType - super class type.
      superInterfaces - implemented interfaces.
      classBlock - class block.
  • Method Details

    • instanceFieldInitializations

      public ArrayList<JFieldDeclaration> instanceFieldInitializations()
      Returns the initializations for instance fields (expressed as assignment statements).
      Returns:
      the initializations for instance fields (expressed as assignment statements).
    • declareThisType

      public void declareThisType(Context context)
      Declares this type in the parent context. Called before pre-analysis so that it is available in the preAnalyze() method of other types.
      Specified by:
      declareThisType in interface JTypeDecl
      Parameters:
      context - the parent (compilation unit) context.
    • preAnalyze

      public void preAnalyze(Context context)
      Pre-analyzes the members of this declaration in the parent context.
      Specified by:
      preAnalyze in interface JTypeDecl
      Parameters:
      context - the parent (compilation unit) context.
    • name

      public String name()
      Returns the name of this type declaration.
      Specified by:
      name in interface JTypeDecl
      Returns:
      the name of this type declaration.
    • thisType

      public Type thisType()
      Returns the type that this type declaration defines.
      Specified by:
      thisType in interface JTypeDecl
      Returns:
      the type defined by this type declaration.
    • superType

      public Type superType()
      Returns the type of the extended class for a class or java.lang.Object for an interface.
      Specified by:
      superType in interface JTypeDecl
      Returns:
      the type of the extended class for a class or java.lang.Object for an interface.
    • superInterfaces

      public ArrayList<TypeName> superInterfaces()
      Returns the types of the implemented interfaces for a class or extended interfaces for an interface.
      Specified by:
      superInterfaces in interface JTypeDecl
      Returns:
      the types of the implemented interfaces for a class or extended interfaces for an interface.
    • analyze

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