wesl 0.7.27 → 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 (61) hide show
  1. package/dist/index.d.ts +272 -126
  2. package/dist/index.js +1742 -1102
  3. package/package.json +1 -1
  4. package/src/AbstractElems.ts +263 -81
  5. package/src/Linker.ts +14 -2
  6. package/src/LinkerUtil.ts +141 -7
  7. package/src/LowerAndEmit.ts +660 -304
  8. package/src/ModuleResolver.ts +15 -4
  9. package/src/ParseWESL.ts +21 -33
  10. package/src/SrcMap.ts +7 -19
  11. package/src/debug/ASTtoString.ts +92 -76
  12. package/src/index.ts +1 -1
  13. package/src/parse/AttachComments.ts +289 -0
  14. package/src/parse/ExpressionUtil.ts +3 -3
  15. package/src/parse/ParseAttribute.ts +49 -71
  16. package/src/parse/ParseCall.ts +3 -4
  17. package/src/parse/ParseControlFlow.ts +100 -56
  18. package/src/parse/ParseDirective.ts +9 -8
  19. package/src/parse/ParseDoBlock.ts +63 -0
  20. package/src/parse/ParseExpression.ts +11 -10
  21. package/src/parse/ParseFn.ts +11 -33
  22. package/src/parse/ParseGlobalVar.ts +36 -27
  23. package/src/parse/ParseIdent.ts +4 -5
  24. package/src/parse/ParseLocalVar.ts +16 -12
  25. package/src/parse/ParseLoop.ts +76 -39
  26. package/src/parse/ParseModule.ts +65 -19
  27. package/src/parse/ParseSimpleStatement.ts +112 -66
  28. package/src/parse/ParseStatement.ts +39 -66
  29. package/src/parse/ParseStruct.ts +8 -22
  30. package/src/parse/ParseType.ts +10 -13
  31. package/src/parse/ParseUtil.ts +26 -12
  32. package/src/parse/ParseValueDeclaration.ts +18 -31
  33. package/src/parse/ParseWesl.ts +11 -14
  34. package/src/parse/ParsingContext.ts +11 -9
  35. package/src/parse/WeslStream.ts +138 -121
  36. package/src/parse/stream/RegexMatchers.ts +45 -0
  37. package/src/parse/stream/WeslLexer.ts +249 -0
  38. package/src/test/BevyLink.test.ts +17 -10
  39. package/src/test/ConditionalElif.test.ts +4 -2
  40. package/src/test/DeclCommentEmit.test.ts +122 -0
  41. package/src/test/DoBlock.test.ts +164 -0
  42. package/src/test/FilterValidElements.test.ts +4 -6
  43. package/src/test/Linker.test.ts +23 -7
  44. package/src/test/Mangling.test.ts +8 -4
  45. package/src/test/ParseComments.test.ts +234 -6
  46. package/src/test/ParseConditionsV2.test.ts +47 -175
  47. package/src/test/ParseElifV2.test.ts +12 -33
  48. package/src/test/ParseErrorV2.test.ts +0 -0
  49. package/src/test/ParseWeslV2.test.ts +247 -626
  50. package/src/test/StatementEmit.test.ts +143 -0
  51. package/src/test/StripWesl.ts +24 -3
  52. package/src/test/TestLink.ts +19 -3
  53. package/src/test/TestUtil.ts +18 -8
  54. package/src/test/Tokenizer.test.ts +96 -0
  55. package/src/test/__snapshots__/ParseWeslV2.test.ts.snap +10 -42
  56. package/src/RawEmit.ts +0 -103
  57. package/src/Reflection.ts +0 -336
  58. package/src/TransformBindingStructs.ts +0 -320
  59. package/src/parse/ContentsHelpers.ts +0 -70
  60. package/src/parse/stream/CachingStream.ts +0 -48
  61. 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