- All Known Subinterfaces:
 CallContext
public interface HostContext
Context of an action of a host fun.
 
The context is valid during invocation of the lambda of
 HostFunBuilder.action(ThrowingFunction1)
 or CallFlowToOn.on(HostFunReaction).
See org.kink_lang.kink.hostfun for usage.
- 
Method Summary
Modifier and TypeMethodDescriptionReturns a call flow to call a fun in the specified mod with no args.Returns a call flow to call the fun, with nada as the recv and no args.Returns a call flow to evaluate the graph.Returns a call flow to call a method ofownerRecvwith no args.Returns a HostResult to raise an exception.Returns a HostResult to raise an exception made from the Java throwable.traces()Returns the traces of the current execution stack, which is the result of traces instruction. 
- 
Method Details
- 
traces
Returns the traces of the current execution stack, which is the result of traces instruction.The traces are ordered from the bottom to the top, unlike stack trace in Java.
- Returns:
 - the traces to the current execution stack.
 
 - 
raise
Returns a HostResult to raise an exception.- Parameters:
 msg- the message of the exception.- Returns:
 - a HostResult to raise an exception.
 
 - 
raise
Returns a HostResult to raise an exception made from the Java throwable.- Parameters:
 throwable- the throwable of which a kink exception is made.- Returns:
 - a HostResult to raise an exception.
 
 - 
call
Returns a call flow to call the fun, with nada as the recv and no args.Example:
FunVal curry2 = vm.fun.make("curry2($fun)").take(1).action(c -> { if (! (c.arg(0) instanceof FunVal fun)) { return c.call(vm.graph.raiseFormat("curry2($fun): required a fun, but got {}", vm.graph.repr(c.arg(0)))); } FunVal curried = vm.fun.make().take(1).action(cc -> { Val a0 = cc.arg(0); return vm.fun.make().take(1).action(c3 -> { Val a1 = c3.arg(0); return c3.call(fun).args(a0, a1); }); }); });- Parameters:
 fun- the fun.- Returns:
 - a call flow to call the fun.
 
 - 
call
Returns a call flow to call a method ofownerRecvwith no args.The ownerRecv is also set as the recv of the call.
Example:
int opAddHandle = vm.sym.handleFor("op_add"); FunVal increment = vm.fun.make().take(1).action(c -> { Val n = c.arg(0); // call “n + 1” return c.call(n, opAddHandle).args(vm.num.of(1)); });If the specified var is empty, or the target of the var is not a fun, call() method returns a call flow which raises an exception.
- Parameters:
 ownerRecv- the owner and the recv of the method.symHandle- the sym handle of the method.- Returns:
 - a call flow with the fun.
 
 - 
call
Returns a call flow to call a fun in the specified mod with no args.nada is set as the recv of the call.
Example:
int exit = vm.sym.handleFor("exit"); FunVal abort = vm.fun.make().take(0).action( c -> c.call("kink/PROCESS", exit).args(vm.num.of(1)));If the specified fun is empty, or the target of the var is not a fun, call() method returns a call flow which raises an exception.
- Parameters:
 modName- the name of the mod containing the fun.symHandle- the sym handle of the fun.- Returns:
 - a call flow.
 
 - 
call
Returns a call flow to evaluate the graph.Example:
FunVal abs = vm.fun.make().take(0).action(c -> { if (! (c.arg(0) instanceof NumVal num)) { return c.call(vm.graph.raiseFormat("unknown val {}", vm.graph.repr(c.arg(0)))); } return vm.num.of(num.bigDecimal().abs()); });- Parameters:
 graph- the graph to evaluate.- Returns:
 - a call flow to evaluate the graph.
 
 
 -