Class If
java.lang.Object
org.jfuncmachine.compiler.model.SourceElement
org.jfuncmachine.compiler.model.expr.Expression
org.jfuncmachine.compiler.model.expr.If
A expression to perform a boolean test and return an expression depending on whether the
test is true or false;
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal ExpressionThe expression to return if the test is false.A placeholder used for generation to mark when the false expression is executedfinal booleanTrue if this expression has a falseExprfinal BooleanExprThe boolean test to performThe sequence of comparisons executed by this test (this is computed when the Java byte code is generatedfinal ExpressionThe expression to return if the test is trueA placeholder used for generation to mark when the true expression is executedFields inherited from class org.jfuncmachine.compiler.model.SourceElement
filename, lineNumber -
Constructor Summary
ConstructorsConstructorDescriptionIf(BooleanExpr test, Expression trueExpr) Create an if expressionIf(BooleanExpr test, Expression trueExpr, String filename, int lineNumber) Create an if expressionIf(BooleanExpr test, Expression trueExpr, Expression falseExpr) Create an if expressionIf(BooleanExpr test, Expression trueExpr, Expression falseExpr, String filename, int lineNumber) Create an if expression -
Method Summary
Modifier and TypeMethodDescriptionconvertToFullTailCalls(boolean inTailPosition) Converts this expression to one that is compatible with full tail call optimizationvoidfindCaptured(Environment env) Search for local variables that would be captured by a lambda.voidgenerate(ClassGenerator generator, Environment env, boolean inTailPosition) Generate the bytecode for this expressiongetType()Get the type returned by this expressionvoidreset()Resets any labels in expressions so that the method can be regeneratedMethods inherited from class org.jfuncmachine.compiler.model.SourceElement
generateException
-
Field Details
-
test
The boolean test to perform -
trueExpr
The expression to return if the test is true -
falseExpr
The expression to return if the test is false. This may be null -
hasFalse
public final boolean hasFalseTrue if this expression has a falseExpr -
testSequence
The sequence of comparisons executed by this test (this is computed when the Java byte code is generated -
trueResult
A placeholder used for generation to mark when the true expression is executed -
falseResult
A placeholder used for generation to mark when the false expression is executed
-
-
Constructor Details
-
If
Create an if expression- Parameters:
test- The test to performtrueExpr- The expression to return if the test is truefalseExpr- The expression to return if the test is false
-
If
public If(BooleanExpr test, Expression trueExpr, Expression falseExpr, String filename, int lineNumber) Create an if expression- Parameters:
test- The test to performtrueExpr- The expression to return if the test is truefalseExpr- The expression to return if the test is falsefilename- The source filename this expression is associated withlineNumber- The source line number this expression is associated with
-
If
Create an if expression- Parameters:
test- The test to performtrueExpr- The expression to return if the test is true
-
If
Create an if expression- Parameters:
test- The test to performtrueExpr- The expression to return if the test is truefilename- The source filename this expression is associated withlineNumber- The source line number this expression is associated with
-
-
Method Details
-
getType
Description copied from class:ExpressionGet the type returned by this expression- Specified by:
getTypein classExpression- Returns:
- The type of this expression
-
reset
public void reset()Description copied from class:ExpressionResets any labels in expressions so that the method can be regenerated- Overrides:
resetin classExpression
-
findCaptured
Description copied from class:ExpressionSearch for local variables that would be captured by a lambda. Each expression has its own implementation of this, because each subexpression must be searched.- Specified by:
findCapturedin classExpression- Parameters:
env- The environment chain to search
-
convertToFullTailCalls
Description copied from class:ExpressionConverts this expression to one that is compatible with full tail call optimization- Specified by:
convertToFullTailCallsin classExpression- Parameters:
inTailPosition- True if this expression is called from the tail position- Returns:
- A version of this expression whose types are compatible with full tail call optimization
-
generate
Description copied from class:ExpressionGenerate the bytecode for this expression- Specified by:
generatein classExpression- Parameters:
generator- The generator for generating instructions and additional declarationsenv- The environment containing the local variables currently visible to this expressioninTailPosition- True if this expression is being generated from the tail position of the method
-