From f576868a7af5e1289926e8acf7328d9dc383970a Mon Sep 17 00:00:00 2001 From: Scott Richmond Date: Mon, 23 Jun 2025 00:07:04 -0400 Subject: [PATCH] update stack discipline in dict patterns --- sandbox.ld | 15 ++------------- src/compiler.rs | 5 +++-- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/sandbox.ld b/sandbox.ld index 6bdf6c7..927e835 100644 --- a/sandbox.ld +++ b/sandbox.ld @@ -1,14 +1,3 @@ -let command = [:forward, 100] - -match command with { - (:goto, (x, y)) -> "goto: {x} and {y}" - [:one, :two] -> :no - (:home) -> "go home!" - & (:clear) -> "clear the screen" - & (:right, turns) -> "make {turns} to the right" - & (:left, turns) -> "turn left! by {turns}" - (:forward, steps) -> "forward {steps} turtle paces" - (:back, steps) -> "flip it and reverse it {steps}" - [...xs] -> :splatted -} +let #{a, b, ...} = #{:a 1, :b 2, :c 3} +(a, b) diff --git a/src/compiler.rs b/src/compiler.rs index e1934a3..3442df8 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -739,8 +739,9 @@ impl<'a> Compiler<'a> { self.patch_jump(idx, self.len() - idx - 3); } - self.emit_op(Op::PopN); - self.emit_byte(pairs.len()); + self.pop_n(pairs.len()); + // self.emit_op(Op::PopN); + // self.emit_byte(pairs.len()); self.patch_jump(before_load_dict_idx, self.len() - before_load_dict_idx - 3); self.patch_jump(jump_idx, self.len() - jump_idx - 3);