Skip to content

Commit f24e69d

Browse files
committed
Cleanup
1 parent 8d7d96f commit f24e69d

File tree

5 files changed

+28
-28
lines changed

5 files changed

+28
-28
lines changed

src/strands/strands_api.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,23 +152,23 @@ export function initGlobalStrandsAPI(p5, fn, strandsContext) {
152152
// Shared variables with smart context detection
153153
fn[`shared${pascalTypeName}`] = function(name) {
154154
const { id, dimension } = build.variableNode(strandsContext, typeInfo, name);
155-
155+
156156
// Initialize shared variables tracking if not present
157157
if (!strandsContext.sharedVariables) {
158158
strandsContext.sharedVariables = new Map();
159159
}
160-
160+
161161
// Track this shared variable for smart declaration generation
162162
strandsContext.sharedVariables.set(name, {
163163
typeInfo,
164164
usedInVertex: false,
165165
usedInFragment: false,
166166
declared: false
167167
});
168-
168+
169169
return createStrandsNode(id, dimension, strandsContext);
170170
};
171-
171+
172172
// Alias varying* as shared* for backward compatibility
173173
fn[`varying${pascalTypeName}`] = fn[`shared${pascalTypeName}`];
174174
if (pascalTypeName.startsWith('Vec')) {
@@ -293,13 +293,13 @@ export function createShaderHooksFunctions(strandsContext, fn, shader) {
293293
const fragmentHooksWithContext = Object.fromEntries(
294294
Object.entries(shader.hooks.fragment).map(([name, hook]) => [name, { ...hook, shaderContext: 'fragment' }])
295295
);
296-
296+
297297
const availableHooks = {
298298
...vertexHooksWithContext,
299299
...fragmentHooksWithContext,
300300
}
301301
const hookTypes = Object.keys(availableHooks).map(name => shader.hookTypes(name));
302-
302+
303303
const { cfg, dag } = strandsContext;
304304
for (const hookType of hookTypes) {
305305
const hookImplementation = function(hookUserCallback) {

src/strands/strands_codegen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function generateShaderCode(strandsContext) {
4646
generationContext.visitedNodes.add(assignmentNodeID);
4747
}
4848
}
49-
49+
5050
// Reset global assignments for next hook
5151
strandsContext.globalAssignments = [];
5252

src/strands/strands_glslBackend.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,12 @@ export const glslBackend = {
200200
// dependsOn[0] = targetNodeID, dependsOn[1] = sourceNodeID
201201
const targetNodeID = node.dependsOn[0];
202202
const sourceNodeID = node.dependsOn[1];
203-
203+
204204
// Generate the target expression (could be variable or swizzle)
205205
const targetExpr = this.generateExpression(generationContext, dag, targetNodeID);
206206
const sourceExpr = this.generateExpression(generationContext, dag, sourceNodeID);
207207
const semicolon = generationContext.suppressSemicolon ? '' : ';';
208-
208+
209209
// Generate assignment if we have both target and source
210210
if (targetExpr && sourceExpr && targetExpr !== sourceExpr) {
211211
generationContext.write(`${targetExpr} = ${sourceExpr}${semicolon}`);

src/strands/strands_node.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export class StrandsNode {
77
this.id = id;
88
this.strandsContext = strandsContext;
99
this.dimension = dimension;
10-
10+
1111
// Store original identifier for varying variables
1212
const dag = this.strandsContext.dag;
1313
const nodeData = getNodeDataFromID(dag, this.id);
@@ -24,7 +24,7 @@ export class StrandsNode {
2424
const { dag, cfg } = this.strandsContext;
2525
const orig = getNodeDataFromID(dag, this.id);
2626
const baseType = orig?.baseType ?? BaseType.FLOAT;
27-
27+
2828
let newValueID;
2929
if (value instanceof StrandsNode) {
3030
newValueID = value.id;
@@ -36,7 +36,7 @@ export class StrandsNode {
3636
);
3737
newValueID = newVal.id;
3838
}
39-
39+
4040
// For varying variables, we need both assignment generation AND a way to reference by identifier
4141
if (this._originalIdentifier) {
4242
// Create a variable node for the target (the varying variable)
@@ -45,7 +45,7 @@ export class StrandsNode {
4545
{ baseType: this._originalBaseType, dimension: this._originalDimension },
4646
this._originalIdentifier
4747
);
48-
48+
4949
// Create assignment node for GLSL generation
5050
const assignmentNode = createNodeData({
5151
nodeType: NodeType.ASSIGNMENT,
@@ -54,10 +54,10 @@ export class StrandsNode {
5454
});
5555
const assignmentID = getOrCreateNode(dag, assignmentNode);
5656
recordInBasicBlock(cfg, cfg.currentBlock, assignmentID);
57-
57+
5858
// Track for global assignments processing
5959
this.strandsContext.globalAssignments.push(assignmentID);
60-
60+
6161
// Simply update this node to be a variable node with the identifier
6262
// This ensures it always generates the variable name in expressions
6363
const variableNodeData = createNodeData({
@@ -67,19 +67,19 @@ export class StrandsNode {
6767
identifier: this._originalIdentifier
6868
});
6969
const variableID = getOrCreateNode(dag, variableNodeData);
70-
70+
7171
this.id = variableID; // Point to the variable node for expression generation
7272
} else {
7373
this.id = newValueID; // For non-varying variables, just update to new value
7474
}
75-
75+
7676
return this;
7777
}
7878
bridgeSwizzle(swizzlePattern, value) {
7979
const { dag, cfg } = this.strandsContext;
8080
const orig = getNodeDataFromID(dag, this.id);
8181
const baseType = orig?.baseType ?? BaseType.FLOAT;
82-
82+
8383
let newValueID;
8484
if (value instanceof StrandsNode) {
8585
newValueID = value.id;
@@ -91,7 +91,7 @@ export class StrandsNode {
9191
);
9292
newValueID = newVal.id;
9393
}
94-
94+
9595
// For varying variables, create swizzle assignment
9696
if (this._originalIdentifier) {
9797
// Create a variable node for the target with swizzle
@@ -100,7 +100,7 @@ export class StrandsNode {
100100
{ baseType: this._originalBaseType, dimension: this._originalDimension },
101101
this._originalIdentifier
102102
);
103-
103+
104104
// Create a swizzle node for the target (myVarying.xyz)
105105
const swizzleNode = createNodeData({
106106
nodeType: NodeType.OPERATION,
@@ -111,7 +111,7 @@ export class StrandsNode {
111111
dependsOn: [targetVarID]
112112
});
113113
const swizzleID = getOrCreateNode(dag, swizzleNode);
114-
114+
115115
// Create assignment node: myVarying.xyz = value
116116
const assignmentNode = createNodeData({
117117
nodeType: NodeType.ASSIGNMENT,
@@ -120,10 +120,10 @@ export class StrandsNode {
120120
});
121121
const assignmentID = getOrCreateNode(dag, assignmentNode);
122122
recordInBasicBlock(cfg, cfg.currentBlock, assignmentID);
123-
123+
124124
// Track for global assignments processing in the current hook context
125125
this.strandsContext.globalAssignments.push(assignmentID);
126-
126+
127127
// Simply update this node to be a variable node with the identifier
128128
// This ensures it always generates the variable name in expressions
129129
const variableNodeData = createNodeData({
@@ -133,12 +133,12 @@ export class StrandsNode {
133133
identifier: this._originalIdentifier
134134
});
135135
const variableID = getOrCreateNode(dag, variableNodeData);
136-
136+
137137
this.id = variableID; // Point to the variable node, not the assignment node
138138
} else {
139139
this.id = newValueID; // For non-varying variables, just update to new value
140140
}
141-
141+
142142
return this;
143143
}
144144
getValue() {
@@ -150,7 +150,7 @@ export class StrandsNode {
150150
);
151151
return createStrandsNode(id, dimension, this.strandsContext);
152152
}
153-
153+
154154
return this;
155155
}
156156
}

src/strands/strands_transpiler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ const ASTCallbacks = {
201201
// Note: node.left.object might be worldPos.getValue() due to prior Identifier transformation
202202
else if (node.left.type === 'MemberExpression') {
203203
let varyingName = null;
204-
204+
205205
// Check if it's a direct identifier: myVarying.xyz
206206
if (node.left.object.type === 'Identifier' && _state.varyings[node.left.object.name]) {
207207
varyingName = node.left.object.name;
@@ -215,7 +215,7 @@ const ASTCallbacks = {
215215
_state.varyings[node.left.object.expression.callee.object.name]) {
216216
varyingName = node.left.object.expression.callee.object.name;
217217
}
218-
218+
219219
if (varyingName) {
220220
const swizzlePattern = node.left.property.name;
221221
node.type = 'ExpressionStatement';

0 commit comments

Comments
 (0)