|
|
@ -6,7 +6,7 @@ import { extract_identifiers } from '../../../../utils/ast.js';
|
|
|
|
import * as b from '#compiler/builders';
|
|
|
|
import * as b from '#compiler/builders';
|
|
|
|
import { create_derived } from '../utils.js';
|
|
|
|
import { create_derived } from '../utils.js';
|
|
|
|
import { get_value } from './shared/declarations.js';
|
|
|
|
import { get_value } from './shared/declarations.js';
|
|
|
|
import { build_legacy_expression } from './shared/utils.js';
|
|
|
|
import { build_legacy_expression, build_legacy_expression_2 } from './shared/utils.js';
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @param {AST.ConstTag} node
|
|
|
|
* @param {AST.ConstTag} node
|
|
|
@ -18,7 +18,7 @@ export function ConstTag(node, context) {
|
|
|
|
if (declaration.id.type === 'Identifier') {
|
|
|
|
if (declaration.id.type === 'Identifier') {
|
|
|
|
const init = context.state.analysis.runes
|
|
|
|
const init = context.state.analysis.runes
|
|
|
|
? /** @type {Expression} */ (context.visit(declaration.init))
|
|
|
|
? /** @type {Expression} */ (context.visit(declaration.init))
|
|
|
|
: build_legacy_expression(declaration.init, context);
|
|
|
|
: build_legacy_expression_2(context, declaration.init, node.metadata.expression);
|
|
|
|
context.state.init.push(b.const(declaration.id, create_derived(context.state, b.thunk(init))));
|
|
|
|
context.state.init.push(b.const(declaration.id, create_derived(context.state, b.thunk(init))));
|
|
|
|
|
|
|
|
|
|
|
|
context.state.transform[declaration.id.name] = { read: get_value };
|
|
|
|
context.state.transform[declaration.id.name] = { read: get_value };
|
|
|
@ -46,7 +46,11 @@ export function ConstTag(node, context) {
|
|
|
|
// instead of destructuring it only to return a new object
|
|
|
|
// instead of destructuring it only to return a new object
|
|
|
|
const init = context.state.analysis.runes
|
|
|
|
const init = context.state.analysis.runes
|
|
|
|
? /** @type {Expression} */ (context.visit(declaration.init, child_state))
|
|
|
|
? /** @type {Expression} */ (context.visit(declaration.init, child_state))
|
|
|
|
: build_legacy_expression(declaration.init, { ...context, state: child_state });
|
|
|
|
: build_legacy_expression_2(
|
|
|
|
|
|
|
|
{ ...context, state: child_state },
|
|
|
|
|
|
|
|
declaration.init,
|
|
|
|
|
|
|
|
node.metadata.expression
|
|
|
|
|
|
|
|
);
|
|
|
|
const fn = b.arrow(
|
|
|
|
const fn = b.arrow(
|
|
|
|
[],
|
|
|
|
[],
|
|
|
|
b.block([
|
|
|
|
b.block([
|
|
|
|