-
Notifications
You must be signed in to change notification settings - Fork 0
Byte Engine
Pt edited this page Jun 17, 2026
·
2 revisions
Byte Engine is the binary backend in Lc for opcode-style runtime execution.
It is suitable for:
- compact VM loops,
- binary protocol handlers,
- instruction stream processing,
- low-level execution runtimes.
- Raw bytes in scope:
INPUT []byte. - Parser builds
[]ParsedBytes. - Parsed data stored in
PARSED []ParsedBytes. - Opcode resolved from
Switchbytes + configured endianness. - Handler execution with auto/manual instruction pointer policy.
ParsedBytes fields:
Switch []byteArgs [][]byteRaw []byteMetadata map[string]interface{}
Expected instruction format:
- command bytes (
CommandBytelen) - args count bytes (
ArgscountBytelen) - per argument:
- arg length bytes (
ArglenBytelen) - argument payload bytes
- arg length bytes (
All integer decoding depends on configured endianness.
Registration:
NewCommandByte(opcode, handler, name, autoBytecodeIdxShift)
Handler signature:
func(*engine.ByteEngine, byteParsing.ParsedBytes) error
Auto mode:
- set
autoBytecodeIdxShift=true, runtime moves to next instruction automatically.
Manual mode:
- set
autoBytecodeIdxShift=false, handler controls flow via:AddToBytecodeIdx(n)SetBytecodeIdx(n)GetBytecodeIdx()
Manual mode enables loops, branches, jump tables, and custom control-flow semantics.
Default events use:
ENDIANESS intBYECODE_IDX *intINPUT []bytePARSED []ParsedBytes
Keep these names reserved in extension code.
Write:
Generator.AddBytes(...)
Read:
Generator.GetBytesRes()
Use pipeline stages when your runtime has pre/post execution phases.