Closed djrieger closed 9 years ago
I'm not sure whether short circuiting is currently possible with our design or not. However, I gave this some thought, what has to happen in the different binary operations:
ast::ue::Not Fairly obvious, just switch trueTarget and falseTarget.
ast::be::OrOr When the ExpressionVisitor visits the OrOr-node, a new jumptarget/block has to be created. Also, it is not possible to recycle the current ExpressionVisitor because of this. The trueTarget for the left child is the currentTrue target. The falseTarget for the left child is the newly created Block in which the right child is to placed/constructed. The trueTarget for the right child is the original trueTarget and the same applies for the falseTarget.
ast::be::AndAnd
Again a new block becomes necessary. However:
leftChild.trueTarget = BlockForRightChild, leftChild.falseTarget = current.falseTarget; rightChild.trueTarget = current.trueTarget, rightChild.falseTarget = current.falseTarget
Thus, it doesn't seem to be possible to use the generic visitBinaryExpression(...)
for AndAnd
and OrOr
. If this is implemented and works, the StatementVisitor for IfStatement has to be adapted as then, the (empty) blocks from the appropriate blocks of the jumpTargets have to be used instead of creating new blocks in visitThenOrElse(...)
.
It might be possible to ditch the jumpTarget stuff and just use blocks.
If this works, it will probably also work for while statements.
Completely got rid of all uses of JumpTarget. Short circuiting seems to work correctly for all combinations of Not, AndAnd and OrOr as of e332754861be4a7305afcce3b2f10e8243632a74
Currently segfaults on If conditions such as
7 == 4 || 1 < 1
.