From 55a0638ffb5a97785db36500694767dd1a48ad7a Mon Sep 17 00:00:00 2001 From: Louis Rubet Date: Sun, 28 May 2017 01:32:06 +0200 Subject: [PATCH] #88: debugged local variable unevaluated --- src/program.hpp | 4 ++-- src/rpn-program.hpp | 9 ++++----- src/rpn-string.hpp | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/program.hpp b/src/program.hpp index 0927c52..6f115e0 100644 --- a/src/program.hpp +++ b/src/program.hpp @@ -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, ..) diff --git a/src/rpn-program.hpp b/src/rpn-program.hpp index d8cafb6..16ec258 100644 --- a/src/rpn-program.hpp +++ b/src/rpn-program.hpp @@ -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 diff --git a/src/rpn-string.hpp b/src/rpn-string.hpp index ff34c40..07c6ea3 100644 --- a/src/rpn-string.hpp +++ b/src/rpn-string.hpp @@ -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); }