class JMethodDeclaration extends JAST implements JMember
Modifier and Type | Field and Description |
---|---|
protected JBlock |
body
Method body.
|
protected MethodContext |
context
Built in analyze().
|
protected String |
descriptor
Computed by preAnalyze().
|
protected boolean |
isAbstract
Is method abstract.
|
protected boolean |
isPrivate
Is method private.
|
protected boolean |
isStatic
Is method static.
|
protected ArrayList<String> |
mods
Method modifiers.
|
protected String |
name
Method name.
|
protected ArrayList<JFormalParameter> |
params
The formal parameters.
|
protected Type |
returnType
Return type.
|
compilationUnit, line
Constructor and Description |
---|
JMethodDeclaration(int line,
ArrayList<String> mods,
String name,
Type returnType,
ArrayList<JFormalParameter> params,
JBlock body)
Construct an AST node for a method declaration given the
line number, method name, return type, formal parameters,
and the method body.
|
Modifier and Type | Method and Description |
---|---|
JAST |
analyze(Context context)
Analysis for a method declaration involves (1) creating a
new method context (that records the return type; this is
used in the analysis of the method body), (2) bumping up
the offset (for instance methods), (3) declaring the
formal parameters in the method context, and (4) analyzing
the method's body.
|
void |
codegen(CLEmitter output)
Generate code for the method declaration.
|
void |
partialCodegen(Context context,
CLEmitter partial)
Add this method declaration to the partial class.
|
void |
preAnalyze(Context context,
CLEmitter partial)
Declare this method in the parent (class) context.
|
void |
writeToStdOut(PrettyPrinter p)
Write the information pertaining to this AST to STDOUT.
|
protected String name
protected Type returnType
protected ArrayList<JFormalParameter> params
protected JBlock body
protected MethodContext context
protected String descriptor
protected boolean isAbstract
protected boolean isStatic
protected boolean isPrivate
public JMethodDeclaration(int line, ArrayList<String> mods, String name, Type returnType, ArrayList<JFormalParameter> params, JBlock body)
line
- line in which the method declaration occurs
in the source file.mods
- modifiers.name
- method name.returnType
- return type.params
- the formal parameters.body
- method body.public void preAnalyze(Context context, CLEmitter partial)
preAnalyze
in interface JMember
context
- the parent (class) context.partial
- the code emitter (basically an abstraction
for producing the partial class).public JAST analyze(Context context)
public void partialCodegen(Context context, CLEmitter partial)
partialCodegen
in class JAST
context
- the parent (class) context.partial
- the code emitter (basically an abstraction
for producing the partial class).public void codegen(CLEmitter output)
public void writeToStdOut(PrettyPrinter p)
JAST
writeToStdOut
in class JAST
p
- for pretty printing with indentation.