The state of the current && and || support is that the parser recognizes these constructs and generates semantic structures for them. The problem is that the part of the compiler which is supposed to generate the respective pseudo code is currently a mere assert() saying that these operators are not yet implemented.
The particular problem of implementing these two is their short-circuit evaluation. When you have, for example, A && B, you first need to evaluate A and if it evaluates to true, only then you can start evaluating B. Without this special feature of C/C++, I'd be able to implement && and || in half a minute, using the already existing template for binary operands. With short-circuit evaluation in place, I need to insert a couple of extra pseudo instructions in the right order:
- L = evaluate(A)
- PI_BF(L, msp2) /* skip evaluation of B */
- R = evaulate(B)
- DEST = PI_LAND(L, R) /* logical AND */
- PI_MOV(L, DEST)
While I am quite successful in generating code for the end of the sequence, I can't figure out how to place the PI_BF pseudo instruction without generating an infinite loop. My guess is that somewhere in the Lestes code, something enforces the opposite order of evaluation of A and B. That would, of course, made the topological sort algorithm spin forever. I've tried to place the instruction between psp and nsp of the entire expression. That got me rid of the infinit loop, but I didn't get the right order.
I also can't figure out how to express the above 14 steps in the SSA form so that the DEST register is assigned to only once and there exists a single pseudo instruction which can be denoted as the origin of the register value.
Well, I guess I need to keep on trying. Every failure like this teaches me something new from Lestes and maybe it's worth the trouble just because of that.