mirror of
https://github.com/louisrubet/rpn
synced 2025-01-01 18:20:06 +01:00
#45: added command type
This commit is contained in:
parent
b1a3b686f4
commit
fd9a78904d
2 changed files with 15 additions and 0 deletions
|
@ -16,6 +16,7 @@ program::keyword_t program::_keywords[] =
|
|||
{ cmd_keyword, "sci", &program::sci, "scientific floating point representation. ex: 20 sci" },
|
||||
{ cmd_keyword, "version", &program::rpn_version, "show rpn version" },
|
||||
{ cmd_keyword, "uname", &program::rpn_uname, "show rpn complete identification string" },
|
||||
{ cmd_keyword, "type", &program::type, "show first stack entry type" },
|
||||
|
||||
//REAL
|
||||
{ cmd_undef, "", NULL, "\nREAL"},
|
||||
|
|
|
@ -172,3 +172,17 @@ void rpn_uname()
|
|||
_stack->push_back(str, str->size(), cmd_string);
|
||||
free(str);
|
||||
}
|
||||
|
||||
void type()
|
||||
{
|
||||
MIN_ARGUMENTS(1);
|
||||
|
||||
int type = _stack->seq_type(_stack->size()-1);
|
||||
if (type < 0 || type >= (int)cmd_max)
|
||||
type = (int)cmd_undef;
|
||||
|
||||
unsigned int string_size = strlen(cmd_type_string[type]);
|
||||
unsigned int size = sizeof(symbol)+string_size+1;
|
||||
symbol* sym = (symbol*)allocate_back(size, cmd_symbol);
|
||||
sym->set(cmd_type_string[type], string_size);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue