mirror of
https://github.com/louisrubet/rpn
synced 2025-01-01 18:20:06 +01:00
rcl and eval do not eat unknown variables anymore
This commit is contained in:
parent
f1df23ef61
commit
995e8f8b15
2 changed files with 12 additions and 2 deletions
|
@ -8,13 +8,18 @@ void eval(void)
|
|||
void* obj;
|
||||
unsigned int size;
|
||||
int type;
|
||||
if (_heap->get(getn(), obj, size, type))
|
||||
string& variable = *((symbol*)_stack->back())->_value;
|
||||
if (_heap->get(variable, obj, size, type))
|
||||
{
|
||||
_stack->pop_back();
|
||||
_stack->push_back(obj, size, type);
|
||||
}
|
||||
else
|
||||
ERR_CONTEXT(ret_unknown_variable);
|
||||
}
|
||||
else if (IS_ARG_TYPE(0, cmd_program))
|
||||
{
|
||||
// eval a program
|
||||
string& entry = *((oprogram*)_stack->back())->_value;
|
||||
_stack->pop_back();
|
||||
|
||||
|
|
|
@ -14,11 +14,16 @@ void rcl(void)
|
|||
MIN_ARGUMENTS(1);
|
||||
ARG_MUST_BE_OF_TYPE(0, cmd_symbol);
|
||||
|
||||
// recall a variable
|
||||
void* obj;
|
||||
unsigned int size;
|
||||
int type;
|
||||
if (_heap->get(getn(), obj, size, type))
|
||||
string& variable = *((symbol*)_stack->back())->_value;
|
||||
if (_heap->get(variable, obj, size, type))
|
||||
{
|
||||
_stack->pop_back();
|
||||
_stack->push_back(obj, size, type);
|
||||
}
|
||||
else
|
||||
ERR_CONTEXT(ret_unknown_variable);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue