Compiler test is passing

This commit is contained in:
2026-04-07 20:36:58 +10:00
parent f25e81cd09
commit 09fc6d5279
2 changed files with 1439 additions and 5 deletions

View File

@@ -155,7 +155,11 @@ static unsigned int emitString(Toy_Bytecode** mb, Toy_String* str) {
free(buffer); free(buffer);
} }
else if (str->info.type == TOY_STRING_LEAF) { else if (str->info.type == TOY_STRING_LEAF) {
dataAddr = emitCStringToData(&(*mb)->data, &(*mb)->dataCapacity, &(*mb)->dataCount, str->leaf.data); char buffer[str->info.length + 1]; //BUGFIX: make sure its a null-terminated c-string
memcpy(buffer, str->leaf.data, str->info.length);
buffer[str->info.length] = '\0';
dataAddr = emitCStringToData(&(*mb)->data, &(*mb)->dataCapacity, &(*mb)->dataCount, buffer);
} }
//mark the position within the jump index, reusing an existing entry if it exists //mark the position within the jump index, reusing an existing entry if it exists
@@ -783,7 +787,7 @@ static unsigned int writeInstructionVarDeclare(Toy_Bytecode** mb, Toy_AstVarDecl
//delcare with the given name string //delcare with the given name string
EMIT_BYTE(mb, code, TOY_OPCODE_DECLARE); EMIT_BYTE(mb, code, TOY_OPCODE_DECLARE);
EMIT_BYTE(mb, code, ast.type); EMIT_BYTE(mb, code, ast.valueType);
EMIT_BYTE(mb, code, ast.name->info.length); //quick optimisation to skip a 'strlen()' call EMIT_BYTE(mb, code, ast.name->info.length); //quick optimisation to skip a 'strlen()' call
EMIT_BYTE(mb, code, ast.constant); //check for constness EMIT_BYTE(mb, code, ast.constant); //check for constness

File diff suppressed because it is too large Load Diff