#pragma once #include #include "compiler/parser/parser.h" typedef enum Command { COMMAND_NONE = 0, COMMAND_PRINT, COMMAND_PUSH_STRING, } Command; extern const char *COMMAND_STRINGS[]; typedef struct Instruction { Command command; void *operand; } Instruction; typedef struct Instructions { Instruction *restrict instructions; size_t size; } Instructions; extern void printInstruction(Instruction instruction); extern void printInstructions(Instructions instructions); extern void deleteInstruction(Instruction instruction); extern void deleteInstructions(Instructions instructions); extern Instructions codeGenerator(ParsedNode *root); extern bool nodeToInstruction(ParsedNode *node, Instruction **instructions, size_t *instructions_size, size_t *instructions_inserted); extern void insertInstruction(const Instruction instruction, Instruction **restrict instructions, size_t *restrict instructions_size, size_t *restrict instructions_inserted); extern SizedString *nodeToString(ParsedNode const *node);