mirror of
https://github.com/louisrubet/rpn
synced 2025-01-30 20:34:30 +01:00
Correct command purge
This commit is contained in:
parent
f0adc8e48b
commit
a682b8cb48
3 changed files with 8 additions and 14 deletions
|
@ -51,8 +51,11 @@ void purge(void)
|
||||||
MIN_ARGUMENTS(1);
|
MIN_ARGUMENTS(1);
|
||||||
ARG_MUST_BE_OF_TYPE(0, cmd_symbol);
|
ARG_MUST_BE_OF_TYPE(0, cmd_symbol);
|
||||||
|
|
||||||
if (!_heap->erase(string(getn())))
|
string name(((symbol*)_stack->back())->_value);
|
||||||
|
if (!_heap->erase(name))
|
||||||
ERR_CONTEXT(ret_unknown_variable);
|
ERR_CONTEXT(ret_unknown_variable);
|
||||||
|
else
|
||||||
|
_stack->pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
void vars(void)
|
void vars(void)
|
||||||
|
|
|
@ -723,15 +723,6 @@ private:
|
||||||
_stack->push_back(&num, num.size(), cmd_binary);
|
_stack->push_back(&num, num.size(), cmd_binary);
|
||||||
}
|
}
|
||||||
|
|
||||||
// care: return value must be used before pushing something else in stack
|
|
||||||
char* getn()
|
|
||||||
{
|
|
||||||
/* warning, caller must check object type before */
|
|
||||||
char* a = ((ostring*)_stack->back())->_value;
|
|
||||||
_stack->pop_back();
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
int stack_size()
|
int stack_size()
|
||||||
{
|
{
|
||||||
return _stack->size();
|
return _stack->size();
|
||||||
|
|
|
@ -251,7 +251,7 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool erase(const string name)
|
bool erase(const string& name)
|
||||||
{
|
{
|
||||||
map<string, struct local_var*>::iterator i = _map.find(name);
|
map<string, struct local_var*>::iterator i = _map.find(name);
|
||||||
if (i != _map.end())
|
if (i != _map.end())
|
||||||
|
|
Loading…
Add table
Reference in a new issue