This repository has been archived on 2026-09-15. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
OxideJS/crates/oxide_compiler/src/counter/expr/chain.rs
T

18 lines
702 B
Rust

use super::*;
impl Compiler {
pub(in crate::counter) fn count_chain_expression(&self, expr: &Expression, ctx: &mut CompileCtx) {
let Expression::ChainExpression(chain) = expr else {
return;
};
let id = ctx.next_label_id();
self.count_chain_element(&chain.expression, true, ctx);
ctx.alloc_reg();
ctx.projected_pc += 1; // LOAD_VAR result <- chain value
ctx.projected_pc += 1; // JMP over short-circuit writer
ctx.labels.label_map.insert(Label::TernaryElse(id), ctx.projected_pc);
ctx.projected_pc += 1; // LOAD_CONST undefined
ctx.labels.label_map.insert(Label::TernaryEnd(id), ctx.projected_pc);
}
}