enum Type;
typedef enum Type Type;
enum Type {
+ BOOLEAN,
BUILTIN,
INTEGER,
STRING
typedef union Value Value;
union Value {
Builtin builtin;
+ bool boolean;
char* string;
int32_t integer;
};
Object arg = Stack_pop(&(thread->stack));
switch(arg.type) {
+ case BOOLEAN:
+ if(arg.value.boolean) printf("true");
+ else printf("false");
+ break;
case INTEGER:
printf("%i", arg.value.integer);
break;
void push(struct Thread* thread, Argument argument) {
char* argumentString = argument.string;
- if(strcmp(argumentString, "print") == 0) {
+ if(strcmp(argumentString, "false") == 0) {
+ Stack_push(&(thread->stack), (Object){ BOOLEAN, false });
+ }else if(strcmp(argumentString, "pow") == 0) {
Object result;
result.type = BUILTIN;
- result.value.builtin = PRINT;
+ result.value.builtin = POW;
Stack_push(&(thread->stack), result);
- } else if(strcmp(argumentString, "pow") == 0) {
+ } else if(strcmp(argumentString, "print") == 0) {
Object result;
result.type = BUILTIN;
- result.value.builtin = POW;
+ result.value.builtin = PRINT;
Stack_push(&(thread->stack), result);
+ } else if(strcmp(argumentString, "true") == 0) {
+ Stack_push(&(thread->stack), (Object){ BOOLEAN, true });
} else {
Environment_get_Result result = Environment_get(thread->environment, argumentString);
if(!result.found) {