Package com.cloudbees.groovy.cps
Class Continuable
java.lang.Object
com.cloudbees.groovy.cps.Continuable
- All Implemented Interfaces:
Serializable
Mutable representation of the program. This is the primary API of the groovy-cps library to the outside.
- Author:
- Kohsuke Kawaguchi
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionUsers of this library must pass (at least) these toGroovyCategorySupport.use(List, Closure)during all operations.static final StackTraceElementThe artificialStackTraceElementthat appears in the stack trace when the CPS library fixes up the stack trace. -
Constructor Summary
ConstructorsConstructorDescriptionContinuable(Block block) Creates aContinuablethat executes the block of code in a fresh empty environment.Continuable(Block block, Env e) Creates aContinuablethat executes the block in the specified environment.Continuable(Continuable src) Continuable(Next n) Continuable(groovy.lang.Script cpsTransformedScript) Continuable(groovy.lang.Script cpsTransformedScript, Env env) Takes aScriptcompiled from CPS-transformingGroovyShelland wraps that into aContinuable, in the context of the givenEnv.Continuable(groovy.lang.Script cpsTransformedScript, Env env, Continuation k) -
Method Summary
Modifier and TypeMethodDescriptionReturns the stack trace in the CPS-transformed code that indicates where thisContinuablewill resume from.booleanChecks if thisContinuableis pointing at the end of the program which cannot be resumed.voidPrints the stack trace into the given writer, much likeThrowable.printStackTrace(PrintWriter)Deprecated.Resumes this program by either returning the value fromsuspend(Object)or throwing an exceptionrunByThrow(Throwable arg) Deprecated.static ObjectDeprecated.static Object
-
Field Details
-
categories
Users of this library must pass (at least) these toGroovyCategorySupport.use(List, Closure)during all operations. -
SEPARATOR_STACK_ELEMENT
The artificialStackTraceElementthat appears in the stack trace when the CPS library fixes up the stack trace. This separator separates the regular call stack that tracks the actual call stack JVM executes and the synthesized CPS call stack that CPS-transformed program is logically executing.
-
-
Constructor Details
-
Continuable
-
Continuable
-
Continuable
Creates aContinuablethat executes the block of code in a fresh empty environment. -
Continuable
Creates aContinuablethat executes the block in the specified environment. -
Continuable
public Continuable(groovy.lang.Script cpsTransformedScript) -
Continuable
Takes aScriptcompiled from CPS-transformingGroovyShelland wraps that into aContinuable, in the context of the givenEnv. The added 'env' parameter can be used to control the execution flow in case of exceptions, and/or providing customInvoker -
Continuable
Takes aScriptcompiled from CPS-transformingGroovyShelland wraps that into aContinuable. The added 'k' parameter can be used to pass the control to somewhere else when the script has finished executing.
-
-
Method Details
-
printStackTrace
Prints the stack trace into the given writer, much likeThrowable.printStackTrace(PrintWriter) -
run
Deprecated.Starts/resumes this program until it suspends the next time.- Throws:
InvocationTargetException- if the program threw an exception that it didn't handle by itself.
-
runByThrow
Deprecated.- Throws:
InvocationTargetException
-
run0
Resumes this program by either returning the value fromsuspend(Object)or throwing an exception -
isResumable
public boolean isResumable()Checks if thisContinuableis pointing at the end of the program which cannot be resumed. -
suspend
Deprecated.Called from within CPS transformed program to suspends the execution.When this method is called, the control goes back to the caller of
run(Object), which returns with the argument given to this method.When the continuable is resumed via
run(Object)later, the argument to the run method will become the return value from this method to the CPS-transformed program. -
suspend
-
getStackTrace
Returns the stack trace in the CPS-transformed code that indicates where thisContinuablewill resume from. If this object represents a yet-started program, an empty list will be returned.
-