From bbb1e3864987de13f70bf212dc4915f1107bca20 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Tue, 26 May 2026 18:51:24 +1000 Subject: [PATCH] Fixed parameter strings in data section Fucking finally. --- source/toy_compiler.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/toy_compiler.c b/source/toy_compiler.c index a73669f..21f76ca 100644 --- a/source/toy_compiler.c +++ b/source/toy_compiler.c @@ -169,8 +169,8 @@ static unsigned int emitString(Toy_Bytecode** mb, Toy_String* str) { } //mark the position within the jump index, reusing an existing entry if it exists - for (unsigned int i = 0; i < (*mb)->jumpsCount; i++) { - if ((*mb)->jumps[i] == dataAddr) { + for (unsigned int i = 0; i < (*mb)->jumpsCount; i += 4) { + if (*(unsigned int*)((*mb)->jumps + i) == dataAddr) { //reuse, and finish EMIT_INT(mb, code, i); return 1; @@ -206,8 +206,8 @@ static unsigned int emitParameters(Toy_Bytecode* mb, Toy_Ast* ast) { unsigned int dataAddr = emitCStringToData(&(mb->data), &(mb->dataCapacity), &(mb->dataCount), buffer); //check the param index for that entry i.e. don't reuse parameter names - for (unsigned int i = 0; i < mb->paramCount; i++) { - if (mb->param[i] == dataAddr) { + for (unsigned int i = 0; i < mb->paramCount; i+=4) { + if (*(unsigned int*)(mb->param + i) == dataAddr) { //not allowed fprintf(stderr, TOY_CC_ERROR "COMPILER ERROR: Function parameters must have unique names\n" TOY_CC_RESET); mb->panic = true;