Class Val

  • All Implemented Interfaces:
    HostResult
    Direct Known Subclasses:
    BinVal, EnvVal, FunVal, IntVal, JavaVal, LocVal, NumVal, StrVal, TraceVal, VarrefVal, VecVal

    public class Val
    extends HostResultCore
    implements HostResult
    A Kink value or val.

    Implementation note: variables

    Variables of a Val are internally layered as three VarMappings:

    • commonVarMapping: immutable var mapping shared among all the vals.
    • traitVarMapping: immutable var mapping shared among a particular type of vals, which can override vars in commonVarMapping.
    • ownVarMapping: mutable var mapping exclusively owned by a val, which can override vars in commonVarMapping and traitVarMapping.

    setVar(int, Val) modifies the ownVarMapping.

    • Field Detail

      • vm

        public final Vm vm
        The vm.
    • Constructor Detail

      • Val

        protected Val​(Vm vm)
        Constructs a val.
        Parameters:
        vm - the vm.
      • Val

        protected Val​(Vm vm,
                      VarMapping initialVarMapping)
        Constructs a val with the initial var mapping.
        Parameters:
        vm - the vm.
        initialVarMapping - the initial var mapping.
    • Method Detail

      • makeHostResultCore

        public HostResultCore makeHostResultCore()
        Description copied from interface: HostResult
        Returns the core of the result, which the executor handles.

        This method is intended to be used by the Kink runtime implementation. Do not call this method from your program.

        Specified by:
        makeHostResultCore in interface HostResult
        Returns:
        the core of the result.
      • getIdentity

        public final BigInteger getIdentity()
        Returns the identity number of this val.

        The identity number is unique within the vm.

        Returns:
        the identity number of this val.
      • setVar

        public void setVar​(int symHandle,
                           Val val)
        Assigns val to the var specified by symHandle.
        Parameters:
        symHandle - the sym handle of the var.
        val - the val to be assigned.
      • getVar

        @Nullable
        public Val getVar​(int symHandle)
        Returns the target of the var specified by sym; or null if absent.
        Parameters:
        symHandle - the sym handle of the var.
        Returns:
        the target of the var specified by sym; or null if absent.
      • hasVar

        public boolean hasVar​(int symHandle)
        Returns whether the val has the var specified by sym.
        Parameters:
        symHandle - the sym handle of the varl.
        Returns:
        true if the val has the var specified by sym.
      • getVarSymHandleSet

        public Set<Integer> getVarSymHandleSet()
        Returns the sym handle set of the vars of this val.
        Returns:
        the sym handle set of the vars of this val.