Got the compiler partially working

This commit is contained in:
2022-08-05 16:29:12 +01:00
parent 1ff32fe101
commit cd05d5d84a
17 changed files with 601 additions and 26 deletions

21
source/compiler.h Normal file
View File

@@ -0,0 +1,21 @@
#pragma once
#include "opcodes.h"
#include "node.h"
#include "literal_array.h"
//the compiler takes the nodes, and turns them into sequential chunks of bytecode, saving literals to an external array
typedef struct Compiler {
LiteralArray literalCache;
unsigned char* bytecode;
int capacity;
int count;
} Compiler;
void initCompiler(Compiler* compiler);
void writeCompiler(Compiler* compiler, Node* node);
void freeCompiler(Compiler* compiler);
//embed the header with version information, data section, code section, etc.
char* collateCompiler(Compiler* compiler, int* size);