Skip to content

Commit 1b6f33f

Browse files
committed
Put back code that got lost in the merge
1 parent 0a4b172 commit 1b6f33f

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

src/strands/ir_builders.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,5 @@ export function arrayAssignmentNode(strandsContext, bufferNode, indexNode, value
704704
// CRITICAL: Record in CFG to preserve sequential ordering
705705
CFG.recordInBasicBlock(cfg, cfg.currentBlock, assignmentID);
706706

707-
// Track for global assignments processing
708-
strandsContext.globalAssignments.push(assignmentID);
709-
710707
return { id: assignmentID };
711708
}

src/strands/strands_transpiler.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ const ASTCallbacks = {
212212
];
213213
let isSwizzle = swizzleSets.some(set =>
214214
[...property].every(char => set.includes(char))
215-
) && node.argument.type === 'MemberExpression';
215+
) && node.argument.type === 'MemberExpression' && !node.argument.computed;
216216
if (isSwizzle) {
217217
node.type = 'MemberExpression';
218218
node.object = {
@@ -245,6 +245,28 @@ const ASTCallbacks = {
245245
node.arguments = [];
246246
node.type = 'CallExpression';
247247
},
248+
MemberExpression(node, _state, ancestors) {
249+
if (ancestors.some(nodeIsUniform)) { return; }
250+
// Skip sets -- these will be converted to .set() method
251+
// calls at the AssignmentExpression level
252+
if (ancestors.at(-2)?.type === 'AssignmentExpression') return;
253+
if (node.computed) {
254+
const callee = node.object;
255+
const member = node.property;
256+
node.computed = undefined;
257+
node.object = undefined;
258+
node.callee = {
259+
type: 'MemberExpression',
260+
object: callee,
261+
property: {
262+
type: 'Identifier',
263+
name: 'get',
264+
}
265+
};
266+
node.arguments = [member];
267+
node.type = 'CallExpression';
268+
}
269+
},
248270
VariableDeclarator(node, _state, ancestors) {
249271
if (ancestors.some(nodeIsUniform)) { return; }
250272
if (nodeIsUniform(node.init)) {

0 commit comments

Comments
 (0)