Class CallStaticMethod


public class CallStaticMethod extends Expression
An expression to invoke a static method. This method differs from the methods in the javainterop package in that it can apply certain optimizations. For example, if this method call is a recursive call to the method currently being defined, and the localTailCallsToLoops option is true, this expression updates the local variables representing the method parameters and jumps back to the beginning of the method. Likewise, if full tail recursion is enabled, this method should be used for any methods generated by JFuncMachine so it can implement the looping necessary to handle full tail calls.
  • Field Details

    • className

      public final String className
      The name of the class containing the method
    • name

      public final String name
      The name of the method
    • arguments

      public final Expression[] arguments
      The method argument values
    • parameterTypes

      public final Type[] parameterTypes
      The method parameter types
    • returnType

      public final Type returnType
      The return type of the method
  • Constructor Details

    • CallStaticMethod

      public CallStaticMethod(String className, String name, Type[] parameterTypes, Type returnType, Expression[] arguments)
      Create a static method invocation
      Parameters:
      className - The name of the class containing the method
      name - The name of the method
      parameterTypes - The method parameter types
      returnType - The method return type
      arguments - The method argument values
    • CallStaticMethod

      public CallStaticMethod(String className, String name, Type[] parameterTypes, Type returnType, Expression[] arguments, String filename, int lineNumber)
      Create a static method invocation
      Parameters:
      className - The name of the class containing the method
      name - The name of the method
      parameterTypes - The method parameter types
      returnType - The method return type
      arguments - The method argument values
      filename - The source filename this expression is associated with
      lineNumber - The source line number this expression is associated with
    • CallStaticMethod

      public CallStaticMethod(String name, Type[] parameterTypes, Type returnType, Expression[] arguments)
      Create a static method invocation
      Parameters:
      name - The name of the method
      parameterTypes - The method parameter types
      returnType - The method return type
      arguments - The method argument values
    • CallStaticMethod

      public CallStaticMethod(String name, Type[] parameterTypes, Type returnType, Expression[] arguments, String filename, int lineNumber)
      Create a static method invocation
      Parameters:
      name - The name of the method
      parameterTypes - The method parameter types
      returnType - The method return type
      arguments - The method argument values
      filename - The source filename this expression is associated with
      lineNumber - The source line number this expression is associated with
    • CallStaticMethod

      public CallStaticMethod(Type[] parameterTypes, Type returnType, Expression[] arguments)
      Create a static method invocation that calls the current method recursively
      Parameters:
      parameterTypes - The method parameter types
      returnType - The method return type
      arguments - The method argument values
    • CallStaticMethod

      public CallStaticMethod(Type[] parameterTypes, Type returnType, Expression[] arguments, String filename, int lineNumber)
      Create a static method invocation that calls the current method recursively
      Parameters:
      parameterTypes - The method parameter types
      returnType - The method return type
      arguments - The method argument values
      filename - The source filename this expression is associated with
      lineNumber - The source line number this expression is associated with
  • Method Details

    • getType

      public Type getType()
      Description copied from class: Expression
      Get the type returned by this expression
      Specified by:
      getType in class Expression
      Returns:
      The type of this expression
    • reset

      public void reset()
      Description copied from class: Expression
      Resets any labels in expressions so that the method can be regenerated
      Overrides:
      reset in class Expression
    • findCaptured

      public void findCaptured(Environment env)
      Description copied from class: Expression
      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.
      Specified by:
      findCaptured in class Expression
      Parameters:
      env - The environment chain to search
    • convertToFullTailCalls

      public Expression convertToFullTailCalls(boolean inTailPosition)
      Description copied from class: Expression
      Converts this expression to one that is compatible with full tail call optimization
      Specified by:
      convertToFullTailCalls in class Expression
      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 void generate(ClassGenerator generator, Environment env, boolean inTailPosition)
      Description copied from class: Expression
      Generate the bytecode for this expression
      Specified by:
      generate in class 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