Struct stack_vm::Code [] [src]

pub struct Code<T> {
    pub symbols: Vec<(usize, String)>,
    pub code: Vec<usize>,
    pub data: Vec<T>,
    pub labels: Vec<(usize, String)>,
}

A structure containing runnable or dumpable code.

See the module-level docs for more details.

Fields

Methods

impl<T: Debug> Code<T>
[src]

[src]

Create a code object from a builder.

This function consumes the builder, making it unusable after it has been converted.

[src]

Create an empty code.

Not useful for anything except tests and documentation.

[src]

Retrieve a list of all symbols in the code.

This is a list of tuples containing op codes and instruction names.

[src]

Retrieve a list of instructions in the code.

This is the executable source program of the code. It is a simple format based around the following:

| Op Code | No of args | Args ...         |
| 0x01    | 0x03       | 0x01, 0x02, 0x03 |

[src]

Retrieve the constant data compiled into the code.

[src]

Retrieve a list of labels used in the program.

Returns a list of tuples containing the IP of the label and the name of the label.

[src]

Returns the IP for a given label.

This function is used within the Machine to perform jumps.

Trait Implementations

impl<T: ToByteCode + Debug> ToByteCode for Code<T>
[src]

[src]

Create bytecode for this Code.

Encodes into a Map of the following format: json { "code" => [ 0, 1, 0, 0, 1, 1, 1, 0 ], "data" => [ 123, 456 ], "symbols" => [ 0, "push", 1, "add" ], "labels" => [ 0, "main" ] }

impl<T: FromByteCode + Debug> FromByteCode for Code<T>
[src]

[src]

Convert from MsgPack to your type. Read more

impl<T: Debug> Debug for Code<T>
[src]

[src]

Formats the value using the given formatter.