Fixed bug when processing the body of a class and a DNode was hit which was not one of the allowed types:

1. VariableDeclaration

Previously we added back the `varDecInstr` which is post-cast and if the cast failed (hence hitting this !varDecInstr branch) we didn't add back `instr` but rather added back `varDecInstr` which is 0 instead of being non-zero.

This later is incorrect.
This commit is contained in:
Tristan B. Velloza Kildaire 2022-09-18 21:52:11 +02:00
parent aae5dbabe8
commit 449e878796
1 changed files with 12 additions and 2 deletions

View File

@ -653,7 +653,6 @@ public final class TypeChecker
/* TODO: Make sure this is correct */ /* TODO: Make sure this is correct */
addInstr(varDecInstr); addInstr(varDecInstr);
gprintln("Hello>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); gprintln("Hello>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
} }
@ -688,12 +687,16 @@ public final class TypeChecker
/* If not VariableDeclaration push back and end */ /* If not VariableDeclaration push back and end */
if(!varDecInstr) if(!varDecInstr)
{ {
addInstr(varDecInstr); addInstr(instr);
assert(varDecInstr is null);
assert(instr);
break; break;
} }
/* If, then make sure related to this class */ /* If, then make sure related to this class */
else else
{ {
gprintln("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
/* TODO: Fetch the variable's context */ /* TODO: Fetch the variable's context */
Variable varDecPNode = cast(Variable)resolver.resolveBest(clazzPNode, varDecInstr.varName); Variable varDecPNode = cast(Variable)resolver.resolveBest(clazzPNode, varDecInstr.varName);
gprintln(varDecPNode); gprintln(varDecPNode);
@ -767,6 +770,11 @@ public final class TypeChecker
VariableAssignmentInstr vAInstr = new VariableAssignmentInstr(variableName, valueInstr); VariableAssignmentInstr vAInstr = new VariableAssignmentInstr(variableName, valueInstr);
addInstrB(vAInstr); addInstrB(vAInstr);
} }
/* Case of no matches */
else
{
gprintln("NO MATCHES FIX ME FOR: "~to!(string)(statement), DebugType.WARNING);
}
} }
@ -788,7 +796,9 @@ public final class TypeChecker
gprintln("Process: "~to!(string)(node)); gprintln("Process: "~to!(string)(node));
/* Print the code queue each time */ /* Print the code queue each time */
gprintln("sdfhjkhdsfjhfdsj 1");
printCodeQueue(); printCodeQueue();
gprintln("sdfhjkhdsfjhfdsj 2");
/** /**
* Now depending on thr DNode type we should * Now depending on thr DNode type we should