class JInstanceOfOp extends JExpression
isStatementExpression, type
compilationUnit, line
Constructor and Description |
---|
JInstanceOfOp(int line,
JExpression expr,
Type typeSpec)
Construct an AST node for an instanceof expression given
its line number, the relational expression and reference
type.
|
Modifier and Type | Method and Description |
---|---|
JInstanceOfOp |
analyze(Context context)
Analysis of an instanceof operation requires analyzing the
expression to be tested, resolving the type was are
testing for, and determining if the test is legal, or if
the answer can be determined at compile time.
|
void |
codegen(CLEmitter output)
Generate code for the type test.
|
void |
codegen(CLEmitter output,
String targetLabel,
boolean onTrue)
Short-circuiting branching for instanceof.
|
void |
writeToStdOut(PrettyPrinter p)
Write the information pertaining to this AST to STDOUT.
|
isStatementExpression, type
line, partialCodegen
public JInstanceOfOp(int line, JExpression expr, Type typeSpec)
line
- the line in which the instanceof expression
occurs in the source file.expr
- the expression denoting the value to be
tested.typeSpec
- the reference type we are testing for.public JInstanceOfOp analyze(Context context)
analyze
in class JExpression
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
- code emitter.targetLabel
- the label to which we should branch.onTrue
- do we branch on true?public void writeToStdOut(PrettyPrinter p)
JAST
writeToStdOut
in class JAST
p
- for pretty printing with indentation.