Skip to content

Commit

Permalink
DNodeGenerator
Browse files Browse the repository at this point in the history
- Updated code for handling the `WhileLoop` AST statement
  • Loading branch information
deavmi committed May 19, 2024
1 parent aa5533e commit aafa429
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions source/tlang/compiler/typecheck/dependency/core.d
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,9 @@ public class DNodeGenerator
DNode branchDNode = pool(whileBranch);
DEBUG("Branch: "~to!(string)(whileBranch));

// If this is a while-loop
/**
* while-loop
*/
if(!whileLoopStmt.isDoWhileLoop())
{
// Extract the condition
Expand All @@ -1345,13 +1347,15 @@ public class DNodeGenerator
// Finally make the branchDNode depend on the body dnode (above)
branchDNode.needs(branchBodyDNode);
}
// If this is a do-while loop
// TODO: I don't think we really need to reverse this?
// Logically we should, but the typechecker will add this things in the correct order anyways?
// We need to look into this!
// Our nodes at the back will always be placed at the back, and the expression will end ip upfront
// i think it is a problem oif maybe other expressions are left on the stack but is that ever a problem
//now with the statement <-> instruction mapping (like will that ever even occur?)
/**
* do-while loop
*
* The order of dependencies is basically
* switched from [expr, stmts...] to
* [stmts..., expr] but at the end of the
* day the way it is processed by the
* typechecker won't change
*/
else
{
// Pass over the statements in the branch's body
Expand All @@ -1375,8 +1379,6 @@ public class DNodeGenerator
/* Make the while-loop/do-while loop depend on the branchDNode */
whileLoopDNode.needs(branchDNode);

/* Make the node of this generalPass we are in depend on the whileLoop's DNode */
// node.needs(whileLoopDNode);
return whileLoopDNode;
}
/**
Expand Down

0 comments on commit aafa429

Please sign in to comment.