RSWBC2 Linear Stack Bytecode ISA & .rsw-rollback.jnl Specification
This reference documents the binary layout of RaggieScript's RSWBC2 bytecode container (RsscBytecodeIsa.hpp) and the on-disk transactional rollback journal (RaggieScriptSdk.hpp).
RSWBC2 Binary Container Header (48 Bytes + Sections)
| Offset | Size | Field | Description |
|---|---|---|---|
0x00 | 6 bytes | Magic | ASCII "RSWBC2" (RaggieScriptVm also loads "RSWBC1" transparently). |
0x06 | 2 bytes | IsaVersion | Little-endian uint16 (0x0100 = ISA v1.0). |
0x08 | 4 bytes | Flags | Bit 0: RSW701 Wizard Verified; Bit 1: RSW702 Sandboxed Profile. |
0x0C | 4 bytes | PayloadLength | Byte length of the serialized metadata + constant pool + chunk table. |
0x10 | 32 bytes | Sha256Digest | bcrypt.dll SHA-256 digest over all PayloadLength bytes (RSW704 verified before load!). |
0x30 | PayloadLength | Sections | Package header metadata, struct/enum/param/feature/payload descriptors, deduplicated Constant Pool, and Linear Instruction Chunks. |
Linear Stack VM Instruction Set (OpCode)
Each instruction is a fixed compact tuple (op: uint8, a: uint32, b: int32, srcLine: uint32):
| Opcode | Operands | Stack Effect | Semantics |
|---|---|---|---|
NOP | — | 0 | No operation. |
PUSH_NULL | — | +1 | Pushes null. |
PUSH_BOOL | b (0/1) | +1 | Pushes false or true. |
PUSH_INT | a (const idx) | +1 | Pushes 64-bit int from constant pool. |
PUSH_FLOAT | a (const idx) | +1 | Pushes 64-bit float from constant pool. |
PUSH_STR | a (const idx) | +1 | Pushes UTF-8 string from constant pool. |
PUSH_VER | a (const idx) | +1 | Pushes 4-part SemVer version. |
POP | — | -1 | Discards top of stack. |
LOAD_VAR | a (name idx) | +1 | Resolves lexical local -> closure upvalue -> global variable. |
DECL_VAR | a (name), b (isConst) | -1 | Declares variable in current lexical frame with popped initializer. |
STORE_VAR | a (name), b (assign op) | 0 (-1 + push) | Mutates existing mutable binding (enforcing RSW713 CLI hard-locks!). |
MAKE_REF | a (name idx) | +1 | Pushes two-way mutable RefVar handle for Wizard bind: / TaskDialog slots. |
MAKE_ARRAY | a (count) | -(count) + 1 | Pops count elements into a new array. |
MAKE_MAP | a (pairCount) | -(2*pairCount) + 1 | Pops (key, val) pairs into a map. |
MAKE_STRUCT | a (struct idx), b (pairCount) | -(2*pairCount) + 1 | Hydrates struct defaults and applies explicit field initializers. |
MAKE_CLOSURE | a (chunk idx) | +1 | Captures lexical environment into a first-class callable closure value. |
GET_MEMBER / SET_MEMBER | a (prop idx) | 0 / -1 | Reads or writes map/struct/enum/namespace property. |
GET_INDEX / SET_INDEX | — | -1 / -2 | Reads or writes arr[idx] / map[key]. |
UNARY_OP / BINARY_OP | b (op code) | 0 / -1 | Executes !, -, +, /, ==, <, SemVer compare, etc. |
JUMP / JUMP_IF_FALSE / JUMP_IF_TRUE / JUMP_IF_NOT_NULL | a (target IP) | 0 / -1 | Structured control-flow, short-circuit &&/||, ??, and match arms. |
CALL_HOST | a (ns.method), b (argc) | -(2*argc) + 1 | Pops named/positional (argName, argVal) pairs and invokes the 21-namespace C++20 Stdlib. |
CALL_VALUE | b (argc) | -(2*argc) | Invokes user fn, global builtin, or first-class closure value! |
WIZ_STEP_BEGIN / WIZ_STEP_END | a (step name) | 0 | Registers declarative Wizard step boundaries with RsscWizardUiEngine. |
DEFER_PUSH | a (defer chunk idx) | 0 | Pushes a lexical cleanup closure onto the current frame's LIFO defer stack (executed on RET or THROW). |
RETURN / EXIT_SETUP / THROW | — | -1 | Runs frame defer stack in LIFO order, then returns from chunk, exits setup, or raises catchable exception. |
Transactional Rollback Ledger (.rsw-rollback.jnl)
Before the first mutating operation inside install { ... }, RaggieScriptVm opens <installDir>\.rsw-rollback.jnl (with automatic fallback to %TEMP% before <installDir> exists) and flushes each pre-image record to disk before performing the OS mutation:
- New File / Extracted Payload (
FILE_CREATED): Records path; deleted on rollback. - Overwritten File /
.ini/.xml/.json(FILE_OVERWRITTEN): Copies original bytes to<file>.<seq>.rswbak; restored atomically over<file>on rollback, or deleted cleanly upon commit! - Created Directory (
DIR_CREATED): Recorded in creation order; removed in reverse leaf-first LIFO order if empty on rollback. - Registry Value (
REG_CREATED/REG_OVERWRITTEN): Captures priorREG_SZ/REG_EXPAND_SZ/REG_DWORD/REG_MULTI_SZtype and bytes +RegView(64vs32); restores exact prior type/bytes or deletes newly added values on rollback. - Services, Shortcuts, Firewall Rules &
PATHEntries: Journals exact inverse removal/restoration commands—and reuses the exact same journal model inside<InstallDir>\Uninstall.rswmsoUninstall.exeleaves zero orphan keys orPATHcruft!