mirror of
https://github.com/louisrubet/rpn
synced 2025-01-20 10:26:37 +01:00
#45: added command type
This commit is contained in:
parent
c388572fa8
commit
335d6f493f
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, "sci", &program::sci, "scientific floating point representation. ex: 20 sci" },
|
||||||
{ cmd_keyword, "version", &program::rpn_version, "show rpn version" },
|
{ cmd_keyword, "version", &program::rpn_version, "show rpn version" },
|
||||||
{ cmd_keyword, "uname", &program::rpn_uname, "show rpn complete identification string" },
|
{ cmd_keyword, "uname", &program::rpn_uname, "show rpn complete identification string" },
|
||||||
|
{ cmd_keyword, "type", &program::type, "show first stack entry type" },
|
||||||
|
|
||||||
//REAL
|
//REAL
|
||||||
{ cmd_undef, "", NULL, "\nREAL"},
|
{ cmd_undef, "", NULL, "\nREAL"},
|
||||||
|
|
|
@ -172,3 +172,17 @@ void rpn_uname()
|
||||||
_stack->push_back(str, str->size(), cmd_string);
|
_stack->push_back(str, str->size(), cmd_string);
|
||||||
free(str);
|
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