mirror of
https://github.com/louisrubet/rpn
synced 2025-01-29 20:34:21 +01:00
#88: debugged local variable unevaluated
This commit is contained in:
parent
57c7f21063
commit
55a0638ffb
3 changed files with 7 additions and 8 deletions
|
@ -42,7 +42,7 @@ public:
|
|||
program(program* parent_prog = NULL) { _parent_prog = parent_prog; }
|
||||
|
||||
// run this program
|
||||
ret_value run(stack& stk, heap& hp, heap* parent_local_hp = NULL)
|
||||
ret_value run(stack& stk, heap& hp)
|
||||
{
|
||||
bool go_out = false;
|
||||
ret_value ret = ret_ok;
|
||||
|
@ -426,7 +426,7 @@ private:
|
|||
// global heap (sto, rcl)
|
||||
heap* _heap;
|
||||
|
||||
// local heap for local loop vairables (for..next)
|
||||
// local heap for local loop variables (for..next)
|
||||
heap _local_heap;
|
||||
|
||||
// local stack internally used by branch commands (start, for, next, ..)
|
||||
|
|
|
@ -78,7 +78,7 @@ void eval(void)
|
|||
if (program::parse(prog_text.c_str(), prog) == ret_ok)
|
||||
{
|
||||
// run it
|
||||
prog.run(*_stack, *_heap, &_local_heap);
|
||||
prog.run(*_stack, *_heap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,22 +145,21 @@ int inprog(branch& myobj)
|
|||
}
|
||||
|
||||
// load variables
|
||||
heap local_heap;
|
||||
for (unsigned int i = myobj.arg1 + count_symbols; i > myobj.arg1; i--)
|
||||
{
|
||||
local_heap.add(string(((symbol*)seq_obj(i))->_value), _stack->get_obj(0), _stack->get_len(0));
|
||||
_local_heap.add(string(((symbol*)seq_obj(i))->_value), _stack->get_obj(0), _stack->get_len(0));
|
||||
(void)_stack->pop_back();
|
||||
}
|
||||
|
||||
// run the program
|
||||
string entry(((oprogram*)seq_obj(myobj.arg1 + count_symbols + 1))->_value);
|
||||
program prog;
|
||||
program prog(this);
|
||||
|
||||
// make the program from entry
|
||||
if (program::parse(entry.c_str(), prog) == ret_ok)
|
||||
{
|
||||
// run it
|
||||
prog.run(*_stack, *_heap, &local_heap);
|
||||
prog.run(*_stack, *_heap);
|
||||
}
|
||||
|
||||
// point on next command
|
||||
|
|
|
@ -40,5 +40,5 @@ void strout()
|
|||
// make program from string in stack level 1
|
||||
if (program::parse(entry.c_str(), prog) == ret_ok)
|
||||
// run it
|
||||
prog.run(*_stack, *_heap, &_local_heap);
|
||||
prog.run(*_stack, *_heap);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue