diff options
author | Thomas Lively <tlively@google.com> | 2024-02-26 17:55:18 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-26 17:55:18 -0800 |
commit | f8b07f75996b34142450435c75a811aa946a6d3b (patch) | |
tree | a6f2c9b0c602acf5e1b07acde2c3c491d0f91076 /test | |
parent | 55c206216ea93bd84de8f68b81fd903724006b50 (diff) | |
download | binaryen-f8b07f75996b34142450435c75a811aa946a6d3b.tar.gz binaryen-f8b07f75996b34142450435c75a811aa946a6d3b.tar.bz2 binaryen-f8b07f75996b34142450435c75a811aa946a6d3b.zip |
[Parser] Parse annotations, including source map comments (#6345)
Parse annotations using the standards-track `(@annotation ...)` format as well
as the `;;@ source-map:0:1` format. Have the lexer implicitly collect
annotations while it skips whitespace and add lexer APIs to access the
annotations since the last token was parsed. Collect annotations before parsing
each instruction and pass the annotations explicitly to the parser and parser
context functions for instructions. Add an API to `IRBuilder` to set a debug
location to be attached to the next visited or created instruction and use it
from the parser.
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/wat-kitchen-sink.wast | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/test/lit/wat-kitchen-sink.wast b/test/lit/wat-kitchen-sink.wast index c0c35acf7..ab81fa4c7 100644 --- a/test/lit/wat-kitchen-sink.wast +++ b/test/lit/wat-kitchen-sink.wast @@ -463,6 +463,11 @@ ;; CHECK: (start $return-none) (start $return-none) + ;; Annotations + (@annotation this is a meaningless (@annotation ) ;; This is still a comment )) + it spans multiple lines just fine and can include $ids 0x42 numbers and "strings" + ) + ;; functions (func) @@ -5092,6 +5097,67 @@ cont.new $simple-cont ) + ;; CHECK: (func $source-maps (type $void) + ;; CHECK-NEXT: ;;@ src.cpp:40:1 + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: ;;@ src.cpp:30:1 + ;; CHECK-NEXT: (i32.add + ;; CHECK-NEXT: ;;@ src.cpp:10:1 + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ;;@ src.cpp:20:1 + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ;;@ src.cpp:90:1 + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: ;;@ src.cpp:70:1 + ;; CHECK-NEXT: (i32.add + ;; CHECK-NEXT: ;;@ src.cpp:50:1 + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ;;@ src.cpp:60:1 + ;; CHECK-NEXT: (block (result i32) + ;; CHECK-NEXT: ;;@ src.cpp:70:1 + ;; CHECK-NEXT: (loop (result i32) + ;; CHECK-NEXT: ;;@ src.cpp:80:1 + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ;;@ src.cpp:100:1 + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $source-maps + ;;@ src.cpp:10:1 + i32.const 0 + ;;@ src.cpp:20:1 + i32.const 1 + (@src src.cpp:30:1) + i32.add + (@src src.cpp:40:1) + drop + ;;@ src.cpp:90:1 + (drop + (@src src.cpp:70:1) + (i32.add + ;;@ src.cpp:50:1 + (i32.const 2) + (@src src.cpp:60:1) + (block (result i32) + ;;@ src.cpp:70:1 + (loop (result i32) + ;;@ src.cpp:80:1 + (unreachable) + ) + ) + ) + ) + ;;@ src.cpp:100:1 + block + end + ) + ;; CHECK: (func $use-types (type $101) (param $0 (ref $s0)) (param $1 (ref $s1)) (param $2 (ref $s2)) (param $3 (ref $s3)) (param $4 (ref $s4)) (param $5 (ref $s5)) (param $6 (ref $s6)) (param $7 (ref $s7)) (param $8 (ref $s8)) (param $9 (ref $a0)) (param $10 (ref $a1)) (param $11 (ref $a2)) (param $12 (ref $a3)) (param $13 (ref $subvoid)) (param $14 (ref $submany)) (param $15 (ref $all-types)) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) |