Package com.cloudbees.groovy.cps.impl
Class FunctionCallEnv
java.lang.Object
com.cloudbees.groovy.cps.impl.FunctionCallEnv
- All Implemented Interfaces:
DepthTrackingEnv,Env,Serializable
- Author:
- Kohsuke Kawaguchi
- See Also:
-
Field Summary
Fields inherited from interface com.cloudbees.groovy.cps.DepthTrackingEnv
MAX_LEGAL_DEPTH -
Constructor Summary
ConstructorsConstructorDescriptionFunctionCallEnv(Env caller, Continuation returnAddress, SourceLocation loc, Object _this) FunctionCallEnv(Env caller, Continuation returnAddress, SourceLocation loc, Object _this, int localsCount) -
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.final ContinuationgetBreakAddress(String label) If we see a break statement, where should we go?final ContinuationgetContinueAddress(String label) If we see a continue statement, where should we go?intgetDepth()Return how deep this environment is within nested closure/function calls.final ContinuationgetExceptionHandler(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) final ContinuationWhere should the return statement return to?getTypes()Because might deserialize old version of class with null value for fieldUsed when we are actually going to mutate the types infovoidsetInvoker(Invoker invoker) Sets theInvoker, which gets inherited through the call chain.voidsetLocalVariable(String name, Object value) Sets the local variable to a new value.toString()
-
Constructor Details
-
FunctionCallEnv
- 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
Description copied from interface:EnvDefines 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
Description copied from interface:EnvObtains the current value of a local variable in the current environment.- Parameters:
name- Name of the local variable.- See Also:
-
setLocalVariable
Description copied from interface:EnvSets the local variable to a new value.- Parameters:
name- Name of the local variable.value- New value- See Also:
-
closureOwner
Description copied from interface:EnvClosure 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
Because might deserialize old version of class with null value for field -
getTypesForMutation
Used when we are actually going to mutate the types info -
getLocalVariableType
- Specified by:
getLocalVariableTypein interfaceEnv
-
setInvoker
Sets theInvoker, which gets inherited through the call chain. -
getInvoker
Description copied from interface:EnvInvokeris typically scoped at the whole execution.- Specified by:
getInvokerin interfaceEnv- Returns:
- never null
-
getReturnAddress
Description copied from interface:EnvWhere should the return statement return to?- Specified by:
getReturnAddressin interfaceEnv
-
getBreakAddress
Description copied from interface:EnvIf we see a break statement, where should we go?- Specified by:
getBreakAddressin interfaceEnv- 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
Description copied from interface:EnvIf we see a continue statement, where should we go?- Specified by:
getContinueAddressin interfaceEnv- 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
Description copied from interface:EnvFinds the exception handler that catches aThrowableinstance of this type.- Specified by:
getExceptionHandlerin interfaceEnv- Returns:
- never null. Even if there's no user-specified exception handler, the default 'unhandled exception handler' must be returned.
-
buildStackTraceElements
Description copied from interface:EnvBuilds the current call stack information forThrowable.getStackTrace().- Specified by:
buildStackTraceElementsin interfaceEnvdepth- Maximum depth of stack trace to obtain.
-
getDepth
public int getDepth()Description copied from interface:DepthTrackingEnvReturn how deep this environment is within nested closure/function calls.- Specified by:
getDepthin interfaceDepthTrackingEnv
-
toString
-