mirror of
https://github.com/louisrubet/rpn
synced 2025-01-30 20:34:30 +01:00
parent
562ae5fdef
commit
8b0b447e6a
2 changed files with 12 additions and 7 deletions
|
@ -134,14 +134,14 @@ void type()
|
|||
{
|
||||
MIN_ARGUMENTS(1);
|
||||
|
||||
int type = _stack->back()->_type;
|
||||
int type = _stack->pop_back()->_type;
|
||||
if (type < 0 || type >= (int)cmd_max)
|
||||
type = (int)cmd_undef;
|
||||
|
||||
unsigned int string_size = strlen(object::s_cmd_type_string[type]);
|
||||
unsigned int size = sizeof(symbol)+string_size+1;
|
||||
symbol* sym = (symbol*)_stack->allocate_back(size, cmd_symbol);
|
||||
sym->set(object::s_cmd_type_string[type], string_size, false);
|
||||
ostring* typ = (ostring*)_stack->allocate_back(size, cmd_string);
|
||||
typ->set(object::s_cmd_type_string[type], string_size);
|
||||
}
|
||||
|
||||
void rpn_default()
|
||||
|
|
|
@ -12,22 +12,27 @@ erase
|
|||
|
||||
# type (1)
|
||||
1 type
|
||||
-> stack should be 1, 'number'
|
||||
-> stack should be "number"
|
||||
erase
|
||||
|
||||
# type (2)
|
||||
"hey" type
|
||||
-> stack should be "hey", 'string'
|
||||
-> stack should be "string"
|
||||
erase
|
||||
|
||||
# type (3)
|
||||
<< -> n << n >> >> type
|
||||
-> stack should be << -> n << n >> >>, 'program'
|
||||
-> stack should be "program"
|
||||
erase
|
||||
|
||||
# type (4)
|
||||
(1,2) type
|
||||
-> stack should be (1,2)), 'complex'
|
||||
-> stack should be "complex"
|
||||
erase
|
||||
|
||||
# type (5)
|
||||
type
|
||||
-> error should be 2
|
||||
erase
|
||||
|
||||
# default
|
||||
|
|
Loading…
Add table
Reference in a new issue