Notes on unary EQZ in compileBinary EQ

This commit is contained in:
dcodeIO
2018-01-02 23:20:57 +01:00
parent f507fc8168
commit fb2b7aa96b
4 changed files with 47 additions and 63 deletions

View File

@ -1545,6 +1545,11 @@ export class Compiler extends DiagnosticEmitter {
case Token.EQUALS_EQUALS:
case Token.EQUALS_EQUALS_EQUALS:
// NOTE that this favors correctness, in terms of emitting a binary expression, over
// checking for a possible use of unary EQZ. while the most classic of all optimizations,
// that's not what the source told us to do. for reference, `!left` emits unary EQZ.
left = this.compileExpression(expression.left, contextualType, ConversionKind.NONE);
right = this.compileExpression(expression.right, this.currentType);