Wrote the interpreter

This commit is contained in:
2022-08-06 07:58:32 +01:00
parent 0048c92cf5
commit 7a3986af33
10 changed files with 292 additions and 27 deletions

View File

@@ -13,9 +13,9 @@ void initCompiler(Compiler* compiler) {
Literal t = TO_BOOLEAN_LITERAL(true);
Literal f = TO_BOOLEAN_LITERAL(false);
writeLiteralArray(&compiler->literalCache, n);
writeLiteralArray(&compiler->literalCache, t);
writeLiteralArray(&compiler->literalCache, f);
pushLiteralArray(&compiler->literalCache, n);
pushLiteralArray(&compiler->literalCache, t);
pushLiteralArray(&compiler->literalCache, f);
}
void writeCompiler(Compiler* compiler, Node* node) {
@@ -33,7 +33,7 @@ void writeCompiler(Compiler* compiler, Node* node) {
//ensure the literal is in the cache
int index = findLiteralIndex(&compiler->literalCache, node->atomic.literal);
if (index < 0) {
index = writeLiteralArray(&compiler->literalCache, node->atomic.literal);
index = pushLiteralArray(&compiler->literalCache, node->atomic.literal);
}
//push the node opcode to the bytecode