wesl 0.7.26 → 0.7.28

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.
Files changed (67) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.ts +283 -147
  3. package/dist/index.js +1765 -1143
  4. package/package.json +2 -2
  5. package/src/AbstractElems.ts +264 -82
  6. package/src/ClickableError.ts +8 -1
  7. package/src/Linker.ts +63 -67
  8. package/src/LinkerUtil.ts +141 -7
  9. package/src/LowerAndEmit.ts +660 -304
  10. package/src/Mangler.ts +1 -1
  11. package/src/ModuleResolver.ts +15 -4
  12. package/src/ParseWESL.ts +21 -33
  13. package/src/SrcMap.ts +7 -19
  14. package/src/StandardTypes.ts +1 -1
  15. package/src/WeslDevice.ts +1 -0
  16. package/src/debug/ASTtoString.ts +92 -76
  17. package/src/index.ts +1 -1
  18. package/src/parse/AttachComments.ts +289 -0
  19. package/src/parse/ExpressionUtil.ts +3 -3
  20. package/src/parse/Keywords.ts +1 -1
  21. package/src/parse/ParseAttribute.ts +49 -71
  22. package/src/parse/ParseCall.ts +3 -4
  23. package/src/parse/ParseControlFlow.ts +100 -56
  24. package/src/parse/ParseDirective.ts +9 -8
  25. package/src/parse/ParseDoBlock.ts +63 -0
  26. package/src/parse/ParseExpression.ts +11 -10
  27. package/src/parse/ParseFn.ts +11 -33
  28. package/src/parse/ParseGlobalVar.ts +36 -27
  29. package/src/parse/ParseIdent.ts +4 -5
  30. package/src/parse/ParseLocalVar.ts +16 -12
  31. package/src/parse/ParseLoop.ts +76 -39
  32. package/src/parse/ParseModule.ts +65 -19
  33. package/src/parse/ParseSimpleStatement.ts +112 -66
  34. package/src/parse/ParseStatement.ts +40 -67
  35. package/src/parse/ParseStruct.ts +8 -22
  36. package/src/parse/ParseType.ts +10 -13
  37. package/src/parse/ParseUtil.ts +26 -12
  38. package/src/parse/ParseValueDeclaration.ts +18 -31
  39. package/src/parse/ParseWesl.ts +11 -14
  40. package/src/parse/ParsingContext.ts +11 -9
  41. package/src/parse/WeslStream.ts +138 -121
  42. package/src/parse/stream/RegexMatchers.ts +45 -0
  43. package/src/parse/stream/WeslLexer.ts +249 -0
  44. package/src/test/BevyLink.test.ts +18 -11
  45. package/src/test/ConditionalElif.test.ts +4 -2
  46. package/src/test/DeclCommentEmit.test.ts +122 -0
  47. package/src/test/DoBlock.test.ts +164 -0
  48. package/src/test/FilterValidElements.test.ts +4 -6
  49. package/src/test/Linker.test.ts +23 -7
  50. package/src/test/Mangling.test.ts +8 -4
  51. package/src/test/ParseComments.test.ts +234 -6
  52. package/src/test/ParseConditionsV2.test.ts +47 -175
  53. package/src/test/ParseElifV2.test.ts +12 -33
  54. package/src/test/ParseErrorV2.test.ts +0 -0
  55. package/src/test/ParseWeslV2.test.ts +247 -626
  56. package/src/test/StatementEmit.test.ts +143 -0
  57. package/src/test/StripWesl.ts +24 -3
  58. package/src/test/TestLink.ts +19 -3
  59. package/src/test/TestUtil.ts +18 -8
  60. package/src/test/Tokenizer.test.ts +96 -0
  61. package/src/test/__snapshots__/ParseWeslV2.test.ts.snap +10 -42
  62. package/src/RawEmit.ts +0 -103
  63. package/src/Reflection.ts +0 -336
  64. package/src/TransformBindingStructs.ts +0 -320
  65. package/src/parse/ContentsHelpers.ts +0 -70
  66. package/src/parse/stream/CachingStream.ts +0 -48
  67. package/src/parse/stream/MatchersStream.ts +0 -85
@@ -10,26 +10,19 @@ test("parse @elif basic", () => {
10
10
  "module
11
11
  const %a @if
12
12
  attribute @if(false)
13
- text ' const '
14
13
  typeDecl %a
15
14
  decl %a
16
- text ' = 1;'
17
- text '
18
- '
15
+ literal literal(1)
19
16
  const %a @elif
20
17
  attribute @elif(true)
21
- text ' const '
22
18
  typeDecl %a
23
19
  decl %a
24
- text ' = 2;'
25
- text '
26
- '
20
+ literal literal(2)
27
21
  const %a @else
28
22
  attribute @else
29
- text ' const '
30
23
  typeDecl %a
31
24
  decl %a
32
- text ' = 3;'"
25
+ literal literal(3)"
33
26
  `);
34
27
  });
35
28
 
@@ -40,15 +33,11 @@ test("parse @elif with complex condition", () => {
40
33
  fn f() @if
41
34
  attribute @if(foo)
42
35
  decl %f
43
- statement
44
- text '{}'
45
- text '
46
- '
36
+ block
47
37
  fn f() @elif
48
38
  attribute @elif(bar && !baz)
49
39
  decl %f
50
- statement
51
- text '{}'"
40
+ block"
52
41
  `);
53
42
  });
54
43
 
@@ -60,34 +49,24 @@ test("parse multiple @elif", () => {
60
49
  "module
61
50
  const %x @if
62
51
  attribute @if(a)
63
- text ' const '
64
52
  typeDecl %x
65
53
  decl %x
66
- text ' = 1;'
67
- text '
68
- '
54
+ literal literal(1)
69
55
  const %x @elif
70
56
  attribute @elif(b)
71
- text ' const '
72
57
  typeDecl %x
73
58
  decl %x
74
- text ' = 2;'
75
- text '
76
- '
59
+ literal literal(2)
77
60
  const %x @elif
78
61
  attribute @elif(c)
79
- text ' const '
80
62
  typeDecl %x
81
63
  decl %x
82
- text ' = 3;'
83
- text '
84
- '
64
+ literal literal(3)
85
65
  const %x @else
86
66
  attribute @else
87
- text ' const '
88
67
  typeDecl %x
89
68
  decl %x
90
- text ' = 4;'"
69
+ literal literal(4)"
91
70
  `);
92
71
  });
93
72
 
@@ -98,8 +77,8 @@ test("parse @elif on import", () => {
98
77
  expect(astToString(ast.moduleElem)).toMatchInlineSnapshot(`
99
78
  "module
100
79
  import a::val; @if
101
- text '
102
- '
103
- import b::val; @elif"
80
+ attribute @if(false)
81
+ import b::val; @elif
82
+ attribute @elif(true)"
104
83
  `);
105
84
  });
Binary file