Class ProxyEnv

java.lang.Object
com.cloudbees.groovy.cps.impl.ProxyEnv
All Implemented Interfaces:
DepthTrackingEnv, Env, Serializable
Direct Known Subclasses:
BlockScopeEnv, CaseEnv, TryBlockEnv

public class ProxyEnv extends Object implements DepthTrackingEnv
Env that delegates to another Env. Useful base class for Env impls.
Author:
Kohsuke Kawaguchi
See Also:
  • Field Details

    • parent

      protected final Env parent
  • Constructor Details

    • ProxyEnv

      public ProxyEnv(Env parent)
  • 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.
      Specified by:
      declareVariable in interface Env
      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.
      Specified by:
      getLocalVariable in interface Env
      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.
      Specified by:
      setLocalVariable in interface Env
      Parameters:
      name - Name of the local variable.
      value - New value
      See Also:
    • getLocalVariableType

      public Class getLocalVariableType(String name)
      Specified by:
      getLocalVariableType in interface Env
    • 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.

      Specified by:
      closureOwner in interface Env
    • getReturnAddress

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

      public 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 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 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.
    • 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
    • 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