|
|
@ -138,14 +138,10 @@ export function VariableDeclaration(node, context) {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (declarator.id.type === 'Identifier') {
|
|
|
|
if (declarator.id.type === 'Identifier') {
|
|
|
|
|
|
|
|
const expression = /** @type {Expression} */ (context.visit(value));
|
|
|
|
|
|
|
|
|
|
|
|
declarations.push(
|
|
|
|
declarations.push(
|
|
|
|
b.declarator(
|
|
|
|
b.declarator(declarator.id, create_state_declarator(declarator.id, expression))
|
|
|
|
declarator.id,
|
|
|
|
|
|
|
|
create_state_declarator(
|
|
|
|
|
|
|
|
declarator.id,
|
|
|
|
|
|
|
|
/** @type {Expression} */ (context.visit(value))
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
);
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
const tmp = b.id(context.state.scope.generate('tmp'));
|
|
|
|
const tmp = b.id(context.state.scope.generate('tmp'));
|
|
|
@ -157,10 +153,8 @@ export function VariableDeclaration(node, context) {
|
|
|
|
id.name = context.state.scope.generate('$$array');
|
|
|
|
id.name = context.state.scope.generate('$$array');
|
|
|
|
context.state.transform[id.name] = { read: get_value };
|
|
|
|
context.state.transform[id.name] = { read: get_value };
|
|
|
|
|
|
|
|
|
|
|
|
return b.declarator(
|
|
|
|
const expression = /** @type {Expression} */ (context.visit(b.thunk(value)));
|
|
|
|
id,
|
|
|
|
return b.declarator(id, b.call('$.derived', expression));
|
|
|
|
b.call('$.derived', /** @type {Expression} */ (context.visit(b.thunk(value))))
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
...paths.map((path) => {
|
|
|
|
...paths.map((path) => {
|
|
|
|
const value = /** @type {Expression} */ (context.visit(path.expression));
|
|
|
|
const value = /** @type {Expression} */ (context.visit(path.expression));
|
|
|
@ -205,12 +199,8 @@ export function VariableDeclaration(node, context) {
|
|
|
|
id.name = context.state.scope.generate('$$array');
|
|
|
|
id.name = context.state.scope.generate('$$array');
|
|
|
|
context.state.transform[id.name] = { read: get_value };
|
|
|
|
context.state.transform[id.name] = { read: get_value };
|
|
|
|
|
|
|
|
|
|
|
|
declarations.push(
|
|
|
|
const expression = /** @type {Expression} */ (context.visit(b.thunk(value)));
|
|
|
|
b.declarator(
|
|
|
|
declarations.push(b.declarator(id, b.call('$.derived', expression)));
|
|
|
|
id,
|
|
|
|
|
|
|
|
b.call('$.derived', /** @type {Expression} */ (context.visit(b.thunk(value))))
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (const path of paths) {
|
|
|
|
for (const path of paths) {
|
|
|
@ -261,12 +251,8 @@ export function VariableDeclaration(node, context) {
|
|
|
|
id.name = context.state.scope.generate('$$array');
|
|
|
|
id.name = context.state.scope.generate('$$array');
|
|
|
|
context.state.transform[id.name] = { read: get_value };
|
|
|
|
context.state.transform[id.name] = { read: get_value };
|
|
|
|
|
|
|
|
|
|
|
|
declarations.push(
|
|
|
|
const expression = /** @type {Expression} */ (context.visit(b.thunk(value)));
|
|
|
|
b.declarator(
|
|
|
|
declarations.push(b.declarator(id, b.call('$.derived', expression)));
|
|
|
|
id,
|
|
|
|
|
|
|
|
b.call('$.derived', /** @type {Expression} */ (context.visit(b.thunk(value))))
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (const path of paths) {
|
|
|
|
for (const path of paths) {
|
|
|
@ -349,10 +335,8 @@ function create_state_declarators(declarator, context, value) {
|
|
|
|
id.name = context.state.scope.generate('$$array');
|
|
|
|
id.name = context.state.scope.generate('$$array');
|
|
|
|
context.state.transform[id.name] = { read: get_value };
|
|
|
|
context.state.transform[id.name] = { read: get_value };
|
|
|
|
|
|
|
|
|
|
|
|
return b.declarator(
|
|
|
|
const expression = /** @type {Expression} */ (context.visit(b.thunk(value)));
|
|
|
|
id,
|
|
|
|
return b.declarator(id, b.call('$.derived', expression));
|
|
|
|
b.call('$.derived', /** @type {Expression} */ (context.visit(b.thunk(value))))
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
...paths.map((path) => {
|
|
|
|
...paths.map((path) => {
|
|
|
|
const value = /** @type {Expression} */ (context.visit(path.expression));
|
|
|
|
const value = /** @type {Expression} */ (context.visit(path.expression));
|
|
|
|