class Ven::Suite::Snippet

Overview

A snippet is a mutable collection of instructions emitted under one label.

Defined in:

ven/suite/snippet.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(label : Ven::Suite::Label) #

[View source]

Class Method Detail

def self.core #

Returns a new snippet with a fictious label.


[View source]

Instance Method Detail

def add(opcode : Opcode, argument : IArg, line : Int32) #

Adds to this chunk an instruction with the given opcode, argument and line.


[View source]
def code : Array(Instruction) #

[View source]
def for(count : Int32, &) #

Iterates over this snippet's instructions in chunks of size count, but advances one instruction at a time. Stops iterating when there are not enough values to make a full chunk.

Yields the chunk and the current iteration index to the block.


[View source]
def label : Label #

[View source]
def remove(start, count : Int32) #

Removes a blob of instructions starting at start and of size count.


[View source]
def replace(start : Int32, count : Int32, opcode : Opcode, argument : IArg) #

Replaces a blob of instructions starting at start and of size count with one instruction, given its opcode and argument

The line number of the replacee instruction is computed from the line number of the first instruction in the blob-to-replace.


[View source]