Update src/compiler/jsgen.js
Browse files- src/compiler/jsgen.js +7 -2
src/compiler/jsgen.js
CHANGED
@@ -337,7 +337,7 @@ const isSafeConstantForEqualsOptimization = input => {
|
|
337 |
* A frame contains some information about the current substack being compiled.
|
338 |
*/
|
339 |
class Frame {
|
340 |
-
constructor (isLoop, parentKind) {
|
341 |
/**
|
342 |
* Whether the current stack runs in a loop (while, for)
|
343 |
* @type {boolean}
|
@@ -351,6 +351,8 @@ class Frame {
|
|
351 |
*/
|
352 |
this.isLastBlock = false;
|
353 |
|
|
|
|
|
354 |
/**
|
355 |
* General important data that needs to be carried down from other threads.
|
356 |
* @type {boolean}
|
@@ -497,6 +499,9 @@ class JSGenerator {
|
|
497 |
isLastBlockInLoop () {
|
498 |
for (let i = this.frames.length - 1; i >= 0; i--) {
|
499 |
const frame = this.frames[i];
|
|
|
|
|
|
|
500 |
if (!frame.isLastBlock) {
|
501 |
return false;
|
502 |
}
|
@@ -567,7 +572,7 @@ class JSGenerator {
|
|
567 |
const originalSource = this.source;
|
568 |
this.source = '(yield* (function*() {';
|
569 |
// descend now since descendStack modifies source
|
570 |
-
this.descendStack(node.code, new Frame(false, 'control.inlineStackOutput'));
|
571 |
this.source += '})())';
|
572 |
// save edited
|
573 |
const stackSource = this.source;
|
|
|
337 |
* A frame contains some information about the current substack being compiled.
|
338 |
*/
|
339 |
class Frame {
|
340 |
+
constructor (isLoop, parentKind, overrideLoop = false) {
|
341 |
/**
|
342 |
* Whether the current stack runs in a loop (while, for)
|
343 |
* @type {boolean}
|
|
|
351 |
*/
|
352 |
this.isLastBlock = false;
|
353 |
|
354 |
+
this.overrideLoop = overrideLoop
|
355 |
+
|
356 |
/**
|
357 |
* General important data that needs to be carried down from other threads.
|
358 |
* @type {boolean}
|
|
|
499 |
isLastBlockInLoop () {
|
500 |
for (let i = this.frames.length - 1; i >= 0; i--) {
|
501 |
const frame = this.frames[i];
|
502 |
+
if (frame.overrideLoop) {
|
503 |
+
return frame.isLoop
|
504 |
+
}
|
505 |
if (!frame.isLastBlock) {
|
506 |
return false;
|
507 |
}
|
|
|
572 |
const originalSource = this.source;
|
573 |
this.source = '(yield* (function*() {';
|
574 |
// descend now since descendStack modifies source
|
575 |
+
this.descendStack(node.code, new Frame(false, 'control.inlineStackOutput', true));
|
576 |
this.source += '})())';
|
577 |
// save edited
|
578 |
const stackSource = this.source;
|