Store complex types in variables

This commit is contained in:
2022-08-22 13:28:44 +01:00
parent 45920f763c
commit 300f8e382b
5 changed files with 51 additions and 10 deletions

View File

@@ -157,8 +157,15 @@ static int writeLiteralTypeToCache(LiteralArray* literalCache, Literal literal)
static int writeLiteralToCompiler(Compiler* compiler, Literal literal) {
//get the index
int index = findLiteralIndex(&compiler->literalCache, literal);
if (index < 0) {
index = pushLiteralArray(&compiler->literalCache, literal);
if (IS_TYPE(literal)) {
//check for the type literal as value
index = writeLiteralTypeToCache(&compiler->literalCache, literal);
}
else {
index = pushLiteralArray(&compiler->literalCache, literal);
}
}
//push the literal to the bytecode