C0 Runtime
C0RT (C0 Runtime Instance)
A C0RT is an abstract class defined in ./src/types.d.ts
that contains following interface:
The actual C0VM state, heap allocator and all things are encapsulated into this Runtime instance.
When the function step_forward
is called, the C0VM will execute a single bytecode instruction from the .bc0
string given in constructor and returns a boolean
value.
If result is
true
, the VM can continue "step forward".If result is
false
, the VM either have executed all the commands in bytecode or have met a breakpoint.
C0VM_RuntimeState
Defined in ./src/vm_core/exec/state.ts
, the state C0VM_RuntimeState
is defined as follow:
constructor
method
Receives a raw byte code and initialize the virtual machine. The PC
will be set to the first byte in main
function.
step_forward
method
Execute a step in virtual machine, that is, execute a single bytecode instruction at the position PC
points to.
restart
method
This method is deprecated as it is an "anti-pattern" in current react framework. This method is here just to comply with C0RT
interface and should never be used.
clone method
Return a shallow copy of the state itself.
The clone
method in this class is to deal with the immutability requirement of React. Calling this function will return a shallow copy of original C0VM state.
debug
method
Returns a reference to the heap memory if DEBUG
option is set to true.
Last updated