File: parse-nominal-types-extends.wast

package info (click to toggle)
binaryen 108-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 35,424 kB
  • sloc: cpp: 151,487; javascript: 62,522; ansic: 13,124; python: 5,260; pascal: 441; sh: 75; asm: 27; makefile: 8
file content (72 lines) | stat: -rw-r--r-- 2,177 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.

;; Test that new-style nominal types are parsed correctly.
;; TODO: Remove --nominal below once nominal types are parsed as nominal by default.

;; RUN: foreach %s %t wasm-opt --nominal -all -S -o - | filecheck %s
;; RUN: foreach %s %t wasm-opt --nominal -all --roundtrip -S -o - | filecheck %s

;; void function type
(module
  ;; CHECK:      (type $super (func_subtype func))

  ;; CHECK:      (type $sub (func_subtype $super))
  (type $sub (func) (extends $super))

  (type $super (func))

  ;; CHECK:      (global $g (ref null $super) (ref.null $sub))
  (global $g (ref null $super) (ref.null $sub))
)

;; function type with params and results
(module
  ;; CHECK:      (type $super (func_subtype (param i32) (result i32) func))

  ;; CHECK:      (type $sub (func_subtype (param i32) (result i32) $super))
  (type $sub (func (param i32) (result i32)) (extends $super))

  (type $super (func (param i32) (result i32)))

  ;; CHECK:      (global $g (ref null $super) (ref.null $sub))
  (global $g (ref null $super) (ref.null $sub))
)

;; empty struct type
(module
  ;; CHECK:      (type $super (struct_subtype  data))

  ;; CHECK:      (type $sub (struct_subtype  $super))
  (type $sub (struct) (extends $super))

  (type $super (struct))

  ;; CHECK:      (global $g (ref null $super) (ref.null $sub))
  (global $g (ref null $super) (ref.null $sub))
)

;; struct type with fields
(module
  ;; CHECK:      (type $super (struct_subtype (field i32) (field i64) data))

  ;; CHECK:      (type $sub (struct_subtype (field i32) (field i64) $super))
  (type $sub (struct i32 (field i64)) (extends $super))

  (type $super (struct (field i32) i64))

  ;; CHECK:      (global $g (ref null $super) (ref.null $sub))
  (global $g (ref null $super) (ref.null $sub))
)

;; array type
(module
  ;; CHECK:      (type $super (array_subtype i8 data))

  ;; CHECK:      (type $sub (array_subtype i8 $super))
  (type $sub (array i8) (extends $super))

  (type $super (array i8))

  ;; CHECK:      (global $g (ref null $super) (ref.null $sub))
  (global $g (ref null $super) (ref.null $sub))
)