Package com.oracle.truffle.sl.runtime
Class SLContext
java.lang.Object
com.oracle.truffle.sl.runtime.SLContext
The run-time state of SL during execution. The context is created by the
SLLanguage. It
is used, for example, by the eval builtin
function.
It would be an error to have two different context instances during the execution of one script. However, if two separate scripts run in one Java VM at the same time, they have a different context. Therefore, the context is not a singleton.
-
Constructor Summary
ConstructorsConstructorDescriptionSLContext(SLLanguage language, com.oracle.truffle.api.TruffleLanguage.Env env, List<com.oracle.truffle.api.dsl.NodeFactory<? extends SLBuiltinNode>> externalBuiltins) -
Method Summary
Modifier and TypeMethodDescriptionstatic Objectstatic SLContextget(com.oracle.truffle.api.nodes.Node node) com.oracle.truffle.api.instrumentation.AllocationReportercom.oracle.truffle.api.TruffleLanguage.EnvgetEnv()Return the current Truffle environment.Returns the registry of all functions that are currently defined.getInput()Returns the default input, i.e., the source for theSLReadlnBuiltin.The default default, i.e., the output for theSLPrintlnBuiltin.com.oracle.truffle.api.interop.TruffleObjectReturns an object that contains bindings that were exported across all used languages.voidinstallBuiltin(com.oracle.truffle.api.dsl.NodeFactory<? extends SLBuiltinNode> factory) com.oracle.truffle.api.CallTargetparse(com.oracle.truffle.api.source.Source source) voidpatchContext(com.oracle.truffle.api.TruffleLanguage.Env newEnv) Patches theSLContextto use a newTruffleLanguage.Env.voidRegister a function as a shutdown hook.voidRun registered shutdown hooks.
-
Constructor Details
-
SLContext
public SLContext(SLLanguage language, com.oracle.truffle.api.TruffleLanguage.Env env, List<com.oracle.truffle.api.dsl.NodeFactory<? extends SLBuiltinNode>> externalBuiltins)
-
-
Method Details
-
patchContext
public void patchContext(com.oracle.truffle.api.TruffleLanguage.Env newEnv) Patches theSLContextto use a newTruffleLanguage.Env. The method is called during the native image execution as a consequence ofContext.create(java.lang.String...).- Parameters:
newEnv- the newTruffleLanguage.Envto use.- See Also:
-
getEnv
public com.oracle.truffle.api.TruffleLanguage.Env getEnv()Return the current Truffle environment. -
getInput
Returns the default input, i.e., the source for theSLReadlnBuiltin. To allow unit testing, we do not useSystem.indirectly. -
getOutput
The default default, i.e., the output for theSLPrintlnBuiltin. To allow unit testing, we do not useSystem.outdirectly. -
getFunctionRegistry
Returns the registry of all functions that are currently defined. -
installBuiltin
-
getAllocationReporter
public com.oracle.truffle.api.instrumentation.AllocationReporter getAllocationReporter() -
fromForeignValue
-
parse
public com.oracle.truffle.api.CallTarget parse(com.oracle.truffle.api.source.Source source) -
getPolyglotBindings
public com.oracle.truffle.api.interop.TruffleObject getPolyglotBindings()Returns an object that contains bindings that were exported across all used languages. To read or write from this object theinteropAPI can be used. -
get
-
registerShutdownHook
Register a function as a shutdown hook. Only no-parameter functions are supported.- Parameters:
func- no-parameter function to be registered as a shutdown hook
-
runShutdownHooks
public void runShutdownHooks()Run registered shutdown hooks. This method is designed to be executed inTruffleLanguage.exitContext(Object, TruffleLanguage.ExitMode, int).
-