MCPcopy Create free account
hub / github.com/ShaderFrog/glsl-parser / renameBinding

Function renameBinding

src/parser/utils.ts:12–32  ·  view source on GitHub ↗
(binding: ScopeEntry, newName: string)

Source from the content-addressed store, hash-verified

10} from './scope.js';
11
12export const renameBinding = (binding: ScopeEntry, newName: string) => {
13 binding.references.forEach((node) => {
14 if (node.type === 'declaration') {
15 node.identifier.identifier = newName;
16 } else if (node.type === 'identifier') {
17 node.identifier = newName;
18 } else if (node.type === 'parameter_declaration' && node.identifier) {
19 node.identifier.identifier = newName;
20 /* Ignore case of:
21 layout(std140,column_major) uniform;
22 uniform Material {
23 uniform vec2 prop;
24 }
25 */
26 } else if (node.type !== 'interface_declarator') {
27 console.warn('Unknown binding node', node);
28 throw new Error(`Binding for type ${node.type} not recognized`);
29 }
30 });
31 return binding;
32};
33
34export const renameBindings = (
35 bindings: ScopeIndex,

Callers 1

renameBindingsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected