Package org.jfuncmachine.compiler.model
Class MethodDef
java.lang.Object
org.jfuncmachine.compiler.model.SourceElement
org.jfuncmachine.compiler.model.MethodDef
- Direct Known Subclasses:
ConstructorDef,StaticInitializerDef
Defines a method, which has zero or more parameters, a return type and a single expression
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal intThe access flags of the method (e.g.The expression that this method executesfinal booleanTrue if this method def is for a lambdafinal booleanIf true, this method can be called using the tail call elimination mechanism implemented by JFuncMachinefinal StringThe name of the methodintUsed by Lambda to indicate how many method parameters were captured from the lambda environment.final Field[]The name and type of each parameterfinal TypeThe return type of the methodfinal LabelA label pointing to the start of the methodFields inherited from class org.jfuncmachine.compiler.model.SourceElement
filename, lineNumber -
Constructor Summary
ConstructorsConstructorDescriptionMethodDef(String name, int access, Field[] parameters, Type returnType, boolean isTailCallable, Expression body) Create a method definitionMethodDef(String name, int access, Field[] parameters, Type returnType, boolean isTailCallable, Expression body, String filename, int lineNumber) Create a method definitionMethodDef(String name, int access, Field[] parameters, Type returnType, Expression body) Create a method definitionMethodDef(String name, int access, Field[] parameters, Type returnType, Expression body, boolean isLambda, String filename, int lineNumber) Create a method definitionMethodDef(String name, int access, Field[] parameters, Type returnType, Expression body, String filename, int lineNumber) Create a method definition -
Method Summary
Modifier and TypeMethodDescriptionGets the return type of this methodReturns a version of this method that can be called from the JFuncMachines tail call optimizationvoidreset()Resets this method back to its original state so it can be regenerated (clears data that was created during code generation)Methods inherited from class org.jfuncmachine.compiler.model.SourceElement
generateException
-
Field Details
-
name
The name of the method -
access
public final int accessThe access flags of the method (e.g. Access.PUBLIC + Access.STATIC) -
parameters
The name and type of each parameter -
body
The expression that this method executes -
returnType
The return type of the method -
startLabel
A label pointing to the start of the method -
isTailCallable
public final boolean isTailCallableIf true, this method can be called using the tail call elimination mechanism implemented by JFuncMachine -
numCapturedParameters
public int numCapturedParametersUsed by Lambda to indicate how many method parameters were captured from the lambda environment. This allows the Recur method to know how many parameters to expect and how to call the lambda function properly. -
isLambda
public final boolean isLambdaTrue if this method def is for a lambda
-
-
Constructor Details
-
MethodDef
Create a method definition- Parameters:
name- The name of the methodaccess- The access flags of the methodparameters- The name and type of each parameterreturnType- The return type of the methodbody- The expression that this method executes
-
MethodDef
public MethodDef(String name, int access, Field[] parameters, Type returnType, Expression body, String filename, int lineNumber) Create a method definition- Parameters:
name- The name of the methodaccess- The access flags of the methodparameters- The name and type of each parameterreturnType- The return type of the methodbody- The expression that this method executesfilename- The name of the source file this method is defined inlineNumber- The line number in the source file where this method definition starts
-
MethodDef
public MethodDef(String name, int access, Field[] parameters, Type returnType, Expression body, boolean isLambda, String filename, int lineNumber) Create a method definition- Parameters:
name- The name of the methodaccess- The access flags of the methodparameters- The name and type of each parameterreturnType- The return type of the methodbody- The expression that this method executesisLambda- True if this method def is for a lambda functionfilename- The name of the source file this method is defined inlineNumber- The line number in the source file where this method definition starts
-
MethodDef
public MethodDef(String name, int access, Field[] parameters, Type returnType, boolean isTailCallable, Expression body) Create a method definition- Parameters:
name- The name of the methodaccess- The access flags of the methodparameters- The name and type of each parameterreturnType- The return type of the methodisTailCallable- If true, this method can be called using JFuncMachine's tail call optimizationbody- The expression that this method executes
-
MethodDef
public MethodDef(String name, int access, Field[] parameters, Type returnType, boolean isTailCallable, Expression body, String filename, int lineNumber) Create a method definition- Parameters:
name- The name of the methodaccess- The access flags of the methodparameters- The name and type of each parameterreturnType- The return type of the methodisTailCallable- If true, this method can be called using JFuncMachine's tail call optimizationbody- The expression that this method executesfilename- The name of the source file this method is defined inlineNumber- The line number in the source file where this method definition starts
-
-
Method Details
-
getTailCallVersion
Returns a version of this method that can be called from the JFuncMachines tail call optimization- Returns:
- A tail-callable version of this method
-
getReturnType
Gets the return type of this method- Returns:
- The return type of this method
-
reset
public void reset()Resets this method back to its original state so it can be regenerated (clears data that was created during code generation)
-