Class FunctionCallEnv

java.lang.Object
com.cloudbees.groovy.cps.impl.FunctionCallEnv
All Implemented Interfaces:
DepthTrackingEnv, Env, Serializable

public class FunctionCallEnv extends Object
Author:
Kohsuke Kawaguchi
See Also:
  • Constructor Details

    • FunctionCallEnv

      public FunctionCallEnv(Env caller, Continuation returnAddress, SourceLocation loc, Object _this)
      Parameters:
      caller - The environment of the call site. Can be null but only if the caller is outside CPS execution.
    • FunctionCallEnv

      public FunctionCallEnv(Env caller, Continuation returnAddress, SourceLocation loc, Object _this, int localsCount)
  • Method Details

    • declareVariable

      public void declareVariable(Class type, String name)
      Description copied from interface: Env
      Defines a local variable in the current environment. This method is called when a variable declaration is encountered.
      Parameters:
      type - Type of the local variable. Object when unknown/implicit (e.g. "def x")
      name - Name of the local variable.
      See Also:
    • getLocalVariable

      public Object getLocalVariable(String name)
      Description copied from interface: Env
      Obtains the current value of a local variable in the current environment.
      Parameters:
      name - Name of the local variable.
      See Also:
    • setLocalVariable

      public void setLocalVariable(String name, Object value)
      Description copied from interface: Env
      Sets the local variable to a new value.
      Parameters:
      name - Name of the local variable.
      value - New value
      See Also:
    • closureOwner

      public Object closureOwner()
      Description copied from interface: Env
      Closure instance or 'this' object that surrounds the currently executing code.

      If a new closure instantiation is encountered, this is the object that becomes the owner of that closure.

      Dynamic property access inside closures are also resolved against this instance.

    • getTypes

      protected Map<String,Class> getTypes()
      Because might deserialize old version of class with null value for field
    • getTypesForMutation

      protected Map<String,Class> getTypesForMutation()
      Used when we are actually going to mutate the types info
    • getLocalVariableType

      public Class getLocalVariableType(String name)
      Specified by:
      getLocalVariableType in interface Env
    • setInvoker

      public void setInvoker(Invoker invoker)
      Sets the Invoker, which gets inherited through the call chain.
    • getInvoker

      public Invoker getInvoker()
      Description copied from interface: Env
      Invoker is typically scoped at the whole execution.
      Specified by:
      getInvoker in interface Env
      Returns:
      never null
    • getReturnAddress

      public final Continuation getReturnAddress()
      Description copied from interface: Env
      Where should the return statement return to?
      Specified by:
      getReturnAddress in interface Env
    • getBreakAddress

      public final Continuation getBreakAddress(String label)
      Description copied from interface: Env
      If we see a break statement, where should we go?
      Specified by:
      getBreakAddress in interface Env
      Parameters:
      label - Specifies the loop to break from. null for nearest loop.
      Returns:
      For semantically correct Groovy code, the return value is never null, because not having the matching label is a compile-time error.
    • getContinueAddress

      public final Continuation getContinueAddress(String label)
      Description copied from interface: Env
      If we see a continue statement, where should we go?
      Specified by:
      getContinueAddress in interface Env
      Parameters:
      label - Specifies the loop to repeat. null for nearest loop.
      Returns:
      For semantically correct Groovy code, the return value is never null, because not having the matching label is a compile-time error.
    • getExceptionHandler

      public final Continuation getExceptionHandler(Class<? extends Throwable> type)
      Description copied from interface: Env
      Finds the exception handler that catches a Throwable instance of this type.
      Specified by:
      getExceptionHandler in interface Env
      Returns:
      never null. Even if there's no user-specified exception handler, the default 'unhandled exception handler' must be returned.
    • buildStackTraceElements

      public void buildStackTraceElements(List<StackTraceElement> stack, int depth)
      Description copied from interface: Env
      Builds the current call stack information for Throwable.getStackTrace().
      Specified by:
      buildStackTraceElements in interface Env
      depth - Maximum depth of stack trace to obtain.
    • getDepth

      public int getDepth()
      Description copied from interface: DepthTrackingEnv
      Return how deep this environment is within nested closure/function calls.
      Specified by:
      getDepth in interface DepthTrackingEnv
    • toString

      public String toString()
      Overrides:
      toString in class Object