implemented drop builtin function
This commit is contained in:
parent
b935325eb4
commit
2ddb0ca4d6
|
|
@ -72,6 +72,7 @@ typedef struct {
|
|||
} FunctionItem;
|
||||
|
||||
Boolean push_token(InterpreterState *interpreter_state, Token token);
|
||||
void clean_stack(StackItem *item);
|
||||
|
||||
Boolean execute(InterpreterState *interpreter_state, LexerTokenResult *token);
|
||||
InterpreterState *interpreter_create();
|
||||
|
|
|
|||
|
|
@ -789,8 +789,12 @@ Boolean builtin_depth(InterpreterState *interpreter_state) {
|
|||
}
|
||||
|
||||
Boolean builtin_drop(InterpreterState *interpreter_state) {
|
||||
(void)interpreter_state;
|
||||
return FALSE;
|
||||
StackItem *node = interpreter_state->stack;
|
||||
if (node == NULL) return FALSE;
|
||||
interpreter_state->stack = node->next;
|
||||
node->next = NULL;
|
||||
clean_stack(node);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Boolean builtin_dup(InterpreterState *interpreter_state) {
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ InterpreterState *interpreter_create() {
|
|||
return interpreter_state;
|
||||
}
|
||||
|
||||
static void clean_stack(StackItem *item) {
|
||||
void clean_stack(StackItem *item) {
|
||||
if (item == NULL) return;
|
||||
if (item->type == STACK_TOKEN_STRING)
|
||||
clean_token_string(item->token_string);
|
||||
|
|
|
|||
|
|
@ -17,8 +17,10 @@
|
|||
static const SlsStr REPL_FILE_NAME = SLS_STR_CONST("<STDIN>");
|
||||
|
||||
void print_top_of_stack(InterpreterState *interpreter_state) {
|
||||
if (interpreter_state->stack == NULL)
|
||||
if (interpreter_state->stack == NULL) {
|
||||
printf("#0: <STACK IS EMPTY>\n");
|
||||
return;
|
||||
}
|
||||
switch (interpreter_state->stack->type) {
|
||||
case STACK_IDENTIFIER:
|
||||
printf("#0: ::%s\n", interpreter_state->stack->identifier.name.str);
|
||||
|
|
|
|||
Loading…
Reference in New Issue