typegpu 0.11.4 → 0.11.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/types.d.ts CHANGED
@@ -70,6 +70,14 @@ type FunctionScopeLayer = {
70
70
  * All types used in `return` statements.
71
71
  */
72
72
  reportedReturnTypes: Set<BaseData>;
73
+ /**
74
+ * Maps variables to their modifier placeholders
75
+ */
76
+ placeholderForVariable: Map<Snippet, string>;
77
+ /**
78
+ * Local variables that need `var` modifier.
79
+ */
80
+ modifiedVariables: Set<Snippet>;
73
81
  };
74
82
  type SlotBindingLayer = {
75
83
  type: 'slotBinding';
@@ -77,6 +85,7 @@ type SlotBindingLayer = {
77
85
  };
78
86
  type BlockScopeLayer = {
79
87
  type: 'blockScope';
88
+ takenLocalIdentifiers: Set<string>;
80
89
  declarations: Map<string, Snippet>;
81
90
  externals: Map<string, Snippet>;
82
91
  };
@@ -84,6 +93,7 @@ type StackLayer = ItemLayer | SlotBindingLayer | FunctionScopeLayer | BlockScope
84
93
  interface ItemStateStack {
85
94
  readonly itemDepth: number;
86
95
  readonly topItem: ItemLayer;
96
+ readonly topBlockScope: BlockScopeLayer | undefined;
87
97
  readonly topFunctionScope: FunctionScopeLayer | undefined;
88
98
  pushItem(): void;
89
99
  pushSlotBindings(pairs: SlotValuePair[]): void;
@@ -237,8 +247,25 @@ interface ResolutionCtx {
237
247
  * @param name the temporary name to assign to the item (if missing, just returns `callback()`)
238
248
  */
239
249
  withRenamed<T>(item: object, name: string | undefined, callback: () => T): T;
240
- getUniqueName(resource: object): string;
241
- makeNameValid(name: string): string;
250
+ /**
251
+ * @param primer The basis for the unique identifier. Depending on the strategy, or
252
+ * the names already taken, this may be modified to ensure uniqueness.
253
+ * @param scope The scope in which to generate the identifier. 'global' means
254
+ * the identifier is meant to be unique across the entire program, while
255
+ * 'block' means it cannot shadow any existing identifiers visible from
256
+ * within the current block. After the block is popped, any identifiers
257
+ * defined within it are no longer visible.
258
+ * @returns an identifier that is unique within the given scope
259
+ */
260
+ makeUniqueIdentifier(primer: string | undefined, scope: 'global' | 'block'): string;
261
+ isIdentifierTaken(name: string): boolean;
262
+ /**
263
+ * Makes sure the given identifier cannot be generated by {@link makeUniqueIdentifier}
264
+ * within the given scope.
265
+ * @param name The name to reserve
266
+ * @param scope See {@link makeUniqueIdentifier} for a description of the scope parameter.
267
+ */
268
+ reserveIdentifier(name: string, scope: 'global' | 'block'): void;
242
269
  }
243
270
  /**
244
271
  * Houses a method on the symbol '$resolve` that returns a
package/nameRegistry.d.ts DELETED
@@ -1,30 +0,0 @@
1
- //#region src/nameRegistry.d.ts
2
- interface NameRegistry {
3
- /**
4
- * Creates a valid WGSL identifier, each guaranteed to be unique
5
- * in the lifetime of a single resolution process
6
- * (excluding non-global identifiers from popped scopes).
7
- * Should append "_" to primer, followed by some id.
8
- * @param primer Used in the generation process, makes the identifier more recognizable.
9
- * @param global Whether the name should be registered in the global scope (true), or in the current function scope (false)
10
- */
11
- makeUnique(primer: string | undefined, global: boolean): string;
12
- /**
13
- * Creates a valid WGSL identifier.
14
- * Renames identifiers that are WGSL reserved words.
15
- * @param primer Used in the generation process.
16
- *
17
- * @example
18
- * makeValid("notAKeyword"); // "notAKeyword"
19
- * makeValid("struct"); // makeUnique("struct")
20
- * makeValid("struct_1"); // makeUnique("struct_1") (to avoid potential name collisions)
21
- * makeValid("_"); // ERROR (too difficult to make valid to care)
22
- */
23
- makeValid(primer: string): string;
24
- pushFunctionScope(): void;
25
- popFunctionScope(): void;
26
- pushBlockScope(): void;
27
- popBlockScope(): void;
28
- }
29
- //#endregion
30
- export { NameRegistry };