|
| 1 | +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. |
| 2 | + |
| 3 | +;; RUN: wasm-opt %s -all -o %t.text.wast -g -S |
| 4 | +;; RUN: wasm-as %s -all -g -o %t.wasm |
| 5 | +;; RUN: wasm-dis %t.wasm -all -o %t.bin.wast |
| 6 | +;; RUN: wasm-as %s -all -o %t.nodebug.wasm |
| 7 | +;; RUN: wasm-dis %t.nodebug.wasm -all -o %t.bin.nodebug.wast |
| 8 | +;; RUN: cat %t.text.wast | filecheck %s --check-prefix=CHECK |
| 9 | +;; RUN: cat %t.bin.wast | filecheck %s --check-prefix=CHECK |
| 10 | +;; RUN: cat %t.bin.nodebug.wast | filecheck %s --check-prefix=CHECK-BIN-NODEBUG |
| 11 | + |
| 12 | +(module |
| 13 | + |
| 14 | + ;; Simple import |
| 15 | + ;; CHECK: (import "env" "t1" (type $t1 (sub eq))) |
| 16 | + (import "env" "t1" (type $t1 (sub eq))) |
| 17 | + |
| 18 | + ;; Import with omitted typetype |
| 19 | + ;; CHECK: (import "env" "t2" (type $t2 (sub any))) |
| 20 | + (import "env" "t2" (type $t2)) |
| 21 | + |
| 22 | + ;; Alternative synyax with both import and export |
| 23 | + (type $t3 (export "t3") (import "env" "t3") (sub struct)) |
| 24 | + |
| 25 | + ;; Use an imported type in a type |
| 26 | + ;; CHECK: (import "env" "t3" (type $t3 (sub struct))) |
| 27 | + |
| 28 | + ;; CHECK: (type $t4 (array (ref $t1))) |
| 29 | + (type $t4 (array (field (ref $t1)))) |
| 30 | + |
| 31 | + ;; CHECK: (type $t5 (struct (field (ref $t1)))) |
| 32 | + (type $t5 (export "t5") (struct (field (ref $t1)))) |
| 33 | + |
| 34 | + ;; Import function with imported types |
| 35 | + ;; CHECK: (type $5 (func (param (ref $t1)) (result (ref $t2)))) |
| 36 | + |
| 37 | + ;; CHECK: (type $6 (func (param (ref eq) (ref $t2) (ref $t3) (ref $t4)) (result (ref $t2)))) |
| 38 | + |
| 39 | + ;; CHECK: (type $7 (func (param (ref $t3)) (result (ref struct)))) |
| 40 | + |
| 41 | + ;; CHECK: (import "env" "g" (func $g (type $5) (param (ref $t1)) (result (ref $t2)))) |
| 42 | + (import "env" "g" (func $g (param (ref $t1)) (result (ref $t2)))) |
| 43 | + |
| 44 | + ;; Cast and function call involving imported types |
| 45 | + (func (export "f1") |
| 46 | + (param $x (ref eq)) (param (ref $t2) (ref $t3) (ref $t4)) (result (ref $t2)) |
| 47 | + (call $g |
| 48 | + (ref.cast (ref $t1) |
| 49 | + (local.get $x) |
| 50 | + ) |
| 51 | + ) |
| 52 | + ) |
| 53 | + |
| 54 | + ;; Check that the imported type is a subtype of its bound |
| 55 | + (func (export "f2") (param $x (ref $t3)) (result (ref struct)) |
| 56 | + (local.get $x) |
| 57 | + ) |
| 58 | + |
| 59 | + ;; Reexport an imported type |
| 60 | + ;; CHECK: (export "t3" (type $t3)) |
| 61 | + |
| 62 | + ;; CHECK: (export "t5" (type $t5)) |
| 63 | + |
| 64 | + ;; CHECK: (export "t2" (type $t2)) |
| 65 | + (export "t2" (type $t2)) |
| 66 | + |
| 67 | + ;; Export a type defined in this module |
| 68 | + ;; CHECK: (export "t4" (type $t4)) |
| 69 | + (export "t4" (type $t4)) |
| 70 | + |
| 71 | + ;; Export an abstract heap type |
| 72 | + (export "t6" (type extern)) |
| 73 | +) |
| 74 | +;; CHECK: (export "f1" (func $0)) |
| 75 | + |
| 76 | +;; CHECK: (export "f2" (func $1)) |
| 77 | + |
| 78 | +;; CHECK: (func $0 (type $6) (param $x (ref eq)) (param $1 (ref $t2)) (param $2 (ref $t3)) (param $3 (ref $t4)) (result (ref $t2)) |
| 79 | +;; CHECK-NEXT: (call $g |
| 80 | +;; CHECK-NEXT: (ref.cast (ref $t1) |
| 81 | +;; CHECK-NEXT: (local.get $x) |
| 82 | +;; CHECK-NEXT: ) |
| 83 | +;; CHECK-NEXT: ) |
| 84 | +;; CHECK-NEXT: ) |
| 85 | + |
| 86 | +;; CHECK: (func $1 (type $7) (param $x (ref $t3)) (result (ref struct)) |
| 87 | +;; CHECK-NEXT: (local.get $x) |
| 88 | +;; CHECK-NEXT: ) |
| 89 | + |
| 90 | +;; CHECK-BIN-NODEBUG: (import "env" "t1" (type $0 (sub eq))) |
| 91 | + |
| 92 | +;; CHECK-BIN-NODEBUG: (import "env" "t2" (type $1 (sub any))) |
| 93 | + |
| 94 | +;; CHECK-BIN-NODEBUG: (import "env" "t3" (type $2 (sub struct))) |
| 95 | + |
| 96 | +;; CHECK-BIN-NODEBUG: (type $3 (array (ref $0))) |
| 97 | + |
| 98 | +;; CHECK-BIN-NODEBUG: (type $4 (struct (field (ref $0)))) |
| 99 | + |
| 100 | +;; CHECK-BIN-NODEBUG: (type $5 (func (param (ref $0)) (result (ref $1)))) |
| 101 | + |
| 102 | +;; CHECK-BIN-NODEBUG: (type $6 (func (param (ref eq) (ref $1) (ref $2) (ref $3)) (result (ref $1)))) |
| 103 | + |
| 104 | +;; CHECK-BIN-NODEBUG: (type $7 (func (param (ref $2)) (result (ref struct)))) |
| 105 | + |
| 106 | +;; CHECK-BIN-NODEBUG: (import "env" "g" (func $fimport$0 (type $5) (param (ref $0)) (result (ref $1)))) |
| 107 | + |
| 108 | +;; CHECK-BIN-NODEBUG: (export "t3" (type $2)) |
| 109 | + |
| 110 | +;; CHECK-BIN-NODEBUG: (export "t5" (type $4)) |
| 111 | + |
| 112 | +;; CHECK-BIN-NODEBUG: (export "t2" (type $1)) |
| 113 | + |
| 114 | +;; CHECK-BIN-NODEBUG: (export "t4" (type $3)) |
| 115 | + |
| 116 | +;; CHECK-BIN-NODEBUG: (export "f1" (func $0)) |
| 117 | + |
| 118 | +;; CHECK-BIN-NODEBUG: (export "f2" (func $1)) |
| 119 | + |
| 120 | +;; CHECK-BIN-NODEBUG: (func $0 (type $6) (param $0 (ref eq)) (param $1 (ref $1)) (param $2 (ref $2)) (param $3 (ref $3)) (result (ref $1)) |
| 121 | +;; CHECK-BIN-NODEBUG-NEXT: (call $fimport$0 |
| 122 | +;; CHECK-BIN-NODEBUG-NEXT: (ref.cast (ref $0) |
| 123 | +;; CHECK-BIN-NODEBUG-NEXT: (local.get $0) |
| 124 | +;; CHECK-BIN-NODEBUG-NEXT: ) |
| 125 | +;; CHECK-BIN-NODEBUG-NEXT: ) |
| 126 | +;; CHECK-BIN-NODEBUG-NEXT: ) |
| 127 | + |
| 128 | +;; CHECK-BIN-NODEBUG: (func $1 (type $7) (param $0 (ref $2)) (result (ref struct)) |
| 129 | +;; CHECK-BIN-NODEBUG-NEXT: (local.get $0) |
| 130 | +;; CHECK-BIN-NODEBUG-NEXT: ) |
0 commit comments