parse expresions with no output register but with internal subeffects properly; fixes #3141
This commit is contained in:
Родитель
a1974e9812
Коммит
e22c24cd7b
|
@ -4449,6 +4449,15 @@ function _main() {
|
|||
}
|
||||
''', [], '0\n')
|
||||
|
||||
do_js_test('effectless expressions, with a subeffect', r'''
|
||||
function _main() {
|
||||
(print (123) | 0) != 0;
|
||||
print (456) | 0;
|
||||
0 != (print (789) | 0);
|
||||
0 | (print (159) | 0);
|
||||
}
|
||||
''', [], '123\n456\n789\n159\n')
|
||||
|
||||
# codegen log tests
|
||||
|
||||
def do_log_test(source, expected, func):
|
||||
|
|
|
@ -6368,8 +6368,21 @@ function emterpretify(ast) {
|
|||
|
||||
if (dropIt) {
|
||||
// a pointless thing we can drop entirely
|
||||
assert(!hasSideEffects(node));
|
||||
return [-1, []];
|
||||
var ret = [-1, []];
|
||||
if (hasSideEffects(node)) {
|
||||
// something here has side effects, emit it but drop the result
|
||||
if (hasSideEffects(node[2])) {
|
||||
var left = getReg(node[2]);
|
||||
releaseIfFree(left[0]);
|
||||
ret[1] = left[1];
|
||||
}
|
||||
if (hasSideEffects(node[3])) {
|
||||
var right = getReg(node[3]);
|
||||
releaseIfFree(right[0]);
|
||||
ret[1] = ret[1].concat(right[1]);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
switch (node[1]) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче