Class Box
java.lang.Object
org.jfuncmachine.compiler.model.SourceElement
org.jfuncmachine.compiler.model.expr.Expression
org.jfuncmachine.compiler.model.expr.boxing.Box
Boxes an expression - converts an expression returning a native type to the Object equivalent
of that type (e.g. byte becomes java.lang.Byte, double becomes java.lang.Double).
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal TypeThe type of the expressionfinal TypeAn optional desired box type, such as boxing a byte as a java.lang.Integer instead of java.lang.Bytefinal ExpressionThe expression to boxFields inherited from class org.jfuncmachine.compiler.model.SourceElement
filename, lineNumber -
Constructor Summary
ConstructorsConstructorDescriptionBox(Expression expr) Create a box for an expressionBox(Expression expr, String filename, int lineNumber) Create a box for an expressionBox(Expression expr, Type desiredBoxType) Create a box for an expression with a specific box typeBox(Expression expr, Type desiredBoxType, String filename, int lineNumber) Create a box for an expression with a specific box typeBox(Expression expr, Type unboxedType, Type desiredBoxType) Create a box for an expression with a specific box typeBox(Expression expr, Type unboxedType, Type desiredBoxType, String filename, int lineNumber) Create a box for an expression with a specific box type -
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
-
expr
The expression to box -
boxType
The type of the expression -
desiredBoxType
An optional desired box type, such as boxing a byte as a java.lang.Integer instead of java.lang.Byte
-
-
Constructor Details
-
Box
Create a box for an expression- Parameters:
expr- The expression to box, the box type is derived from the expression type
-
Box
Create a box for an expression- Parameters:
expr- The expression to box, the box type is derived from the expression typefilename- The source filename this expression is associated withlineNumber- The source line number this expression is associated with
-
Box
Create a box for an expression with a specific box type- Parameters:
expr- The expression to box, the box type is derived from the expression typedesiredBoxType- The type of the box to use, in case it is different than what would otherwise be derived from the expression type
-
Box
Create a box for an expression with a specific box type- Parameters:
expr- The expression to box, the box type is derived from the expression typedesiredBoxType- The type of the box to use, in case it is different than what would otherwise be derived from the expression typefilename- The source filename this expression is associated withlineNumber- The source line number this expression is associated with
-
Box
Create a box for an expression with a specific box type- Parameters:
expr- The expression to box, the box type is derived from the expression typeunboxedType- The type of the unboxed expression (if it is different from that of expr)desiredBoxType- The type of the box to use, in case it is different than what would otherwise be derived from the expression type
-
Box
Create a box for an expression with a specific box type- Parameters:
expr- The expression to box, the box type is derived from the expression typeunboxedType- The type of the unboxed expression (if it is different from that of expr)desiredBoxType- The type of the box to use, in case it is different than what would otherwise be derived from the expression typefilename- 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
-
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
-
reset
public void reset()Description copied from class:ExpressionResets any labels in expressions so that the method can be regenerated- Overrides:
resetin classExpression
-
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
-