2015-02-12 18:23:17 +01:00
|
|
|
void instr()
|
|
|
|
{
|
2015-05-19 17:51:03 +02:00
|
|
|
MIN_ARGUMENTS(1);
|
2015-02-12 18:23:17 +01:00
|
|
|
|
2015-05-19 17:51:03 +02:00
|
|
|
// stringify only if not already a string
|
|
|
|
if (_stack->get_type(0) != cmd_string)
|
|
|
|
{
|
2017-04-15 19:34:01 +02:00
|
|
|
// write the object in stack(0) in a string and remove this obj
|
2015-05-19 17:51:03 +02:00
|
|
|
stringstream out;
|
|
|
|
((object*)_stack->back())->show(out);
|
|
|
|
_stack->pop_back();
|
2015-02-12 18:23:17 +01:00
|
|
|
|
2017-04-15 19:34:01 +02:00
|
|
|
// reserve the correct size in stack
|
|
|
|
_stack->push_back(NULL, out.str().size(), cmd_string, true);
|
|
|
|
|
|
|
|
// fill the obj
|
|
|
|
ostring* str = (ostring*)_stack->get_obj(0);
|
|
|
|
str->set(out.str().c_str(), out.str().size());
|
2015-05-19 17:51:03 +02:00
|
|
|
}
|
2015-02-12 18:23:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void strout()
|
|
|
|
{
|
2015-02-26 22:33:28 +01:00
|
|
|
MIN_ARGUMENTS(1);
|
2015-05-19 17:51:03 +02:00
|
|
|
ARG_MUST_BE_OF_TYPE(0, cmd_string);
|
2015-02-12 18:23:17 +01:00
|
|
|
|
2015-03-01 23:10:45 +01:00
|
|
|
string entry(((ostring*)_stack->back())->_value);
|
2015-05-19 17:51:03 +02:00
|
|
|
_stack->pop_back();
|
2015-02-12 18:23:17 +01:00
|
|
|
|
2015-05-19 17:51:03 +02:00
|
|
|
program prog;
|
2015-02-12 18:23:17 +01:00
|
|
|
|
2015-05-19 17:51:03 +02:00
|
|
|
// make program from string in stack level 1
|
2015-03-01 23:10:45 +01:00
|
|
|
if (program::parse(entry.c_str(), prog) == ret_ok)
|
2015-05-19 17:51:03 +02:00
|
|
|
{
|
|
|
|
// run it
|
2015-03-04 17:01:30 +01:00
|
|
|
prog.run(*_stack, *_global_heap, &_local_heap);
|
2015-05-19 17:51:03 +02:00
|
|
|
}
|
2015-02-12 18:23:17 +01:00
|
|
|
}
|