|
|
|
@ -2,7 +2,6 @@ import Let from '../../../nodes/Let';
|
|
|
|
|
import { x, p } from 'code-red';
|
|
|
|
|
import Block from '../../Block';
|
|
|
|
|
import TemplateScope from '../../../nodes/shared/TemplateScope';
|
|
|
|
|
import { BinaryExpression } from 'estree';
|
|
|
|
|
|
|
|
|
|
export function get_slot_definition(block: Block, scope: TemplateScope, lets: Let[]) {
|
|
|
|
|
if (lets.length === 0) return { block, scope };
|
|
|
|
@ -36,39 +35,30 @@ export function get_slot_definition(block: Block, scope: TemplateScope, lets: Le
|
|
|
|
|
const changes = {
|
|
|
|
|
type: 'ParenthesizedExpression',
|
|
|
|
|
get expression() {
|
|
|
|
|
if (block.renderer.context_overflow) {
|
|
|
|
|
const grouped = [];
|
|
|
|
|
const grouped = [];
|
|
|
|
|
|
|
|
|
|
Array.from(names).forEach(name => {
|
|
|
|
|
const i = context_lookup.get(name).index.value as number;
|
|
|
|
|
const g = Math.floor(i / 31);
|
|
|
|
|
Array.from(names).forEach(name => {
|
|
|
|
|
const i = context_lookup.get(name).index.value as number;
|
|
|
|
|
const g = Math.floor(i / 31);
|
|
|
|
|
|
|
|
|
|
if (!grouped[g]) grouped[g] = [];
|
|
|
|
|
grouped[g].push({ name, n: i % 31 });
|
|
|
|
|
});
|
|
|
|
|
if (!grouped[g]) grouped[g] = [];
|
|
|
|
|
grouped[g].push({ name, n: i % 31 });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const elements = [];
|
|
|
|
|
const elements = [];
|
|
|
|
|
|
|
|
|
|
for (let g = 0; g < grouped.length; g += 1) {
|
|
|
|
|
elements[g] = grouped[g]
|
|
|
|
|
? grouped[g]
|
|
|
|
|
.map(({ name, n }) => x`${name} ? ${1 << n} : 0`)
|
|
|
|
|
.reduce((lhs, rhs) => x`${lhs} | ${rhs}`)
|
|
|
|
|
: x`0`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
type: 'ArrayExpression',
|
|
|
|
|
elements
|
|
|
|
|
};
|
|
|
|
|
for (let g = 0; g < grouped.length; g += 1) {
|
|
|
|
|
elements[g] = grouped[g]
|
|
|
|
|
? grouped[g]
|
|
|
|
|
.map(({ name, n }) => x`${name} ? ${1 << n} : 0`)
|
|
|
|
|
.reduce((lhs, rhs) => x`${lhs} | ${rhs}`)
|
|
|
|
|
: x`0`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Array.from(names)
|
|
|
|
|
.map(name => {
|
|
|
|
|
const i = context_lookup.get(name).index.value as number;
|
|
|
|
|
return x`${name} ? ${1 << i} : 0`;
|
|
|
|
|
})
|
|
|
|
|
.reduce((lhs, rhs) => x`${lhs} | ${rhs}`) as BinaryExpression;
|
|
|
|
|
return {
|
|
|
|
|
type: 'ArrayExpression',
|
|
|
|
|
elements
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|