// void sto(void) { MIN_ARGUMENTS(2); ARG_MUST_BE_OF_TYPE(0, cmd_symbol); string name(((symbol*)_stack->pop_back())->_value); _global_heap->add(name, _stack->get_obj(0), _stack->get_len(0), _stack->get_type(0)); (void)_stack->pop_back(); } void rcl(void) { MIN_ARGUMENTS(1); ARG_MUST_BE_OF_TYPE(0, cmd_symbol); // recall a variable void* obj; unsigned int size; int type; string variable(((symbol*)_stack->back())->_value); // mind the order of heaps if (_local_heap.get(variable, obj, size, type) || ((_parent_local_heap != NULL) && (_parent_local_heap->get(variable, obj, size, type))) || _global_heap->get(variable, obj, size, type)) { (void)_stack->pop_back(); _stack->push_back(obj, size, type); } else ERR_CONTEXT(ret_unknown_variable); } void edit(void) { MIN_ARGUMENTS(1); stringstream out; if (((object*)_stack->back())->_type == cmd_number) { switch(number::s_mode) { case number::std: out.precision(number::s_current_precision); out.unsetf(ios_base::floatfield); break; case number::fix: out << setprecision(number::s_current_precision) << fixed; break; case number::sci: out << setprecision(number::s_current_precision) << scientific; break; } } // re-write stack objet in a stream ((object*)_stack->pop_back())->show(out); // edit: stuff chars using readline facility string str = out.str(); for(int i=0;i_auto_eval) { void* obj; unsigned int size; int type; string variable(symb->_value); // mind the order of heaps if (_local_heap.get(variable, obj, size, type) || ((_parent_local_heap != NULL) && (_parent_local_heap->get(variable, obj, size, type))) || _global_heap->get(variable, obj, size, type)) { _stack->push_back(obj, size, type); if (type == cmd_program) eval(); else if (type == cmd_number) ((number*)_stack->back())->ensure_significand(); } else _stack->push_back(symb, symb->size(), cmd_symbol); } else _stack->push_back(symb, symb->size(), cmd_symbol); } void purge(void) { MIN_ARGUMENTS(1); ARG_MUST_BE_OF_TYPE(0, cmd_symbol); string name(((symbol*)_stack->pop_back())->_value); // mind the order of heaps bool done = false; if (!_local_heap.erase(name)) { if ((_parent_local_heap != NULL) && (_parent_local_heap->erase(name))) done = true; else if (_global_heap->erase(name)) done = true; } else done = true; if (!done) ERR_CONTEXT(ret_unknown_variable); } void vars(void) { object* obj; unsigned int size; int type; string name; for (int i=0; i<(int)_global_heap->size(); i++) { (void)_global_heap->get_by_index(i, name, (void*&)obj, size, type); cout<<"var "<show(); cout<size(); i++) { (void)_parent_local_heap->get_by_index(i, name, (void*&)obj, size, type); cout<<"local var "<show(); cout<show(); cout<