wesl 0.6.0-pre10
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/README.md +31 -0
- package/dist/index.js +4468 -0
- package/dist/index.js.map +1 -0
- package/dist/minified.js +3426 -0
- package/dist/minified.js.map +1 -0
- package/dist/tools/packages/wesl/src/AbstractElems.d.ts +322 -0
- package/dist/tools/packages/wesl/src/Assertions.d.ts +27 -0
- package/dist/tools/packages/wesl/src/BindIdents.d.ts +70 -0
- package/dist/tools/packages/wesl/src/Conditions.d.ts +6 -0
- package/dist/tools/packages/wesl/src/FlattenTreeImport.d.ts +11 -0
- package/dist/tools/packages/wesl/src/LinkedWesl.d.ts +50 -0
- package/dist/tools/packages/wesl/src/Linker.d.ts +87 -0
- package/dist/tools/packages/wesl/src/LinkerUtil.d.ts +3 -0
- package/dist/tools/packages/wesl/src/LiveDeclarations.d.ts +12 -0
- package/dist/tools/packages/wesl/src/LowerAndEmit.d.ts +31 -0
- package/dist/tools/packages/wesl/src/Mangler.d.ts +39 -0
- package/dist/tools/packages/wesl/src/ParseWESL.d.ts +60 -0
- package/dist/tools/packages/wesl/src/ParsedRegistry.d.ts +29 -0
- package/dist/tools/packages/wesl/src/PathUtil.d.ts +6 -0
- package/dist/tools/packages/wesl/src/RawEmit.d.ts +6 -0
- package/dist/tools/packages/wesl/src/Reflection.d.ts +45 -0
- package/dist/tools/packages/wesl/src/Scope.d.ts +81 -0
- package/dist/tools/packages/wesl/src/StandardTypes.d.ts +13 -0
- package/dist/tools/packages/wesl/src/TransformBindingStructs.d.ts +52 -0
- package/dist/tools/packages/wesl/src/Util.d.ts +43 -0
- package/dist/tools/packages/wesl/src/WESLCollect.d.ts +94 -0
- package/dist/tools/packages/wesl/src/WeslBundle.d.ts +13 -0
- package/dist/tools/packages/wesl/src/WeslDevice.d.ts +25 -0
- package/dist/tools/packages/wesl/src/debug/ASTtoString.d.ts +5 -0
- package/dist/tools/packages/wesl/src/debug/ImportToString.d.ts +2 -0
- package/dist/tools/packages/wesl/src/debug/LineWrapper.d.ts +21 -0
- package/dist/tools/packages/wesl/src/debug/ScopeToString.d.ts +6 -0
- package/dist/tools/packages/wesl/src/index.d.ts +11 -0
- package/dist/tools/packages/wesl/src/parse/ImportGrammar.d.ts +5 -0
- package/dist/tools/packages/wesl/src/parse/Keywords.d.ts +4 -0
- package/dist/tools/packages/wesl/src/parse/WeslBaseGrammar.d.ts +5 -0
- package/dist/tools/packages/wesl/src/parse/WeslExpression.d.ts +13 -0
- package/dist/tools/packages/wesl/src/parse/WeslGrammar.d.ts +80 -0
- package/dist/tools/packages/wesl/src/parse/WeslStream.d.ts +44 -0
- package/dist/tools/packages/wesl/src/test/BindWESL.test.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/ConditionLinking.test.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/ConditionalTranslationCases.test.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/ErrorLogging.test.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/Expression.test.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/FlattenTreeImport.test.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/ImportCases.test.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/ImportSyntaxCases.test.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/LinkGlob.test.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/LinkPackage.test.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/Linker.test.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/Mangling.test.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/ParseComments.test.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/ParseConditions.test.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/ParseError.test.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/ParseWESL.test.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/PathUtil.test.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/PrettyGrammar.test.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/Reflection.test.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/ScopeWESL.test.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/TestLink.d.ts +21 -0
- package/dist/tools/packages/wesl/src/test/TestSetup.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/TestUtil.d.ts +40 -0
- package/dist/tools/packages/wesl/src/test/Tokenizer.test.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/TransformBindingStructs.test.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/Util.test.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/VirtualModules.test.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/WeslDevice.test.d.ts +1 -0
- package/dist/tools/packages/wesl/src/test/WgslTests.d.ts +0 -0
- package/dist/tools/packages/wesl/src/vlq/vlq.d.ts +11 -0
- package/package.json +46 -0
- package/src/AbstractElems.ts +446 -0
- package/src/Assertions.ts +51 -0
- package/src/BindIdents.ts +523 -0
- package/src/Conditions.ts +74 -0
- package/src/FlattenTreeImport.ts +55 -0
- package/src/LinkedWesl.ts +184 -0
- package/src/Linker.ts +284 -0
- package/src/LinkerUtil.ts +29 -0
- package/src/LiveDeclarations.ts +31 -0
- package/src/LowerAndEmit.ts +413 -0
- package/src/Mangler.ts +94 -0
- package/src/ParseWESL.ts +157 -0
- package/src/ParsedRegistry.ts +120 -0
- package/src/PathUtil.ts +31 -0
- package/src/RawEmit.ts +102 -0
- package/src/Reflection.ts +334 -0
- package/src/Scope.ts +162 -0
- package/src/StandardTypes.ts +97 -0
- package/src/TransformBindingStructs.ts +319 -0
- package/src/Util.ts +194 -0
- package/src/WESLCollect.ts +614 -0
- package/src/WeslBundle.ts +16 -0
- package/src/WeslDevice.ts +209 -0
- package/src/debug/ASTtoString.ts +290 -0
- package/src/debug/ImportToString.ts +29 -0
- package/src/debug/LineWrapper.ts +70 -0
- package/src/debug/ScopeToString.ts +79 -0
- package/src/index.ts +11 -0
- package/src/parse/ImportGrammar.ts +157 -0
- package/src/parse/Keywords.ts +26 -0
- package/src/parse/WeslBaseGrammar.ts +8 -0
- package/src/parse/WeslExpression.ts +207 -0
- package/src/parse/WeslGrammar.ts +856 -0
- package/src/parse/WeslStream.ts +279 -0
- package/src/test/BindWESL.test.ts +57 -0
- package/src/test/ConditionLinking.test.ts +91 -0
- package/src/test/ConditionalTranslationCases.test.ts +56 -0
- package/src/test/ErrorLogging.test.ts +30 -0
- package/src/test/Expression.test.ts +22 -0
- package/src/test/FlattenTreeImport.test.ts +74 -0
- package/src/test/ImportCases.test.ts +56 -0
- package/src/test/ImportSyntaxCases.test.ts +24 -0
- package/src/test/LinkGlob.test.ts +25 -0
- package/src/test/LinkPackage.test.ts +26 -0
- package/src/test/Linker.test.ts +125 -0
- package/src/test/Mangling.test.ts +45 -0
- package/src/test/ParseComments.test.ts +36 -0
- package/src/test/ParseConditions.test.ts +183 -0
- package/src/test/ParseError.test.ts +36 -0
- package/src/test/ParseWESL.test.ts +1572 -0
- package/src/test/PathUtil.test.ts +34 -0
- package/src/test/PrettyGrammar.test.ts +20 -0
- package/src/test/Reflection.test.ts +172 -0
- package/src/test/ScopeWESL.test.ts +462 -0
- package/src/test/TestLink.ts +82 -0
- package/src/test/TestSetup.ts +4 -0
- package/src/test/TestUtil.ts +126 -0
- package/src/test/Tokenizer.test.ts +135 -0
- package/src/test/TransformBindingStructs.test.ts +230 -0
- package/src/test/Util.test.ts +22 -0
- package/src/test/VirtualModules.test.ts +37 -0
- package/src/test/WeslDevice.test.ts +265 -0
- package/src/test/WgslTests.ts +0 -0
- package/src/test/__snapshots__/ParseDirectives.test.ts.snap +25 -0
- package/src/test/__snapshots__/ParseWESL.test.ts.snap +119 -0
- package/src/test/__snapshots__/RustDirective.test.ts.snap +359 -0
- package/src/test/wgsl_1/main.wgsl +3 -0
- package/src/test/wgsl_1/util.wgsl +1 -0
- package/src/test/wgsl_2/main2.wgsl +3 -0
- package/src/test/wgsl_2/util2.wgsl +1 -0
- package/src/vlq/vlq.ts +94 -0
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import { Span } from '../../mini-parse/src';
|
|
2
|
+
import { DeclIdent, RefIdent, SrcModule } from './Scope.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Structures to describe the 'interesting' parts of a WESL source file.
|
|
5
|
+
*
|
|
6
|
+
* The parts of the source that need to analyze further in the linker
|
|
7
|
+
* are pulled out into these structures.
|
|
8
|
+
*
|
|
9
|
+
* The parts that are uninteresting the the linker are recorded
|
|
10
|
+
* as 'TextElem' nodes, which are generally just copied to the output WGSL
|
|
11
|
+
* along with their containing element.
|
|
12
|
+
*/
|
|
13
|
+
export type AbstractElem = GrammarElem | SyntheticElem;
|
|
14
|
+
export type GrammarElem = ContainerElem | TerminalElem;
|
|
15
|
+
export type ContainerElem = AttributeElem | AliasElem | ConstAssertElem | ConstElem | UnknownExpressionElem | SimpleMemberRef | FnElem | TypedDeclElem | GlobalVarElem | LetElem | ModuleElem | OverrideElem | FnParamElem | StructElem | StructMemberElem | StuffElem | TypeRefElem | VarElem | StatementElem | SwitchClauseElem;
|
|
16
|
+
/** Inspired by https://github.com/wgsl-tooling-wg/wesl-rs/blob/3b2434eac1b2ebda9eb8bfb25f43d8600d819872/crates/wgsl-parse/src/syntax.rs#L364 */
|
|
17
|
+
export type ExpressionElem = Literal | TranslateTimeFeature | RefIdentElem | ParenthesizedExpression | ComponentExpression | ComponentMemberExpression | UnaryExpression | BinaryExpression | FunctionCallExpression;
|
|
18
|
+
export type TerminalElem = DirectiveElem | DeclIdentElem | NameElem | RefIdentElem | TextElem | ImportElem;
|
|
19
|
+
export type GlobalDeclarationElem = AliasElem | ConstElem | FnElem | GlobalVarElem | OverrideElem | StructElem;
|
|
20
|
+
export type DeclarationElem = GlobalDeclarationElem | FnParamElem | VarElem;
|
|
21
|
+
export type ElemWithAttributes = Extract<AbstractElem, HasAttributes>;
|
|
22
|
+
export interface AbstractElemBase {
|
|
23
|
+
kind: AbstractElem["kind"];
|
|
24
|
+
start: number;
|
|
25
|
+
end: number;
|
|
26
|
+
}
|
|
27
|
+
export interface ElemWithContentsBase extends AbstractElemBase {
|
|
28
|
+
contents: AbstractElem[];
|
|
29
|
+
}
|
|
30
|
+
export interface HasAttributes {
|
|
31
|
+
attributes?: AttributeElem[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* a raw bit of text in WESL source that's typically copied to the linked WGSL.
|
|
35
|
+
* e.g. a keyword like 'var'
|
|
36
|
+
* or a phrase we needn't analyze further like '@diagnostic(off,derivative_uniformity)'
|
|
37
|
+
*/
|
|
38
|
+
export interface TextElem extends AbstractElemBase {
|
|
39
|
+
kind: "text";
|
|
40
|
+
srcModule: SrcModule;
|
|
41
|
+
}
|
|
42
|
+
/** a name that doesn't need to be an Ident
|
|
43
|
+
* e.g.
|
|
44
|
+
* - a struct member name
|
|
45
|
+
* - a diagnostic rule name
|
|
46
|
+
* - an enable-extension name
|
|
47
|
+
* - an interpolation sampling name
|
|
48
|
+
*/
|
|
49
|
+
export interface NameElem extends AbstractElemBase {
|
|
50
|
+
kind: "name";
|
|
51
|
+
name: string;
|
|
52
|
+
}
|
|
53
|
+
/** an identifier that 'refers to' a declaration (aka a symbol reference) */
|
|
54
|
+
export interface RefIdentElem extends AbstractElemBase {
|
|
55
|
+
kind: RefIdent["kind"];
|
|
56
|
+
ident: RefIdent;
|
|
57
|
+
srcModule: SrcModule;
|
|
58
|
+
}
|
|
59
|
+
/** a declaration identifier (aka a symbol declaration) */
|
|
60
|
+
export interface DeclIdentElem extends AbstractElemBase {
|
|
61
|
+
kind: DeclIdent["kind"];
|
|
62
|
+
ident: DeclIdent;
|
|
63
|
+
srcModule: SrcModule;
|
|
64
|
+
}
|
|
65
|
+
/** Holds an import statement, and has a span */
|
|
66
|
+
export interface ImportElem extends AbstractElemBase {
|
|
67
|
+
kind: "import";
|
|
68
|
+
imports: ImportStatement;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* An import statement, which is tree shaped.
|
|
72
|
+
* `import foo::bar::{baz, cat as neko};
|
|
73
|
+
*/
|
|
74
|
+
export interface ImportStatement {
|
|
75
|
+
kind: "import-statement";
|
|
76
|
+
segments: ImportSegment[];
|
|
77
|
+
finalSegment: ImportCollection | ImportItem;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A collection of import trees.
|
|
81
|
+
* `{baz, cat as neko}`
|
|
82
|
+
*/
|
|
83
|
+
export interface ImportSegment {
|
|
84
|
+
kind: "import-segment";
|
|
85
|
+
name: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* A primitive segment in an import statement.
|
|
89
|
+
* `foo`
|
|
90
|
+
*/
|
|
91
|
+
export interface ImportCollection {
|
|
92
|
+
kind: "import-collection";
|
|
93
|
+
subtrees: ImportStatement[];
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* A renamed item at the end of an import statement.
|
|
97
|
+
* `cat as neko`
|
|
98
|
+
*/
|
|
99
|
+
export interface ImportItem {
|
|
100
|
+
kind: "import-item";
|
|
101
|
+
name: string;
|
|
102
|
+
as?: string;
|
|
103
|
+
}
|
|
104
|
+
/** generated element, produced after parsing and binding */
|
|
105
|
+
export interface SyntheticElem {
|
|
106
|
+
kind: "synthetic";
|
|
107
|
+
text: string;
|
|
108
|
+
}
|
|
109
|
+
/** a declaration identifer with a possible type */
|
|
110
|
+
export interface TypedDeclElem extends ElemWithContentsBase {
|
|
111
|
+
kind: "typeDecl";
|
|
112
|
+
decl: DeclIdentElem;
|
|
113
|
+
typeRef?: TypeRefElem;
|
|
114
|
+
}
|
|
115
|
+
/** an alias statement */
|
|
116
|
+
export interface AliasElem extends ElemWithContentsBase, HasAttributes {
|
|
117
|
+
kind: "alias";
|
|
118
|
+
name: DeclIdentElem;
|
|
119
|
+
typeRef: TypeRefElem;
|
|
120
|
+
}
|
|
121
|
+
/** an attribute like '@compute' or '@binding(0)' */
|
|
122
|
+
export interface AttributeElem extends ElemWithContentsBase {
|
|
123
|
+
kind: "attribute";
|
|
124
|
+
attribute: Attribute;
|
|
125
|
+
}
|
|
126
|
+
export type Attribute = StandardAttribute | InterpolateAttribute | BuiltinAttribute | DiagnosticAttribute | IfAttribute;
|
|
127
|
+
export interface StandardAttribute {
|
|
128
|
+
kind: "@attribute";
|
|
129
|
+
name: string;
|
|
130
|
+
params?: UnknownExpressionElem[];
|
|
131
|
+
}
|
|
132
|
+
export interface InterpolateAttribute {
|
|
133
|
+
kind: "@interpolate";
|
|
134
|
+
params: NameElem[];
|
|
135
|
+
}
|
|
136
|
+
export interface BuiltinAttribute {
|
|
137
|
+
kind: "@builtin";
|
|
138
|
+
param: NameElem;
|
|
139
|
+
}
|
|
140
|
+
export interface DiagnosticAttribute {
|
|
141
|
+
kind: "@diagnostic";
|
|
142
|
+
severity: NameElem;
|
|
143
|
+
rule: [NameElem, NameElem | null];
|
|
144
|
+
}
|
|
145
|
+
export interface IfAttribute {
|
|
146
|
+
kind: "@if";
|
|
147
|
+
param: TranslateTimeExpressionElem;
|
|
148
|
+
}
|
|
149
|
+
/** a const_assert statement */
|
|
150
|
+
export interface ConstAssertElem extends ElemWithContentsBase, HasAttributes {
|
|
151
|
+
kind: "assert";
|
|
152
|
+
}
|
|
153
|
+
/** a const declaration */
|
|
154
|
+
export interface ConstElem extends ElemWithContentsBase, HasAttributes {
|
|
155
|
+
kind: "const";
|
|
156
|
+
name: TypedDeclElem;
|
|
157
|
+
}
|
|
158
|
+
/** an expression w/o special handling, used inside attribute parameters */
|
|
159
|
+
export interface UnknownExpressionElem extends ElemWithContentsBase {
|
|
160
|
+
kind: "expression";
|
|
161
|
+
}
|
|
162
|
+
/** an expression that can be safely evaluated at compile time */
|
|
163
|
+
export interface TranslateTimeExpressionElem {
|
|
164
|
+
kind: "translate-time-expression";
|
|
165
|
+
expression: ExpressionElem;
|
|
166
|
+
span: Span;
|
|
167
|
+
}
|
|
168
|
+
/** A literal value in WESL source. A boolean or a number. */
|
|
169
|
+
export interface Literal {
|
|
170
|
+
kind: "literal";
|
|
171
|
+
value: string;
|
|
172
|
+
span: Span;
|
|
173
|
+
}
|
|
174
|
+
/** `words`s inside `@if` */
|
|
175
|
+
export interface TranslateTimeFeature {
|
|
176
|
+
kind: "translate-time-feature";
|
|
177
|
+
name: string;
|
|
178
|
+
span: Span;
|
|
179
|
+
}
|
|
180
|
+
/** (expr) */
|
|
181
|
+
export interface ParenthesizedExpression {
|
|
182
|
+
kind: "parenthesized-expression";
|
|
183
|
+
expression: ExpressionElem;
|
|
184
|
+
}
|
|
185
|
+
/** `foo[expr]` */
|
|
186
|
+
export interface ComponentExpression {
|
|
187
|
+
kind: "component-expression";
|
|
188
|
+
base: ExpressionElem;
|
|
189
|
+
access: ExpressionElem;
|
|
190
|
+
}
|
|
191
|
+
/** `foo.member` */
|
|
192
|
+
export interface ComponentMemberExpression {
|
|
193
|
+
kind: "component-member-expression";
|
|
194
|
+
base: ExpressionElem;
|
|
195
|
+
access: NameElem;
|
|
196
|
+
}
|
|
197
|
+
/** `+foo` */
|
|
198
|
+
export interface UnaryExpression {
|
|
199
|
+
kind: "unary-expression";
|
|
200
|
+
operator: UnaryOperator;
|
|
201
|
+
expression: ExpressionElem;
|
|
202
|
+
}
|
|
203
|
+
/** `foo + bar` */
|
|
204
|
+
export interface BinaryExpression {
|
|
205
|
+
kind: "binary-expression";
|
|
206
|
+
operator: BinaryOperator;
|
|
207
|
+
left: ExpressionElem;
|
|
208
|
+
right: ExpressionElem;
|
|
209
|
+
}
|
|
210
|
+
/** `foo(arg, arg)` */
|
|
211
|
+
export interface FunctionCallExpression {
|
|
212
|
+
kind: "call-expression";
|
|
213
|
+
function: RefIdentElem;
|
|
214
|
+
arguments: ExpressionElem[];
|
|
215
|
+
}
|
|
216
|
+
export interface UnaryOperator {
|
|
217
|
+
value: "!" | "&" | "*" | "-" | "~";
|
|
218
|
+
span: Span;
|
|
219
|
+
}
|
|
220
|
+
export interface BinaryOperator {
|
|
221
|
+
value: ("||" | "&&" | "+" | "-" | "*" | "/" | "%" | "==") | ("!=" | "<" | "<=" | ">" | ">=" | "|" | "&" | "^") | ("<<" | ">>");
|
|
222
|
+
span: Span;
|
|
223
|
+
}
|
|
224
|
+
export type DirectiveVariant = DiagnosticDirective | EnableDirective | RequiresDirective;
|
|
225
|
+
export interface DirectiveElem extends AbstractElemBase, HasAttributes {
|
|
226
|
+
kind: "directive";
|
|
227
|
+
directive: DirectiveVariant;
|
|
228
|
+
}
|
|
229
|
+
export interface DiagnosticDirective {
|
|
230
|
+
kind: "diagnostic";
|
|
231
|
+
severity: NameElem;
|
|
232
|
+
rule: [NameElem, NameElem | null];
|
|
233
|
+
}
|
|
234
|
+
export interface EnableDirective {
|
|
235
|
+
kind: "enable";
|
|
236
|
+
extensions: NameElem[];
|
|
237
|
+
}
|
|
238
|
+
export interface RequiresDirective {
|
|
239
|
+
kind: "requires";
|
|
240
|
+
extensions: NameElem[];
|
|
241
|
+
}
|
|
242
|
+
/** a function declaration */
|
|
243
|
+
export interface FnElem extends ElemWithContentsBase, HasAttributes {
|
|
244
|
+
kind: "fn";
|
|
245
|
+
name: DeclIdentElem;
|
|
246
|
+
params: FnParamElem[];
|
|
247
|
+
body: StatementElem;
|
|
248
|
+
returnAttributes?: AttributeElem[];
|
|
249
|
+
returnType?: TypeRefElem;
|
|
250
|
+
}
|
|
251
|
+
/** a global variable declaration (at the root level) */
|
|
252
|
+
export interface GlobalVarElem extends ElemWithContentsBase, HasAttributes {
|
|
253
|
+
kind: "gvar";
|
|
254
|
+
name: TypedDeclElem;
|
|
255
|
+
}
|
|
256
|
+
/** an entire file */
|
|
257
|
+
export interface ModuleElem extends ElemWithContentsBase {
|
|
258
|
+
kind: "module";
|
|
259
|
+
}
|
|
260
|
+
/** an override declaration */
|
|
261
|
+
export interface OverrideElem extends ElemWithContentsBase, HasAttributes {
|
|
262
|
+
kind: "override";
|
|
263
|
+
name: TypedDeclElem;
|
|
264
|
+
}
|
|
265
|
+
/** a parameter in a function declaration */
|
|
266
|
+
export interface FnParamElem extends ElemWithContentsBase, HasAttributes {
|
|
267
|
+
kind: "param";
|
|
268
|
+
name: TypedDeclElem;
|
|
269
|
+
}
|
|
270
|
+
/** simple references to structures, like myStruct.bar
|
|
271
|
+
* (used for transforming refs to binding structs) */
|
|
272
|
+
export interface SimpleMemberRef extends ElemWithContentsBase {
|
|
273
|
+
kind: "memberRef";
|
|
274
|
+
name: RefIdentElem;
|
|
275
|
+
member: NameElem;
|
|
276
|
+
extraComponents?: StuffElem;
|
|
277
|
+
}
|
|
278
|
+
/** a struct declaration */
|
|
279
|
+
export interface StructElem extends ElemWithContentsBase, HasAttributes {
|
|
280
|
+
kind: "struct";
|
|
281
|
+
name: DeclIdentElem;
|
|
282
|
+
members: StructMemberElem[];
|
|
283
|
+
bindingStruct?: true;
|
|
284
|
+
}
|
|
285
|
+
/** generic container of other elements */
|
|
286
|
+
export interface StuffElem extends ElemWithContentsBase {
|
|
287
|
+
kind: "stuff";
|
|
288
|
+
}
|
|
289
|
+
/** a struct declaration that's been marked as a bindingStruct */
|
|
290
|
+
export interface BindingStructElem extends StructElem {
|
|
291
|
+
bindingStruct: true;
|
|
292
|
+
entryFn?: FnElem;
|
|
293
|
+
}
|
|
294
|
+
/** a member of a struct declaration */
|
|
295
|
+
export interface StructMemberElem extends ElemWithContentsBase, HasAttributes {
|
|
296
|
+
kind: "member";
|
|
297
|
+
name: NameElem;
|
|
298
|
+
typeRef: TypeRefElem;
|
|
299
|
+
mangledVarName?: string;
|
|
300
|
+
}
|
|
301
|
+
export type TypeTemplateParameter = TypeRefElem | UnknownExpressionElem;
|
|
302
|
+
/** a reference to a type, like 'f32', or 'MyStruct', or 'ptr<storage, array<f32>, read_only>' */
|
|
303
|
+
export interface TypeRefElem extends ElemWithContentsBase {
|
|
304
|
+
kind: "type";
|
|
305
|
+
name: RefIdent;
|
|
306
|
+
templateParams?: TypeTemplateParameter[];
|
|
307
|
+
}
|
|
308
|
+
/** a variable declaration */
|
|
309
|
+
export interface VarElem extends ElemWithContentsBase, HasAttributes {
|
|
310
|
+
kind: "var";
|
|
311
|
+
name: TypedDeclElem;
|
|
312
|
+
}
|
|
313
|
+
export interface LetElem extends ElemWithContentsBase, HasAttributes {
|
|
314
|
+
kind: "let";
|
|
315
|
+
name: TypedDeclElem;
|
|
316
|
+
}
|
|
317
|
+
export interface StatementElem extends ElemWithContentsBase, HasAttributes {
|
|
318
|
+
kind: "statement";
|
|
319
|
+
}
|
|
320
|
+
export interface SwitchClauseElem extends ElemWithContentsBase, HasAttributes {
|
|
321
|
+
kind: "switch-clause";
|
|
322
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** checks whether a condition is true, otherwise throws */
|
|
2
|
+
export declare function assertThat(condition: any, msg?: string): asserts condition;
|
|
3
|
+
/** when debug testing is enabled, checks whether a condition is true, otherwise throws */
|
|
4
|
+
export declare function assertThatDebug(condition: any, msg?: string): asserts condition;
|
|
5
|
+
/** when debug testing is enabled throw an error */
|
|
6
|
+
export declare function failDebug(msg?: string): void;
|
|
7
|
+
/**
|
|
8
|
+
* Typescript will complain at compile time if it thinks this could be executed.
|
|
9
|
+
* Useful to validate that all cases are handled.
|
|
10
|
+
*
|
|
11
|
+
* Does nothing at runtime.
|
|
12
|
+
*/
|
|
13
|
+
export declare function assertUnreachableSilent(_value: never): void;
|
|
14
|
+
/**
|
|
15
|
+
* Useful to validate that all cases are handled,
|
|
16
|
+
* TypeScript should complain if this statement could possibly be executed.
|
|
17
|
+
*
|
|
18
|
+
* If this is somehow executed at runtime, throw an exception.
|
|
19
|
+
*/
|
|
20
|
+
export declare function assertUnreachable(value: never): never;
|
|
21
|
+
export interface ErrorWithDataOptions extends ErrorOptions {
|
|
22
|
+
data: any;
|
|
23
|
+
}
|
|
24
|
+
export declare class ErrorWithData extends Error {
|
|
25
|
+
data: any;
|
|
26
|
+
constructor(message?: string, options?: ErrorWithDataOptions);
|
|
27
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { AbstractElem } from './AbstractElems.ts';
|
|
2
|
+
import { LinkRegistryParams, VirtualLibraryFn } from './Linker.ts';
|
|
3
|
+
import { WeslAST } from './ParseWESL.ts';
|
|
4
|
+
import { Conditions, DeclIdent, Scope, SrcModule } from './Scope.ts';
|
|
5
|
+
/**
|
|
6
|
+
BindIdents pass
|
|
7
|
+
|
|
8
|
+
Goals:
|
|
9
|
+
- link references identifiers to their declaration identifiers.
|
|
10
|
+
- produce a list of declarations that are used (and need to be emitted in the link)
|
|
11
|
+
- create mangled names for global declarations (to avoid name conflicts)
|
|
12
|
+
|
|
13
|
+
BindIdents proceeds as a recursive tree walk of the scope tree, starting from the root module (e.g. main.wesl).
|
|
14
|
+
It traverses the scope tree depth first (and not the syntax tree).
|
|
15
|
+
- For each ref ident, search prior declarations in the current scope, then
|
|
16
|
+
up the scope tree to find a matching declaration
|
|
17
|
+
- If no local match is found, check for partial matches with import statements
|
|
18
|
+
- combine the ident with import statement to match a decl in an exporting module
|
|
19
|
+
- As global declaration identifies are found, also:
|
|
20
|
+
- mutate their mangled name to be globally unique.
|
|
21
|
+
- collect the declarations (they will be emitted)
|
|
22
|
+
|
|
23
|
+
When iterating through the idents inside a scope, we maintain a parallel data structure of
|
|
24
|
+
'liveDecls', the declarations that are visible in the current scope at the currently
|
|
25
|
+
processed ident, along with a link to parent liveDecls for their current decl visibility.
|
|
26
|
+
*/
|
|
27
|
+
/** results returned from binding pass */
|
|
28
|
+
export interface BindResults {
|
|
29
|
+
/** root level names (including names mangled due to conflict with earlier names) */
|
|
30
|
+
globalNames: Set<string>;
|
|
31
|
+
/** global declarations that were referenced (these will need to be emitted in the link) */
|
|
32
|
+
decls: DeclIdent[];
|
|
33
|
+
/** additional global statements to include in linked results
|
|
34
|
+
* (e.g. for adding module level const_assert statements) */
|
|
35
|
+
newStatements: EmittableElem[];
|
|
36
|
+
}
|
|
37
|
+
/** an element that can be directly emitted into the linked result */
|
|
38
|
+
export interface EmittableElem {
|
|
39
|
+
srcModule: SrcModule;
|
|
40
|
+
elem: AbstractElem;
|
|
41
|
+
}
|
|
42
|
+
/** virtual package, generated by code generation function. */
|
|
43
|
+
export interface VirtualLibrary {
|
|
44
|
+
/** function to generate the module */
|
|
45
|
+
fn: VirtualLibraryFn;
|
|
46
|
+
/** parsed AST for the module (constructed lazily) */
|
|
47
|
+
ast?: WeslAST;
|
|
48
|
+
}
|
|
49
|
+
/** key is virtual module name */
|
|
50
|
+
export type VirtualLibrarySet = Record<string, VirtualLibrary>;
|
|
51
|
+
export interface BindIdentsParams extends Pick<LinkRegistryParams, "registry" | "conditions" | "mangler"> {
|
|
52
|
+
rootAst: WeslAST;
|
|
53
|
+
virtuals?: VirtualLibrarySet;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Bind active reference idents to declaration Idents by mutating the refersTo: field
|
|
57
|
+
* Also in this pass, set the mangledName: field for all active global declaration idents.
|
|
58
|
+
*
|
|
59
|
+
* @param parsed
|
|
60
|
+
* @param conditions only bind to/from idents that are valid with the current condition set
|
|
61
|
+
* @return any new declaration elements found (they will need to be emitted)
|
|
62
|
+
*/
|
|
63
|
+
export declare function bindIdents(params: BindIdentsParams): BindResults;
|
|
64
|
+
/**
|
|
65
|
+
* @return the list of conditional valid declarations at the root level
|
|
66
|
+
* decls are either in the root scope or in a conditionally valid partial scope
|
|
67
|
+
*/
|
|
68
|
+
export declare function findValidRootDecls(rootScope: Scope, conditions: Conditions): DeclIdent[];
|
|
69
|
+
/** @return true if this decl is at the root scope level of a module */
|
|
70
|
+
export declare function isGlobal(declIdent: DeclIdent): boolean;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ElemWithAttributes } from './AbstractElems.ts';
|
|
2
|
+
import { Conditions, Scope } from './Scope.ts';
|
|
3
|
+
/** @return true if the element is valid under current Conditions */
|
|
4
|
+
export declare function elementValid(elem: ElemWithAttributes, conditions: Conditions): boolean;
|
|
5
|
+
/** @return true if the scope is valid under current conditions */
|
|
6
|
+
export declare function scopeValid(scope: Scope, conditions: Conditions): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ImportStatement } from './AbstractElems';
|
|
2
|
+
export interface FlatImport {
|
|
3
|
+
importPath: string[];
|
|
4
|
+
modulePath: string[];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Simplify importTree into a flattened map from import paths to module paths.
|
|
8
|
+
*
|
|
9
|
+
* @return map from import path (with 'as' renaming) to module Path
|
|
10
|
+
*/
|
|
11
|
+
export declare function flattenTreeImport(imp: ImportStatement): FlatImport[];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { SrcMap } from '../../mini-parse/src';
|
|
2
|
+
import { WeslDevice } from './WeslDevice';
|
|
3
|
+
/** Results of shader compilation. Has {@link WeslGPUCompilationMessage}
|
|
4
|
+
* which are aware of the WESL module that an error was thrown from. */
|
|
5
|
+
export interface WeslGPUCompilationInfo extends GPUCompilationInfo {
|
|
6
|
+
messages: WeslGPUCompilationMessage[];
|
|
7
|
+
}
|
|
8
|
+
export interface WeslGPUCompilationMessage extends GPUCompilationMessage {
|
|
9
|
+
module: {
|
|
10
|
+
url: string;
|
|
11
|
+
text?: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A {@link GPUValidationError} with an inner error (for a stack trace).
|
|
16
|
+
* Can also point at a WESL source file.
|
|
17
|
+
*/
|
|
18
|
+
export interface ExtendedGPUValidationError extends GPUValidationError {
|
|
19
|
+
cause?: Error;
|
|
20
|
+
compilationInfo?: WeslGPUCompilationInfo;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Multiple WESL files that have been linked together to produce WGSL code.
|
|
24
|
+
*
|
|
25
|
+
* Call {@link LinkedWesl.createShaderModule} on a {@link WeslDevice}
|
|
26
|
+
* to make the error reporting aware of the WESL code.
|
|
27
|
+
*/
|
|
28
|
+
export declare class LinkedWesl {
|
|
29
|
+
sourceMap: SrcMap;
|
|
30
|
+
constructor(sourceMap: SrcMap);
|
|
31
|
+
/**
|
|
32
|
+
* Creates a {@link GPUShaderModule}.
|
|
33
|
+
* When errors occur, they will point at the original WESL source code.
|
|
34
|
+
*
|
|
35
|
+
* The compilation info {@link GPUShaderModule.getCompilationInfo}
|
|
36
|
+
* can be remapped with {@link mapGPUCompilationInfo}
|
|
37
|
+
* @param device GPUDevice. Preferably a {@link WeslDevice} for better error reporting.
|
|
38
|
+
* @param descriptor - Description of the {@link GPUShaderModule} to create.
|
|
39
|
+
*/
|
|
40
|
+
createShaderModule(device: GPUDevice | WeslDevice, descriptor: Omit<GPUShaderModuleDescriptor, "code">): GPUShaderModule;
|
|
41
|
+
/**
|
|
42
|
+
* Use {@link LinkedWesl.createShaderModule} for a
|
|
43
|
+
* better error reporting experience.
|
|
44
|
+
*/
|
|
45
|
+
get dest(): string;
|
|
46
|
+
/** Turns raw compilation info into compilation info
|
|
47
|
+
* that points at the WESL sources. */
|
|
48
|
+
mapGPUCompilationInfo(compilationInfo: GPUCompilationInfo): WeslGPUCompilationInfo;
|
|
49
|
+
private mapGPUCompilationMessage;
|
|
50
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { SrcMap } from '../../mini-parse/src';
|
|
2
|
+
import { AbstractElem } from './AbstractElems.ts';
|
|
3
|
+
import { EmittableElem } from './BindIdents.ts';
|
|
4
|
+
import { LinkedWesl } from './LinkedWesl.ts';
|
|
5
|
+
import { ManglerFn } from './Mangler.ts';
|
|
6
|
+
import { ParsedRegistry } from './ParsedRegistry.ts';
|
|
7
|
+
import { WeslAST } from './ParseWESL.ts';
|
|
8
|
+
import { Conditions, DeclIdent } from './Scope.ts';
|
|
9
|
+
import { WeslBundle } from './WeslBundle.ts';
|
|
10
|
+
type LinkerTransform = (boundAST: TransformedAST) => TransformedAST;
|
|
11
|
+
export interface WeslJsPlugin {
|
|
12
|
+
transform?: LinkerTransform;
|
|
13
|
+
}
|
|
14
|
+
export interface TransformedAST extends Pick<WeslAST, "srcModule" | "moduleElem"> {
|
|
15
|
+
globalNames: Set<string>;
|
|
16
|
+
notableElems: Record<string, AbstractElem[]>;
|
|
17
|
+
}
|
|
18
|
+
export interface LinkConfig {
|
|
19
|
+
plugins?: WeslJsPlugin[];
|
|
20
|
+
}
|
|
21
|
+
export interface LinkParams {
|
|
22
|
+
/** record of file paths and wesl text for modules.
|
|
23
|
+
* key is module path or file path
|
|
24
|
+
* `package::foo::bar`, or './foo/bar.wesl', or './foo/bar'
|
|
25
|
+
* value is wesl src
|
|
26
|
+
*
|
|
27
|
+
*
|
|
28
|
+
* Only accepts unix-style, relative filesystem paths that are valid WGSL identifiers
|
|
29
|
+
* - Unix-style: Slashes as separators.
|
|
30
|
+
* - Valid WGSL identifiers: No backslashes, no `..`, or other non-identifier symbols.
|
|
31
|
+
* - Relative paths: They have to be relative to the wesl root.
|
|
32
|
+
*/
|
|
33
|
+
weslSrc: Record<string, string>;
|
|
34
|
+
/** name of root wesl module
|
|
35
|
+
* for an app, the root module normally contains the '@compute', '@vertex' or '@fragment' entry points
|
|
36
|
+
* for a library, the root module defines the public api fo the library
|
|
37
|
+
* can be specified as file path (./main.wesl), a module path (package::main), or just a module name (main)
|
|
38
|
+
*/
|
|
39
|
+
rootModuleName?: string;
|
|
40
|
+
/** For debug logging. Will be prepended to file paths. */
|
|
41
|
+
debugWeslRoot?: string;
|
|
42
|
+
/** runtime conditions for conditional compiling with @if and friends */
|
|
43
|
+
conditions?: Conditions;
|
|
44
|
+
/** libraries available for the link */
|
|
45
|
+
libs?: WeslBundle[];
|
|
46
|
+
/** generate wesl from code at runtime */
|
|
47
|
+
virtualLibs?: Record<string, VirtualLibraryFn>;
|
|
48
|
+
/** plugins and other configuration to use while linking */
|
|
49
|
+
config?: LinkConfig;
|
|
50
|
+
/** Host (ts/js) provided wgsl constants.
|
|
51
|
+
* Users can import the values from wesl code via the `constants' virtual library:
|
|
52
|
+
* `import constants::num_lights;` */
|
|
53
|
+
constants?: Record<string, string | number>;
|
|
54
|
+
/** function to construct globally unique wgsl identifiers */
|
|
55
|
+
mangler?: ManglerFn;
|
|
56
|
+
}
|
|
57
|
+
/** Generate a virtual WESL module based on a set of conditions. */
|
|
58
|
+
export type VirtualLibraryFn = (conditions: Conditions) => string;
|
|
59
|
+
/**
|
|
60
|
+
* Link a set of WESL source modules (typically the text from .wesl files) into a single WGSL string.
|
|
61
|
+
* Linking starts with a specified 'root' source module, and recursively incorporates code
|
|
62
|
+
* referenced from other modules (in local files or libraries).
|
|
63
|
+
*
|
|
64
|
+
* Unreferenced (dead) code outside the root module is not included in the output WGSL.
|
|
65
|
+
* Additionally the caller can specify conditions for to control conditional compilation.
|
|
66
|
+
* Only code that is valid with the current conditions is included in the output.
|
|
67
|
+
*/
|
|
68
|
+
export declare function link(params: LinkParams): Promise<LinkedWesl>;
|
|
69
|
+
export interface LinkRegistryParams extends Pick<LinkParams, "rootModuleName" | "conditions" | "virtualLibs" | "config" | "constants" | "mangler"> {
|
|
70
|
+
registry: ParsedRegistry;
|
|
71
|
+
}
|
|
72
|
+
/** Link wesl from a registry of already parsed modules.
|
|
73
|
+
*
|
|
74
|
+
* This entry point is intended for users who want to link multiple times
|
|
75
|
+
* from the same sources. (e.g. linking with different conditions
|
|
76
|
+
* each time, or perhaps to produce multiple wgsl shaders
|
|
77
|
+
* that share some sources.)
|
|
78
|
+
*/
|
|
79
|
+
export declare function linkRegistry(params: LinkRegistryParams): SrcMap;
|
|
80
|
+
export interface BoundAndTransformed {
|
|
81
|
+
transformedAst: TransformedAST;
|
|
82
|
+
newDecls: DeclIdent[];
|
|
83
|
+
newStatements: EmittableElem[];
|
|
84
|
+
}
|
|
85
|
+
/** bind identifers and apply any transform plugins */
|
|
86
|
+
export declare function bindAndTransform(params: LinkRegistryParams): BoundAndTransformed;
|
|
87
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { AbstractElem, DeclIdentElem, RefIdentElem } from './AbstractElems.ts';
|
|
2
|
+
export declare function visitAst(elem: AbstractElem, visitor: (elem: AbstractElem) => void): void;
|
|
3
|
+
export declare function identElemLog(identElem: DeclIdentElem | RefIdentElem, ...messages: any[]): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DeclIdent } from './Scope.ts';
|
|
2
|
+
/** decls currently visible in this scope */
|
|
3
|
+
export interface LiveDecls {
|
|
4
|
+
/** decls currently visible in this scope */
|
|
5
|
+
decls: Map<string, DeclIdent>;
|
|
6
|
+
/** live decls in the parent scope. null for the modue root scope */
|
|
7
|
+
parent?: LiveDecls | null;
|
|
8
|
+
}
|
|
9
|
+
/** create a LiveDecls */
|
|
10
|
+
export declare function makeLiveDecls(parent?: LiveDecls | null): LiveDecls;
|
|
11
|
+
/** debug routine for logging LiveDecls */
|
|
12
|
+
export declare function liveDeclsToString(liveDecls: LiveDecls): string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SrcMapBuilder } from '../../mini-parse/src';
|
|
2
|
+
import { AbstractElem, ContainerElem, DeclIdentElem, ExpressionElem, FnElem, NameElem, RefIdentElem, StructElem, SyntheticElem, TextElem } from './AbstractElems.ts';
|
|
3
|
+
import { Conditions, DeclIdent, Ident } from './Scope.ts';
|
|
4
|
+
/** passed to the emitters */
|
|
5
|
+
interface EmitContext {
|
|
6
|
+
srcBuilder: SrcMapBuilder;
|
|
7
|
+
conditions: Conditions;
|
|
8
|
+
extracting: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** traverse the AST, starting from root elements, emitting wgsl for each */
|
|
11
|
+
export declare function lowerAndEmit(srcBuilder: SrcMapBuilder, rootElems: AbstractElem[], conditions: Conditions, extracting?: boolean): void;
|
|
12
|
+
export declare function lowerAndEmitElem(e: AbstractElem, ctx: EmitContext): void;
|
|
13
|
+
export declare function emitText(e: TextElem, ctx: EmitContext): void;
|
|
14
|
+
export declare function emitName(e: NameElem, ctx: EmitContext): void;
|
|
15
|
+
/** emit function explicitly so we can control commas between conditional parameters */
|
|
16
|
+
export declare function emitFn(e: FnElem, ctx: EmitContext): void;
|
|
17
|
+
/** emit structs explicitly so we can control commas between conditional members */
|
|
18
|
+
export declare function emitStruct(e: StructElem, ctx: EmitContext): void;
|
|
19
|
+
export declare function emitSynthetic(e: SyntheticElem, ctx: EmitContext): void;
|
|
20
|
+
export declare function emitContents(elem: ContainerElem, ctx: EmitContext): void;
|
|
21
|
+
export declare function emitRefIdent(e: RefIdentElem, ctx: EmitContext): void;
|
|
22
|
+
export declare function emitDeclIdent(e: DeclIdentElem, ctx: EmitContext): void;
|
|
23
|
+
export declare function diagnosticControlToString(severity: NameElem, rule: [NameElem, NameElem | null]): string;
|
|
24
|
+
export declare function expressionToString(elem: ExpressionElem): string;
|
|
25
|
+
/** trace through refersTo links in reference Idents until we find the declaration
|
|
26
|
+
* expects that bindIdents has filled in all refersTo: links
|
|
27
|
+
*/
|
|
28
|
+
export declare function findDecl(ident: Ident): DeclIdent;
|
|
29
|
+
/** check if the element is visible with the current current conditional compilation settings */
|
|
30
|
+
export declare function conditionsValid(elem: AbstractElem, conditions: Conditions): true | false | undefined;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { DeclIdent, SrcModule } from './Scope.ts';
|
|
2
|
+
/**
|
|
3
|
+
* A function for constructing a unique identifier name for a global declaration.
|
|
4
|
+
* Global names must be unique in the linked wgsl.
|
|
5
|
+
*
|
|
6
|
+
* Three manglers are currently available:
|
|
7
|
+
* . minimalMangle preserves original source names where possible
|
|
8
|
+
* . underscoreMangle constructs long but predictable names for every declaration
|
|
9
|
+
* . lengthPrefixMangle constructs long but predictable names for every declaration
|
|
10
|
+
*/
|
|
11
|
+
export type ManglerFn = (
|
|
12
|
+
/** global declaration that needs a name */
|
|
13
|
+
decl: DeclIdent,
|
|
14
|
+
/** module that contains the declaration */
|
|
15
|
+
srcModule: SrcModule,
|
|
16
|
+
/** name at use site (possibly import as renamed from declaration) */
|
|
17
|
+
proposedName: string,
|
|
18
|
+
/** current set of mangled root level names for the linked result (read only) */
|
|
19
|
+
globalNames: Set<string>) => string;
|
|
20
|
+
/**
|
|
21
|
+
* Construct a globally unique name based on the declaration
|
|
22
|
+
* module path separated by underscores.
|
|
23
|
+
* Corresponds to "Underscore-count mangling" from [NameMangling.md](https://github.com/wgsl-tooling-wg/wesl-spec/blob/main/NameMangling.md)
|
|
24
|
+
*/
|
|
25
|
+
export declare function underscoreMangle(decl: DeclIdent, srcModule: SrcModule): string;
|
|
26
|
+
/**
|
|
27
|
+
* Construct a globally unique name based on the declaration
|
|
28
|
+
*/
|
|
29
|
+
export declare function lengthPrefixMangle(decl: DeclIdent, srcModule: SrcModule): string;
|
|
30
|
+
/**
|
|
31
|
+
* ManglerFn to construct a globally unique name
|
|
32
|
+
* using the requested name plus a uniquing number suffix if necessary
|
|
33
|
+
*/
|
|
34
|
+
export declare function minimalMangle(_d: DeclIdent, _s: SrcModule, proposedName: string, globalNames: Set<string>): string;
|
|
35
|
+
/**
|
|
36
|
+
* Construct a globally unique name by using the requested name if possible
|
|
37
|
+
* and appending a number suffix necessary
|
|
38
|
+
*/
|
|
39
|
+
export declare function minimallyMangledName(proposedName: string, globalNames: Set<string>): string;
|