Module Main__.Vm

type vm_atom =
| VMAtom of string * node_ref array
| VMInd of node_ref Stdlib.ref
and node_ref = (int * vm_atom) Stdlib.ref

(indeg, atom)

val null_ptr : (int * vm_atom) Stdlib.ref

レジスタを初期化するためだけのアドレス(本来はいらない)

type register = node_ref array

レジスタ

val init_register : int -> (int * vm_atom) Stdlib.ref array

初期状態のレジスタを確保する

val deref_symbol_atom : ('a * vm_atom) Stdlib.ref -> string * node_ref array

シンボルアトムへの参照を dereference する

val free_atom : ('a * vm_atom) Stdlib.ref -> unit

Free memory fragment of the given address. Possibly implemented with option type and assign None.

val traverse : int -> node_ref -> node_ref

Traverse indirection atoms and returns the pointing symbol atom. There is no worring of circulating indirection (if that exists, then the basic design is wrong). If the given pointer points to an indirection atom, decrease the reference counter by the given ref_count (which is 1 if this is pointed by a symbol atom)

returns

the reference to a symbol atom

val clean_atom_list : ('a * vm_atom) Stdlib.ref list -> unit

Resolve indirections and clean up the given atom list. Supposed to be called in the end of the program execution.