Package jminusminus
Class JExpression
java.lang.Object
jminusminus.JAST
jminusminus.JStatement
jminusminus.JExpression
- Direct Known Subclasses:
JArrayExpression
,JArrayInitializer
,JBinaryExpression
,JCastOp
,JConditionalExpression
,JFieldSelection
,JInstanceOfOp
,JLiteralBoolean
,JLiteralChar
,JLiteralDouble
,JLiteralInt
,JLiteralLong
,JLiteralNull
,JLiteralString
,JMessageExpression
,JNewArrayOp
,JNewOp
,JSuper
,JSuperConstruction
,JThis
,JThisConstruction
,JUnaryExpression
,JVariable
,JWildExpression
The AST node for an expression. The syntax says all expressions are statements, but a semantic
check throws some (those without a side-effect) out. Every expression has a type and a flag
indicating whether or not it's a statement-expression.
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
Whether or not this expression is a statement.protected Type
Expression type.Fields inherited from class jminusminus.JAST
compilationUnit, line
-
Constructor Summary
ModifierConstructorDescriptionprotected
JExpression
(int line) Constructs an AST node for an expression. -
Method Summary
Modifier and TypeMethodDescriptionabstract JExpression
Analyzes and returns a JExpression.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.boolean
Returns true if this expression is being used as a statement, and false otherwise.type()
Returns the expression type.
-
Field Details
-
type
Expression type. -
isStatementExpression
protected boolean isStatementExpressionWhether or not this expression is a statement.
-
-
Constructor Details
-
JExpression
protected JExpression(int line) Constructs an AST node for an expression.- Parameters:
line
- line in which the expression occurs in the source file.
-
-
Method Details
-
type
Returns the expression type.- Returns:
- the expression type.
-
isStatementExpression
public boolean isStatementExpression()Returns true if this expression is being used as a statement, and false otherwise.- Returns:
- true if this expression is being used as a statement, and false otherwise.
-
analyze
Analyzes and returns a JExpression. -
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.- Parameters:
output
- the code emitter.targetLabel
- the label to which we should branch.onTrue
- do we branch on true?
-