public final class TruffleContext.Builder extends Object
TruffleContext instances.| Modifier and Type | Method and Description |
|---|---|
TruffleContext |
build()
Builds the new context instance.
|
TruffleContext.Builder |
config(String key,
Object value)
Sets a config parameter that the child context of this language can access using
TruffleLanguage.Env.getConfig(). |
TruffleContext.Builder |
initializeCreatorContext(boolean enabled)
Specifies whether the creating language context should be initialized in the new context.
|
TruffleContext.Builder |
onCancelled(Runnable r)
|
TruffleContext.Builder |
onClosed(Runnable r)
Specifies a
Runnable that will be executed when some operation on the new context
attenmpted while the context is already TruffleContext.close() closed}. |
TruffleContext.Builder |
onExited(Consumer<Integer> r)
Specifies a
Consumer that will be executed when the new context is
hard-exited and the exit exception is about
to reach the outer context, or when some operation on the new context is attempted while
the context is already hard-exited. |
public TruffleContext.Builder config(String key, Object value)
TruffleLanguage.Env.getConfig().public TruffleContext.Builder initializeCreatorContext(boolean enabled)
public TruffleContext.Builder onCancelled(Runnable r)
Runnable that will be executed when the new context is
cancelled and the cancel exception is
about to reach the outer context, or when some operation on the new context is attempted
while the context is already cancelled. However, the runnable will only be executed if
the outer context is not cancelled.
The purpose of the runnable is to allow throwing a custom guest exception before the
cancel exception reaches the outer context, so that the outer context can properly handle
the exception. In case the runnable does not throw any exception, an internal error is
thrown (should not be caught).public TruffleContext.Builder onExited(Consumer<Integer> r)
Consumer that will be executed when the new context is
hard-exited and the exit exception is about
to reach the outer context, or when some operation on the new context is attempted while
the context is already hard-exited. However, the consumer will only be executed if the
outer context is not hard-exited.
The purpose of the consumer is to allow throwing a custom guest exception before the exit
exception reaches the outer context, so that the outer context can properly handle the
exception. In case the consumer does not throw any exception, an internal error is thrown
(should not be caught).
The single input argument to the Consumer is the exit code.public TruffleContext.Builder onClosed(Runnable r)
Runnable that will be executed when some operation on the new context
attenmpted while the context is already TruffleContext.close() closed}. However,
the runnable will only be executed if the outer context is not closed.
The purpose of the runnable is to allow throwing a custom guest exception before the
close exception reaches the outer context, so that the outer context can properly handle
the exception. In case the runnable does not throw any exception, an internal error is
thrown (should not be caught).public TruffleContext build()