java.lang.Object
org.kink_lang.kink.Vm
A Kink vm.
-
Field Summary
Modifier and TypeFieldDescriptionfinal BinHelper
The helper for bin vals.final BindingHelper
The helper for env vals.final BoolHelper
The helper for bool vals.final ComponentRegistry
The component registry.final ExceptionHelper
The helper for exception vals.final FunHelper
The helper of funs.final GraphFacade
The facade for the Execution Graph DSL.final JavaHelper
The helper for java vals.final LocationHelper
The helper for location vals.final Val
The nada val.final NumHelper
The helper for num vals.final SharedVarsFactory
The factory of SharedVars.final StrHelper
The helper for str vals.final SymRegistry
The registry of syms.final TraceHelper
The helper for trace vals.final VarrefHelper
The helper for varref vals.final VecHelper
The helper for vec vals. -
Method Summary
Modifier and TypeMethodDescriptionfinal Val
newVal()
Returns a new val.final Val
newVal
(SharedVars sharedVars) Returns a new val with the shared vars.static Vm
newVm()
Returns a new vm.<T> T
run
(HostFunAction bootstrapAction, Function<? super Val, ? extends T> onReturned, Function<? super ExceptionVal, ? extends T> onRaised) Runs a new execution stack which starts from the bootstrap action.
-
Field Details
-
nada
The nada val. -
bool
The helper for bool vals. -
binding
The helper for env vals. -
num
The helper for num vals. -
str
The helper for str vals. -
bin
The helper for bin vals. -
fun
The helper of funs. -
varref
The helper for varref vals. -
exception
The helper for exception vals. -
vec
The helper for vec vals. -
trace
The helper for trace vals. -
location
The helper for location vals. -
java
The helper for java vals. -
sym
The registry of syms. -
graph
The facade for the Execution Graph DSL. -
component
The component registry.
-
-
Method Details
-
newVm
Returns a new vm.- Returns:
- a new vm.
-
newVal
Returns a new val.- Returns:
- a new val.
-
run
public <T> T run(HostFunAction bootstrapAction, Function<? super Val, ? extends T> onReturned, Function<? super ExceptionVal, ? extends T> onRaised) Runs a new execution stack which starts from the bootstrap action.The execution starts from
bootstrapAction
.If the execution succeeds with a result, the method invokes
onReturned
with the result val. If the execution fails, the method invokesonRaised
with the exception.Example:
FunVal fun = ...; boolean isSuccess = vm.run( c -> c.call(fun).args(x, y), result -> { System.out.printf("OK!: %s%n", result); return true; }, exc -> { System.out.printf("Bad: %s", exc); return false; } );
- Type Parameters:
T
- the result type ofonReturned
andonRaised
.- Parameters:
bootstrapAction
- the action which is called to start the execution.onReturned
- called when the execution succeeds with a result.onRaised
- called when the execution fails with an exception.- Returns:
- the result of
onReturned
oronRaised
.
-