fix dict pattern stack discipline
This commit is contained in:
parent
f09caabfcb
commit
6954857fdd
|
@ -495,4 +495,7 @@ Here's a list of things that need doing:
|
|||
- I _think_ I just fixed this by fixing tail position tracking in collections
|
||||
- [ ] test this
|
||||
* [ ] Dict patterns are giving me stack discipline grief. Why is stack discipline so hard?
|
||||
* [ ] This is in the service of getting turtle graphics working
|
||||
* Other forms in the language need help:
|
||||
* [ ] repeat needs its stack discipline updated, it currently crashes the compiler
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
& let state = #{:position (0, 0), :heading 0, :pencolor :white}
|
||||
let state = #{:position (0, 0), :heading 0, :pencolor :white}
|
||||
|
||||
& let command = (:forward, 10)
|
||||
|
||||
|
@ -35,6 +35,5 @@
|
|||
& & (:background, _) -> state
|
||||
& }
|
||||
|
||||
let foo = #{:a 1, :b 2, :c 3}
|
||||
let #{a, b, ...c} = foo
|
||||
|
||||
|
||||
|
|
|
@ -724,6 +724,7 @@ impl<'a> Compiler<'a> {
|
|||
};
|
||||
self.emit_constant(Value::Keyword(key));
|
||||
self.emit_op(Op::DropDictEntry);
|
||||
self.stack_depth -= 1;
|
||||
}
|
||||
|
||||
if let Some(splatt) = splattern {
|
||||
|
|
|
@ -112,8 +112,8 @@ pub fn run(src: &'static str) {
|
|||
// in any event, the AST should live forever
|
||||
let parsed: &'static Spanned<Ast> = Box::leak(Box::new(parse_result.unwrap()));
|
||||
|
||||
let prelude = prelude();
|
||||
// let prelude = imbl::HashMap::new();
|
||||
// let prelude = prelude();
|
||||
let prelude = imbl::HashMap::new();
|
||||
|
||||
let mut validator = Validator::new(&parsed.0, &parsed.1, "user input", src, prelude.clone());
|
||||
validator.validate();
|
||||
|
|
10
src/vm.rs
10
src/vm.rs
|
@ -910,7 +910,7 @@ impl Vm {
|
|||
for i in 0..arity as usize {
|
||||
self.return_register[arity as usize - i - 1] = self.pop();
|
||||
}
|
||||
self.print_stack();
|
||||
// self.print_stack();
|
||||
|
||||
// then pop everything back to the current stack frame
|
||||
self.stack.truncate(self.frame.stack_base);
|
||||
|
@ -976,10 +976,10 @@ impl Vm {
|
|||
// self.ip = self.frame.ip;
|
||||
// // finally, throw the value on the stack
|
||||
self.push(value);
|
||||
println!(
|
||||
"=== returning to {} ===",
|
||||
self.frame.function.as_fn().name()
|
||||
);
|
||||
// println!(
|
||||
// "=== returning to {} ===",
|
||||
// self.frame.function.as_fn().name()
|
||||
// );
|
||||
}
|
||||
Value::Partial(partial) => {
|
||||
let last_arg = self.pop();
|
||||
|
|
Loading…
Reference in New Issue
Block a user