|
|
|
@ -38,9 +38,10 @@ export function is_state_source(binding, analysis) {
|
|
|
|
|
*/
|
|
|
|
|
export function can_be_parallelized(expression, scope, analysis, bindings) {
|
|
|
|
|
let has_closures = false;
|
|
|
|
|
let should_stop = false;
|
|
|
|
|
/** @type {Set<string>} */
|
|
|
|
|
const references = new Set();
|
|
|
|
|
walk(expression, null, {
|
|
|
|
|
walk(/** @type {Node} */ (expression), null, {
|
|
|
|
|
ArrowFunctionExpression(_, { stop }) {
|
|
|
|
|
has_closures = true;
|
|
|
|
|
stop();
|
|
|
|
@ -53,9 +54,25 @@ export function can_be_parallelized(expression, scope, analysis, bindings) {
|
|
|
|
|
if (is_reference(node, /** @type {Node} */ (path.at(-1)))) {
|
|
|
|
|
references.add(node.name);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
MemberExpression(node, { stop }) {
|
|
|
|
|
should_stop = true;
|
|
|
|
|
stop();
|
|
|
|
|
},
|
|
|
|
|
CallExpression(node, { stop }) {
|
|
|
|
|
should_stop = true;
|
|
|
|
|
stop();
|
|
|
|
|
},
|
|
|
|
|
NewExpression(node, { stop }) {
|
|
|
|
|
should_stop = true;
|
|
|
|
|
stop();
|
|
|
|
|
},
|
|
|
|
|
StaticBlock(node, { stop }) {
|
|
|
|
|
has_closures = true;
|
|
|
|
|
stop();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if (has_closures) {
|
|
|
|
|
if (has_closures || should_stop) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
for (const reference of references) {
|
|
|
|
|