-
Notifications
You must be signed in to change notification settings - Fork 1
/
IndexTypes.rkt
56 lines (47 loc) · 2.52 KB
/
IndexTypes.rkt
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
#lang racket
(require redex/reduction-semantics "WASM-Redex/Syntax.rkt")
(provide WASMIndexTypes)
(define-extended-language WASMIndexTypes WASM
(ibinop ::= .... div-u/unsafe div-s/unsafe rem-u/unsafe rem-s/unsafe)
(e ::= .... (call-indirect/unsafe tfiann)
(t load/unsafe a o) (t load/unsafe (tp sx) a o)
(t store/unsafe a o) (t store/unsafe tp a o)
(if tf (e ...) else (e ...)) (block tf (e ...)) (loop tf (e ...)))
;; Index language
(ivar ::= variable-not-otherwise-mentioned)
(x y ::= ivar (t c) ((t binop) x y) ((t testop) x) ((t relop) x y) ((t cvtop t) x) ((t cvtop t sx) x))
(P ::= (= x y) (if P P P) (not P) (and P P) (or P P) (valid-address ivar o n n) ⊥)
(φ ::= empty (φ P))
(Γ ::= empty (Γ ti))
(ti ::= (t ivar))
;; Instruction index types
(locals ::= (ti ...))
;; Index-type pre/post-condition: types on stack, locals, and constraint context
(ticond ::= ((ti ...) locals Γ φ))
(labelty ::= ((ti ...) locals φ))
(retty ::= ((ti ...) φ))
;; Function annotation
(tfiann ::= (retty -> retty))
(tfi ::= (ticond -> ticond))
;; Indexed module contexts
(C ::= ((func tfiann ...) (global tg ...) (table (j tfiann ...)) (memory j) (local t ...) (label labelty ...) (return retty))
((func tfiann ...) (global tg ...) (table (j tfiann ...)) (memory j) (local t ...) (label labelty ...) (return))
((func tfiann ...) (global tg ...) (table (j tfiann ...)) (memory) (local t ...) (label labelty ...) (return retty))
((func tfiann ...) (global tg ...) (table (j tfiann ...)) (memory) (local t ...) (label labelty ...) (return))
((func tfiann ...) (global tg ...) (table) (memory j) (local t ...) (label labelty ...) (return retty))
((func tfiann ...) (global tg ...) (table) (memory j) (local t ...) (label labelty ...) (return))
((func tfiann ...) (global tg ...) (table) (memory) (local t ...) (label labelty ...) (return retty))
((func tfiann ...) (global tg ...) (table) (memory) (local t ...) (label labelty ...) (return)))
(S ::= ((C ...) (table ((j (tfiann ...)) ...)) (memory (j ...))))
;; Module-level indexed declarations
(f ::= ((ex ...) (func tfiann (local (t ...) (e ...))))
((ex ...) (func tfiann im)))
(glob ::= ((ex ...) (global tg (e ...)))
((ex ...) (global tg im)))
(tab ::= ((ex ...) (table n i ...))
((ex ...) (table n im tfi ...)))
(mem ::= ((ex ...) (memory n))
((ex ...) (memory n im)))
(im ::= (import string string))
(ex ::= (export string))
(mod ::= (module (f ...) (glob ...) (tab ...) (mem ...))))