Skip to main content

Crate tishlang_bytecode

Crate tishlang_bytecode 

Source
Expand description

Bytecode compiler for Tish. Compiles AST to stack-based bytecode for VM execution.

Structs§

Chunk
A bytecode chunk: instructions and associated data.
CompileError

Enums§

Constant
A constant in the constants table.
MathBinaryFn
The binary Math functions the Opcode::MathBinary fast path recognizes (#203). (f64, f64) → f64; the discriminant is the opcode operand. Kept in sync with the VM handler and JIT lowering. (hypot is intentionally NOT here — it stays a correct generic call to avoid replicating its scaled-sum-of-squares in this below-builtins crate.)
MathUnaryFn
The unary Math functions the Opcode::MathUnary fast path recognizes (#186). f64→f64; the discriminant is the opcode operand. Kept in sync with the VM handler and the JIT lowering.
Opcode
Stack-based bytecode opcodes.

Constants§

NO_REST_PARAM

Functions§

binop_to_u8
Encode BinOp for bytecode operand. Used by compiler.
compile
Compile a Tish program to bytecode (with peephole optimizations).
compile_for_repl
Compile for REPL: last expression statement leaves its value on the stack (no Pop, no trailing Null).
compile_for_repl_unoptimized
Compile for REPL without peephole optimizations.
compile_unoptimized
Compile without peephole optimizations (for –no-optimize).
compile_with_source
Compile, tagging the chunk with a source file path so runtime errors can report file:line (issue #74). The line table is built during compilation and survives the in-place peephole pass; it is not serialized.
compound_op_to_u8
Encode CompoundOp for bytecode (same numeric subset as BinOp: Add,Sub,Mul,Div,Mod).
deserialize
Deserialize a chunk from bytes.
serialize
Serialize a chunk to bytes (includes nested chunks for functions).
u8_to_binop
Decode bytecode operand to BinOp. Used by VM.
u8_to_unaryop
Decode bytecode operand to UnaryOp. Used by VM.
unaryop_to_u8
Encode UnaryOp for bytecode operand. Used by compiler.