39 lines
935 B
C
39 lines
935 B
C
#include "stackops.h"
|
|
|
|
void dropCmd(struct State* state) {
|
|
if (state->mode == EXECUTE) {
|
|
pop(&(state->pile));
|
|
}
|
|
}
|
|
|
|
void dupCmd(struct State* state) {
|
|
if (state->mode == EXECUTE) {
|
|
push(&(state->pile), top(&(state->pile)));
|
|
}
|
|
}
|
|
|
|
void swapCmd(struct State* state) {
|
|
if (state->mode == EXECUTE) {
|
|
struct NumContainer num1;
|
|
struct NumContainer num2;
|
|
|
|
getlastnums(&num1, &num2, &(state->pile));
|
|
push(&(state->pile), num2);
|
|
push(&(state->pile), num1);
|
|
}
|
|
}
|
|
|
|
void rotCmd(struct State* state) {
|
|
if (state->mode == EXECUTE) {
|
|
struct NumContainer num1;
|
|
struct NumContainer num2;
|
|
struct NumContainer num3;
|
|
|
|
getlastnums(&num1, &num2, &(state->pile));
|
|
num3 = top(&(state->pile));
|
|
pop(&(state->pile));
|
|
push(&(state->pile), num2);
|
|
push(&(state->pile), num1);
|
|
push(&(state->pile), num3);
|
|
}
|
|
}
|