->str and str->

This commit is contained in:
louis 2015-03-01 23:10:45 +01:00
parent 9197d5d36d
commit 73f2578a12

View file

@ -2,8 +2,6 @@ void instr()
{ {
MIN_ARGUMENTS(1); MIN_ARGUMENTS(1);
//TODO
#if 0
// stringify only if not already a string // stringify only if not already a string
if (_stack->get_type(0) != cmd_string) if (_stack->get_type(0) != cmd_string)
{ {
@ -11,29 +9,26 @@ void instr()
((object*)_stack->back())->show(out); ((object*)_stack->back())->show(out);
_stack->pop_back(); _stack->pop_back();
ostring* str = new ostring(out.str().c_str()); ostring str;
_stack->push_back(str, sizeof(ostring), cmd_string); str.set(out.str().c_str(), out.str().size());
_stack->push_back(&str, str.size(), cmd_string);
} }
#endif
} }
void strout() void strout()
{ {
//TODO
#if 0
MIN_ARGUMENTS(1); MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_string); ARG_MUST_BE_OF_TYPE(0, cmd_string);
string& entry = *((ostring*)_stack->back())->_value; string entry(((ostring*)_stack->back())->_value);
_stack->pop_back(); _stack->pop_back();
program prog; program prog;
// make program from string in stack level 1 // make program from string in stack level 1
if (program::parse(entry, prog) == ret_ok) if (program::parse(entry.c_str(), prog) == ret_ok)
{ {
// run it // run it
prog.run(*_stack, *_heap); prog.run(*_stack, *_heap);
} }
#endif
} }