Module Main__.Eval

include 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.

val reduce : Main__.Vm.node_ref list -> (int * (Generator.lhs_inst list * Generator.rhs_inst list)) -> Main__.Vm.node_ref list option

Try to reduce one step with the given atoms and a rule

  • ルール適用に成功したら Some で包んだ更新された atom_list を返す
val run_once : Main__.Vm.node_ref list -> (int * (Generator.lhs_inst list * Generator.rhs_inst list)) list -> Main__.Vm.node_ref list option

Try reduce one step with the given atoms and rules

val init_atoms : (int * Generator.rhs_inst list) -> Main__.Vm.node_ref list

push the initial graph and return their references