Class Expression

java.lang.Object
org.jfuncmachine.compiler.model.SourceElement
org.jfuncmachine.compiler.model.expr.Expression
Direct Known Subclasses:
ArrayGet, ArraySet, Binding, BindingRecurse, Block, BooleanConstant, Box, ByteConstant, CallJavaConstructor, CallJavaInterface, CallJavaMethod, CallJavaSpecialMethod, CallJavaStaticMethod, CallJavaSuperConstructor, CallMethod, CallStaticMethod, CallTailCallMethod, CallTailCallStaticMethod, Cast, CharConstant, ClassConstant, DoubleConstant, EnumSwitch, FloatConstant, GetJavaField, GetJavaStaticField, GetValue, If, InitializeEnum, InlineCall, IntConstant, IntSwitch, Invoke, Lambda, LocalRecurse, LongConstant, NewArray, NewArrayWithValues, Noop, NullConstant, ObjectConstant, PartialCall, SetJavaField, SetJavaStaticField, SetValue, ShortConstant, StringConstant, Throw, ToByte, ToChar, ToDouble, ToFloat, ToInt, ToLong, ToShort, ToUnit, TryCatchFinally, TypeSwitch, Unbox

public abstract class Expression extends SourceElement
Base class for all JFuncMachine expressions
  • Constructor Details

    • Expression

      public Expression(String filename, int lineNumber)
      Create an expression associated with a specific filename and line number
      Parameters:
      filename - The source filename this expression occurs in, or null
      lineNumber - The line number this expression occurs on
  • Method Details

    • getType

      public abstract Type getType()
      Get the type returned by this expression
      Returns:
      The type of this expression
    • findCaptured

      public abstract void findCaptured(Environment env)
      Search for local variables that would be captured by a lambda. Each expression has its own implementation of this, because each subexpression must be searched.
      Parameters:
      env - The environment chain to search
    • reset

      public void reset()
      Resets any labels in expressions so that the method can be regenerated
    • convertToFullTailCalls

      public abstract Expression convertToFullTailCalls(boolean inTailPosition)
      Converts this expression to one that is compatible with full tail call optimization
      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

      public abstract void generate(ClassGenerator generator, Environment env, boolean inTailPosition)
      Generate the bytecode for this expression
      Parameters:
      generator - The generator for generating instructions and additional declarations
      env - The environment containing the local variables currently visible to this expression
      inTailPosition - True if this expression is being generated from the tail position of the method