🐛 bug: fma test passes with a hack
So closures are kinda working, but I'm probably missing some edge cases.main
parent
2a0e02aec4
commit
57486f7a65
10
src/state.rs
10
src/state.rs
|
@ -444,6 +444,9 @@ impl <'a> State <'a> {
|
|||
*self.reg_mut (*a) = (b % c).into ();
|
||||
},
|
||||
Instruction::Move (a, b) => {
|
||||
// If the value in b is deleted instead of duplicated,
|
||||
// a bunch of tests fail
|
||||
|
||||
*self.reg_mut (*a) = self.reg (*b).clone ();
|
||||
},
|
||||
Instruction::Mul (a, b, c) => {
|
||||
|
@ -474,9 +477,10 @@ impl <'a> State <'a> {
|
|||
|
||||
let popped_frame = self.stack.pop ().unwrap ();
|
||||
|
||||
// Build closure if needed
|
||||
if *k {
|
||||
|
||||
// Build closure if needed. No point building if we're
|
||||
// popping the last frame and exiting the program.
|
||||
|
||||
if *k && ! self.stack.is_empty () {
|
||||
let closure_idx = match &self.registers [popped_frame.register_offset + a] {
|
||||
Value::BogusClosure (rc) => rc.borrow ().idx,
|
||||
_ => panic! ("Impossible"),
|
||||
|
|
|
@ -45,7 +45,7 @@ impl fmt::Debug for Value {
|
|||
Value::Float (x) => write! (f, "{:?}", x),
|
||||
Value::Integer (x) => write! (f, "{}", x),
|
||||
Value::RsFunc (x) => write! (f, "function: {:?}", x),
|
||||
Value::String (s) => write! (f, "{}", s),
|
||||
Value::String (s) => write! (f, "\"{}\"", s),
|
||||
Value::Table (t) => write! (f, "{:?}", t.borrow ()),
|
||||
|
||||
Value::BogusClosure (x) => write! (f, "{:?}", x.borrow ()),
|
||||
|
|
|
@ -17,9 +17,10 @@ end
|
|||
local function run ()
|
||||
local hh = fma (10, 11, 12)
|
||||
print (hh)
|
||||
return hh
|
||||
end
|
||||
|
||||
run ()
|
||||
local hh = run ()
|
||||
print (ii)
|
||||
|
||||
return hh
|
||||
|
|
Loading…
Reference in New Issue