|
|
@ -24,7 +24,7 @@ import TemplateScope from './nodes/shared/TemplateScope';
|
|
|
|
import fuzzymatch from '../utils/fuzzymatch';
|
|
|
|
import fuzzymatch from '../utils/fuzzymatch';
|
|
|
|
import get_object from './utils/get_object';
|
|
|
|
import get_object from './utils/get_object';
|
|
|
|
import Slot from './nodes/Slot';
|
|
|
|
import Slot from './nodes/Slot';
|
|
|
|
import { Node, ImportDeclaration, ExportNamedDeclaration, Identifier, ExpressionStatement, AssignmentExpression, Literal, Property, RestElement, ExportDefaultDeclaration, ExportAllDeclaration } from 'estree';
|
|
|
|
import { Node, ImportDeclaration, ExportNamedDeclaration, Identifier, ExpressionStatement, AssignmentExpression, Literal, Property, RestElement, ExportDefaultDeclaration, ExportAllDeclaration, FunctionDeclaration, FunctionExpression } from 'estree';
|
|
|
|
import add_to_set from './utils/add_to_set';
|
|
|
|
import add_to_set from './utils/add_to_set';
|
|
|
|
import check_graph_for_cycles from './utils/check_graph_for_cycles';
|
|
|
|
import check_graph_for_cycles from './utils/check_graph_for_cycles';
|
|
|
|
import { print, b } from 'code-red';
|
|
|
|
import { print, b } from 'code-red';
|
|
|
@ -766,12 +766,13 @@ export default class Component {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
let scope_updated = false;
|
|
|
|
let scope_updated = false;
|
|
|
|
|
|
|
|
|
|
|
|
let generator_count = 0;
|
|
|
|
const current_function_stack = [];
|
|
|
|
|
|
|
|
let current_function: FunctionDeclaration | FunctionExpression = null;
|
|
|
|
|
|
|
|
|
|
|
|
walk(content, {
|
|
|
|
walk(content, {
|
|
|
|
enter(node: Node, parent: Node, prop, index) {
|
|
|
|
enter(node: Node, parent: Node, prop, index) {
|
|
|
|
if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression') && node.generator === true) {
|
|
|
|
if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression')) {
|
|
|
|
generator_count++;
|
|
|
|
current_function_stack.push(current_function = node);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (map.has(node)) {
|
|
|
|
if (map.has(node)) {
|
|
|
@ -800,12 +801,13 @@ export default class Component {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
leave(node: Node) {
|
|
|
|
leave(node: Node) {
|
|
|
|
if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression') && node.generator === true) {
|
|
|
|
if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression')) {
|
|
|
|
generator_count--;
|
|
|
|
current_function_stack.pop();
|
|
|
|
|
|
|
|
current_function = current_function_stack[current_function_stack.length - 1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// do it on leave, to prevent infinite loop
|
|
|
|
// do it on leave, to prevent infinite loop
|
|
|
|
if (component.compile_options.dev && component.compile_options.loopGuardTimeout > 0 && generator_count <= 0) {
|
|
|
|
if (component.compile_options.dev && component.compile_options.loopGuardTimeout > 0 && (!current_function || (!current_function.generator && !current_function.async))) {
|
|
|
|
const to_replace_for_loop_protect = component.loop_protect(node, scope, component.compile_options.loopGuardTimeout);
|
|
|
|
const to_replace_for_loop_protect = component.loop_protect(node, scope, component.compile_options.loopGuardTimeout);
|
|
|
|
if (to_replace_for_loop_protect) {
|
|
|
|
if (to_replace_for_loop_protect) {
|
|
|
|
this.replace(to_replace_for_loop_protect);
|
|
|
|
this.replace(to_replace_for_loop_protect);
|
|
|
|