class JFieldSelection extends JExpression implements JLhs
Modifier and Type | Field and Description |
---|---|
protected JExpression |
target
The target expression.
|
isStatementExpression, type
compilationUnit, line
Constructor and Description |
---|
JFieldSelection(int line,
AmbiguousName ambiguousPart,
JExpression target,
String fieldName)
Construct an AST node for a field selection having an ambiguous part.
|
JFieldSelection(int line,
JExpression target,
String fieldName)
Construct an AST node for a field selection without an ambiguous part.
|
Modifier and Type | Method and Description |
---|---|
JExpression |
analyze(Context context)
Analyzing a field selection expression involves, (1) reclassifying any
ambiguous part, (2) analyzing the target, (3) treating "length" field of
arrays specially, or computing the Field object, (4) checking the access
rules, and (5) computing the resultant type.
|
JExpression |
analyzeLhs(Context context)
Analyze the field selection expression for use on the lhs of an
assignment.
|
void |
codegen(CLEmitter output)
Generate the code necessary to load the Rvalue for this field selection.
|
void |
codegen(CLEmitter output,
String targetLabel,
boolean onTrue)
The semantics of j-- require that we implement short-circuiting branching
in implementing field selections.
|
void |
codegenDuplicateRvalue(CLEmitter output)
Generate the code required for duplicating the Rvalue that is on the
stack becuase it is to be used in a surrounding expression, as in a[i] =
x =
|
void |
codegenLoadLhsLvalue(CLEmitter output)
Generate the code required for setting up an Lvalue, eg, for use in an
assignment.
|
void |
codegenLoadLhsRvalue(CLEmitter output)
Generate the code required for loading an Rvalue for this variable, eg
for use in a +=.
|
void |
codegenStore(CLEmitter output)
Generate the code required for doing the actual assignment.
|
void |
writeToStdOut(PrettyPrinter p)
Write the information pertaining to this AST to STDOUT.
|
isStatementExpression, type
line, partialCodegen
protected JExpression target
public JFieldSelection(int line, JExpression target, String fieldName)
line
- the line number of the selection.target
- the target of the selection.fieldName
- the field name.public JFieldSelection(int line, AmbiguousName ambiguousPart, JExpression target, String fieldName)
line
- line in which the field selection occurs in the source file.ambiguousPart
- the ambiguous part.target
- the target of the selection.fieldName
- the field name.public JExpression analyze(Context context)
analyze
in class JExpression
context
- context in which names are resolved.public JExpression analyzeLhs(Context context)
analyzeLhs
in interface JLhs
context
- context in which names are resolved.public void codegen(CLEmitter output)
public void codegen(CLEmitter output, String targetLabel, boolean onTrue)
codegen
in class JExpression
output
- the code emitter (basically an abstraction for producing the
.class file).targetLabel
- the label to which we should branch.onTrue
- do we branch on true?public void codegenLoadLhsLvalue(CLEmitter output)
codegenLoadLhsLvalue
in interface JLhs
output
- the code emitter (basically an abstraction for producing the
.class file).public void codegenLoadLhsRvalue(CLEmitter output)
codegenLoadLhsRvalue
in interface JLhs
output
- the code emitter (basically an abstraction for producing the
.class file).public void codegenDuplicateRvalue(CLEmitter output)
codegenDuplicateRvalue
in interface JLhs
output
- the code emitter (basically an abstraction for producing the
.class file).public void codegenStore(CLEmitter output)
codegenStore
in interface JLhs
output
- the code emitter (basically an abstraction for producing the
.class file).public void writeToStdOut(PrettyPrinter p)
JAST
writeToStdOut
in class JAST
p
- for pretty printing with indentation.