Fixed parameter strings in data section

Fucking finally.
This commit is contained in:
2026-05-26 18:51:24 +10:00
parent 190477add8
commit bbb1e38649
+4 -4
View File
@@ -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 //mark the position within the jump index, reusing an existing entry if it exists
for (unsigned int i = 0; i < (*mb)->jumpsCount; i++) { for (unsigned int i = 0; i < (*mb)->jumpsCount; i += 4) {
if ((*mb)->jumps[i] == dataAddr) { if (*(unsigned int*)((*mb)->jumps + i) == dataAddr) {
//reuse, and finish //reuse, and finish
EMIT_INT(mb, code, i); EMIT_INT(mb, code, i);
return 1; 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); 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 //check the param index for that entry i.e. don't reuse parameter names
for (unsigned int i = 0; i < mb->paramCount; i++) { for (unsigned int i = 0; i < mb->paramCount; i+=4) {
if (mb->param[i] == dataAddr) { if (*(unsigned int*)(mb->param + i) == dataAddr) {
//not allowed //not allowed
fprintf(stderr, TOY_CC_ERROR "COMPILER ERROR: Function parameters must have unique names\n" TOY_CC_RESET); fprintf(stderr, TOY_CC_ERROR "COMPILER ERROR: Function parameters must have unique names\n" TOY_CC_RESET);
mb->panic = true; mb->panic = true;