feat: naive variable observers
This commit is contained in:
parent
48b0e3a806
commit
faac9b54d8
3 changed files with 115 additions and 22 deletions
|
|
@ -1134,12 +1134,13 @@ fn assign(gi: *GenIr, scope: *Scope, node: *const Ast.Node) InnerError!void {
|
|||
const expr_node = node.data.bin.rhs.?;
|
||||
const name_str = try astgen.strFromNode(identifier_node);
|
||||
|
||||
if (scope.lookup(name_str.index)) |decl| {
|
||||
const expr_result = try expr(gi, scope, expr_node);
|
||||
_ = try gi.addBinaryNode(.store, decl.inst_index.toRef(), expr_result);
|
||||
return;
|
||||
}
|
||||
_ = try gi.addStrTok(.decl_ref, name_str.index, node.loc.start);
|
||||
const lhs = if (scope.lookup(name_str.index)) |decl| blk: {
|
||||
break :blk decl.inst_index.toRef();
|
||||
} else blk: {
|
||||
break :blk try gi.addStrTok(.decl_ref, name_str.index, node.loc.start);
|
||||
};
|
||||
const rhs = try expr(gi, scope, expr_node);
|
||||
_ = try gi.addBinaryNode(.store, lhs, rhs);
|
||||
}
|
||||
|
||||
fn assignOp(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue