- java.lang.Object
-
- org.kink_lang.kink.HostResultCore
-
- org.kink_lang.kink.Val
-
- All Implemented Interfaces:
HostResult
- Direct Known Subclasses:
BindingVal
,BinVal
,FunVal
,IntVal
,JavaVal
,LocVal
,NumVal
,RngVal
,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.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Val(Vm vm)
Constructs a val.protected
Val(Vm vm, VarMapping initialVarMapping)
Constructs a val with the initial var mapping.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BigInteger
getIdentity()
Returns the identity number of this val.Val
getVar(int symHandle)
Returns the target of the var specified bysym
; or null if absent.Set<Integer>
getVarSymHandleSet()
Returns the sym handle set of the vars of this val.boolean
hasVar(int symHandle)
Returns whether the val has the var specified bysym
.HostResultCore
makeHostResultCore()
Returns the core of the result, which the executor handles.void
setVar(int symHandle, Val val)
Assignsval
to the var specified bysymHandle
.
-
-
-
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 interfaceHostResult
- 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)
Assignsval
to the var specified bysymHandle
.- 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 bysym
; 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 bysym
.- Parameters:
symHandle
- the sym handle of the varl.- Returns:
- true if the val has the var specified by
sym
.
-
-