[][src]Struct jsyc_compiler::bytecode::Bytecode

pub struct Bytecode {
    pub elements: Vec<BytecodeElement>,
}

Represents the bytecode produced by the compiler.

Bytecode is a wrapper for a list of bytecode elements. It offers an API to extend it by other bytecode, commands or labels.

use jsyc_compiler::{Bytecode, Operation, Instruction, Operand};

let bytecode = Bytecode::new()
                 .add(Operation::new(Instruction::LoadNum,
                                   vec![Operand::Reg(10), Operand::ShortNum(10)]))
                 .add(Operation::new(Instruction::Add,
                                   vec![Operand::Reg(10), Operand::Reg(9)]));

Fields

elements: Vec<BytecodeElement>

Methods

impl Bytecode[src]

pub fn new() -> Self[src]

pub fn add(self, command: Operation) -> Self[src]

pub fn add_label(self, label: Label) -> Self[src]

Appends a label as bytecode element.

pub fn add_bytecode(self, other: Bytecode) -> Self[src]

Appends another bytecode onto this bytecode.

pub fn encode_base64(&self) -> String[src]

Returns the base64-encoded bytecode as string.

pub fn last_op_is_return(&self) -> bool[src]

Checks whether the last element is a return instruction.

pub fn commands_iter_mut(&mut self) -> impl Iterator<Item = &mut Operation>[src]

Returns an iterator over all commands in the bytecode.

Trait Implementations

impl ToBytes for Bytecode[src]

impl PartialEq<Bytecode> for Bytecode[src]

impl Clone for Bytecode[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Bytecode[src]

impl Display for Bytecode[src]

impl FromIterator<Bytecode> for Bytecode[src]

Auto Trait Implementations

impl Send for Bytecode

impl Sync for Bytecode

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]