# KOS_OP_LABEL - **Style**: COMPILE. Compile-time only. - **Stack**: No change. - **Invariants**: Not present in final bytecode after normal finalize; or executed as no-op if retained. - **Behavior**: Jump target placeholder. Finalize resolves branch targets to the LABEL's pc, then **strips** the LABEL instruction (branch args are adjusted to point at the next instruction). If a LABEL is retained, it advances PC only (safety net). - **Compiler form:** Pre-compile arg = label name, a str or int. Branches refer to this name; finalize resolves names to pcs and strips LABEL. Post-compile: **normally omitted**; if retained, arg is 0 or unused. **Pre-compile example:** List of (opcode, arg) pairs. The label name `"done"` is used by JUMP; finalize resolves it and then strips the LABEL. ``` ["JUMP", "done"], ["CONST", 99], ["LABEL", "done"], ["RETURN", 1], ``` **Post-compile (normal):** LABEL is stripped. JUMP's target was the LABEL at index 2; after stripping, that target becomes index 1 (the next instruction). Constant 99 is in the pool at index 0. | index | opcode | arg | arg view | comment | |------:|--------|-----|----------|---------| | 0 | JUMP | 1 | 1 (-> 1) | branch to "done" (was LABEL at 2; after strip, target is 1) | | 1 | CONST | 0 | 0 (99) | dead code; pool 0 = 99 | | 2 | RETURN | 1 | 1 | (was index 3 before strip) | **Post-compile (if LABEL retained):** Safety-net case only. If the LABEL were not stripped, it would appear as below and execute as a no-op. | index | opcode | arg | arg view | comment | |------:|--------|-----|----------|---------| | 0 | JUMP | 2 | 2 (-> 2) | branch to label | | 1 | CONST | 0 | 0 (99) | dead code | | 2 | LABEL | 0 | -- | target "done"; no-op if executed | | 3 | RETURN | 1 | 1 | |