Class Vm

  • public class Vm
    extends Object
    A Kink vm.
    • Field Detail

      • nada

        public final Val nada
        The nada val.
      • bool

        public final BoolHelper bool
        The helper for bool vals.
      • binding

        public final BindingHelper binding
        The helper for env vals.
      • num

        public final NumHelper num
        The helper for num vals.
      • str

        public final StrHelper str
        The helper for str vals.
      • bin

        public final BinHelper bin
        The helper for bin vals.
      • fun

        public final FunHelper fun
        The helper of funs.
      • varref

        public final VarrefHelper varref
        The helper for varref vals.
      • vec

        public final VecHelper vec
        The helper for vec vals.
      • trace

        public final TraceHelper trace
        The helper for trace vals.
      • loc

        public final LocHelper loc
        The helper for loc vals.
      • java

        public final JavaHelper java
        The helper for java vals.
      • sym

        public final SymRegistry sym
        The registry of syms.
      • graph

        public final GraphFacade graph
        The facade for the Execution Graph DSL.
    • Method Detail

      • newVm

        public static Vm newVm()
        Returns a new vm.
        a new vm.
      • newVal

        public final Val newVal()
        Returns a new val.
        a new val.
      • newVal

        public final Val newVal​(VarMapping initialVarMapping)
        Returns a new val with the initial var mapping.

        The contents of the initialVarMapping override the common ones.

        initialVarMapping - the initial var mapping for the new val.
        a new val.
      • run

        public <T> T run​(ThrowingFunction1<? super HostContext,​HostResult> bootstrapAction,
                         Function<Val,​T> onReturned,
                         BiFunction<String,​List<TraceVal>,​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 invokes onRaised with the exception message and the traces.


         FunVal fun = ...;
         boolean isSuccess =
              c ->, y),
              result -> { System.out.printf("OK!: %s%n", result); return true; },
              (msg, traces) -> { System.out.printf("Bad: %s %s", msg, traces); return false; }
        Type Parameters:
        T - the result type of onReturned and onRaised.
        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.
        the result of onReturned or onRaised.