class Ven::Suite::Snippet
- Ven::Suite::Snippet
- Reference
- Object
Overview
A snippet is a mutable collection of instructions emitted under one label.
Defined in:
ven/suite/snippet.crConstructors
Class Method Summary
-
.core
Returns a new snippet with a fictious label.
Instance Method Summary
-
#add(opcode : Opcode, argument : IArg, line : Int32)
Adds to this chunk an instruction with the given opcode, argument and line.
- #code : Array(Instruction)
-
#for(count : Int32, &)
Iterates over this snippet's instructions in chunks of size count, but advances one instruction at a time.
- #label : Label
-
#remove(start, count : Int32)
Removes a blob of instructions starting at start and of size count.
-
#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
Constructor Detail
Class Method Detail
Instance Method Detail
Adds to this chunk an instruction with the given opcode, argument and line.
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.
Removes a blob of instructions starting at start and of size count.
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.