Package jminusminus
Class JVariable
java.lang.Object
jminusminus.JAST
jminusminus.JStatement
jminusminus.JExpression
jminusminus.JVariable
- All Implemented Interfaces:
JLhs
The AST node for an identifier used as a primary expression.
-
Field Summary
Fields inherited from class jminusminus.JExpression
isStatementExpression, typeFields inherited from class jminusminus.JAST
compilationUnit, line -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAnalyzes and returns a JExpression.analyzeLhs(Context context) Analyzes the lhs of an assignment.voidPerforms code generation for this AST.voidPerforms 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.voidcodegenDuplicateRvalue(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--.voidcodegenLoadLhsLvalue(CLEmitter output) Generates code to load onto the stack any part of the lhs that must be there, as in a[i] = x.voidcodegenLoadLhsRvalue(CLEmitter output) Generates code to load an Rvalue of the lhs, as in a += x.voidcodegenStore(CLEmitter output) Generates the code to do the actual assignment.iDefn()Returns the identifier's definition.name()Returns the identifier name.voidtoJSON(JSONElement json) Stores information about this AST in JSON format.Methods inherited from class jminusminus.JExpression
isStatementExpression, typeMethods inherited from class jminusminus.JAST
line, partialCodegen, unescape
-
Constructor Details
-
JVariable
Constructs the AST node for a variable.- Parameters:
line- line in which the variable occurs in the source file.name- the name.
-
-
Method Details
-
name
Returns the identifier name.- Returns:
- the identifier name.
-
iDefn
Returns the identifier's definition.- Returns:
- the identifier's definition.
-
analyze
Analyzes and returns a JExpression.- Specified by:
analyzein 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:
analyzeLhsin 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:
codegenin 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:
codegenLoadLhsLvaluein interfaceJLhs- Parameters:
output- the code emitter.
-
codegenLoadLhsRvalue
Generates code to load an Rvalue of the lhs, as in a += x.- Specified by:
codegenLoadLhsRvaluein 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:
codegenDuplicateRvaluein interfaceJLhs- Parameters:
output- the code emitter.
-
codegenStore
Generates the code to do the actual assignment.- Specified by:
codegenStorein interfaceJLhs- Parameters:
output- the code emitter.
-
toJSON
Stores information about this AST in JSON format.
-