Package jminusminus
Class JFieldSelection
java.lang.Object
jminusminus.JAST
jminusminus.JStatement
jminusminus.JExpression
jminusminus.JFieldSelection
- All Implemented Interfaces:
JLhs
The AST node for a field selection operation. It has a target object, a field name, and the
field it defines.
-
Field Summary
Fields inherited from class jminusminus.JExpression
isStatementExpression, type
Fields inherited from class jminusminus.JAST
compilationUnit, line
-
Constructor Summary
ConstructorDescriptionJFieldSelection
(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) Constructs an AST node for a field selection without an ambiguous part. -
Method Summary
Modifier and TypeMethodDescriptionAnalyzes and returns a JExpression.analyzeLhs
(Context context) Analyzes the lhs of an assignment.void
Performs code generation for this AST.void
Performs short-circuit code generation for a boolean expression, given the code emitter, a target label, and whether we branch to that label on true or on false.void
codegenDuplicateRvalue
(CLEmitter output) Generates the code to duplicate the Rvalue that is on the stack because it is to be used in a surrounding expression, as in a[i] = x--.void
codegenLoadLhsLvalue
(CLEmitter output) Generates code to load onto the stack any part of the lhs that must be there, as in a[i] = x.void
codegenLoadLhsRvalue
(CLEmitter output) Generates code to load an Rvalue of the lhs, as in a += x.void
codegenStore
(CLEmitter output) Generates the code to do the actual assignment.void
toJSON
(JSONElement json) Stores information about this AST in JSON format.Methods inherited from class jminusminus.JExpression
isStatementExpression, type
Methods inherited from class jminusminus.JAST
line, partialCodegen, unescape
-
Field Details
-
target
The target expression.
-
-
Constructor Details
-
JFieldSelection
Constructs an AST node for a field selection without an ambiguous part.- Parameters:
line
- the line number of the selection.target
- the target of the selection.fieldName
- the field name.
-
JFieldSelection
Construct an AST node for a field selection having an ambiguous part.- Parameters:
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.
-
-
Method Details
-
analyze
Analyzes and returns a JExpression.- Specified by:
analyze
in classJExpression
- Parameters:
context
- context in which names are resolved.- Returns:
- the analyzed (and possibly rewritten) AST subtree.
-
analyzeLhs
Analyzes the lhs of an assignment. This is very much like the analyze() methods, but perhaps a little more selective here and there.- Specified by:
analyzeLhs
in interfaceJLhs
- Parameters:
context
- context in which names are resolved.- Returns:
- the analyzed (and possibly rewritten) AST subtree.
-
codegen
Performs code generation for this AST. -
codegen
Performs short-circuit code generation for a boolean expression, given the code emitter, a target label, and whether we branch to that label on true or on false.- Overrides:
codegen
in classJExpression
- Parameters:
output
- the code emitter.targetLabel
- the label to which we should branch.onTrue
- do we branch on true?
-
codegenLoadLhsLvalue
Generates code to load onto the stack any part of the lhs that must be there, as in a[i] = x.- Specified by:
codegenLoadLhsLvalue
in interfaceJLhs
- Parameters:
output
- the code emitter.
-
codegenLoadLhsRvalue
Generates code to load an Rvalue of the lhs, as in a += x.- Specified by:
codegenLoadLhsRvalue
in interfaceJLhs
- Parameters:
output
- the code emitter.
-
codegenDuplicateRvalue
Generates the code to duplicate the Rvalue that is on the stack because it is to be used in a surrounding expression, as in a[i] = x--.- Specified by:
codegenDuplicateRvalue
in interfaceJLhs
- Parameters:
output
- the code emitter.
-
codegenStore
Generates the code to do the actual assignment.- Specified by:
codegenStore
in interfaceJLhs
- Parameters:
output
- the code emitter.
-
toJSON
Stores information about this AST in JSON format.
-