mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-14 19:31:25 +00:00
docs/ -> docs/tint/ fuzzers/ -> src/tint/fuzzers/ samples/ -> src/tint/cmd/ src/ -> src/tint/ test/ -> test/tint/ BUG=tint:1418,tint:1433 Change-Id: Id2aa79f989aef3245b80ef4aa37a27ff16cd700b Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/80482 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
120 lines
1.7 KiB
Markdown
120 lines
1.7 KiB
Markdown
# Compound Statements
|
|
|
|
Compound statements are statements that can hold other statements.
|
|
|
|
This document maps the WGSL compound statements to their semantic tree representations.
|
|
|
|
## if statement
|
|
|
|
WGSL:
|
|
```
|
|
if (condition_a) {
|
|
statement_a;
|
|
} else if (condition_b) {
|
|
statement_b;
|
|
} else {
|
|
statement_c;
|
|
}
|
|
```
|
|
|
|
Semantic tree:
|
|
```
|
|
sem::IfStatement {
|
|
condition_a
|
|
sem::BlockStatement {
|
|
statement_a
|
|
}
|
|
sem::ElseStatement {
|
|
condition_b
|
|
sem::BlockStatement {
|
|
statement_b
|
|
}
|
|
}
|
|
sem::ElseStatement {
|
|
sem::BlockStatement {
|
|
statement_c
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
## for loop
|
|
|
|
WGSL:
|
|
```
|
|
for (initializer; condition; continuing) {
|
|
statement;
|
|
}
|
|
```
|
|
|
|
Semantic tree:
|
|
```
|
|
sem::ForLoopStatement {
|
|
sem::Statement initializer
|
|
sem::Expression condition
|
|
sem::Statement continuing
|
|
|
|
sem::LoopBlockStatement {
|
|
sem::Statement statement
|
|
}
|
|
}
|
|
```
|
|
|
|
## loop
|
|
|
|
WGSL:
|
|
```
|
|
loop (condition) {
|
|
statement_a;
|
|
continuing {
|
|
statement_b;
|
|
}
|
|
}
|
|
```
|
|
|
|
Semantic tree:
|
|
```
|
|
sem::LoopStatement {
|
|
sem::Expression condition
|
|
|
|
sem::LoopBlockStatement {
|
|
sem::Statement statement_a
|
|
sem::LoopContinuingBlockStatement {
|
|
sem::Statement statement_b
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
|
|
## switch statement
|
|
|
|
WGSL:
|
|
```
|
|
switch (condition) {
|
|
case literal_a, literal_b: {
|
|
statement_a;
|
|
}
|
|
default {
|
|
statement_b;
|
|
}
|
|
}
|
|
```
|
|
|
|
Semantic tree:
|
|
```
|
|
sem::SwitchStatement {
|
|
sem::Expression condition
|
|
sem::CaseStatement {
|
|
sem::BlockStatement {
|
|
sem::Statement statement_a
|
|
}
|
|
}
|
|
sem::CaseStatement {
|
|
sem::BlockStatement {
|
|
sem::Statement statement_b
|
|
}
|
|
}
|
|
}
|
|
```
|