diff options
| -rw-r--r-- | optable.c | 15 | ||||
| -rw-r--r-- | stack.c | 4 | ||||
| -rw-r--r-- | stack.h | 2 | 
3 files changed, 18 insertions, 3 deletions
| @@ -55,10 +55,11 @@ static wordop optable[OPTABLE_MAX_SIZE] = {      {"then", builtin, {donothing}},      {"depth", builtin, {depth}},      {".s", builtin, {stack_printall}}, +    {"clearstack", builtin, {stack_clear}},      {"if", directive, {ifdirective}},      {":", directive, {defineop}},  }; -static int optablelen = 25; +static int optablelen = 26;  #pragma clang diagnostic pop  compileditem* compilewords(int len, char** script) { @@ -87,13 +88,21 @@ void optable_init() {      optable[optablelen].oplist = oplist;      optablelen++; +    optable[optablelen].word = "tuck"; +    optable[optablelen].optype = compiled; +    oplistlen = 3; +    optable[optablelen].oplistlen = oplistlen; +    char* ws2[] = {"dup", "rot", "rot"}; +    oplist = compilewords(oplistlen, ws2); +    optable[optablelen].oplist = oplist; +    optablelen++;      optable[optablelen].word = "incr";      optable[optablelen].optype = compiled;      oplistlen = 2;      optable[optablelen].oplistlen = oplistlen; -    char* ws2[] = {"1", "+"}; -    oplist = compilewords(2, ws2); +    char* ws3[] = {"1", "+"}; +    oplist = compilewords(2, ws3);      optable[optablelen].oplist = oplist;      optablelen++; @@ -77,3 +77,7 @@ void stack_pick(stack *s) {          stack_push(s, 0);      }  } + +void stack_clear(stack* s) { +    s->size = 0; +} @@ -29,4 +29,6 @@ void stack_roll(stack *s);  void stack_pick(stack *s); +void stack_clear(stack *s); +  #endif | 
