#pragma once #include "ast.h" #include #include #define VARIABLES_MAX 64 // the longest thing a single type can say when emitted #define TEXT_LENGTH_MAX 255 enum TypeKind { KIND_VOID, KIND_INT32, KIND_BYTE, KIND_SIZE, KIND_ARRAY, KIND_CHAR, KIND_CHAR_CONSTANT, KIND_TUPLE, KIND_VALUE }; // a tuple keeps what it will say, already said, so nothing inside it can go out of scope struct Type { enum TypeKind kind; int64_t number; char text[TEXT_LENGTH_MAX + 1]; }; struct Variable { char name[NAME_LENGTH_MAX + 1]; int64_t value; bool declared; }; struct Machine { struct Variable variables[VARIABLES_MAX]; }; enum RunStatus { RUN_DONE, RUN_FAILED }; void machine_init(struct Machine* machine); enum RunStatus execute(struct Machine* machine, const struct Node* statement);