mirror of
https://github.com/louisrubet/rpn
synced 2025-01-05 11:01:52 +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;
|
void* obj;
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
int type;
|
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);
|
_stack->push_back(obj, size, type);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ERR_CONTEXT(ret_unknown_variable);
|
ERR_CONTEXT(ret_unknown_variable);
|
||||||
}
|
}
|
||||||
else if (IS_ARG_TYPE(0, cmd_program))
|
else if (IS_ARG_TYPE(0, cmd_program))
|
||||||
{
|
{
|
||||||
|
// eval a program
|
||||||
string& entry = *((oprogram*)_stack->back())->_value;
|
string& entry = *((oprogram*)_stack->back())->_value;
|
||||||
_stack->pop_back();
|
_stack->pop_back();
|
||||||
|
|
||||||
|
|
|
@ -14,11 +14,16 @@ void rcl(void)
|
||||||
MIN_ARGUMENTS(1);
|
MIN_ARGUMENTS(1);
|
||||||
ARG_MUST_BE_OF_TYPE(0, cmd_symbol);
|
ARG_MUST_BE_OF_TYPE(0, cmd_symbol);
|
||||||
|
|
||||||
|
// recall a variable
|
||||||
void* obj;
|
void* obj;
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
int type;
|
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);
|
_stack->push_back(obj, size, type);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ERR_CONTEXT(ret_unknown_variable);
|
ERR_CONTEXT(ret_unknown_variable);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue