aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2015-11-02 13:40:39 -0800
committerAlon Zakai <alonzakai@gmail.com>2015-11-02 18:09:33 -0800
commit60b3febf42272d5c2a3a39129d7628a8df95bcdc (patch)
treed8c59d46f4b54e904d2218a8161574be13918dd1
parent80cf814b4bbc1b8583ba3d1f6516791a4a5a844b (diff)
downloadnanowasm-design-60b3febf42272d5c2a3a39129d7628a8df95bcdc.tar.gz
control flow clarifications
-rw-r--r--AstSemantics.md8
1 files changed, 5 insertions, 3 deletions
diff --git a/AstSemantics.md b/AstSemantics.md
index 1d91acc..237fc38 100644
--- a/AstSemantics.md
+++ b/AstSemantics.md
@@ -242,7 +242,9 @@ All control flow structures, except `case`, are statements.
* `block`: a fixed-length sequence of statements with a label at the end
* `loop`: a fixed-length sequence of statements with a label at the end
- and a loop header label at the top
+ and a loop header label at the top (note: this does not loop by
+ itself, so one would often combine this with a br_if at the end
+ to form a branch back to the top)
* `if`: if statement with then body
* `if_else`: if statement with then and else bodies
* `br`: branch to a given label in an enclosing construct (see below)
@@ -262,8 +264,8 @@ one can arrange `block`s to put labels wherever one wants to jump to, except
for one restriction: one can't jump into the middle of a loop from outside
it. This restriction ensures the well-structured property discussed below.
-`tableswitch` instructions have a zero-based array of labels, a label index,
-a "default" label, an index operand, and a list of `case` nodes. A `tableswitch`
+`tableswitch` instructions have a zero-based array of labels, a "default"
+label, an index operand, and a list of `case` nodes. A `tableswitch`
selects which label to branch to by looking up the index value in the label
array, and transferring control to that label. If the index is out of bounds,
it transfers control to the "default" label.