rpn/src/rpn-string.h

34 lines
620 B
C
Raw Normal View History

2015-02-12 18:23:17 +01:00
void instr()
{
MIN_ARGUMENTS(1);
// stringify only if not already a string
if (_stack->get_type(0) != cmd_string)
{
stringstream out;
((object*)_stack->back())->show(out);
_stack->pop_back();
ostring* str = new ostring(out.str().c_str());
_stack->push_back(str, sizeof(ostring), cmd_string);
}
}
void strout()
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_string);
string& entry = *((ostring*)_stack->back())->_name;
_stack->pop_back();
program prog;
// make program from string in stack level 1
2015-02-24 11:46:45 +01:00
if (program::parse(entry, prog) == ret_ok)
2015-02-12 18:23:17 +01:00
{
// run it
2015-02-24 11:46:45 +01:00
prog.run(*_stack, *_heap);
2015-02-12 18:23:17 +01:00
}
}