Class CallJavaConstructor
java.lang.Object
org.jfuncmachine.compiler.model.SourceElement
org.jfuncmachine.compiler.model.expr.Expression
org.jfuncmachine.compiler.model.expr.javainterop.CallJavaConstructor
An expression to call a Java constructor.
In the Java Virtual Machine, object creation is a two-step process that requires the creation
of an object via the new_object instruction, and then executing the constructor method to initialize
the newly-created object. This class takes care of both of those operations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal Expression[]The arguments to pass to the constructorfinal StringThe name of the class to createfinal Type[]The parameter types of the constructorFields inherited from class org.jfuncmachine.compiler.model.SourceElement
filename, lineNumber -
Constructor Summary
ConstructorsConstructorDescriptionCallJavaConstructor(String className, Expression[] arguments) Create a Java constructor expressionCallJavaConstructor(String className, Expression[] arguments, String filename, int lineNumber) Create a Java constructor expressionCallJavaConstructor(String className, Type[] parameterTypes, Expression[] arguments) Create a Java constructor expressionCallJavaConstructor(String className, Type[] parameterTypes, Expression[] arguments, String filename, int lineNumber) Create a Java constructor 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
-
className
The name of the class to create -
parameterTypes
The parameter types of the constructor -
arguments
The arguments to pass to the constructor
-
-
Constructor Details
-
CallJavaConstructor
Create a Java constructor expression- Parameters:
className- The name of the class to createarguments- The arguments to pass to the constructor
-
CallJavaConstructor
public CallJavaConstructor(String className, Expression[] arguments, String filename, int lineNumber) Create a Java constructor expression- Parameters:
className- The name of the class to createarguments- The arguments to pass to the constructorfilename- The source filename this expression is associated withlineNumber- The source line number this expression is associated with
-
CallJavaConstructor
Create a Java constructor expression- Parameters:
className- The name of the class to createparameterTypes- The parameter types of the constructor, in case they differ from the types of the argument expressionsarguments- The arguments to pass to the constructor
-
CallJavaConstructor
public CallJavaConstructor(String className, Type[] parameterTypes, Expression[] arguments, String filename, int lineNumber) Create a Java constructor expression- Parameters:
className- The name of the class to createparameterTypes- The parameter types of the constructor, in case they differ from the types of the argument expressionsarguments- The arguments to pass to the constructorfilename- 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
-