Package com.cloudbees.groovy.cps
Interface Env
- All Superinterfaces:
Serializable
- All Known Subinterfaces:
DepthTrackingEnv
- All Known Implementing Classes:
BlockScopeEnv,CaseEnv,FunctionCallEnv,ProxyEnv,TryBlockEnv
Represents an environment in which
Block is evaluated.
In the Harvard architecture terms,
Block is instruction and Env is data.
This interface is not to be implemented outside this library.
See cps-model.md
- Author:
- Kohsuke Kawaguchi
-
Method Summary
Modifier and TypeMethodDescriptionvoidbuildStackTraceElements(List<StackTraceElement> stack, int depth) Builds the current call stack information forThrowable.getStackTrace().Closure instance or 'this' object that surrounds the currently executing code.voiddeclareVariable(Class type, String name) Defines a local variable in the current environment.getBreakAddress(String label) If we see a break statement, where should we go?getContinueAddress(String label) If we see a continue statement, where should we go?getExceptionHandler(Class<? extends Throwable> type) Finds the exception handler that catches aThrowableinstance of this type.Invokeris typically scoped at the whole execution.getLocalVariable(String name) Obtains the current value of a local variable in the current environment.getLocalVariableType(String name) Where should the return statement return to?voidsetLocalVariable(String name, Object value) Sets the local variable to a new value.
-
Method Details
-
declareVariable
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.Objectwhen unknown/implicit (e.g. "def x")name- Name of the local variable.- See Also:
-
getLocalVariable
Obtains the current value of a local variable in the current environment.- Parameters:
name- Name of the local variable.- See Also:
-
setLocalVariable
Sets the local variable to a new value.- Parameters:
name- Name of the local variable.value- New value- See Also:
-
getLocalVariableType
-
closureOwner
Object closureOwner()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.
-
getReturnAddress
Continuation getReturnAddress()Where should the return statement return to? -
getBreakAddress
If we see a break statement, where should we go?- 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
If we see a continue statement, where should we go?- 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
Finds the exception handler that catches aThrowableinstance of this type.- Returns:
- never null. Even if there's no user-specified exception handler, the default 'unhandled exception handler' must be returned.
-
buildStackTraceElements
Builds the current call stack information forThrowable.getStackTrace().- Parameters:
depth- Maximum depth of stack trace to obtain.
-
getInvoker
Invoker getInvoker()Invokeris typically scoped at the whole execution.- Returns:
- never null
-