Package jminusminus

Class JMethodDeclaration

java.lang.Object
jminusminus.JAST
jminusminus.JMethodDeclaration
All Implemented Interfaces:
JMember
Direct Known Subclasses:
JConstructorDeclaration

class JMethodDeclaration extends JAST implements JMember
The AST node for a method declaration.
  • Field Details

    • mods

      protected ArrayList<String> mods
      Method modifiers.
    • name

      protected String name
      Method name.
    • returnType

      protected Type returnType
      Return type.
    • params

      protected ArrayList<JFormalParameter> params
      The formal parameters.
    • exceptions

      protected ArrayList<TypeName> exceptions
      Exceptions thrown.
    • body

      protected JBlock body
      Method body.
    • context

      protected MethodContext context
      Method context (built in analyze()).
    • descriptor

      protected String descriptor
      Method descriptor (computed in preAnalyze()).
    • isAbstract

      protected boolean isAbstract
      Is this method abstract?
    • isStatic

      protected boolean isStatic
      Is this method static?
    • isPrivate

      protected boolean isPrivate
      Is this method private?
  • Constructor Details

    • JMethodDeclaration

      public JMethodDeclaration(int line, ArrayList<String> mods, String name, Type returnType, ArrayList<JFormalParameter> params, ArrayList<TypeName> exceptions, JBlock body)
      Constructs an AST node for a method declaration.
      Parameters:
      line - line in which the method declaration occurs in the source file.
      mods - modifiers.
      name - method name.
      returnType - return type.
      params - the formal parameters.
      exceptions - exceptions thrown.
      body - method body.
  • Method Details

    • preAnalyze

      public void preAnalyze(Context context, CLEmitter partial)
      Declares the member names in the specified (class) context and generates the member headers in the partial class.
      Specified by:
      preAnalyze in interface JMember
      Parameters:
      context - class context in which names are resolved.
      partial - the code emitter.
    • 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.
    • partialCodegen

      public void partialCodegen(Context context, CLEmitter partial)
      Generates a partial class for a type, reflecting only the member information required to do analysis.
      Overrides:
      partialCodegen in class JAST
      Parameters:
      context - the parent (class) context.
      partial - the code emitter.
    • 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.