From 152b2d0d2d97a357c2336cb19dd962b7e5d58897 Mon Sep 17 00:00:00 2001 From: Wonho Date: Tue, 13 Jun 2023 17:29:47 +0900 Subject: [PATCH 01/49] Change instance representation as record --- spectec/spec/4-runtime.watsup | 54 +- spectec/spec/6-reduction.watsup | 55 +- spectec/test-frontend/TEST.md | 417 +++--- spectec/test-middlend/TEST.md | 2217 +++++++++++++++---------------- spectec/test-prose/TEST.md | 18 +- 5 files changed, 1380 insertions(+), 1381 deletions(-) diff --git a/spectec/spec/4-runtime.watsup b/spectec/spec/4-runtime.watsup index 2f14dde6e4..3a0cdcaca9 100644 --- a/spectec/spec/4-runtime.watsup +++ b/spectec/spec/4-runtime.watsup @@ -52,13 +52,25 @@ def $default_(EXTERNREF) = (REF.NULL EXTERNREF) ;; TODO: All reference types sho ;; Configurations -syntax funcinst hint(desc "function instance") = moduleinst; func -syntax globalinst hint(desc "global instance") = val -syntax tableinst hint(desc "table instance") = ref* -syntax meminst hint(desc "memory instance") = byte* -syntax eleminst hint(desc "element instance") = ref* -syntax datainst hint(desc "data instance") = byte* -syntax exportinst hint(desc "export instance") = EXPORT name externval +syntax funcinst hint(desc "function instance") = + { MODULE moduleinst, + CODE func } +syntax globalinst hint(desc "global instance") = + { TYPE globaltype, + VALUE val } +syntax tableinst hint(desc "table instance") = + { TYPE tabletype, + ELEM ref* } +syntax meminst hint(desc "memory instance") = + { TYPE memtype, + DATA byte* } +syntax eleminst hint(desc "element instance") = + { ELEM ref* } +syntax datainst hint(desc "data instance") = + { DATA byte* } +syntax exportinst hint(desc "export instance") = + { NAME name, + VALUE externval } syntax store hint(desc "store") = { FUNC funcinst*, @@ -123,22 +135,22 @@ def $local((s; f), x) = f.LOCAL[x] def $with_local(state, localidx, val) : state hint(show %[.LOCAL[%] = %]) -def $with_global(state, globalidx, val) : state hint(show %[.GLOBAL[%] = %]) -def $with_table(state, tableidx, nat, ref) : state hint(show %[.TABLE[%][%] = %]) -def $with_tableext(state, tableidx, ref*) : state hint(show %[.TABLE[%] =.. %]) -def $with_mem(state, tableidx, nat, nat, byte*) : state hint(show %[.MEM[%][% : %] = %]) -def $with_memext(state, tableidx, byte*) : state hint(show %[.MEM[%] =.. %]) -def $with_elem(state, elemidx, ref*) : state hint(show %[.ELEM[%] = %]) -def $with_data(state, dataidx, byte*) : state hint(show %[.DATA[%] = %]) +def $with_global(state, globalidx, val) : state hint(show %[.GLOBAL[%].VALUE = %]) +def $with_table(state, tableidx, nat, ref) : state hint(show %[.TABLE[%].ELEM[%] = %]) +def $with_tableext(state, tableidx, ref*) : state hint(show %[.TABLE[%].ELEM =.. %]) +def $with_mem(state, tableidx, nat, nat, byte*) : state hint(show %[.MEM[%].DATA[% : %] = %]) +def $with_memext(state, tableidx, byte*) : state hint(show %[.MEM[%].DATA =.. %]) +def $with_elem(state, elemidx, ref*) : state hint(show %[.ELEM[%].ELEM = %]) +def $with_data(state, dataidx, byte*) : state hint(show %[.DATA[%].DATA = %]) def $with_local((s; f), x, v) = s; f[.LOCAL[x] = v] -def $with_global((s; f), x, v) = s[.GLOBAL[f.MODULE.GLOBAL[x]] = v]; f -def $with_table((s; f), x, i, r) = s[.TABLE[f.MODULE.TABLE[x]][i] = r]; f -def $with_tableext((s; f), x, r*) = s[.TABLE[f.MODULE.TABLE[x]] =.. r*]; f -def $with_mem((s; f), x, i, j, b*) = s[.MEM[f.MODULE.MEM[x]][i : j] = b*]; f -def $with_memext((s; f), x, b*) = s[.MEM[f.MODULE.MEM[x]] =.. b*]; f -def $with_elem((s; f), x, r*) = s[.ELEM[f.MODULE.ELEM[x]] = r*]; f -def $with_data((s; f), x, b*) = s[.DATA[f.MODULE.DATA[x]] = b*]; f +def $with_global((s; f), x, v) = s[.GLOBAL[f.MODULE.GLOBAL[x]].VALUE = v]; f +def $with_table((s; f), x, i, r) = s[.TABLE[f.MODULE.TABLE[x]].ELEM[i] = r]; f +def $with_tableext((s; f), x, r*) = s[.TABLE[f.MODULE.TABLE[x]].ELEM =.. r*]; f +def $with_mem((s; f), x, i, j, b*) = s[.MEM[f.MODULE.MEM[x]].DATA[i : j] = b*]; f +def $with_memext((s; f), x, b*) = s[.MEM[f.MODULE.MEM[x]].DATA =.. b*]; f +def $with_elem((s; f), x, r*) = s[.ELEM[f.MODULE.ELEM[x]].ELEM = r*]; f +def $with_data((s; f), x, b*) = s[.DATA[f.MODULE.DATA[x]].DATA = b*]; f ;; Administrative Instructions diff --git a/spectec/spec/6-reduction.watsup b/spectec/spec/6-reduction.watsup index ea39af8dcb..4e92cf743c 100644 --- a/spectec/spec/6-reduction.watsup +++ b/spectec/spec/6-reduction.watsup @@ -84,8 +84,8 @@ rule Step_read/call: rule Step_read/call_indirect-call: z; (CONST I32 i) (CALL_INDIRECT x ft) ~> (CALL_ADDR a) - -- if $table(z, x)[i] = (REF.FUNC_ADDR a) - -- if $funcinst(z)[a] = m; FUNC ft' t* instr* + -- if $table(z, x).ELEM[i] = (REF.FUNC_ADDR a) + -- if $funcinst(z)[a].CODE = FUNC ft' t* instr* -- if ft = ft' rule Step_read/call_indirect-trap: @@ -94,7 +94,8 @@ rule Step_read/call_indirect-trap: rule Step_read/call_addr: z; val^k (CALL_ADDR a) ~> (FRAME_ n `{f} (LABEL_ n `{epsilon} instr*)) - -- if $funcinst(z)[a] = m; FUNC (t_1^k -> t_2^n) t* instr* + -- if $funcinst(z)[a] = {MODULE m, CODE func} + -- if func = FUNC (t_1^k -> t_2^n) t* instr* -- if f = {LOCAL val^k ($default_(t))*, MODULE m} @@ -172,7 +173,7 @@ rule Step_pure/local.tee: rule Step_read/global.get: - z; (GLOBAL.GET x) ~> $global(z, x) + z; (GLOBAL.GET x) ~> $global(z, x).VALUE rule Step/global.set: z; val (GLOBAL.SET x) ~> $with_global(z, x, val); epsilon @@ -180,28 +181,28 @@ rule Step/global.set: rule Step_read/table.get-trap: z; (CONST I32 i) (TABLE.GET x) ~> TRAP - -- if i >= |$table(z, x)| + -- if i >= |$table(z, x).ELEM| rule Step_read/table.get-val: - z; (CONST I32 i) (TABLE.GET x) ~> $table(z,x)[i] - -- if i < |$table(z, x)| + z; (CONST I32 i) (TABLE.GET x) ~> $table(z,x).ELEM[i] + -- if i < |$table(z, x).ELEM| rule Step/table.set-trap: z; (CONST I32 i) ref (TABLE.GET x) ~> z; TRAP - -- if i >= |$table(z, x)| + -- if i >= |$table(z, x).ELEM| rule Step/table.set-val: z; (CONST I32 i) ref (TABLE.GET x) ~> $with_table(z, x, i, ref); epsilon - -- if i < |$table(z, x)| + -- if i < |$table(z, x).ELEM| rule Step_read/table.size: z; (TABLE.SIZE x) ~> (CONST I32 n) - -- if |$table(z, x)| = n ;; TODO: inline this + -- if |$table(z, x).ELEM| = n ;; TODO: inline this rule Step/table.grow-succeed: - z; ref (CONST I32 n) (TABLE.GROW x) ~> $with_tableext(z, x, ref^n); (CONST I32 $(|$table(z, x)|)) + z; ref (CONST I32 n) (TABLE.GROW x) ~> $with_tableext(z, x, ref^n); (CONST I32 $(|$table(z, x).ELEM|)) rule Step/table.grow-fail: z; ref (CONST I32 n) (TABLE.GROW x) ~> z; (CONST I32 $(-1)) @@ -209,7 +210,7 @@ rule Step/table.grow-fail: rule Step_read/table.fill-trap: z; (CONST I32 i) val (CONST I32 n) (TABLE.FILL x) ~> TRAP - -- if $(i + n) > |$table(z, x)| + -- if $(i + n) > |$table(z, x).ELEM| rule Step_read/table.fill-zero: z; (CONST I32 i) val (CONST I32 n) (TABLE.FILL x) ~> epsilon @@ -225,7 +226,7 @@ rule Step_read/table.fill-succ: rule Step_read/table.copy-trap: z; (CONST I32 j) (CONST I32 i) (CONST I32 n) (TABLE.COPY x y) ~> TRAP - -- if $(i + n) > |$table(z, y)| \/ $(j + n) > |$table(z, x)| + -- if $(i + n) > |$table(z, y).ELEM| \/ $(j + n) > |$table(z, x).ELEM| rule Step_read/table.copy-zero: z; (CONST I32 j) (CONST I32 i) (CONST I32 n) (TABLE.COPY x y) ~> epsilon @@ -248,7 +249,7 @@ rule Step_read/table.copy-gt: rule Step_read/table.init-trap: z; (CONST I32 j) (CONST I32 i) (CONST I32 n) (TABLE.INIT x y) ~> TRAP - -- if $(i + n) > |$elem(z, y)| \/ $(j + n) > |$table(z, x)| + -- if $(i + n) > |$elem(z, y).ELEM| \/ $(j + n) > |$table(z, x).ELEM| rule Step_read/table.init-zero: z; (CONST I32 j) (CONST I32 i) (CONST I32 n) (TABLE.INIT x y) ~> epsilon @@ -257,7 +258,7 @@ rule Step_read/table.init-zero: rule Step_read/table.init-succ: z; (CONST I32 j) (CONST I32 i) (CONST I32 n) (TABLE.INIT x y) ~> - (CONST I32 j) $elem(z,y)[i] (TABLE.SET x) + (CONST I32 j) $elem(z,y).ELEM[i] (TABLE.SET x) (CONST I32 $(j+1)) (CONST I32 $(i+1)) (CONST I32 $(n-1)) (TABLE.INIT x y) -- otherwise @@ -268,24 +269,24 @@ rule Step/elem.drop: rule Step_read/load-num-trap: z; (CONST I32 i) (LOAD nt n_A n_O) ~> TRAP - -- if $(i + n_O + $size(nt)/8 > |$mem(z, 0)|) + -- if $(i + n_O + $size(nt)/8 > |$mem(z, 0).DATA|) rule Step_read/load-num-val: z; (CONST I32 i) (LOAD nt n_A n_O) ~> (CONST nt c) - -- if $bytes_($size(nt), c) = $mem(z, 0)[i + n_O : $size(nt)/8] + -- if $bytes_($size(nt), c) = $mem(z, 0).DATA[i + n_O : $size(nt)/8] rule Step_read/load-pack-trap: z; (CONST I32 i) (LOAD nt (n _ sx) n_A n_O) ~> TRAP - -- if $(i + n_O + n/8 > |$mem(z, 0)|) + -- if $(i + n_O + n/8 > |$mem(z, 0).DATA|) rule Step_read/load-pack-val: z; (CONST I32 i) (LOAD nt (n _ sx) n_A n_O) ~> (CONST nt $ext(n, $size(nt), sx, c)) - -- if $bytes_(n, c) = $mem(z, 0)[i + n_O : n/8] + -- if $bytes_(n, c) = $mem(z, 0).DATA[i + n_O : n/8] rule Step/store-num-trap: z; (CONST I32 i) (CONST nt c) (STORE nt n_A n_O) ~> z; TRAP - -- if $(i + n_O + $size(nt)/8) > |$mem(z, 0)| + -- if $(i + n_O + $size(nt)/8) > |$mem(z, 0).DATA| rule Step/store-num-val: z; (CONST I32 i) (CONST nt c) (STORE nt n_A n_O) ~> $with_mem(z, 0, $(i + n_O), $($size(nt)/8), b*); epsilon @@ -293,7 +294,7 @@ rule Step/store-num-val: rule Step/store-pack-trap: z; (CONST I32 i) (CONST nt c) (STORE nt n n_A n_O) ~> z; TRAP - -- if $(i + n_O + n/8) > |$mem(z, 0)| + -- if $(i + n_O + n/8) > |$mem(z, 0).DATA| rule Step/store-pack-val: z; (CONST I32 i) (CONST nt c) (STORE nt n n_A n_O) ~> $with_mem(z, 0, $(i + n_O), $(n/8), b*); epsilon @@ -302,11 +303,11 @@ rule Step/store-pack-val: rule Step_read/memory.size: z; (MEMORY.SIZE) ~> (CONST I32 n) - -- if $(n * 64 * $Ki) = |$mem(z, 0)| + -- if $(n * 64 * $Ki) = |$mem(z, 0).DATA| rule Step/memory.grow-succeed: - z; (CONST I32 n) (MEMORY.GROW) ~> $with_memext(z, 0, 0^(n * 64 * $Ki)); (CONST I32 $(|$mem(z, 0)| / (64 * $Ki))) + z; (CONST I32 n) (MEMORY.GROW) ~> $with_memext(z, 0, 0^(n * 64 * $Ki)); (CONST I32 $(|$mem(z, 0).DATA| / (64 * $Ki))) rule Step/memory.grow-fail: z; (CONST I32 n) (MEMORY.GROW) ~> z; (CONST I32 $(-1)) @@ -314,7 +315,7 @@ rule Step/memory.grow-fail: rule Step_read/memory.fill-trap: z; (CONST I32 i) val (CONST I32 n) (MEMORY.FILL) ~> TRAP - -- if $(i + n) > |$mem(z, 0)| + -- if $(i + n) > |$mem(z, 0).DATA| rule Step_read/memory.fill-zero: z; (CONST I32 i) val (CONST I32 n) (MEMORY.FILL) ~> epsilon @@ -330,7 +331,7 @@ rule Step_read/memory.fill-succ: rule Step_read/memory.copy-trap: z; (CONST I32 j) (CONST I32 i) (CONST I32 n) (MEMORY.COPY) ~> TRAP - -- if $(i + n) > |$mem(z, 0)| \/ $(j + n) > |$mem(z, 0)| + -- if $(i + n) > |$mem(z, 0).DATA| \/ $(j + n) > |$mem(z, 0).DATA| rule Step_read/memory.copy-zero: z; (CONST I32 j) (CONST I32 i) (CONST I32 n) (MEMORY.COPY) ~> epsilon @@ -353,7 +354,7 @@ rule Step_read/memory.copy-gt: rule Step_read/memory.init-trap: z; (CONST I32 j) (CONST I32 i) (CONST I32 n) (MEMORY.INIT x) ~> TRAP - -- if $(i + n) > |$data(z, x)| \/ $(j + n) > |$mem(z, 0)| + -- if $(i + n) > |$data(z, x).DATA| \/ $(j + n) > |$mem(z, 0).DATA| rule Step_read/memory.init-zero: z; (CONST I32 j) (CONST I32 i) (CONST I32 n) (MEMORY.INIT x) ~> epsilon @@ -362,7 +363,7 @@ rule Step_read/memory.init-zero: rule Step_read/memory.init-succ: z; (CONST I32 j) (CONST I32 i) (CONST I32 n) (MEMORY.INIT x) ~> - (CONST I32 j) (CONST I32 $data(z,x)[i]) (STORE I32 8 0 0) + (CONST I32 j) (CONST I32 $data(z,x).DATA[i]) (STORE I32 8 0 0) (CONST I32 $(j+1)) (CONST I32 $(i+1)) (CONST I32 $(n-1)) (MEMORY.INIT x) -- otherwise diff --git a/spectec/test-frontend/TEST.md b/spectec/test-frontend/TEST.md index 56ddca181f..b32ad7760b 100644 --- a/spectec/test-frontend/TEST.md +++ b/spectec/test-frontend/TEST.md @@ -1019,43 +1019,43 @@ def default_ : valtype -> val ;; 4-runtime.watsup:50.1-50.48 def default_(EXTERNREF_valtype) = REF.NULL_val(EXTERNREF_reftype) -;; 4-runtime.watsup:61.1-61.71 -syntax exportinst = EXPORT(name, externval) +;; 4-runtime.watsup:71.1-73.22 +syntax exportinst = {NAME name, VALUE externval} -;; 4-runtime.watsup:71.1-78.25 +;; 4-runtime.watsup:83.1-90.25 syntax moduleinst = {FUNC funcaddr*, GLOBAL globaladdr*, TABLE tableaddr*, MEM memaddr*, ELEM elemaddr*, DATA dataaddr*, EXPORT exportinst*} -;; 4-runtime.watsup:55.1-55.66 -syntax funcinst = `%;%`(moduleinst, func) +;; 4-runtime.watsup:55.1-57.16 +syntax funcinst = {MODULE moduleinst, CODE func} -;; 4-runtime.watsup:56.1-56.53 -syntax globalinst = val +;; 4-runtime.watsup:58.1-60.16 +syntax globalinst = {TYPE globaltype, VALUE val} -;; 4-runtime.watsup:57.1-57.52 -syntax tableinst = ref* +;; 4-runtime.watsup:61.1-63.16 +syntax tableinst = {TYPE tabletype, ELEM ref*} -;; 4-runtime.watsup:58.1-58.52 -syntax meminst = byte* +;; 4-runtime.watsup:64.1-66.17 +syntax meminst = {TYPE memtype, DATA byte*} -;; 4-runtime.watsup:59.1-59.53 -syntax eleminst = ref* +;; 4-runtime.watsup:67.1-68.16 +syntax eleminst = {ELEM ref*} -;; 4-runtime.watsup:60.1-60.51 -syntax datainst = byte* +;; 4-runtime.watsup:69.1-70.17 +syntax datainst = {DATA byte*} -;; 4-runtime.watsup:63.1-69.21 +;; 4-runtime.watsup:75.1-81.21 syntax store = {FUNC funcinst*, GLOBAL globalinst*, TABLE tableinst*, MEM meminst*, ELEM eleminst*, DATA datainst*} -;; 4-runtime.watsup:80.1-82.24 +;; 4-runtime.watsup:92.1-94.24 syntax frame = {LOCAL val*, MODULE moduleinst} -;; 4-runtime.watsup:83.1-83.47 +;; 4-runtime.watsup:95.1-95.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:146.1-153.5 +;; 4-runtime.watsup:158.1-165.5 rec { -;; 4-runtime.watsup:146.1-153.5 +;; 4-runtime.watsup:158.1-165.5 syntax admininstr = | UNREACHABLE | NOP @@ -1109,98 +1109,98 @@ syntax admininstr = | TRAP } -;; 4-runtime.watsup:84.1-84.62 +;; 4-runtime.watsup:96.1-96.62 syntax config = `%;%*`(state, admininstr*) -;; 4-runtime.watsup:102.1-102.59 +;; 4-runtime.watsup:114.1-114.59 def funcaddr : state -> funcaddr* - ;; 4-runtime.watsup:103.1-103.38 + ;; 4-runtime.watsup:115.1-115.38 def {f : frame, s : store} funcaddr(`%;%`(s, f)) = f.MODULE_frame.FUNC_moduleinst -;; 4-runtime.watsup:105.1-105.52 +;; 4-runtime.watsup:117.1-117.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:106.1-106.31 + ;; 4-runtime.watsup:118.1-118.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:108.1-108.67 +;; 4-runtime.watsup:120.1-120.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:116.1-116.48 + ;; 4-runtime.watsup:128.1-128.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:109.1-109.69 +;; 4-runtime.watsup:121.1-121.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:117.1-117.54 + ;; 4-runtime.watsup:129.1-129.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:110.1-110.68 +;; 4-runtime.watsup:122.1-122.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:118.1-118.51 + ;; 4-runtime.watsup:130.1-130.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:111.1-111.66 +;; 4-runtime.watsup:123.1-123.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:119.1-119.45 + ;; 4-runtime.watsup:131.1-131.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:112.1-112.67 +;; 4-runtime.watsup:124.1-124.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:120.1-120.48 + ;; 4-runtime.watsup:132.1-132.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:113.1-113.67 +;; 4-runtime.watsup:125.1-125.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:121.1-121.48 + ;; 4-runtime.watsup:133.1-133.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:114.1-114.68 +;; 4-runtime.watsup:126.1-126.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:122.1-122.35 + ;; 4-runtime.watsup:134.1-134.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:125.1-125.78 +;; 4-runtime.watsup:137.1-137.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:134.1-134.52 + ;; 4-runtime.watsup:146.1-146.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:126.1-126.79 +;; 4-runtime.watsup:138.1-138.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:135.1-135.71 - def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] = v], f) + ;; 4-runtime.watsup:147.1-147.77 + def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:127.1-127.83 +;; 4-runtime.watsup:139.1-139.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:136.1-136.74 - def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]][i] = r], f) + ;; 4-runtime.watsup:148.1-148.79 + def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:128.1-128.80 +;; 4-runtime.watsup:140.1-140.85 def with_tableext : (state, tableidx, ref*) -> state - ;; 4-runtime.watsup:137.1-137.75 - def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] =.. r*{r}], f) + ;; 4-runtime.watsup:149.1-149.80 + def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst =.. r*{r}], f) -;; 4-runtime.watsup:129.1-129.90 +;; 4-runtime.watsup:141.1-141.95 def with_mem : (state, tableidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:138.1-138.77 - def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]][i : j] = b*{b}], f) + ;; 4-runtime.watsup:150.1-150.82 + def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:130.1-130.78 +;; 4-runtime.watsup:142.1-142.83 def with_memext : (state, tableidx, byte*) -> state - ;; 4-runtime.watsup:139.1-139.69 - def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] =.. b*{b}], f) + ;; 4-runtime.watsup:151.1-151.74 + def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst =.. b*{b}], f) -;; 4-runtime.watsup:131.1-131.77 +;; 4-runtime.watsup:143.1-143.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:140.1-140.67 - def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] = r*{r}], f) + ;; 4-runtime.watsup:152.1-152.72 + def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:132.1-132.77 +;; 4-runtime.watsup:144.1-144.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:141.1-141.67 - def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]] = b*{b}], f) + ;; 4-runtime.watsup:153.1-153.72 + def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:155.1-158.21 +;; 4-runtime.watsup:167.1-170.21 rec { -;; 4-runtime.watsup:155.1-158.21 +;; 4-runtime.watsup:167.1-170.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -1307,73 +1307,73 @@ relation Step_pure: `%*~>%*`(admininstr*, admininstr*) `%*~>%*`([CONST_admininstr(I32_numtype, i) BR_TABLE_admininstr(l*{l}, l')], [BR_admininstr(l')]) -- if (i >= |l*{l}|) - ;; 6-reduction.watsup:101.1-102.35 + ;; 6-reduction.watsup:102.1-103.35 rule frame-vals {f : frame, n : n, val^n : val^n}: `%*~>%*`([FRAME__admininstr(n, f, (val <: admininstr)^n{val})], (val <: admininstr)^n{val}) - ;; 6-reduction.watsup:104.1-105.55 + ;; 6-reduction.watsup:105.1-106.55 rule return-frame {f : frame, instr* : instr*, n : n, val^n : val^n, val'* : val*}: `%*~>%*`([FRAME__admininstr(n, f, (val' <: admininstr)*{val'} :: (val <: admininstr)^n{val} :: [RETURN_admininstr] :: (instr <: admininstr)*{instr})], (val <: admininstr)^n{val}) - ;; 6-reduction.watsup:107.1-108.60 + ;; 6-reduction.watsup:108.1-109.60 rule return-label {instr* : instr*, instr'* : instr*, k : nat, val* : val*}: `%*~>%*`([LABEL__admininstr(k, instr'*{instr'}, (val <: admininstr)*{val} :: [RETURN_admininstr] :: (instr <: admininstr)*{instr})], (val <: admininstr)*{val} :: [RETURN_admininstr]) - ;; 6-reduction.watsup:111.1-113.33 + ;; 6-reduction.watsup:112.1-114.33 rule unop-val {c : c_numtype, c_1 : c_numtype, nt : numtype, unop : unop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) UNOP_admininstr(nt, unop)], [CONST_admininstr(nt, c)]) -- if ($unop(unop, nt, c_1) = [c]) - ;; 6-reduction.watsup:115.1-117.39 + ;; 6-reduction.watsup:116.1-118.39 rule unop-trap {c_1 : c_numtype, nt : numtype, unop : unop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) UNOP_admininstr(nt, unop)], [TRAP_admininstr]) -- if ($unop(unop, nt, c_1) = []) - ;; 6-reduction.watsup:120.1-122.40 + ;; 6-reduction.watsup:121.1-123.40 rule binop-val {binop : binop_numtype, c : c_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) BINOP_admininstr(nt, binop)], [CONST_admininstr(nt, c)]) -- if ($binop(binop, nt, c_1, c_2) = [c]) - ;; 6-reduction.watsup:124.1-126.46 + ;; 6-reduction.watsup:125.1-127.46 rule binop-trap {binop : binop_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) BINOP_admininstr(nt, binop)], [TRAP_admininstr]) -- if ($binop(binop, nt, c_1, c_2) = []) - ;; 6-reduction.watsup:129.1-131.37 + ;; 6-reduction.watsup:130.1-132.37 rule testop {c : c_numtype, c_1 : c_numtype, nt : numtype, testop : testop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) TESTOP_admininstr(nt, testop)], [CONST_admininstr(I32_numtype, c)]) -- if (c = $testop(testop, nt, c_1)) - ;; 6-reduction.watsup:133.1-135.40 + ;; 6-reduction.watsup:134.1-136.40 rule relop {c : c_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype, relop : relop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) RELOP_admininstr(nt, relop)], [CONST_admininstr(I32_numtype, c)]) -- if (c = $relop(relop, nt, c_1, c_2)) - ;; 6-reduction.watsup:138.1-139.70 + ;; 6-reduction.watsup:139.1-140.70 rule extend {c : c_numtype, n : n, nt : numtype}: `%*~>%*`([CONST_admininstr(nt, c) EXTEND_admininstr(nt, n)], [CONST_admininstr(nt, $ext(n, $size(nt <: valtype), S_sx, c))]) - ;; 6-reduction.watsup:142.1-144.48 + ;; 6-reduction.watsup:143.1-145.48 rule cvtop-val {c : c_numtype, c_1 : c_numtype, cvtop : cvtop, nt_1 : numtype, nt_2 : numtype, sx? : sx?}: `%*~>%*`([CONST_admininstr(nt_1, c_1) CVTOP_admininstr(nt_2, cvtop, nt_1, sx?{sx})], [CONST_admininstr(nt_2, c)]) -- if ($cvtop(nt_1, cvtop, nt_2, sx?{sx}, c_1) = [c]) - ;; 6-reduction.watsup:146.1-148.54 + ;; 6-reduction.watsup:147.1-149.54 rule cvtop-trap {c_1 : c_numtype, cvtop : cvtop, nt_1 : numtype, nt_2 : numtype, sx? : sx?}: `%*~>%*`([CONST_admininstr(nt_1, c_1) CVTOP_admininstr(nt_2, cvtop, nt_1, sx?{sx})], [TRAP_admininstr]) -- if ($cvtop(nt_1, cvtop, nt_2, sx?{sx}, c_1) = []) - ;; 6-reduction.watsup:155.1-157.28 + ;; 6-reduction.watsup:156.1-158.28 rule ref.is_null-true {rt : reftype, val : val}: `%*~>%*`([(val <: admininstr) REF.IS_NULL_admininstr], [CONST_admininstr(I32_numtype, 1)]) -- if (val = REF.NULL_val(rt)) - ;; 6-reduction.watsup:159.1-161.15 + ;; 6-reduction.watsup:160.1-162.15 rule ref.is_null-false {val : val}: `%*~>%*`([(val <: admininstr) REF.IS_NULL_admininstr], [CONST_admininstr(I32_numtype, 0)]) -- otherwise - ;; 6-reduction.watsup:170.1-171.47 + ;; 6-reduction.watsup:171.1-172.47 rule local.tee {val : val, x : idx}: `%*~>%*`([(val <: admininstr) LOCAL.TEE_admininstr(x)], [(val <: admininstr) (val <: admininstr) LOCAL.SET_admininstr(x)]) @@ -1384,10 +1384,10 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [CALL_admininstr(x)]), [CALL_ADDR_admininstr($funcaddr(z)[x])]) ;; 6-reduction.watsup:85.1-89.17 - rule call_indirect-call {a : addr, ft : functype, ft' : functype, i : nat, instr* : instr*, m : moduleinst, t* : valtype*, x : idx, z : state}: + rule call_indirect-call {a : addr, ft : functype, ft' : functype, i : nat, instr* : instr*, t* : valtype*, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CALL_INDIRECT_admininstr(x, ft)]), [CALL_ADDR_admininstr(a)]) - -- if ($table(z, x)[i] = REF.FUNC_ADDR_ref(a)) - -- if ($funcinst(z)[a] = `%;%`(m, `FUNC%%*%`(ft', t*{t}, instr*{instr}))) + -- if ($table(z, x).ELEM_tableinst[i] = REF.FUNC_ADDR_ref(a)) + -- if ($funcinst(z)[a].CODE_funcinst = `FUNC%%*%`(ft', t*{t}, instr*{instr})) -- if (ft = ft') ;; 6-reduction.watsup:91.1-93.15 @@ -1395,170 +1395,171 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CALL_INDIRECT_admininstr(x, ft)]), [TRAP_admininstr]) -- otherwise - ;; 6-reduction.watsup:95.1-98.52 - rule call_addr {a : addr, f : frame, instr* : instr*, k : nat, m : moduleinst, n : n, t* : valtype*, t_1^k : valtype^k, t_2^n : valtype^n, val^k : val^k, z : state}: + ;; 6-reduction.watsup:95.1-99.52 + rule call_addr {a : addr, f : frame, func : func, instr* : instr*, k : nat, m : moduleinst, n : n, t* : valtype*, t_1^k : valtype^k, t_2^n : valtype^n, val^k : val^k, z : state}: `%~>%*`(`%;%*`(z, (val <: admininstr)^k{val} :: [CALL_ADDR_admininstr(a)]), [FRAME__admininstr(n, f, [LABEL__admininstr(n, [], (instr <: admininstr)*{instr})])]) - -- if ($funcinst(z)[a] = `%;%`(m, `FUNC%%*%`(`%->%`(t_1^k{t_1}, t_2^n{t_2}), t*{t}, instr*{instr}))) + -- if ($funcinst(z)[a] = {MODULE m, CODE func}) + -- if (func = `FUNC%%*%`(`%->%`(t_1^k{t_1}, t_2^n{t_2}), t*{t}, instr*{instr})) -- if (f = {LOCAL val^k{val} :: $default_(t)*{t}, MODULE m}) - ;; 6-reduction.watsup:151.1-152.53 + ;; 6-reduction.watsup:152.1-153.53 rule ref.func {x : idx, z : state}: `%~>%*`(`%;%*`(z, [REF.FUNC_admininstr(x)]), [REF.FUNC_ADDR_admininstr($funcaddr(z)[x])]) - ;; 6-reduction.watsup:164.1-165.37 + ;; 6-reduction.watsup:165.1-166.37 rule local.get {x : idx, z : state}: `%~>%*`(`%;%*`(z, [LOCAL.GET_admininstr(x)]), [($local(z, x) <: admininstr)]) - ;; 6-reduction.watsup:174.1-175.39 + ;; 6-reduction.watsup:175.1-176.45 rule global.get {x : idx, z : state}: - `%~>%*`(`%;%*`(z, [GLOBAL.GET_admininstr(x)]), [($global(z, x) <: admininstr)]) + `%~>%*`(`%;%*`(z, [GLOBAL.GET_admininstr(x)]), [($global(z, x).VALUE_globalinst <: admininstr)]) - ;; 6-reduction.watsup:181.1-183.28 + ;; 6-reduction.watsup:182.1-184.33 rule table.get-trap {i : nat, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [TRAP_admininstr]) - -- if (i >= |$table(z, x)|) + -- if (i >= |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:185.1-187.27 + ;; 6-reduction.watsup:186.1-188.32 rule table.get-val {i : nat, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [($table(z, x)[i] <: admininstr)]) - -- if (i < |$table(z, x)|) + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [($table(z, x).ELEM_tableinst[i] <: admininstr)]) + -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:198.1-200.27 + ;; 6-reduction.watsup:199.1-201.32 rule table.size {n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) - -- if (|$table(z, x)| = n) + -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:210.1-212.34 + ;; 6-reduction.watsup:211.1-213.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) - -- if ((i + n) > |$table(z, x)|) + -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:214.1-217.14 + ;; 6-reduction.watsup:215.1-218.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:219.1-223.15 + ;; 6-reduction.watsup:220.1-224.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) (val <: admininstr) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) (val <: admininstr) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:226.1-228.63 + ;; 6-reduction.watsup:227.1-229.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) - -- if (((i + n) > |$table(z, y)|) \/ ((j + n) > |$table(z, x)|)) + -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:230.1-233.14 + ;; 6-reduction.watsup:231.1-234.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:235.1-240.15 + ;; 6-reduction.watsup:236.1-241.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:242.1-246.15 + ;; 6-reduction.watsup:243.1-247.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:249.1-251.62 + ;; 6-reduction.watsup:250.1-252.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) - -- if (((i + n) > |$elem(z, y)|) \/ ((j + n) > |$table(z, x)|)) + -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:253.1-256.14 + ;; 6-reduction.watsup:254.1-257.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:258.1-262.15 + ;; 6-reduction.watsup:259.1-263.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) ($elem(z, y)[i] <: admininstr) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) ($elem(z, y).ELEM_eleminst[i] <: admininstr) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:269.1-271.48 + ;; 6-reduction.watsup:270.1-272.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) - -- if (((i + n_O) + ($size(nt <: valtype) / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + ($size(nt <: valtype) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:273.1-275.66 + ;; 6-reduction.watsup:274.1-276.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) - -- if ($bytes_($size(nt <: valtype), c) = $mem(z, 0)[(i + n_O) : ($size(nt <: valtype) / 8)]) + -- if ($bytes_($size(nt <: valtype), c) = $mem(z, 0).DATA_meminst[(i + n_O) : ($size(nt <: valtype) / 8)]) - ;; 6-reduction.watsup:277.1-279.40 + ;; 6-reduction.watsup:278.1-280.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) - -- if (((i + n_O) + (n / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:281.1-283.50 + ;; 6-reduction.watsup:282.1-284.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, $size(nt <: valtype), sx, c))]) - -- if ($bytes_(n, c) = $mem(z, 0)[(i + n_O) : (n / 8)]) + -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:303.1-305.39 + ;; 6-reduction.watsup:304.1-306.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) - -- if (((n * 64) * $Ki) = |$mem(z, 0)|) + -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:315.1-317.32 + ;; 6-reduction.watsup:316.1-318.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) - -- if ((i + n) > |$mem(z, 0)|) + -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:319.1-322.14 + ;; 6-reduction.watsup:320.1-323.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:324.1-328.15 + ;; 6-reduction.watsup:325.1-329.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) (val <: admininstr) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) (val <: admininstr) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:331.1-333.59 + ;; 6-reduction.watsup:332.1-334.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) - -- if (((i + n) > |$mem(z, 0)|) \/ ((j + n) > |$mem(z, 0)|)) + -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:335.1-338.14 + ;; 6-reduction.watsup:336.1-339.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:340.1-345.15 + ;; 6-reduction.watsup:341.1-346.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:347.1-351.15 + ;; 6-reduction.watsup:348.1-352.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:354.1-356.60 + ;; 6-reduction.watsup:355.1-357.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) - -- if (((i + n) > |$data(z, x)|) \/ ((j + n) > |$mem(z, 0)|)) + -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:358.1-361.14 + ;; 6-reduction.watsup:359.1-362.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:363.1-367.15 + ;; 6-reduction.watsup:364.1-368.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x)[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise ;; 6-reduction.watsup:3.1-3.63 @@ -1573,65 +1574,65 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, (instr <: admininstr)*{instr}), `%;%*`(z, (instr' <: admininstr)*{instr'})) -- Step_read: `%~>%*`(`%;%*`(z, (instr <: admininstr)*{instr}), (instr' <: admininstr)*{instr'}) - ;; 6-reduction.watsup:167.1-168.60 + ;; 6-reduction.watsup:168.1-169.60 rule local.set {val : val, x : idx, z : state}: `%~>%`(`%;%*`(z, [(val <: admininstr) LOCAL.SET_admininstr(x)]), `%;%*`($with_local(z, x, val), [])) - ;; 6-reduction.watsup:177.1-178.62 + ;; 6-reduction.watsup:178.1-179.62 rule global.set {val : val, x : idx, z : state}: `%~>%`(`%;%*`(z, [(val <: admininstr) GLOBAL.SET_admininstr(x)]), `%;%*`($with_global(z, x, val), [])) - ;; 6-reduction.watsup:189.1-191.28 + ;; 6-reduction.watsup:190.1-192.33 rule table.set-trap {i : nat, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (ref <: admininstr) TABLE.GET_admininstr(x)]), `%;%*`(z, [TRAP_admininstr])) - -- if (i >= |$table(z, x)|) + -- if (i >= |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:193.1-195.27 + ;; 6-reduction.watsup:194.1-196.32 rule table.set-val {i : nat, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (ref <: admininstr) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) - -- if (i < |$table(z, x)|) + -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:203.1-204.102 + ;; 6-reduction.watsup:204.1-205.107 rule table.grow-succeed {n : n, ref : ref, x : idx, z : state}: - `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x)|)])) + `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - ;; 6-reduction.watsup:206.1-207.64 + ;; 6-reduction.watsup:207.1-208.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:265.1-266.59 + ;; 6-reduction.watsup:266.1-267.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:286.1-288.48 + ;; 6-reduction.watsup:287.1-289.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) - -- if (((i + n_O) + ($size(nt <: valtype) / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + ($size(nt <: valtype) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:290.1-292.35 + ;; 6-reduction.watsup:291.1-293.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), ($size(nt <: valtype) / 8), b*{b}), [])) -- if (b*{b} = $bytes_($size(nt <: valtype), c)) - ;; 6-reduction.watsup:294.1-296.40 + ;; 6-reduction.watsup:295.1-297.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) - -- if (((i + n_O) + (n / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:298.1-300.50 + ;; 6-reduction.watsup:299.1-301.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if (b*{b} = $bytes_(n, $wrap_(($size(nt <: valtype), n), c))) - ;; 6-reduction.watsup:308.1-309.117 + ;; 6-reduction.watsup:309.1-310.122 rule memory.grow-succeed {n : n, z : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0)| / (64 * $Ki)))])) + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - ;; 6-reduction.watsup:311.1-312.59 + ;; 6-reduction.watsup:312.1-313.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:370.1-371.59 + ;; 6-reduction.watsup:371.1-372.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) @@ -3166,13 +3167,25 @@ $$ $$ \begin{array}{@{}lrrl@{}} -\mbox{(function instance)} & \mathit{funcinst} &::=& \mathit{moduleinst} ; \mathit{func} \\ -\mbox{(global instance)} & \mathit{globalinst} &::=& \mathit{val} \\ -\mbox{(table instance)} & \mathit{tableinst} &::=& {\mathit{ref}^\ast} \\ -\mbox{(memory instance)} & \mathit{meminst} &::=& {\mathit{byte}^\ast} \\ -\mbox{(element instance)} & \mathit{eleminst} &::=& {\mathit{ref}^\ast} \\ -\mbox{(data instance)} & \mathit{datainst} &::=& {\mathit{byte}^\ast} \\ -\mbox{(export instance)} & \mathit{exportinst} &::=& \mathsf{export}~\mathit{name}~\mathit{externval} \\ +\mbox{(function instance)} & \mathit{funcinst} &::=& \{\; \begin{array}[t]{@{}l@{}} +\mathsf{module}~\mathit{moduleinst},\; \\ + \mathsf{code}~\mathit{func} \;\}\end{array} \\ +\mbox{(global instance)} & \mathit{globalinst} &::=& \{\; \begin{array}[t]{@{}l@{}} +\mathsf{type}~\mathit{globaltype},\; \\ + \mathsf{value}~\mathit{val} \;\}\end{array} \\ +\mbox{(table instance)} & \mathit{tableinst} &::=& \{\; \begin{array}[t]{@{}l@{}} +\mathsf{type}~\mathit{tabletype},\; \\ + \mathsf{elem}~{\mathit{ref}^\ast} \;\}\end{array} \\ +\mbox{(memory instance)} & \mathit{meminst} &::=& \{\; \begin{array}[t]{@{}l@{}} +\mathsf{type}~\mathit{memtype},\; \\ + \mathsf{data}~{\mathit{byte}^\ast} \;\}\end{array} \\ +\mbox{(element instance)} & \mathit{eleminst} &::=& \{\; \begin{array}[t]{@{}l@{}} +\mathsf{elem}~{\mathit{ref}^\ast} \;\}\end{array} \\ +\mbox{(data instance)} & \mathit{datainst} &::=& \{\; \begin{array}[t]{@{}l@{}} +\mathsf{data}~{\mathit{byte}^\ast} \;\}\end{array} \\ +\mbox{(export instance)} & \mathit{exportinst} &::=& \{\; \begin{array}[t]{@{}l@{}} +\mathsf{name}~\mathit{name},\; \\ + \mathsf{value}~\mathit{externval} \;\}\end{array} \\ \mbox{(store)} & \mathit{store} &::=& \{\; \begin{array}[t]{@{}l@{}} \mathsf{func}~{\mathit{funcinst}^\ast},\; \\ \mathsf{global}~{\mathit{globalinst}^\ast},\; \\ @@ -3262,43 +3275,43 @@ $$ $$ \begin{array}{@{}lcl@{}l@{}} -(\mathit{s} ; \mathit{f})[\mathsf{global}[\mathit{x}] = \mathit{v}] &=& \mathit{s}[\mathsf{global}[\mathit{f}.\mathsf{module}.\mathsf{global}[\mathit{x}]] = \mathit{v}] ; \mathit{f} & \\ +(\mathit{s} ; \mathit{f})[\mathsf{global}[\mathit{x}].\mathsf{value} = \mathit{v}] &=& \mathit{s}[\mathsf{global}[\mathit{f}.\mathsf{module}.\mathsf{global}[\mathit{x}]].\mathsf{value} = \mathit{v}] ; \mathit{f} & \\ \end{array} $$ $$ \begin{array}{@{}lcl@{}l@{}} -(\mathit{s} ; \mathit{f})[\mathsf{table}[\mathit{x}][\mathit{i}] = \mathit{r}] &=& \mathit{s}[\mathsf{table}[\mathit{f}.\mathsf{module}.\mathsf{table}[\mathit{x}]][\mathit{i}] = \mathit{r}] ; \mathit{f} & \\ +(\mathit{s} ; \mathit{f})[\mathsf{table}[\mathit{x}].\mathsf{elem}[\mathit{i}] = \mathit{r}] &=& \mathit{s}[\mathsf{table}[\mathit{f}.\mathsf{module}.\mathsf{table}[\mathit{x}]].\mathsf{elem}[\mathit{i}] = \mathit{r}] ; \mathit{f} & \\ \end{array} $$ $$ \begin{array}{@{}lcl@{}l@{}} -(\mathit{s} ; \mathit{f})[\mathsf{table}[\mathit{x}] = ..{\mathit{r}^\ast}] &=& \mathit{s}[\mathsf{table}[\mathit{f}.\mathsf{module}.\mathsf{table}[\mathit{x}]] = ..{\mathit{r}^\ast}] ; \mathit{f} & \\ +(\mathit{s} ; \mathit{f})[\mathsf{table}[\mathit{x}].\mathsf{elem} = ..{\mathit{r}^\ast}] &=& \mathit{s}[\mathsf{table}[\mathit{f}.\mathsf{module}.\mathsf{table}[\mathit{x}]].\mathsf{elem} = ..{\mathit{r}^\ast}] ; \mathit{f} & \\ \end{array} $$ $$ \begin{array}{@{}lcl@{}l@{}} -(\mathit{s} ; \mathit{f})[\mathsf{mem}[\mathit{x}][\mathit{i} : \mathit{j}] = {\mathit{b}^\ast}] &=& \mathit{s}[\mathsf{mem}[\mathit{f}.\mathsf{module}.\mathsf{mem}[\mathit{x}]][\mathit{i} : \mathit{j}] = {\mathit{b}^\ast}] ; \mathit{f} & \\ +(\mathit{s} ; \mathit{f})[\mathsf{mem}[\mathit{x}].\mathsf{data}[\mathit{i} : \mathit{j}] = {\mathit{b}^\ast}] &=& \mathit{s}[\mathsf{mem}[\mathit{f}.\mathsf{module}.\mathsf{mem}[\mathit{x}]].\mathsf{data}[\mathit{i} : \mathit{j}] = {\mathit{b}^\ast}] ; \mathit{f} & \\ \end{array} $$ $$ \begin{array}{@{}lcl@{}l@{}} -(\mathit{s} ; \mathit{f})[\mathsf{mem}[\mathit{x}] = ..{\mathit{b}^\ast}] &=& \mathit{s}[\mathsf{mem}[\mathit{f}.\mathsf{module}.\mathsf{mem}[\mathit{x}]] = ..{\mathit{b}^\ast}] ; \mathit{f} & \\ +(\mathit{s} ; \mathit{f})[\mathsf{mem}[\mathit{x}].\mathsf{data} = ..{\mathit{b}^\ast}] &=& \mathit{s}[\mathsf{mem}[\mathit{f}.\mathsf{module}.\mathsf{mem}[\mathit{x}]].\mathsf{data} = ..{\mathit{b}^\ast}] ; \mathit{f} & \\ \end{array} $$ $$ \begin{array}{@{}lcl@{}l@{}} -(\mathit{s} ; \mathit{f})[\mathsf{elem}[\mathit{x}] = {\mathit{r}^\ast}] &=& \mathit{s}[\mathsf{elem}[\mathit{f}.\mathsf{module}.\mathsf{elem}[\mathit{x}]] = {\mathit{r}^\ast}] ; \mathit{f} & \\ +(\mathit{s} ; \mathit{f})[\mathsf{elem}[\mathit{x}].\mathsf{elem} = {\mathit{r}^\ast}] &=& \mathit{s}[\mathsf{elem}[\mathit{f}.\mathsf{module}.\mathsf{elem}[\mathit{x}]].\mathsf{elem} = {\mathit{r}^\ast}] ; \mathit{f} & \\ \end{array} $$ $$ \begin{array}{@{}lcl@{}l@{}} -(\mathit{s} ; \mathit{f})[\mathsf{data}[\mathit{x}] = {\mathit{b}^\ast}] &=& \mathit{s}[\mathsf{data}[\mathit{f}.\mathsf{module}.\mathsf{data}[\mathit{x}]] = {\mathit{b}^\ast}] ; \mathit{f} & \\ +(\mathit{s} ; \mathit{f})[\mathsf{data}[\mathit{x}].\mathsf{data} = {\mathit{b}^\ast}] &=& \mathit{s}[\mathsf{data}[\mathit{f}.\mathsf{module}.\mathsf{data}[\mathit{x}]].\mathsf{data} = {\mathit{b}^\ast}] ; \mathit{f} & \\ \end{array} $$ @@ -3415,13 +3428,15 @@ $$ \begin{array}{@{}l@{}lcl@{}l@{}} {[\textsc{\scriptsize E{-}call}]} \quad & \mathit{z} ; (\mathsf{call}~\mathit{x}) &\hookrightarrow& (\mathsf{call}~\mathit{z}.\mathsf{module}.\mathsf{func}[\mathit{x}]) & \\ {[\textsc{\scriptsize E{-}call\_indirect{-}call}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{call\_indirect}~\mathit{x}~\mathit{ft}) &\hookrightarrow& (\mathsf{call}~\mathit{a}) &\quad - \mbox{if}~{\mathit{z}.\mathsf{table}}{[\mathit{x}]}[\mathit{i}] = (\mathsf{ref.func}~\mathit{a}) \\ - &&&&\quad {\land}~\mathit{z}.\mathsf{func}[\mathit{a}] = \mathit{m} ; \mathsf{func}~{\mathit{ft}'}~{\mathit{t}^\ast}~{\mathit{instr}^\ast} \\ + \mbox{if}~{\mathit{z}.\mathsf{table}}{[\mathit{x}]}.\mathsf{elem}[\mathit{i}] = (\mathsf{ref.func}~\mathit{a}) \\ + &&&&\quad {\land}~\mathit{z}.\mathsf{func}[\mathit{a}].\mathsf{code} = \mathsf{func}~{\mathit{ft}'}~{\mathit{t}^\ast}~{\mathit{instr}^\ast} \\ &&&&\quad {\land}~\mathit{ft} = {\mathit{ft}'} \\ {[\textsc{\scriptsize E{-}call\_indirect{-}trap}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{call\_indirect}~\mathit{x}~\mathit{ft}) &\hookrightarrow& \mathsf{trap} &\quad \mbox{otherwise} \\ {[\textsc{\scriptsize E{-}call\_addr}]} \quad & \mathit{z} ; {\mathit{val}^{\mathit{k}}}~(\mathsf{call}~\mathit{a}) &\hookrightarrow& ({{\mathsf{frame}}_{\mathit{n}}}{\{\mathit{f}\}}~({{\mathsf{label}}_{\mathit{n}}}{\{\epsilon\}}~{\mathit{instr}^\ast})) &\quad - \mbox{if}~\mathit{z}.\mathsf{func}[\mathit{a}] = \mathit{m} ; \mathsf{func}~({\mathit{t}_{1}^{\mathit{k}}} \rightarrow {\mathit{t}_{2}^{\mathit{n}}})~{\mathit{t}^\ast}~{\mathit{instr}^\ast} \\ + \mbox{if}~\mathit{z}.\mathsf{func}[\mathit{a}] = \{ \begin{array}[t]{@{}l@{}} +\mathsf{module}~\mathit{m},\; \mathsf{code}~\mathit{func} \}\end{array} \\ + &&&&\quad {\land}~\mathit{func} = \mathsf{func}~({\mathit{t}_{1}^{\mathit{k}}} \rightarrow {\mathit{t}_{2}^{\mathit{n}}})~{\mathit{t}^\ast}~{\mathit{instr}^\ast} \\ &&&&\quad {\land}~\mathit{f} = \{ \begin{array}[t]{@{}l@{}} \mathsf{local}~{\mathit{val}^{\mathit{k}}}~{({\mathrm{default}}_{\mathit{t}})^\ast},\; \mathsf{module}~\mathit{m} \}\end{array} \\ \end{array} @@ -3532,13 +3547,13 @@ $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}global.get}]} \quad & \mathit{z} ; (\mathsf{global.get}~\mathit{x}) &\hookrightarrow& {\mathit{z}.\mathsf{global}}{[\mathit{x}]} & \\ +{[\textsc{\scriptsize E{-}global.get}]} \quad & \mathit{z} ; (\mathsf{global.get}~\mathit{x}) &\hookrightarrow& {\mathit{z}.\mathsf{global}}{[\mathit{x}]}.\mathsf{value} & \\ \end{array} $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}global.set}]} \quad & \mathit{z} ; \mathit{val}~(\mathsf{global.set}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{global}[\mathit{x}] = \mathit{val}] ; \epsilon & \\ +{[\textsc{\scriptsize E{-}global.set}]} \quad & \mathit{z} ; \mathit{val}~(\mathsf{global.set}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{global}[\mathit{x}].\mathsf{value} = \mathit{val}] ; \epsilon & \\ \end{array} $$ @@ -3547,18 +3562,18 @@ $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} {[\textsc{\scriptsize E{-}table.get{-}trap}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{table.get}~\mathit{x}) &\hookrightarrow& \mathsf{trap} &\quad - \mbox{if}~\mathit{i} \geq {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|} \\ -{[\textsc{\scriptsize E{-}table.get{-}val}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{table.get}~\mathit{x}) &\hookrightarrow& {\mathit{z}.\mathsf{table}}{[\mathit{x}]}[\mathit{i}] &\quad - \mbox{if}~\mathit{i} < {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|} \\ + \mbox{if}~\mathit{i} \geq {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}.\mathsf{elem}|} \\ +{[\textsc{\scriptsize E{-}table.get{-}val}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{table.get}~\mathit{x}) &\hookrightarrow& {\mathit{z}.\mathsf{table}}{[\mathit{x}]}.\mathsf{elem}[\mathit{i}] &\quad + \mbox{if}~\mathit{i} < {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}.\mathsf{elem}|} \\ \end{array} $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} {[\textsc{\scriptsize E{-}table.set{-}trap}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~\mathit{ref}~(\mathsf{table.get}~\mathit{x}) &\hookrightarrow& \mathit{z} ; \mathsf{trap} &\quad - \mbox{if}~\mathit{i} \geq {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|} \\ -{[\textsc{\scriptsize E{-}table.set{-}val}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~\mathit{ref}~(\mathsf{table.get}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{table}[\mathit{x}][\mathit{i}] = \mathit{ref}] ; \epsilon &\quad - \mbox{if}~\mathit{i} < {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|} \\ + \mbox{if}~\mathit{i} \geq {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}.\mathsf{elem}|} \\ +{[\textsc{\scriptsize E{-}table.set{-}val}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~\mathit{ref}~(\mathsf{table.get}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{table}[\mathit{x}].\mathsf{elem}[\mathit{i}] = \mathit{ref}] ; \epsilon &\quad + \mbox{if}~\mathit{i} < {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}.\mathsf{elem}|} \\ \end{array} $$ @@ -3567,7 +3582,7 @@ $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} {[\textsc{\scriptsize E{-}table.size}]} \quad & \mathit{z} ; (\mathsf{table.size}~\mathit{x}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n}) &\quad - \mbox{if}~{|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|} = \mathit{n} \\ + \mbox{if}~{|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}.\mathsf{elem}|} = \mathit{n} \\ \end{array} $$ @@ -3575,7 +3590,7 @@ $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}table.grow{-}succeed}]} \quad & \mathit{z} ; \mathit{ref}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.grow}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{table}[\mathit{x}] = ..{\mathit{ref}^{\mathit{n}}}] ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~{|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|}) & \\ +{[\textsc{\scriptsize E{-}table.grow{-}succeed}]} \quad & \mathit{z} ; \mathit{ref}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.grow}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{table}[\mathit{x}].\mathsf{elem} = ..{\mathit{ref}^{\mathit{n}}}] ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~{|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}.\mathsf{elem}|}) & \\ {[\textsc{\scriptsize E{-}table.grow{-}fail}]} \quad & \mathit{z} ; \mathit{ref}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.grow}~\mathit{x}) &\hookrightarrow& \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~-1) & \\ \end{array} $$ @@ -3585,7 +3600,7 @@ $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} {[\textsc{\scriptsize E{-}table.fill{-}trap}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~\mathit{val}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.fill}~\mathit{x}) &\hookrightarrow& \mathsf{trap} &\quad - \mbox{if}~\mathit{i} + \mathit{n} > {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|} \\ + \mbox{if}~\mathit{i} + \mathit{n} > {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}.\mathsf{elem}|} \\ {[\textsc{\scriptsize E{-}table.fill{-}zero}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~\mathit{val}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.fill}~\mathit{x}) &\hookrightarrow& \epsilon &\quad \mbox{otherwise, if}~\mathit{n} = 0 \\ {[\textsc{\scriptsize E{-}table.fill{-}succ}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~\mathit{val}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.fill}~\mathit{x}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~\mathit{val}~(\mathsf{table.set}~\mathit{x})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i} + 1)~\mathit{val}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n} - 1)~(\mathsf{table.fill}~\mathit{x}) &\quad @@ -3598,7 +3613,7 @@ $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} {[\textsc{\scriptsize E{-}table.copy{-}trap}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.copy}~\mathit{x}~\mathit{y}) &\hookrightarrow& \mathsf{trap} &\quad - \mbox{if}~\mathit{i} + \mathit{n} > {|{\mathit{z}.\mathsf{table}}{[\mathit{y}]}|} \lor \mathit{j} + \mathit{n} > {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|} \\ + \mbox{if}~\mathit{i} + \mathit{n} > {|{\mathit{z}.\mathsf{table}}{[\mathit{y}]}.\mathsf{elem}|} \lor \mathit{j} + \mathit{n} > {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}.\mathsf{elem}|} \\ {[\textsc{\scriptsize E{-}table.copy{-}zero}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.copy}~\mathit{x}~\mathit{y}) &\hookrightarrow& \epsilon &\quad \mbox{otherwise, if}~\mathit{n} = 0 \\ {[\textsc{\scriptsize E{-}table.copy{-}le}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.copy}~\mathit{x}~\mathit{y}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{table.get}~\mathit{y})~(\mathsf{table.set}~\mathit{x})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j} + 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i} + 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n} - 1)~(\mathsf{table.copy}~\mathit{x}~\mathit{y}) &\quad @@ -3613,10 +3628,10 @@ $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} {[\textsc{\scriptsize E{-}table.init{-}trap}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.init}~\mathit{x}~\mathit{y}) &\hookrightarrow& \mathsf{trap} &\quad - \mbox{if}~\mathit{i} + \mathit{n} > {|{\mathit{z}.\mathsf{elem}}{[\mathit{y}]}|} \lor \mathit{j} + \mathit{n} > {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|} \\ + \mbox{if}~\mathit{i} + \mathit{n} > {|{\mathit{z}.\mathsf{elem}}{[\mathit{y}]}.\mathsf{elem}|} \lor \mathit{j} + \mathit{n} > {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}.\mathsf{elem}|} \\ {[\textsc{\scriptsize E{-}table.init{-}zero}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.init}~\mathit{x}~\mathit{y}) &\hookrightarrow& \epsilon &\quad \mbox{otherwise, if}~\mathit{n} = 0 \\ -{[\textsc{\scriptsize E{-}table.init{-}succ}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.init}~\mathit{x}~\mathit{y}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~{\mathit{z}.\mathsf{elem}}{[\mathit{y}]}[\mathit{i}]~(\mathsf{table.set}~\mathit{x})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j} + 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i} + 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n} - 1)~(\mathsf{table.init}~\mathit{x}~\mathit{y}) &\quad +{[\textsc{\scriptsize E{-}table.init{-}succ}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.init}~\mathit{x}~\mathit{y}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~{\mathit{z}.\mathsf{elem}}{[\mathit{y}]}.\mathsf{elem}[\mathit{i}]~(\mathsf{table.set}~\mathit{x})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j} + 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i} + 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n} - 1)~(\mathsf{table.init}~\mathit{x}~\mathit{y}) &\quad \mbox{otherwise} \\ \end{array} $$ @@ -3625,7 +3640,7 @@ $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}elem.drop}]} \quad & \mathit{z} ; (\mathsf{elem.drop}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{elem}[\mathit{x}] = \epsilon] ; \epsilon & \\ +{[\textsc{\scriptsize E{-}elem.drop}]} \quad & \mathit{z} ; (\mathsf{elem.drop}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{elem}[\mathit{x}].\mathsf{elem} = \epsilon] ; \epsilon & \\ \end{array} $$ @@ -3634,13 +3649,13 @@ $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} {[\textsc{\scriptsize E{-}load{-}num{-}trap}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathit{nt}.\mathsf{load}~\mathit{n}_{\mathsf{a}}~\mathit{n}_{\mathsf{o}}) &\hookrightarrow& \mathsf{trap} &\quad - \mbox{if}~\mathit{i} + \mathit{n}_{\mathsf{o}} + {|\mathit{nt}|} / 8 > {|{\mathit{z}.\mathsf{mem}}{[0]}|} \\ + \mbox{if}~\mathit{i} + \mathit{n}_{\mathsf{o}} + {|\mathit{nt}|} / 8 > {|{\mathit{z}.\mathsf{mem}}{[0]}.\mathsf{data}|} \\ {[\textsc{\scriptsize E{-}load{-}num{-}val}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathit{nt}.\mathsf{load}~\mathit{n}_{\mathsf{a}}~\mathit{n}_{\mathsf{o}}) &\hookrightarrow& (\mathit{nt}.\mathsf{const}~\mathit{c}) &\quad - \mbox{if}~{\mathrm{bytes}}_{{|\mathit{nt}|}}(\mathit{c}) = {\mathit{z}.\mathsf{mem}}{[0]}[\mathit{i} + \mathit{n}_{\mathsf{o}} : {|\mathit{nt}|} / 8] \\ + \mbox{if}~{\mathrm{bytes}}_{{|\mathit{nt}|}}(\mathit{c}) = {\mathit{z}.\mathsf{mem}}{[0]}.\mathsf{data}[\mathit{i} + \mathit{n}_{\mathsf{o}} : {|\mathit{nt}|} / 8] \\ {[\textsc{\scriptsize E{-}load{-}pack{-}trap}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~({\mathit{nt}.\mathsf{load}}{{{\mathit{n}}{\mathsf{\_}}}{\mathit{sx}}}~\mathit{n}_{\mathsf{a}}~\mathit{n}_{\mathsf{o}}) &\hookrightarrow& \mathsf{trap} &\quad - \mbox{if}~\mathit{i} + \mathit{n}_{\mathsf{o}} + \mathit{n} / 8 > {|{\mathit{z}.\mathsf{mem}}{[0]}|} \\ + \mbox{if}~\mathit{i} + \mathit{n}_{\mathsf{o}} + \mathit{n} / 8 > {|{\mathit{z}.\mathsf{mem}}{[0]}.\mathsf{data}|} \\ {[\textsc{\scriptsize E{-}load{-}pack{-}val}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~({\mathit{nt}.\mathsf{load}}{{{\mathit{n}}{\mathsf{\_}}}{\mathit{sx}}}~\mathit{n}_{\mathsf{a}}~\mathit{n}_{\mathsf{o}}) &\hookrightarrow& (\mathit{nt}.\mathsf{const}~{{\mathrm{ext}}_{\mathit{n}}({|\mathit{nt}|})^{\mathit{sx}}}~(\mathit{c})) &\quad - \mbox{if}~{\mathrm{bytes}}_{\mathit{n}}(\mathit{c}) = {\mathit{z}.\mathsf{mem}}{[0]}[\mathit{i} + \mathit{n}_{\mathsf{o}} : \mathit{n} / 8] \\ + \mbox{if}~{\mathrm{bytes}}_{\mathit{n}}(\mathit{c}) = {\mathit{z}.\mathsf{mem}}{[0]}.\mathsf{data}[\mathit{i} + \mathit{n}_{\mathsf{o}} : \mathit{n} / 8] \\ \end{array} $$ @@ -3649,12 +3664,12 @@ $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} {[\textsc{\scriptsize E{-}store{-}num{-}trap}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathit{nt}.\mathsf{const}~\mathit{c})~(\mathit{nt}.\mathsf{store}~\mathit{n}_{\mathsf{a}}~\mathit{n}_{\mathsf{o}}) &\hookrightarrow& \mathit{z} ; \mathsf{trap} &\quad - \mbox{if}~\mathit{i} + \mathit{n}_{\mathsf{o}} + {|\mathit{nt}|} / 8 > {|{\mathit{z}.\mathsf{mem}}{[0]}|} \\ -{[\textsc{\scriptsize E{-}store{-}num{-}val}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathit{nt}.\mathsf{const}~\mathit{c})~(\mathit{nt}.\mathsf{store}~\mathit{n}_{\mathsf{a}}~\mathit{n}_{\mathsf{o}}) &\hookrightarrow& \mathit{z}[\mathsf{mem}[0][\mathit{i} + \mathit{n}_{\mathsf{o}} : {|\mathit{nt}|} / 8] = {\mathit{b}^\ast}] ; \epsilon &\quad + \mbox{if}~\mathit{i} + \mathit{n}_{\mathsf{o}} + {|\mathit{nt}|} / 8 > {|{\mathit{z}.\mathsf{mem}}{[0]}.\mathsf{data}|} \\ +{[\textsc{\scriptsize E{-}store{-}num{-}val}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathit{nt}.\mathsf{const}~\mathit{c})~(\mathit{nt}.\mathsf{store}~\mathit{n}_{\mathsf{a}}~\mathit{n}_{\mathsf{o}}) &\hookrightarrow& \mathit{z}[\mathsf{mem}[0].\mathsf{data}[\mathit{i} + \mathit{n}_{\mathsf{o}} : {|\mathit{nt}|} / 8] = {\mathit{b}^\ast}] ; \epsilon &\quad \mbox{if}~{\mathit{b}^\ast} = {\mathrm{bytes}}_{{|\mathit{nt}|}}(\mathit{c}) \\ {[\textsc{\scriptsize E{-}store{-}pack{-}trap}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathit{nt}.\mathsf{const}~\mathit{c})~({\mathit{nt}.\mathsf{store}}{\mathit{n}}~\mathit{n}_{\mathsf{a}}~\mathit{n}_{\mathsf{o}}) &\hookrightarrow& \mathit{z} ; \mathsf{trap} &\quad - \mbox{if}~\mathit{i} + \mathit{n}_{\mathsf{o}} + \mathit{n} / 8 > {|{\mathit{z}.\mathsf{mem}}{[0]}|} \\ -{[\textsc{\scriptsize E{-}store{-}pack{-}val}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathit{nt}.\mathsf{const}~\mathit{c})~({\mathit{nt}.\mathsf{store}}{\mathit{n}}~\mathit{n}_{\mathsf{a}}~\mathit{n}_{\mathsf{o}}) &\hookrightarrow& \mathit{z}[\mathsf{mem}[0][\mathit{i} + \mathit{n}_{\mathsf{o}} : \mathit{n} / 8] = {\mathit{b}^\ast}] ; \epsilon &\quad + \mbox{if}~\mathit{i} + \mathit{n}_{\mathsf{o}} + \mathit{n} / 8 > {|{\mathit{z}.\mathsf{mem}}{[0]}.\mathsf{data}|} \\ +{[\textsc{\scriptsize E{-}store{-}pack{-}val}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathit{nt}.\mathsf{const}~\mathit{c})~({\mathit{nt}.\mathsf{store}}{\mathit{n}}~\mathit{n}_{\mathsf{a}}~\mathit{n}_{\mathsf{o}}) &\hookrightarrow& \mathit{z}[\mathsf{mem}[0].\mathsf{data}[\mathit{i} + \mathit{n}_{\mathsf{o}} : \mathit{n} / 8] = {\mathit{b}^\ast}] ; \epsilon &\quad \mbox{if}~{\mathit{b}^\ast} = {\mathrm{bytes}}_{\mathit{n}}({\mathrm{wrap}}_{{|\mathit{nt}|},\mathit{n}}(\mathit{c})) \\ \end{array} $$ @@ -3664,7 +3679,7 @@ $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} {[\textsc{\scriptsize E{-}memory.size}]} \quad & \mathit{z} ; (\mathsf{memory.size}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n}) &\quad - \mbox{if}~\mathit{n} \cdot 64 \cdot \mathrm{Ki} = {|{\mathit{z}.\mathsf{mem}}{[0]}|} \\ + \mbox{if}~\mathit{n} \cdot 64 \cdot \mathrm{Ki} = {|{\mathit{z}.\mathsf{mem}}{[0]}.\mathsf{data}|} \\ \end{array} $$ @@ -3672,7 +3687,7 @@ $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}memory.grow{-}succeed}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.grow}) &\hookrightarrow& \mathit{z}[\mathsf{mem}[0] = ..{0^{\mathit{n} \cdot 64 \cdot \mathrm{Ki}}}] ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~{|{\mathit{z}.\mathsf{mem}}{[0]}|} / (64 \cdot \mathrm{Ki})) & \\ +{[\textsc{\scriptsize E{-}memory.grow{-}succeed}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.grow}) &\hookrightarrow& \mathit{z}[\mathsf{mem}[0].\mathsf{data} = ..{0^{\mathit{n} \cdot 64 \cdot \mathrm{Ki}}}] ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~{|{\mathit{z}.\mathsf{mem}}{[0]}.\mathsf{data}|} / (64 \cdot \mathrm{Ki})) & \\ {[\textsc{\scriptsize E{-}memory.grow{-}fail}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.grow}) &\hookrightarrow& \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~-1) & \\ \end{array} $$ @@ -3682,7 +3697,7 @@ $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} {[\textsc{\scriptsize E{-}memory.fill{-}trap}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~\mathit{val}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.fill}) &\hookrightarrow& \mathsf{trap} &\quad - \mbox{if}~\mathit{i} + \mathit{n} > {|{\mathit{z}.\mathsf{mem}}{[0]}|} \\ + \mbox{if}~\mathit{i} + \mathit{n} > {|{\mathit{z}.\mathsf{mem}}{[0]}.\mathsf{data}|} \\ {[\textsc{\scriptsize E{-}memory.fill{-}zero}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~\mathit{val}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.fill}) &\hookrightarrow& \epsilon &\quad \mbox{otherwise, if}~\mathit{n} = 0 \\ {[\textsc{\scriptsize E{-}memory.fill{-}succ}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~\mathit{val}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.fill}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~\mathit{val}~({\mathsf{i{\scriptstyle32}}.\mathsf{store}}{8}~0~0)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i} + 1)~\mathit{val}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n} - 1)~(\mathsf{memory.fill}) &\quad @@ -3695,7 +3710,7 @@ $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} {[\textsc{\scriptsize E{-}memory.copy{-}trap}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.copy}) &\hookrightarrow& \mathsf{trap} &\quad - \mbox{if}~\mathit{i} + \mathit{n} > {|{\mathit{z}.\mathsf{mem}}{[0]}|} \lor \mathit{j} + \mathit{n} > {|{\mathit{z}.\mathsf{mem}}{[0]}|} \\ + \mbox{if}~\mathit{i} + \mathit{n} > {|{\mathit{z}.\mathsf{mem}}{[0]}.\mathsf{data}|} \lor \mathit{j} + \mathit{n} > {|{\mathit{z}.\mathsf{mem}}{[0]}.\mathsf{data}|} \\ {[\textsc{\scriptsize E{-}memory.copy{-}zero}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.copy}) &\hookrightarrow& \epsilon &\quad \mbox{otherwise, if}~\mathit{n} = 0 \\ {[\textsc{\scriptsize E{-}memory.copy{-}le}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.copy}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~({\mathsf{i{\scriptstyle32}}.\mathsf{load}}{{{8}{\mathsf{\_}}}{\mathsf{u}}}~0~0)~({\mathsf{i{\scriptstyle32}}.\mathsf{store}}{8}~0~0)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j} + 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i} + 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n} - 1)~(\mathsf{memory.copy}) &\quad @@ -3710,10 +3725,10 @@ $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} {[\textsc{\scriptsize E{-}memory.init{-}trap}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.init}~\mathit{x}) &\hookrightarrow& \mathsf{trap} &\quad - \mbox{if}~\mathit{i} + \mathit{n} > {|{\mathit{z}.\mathsf{data}}{[\mathit{x}]}|} \lor \mathit{j} + \mathit{n} > {|{\mathit{z}.\mathsf{mem}}{[0]}|} \\ + \mbox{if}~\mathit{i} + \mathit{n} > {|{\mathit{z}.\mathsf{data}}{[\mathit{x}]}.\mathsf{data}|} \lor \mathit{j} + \mathit{n} > {|{\mathit{z}.\mathsf{mem}}{[0]}.\mathsf{data}|} \\ {[\textsc{\scriptsize E{-}memory.init{-}zero}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.init}~\mathit{x}) &\hookrightarrow& \epsilon &\quad \mbox{otherwise, if}~\mathit{n} = 0 \\ -{[\textsc{\scriptsize E{-}memory.init{-}succ}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.init}~\mathit{x}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~{\mathit{z}.\mathsf{data}}{[\mathit{x}]}[\mathit{i}])~({\mathsf{i{\scriptstyle32}}.\mathsf{store}}{8}~0~0)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j} + 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i} + 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n} - 1)~(\mathsf{memory.init}~\mathit{x}) &\quad +{[\textsc{\scriptsize E{-}memory.init{-}succ}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.init}~\mathit{x}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~{\mathit{z}.\mathsf{data}}{[\mathit{x}]}.\mathsf{data}[\mathit{i}])~({\mathsf{i{\scriptstyle32}}.\mathsf{store}}{8}~0~0)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j} + 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i} + 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n} - 1)~(\mathsf{memory.init}~\mathit{x}) &\quad \mbox{otherwise} \\ \end{array} $$ @@ -3722,7 +3737,7 @@ $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}data.drop}]} \quad & \mathit{z} ; (\mathsf{data.drop}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{data}[\mathit{x}] = \epsilon] ; \epsilon & \\ +{[\textsc{\scriptsize E{-}data.drop}]} \quad & \mathit{z} ; (\mathsf{data.drop}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{data}[\mathit{x}].\mathsf{data} = \epsilon] ; \epsilon & \\ \end{array} $$ diff --git a/spectec/test-middlend/TEST.md b/spectec/test-middlend/TEST.md index 6af2e43e18..067e52faf8 100644 --- a/spectec/test-middlend/TEST.md +++ b/spectec/test-middlend/TEST.md @@ -1018,43 +1018,43 @@ def default_ : valtype -> val ;; 4-runtime.watsup:50.1-50.48 def default_(EXTERNREF_valtype) = REF.NULL_val(EXTERNREF_reftype) -;; 4-runtime.watsup:61.1-61.71 -syntax exportinst = EXPORT(name, externval) +;; 4-runtime.watsup:71.1-73.22 +syntax exportinst = {NAME name, VALUE externval} -;; 4-runtime.watsup:71.1-78.25 +;; 4-runtime.watsup:83.1-90.25 syntax moduleinst = {FUNC funcaddr*, GLOBAL globaladdr*, TABLE tableaddr*, MEM memaddr*, ELEM elemaddr*, DATA dataaddr*, EXPORT exportinst*} -;; 4-runtime.watsup:55.1-55.66 -syntax funcinst = `%;%`(moduleinst, func) +;; 4-runtime.watsup:55.1-57.16 +syntax funcinst = {MODULE moduleinst, CODE func} -;; 4-runtime.watsup:56.1-56.53 -syntax globalinst = val +;; 4-runtime.watsup:58.1-60.16 +syntax globalinst = {TYPE globaltype, VALUE val} -;; 4-runtime.watsup:57.1-57.52 -syntax tableinst = ref* +;; 4-runtime.watsup:61.1-63.16 +syntax tableinst = {TYPE tabletype, ELEM ref*} -;; 4-runtime.watsup:58.1-58.52 -syntax meminst = byte* +;; 4-runtime.watsup:64.1-66.17 +syntax meminst = {TYPE memtype, DATA byte*} -;; 4-runtime.watsup:59.1-59.53 -syntax eleminst = ref* +;; 4-runtime.watsup:67.1-68.16 +syntax eleminst = {ELEM ref*} -;; 4-runtime.watsup:60.1-60.51 -syntax datainst = byte* +;; 4-runtime.watsup:69.1-70.17 +syntax datainst = {DATA byte*} -;; 4-runtime.watsup:63.1-69.21 +;; 4-runtime.watsup:75.1-81.21 syntax store = {FUNC funcinst*, GLOBAL globalinst*, TABLE tableinst*, MEM meminst*, ELEM eleminst*, DATA datainst*} -;; 4-runtime.watsup:80.1-82.24 +;; 4-runtime.watsup:92.1-94.24 syntax frame = {LOCAL val*, MODULE moduleinst} -;; 4-runtime.watsup:83.1-83.47 +;; 4-runtime.watsup:95.1-95.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:146.1-153.5 +;; 4-runtime.watsup:158.1-165.5 rec { -;; 4-runtime.watsup:146.1-153.5 +;; 4-runtime.watsup:158.1-165.5 syntax admininstr = | UNREACHABLE | NOP @@ -1108,98 +1108,98 @@ syntax admininstr = | TRAP } -;; 4-runtime.watsup:84.1-84.62 +;; 4-runtime.watsup:96.1-96.62 syntax config = `%;%*`(state, admininstr*) -;; 4-runtime.watsup:102.1-102.59 +;; 4-runtime.watsup:114.1-114.59 def funcaddr : state -> funcaddr* - ;; 4-runtime.watsup:103.1-103.38 + ;; 4-runtime.watsup:115.1-115.38 def {f : frame, s : store} funcaddr(`%;%`(s, f)) = f.MODULE_frame.FUNC_moduleinst -;; 4-runtime.watsup:105.1-105.52 +;; 4-runtime.watsup:117.1-117.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:106.1-106.31 + ;; 4-runtime.watsup:118.1-118.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:108.1-108.67 +;; 4-runtime.watsup:120.1-120.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:116.1-116.48 + ;; 4-runtime.watsup:128.1-128.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:109.1-109.69 +;; 4-runtime.watsup:121.1-121.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:117.1-117.54 + ;; 4-runtime.watsup:129.1-129.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:110.1-110.68 +;; 4-runtime.watsup:122.1-122.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:118.1-118.51 + ;; 4-runtime.watsup:130.1-130.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:111.1-111.66 +;; 4-runtime.watsup:123.1-123.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:119.1-119.45 + ;; 4-runtime.watsup:131.1-131.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:112.1-112.67 +;; 4-runtime.watsup:124.1-124.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:120.1-120.48 + ;; 4-runtime.watsup:132.1-132.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:113.1-113.67 +;; 4-runtime.watsup:125.1-125.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:121.1-121.48 + ;; 4-runtime.watsup:133.1-133.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:114.1-114.68 +;; 4-runtime.watsup:126.1-126.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:122.1-122.35 + ;; 4-runtime.watsup:134.1-134.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:125.1-125.78 +;; 4-runtime.watsup:137.1-137.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:134.1-134.52 + ;; 4-runtime.watsup:146.1-146.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:126.1-126.79 +;; 4-runtime.watsup:138.1-138.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:135.1-135.71 - def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] = v], f) + ;; 4-runtime.watsup:147.1-147.77 + def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:127.1-127.83 +;; 4-runtime.watsup:139.1-139.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:136.1-136.74 - def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]][i] = r], f) + ;; 4-runtime.watsup:148.1-148.79 + def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:128.1-128.80 +;; 4-runtime.watsup:140.1-140.85 def with_tableext : (state, tableidx, ref*) -> state - ;; 4-runtime.watsup:137.1-137.75 - def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] =.. r*{r}], f) + ;; 4-runtime.watsup:149.1-149.80 + def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst =.. r*{r}], f) -;; 4-runtime.watsup:129.1-129.90 +;; 4-runtime.watsup:141.1-141.95 def with_mem : (state, tableidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:138.1-138.77 - def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]][i : j] = b*{b}], f) + ;; 4-runtime.watsup:150.1-150.82 + def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:130.1-130.78 +;; 4-runtime.watsup:142.1-142.83 def with_memext : (state, tableidx, byte*) -> state - ;; 4-runtime.watsup:139.1-139.69 - def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] =.. b*{b}], f) + ;; 4-runtime.watsup:151.1-151.74 + def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst =.. b*{b}], f) -;; 4-runtime.watsup:131.1-131.77 +;; 4-runtime.watsup:143.1-143.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:140.1-140.67 - def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] = r*{r}], f) + ;; 4-runtime.watsup:152.1-152.72 + def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:132.1-132.77 +;; 4-runtime.watsup:144.1-144.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:141.1-141.67 - def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]] = b*{b}], f) + ;; 4-runtime.watsup:153.1-153.72 + def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:155.1-158.21 +;; 4-runtime.watsup:167.1-170.21 rec { -;; 4-runtime.watsup:155.1-158.21 +;; 4-runtime.watsup:167.1-170.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -1306,73 +1306,73 @@ relation Step_pure: `%*~>%*`(admininstr*, admininstr*) `%*~>%*`([CONST_admininstr(I32_numtype, i) BR_TABLE_admininstr(l*{l}, l')], [BR_admininstr(l')]) -- if (i >= |l*{l}|) - ;; 6-reduction.watsup:101.1-102.35 + ;; 6-reduction.watsup:102.1-103.35 rule frame-vals {f : frame, n : n, val^n : val^n}: `%*~>%*`([FRAME__admininstr(n, f, (val <: admininstr)^n{val})], (val <: admininstr)^n{val}) - ;; 6-reduction.watsup:104.1-105.55 + ;; 6-reduction.watsup:105.1-106.55 rule return-frame {f : frame, instr* : instr*, n : n, val^n : val^n, val'* : val*}: `%*~>%*`([FRAME__admininstr(n, f, (val' <: admininstr)*{val'} :: (val <: admininstr)^n{val} :: [RETURN_admininstr] :: (instr <: admininstr)*{instr})], (val <: admininstr)^n{val}) - ;; 6-reduction.watsup:107.1-108.60 + ;; 6-reduction.watsup:108.1-109.60 rule return-label {instr* : instr*, instr'* : instr*, k : nat, val* : val*}: `%*~>%*`([LABEL__admininstr(k, instr'*{instr'}, (val <: admininstr)*{val} :: [RETURN_admininstr] :: (instr <: admininstr)*{instr})], (val <: admininstr)*{val} :: [RETURN_admininstr]) - ;; 6-reduction.watsup:111.1-113.33 + ;; 6-reduction.watsup:112.1-114.33 rule unop-val {c : c_numtype, c_1 : c_numtype, nt : numtype, unop : unop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) UNOP_admininstr(nt, unop)], [CONST_admininstr(nt, c)]) -- if ($unop(unop, nt, c_1) = [c]) - ;; 6-reduction.watsup:115.1-117.39 + ;; 6-reduction.watsup:116.1-118.39 rule unop-trap {c_1 : c_numtype, nt : numtype, unop : unop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) UNOP_admininstr(nt, unop)], [TRAP_admininstr]) -- if ($unop(unop, nt, c_1) = []) - ;; 6-reduction.watsup:120.1-122.40 + ;; 6-reduction.watsup:121.1-123.40 rule binop-val {binop : binop_numtype, c : c_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) BINOP_admininstr(nt, binop)], [CONST_admininstr(nt, c)]) -- if ($binop(binop, nt, c_1, c_2) = [c]) - ;; 6-reduction.watsup:124.1-126.46 + ;; 6-reduction.watsup:125.1-127.46 rule binop-trap {binop : binop_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) BINOP_admininstr(nt, binop)], [TRAP_admininstr]) -- if ($binop(binop, nt, c_1, c_2) = []) - ;; 6-reduction.watsup:129.1-131.37 + ;; 6-reduction.watsup:130.1-132.37 rule testop {c : c_numtype, c_1 : c_numtype, nt : numtype, testop : testop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) TESTOP_admininstr(nt, testop)], [CONST_admininstr(I32_numtype, c)]) -- if (c = $testop(testop, nt, c_1)) - ;; 6-reduction.watsup:133.1-135.40 + ;; 6-reduction.watsup:134.1-136.40 rule relop {c : c_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype, relop : relop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) RELOP_admininstr(nt, relop)], [CONST_admininstr(I32_numtype, c)]) -- if (c = $relop(relop, nt, c_1, c_2)) - ;; 6-reduction.watsup:138.1-139.70 + ;; 6-reduction.watsup:139.1-140.70 rule extend {c : c_numtype, n : n, nt : numtype}: `%*~>%*`([CONST_admininstr(nt, c) EXTEND_admininstr(nt, n)], [CONST_admininstr(nt, $ext(n, $size(nt <: valtype), S_sx, c))]) - ;; 6-reduction.watsup:142.1-144.48 + ;; 6-reduction.watsup:143.1-145.48 rule cvtop-val {c : c_numtype, c_1 : c_numtype, cvtop : cvtop, nt_1 : numtype, nt_2 : numtype, sx? : sx?}: `%*~>%*`([CONST_admininstr(nt_1, c_1) CVTOP_admininstr(nt_2, cvtop, nt_1, sx?{sx})], [CONST_admininstr(nt_2, c)]) -- if ($cvtop(nt_1, cvtop, nt_2, sx?{sx}, c_1) = [c]) - ;; 6-reduction.watsup:146.1-148.54 + ;; 6-reduction.watsup:147.1-149.54 rule cvtop-trap {c_1 : c_numtype, cvtop : cvtop, nt_1 : numtype, nt_2 : numtype, sx? : sx?}: `%*~>%*`([CONST_admininstr(nt_1, c_1) CVTOP_admininstr(nt_2, cvtop, nt_1, sx?{sx})], [TRAP_admininstr]) -- if ($cvtop(nt_1, cvtop, nt_2, sx?{sx}, c_1) = []) - ;; 6-reduction.watsup:155.1-157.28 + ;; 6-reduction.watsup:156.1-158.28 rule ref.is_null-true {rt : reftype, val : val}: `%*~>%*`([(val <: admininstr) REF.IS_NULL_admininstr], [CONST_admininstr(I32_numtype, 1)]) -- if (val = REF.NULL_val(rt)) - ;; 6-reduction.watsup:159.1-161.15 + ;; 6-reduction.watsup:160.1-162.15 rule ref.is_null-false {val : val}: `%*~>%*`([(val <: admininstr) REF.IS_NULL_admininstr], [CONST_admininstr(I32_numtype, 0)]) -- otherwise - ;; 6-reduction.watsup:170.1-171.47 + ;; 6-reduction.watsup:171.1-172.47 rule local.tee {val : val, x : idx}: `%*~>%*`([(val <: admininstr) LOCAL.TEE_admininstr(x)], [(val <: admininstr) (val <: admininstr) LOCAL.SET_admininstr(x)]) @@ -1383,10 +1383,10 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [CALL_admininstr(x)]), [CALL_ADDR_admininstr($funcaddr(z)[x])]) ;; 6-reduction.watsup:85.1-89.17 - rule call_indirect-call {a : addr, ft : functype, ft' : functype, i : nat, instr* : instr*, m : moduleinst, t* : valtype*, x : idx, z : state}: + rule call_indirect-call {a : addr, ft : functype, ft' : functype, i : nat, instr* : instr*, t* : valtype*, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CALL_INDIRECT_admininstr(x, ft)]), [CALL_ADDR_admininstr(a)]) - -- if ($table(z, x)[i] = REF.FUNC_ADDR_ref(a)) - -- if ($funcinst(z)[a] = `%;%`(m, `FUNC%%*%`(ft', t*{t}, instr*{instr}))) + -- if ($table(z, x).ELEM_tableinst[i] = REF.FUNC_ADDR_ref(a)) + -- if ($funcinst(z)[a].CODE_funcinst = `FUNC%%*%`(ft', t*{t}, instr*{instr})) -- if (ft = ft') ;; 6-reduction.watsup:91.1-93.15 @@ -1394,170 +1394,171 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CALL_INDIRECT_admininstr(x, ft)]), [TRAP_admininstr]) -- otherwise - ;; 6-reduction.watsup:95.1-98.52 - rule call_addr {a : addr, f : frame, instr* : instr*, k : nat, m : moduleinst, n : n, t* : valtype*, t_1^k : valtype^k, t_2^n : valtype^n, val^k : val^k, z : state}: + ;; 6-reduction.watsup:95.1-99.52 + rule call_addr {a : addr, f : frame, func : func, instr* : instr*, k : nat, m : moduleinst, n : n, t* : valtype*, t_1^k : valtype^k, t_2^n : valtype^n, val^k : val^k, z : state}: `%~>%*`(`%;%*`(z, (val <: admininstr)^k{val} :: [CALL_ADDR_admininstr(a)]), [FRAME__admininstr(n, f, [LABEL__admininstr(n, [], (instr <: admininstr)*{instr})])]) - -- if ($funcinst(z)[a] = `%;%`(m, `FUNC%%*%`(`%->%`(t_1^k{t_1}, t_2^n{t_2}), t*{t}, instr*{instr}))) + -- if ($funcinst(z)[a] = {MODULE m, CODE func}) + -- if (func = `FUNC%%*%`(`%->%`(t_1^k{t_1}, t_2^n{t_2}), t*{t}, instr*{instr})) -- if (f = {LOCAL val^k{val} :: $default_(t)*{t}, MODULE m}) - ;; 6-reduction.watsup:151.1-152.53 + ;; 6-reduction.watsup:152.1-153.53 rule ref.func {x : idx, z : state}: `%~>%*`(`%;%*`(z, [REF.FUNC_admininstr(x)]), [REF.FUNC_ADDR_admininstr($funcaddr(z)[x])]) - ;; 6-reduction.watsup:164.1-165.37 + ;; 6-reduction.watsup:165.1-166.37 rule local.get {x : idx, z : state}: `%~>%*`(`%;%*`(z, [LOCAL.GET_admininstr(x)]), [($local(z, x) <: admininstr)]) - ;; 6-reduction.watsup:174.1-175.39 + ;; 6-reduction.watsup:175.1-176.45 rule global.get {x : idx, z : state}: - `%~>%*`(`%;%*`(z, [GLOBAL.GET_admininstr(x)]), [($global(z, x) <: admininstr)]) + `%~>%*`(`%;%*`(z, [GLOBAL.GET_admininstr(x)]), [($global(z, x).VALUE_globalinst <: admininstr)]) - ;; 6-reduction.watsup:181.1-183.28 + ;; 6-reduction.watsup:182.1-184.33 rule table.get-trap {i : nat, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [TRAP_admininstr]) - -- if (i >= |$table(z, x)|) + -- if (i >= |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:185.1-187.27 + ;; 6-reduction.watsup:186.1-188.32 rule table.get-val {i : nat, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [($table(z, x)[i] <: admininstr)]) - -- if (i < |$table(z, x)|) + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [($table(z, x).ELEM_tableinst[i] <: admininstr)]) + -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:198.1-200.27 + ;; 6-reduction.watsup:199.1-201.32 rule table.size {n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) - -- if (|$table(z, x)| = n) + -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:210.1-212.34 + ;; 6-reduction.watsup:211.1-213.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) - -- if ((i + n) > |$table(z, x)|) + -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:214.1-217.14 + ;; 6-reduction.watsup:215.1-218.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:219.1-223.15 + ;; 6-reduction.watsup:220.1-224.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) (val <: admininstr) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) (val <: admininstr) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:226.1-228.63 + ;; 6-reduction.watsup:227.1-229.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) - -- if (((i + n) > |$table(z, y)|) \/ ((j + n) > |$table(z, x)|)) + -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:230.1-233.14 + ;; 6-reduction.watsup:231.1-234.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:235.1-240.15 + ;; 6-reduction.watsup:236.1-241.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:242.1-246.15 + ;; 6-reduction.watsup:243.1-247.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:249.1-251.62 + ;; 6-reduction.watsup:250.1-252.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) - -- if (((i + n) > |$elem(z, y)|) \/ ((j + n) > |$table(z, x)|)) + -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:253.1-256.14 + ;; 6-reduction.watsup:254.1-257.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:258.1-262.15 + ;; 6-reduction.watsup:259.1-263.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) ($elem(z, y)[i] <: admininstr) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) ($elem(z, y).ELEM_eleminst[i] <: admininstr) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:269.1-271.48 + ;; 6-reduction.watsup:270.1-272.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) - -- if (((i + n_O) + ($size(nt <: valtype) / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + ($size(nt <: valtype) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:273.1-275.66 + ;; 6-reduction.watsup:274.1-276.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) - -- if ($bytes_($size(nt <: valtype), c) = $mem(z, 0)[(i + n_O) : ($size(nt <: valtype) / 8)]) + -- if ($bytes_($size(nt <: valtype), c) = $mem(z, 0).DATA_meminst[(i + n_O) : ($size(nt <: valtype) / 8)]) - ;; 6-reduction.watsup:277.1-279.40 + ;; 6-reduction.watsup:278.1-280.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) - -- if (((i + n_O) + (n / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:281.1-283.50 + ;; 6-reduction.watsup:282.1-284.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, $size(nt <: valtype), sx, c))]) - -- if ($bytes_(n, c) = $mem(z, 0)[(i + n_O) : (n / 8)]) + -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:303.1-305.39 + ;; 6-reduction.watsup:304.1-306.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) - -- if (((n * 64) * $Ki) = |$mem(z, 0)|) + -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:315.1-317.32 + ;; 6-reduction.watsup:316.1-318.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) - -- if ((i + n) > |$mem(z, 0)|) + -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:319.1-322.14 + ;; 6-reduction.watsup:320.1-323.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:324.1-328.15 + ;; 6-reduction.watsup:325.1-329.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) (val <: admininstr) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) (val <: admininstr) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:331.1-333.59 + ;; 6-reduction.watsup:332.1-334.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) - -- if (((i + n) > |$mem(z, 0)|) \/ ((j + n) > |$mem(z, 0)|)) + -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:335.1-338.14 + ;; 6-reduction.watsup:336.1-339.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:340.1-345.15 + ;; 6-reduction.watsup:341.1-346.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:347.1-351.15 + ;; 6-reduction.watsup:348.1-352.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:354.1-356.60 + ;; 6-reduction.watsup:355.1-357.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) - -- if (((i + n) > |$data(z, x)|) \/ ((j + n) > |$mem(z, 0)|)) + -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:358.1-361.14 + ;; 6-reduction.watsup:359.1-362.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:363.1-367.15 + ;; 6-reduction.watsup:364.1-368.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x)[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise ;; 6-reduction.watsup:3.1-3.63 @@ -1572,65 +1573,65 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, (instr <: admininstr)*{instr}), `%;%*`(z, (instr' <: admininstr)*{instr'})) -- Step_read: `%~>%*`(`%;%*`(z, (instr <: admininstr)*{instr}), (instr' <: admininstr)*{instr'}) - ;; 6-reduction.watsup:167.1-168.60 + ;; 6-reduction.watsup:168.1-169.60 rule local.set {val : val, x : idx, z : state}: `%~>%`(`%;%*`(z, [(val <: admininstr) LOCAL.SET_admininstr(x)]), `%;%*`($with_local(z, x, val), [])) - ;; 6-reduction.watsup:177.1-178.62 + ;; 6-reduction.watsup:178.1-179.62 rule global.set {val : val, x : idx, z : state}: `%~>%`(`%;%*`(z, [(val <: admininstr) GLOBAL.SET_admininstr(x)]), `%;%*`($with_global(z, x, val), [])) - ;; 6-reduction.watsup:189.1-191.28 + ;; 6-reduction.watsup:190.1-192.33 rule table.set-trap {i : nat, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (ref <: admininstr) TABLE.GET_admininstr(x)]), `%;%*`(z, [TRAP_admininstr])) - -- if (i >= |$table(z, x)|) + -- if (i >= |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:193.1-195.27 + ;; 6-reduction.watsup:194.1-196.32 rule table.set-val {i : nat, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (ref <: admininstr) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) - -- if (i < |$table(z, x)|) + -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:203.1-204.102 + ;; 6-reduction.watsup:204.1-205.107 rule table.grow-succeed {n : n, ref : ref, x : idx, z : state}: - `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x)|)])) + `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - ;; 6-reduction.watsup:206.1-207.64 + ;; 6-reduction.watsup:207.1-208.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:265.1-266.59 + ;; 6-reduction.watsup:266.1-267.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:286.1-288.48 + ;; 6-reduction.watsup:287.1-289.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) - -- if (((i + n_O) + ($size(nt <: valtype) / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + ($size(nt <: valtype) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:290.1-292.35 + ;; 6-reduction.watsup:291.1-293.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), ($size(nt <: valtype) / 8), b*{b}), [])) -- if (b*{b} = $bytes_($size(nt <: valtype), c)) - ;; 6-reduction.watsup:294.1-296.40 + ;; 6-reduction.watsup:295.1-297.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) - -- if (((i + n_O) + (n / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:298.1-300.50 + ;; 6-reduction.watsup:299.1-301.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if (b*{b} = $bytes_(n, $wrap_(($size(nt <: valtype), n), c))) - ;; 6-reduction.watsup:308.1-309.117 + ;; 6-reduction.watsup:309.1-310.122 rule memory.grow-succeed {n : n, z : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0)| / (64 * $Ki)))])) + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - ;; 6-reduction.watsup:311.1-312.59 + ;; 6-reduction.watsup:312.1-313.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:370.1-371.59 + ;; 6-reduction.watsup:371.1-372.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) @@ -2679,43 +2680,43 @@ def default_ : valtype -> val ;; 4-runtime.watsup:50.1-50.48 def default_(EXTERNREF_valtype) = REF.NULL_val(EXTERNREF_reftype) -;; 4-runtime.watsup:61.1-61.71 -syntax exportinst = EXPORT(name, externval) +;; 4-runtime.watsup:71.1-73.22 +syntax exportinst = {NAME name, VALUE externval} -;; 4-runtime.watsup:71.1-78.25 +;; 4-runtime.watsup:83.1-90.25 syntax moduleinst = {FUNC funcaddr*, GLOBAL globaladdr*, TABLE tableaddr*, MEM memaddr*, ELEM elemaddr*, DATA dataaddr*, EXPORT exportinst*} -;; 4-runtime.watsup:55.1-55.66 -syntax funcinst = `%;%`(moduleinst, func) +;; 4-runtime.watsup:55.1-57.16 +syntax funcinst = {MODULE moduleinst, CODE func} -;; 4-runtime.watsup:56.1-56.53 -syntax globalinst = val +;; 4-runtime.watsup:58.1-60.16 +syntax globalinst = {TYPE globaltype, VALUE val} -;; 4-runtime.watsup:57.1-57.52 -syntax tableinst = ref* +;; 4-runtime.watsup:61.1-63.16 +syntax tableinst = {TYPE tabletype, ELEM ref*} -;; 4-runtime.watsup:58.1-58.52 -syntax meminst = byte* +;; 4-runtime.watsup:64.1-66.17 +syntax meminst = {TYPE memtype, DATA byte*} -;; 4-runtime.watsup:59.1-59.53 -syntax eleminst = ref* +;; 4-runtime.watsup:67.1-68.16 +syntax eleminst = {ELEM ref*} -;; 4-runtime.watsup:60.1-60.51 -syntax datainst = byte* +;; 4-runtime.watsup:69.1-70.17 +syntax datainst = {DATA byte*} -;; 4-runtime.watsup:63.1-69.21 +;; 4-runtime.watsup:75.1-81.21 syntax store = {FUNC funcinst*, GLOBAL globalinst*, TABLE tableinst*, MEM meminst*, ELEM eleminst*, DATA datainst*} -;; 4-runtime.watsup:80.1-82.24 +;; 4-runtime.watsup:92.1-94.24 syntax frame = {LOCAL val*, MODULE moduleinst} -;; 4-runtime.watsup:83.1-83.47 +;; 4-runtime.watsup:95.1-95.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:146.1-153.5 +;; 4-runtime.watsup:158.1-165.5 rec { -;; 4-runtime.watsup:146.1-153.5 +;; 4-runtime.watsup:158.1-165.5 syntax admininstr = | UNREACHABLE | NOP @@ -2769,12 +2770,6 @@ syntax admininstr = | TRAP } -def admininstr_globalinst : globalinst -> admininstr - def {x0 : numtype, x1 : c_numtype} admininstr_globalinst(CONST_val(x0, x1)) = CONST_admininstr(x0, x1) - def {x : reftype} admininstr_globalinst(REF.NULL_val(x)) = REF.NULL_admininstr(x) - def {x : funcaddr} admininstr_globalinst(REF.FUNC_ADDR_val(x)) = REF.FUNC_ADDR_admininstr(x) - def {x : hostaddr} admininstr_globalinst(REF.HOST_ADDR_val(x)) = REF.HOST_ADDR_admininstr(x) - def admininstr_instr : instr -> admininstr def admininstr_instr(UNREACHABLE_instr) = UNREACHABLE_admininstr def admininstr_instr(NOP_instr) = NOP_admininstr @@ -2832,98 +2827,98 @@ def admininstr_val : val -> admininstr def {x : funcaddr} admininstr_val(REF.FUNC_ADDR_val(x)) = REF.FUNC_ADDR_admininstr(x) def {x : hostaddr} admininstr_val(REF.HOST_ADDR_val(x)) = REF.HOST_ADDR_admininstr(x) -;; 4-runtime.watsup:84.1-84.62 +;; 4-runtime.watsup:96.1-96.62 syntax config = `%;%*`(state, admininstr*) -;; 4-runtime.watsup:102.1-102.59 +;; 4-runtime.watsup:114.1-114.59 def funcaddr : state -> funcaddr* - ;; 4-runtime.watsup:103.1-103.38 + ;; 4-runtime.watsup:115.1-115.38 def {f : frame, s : store} funcaddr(`%;%`(s, f)) = f.MODULE_frame.FUNC_moduleinst -;; 4-runtime.watsup:105.1-105.52 +;; 4-runtime.watsup:117.1-117.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:106.1-106.31 + ;; 4-runtime.watsup:118.1-118.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:108.1-108.67 +;; 4-runtime.watsup:120.1-120.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:116.1-116.48 + ;; 4-runtime.watsup:128.1-128.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:109.1-109.69 +;; 4-runtime.watsup:121.1-121.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:117.1-117.54 + ;; 4-runtime.watsup:129.1-129.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:110.1-110.68 +;; 4-runtime.watsup:122.1-122.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:118.1-118.51 + ;; 4-runtime.watsup:130.1-130.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:111.1-111.66 +;; 4-runtime.watsup:123.1-123.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:119.1-119.45 + ;; 4-runtime.watsup:131.1-131.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:112.1-112.67 +;; 4-runtime.watsup:124.1-124.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:120.1-120.48 + ;; 4-runtime.watsup:132.1-132.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:113.1-113.67 +;; 4-runtime.watsup:125.1-125.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:121.1-121.48 + ;; 4-runtime.watsup:133.1-133.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:114.1-114.68 +;; 4-runtime.watsup:126.1-126.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:122.1-122.35 + ;; 4-runtime.watsup:134.1-134.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:125.1-125.78 +;; 4-runtime.watsup:137.1-137.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:134.1-134.52 + ;; 4-runtime.watsup:146.1-146.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:126.1-126.79 +;; 4-runtime.watsup:138.1-138.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:135.1-135.71 - def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] = v], f) + ;; 4-runtime.watsup:147.1-147.77 + def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:127.1-127.83 +;; 4-runtime.watsup:139.1-139.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:136.1-136.74 - def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]][i] = r], f) + ;; 4-runtime.watsup:148.1-148.79 + def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:128.1-128.80 +;; 4-runtime.watsup:140.1-140.85 def with_tableext : (state, tableidx, ref*) -> state - ;; 4-runtime.watsup:137.1-137.75 - def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] =.. r*{r}], f) + ;; 4-runtime.watsup:149.1-149.80 + def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst =.. r*{r}], f) -;; 4-runtime.watsup:129.1-129.90 +;; 4-runtime.watsup:141.1-141.95 def with_mem : (state, tableidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:138.1-138.77 - def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]][i : j] = b*{b}], f) + ;; 4-runtime.watsup:150.1-150.82 + def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:130.1-130.78 +;; 4-runtime.watsup:142.1-142.83 def with_memext : (state, tableidx, byte*) -> state - ;; 4-runtime.watsup:139.1-139.69 - def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] =.. b*{b}], f) + ;; 4-runtime.watsup:151.1-151.74 + def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst =.. b*{b}], f) -;; 4-runtime.watsup:131.1-131.77 +;; 4-runtime.watsup:143.1-143.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:140.1-140.67 - def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] = r*{r}], f) + ;; 4-runtime.watsup:152.1-152.72 + def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:132.1-132.77 +;; 4-runtime.watsup:144.1-144.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:141.1-141.67 - def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]] = b*{b}], f) + ;; 4-runtime.watsup:153.1-153.72 + def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:155.1-158.21 +;; 4-runtime.watsup:167.1-170.21 rec { -;; 4-runtime.watsup:155.1-158.21 +;; 4-runtime.watsup:167.1-170.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -3030,73 +3025,73 @@ relation Step_pure: `%*~>%*`(admininstr*, admininstr*) `%*~>%*`([CONST_admininstr(I32_numtype, i) BR_TABLE_admininstr(l*{l}, l')], [BR_admininstr(l')]) -- if (i >= |l*{l}|) - ;; 6-reduction.watsup:101.1-102.35 + ;; 6-reduction.watsup:102.1-103.35 rule frame-vals {f : frame, n : n, val^n : val^n}: `%*~>%*`([FRAME__admininstr(n, f, $admininstr_val(val)^n{val})], $admininstr_val(val)^n{val}) - ;; 6-reduction.watsup:104.1-105.55 + ;; 6-reduction.watsup:105.1-106.55 rule return-frame {f : frame, instr* : instr*, n : n, val^n : val^n, val'* : val*}: `%*~>%*`([FRAME__admininstr(n, f, $admininstr_val(val')*{val'} :: $admininstr_val(val)^n{val} :: [RETURN_admininstr] :: $admininstr_instr(instr)*{instr})], $admininstr_val(val)^n{val}) - ;; 6-reduction.watsup:107.1-108.60 + ;; 6-reduction.watsup:108.1-109.60 rule return-label {instr* : instr*, instr'* : instr*, k : nat, val* : val*}: `%*~>%*`([LABEL__admininstr(k, instr'*{instr'}, $admininstr_val(val)*{val} :: [RETURN_admininstr] :: $admininstr_instr(instr)*{instr})], $admininstr_val(val)*{val} :: [RETURN_admininstr]) - ;; 6-reduction.watsup:111.1-113.33 + ;; 6-reduction.watsup:112.1-114.33 rule unop-val {c : c_numtype, c_1 : c_numtype, nt : numtype, unop : unop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) UNOP_admininstr(nt, unop)], [CONST_admininstr(nt, c)]) -- if ($unop(unop, nt, c_1) = [c]) - ;; 6-reduction.watsup:115.1-117.39 + ;; 6-reduction.watsup:116.1-118.39 rule unop-trap {c_1 : c_numtype, nt : numtype, unop : unop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) UNOP_admininstr(nt, unop)], [TRAP_admininstr]) -- if ($unop(unop, nt, c_1) = []) - ;; 6-reduction.watsup:120.1-122.40 + ;; 6-reduction.watsup:121.1-123.40 rule binop-val {binop : binop_numtype, c : c_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) BINOP_admininstr(nt, binop)], [CONST_admininstr(nt, c)]) -- if ($binop(binop, nt, c_1, c_2) = [c]) - ;; 6-reduction.watsup:124.1-126.46 + ;; 6-reduction.watsup:125.1-127.46 rule binop-trap {binop : binop_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) BINOP_admininstr(nt, binop)], [TRAP_admininstr]) -- if ($binop(binop, nt, c_1, c_2) = []) - ;; 6-reduction.watsup:129.1-131.37 + ;; 6-reduction.watsup:130.1-132.37 rule testop {c : c_numtype, c_1 : c_numtype, nt : numtype, testop : testop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) TESTOP_admininstr(nt, testop)], [CONST_admininstr(I32_numtype, c)]) -- if (c = $testop(testop, nt, c_1)) - ;; 6-reduction.watsup:133.1-135.40 + ;; 6-reduction.watsup:134.1-136.40 rule relop {c : c_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype, relop : relop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) RELOP_admininstr(nt, relop)], [CONST_admininstr(I32_numtype, c)]) -- if (c = $relop(relop, nt, c_1, c_2)) - ;; 6-reduction.watsup:138.1-139.70 + ;; 6-reduction.watsup:139.1-140.70 rule extend {c : c_numtype, n : n, nt : numtype}: `%*~>%*`([CONST_admininstr(nt, c) EXTEND_admininstr(nt, n)], [CONST_admininstr(nt, $ext(n, $size($valtype_numtype(nt)), S_sx, c))]) - ;; 6-reduction.watsup:142.1-144.48 + ;; 6-reduction.watsup:143.1-145.48 rule cvtop-val {c : c_numtype, c_1 : c_numtype, cvtop : cvtop, nt_1 : numtype, nt_2 : numtype, sx? : sx?}: `%*~>%*`([CONST_admininstr(nt_1, c_1) CVTOP_admininstr(nt_2, cvtop, nt_1, sx?{sx})], [CONST_admininstr(nt_2, c)]) -- if ($cvtop(nt_1, cvtop, nt_2, sx?{sx}, c_1) = [c]) - ;; 6-reduction.watsup:146.1-148.54 + ;; 6-reduction.watsup:147.1-149.54 rule cvtop-trap {c_1 : c_numtype, cvtop : cvtop, nt_1 : numtype, nt_2 : numtype, sx? : sx?}: `%*~>%*`([CONST_admininstr(nt_1, c_1) CVTOP_admininstr(nt_2, cvtop, nt_1, sx?{sx})], [TRAP_admininstr]) -- if ($cvtop(nt_1, cvtop, nt_2, sx?{sx}, c_1) = []) - ;; 6-reduction.watsup:155.1-157.28 + ;; 6-reduction.watsup:156.1-158.28 rule ref.is_null-true {rt : reftype, val : val}: `%*~>%*`([$admininstr_val(val) REF.IS_NULL_admininstr], [CONST_admininstr(I32_numtype, 1)]) -- if (val = REF.NULL_val(rt)) - ;; 6-reduction.watsup:159.1-161.15 + ;; 6-reduction.watsup:160.1-162.15 rule ref.is_null-false {val : val}: `%*~>%*`([$admininstr_val(val) REF.IS_NULL_admininstr], [CONST_admininstr(I32_numtype, 0)]) -- otherwise - ;; 6-reduction.watsup:170.1-171.47 + ;; 6-reduction.watsup:171.1-172.47 rule local.tee {val : val, x : idx}: `%*~>%*`([$admininstr_val(val) LOCAL.TEE_admininstr(x)], [$admininstr_val(val) $admininstr_val(val) LOCAL.SET_admininstr(x)]) @@ -3107,10 +3102,10 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [CALL_admininstr(x)]), [CALL_ADDR_admininstr($funcaddr(z)[x])]) ;; 6-reduction.watsup:85.1-89.17 - rule call_indirect-call {a : addr, ft : functype, ft' : functype, i : nat, instr* : instr*, m : moduleinst, t* : valtype*, x : idx, z : state}: + rule call_indirect-call {a : addr, ft : functype, ft' : functype, i : nat, instr* : instr*, t* : valtype*, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CALL_INDIRECT_admininstr(x, ft)]), [CALL_ADDR_admininstr(a)]) - -- if ($table(z, x)[i] = REF.FUNC_ADDR_ref(a)) - -- if ($funcinst(z)[a] = `%;%`(m, `FUNC%%*%`(ft', t*{t}, instr*{instr}))) + -- if ($table(z, x).ELEM_tableinst[i] = REF.FUNC_ADDR_ref(a)) + -- if ($funcinst(z)[a].CODE_funcinst = `FUNC%%*%`(ft', t*{t}, instr*{instr})) -- if (ft = ft') ;; 6-reduction.watsup:91.1-93.15 @@ -3118,170 +3113,171 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CALL_INDIRECT_admininstr(x, ft)]), [TRAP_admininstr]) -- otherwise - ;; 6-reduction.watsup:95.1-98.52 - rule call_addr {a : addr, f : frame, instr* : instr*, k : nat, m : moduleinst, n : n, t* : valtype*, t_1^k : valtype^k, t_2^n : valtype^n, val^k : val^k, z : state}: + ;; 6-reduction.watsup:95.1-99.52 + rule call_addr {a : addr, f : frame, func : func, instr* : instr*, k : nat, m : moduleinst, n : n, t* : valtype*, t_1^k : valtype^k, t_2^n : valtype^n, val^k : val^k, z : state}: `%~>%*`(`%;%*`(z, $admininstr_val(val)^k{val} :: [CALL_ADDR_admininstr(a)]), [FRAME__admininstr(n, f, [LABEL__admininstr(n, [], $admininstr_instr(instr)*{instr})])]) - -- if ($funcinst(z)[a] = `%;%`(m, `FUNC%%*%`(`%->%`(t_1^k{t_1}, t_2^n{t_2}), t*{t}, instr*{instr}))) + -- if ($funcinst(z)[a] = {MODULE m, CODE func}) + -- if (func = `FUNC%%*%`(`%->%`(t_1^k{t_1}, t_2^n{t_2}), t*{t}, instr*{instr})) -- if (f = {LOCAL val^k{val} :: $default_(t)*{t}, MODULE m}) - ;; 6-reduction.watsup:151.1-152.53 + ;; 6-reduction.watsup:152.1-153.53 rule ref.func {x : idx, z : state}: `%~>%*`(`%;%*`(z, [REF.FUNC_admininstr(x)]), [REF.FUNC_ADDR_admininstr($funcaddr(z)[x])]) - ;; 6-reduction.watsup:164.1-165.37 + ;; 6-reduction.watsup:165.1-166.37 rule local.get {x : idx, z : state}: `%~>%*`(`%;%*`(z, [LOCAL.GET_admininstr(x)]), [$admininstr_val($local(z, x))]) - ;; 6-reduction.watsup:174.1-175.39 + ;; 6-reduction.watsup:175.1-176.45 rule global.get {x : idx, z : state}: - `%~>%*`(`%;%*`(z, [GLOBAL.GET_admininstr(x)]), [$admininstr_globalinst($global(z, x))]) + `%~>%*`(`%;%*`(z, [GLOBAL.GET_admininstr(x)]), [$admininstr_val($global(z, x).VALUE_globalinst)]) - ;; 6-reduction.watsup:181.1-183.28 + ;; 6-reduction.watsup:182.1-184.33 rule table.get-trap {i : nat, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [TRAP_admininstr]) - -- if (i >= |$table(z, x)|) + -- if (i >= |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:185.1-187.27 + ;; 6-reduction.watsup:186.1-188.32 rule table.get-val {i : nat, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [$admininstr_ref($table(z, x)[i])]) - -- if (i < |$table(z, x)|) + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [$admininstr_ref($table(z, x).ELEM_tableinst[i])]) + -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:198.1-200.27 + ;; 6-reduction.watsup:199.1-201.32 rule table.size {n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) - -- if (|$table(z, x)| = n) + -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:210.1-212.34 + ;; 6-reduction.watsup:211.1-213.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) - -- if ((i + n) > |$table(z, x)|) + -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:214.1-217.14 + ;; 6-reduction.watsup:215.1-218.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:219.1-223.15 + ;; 6-reduction.watsup:220.1-224.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:226.1-228.63 + ;; 6-reduction.watsup:227.1-229.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) - -- if (((i + n) > |$table(z, y)|) \/ ((j + n) > |$table(z, x)|)) + -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:230.1-233.14 + ;; 6-reduction.watsup:231.1-234.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:235.1-240.15 + ;; 6-reduction.watsup:236.1-241.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:242.1-246.15 + ;; 6-reduction.watsup:243.1-247.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:249.1-251.62 + ;; 6-reduction.watsup:250.1-252.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) - -- if (((i + n) > |$elem(z, y)|) \/ ((j + n) > |$table(z, x)|)) + -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:253.1-256.14 + ;; 6-reduction.watsup:254.1-257.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:258.1-262.15 + ;; 6-reduction.watsup:259.1-263.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y)[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y).ELEM_eleminst[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:269.1-271.48 + ;; 6-reduction.watsup:270.1-272.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) - -- if (((i + n_O) + ($size($valtype_numtype(nt)) / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + ($size($valtype_numtype(nt)) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:273.1-275.66 + ;; 6-reduction.watsup:274.1-276.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) - -- if ($bytes_($size($valtype_numtype(nt)), c) = $mem(z, 0)[(i + n_O) : ($size($valtype_numtype(nt)) / 8)]) + -- if ($bytes_($size($valtype_numtype(nt)), c) = $mem(z, 0).DATA_meminst[(i + n_O) : ($size($valtype_numtype(nt)) / 8)]) - ;; 6-reduction.watsup:277.1-279.40 + ;; 6-reduction.watsup:278.1-280.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) - -- if (((i + n_O) + (n / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:281.1-283.50 + ;; 6-reduction.watsup:282.1-284.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, $size($valtype_numtype(nt)), sx, c))]) - -- if ($bytes_(n, c) = $mem(z, 0)[(i + n_O) : (n / 8)]) + -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:303.1-305.39 + ;; 6-reduction.watsup:304.1-306.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) - -- if (((n * 64) * $Ki) = |$mem(z, 0)|) + -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:315.1-317.32 + ;; 6-reduction.watsup:316.1-318.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) - -- if ((i + n) > |$mem(z, 0)|) + -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:319.1-322.14 + ;; 6-reduction.watsup:320.1-323.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:324.1-328.15 + ;; 6-reduction.watsup:325.1-329.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:331.1-333.59 + ;; 6-reduction.watsup:332.1-334.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) - -- if (((i + n) > |$mem(z, 0)|) \/ ((j + n) > |$mem(z, 0)|)) + -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:335.1-338.14 + ;; 6-reduction.watsup:336.1-339.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:340.1-345.15 + ;; 6-reduction.watsup:341.1-346.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:347.1-351.15 + ;; 6-reduction.watsup:348.1-352.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:354.1-356.60 + ;; 6-reduction.watsup:355.1-357.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) - -- if (((i + n) > |$data(z, x)|) \/ ((j + n) > |$mem(z, 0)|)) + -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:358.1-361.14 + ;; 6-reduction.watsup:359.1-362.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:363.1-367.15 + ;; 6-reduction.watsup:364.1-368.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x)[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise ;; 6-reduction.watsup:3.1-3.63 @@ -3296,65 +3292,65 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, $admininstr_instr(instr)*{instr}), `%;%*`(z, $admininstr_instr(instr')*{instr'})) -- Step_read: `%~>%*`(`%;%*`(z, $admininstr_instr(instr)*{instr}), $admininstr_instr(instr')*{instr'}) - ;; 6-reduction.watsup:167.1-168.60 + ;; 6-reduction.watsup:168.1-169.60 rule local.set {val : val, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_val(val) LOCAL.SET_admininstr(x)]), `%;%*`($with_local(z, x, val), [])) - ;; 6-reduction.watsup:177.1-178.62 + ;; 6-reduction.watsup:178.1-179.62 rule global.set {val : val, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_val(val) GLOBAL.SET_admininstr(x)]), `%;%*`($with_global(z, x, val), [])) - ;; 6-reduction.watsup:189.1-191.28 + ;; 6-reduction.watsup:190.1-192.33 rule table.set-trap {i : nat, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`(z, [TRAP_admininstr])) - -- if (i >= |$table(z, x)|) + -- if (i >= |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:193.1-195.27 + ;; 6-reduction.watsup:194.1-196.32 rule table.set-val {i : nat, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) - -- if (i < |$table(z, x)|) + -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:203.1-204.102 + ;; 6-reduction.watsup:204.1-205.107 rule table.grow-succeed {n : n, ref : ref, x : idx, z : state}: - `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x)|)])) + `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - ;; 6-reduction.watsup:206.1-207.64 + ;; 6-reduction.watsup:207.1-208.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:265.1-266.59 + ;; 6-reduction.watsup:266.1-267.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:286.1-288.48 + ;; 6-reduction.watsup:287.1-289.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) - -- if (((i + n_O) + ($size($valtype_numtype(nt)) / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + ($size($valtype_numtype(nt)) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:290.1-292.35 + ;; 6-reduction.watsup:291.1-293.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), ($size($valtype_numtype(nt)) / 8), b*{b}), [])) -- if (b*{b} = $bytes_($size($valtype_numtype(nt)), c)) - ;; 6-reduction.watsup:294.1-296.40 + ;; 6-reduction.watsup:295.1-297.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) - -- if (((i + n_O) + (n / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:298.1-300.50 + ;; 6-reduction.watsup:299.1-301.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if (b*{b} = $bytes_(n, $wrap_(($size($valtype_numtype(nt)), n), c))) - ;; 6-reduction.watsup:308.1-309.117 + ;; 6-reduction.watsup:309.1-310.122 rule memory.grow-succeed {n : n, z : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0)| / (64 * $Ki)))])) + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - ;; 6-reduction.watsup:311.1-312.59 + ;; 6-reduction.watsup:312.1-313.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:370.1-371.59 + ;; 6-reduction.watsup:371.1-372.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) @@ -4405,43 +4401,43 @@ def default_ : valtype -> val? def default_(EXTERNREF_valtype) = ?(REF.NULL_val(EXTERNREF_reftype)) def {x : valtype} default_(x) = ?() -;; 4-runtime.watsup:61.1-61.71 -syntax exportinst = EXPORT(name, externval) +;; 4-runtime.watsup:71.1-73.22 +syntax exportinst = {NAME name, VALUE externval} -;; 4-runtime.watsup:71.1-78.25 +;; 4-runtime.watsup:83.1-90.25 syntax moduleinst = {FUNC funcaddr*, GLOBAL globaladdr*, TABLE tableaddr*, MEM memaddr*, ELEM elemaddr*, DATA dataaddr*, EXPORT exportinst*} -;; 4-runtime.watsup:55.1-55.66 -syntax funcinst = `%;%`(moduleinst, func) +;; 4-runtime.watsup:55.1-57.16 +syntax funcinst = {MODULE moduleinst, CODE func} -;; 4-runtime.watsup:56.1-56.53 -syntax globalinst = val +;; 4-runtime.watsup:58.1-60.16 +syntax globalinst = {TYPE globaltype, VALUE val} -;; 4-runtime.watsup:57.1-57.52 -syntax tableinst = ref* +;; 4-runtime.watsup:61.1-63.16 +syntax tableinst = {TYPE tabletype, ELEM ref*} -;; 4-runtime.watsup:58.1-58.52 -syntax meminst = byte* +;; 4-runtime.watsup:64.1-66.17 +syntax meminst = {TYPE memtype, DATA byte*} -;; 4-runtime.watsup:59.1-59.53 -syntax eleminst = ref* +;; 4-runtime.watsup:67.1-68.16 +syntax eleminst = {ELEM ref*} -;; 4-runtime.watsup:60.1-60.51 -syntax datainst = byte* +;; 4-runtime.watsup:69.1-70.17 +syntax datainst = {DATA byte*} -;; 4-runtime.watsup:63.1-69.21 +;; 4-runtime.watsup:75.1-81.21 syntax store = {FUNC funcinst*, GLOBAL globalinst*, TABLE tableinst*, MEM meminst*, ELEM eleminst*, DATA datainst*} -;; 4-runtime.watsup:80.1-82.24 +;; 4-runtime.watsup:92.1-94.24 syntax frame = {LOCAL val*, MODULE moduleinst} -;; 4-runtime.watsup:83.1-83.47 +;; 4-runtime.watsup:95.1-95.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:146.1-153.5 +;; 4-runtime.watsup:158.1-165.5 rec { -;; 4-runtime.watsup:146.1-153.5 +;; 4-runtime.watsup:158.1-165.5 syntax admininstr = | UNREACHABLE | NOP @@ -4495,12 +4491,6 @@ syntax admininstr = | TRAP } -def admininstr_globalinst : globalinst -> admininstr - def {x0 : numtype, x1 : c_numtype} admininstr_globalinst(CONST_val(x0, x1)) = CONST_admininstr(x0, x1) - def {x : reftype} admininstr_globalinst(REF.NULL_val(x)) = REF.NULL_admininstr(x) - def {x : funcaddr} admininstr_globalinst(REF.FUNC_ADDR_val(x)) = REF.FUNC_ADDR_admininstr(x) - def {x : hostaddr} admininstr_globalinst(REF.HOST_ADDR_val(x)) = REF.HOST_ADDR_admininstr(x) - def admininstr_instr : instr -> admininstr def admininstr_instr(UNREACHABLE_instr) = UNREACHABLE_admininstr def admininstr_instr(NOP_instr) = NOP_admininstr @@ -4558,98 +4548,98 @@ def admininstr_val : val -> admininstr def {x : funcaddr} admininstr_val(REF.FUNC_ADDR_val(x)) = REF.FUNC_ADDR_admininstr(x) def {x : hostaddr} admininstr_val(REF.HOST_ADDR_val(x)) = REF.HOST_ADDR_admininstr(x) -;; 4-runtime.watsup:84.1-84.62 +;; 4-runtime.watsup:96.1-96.62 syntax config = `%;%*`(state, admininstr*) -;; 4-runtime.watsup:102.1-102.59 +;; 4-runtime.watsup:114.1-114.59 def funcaddr : state -> funcaddr* - ;; 4-runtime.watsup:103.1-103.38 + ;; 4-runtime.watsup:115.1-115.38 def {f : frame, s : store} funcaddr(`%;%`(s, f)) = f.MODULE_frame.FUNC_moduleinst -;; 4-runtime.watsup:105.1-105.52 +;; 4-runtime.watsup:117.1-117.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:106.1-106.31 + ;; 4-runtime.watsup:118.1-118.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:108.1-108.67 +;; 4-runtime.watsup:120.1-120.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:116.1-116.48 + ;; 4-runtime.watsup:128.1-128.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:109.1-109.69 +;; 4-runtime.watsup:121.1-121.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:117.1-117.54 + ;; 4-runtime.watsup:129.1-129.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:110.1-110.68 +;; 4-runtime.watsup:122.1-122.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:118.1-118.51 + ;; 4-runtime.watsup:130.1-130.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:111.1-111.66 +;; 4-runtime.watsup:123.1-123.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:119.1-119.45 + ;; 4-runtime.watsup:131.1-131.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:112.1-112.67 +;; 4-runtime.watsup:124.1-124.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:120.1-120.48 + ;; 4-runtime.watsup:132.1-132.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:113.1-113.67 +;; 4-runtime.watsup:125.1-125.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:121.1-121.48 + ;; 4-runtime.watsup:133.1-133.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:114.1-114.68 +;; 4-runtime.watsup:126.1-126.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:122.1-122.35 + ;; 4-runtime.watsup:134.1-134.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:125.1-125.78 +;; 4-runtime.watsup:137.1-137.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:134.1-134.52 + ;; 4-runtime.watsup:146.1-146.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:126.1-126.79 +;; 4-runtime.watsup:138.1-138.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:135.1-135.71 - def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] = v], f) + ;; 4-runtime.watsup:147.1-147.77 + def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:127.1-127.83 +;; 4-runtime.watsup:139.1-139.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:136.1-136.74 - def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]][i] = r], f) + ;; 4-runtime.watsup:148.1-148.79 + def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:128.1-128.80 +;; 4-runtime.watsup:140.1-140.85 def with_tableext : (state, tableidx, ref*) -> state - ;; 4-runtime.watsup:137.1-137.75 - def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] =.. r*{r}], f) + ;; 4-runtime.watsup:149.1-149.80 + def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst =.. r*{r}], f) -;; 4-runtime.watsup:129.1-129.90 +;; 4-runtime.watsup:141.1-141.95 def with_mem : (state, tableidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:138.1-138.77 - def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]][i : j] = b*{b}], f) + ;; 4-runtime.watsup:150.1-150.82 + def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:130.1-130.78 +;; 4-runtime.watsup:142.1-142.83 def with_memext : (state, tableidx, byte*) -> state - ;; 4-runtime.watsup:139.1-139.69 - def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] =.. b*{b}], f) + ;; 4-runtime.watsup:151.1-151.74 + def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst =.. b*{b}], f) -;; 4-runtime.watsup:131.1-131.77 +;; 4-runtime.watsup:143.1-143.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:140.1-140.67 - def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] = r*{r}], f) + ;; 4-runtime.watsup:152.1-152.72 + def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:132.1-132.77 +;; 4-runtime.watsup:144.1-144.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:141.1-141.67 - def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]] = b*{b}], f) + ;; 4-runtime.watsup:153.1-153.72 + def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:155.1-158.21 +;; 4-runtime.watsup:167.1-170.21 rec { -;; 4-runtime.watsup:155.1-158.21 +;; 4-runtime.watsup:167.1-170.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -4756,73 +4746,73 @@ relation Step_pure: `%*~>%*`(admininstr*, admininstr*) `%*~>%*`([CONST_admininstr(I32_numtype, i) BR_TABLE_admininstr(l*{l}, l')], [BR_admininstr(l')]) -- if (i >= |l*{l}|) - ;; 6-reduction.watsup:101.1-102.35 + ;; 6-reduction.watsup:102.1-103.35 rule frame-vals {f : frame, n : n, val^n : val^n}: `%*~>%*`([FRAME__admininstr(n, f, $admininstr_val(val)^n{val})], $admininstr_val(val)^n{val}) - ;; 6-reduction.watsup:104.1-105.55 + ;; 6-reduction.watsup:105.1-106.55 rule return-frame {f : frame, instr* : instr*, n : n, val^n : val^n, val'* : val*}: `%*~>%*`([FRAME__admininstr(n, f, $admininstr_val(val')*{val'} :: $admininstr_val(val)^n{val} :: [RETURN_admininstr] :: $admininstr_instr(instr)*{instr})], $admininstr_val(val)^n{val}) - ;; 6-reduction.watsup:107.1-108.60 + ;; 6-reduction.watsup:108.1-109.60 rule return-label {instr* : instr*, instr'* : instr*, k : nat, val* : val*}: `%*~>%*`([LABEL__admininstr(k, instr'*{instr'}, $admininstr_val(val)*{val} :: [RETURN_admininstr] :: $admininstr_instr(instr)*{instr})], $admininstr_val(val)*{val} :: [RETURN_admininstr]) - ;; 6-reduction.watsup:111.1-113.33 + ;; 6-reduction.watsup:112.1-114.33 rule unop-val {c : c_numtype, c_1 : c_numtype, nt : numtype, unop : unop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) UNOP_admininstr(nt, unop)], [CONST_admininstr(nt, c)]) -- if ($unop(unop, nt, c_1) = [c]) - ;; 6-reduction.watsup:115.1-117.39 + ;; 6-reduction.watsup:116.1-118.39 rule unop-trap {c_1 : c_numtype, nt : numtype, unop : unop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) UNOP_admininstr(nt, unop)], [TRAP_admininstr]) -- if ($unop(unop, nt, c_1) = []) - ;; 6-reduction.watsup:120.1-122.40 + ;; 6-reduction.watsup:121.1-123.40 rule binop-val {binop : binop_numtype, c : c_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) BINOP_admininstr(nt, binop)], [CONST_admininstr(nt, c)]) -- if ($binop(binop, nt, c_1, c_2) = [c]) - ;; 6-reduction.watsup:124.1-126.46 + ;; 6-reduction.watsup:125.1-127.46 rule binop-trap {binop : binop_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) BINOP_admininstr(nt, binop)], [TRAP_admininstr]) -- if ($binop(binop, nt, c_1, c_2) = []) - ;; 6-reduction.watsup:129.1-131.37 + ;; 6-reduction.watsup:130.1-132.37 rule testop {c : c_numtype, c_1 : c_numtype, nt : numtype, testop : testop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) TESTOP_admininstr(nt, testop)], [CONST_admininstr(I32_numtype, c)]) -- if (c = $testop(testop, nt, c_1)) - ;; 6-reduction.watsup:133.1-135.40 + ;; 6-reduction.watsup:134.1-136.40 rule relop {c : c_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype, relop : relop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) RELOP_admininstr(nt, relop)], [CONST_admininstr(I32_numtype, c)]) -- if (c = $relop(relop, nt, c_1, c_2)) - ;; 6-reduction.watsup:138.1-139.70 + ;; 6-reduction.watsup:139.1-140.70 rule extend {c : c_numtype, n : n, nt : numtype}: `%*~>%*`([CONST_admininstr(nt, c) EXTEND_admininstr(nt, n)], [CONST_admininstr(nt, $ext(n, !($size($valtype_numtype(nt))), S_sx, c))]) - ;; 6-reduction.watsup:142.1-144.48 + ;; 6-reduction.watsup:143.1-145.48 rule cvtop-val {c : c_numtype, c_1 : c_numtype, cvtop : cvtop, nt_1 : numtype, nt_2 : numtype, sx? : sx?}: `%*~>%*`([CONST_admininstr(nt_1, c_1) CVTOP_admininstr(nt_2, cvtop, nt_1, sx?{sx})], [CONST_admininstr(nt_2, c)]) -- if ($cvtop(nt_1, cvtop, nt_2, sx?{sx}, c_1) = [c]) - ;; 6-reduction.watsup:146.1-148.54 + ;; 6-reduction.watsup:147.1-149.54 rule cvtop-trap {c_1 : c_numtype, cvtop : cvtop, nt_1 : numtype, nt_2 : numtype, sx? : sx?}: `%*~>%*`([CONST_admininstr(nt_1, c_1) CVTOP_admininstr(nt_2, cvtop, nt_1, sx?{sx})], [TRAP_admininstr]) -- if ($cvtop(nt_1, cvtop, nt_2, sx?{sx}, c_1) = []) - ;; 6-reduction.watsup:155.1-157.28 + ;; 6-reduction.watsup:156.1-158.28 rule ref.is_null-true {rt : reftype, val : val}: `%*~>%*`([$admininstr_val(val) REF.IS_NULL_admininstr], [CONST_admininstr(I32_numtype, 1)]) -- if (val = REF.NULL_val(rt)) - ;; 6-reduction.watsup:159.1-161.15 + ;; 6-reduction.watsup:160.1-162.15 rule ref.is_null-false {val : val}: `%*~>%*`([$admininstr_val(val) REF.IS_NULL_admininstr], [CONST_admininstr(I32_numtype, 0)]) -- otherwise - ;; 6-reduction.watsup:170.1-171.47 + ;; 6-reduction.watsup:171.1-172.47 rule local.tee {val : val, x : idx}: `%*~>%*`([$admininstr_val(val) LOCAL.TEE_admininstr(x)], [$admininstr_val(val) $admininstr_val(val) LOCAL.SET_admininstr(x)]) @@ -4833,10 +4823,10 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [CALL_admininstr(x)]), [CALL_ADDR_admininstr($funcaddr(z)[x])]) ;; 6-reduction.watsup:85.1-89.17 - rule call_indirect-call {a : addr, ft : functype, ft' : functype, i : nat, instr* : instr*, m : moduleinst, t* : valtype*, x : idx, z : state}: + rule call_indirect-call {a : addr, ft : functype, ft' : functype, i : nat, instr* : instr*, t* : valtype*, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CALL_INDIRECT_admininstr(x, ft)]), [CALL_ADDR_admininstr(a)]) - -- if ($table(z, x)[i] = REF.FUNC_ADDR_ref(a)) - -- if ($funcinst(z)[a] = `%;%`(m, `FUNC%%*%`(ft', t*{t}, instr*{instr}))) + -- if ($table(z, x).ELEM_tableinst[i] = REF.FUNC_ADDR_ref(a)) + -- if ($funcinst(z)[a].CODE_funcinst = `FUNC%%*%`(ft', t*{t}, instr*{instr})) -- if (ft = ft') ;; 6-reduction.watsup:91.1-93.15 @@ -4844,170 +4834,171 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CALL_INDIRECT_admininstr(x, ft)]), [TRAP_admininstr]) -- otherwise - ;; 6-reduction.watsup:95.1-98.52 - rule call_addr {a : addr, f : frame, instr* : instr*, k : nat, m : moduleinst, n : n, t* : valtype*, t_1^k : valtype^k, t_2^n : valtype^n, val^k : val^k, z : state}: + ;; 6-reduction.watsup:95.1-99.52 + rule call_addr {a : addr, f : frame, func : func, instr* : instr*, k : nat, m : moduleinst, n : n, t* : valtype*, t_1^k : valtype^k, t_2^n : valtype^n, val^k : val^k, z : state}: `%~>%*`(`%;%*`(z, $admininstr_val(val)^k{val} :: [CALL_ADDR_admininstr(a)]), [FRAME__admininstr(n, f, [LABEL__admininstr(n, [], $admininstr_instr(instr)*{instr})])]) - -- if ($funcinst(z)[a] = `%;%`(m, `FUNC%%*%`(`%->%`(t_1^k{t_1}, t_2^n{t_2}), t*{t}, instr*{instr}))) + -- if ($funcinst(z)[a] = {MODULE m, CODE func}) + -- if (func = `FUNC%%*%`(`%->%`(t_1^k{t_1}, t_2^n{t_2}), t*{t}, instr*{instr})) -- if (f = {LOCAL val^k{val} :: !($default_(t))*{t}, MODULE m}) - ;; 6-reduction.watsup:151.1-152.53 + ;; 6-reduction.watsup:152.1-153.53 rule ref.func {x : idx, z : state}: `%~>%*`(`%;%*`(z, [REF.FUNC_admininstr(x)]), [REF.FUNC_ADDR_admininstr($funcaddr(z)[x])]) - ;; 6-reduction.watsup:164.1-165.37 + ;; 6-reduction.watsup:165.1-166.37 rule local.get {x : idx, z : state}: `%~>%*`(`%;%*`(z, [LOCAL.GET_admininstr(x)]), [$admininstr_val($local(z, x))]) - ;; 6-reduction.watsup:174.1-175.39 + ;; 6-reduction.watsup:175.1-176.45 rule global.get {x : idx, z : state}: - `%~>%*`(`%;%*`(z, [GLOBAL.GET_admininstr(x)]), [$admininstr_globalinst($global(z, x))]) + `%~>%*`(`%;%*`(z, [GLOBAL.GET_admininstr(x)]), [$admininstr_val($global(z, x).VALUE_globalinst)]) - ;; 6-reduction.watsup:181.1-183.28 + ;; 6-reduction.watsup:182.1-184.33 rule table.get-trap {i : nat, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [TRAP_admininstr]) - -- if (i >= |$table(z, x)|) + -- if (i >= |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:185.1-187.27 + ;; 6-reduction.watsup:186.1-188.32 rule table.get-val {i : nat, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [$admininstr_ref($table(z, x)[i])]) - -- if (i < |$table(z, x)|) + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [$admininstr_ref($table(z, x).ELEM_tableinst[i])]) + -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:198.1-200.27 + ;; 6-reduction.watsup:199.1-201.32 rule table.size {n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) - -- if (|$table(z, x)| = n) + -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:210.1-212.34 + ;; 6-reduction.watsup:211.1-213.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) - -- if ((i + n) > |$table(z, x)|) + -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:214.1-217.14 + ;; 6-reduction.watsup:215.1-218.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:219.1-223.15 + ;; 6-reduction.watsup:220.1-224.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:226.1-228.63 + ;; 6-reduction.watsup:227.1-229.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) - -- if (((i + n) > |$table(z, y)|) \/ ((j + n) > |$table(z, x)|)) + -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:230.1-233.14 + ;; 6-reduction.watsup:231.1-234.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:235.1-240.15 + ;; 6-reduction.watsup:236.1-241.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:242.1-246.15 + ;; 6-reduction.watsup:243.1-247.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:249.1-251.62 + ;; 6-reduction.watsup:250.1-252.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) - -- if (((i + n) > |$elem(z, y)|) \/ ((j + n) > |$table(z, x)|)) + -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:253.1-256.14 + ;; 6-reduction.watsup:254.1-257.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:258.1-262.15 + ;; 6-reduction.watsup:259.1-263.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y)[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y).ELEM_eleminst[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:269.1-271.48 + ;; 6-reduction.watsup:270.1-272.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) - -- if (((i + n_O) + (!($size($valtype_numtype(nt))) / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (!($size($valtype_numtype(nt))) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:273.1-275.66 + ;; 6-reduction.watsup:274.1-276.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) - -- if ($bytes_(!($size($valtype_numtype(nt))), c) = $mem(z, 0)[(i + n_O) : (!($size($valtype_numtype(nt))) / 8)]) + -- if ($bytes_(!($size($valtype_numtype(nt))), c) = $mem(z, 0).DATA_meminst[(i + n_O) : (!($size($valtype_numtype(nt))) / 8)]) - ;; 6-reduction.watsup:277.1-279.40 + ;; 6-reduction.watsup:278.1-280.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) - -- if (((i + n_O) + (n / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:281.1-283.50 + ;; 6-reduction.watsup:282.1-284.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, !($size($valtype_numtype(nt))), sx, c))]) - -- if ($bytes_(n, c) = $mem(z, 0)[(i + n_O) : (n / 8)]) + -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:303.1-305.39 + ;; 6-reduction.watsup:304.1-306.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) - -- if (((n * 64) * $Ki) = |$mem(z, 0)|) + -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:315.1-317.32 + ;; 6-reduction.watsup:316.1-318.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) - -- if ((i + n) > |$mem(z, 0)|) + -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:319.1-322.14 + ;; 6-reduction.watsup:320.1-323.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:324.1-328.15 + ;; 6-reduction.watsup:325.1-329.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:331.1-333.59 + ;; 6-reduction.watsup:332.1-334.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) - -- if (((i + n) > |$mem(z, 0)|) \/ ((j + n) > |$mem(z, 0)|)) + -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:335.1-338.14 + ;; 6-reduction.watsup:336.1-339.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:340.1-345.15 + ;; 6-reduction.watsup:341.1-346.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:347.1-351.15 + ;; 6-reduction.watsup:348.1-352.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:354.1-356.60 + ;; 6-reduction.watsup:355.1-357.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) - -- if (((i + n) > |$data(z, x)|) \/ ((j + n) > |$mem(z, 0)|)) + -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:358.1-361.14 + ;; 6-reduction.watsup:359.1-362.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:363.1-367.15 + ;; 6-reduction.watsup:364.1-368.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x)[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise ;; 6-reduction.watsup:3.1-3.63 @@ -5022,65 +5013,65 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, $admininstr_instr(instr)*{instr}), `%;%*`(z, $admininstr_instr(instr')*{instr'})) -- Step_read: `%~>%*`(`%;%*`(z, $admininstr_instr(instr)*{instr}), $admininstr_instr(instr')*{instr'}) - ;; 6-reduction.watsup:167.1-168.60 + ;; 6-reduction.watsup:168.1-169.60 rule local.set {val : val, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_val(val) LOCAL.SET_admininstr(x)]), `%;%*`($with_local(z, x, val), [])) - ;; 6-reduction.watsup:177.1-178.62 + ;; 6-reduction.watsup:178.1-179.62 rule global.set {val : val, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_val(val) GLOBAL.SET_admininstr(x)]), `%;%*`($with_global(z, x, val), [])) - ;; 6-reduction.watsup:189.1-191.28 + ;; 6-reduction.watsup:190.1-192.33 rule table.set-trap {i : nat, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`(z, [TRAP_admininstr])) - -- if (i >= |$table(z, x)|) + -- if (i >= |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:193.1-195.27 + ;; 6-reduction.watsup:194.1-196.32 rule table.set-val {i : nat, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) - -- if (i < |$table(z, x)|) + -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:203.1-204.102 + ;; 6-reduction.watsup:204.1-205.107 rule table.grow-succeed {n : n, ref : ref, x : idx, z : state}: - `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x)|)])) + `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - ;; 6-reduction.watsup:206.1-207.64 + ;; 6-reduction.watsup:207.1-208.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:265.1-266.59 + ;; 6-reduction.watsup:266.1-267.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:286.1-288.48 + ;; 6-reduction.watsup:287.1-289.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) - -- if (((i + n_O) + (!($size($valtype_numtype(nt))) / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (!($size($valtype_numtype(nt))) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:290.1-292.35 + ;; 6-reduction.watsup:291.1-293.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (!($size($valtype_numtype(nt))) / 8), b*{b}), [])) -- if (b*{b} = $bytes_(!($size($valtype_numtype(nt))), c)) - ;; 6-reduction.watsup:294.1-296.40 + ;; 6-reduction.watsup:295.1-297.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) - -- if (((i + n_O) + (n / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:298.1-300.50 + ;; 6-reduction.watsup:299.1-301.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if (b*{b} = $bytes_(n, $wrap_((!($size($valtype_numtype(nt))), n), c))) - ;; 6-reduction.watsup:308.1-309.117 + ;; 6-reduction.watsup:309.1-310.122 rule memory.grow-succeed {n : n, z : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0)| / (64 * $Ki)))])) + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - ;; 6-reduction.watsup:311.1-312.59 + ;; 6-reduction.watsup:312.1-313.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:370.1-371.59 + ;; 6-reduction.watsup:371.1-372.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) @@ -6140,43 +6131,43 @@ def default_ : valtype -> val? def default_(EXTERNREF_valtype) = ?(REF.NULL_val(EXTERNREF_reftype)) def {x : valtype} default_(x) = ?() -;; 4-runtime.watsup:61.1-61.71 -syntax exportinst = EXPORT(name, externval) +;; 4-runtime.watsup:71.1-73.22 +syntax exportinst = {NAME name, VALUE externval} -;; 4-runtime.watsup:71.1-78.25 +;; 4-runtime.watsup:83.1-90.25 syntax moduleinst = {FUNC funcaddr*, GLOBAL globaladdr*, TABLE tableaddr*, MEM memaddr*, ELEM elemaddr*, DATA dataaddr*, EXPORT exportinst*} -;; 4-runtime.watsup:55.1-55.66 -syntax funcinst = `%;%`(moduleinst, func) +;; 4-runtime.watsup:55.1-57.16 +syntax funcinst = {MODULE moduleinst, CODE func} -;; 4-runtime.watsup:56.1-56.53 -syntax globalinst = val +;; 4-runtime.watsup:58.1-60.16 +syntax globalinst = {TYPE globaltype, VALUE val} -;; 4-runtime.watsup:57.1-57.52 -syntax tableinst = ref* +;; 4-runtime.watsup:61.1-63.16 +syntax tableinst = {TYPE tabletype, ELEM ref*} -;; 4-runtime.watsup:58.1-58.52 -syntax meminst = byte* +;; 4-runtime.watsup:64.1-66.17 +syntax meminst = {TYPE memtype, DATA byte*} -;; 4-runtime.watsup:59.1-59.53 -syntax eleminst = ref* +;; 4-runtime.watsup:67.1-68.16 +syntax eleminst = {ELEM ref*} -;; 4-runtime.watsup:60.1-60.51 -syntax datainst = byte* +;; 4-runtime.watsup:69.1-70.17 +syntax datainst = {DATA byte*} -;; 4-runtime.watsup:63.1-69.21 +;; 4-runtime.watsup:75.1-81.21 syntax store = {FUNC funcinst*, GLOBAL globalinst*, TABLE tableinst*, MEM meminst*, ELEM eleminst*, DATA datainst*} -;; 4-runtime.watsup:80.1-82.24 +;; 4-runtime.watsup:92.1-94.24 syntax frame = {LOCAL val*, MODULE moduleinst} -;; 4-runtime.watsup:83.1-83.47 +;; 4-runtime.watsup:95.1-95.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:146.1-153.5 +;; 4-runtime.watsup:158.1-165.5 rec { -;; 4-runtime.watsup:146.1-153.5 +;; 4-runtime.watsup:158.1-165.5 syntax admininstr = | UNREACHABLE | NOP @@ -6230,12 +6221,6 @@ syntax admininstr = | TRAP } -def admininstr_globalinst : globalinst -> admininstr - def {x0 : numtype, x1 : c_numtype} admininstr_globalinst(CONST_val(x0, x1)) = CONST_admininstr(x0, x1) - def {x : reftype} admininstr_globalinst(REF.NULL_val(x)) = REF.NULL_admininstr(x) - def {x : funcaddr} admininstr_globalinst(REF.FUNC_ADDR_val(x)) = REF.FUNC_ADDR_admininstr(x) - def {x : hostaddr} admininstr_globalinst(REF.HOST_ADDR_val(x)) = REF.HOST_ADDR_admininstr(x) - def admininstr_instr : instr -> admininstr def admininstr_instr(UNREACHABLE_instr) = UNREACHABLE_admininstr def admininstr_instr(NOP_instr) = NOP_admininstr @@ -6293,98 +6278,98 @@ def admininstr_val : val -> admininstr def {x : funcaddr} admininstr_val(REF.FUNC_ADDR_val(x)) = REF.FUNC_ADDR_admininstr(x) def {x : hostaddr} admininstr_val(REF.HOST_ADDR_val(x)) = REF.HOST_ADDR_admininstr(x) -;; 4-runtime.watsup:84.1-84.62 +;; 4-runtime.watsup:96.1-96.62 syntax config = `%;%*`(state, admininstr*) -;; 4-runtime.watsup:102.1-102.59 +;; 4-runtime.watsup:114.1-114.59 def funcaddr : state -> funcaddr* - ;; 4-runtime.watsup:103.1-103.38 + ;; 4-runtime.watsup:115.1-115.38 def {f : frame, s : store} funcaddr(`%;%`(s, f)) = f.MODULE_frame.FUNC_moduleinst -;; 4-runtime.watsup:105.1-105.52 +;; 4-runtime.watsup:117.1-117.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:106.1-106.31 + ;; 4-runtime.watsup:118.1-118.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:108.1-108.67 +;; 4-runtime.watsup:120.1-120.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:116.1-116.48 + ;; 4-runtime.watsup:128.1-128.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:109.1-109.69 +;; 4-runtime.watsup:121.1-121.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:117.1-117.54 + ;; 4-runtime.watsup:129.1-129.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:110.1-110.68 +;; 4-runtime.watsup:122.1-122.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:118.1-118.51 + ;; 4-runtime.watsup:130.1-130.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:111.1-111.66 +;; 4-runtime.watsup:123.1-123.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:119.1-119.45 + ;; 4-runtime.watsup:131.1-131.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:112.1-112.67 +;; 4-runtime.watsup:124.1-124.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:120.1-120.48 + ;; 4-runtime.watsup:132.1-132.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:113.1-113.67 +;; 4-runtime.watsup:125.1-125.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:121.1-121.48 + ;; 4-runtime.watsup:133.1-133.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:114.1-114.68 +;; 4-runtime.watsup:126.1-126.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:122.1-122.35 + ;; 4-runtime.watsup:134.1-134.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:125.1-125.78 +;; 4-runtime.watsup:137.1-137.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:134.1-134.52 + ;; 4-runtime.watsup:146.1-146.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:126.1-126.79 +;; 4-runtime.watsup:138.1-138.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:135.1-135.71 - def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] = v], f) + ;; 4-runtime.watsup:147.1-147.77 + def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:127.1-127.83 +;; 4-runtime.watsup:139.1-139.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:136.1-136.74 - def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]][i] = r], f) + ;; 4-runtime.watsup:148.1-148.79 + def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:128.1-128.80 +;; 4-runtime.watsup:140.1-140.85 def with_tableext : (state, tableidx, ref*) -> state - ;; 4-runtime.watsup:137.1-137.75 - def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] =.. r*{r}], f) + ;; 4-runtime.watsup:149.1-149.80 + def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst =.. r*{r}], f) -;; 4-runtime.watsup:129.1-129.90 +;; 4-runtime.watsup:141.1-141.95 def with_mem : (state, tableidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:138.1-138.77 - def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]][i : j] = b*{b}], f) + ;; 4-runtime.watsup:150.1-150.82 + def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:130.1-130.78 +;; 4-runtime.watsup:142.1-142.83 def with_memext : (state, tableidx, byte*) -> state - ;; 4-runtime.watsup:139.1-139.69 - def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] =.. b*{b}], f) + ;; 4-runtime.watsup:151.1-151.74 + def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst =.. b*{b}], f) -;; 4-runtime.watsup:131.1-131.77 +;; 4-runtime.watsup:143.1-143.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:140.1-140.67 - def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] = r*{r}], f) + ;; 4-runtime.watsup:152.1-152.72 + def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:132.1-132.77 +;; 4-runtime.watsup:144.1-144.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:141.1-141.67 - def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]] = b*{b}], f) + ;; 4-runtime.watsup:153.1-153.72 + def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:155.1-158.21 +;; 4-runtime.watsup:167.1-170.21 rec { -;; 4-runtime.watsup:155.1-158.21 +;; 4-runtime.watsup:167.1-170.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -6491,74 +6476,74 @@ relation Step_pure: `%*~>%*`(admininstr*, admininstr*) `%*~>%*`([CONST_admininstr(I32_numtype, i) BR_TABLE_admininstr(l*{l}, l')], [BR_admininstr(l')]) -- if (i >= |l*{l}|) - ;; 6-reduction.watsup:101.1-102.35 + ;; 6-reduction.watsup:102.1-103.35 rule frame-vals {f : frame, n : n, val^n : val^n}: `%*~>%*`([FRAME__admininstr(n, f, $admininstr_val(val)^n{val})], $admininstr_val(val)^n{val}) - ;; 6-reduction.watsup:104.1-105.55 + ;; 6-reduction.watsup:105.1-106.55 rule return-frame {f : frame, instr* : instr*, n : n, val^n : val^n, val'* : val*}: `%*~>%*`([FRAME__admininstr(n, f, $admininstr_val(val')*{val'} :: $admininstr_val(val)^n{val} :: [RETURN_admininstr] :: $admininstr_instr(instr)*{instr})], $admininstr_val(val)^n{val}) - ;; 6-reduction.watsup:107.1-108.60 + ;; 6-reduction.watsup:108.1-109.60 rule return-label {instr* : instr*, instr'* : instr*, k : nat, val* : val*}: `%*~>%*`([LABEL__admininstr(k, instr'*{instr'}, $admininstr_val(val)*{val} :: [RETURN_admininstr] :: $admininstr_instr(instr)*{instr})], $admininstr_val(val)*{val} :: [RETURN_admininstr]) - ;; 6-reduction.watsup:111.1-113.33 + ;; 6-reduction.watsup:112.1-114.33 rule unop-val {c : c_numtype, c_1 : c_numtype, nt : numtype, unop : unop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) UNOP_admininstr(nt, unop)], [CONST_admininstr(nt, c)]) -- if ($unop(unop, nt, c_1) = [c]) - ;; 6-reduction.watsup:115.1-117.39 + ;; 6-reduction.watsup:116.1-118.39 rule unop-trap {c_1 : c_numtype, nt : numtype, unop : unop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) UNOP_admininstr(nt, unop)], [TRAP_admininstr]) -- if ($unop(unop, nt, c_1) = []) - ;; 6-reduction.watsup:120.1-122.40 + ;; 6-reduction.watsup:121.1-123.40 rule binop-val {binop : binop_numtype, c : c_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) BINOP_admininstr(nt, binop)], [CONST_admininstr(nt, c)]) -- if ($binop(binop, nt, c_1, c_2) = [c]) - ;; 6-reduction.watsup:124.1-126.46 + ;; 6-reduction.watsup:125.1-127.46 rule binop-trap {binop : binop_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) BINOP_admininstr(nt, binop)], [TRAP_admininstr]) -- if ($binop(binop, nt, c_1, c_2) = []) - ;; 6-reduction.watsup:129.1-131.37 + ;; 6-reduction.watsup:130.1-132.37 rule testop {c : c_numtype, c_1 : c_numtype, nt : numtype, testop : testop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) TESTOP_admininstr(nt, testop)], [CONST_admininstr(I32_numtype, c)]) -- if (c = $testop(testop, nt, c_1)) - ;; 6-reduction.watsup:133.1-135.40 + ;; 6-reduction.watsup:134.1-136.40 rule relop {c : c_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype, relop : relop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) RELOP_admininstr(nt, relop)], [CONST_admininstr(I32_numtype, c)]) -- if (c = $relop(relop, nt, c_1, c_2)) - ;; 6-reduction.watsup:138.1-139.70 + ;; 6-reduction.watsup:139.1-140.70 rule extend {c : c_numtype, n : n, nt : numtype, o0 : nat}: `%*~>%*`([CONST_admininstr(nt, c) EXTEND_admininstr(nt, n)], [CONST_admininstr(nt, $ext(n, o0, S_sx, c))]) -- if ($size($valtype_numtype(nt)) = ?(o0)) - ;; 6-reduction.watsup:142.1-144.48 + ;; 6-reduction.watsup:143.1-145.48 rule cvtop-val {c : c_numtype, c_1 : c_numtype, cvtop : cvtop, nt_1 : numtype, nt_2 : numtype, sx? : sx?}: `%*~>%*`([CONST_admininstr(nt_1, c_1) CVTOP_admininstr(nt_2, cvtop, nt_1, sx?{sx})], [CONST_admininstr(nt_2, c)]) -- if ($cvtop(nt_1, cvtop, nt_2, sx?{sx}, c_1) = [c]) - ;; 6-reduction.watsup:146.1-148.54 + ;; 6-reduction.watsup:147.1-149.54 rule cvtop-trap {c_1 : c_numtype, cvtop : cvtop, nt_1 : numtype, nt_2 : numtype, sx? : sx?}: `%*~>%*`([CONST_admininstr(nt_1, c_1) CVTOP_admininstr(nt_2, cvtop, nt_1, sx?{sx})], [TRAP_admininstr]) -- if ($cvtop(nt_1, cvtop, nt_2, sx?{sx}, c_1) = []) - ;; 6-reduction.watsup:155.1-157.28 + ;; 6-reduction.watsup:156.1-158.28 rule ref.is_null-true {rt : reftype, val : val}: `%*~>%*`([$admininstr_val(val) REF.IS_NULL_admininstr], [CONST_admininstr(I32_numtype, 1)]) -- if (val = REF.NULL_val(rt)) - ;; 6-reduction.watsup:159.1-161.15 + ;; 6-reduction.watsup:160.1-162.15 rule ref.is_null-false {val : val}: `%*~>%*`([$admininstr_val(val) REF.IS_NULL_admininstr], [CONST_admininstr(I32_numtype, 0)]) -- otherwise - ;; 6-reduction.watsup:170.1-171.47 + ;; 6-reduction.watsup:171.1-172.47 rule local.tee {val : val, x : idx}: `%*~>%*`([$admininstr_val(val) LOCAL.TEE_admininstr(x)], [$admininstr_val(val) $admininstr_val(val) LOCAL.SET_admininstr(x)]) @@ -6569,10 +6554,10 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [CALL_admininstr(x)]), [CALL_ADDR_admininstr($funcaddr(z)[x])]) ;; 6-reduction.watsup:85.1-89.17 - rule call_indirect-call {a : addr, ft : functype, ft' : functype, i : nat, instr* : instr*, m : moduleinst, t* : valtype*, x : idx, z : state}: + rule call_indirect-call {a : addr, ft : functype, ft' : functype, i : nat, instr* : instr*, t* : valtype*, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CALL_INDIRECT_admininstr(x, ft)]), [CALL_ADDR_admininstr(a)]) - -- if ($table(z, x)[i] = REF.FUNC_ADDR_ref(a)) - -- if ($funcinst(z)[a] = `%;%`(m, `FUNC%%*%`(ft', t*{t}, instr*{instr}))) + -- if ($table(z, x).ELEM_tableinst[i] = REF.FUNC_ADDR_ref(a)) + -- if ($funcinst(z)[a].CODE_funcinst = `FUNC%%*%`(ft', t*{t}, instr*{instr})) -- if (ft = ft') ;; 6-reduction.watsup:91.1-93.15 @@ -6580,175 +6565,176 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CALL_INDIRECT_admininstr(x, ft)]), [TRAP_admininstr]) -- otherwise - ;; 6-reduction.watsup:95.1-98.52 - rule call_addr {a : addr, f : frame, instr* : instr*, k : nat, m : moduleinst, n : n, t* : valtype*, t_1^k : valtype^k, t_2^n : valtype^n, val^k : val^k, z : state, o0* : val*}: + ;; 6-reduction.watsup:95.1-99.52 + rule call_addr {a : addr, f : frame, func : func, instr* : instr*, k : nat, m : moduleinst, n : n, t* : valtype*, t_1^k : valtype^k, t_2^n : valtype^n, val^k : val^k, z : state, o0* : val*}: `%~>%*`(`%;%*`(z, $admininstr_val(val)^k{val} :: [CALL_ADDR_admininstr(a)]), [FRAME__admininstr(n, f, [LABEL__admininstr(n, [], $admininstr_instr(instr)*{instr})])]) -- (if ($default_(t) = ?(o0)))*{t o0} - -- if ($funcinst(z)[a] = `%;%`(m, `FUNC%%*%`(`%->%`(t_1^k{t_1}, t_2^n{t_2}), t*{t}, instr*{instr}))) + -- if ($funcinst(z)[a] = {MODULE m, CODE func}) + -- if (func = `FUNC%%*%`(`%->%`(t_1^k{t_1}, t_2^n{t_2}), t*{t}, instr*{instr})) -- if (f = {LOCAL val^k{val} :: o0*{o0}, MODULE m}) - ;; 6-reduction.watsup:151.1-152.53 + ;; 6-reduction.watsup:152.1-153.53 rule ref.func {x : idx, z : state}: `%~>%*`(`%;%*`(z, [REF.FUNC_admininstr(x)]), [REF.FUNC_ADDR_admininstr($funcaddr(z)[x])]) - ;; 6-reduction.watsup:164.1-165.37 + ;; 6-reduction.watsup:165.1-166.37 rule local.get {x : idx, z : state}: `%~>%*`(`%;%*`(z, [LOCAL.GET_admininstr(x)]), [$admininstr_val($local(z, x))]) - ;; 6-reduction.watsup:174.1-175.39 + ;; 6-reduction.watsup:175.1-176.45 rule global.get {x : idx, z : state}: - `%~>%*`(`%;%*`(z, [GLOBAL.GET_admininstr(x)]), [$admininstr_globalinst($global(z, x))]) + `%~>%*`(`%;%*`(z, [GLOBAL.GET_admininstr(x)]), [$admininstr_val($global(z, x).VALUE_globalinst)]) - ;; 6-reduction.watsup:181.1-183.28 + ;; 6-reduction.watsup:182.1-184.33 rule table.get-trap {i : nat, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [TRAP_admininstr]) - -- if (i >= |$table(z, x)|) + -- if (i >= |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:185.1-187.27 + ;; 6-reduction.watsup:186.1-188.32 rule table.get-val {i : nat, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [$admininstr_ref($table(z, x)[i])]) - -- if (i < |$table(z, x)|) + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [$admininstr_ref($table(z, x).ELEM_tableinst[i])]) + -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:198.1-200.27 + ;; 6-reduction.watsup:199.1-201.32 rule table.size {n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) - -- if (|$table(z, x)| = n) + -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:210.1-212.34 + ;; 6-reduction.watsup:211.1-213.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) - -- if ((i + n) > |$table(z, x)|) + -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:214.1-217.14 + ;; 6-reduction.watsup:215.1-218.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:219.1-223.15 + ;; 6-reduction.watsup:220.1-224.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:226.1-228.63 + ;; 6-reduction.watsup:227.1-229.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) - -- if (((i + n) > |$table(z, y)|) \/ ((j + n) > |$table(z, x)|)) + -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:230.1-233.14 + ;; 6-reduction.watsup:231.1-234.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:235.1-240.15 + ;; 6-reduction.watsup:236.1-241.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:242.1-246.15 + ;; 6-reduction.watsup:243.1-247.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:249.1-251.62 + ;; 6-reduction.watsup:250.1-252.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) - -- if (((i + n) > |$elem(z, y)|) \/ ((j + n) > |$table(z, x)|)) + -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:253.1-256.14 + ;; 6-reduction.watsup:254.1-257.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:258.1-262.15 + ;; 6-reduction.watsup:259.1-263.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y)[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y).ELEM_eleminst[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:269.1-271.48 + ;; 6-reduction.watsup:270.1-272.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- if ($size($valtype_numtype(nt)) = ?(o0)) - -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:273.1-275.66 + ;; 6-reduction.watsup:274.1-276.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($size($valtype_numtype(nt)) = ?(o1)) - -- if ($bytes_(o0, c) = $mem(z, 0)[(i + n_O) : (o1 / 8)]) + -- if ($bytes_(o0, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (o1 / 8)]) - ;; 6-reduction.watsup:277.1-279.40 + ;; 6-reduction.watsup:278.1-280.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) - -- if (((i + n_O) + (n / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:281.1-283.50 + ;; 6-reduction.watsup:282.1-284.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, o0, sx, c))]) -- if ($size($valtype_numtype(nt)) = ?(o0)) - -- if ($bytes_(n, c) = $mem(z, 0)[(i + n_O) : (n / 8)]) + -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:303.1-305.39 + ;; 6-reduction.watsup:304.1-306.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) - -- if (((n * 64) * $Ki) = |$mem(z, 0)|) + -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:315.1-317.32 + ;; 6-reduction.watsup:316.1-318.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) - -- if ((i + n) > |$mem(z, 0)|) + -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:319.1-322.14 + ;; 6-reduction.watsup:320.1-323.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:324.1-328.15 + ;; 6-reduction.watsup:325.1-329.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:331.1-333.59 + ;; 6-reduction.watsup:332.1-334.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) - -- if (((i + n) > |$mem(z, 0)|) \/ ((j + n) > |$mem(z, 0)|)) + -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:335.1-338.14 + ;; 6-reduction.watsup:336.1-339.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:340.1-345.15 + ;; 6-reduction.watsup:341.1-346.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:347.1-351.15 + ;; 6-reduction.watsup:348.1-352.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:354.1-356.60 + ;; 6-reduction.watsup:355.1-357.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) - -- if (((i + n) > |$data(z, x)|) \/ ((j + n) > |$mem(z, 0)|)) + -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:358.1-361.14 + ;; 6-reduction.watsup:359.1-362.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:363.1-367.15 + ;; 6-reduction.watsup:364.1-368.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x)[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise ;; 6-reduction.watsup:3.1-3.63 @@ -6763,69 +6749,69 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, $admininstr_instr(instr)*{instr}), `%;%*`(z, $admininstr_instr(instr')*{instr'})) -- Step_read: `%~>%*`(`%;%*`(z, $admininstr_instr(instr)*{instr}), $admininstr_instr(instr')*{instr'}) - ;; 6-reduction.watsup:167.1-168.60 + ;; 6-reduction.watsup:168.1-169.60 rule local.set {val : val, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_val(val) LOCAL.SET_admininstr(x)]), `%;%*`($with_local(z, x, val), [])) - ;; 6-reduction.watsup:177.1-178.62 + ;; 6-reduction.watsup:178.1-179.62 rule global.set {val : val, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_val(val) GLOBAL.SET_admininstr(x)]), `%;%*`($with_global(z, x, val), [])) - ;; 6-reduction.watsup:189.1-191.28 + ;; 6-reduction.watsup:190.1-192.33 rule table.set-trap {i : nat, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`(z, [TRAP_admininstr])) - -- if (i >= |$table(z, x)|) + -- if (i >= |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:193.1-195.27 + ;; 6-reduction.watsup:194.1-196.32 rule table.set-val {i : nat, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) - -- if (i < |$table(z, x)|) + -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:203.1-204.102 + ;; 6-reduction.watsup:204.1-205.107 rule table.grow-succeed {n : n, ref : ref, x : idx, z : state}: - `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x)|)])) + `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - ;; 6-reduction.watsup:206.1-207.64 + ;; 6-reduction.watsup:207.1-208.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:265.1-266.59 + ;; 6-reduction.watsup:266.1-267.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:286.1-288.48 + ;; 6-reduction.watsup:287.1-289.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if ($size($valtype_numtype(nt)) = ?(o0)) - -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:290.1-292.35 + ;; 6-reduction.watsup:291.1-293.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (o0 / 8), b*{b}), [])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($size($valtype_numtype(nt)) = ?(o1)) -- if (b*{b} = $bytes_(o1, c)) - ;; 6-reduction.watsup:294.1-296.40 + ;; 6-reduction.watsup:295.1-297.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) - -- if (((i + n_O) + (n / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:298.1-300.50 + ;; 6-reduction.watsup:299.1-301.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (b*{b} = $bytes_(n, $wrap_((o0, n), c))) - ;; 6-reduction.watsup:308.1-309.117 + ;; 6-reduction.watsup:309.1-310.122 rule memory.grow-succeed {n : n, z : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0)| / (64 * $Ki)))])) + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - ;; 6-reduction.watsup:311.1-312.59 + ;; 6-reduction.watsup:312.1-313.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:370.1-371.59 + ;; 6-reduction.watsup:371.1-372.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) @@ -7885,43 +7871,43 @@ def default_ : valtype -> val? def default_(EXTERNREF_valtype) = ?(REF.NULL_val(EXTERNREF_reftype)) def {x : valtype} default_(x) = ?() -;; 4-runtime.watsup:61.1-61.71 -syntax exportinst = EXPORT(name, externval) +;; 4-runtime.watsup:71.1-73.22 +syntax exportinst = {NAME name, VALUE externval} -;; 4-runtime.watsup:71.1-78.25 +;; 4-runtime.watsup:83.1-90.25 syntax moduleinst = {FUNC funcaddr*, GLOBAL globaladdr*, TABLE tableaddr*, MEM memaddr*, ELEM elemaddr*, DATA dataaddr*, EXPORT exportinst*} -;; 4-runtime.watsup:55.1-55.66 -syntax funcinst = `%;%`(moduleinst, func) +;; 4-runtime.watsup:55.1-57.16 +syntax funcinst = {MODULE moduleinst, CODE func} -;; 4-runtime.watsup:56.1-56.53 -syntax globalinst = val +;; 4-runtime.watsup:58.1-60.16 +syntax globalinst = {TYPE globaltype, VALUE val} -;; 4-runtime.watsup:57.1-57.52 -syntax tableinst = ref* +;; 4-runtime.watsup:61.1-63.16 +syntax tableinst = {TYPE tabletype, ELEM ref*} -;; 4-runtime.watsup:58.1-58.52 -syntax meminst = byte* +;; 4-runtime.watsup:64.1-66.17 +syntax meminst = {TYPE memtype, DATA byte*} -;; 4-runtime.watsup:59.1-59.53 -syntax eleminst = ref* +;; 4-runtime.watsup:67.1-68.16 +syntax eleminst = {ELEM ref*} -;; 4-runtime.watsup:60.1-60.51 -syntax datainst = byte* +;; 4-runtime.watsup:69.1-70.17 +syntax datainst = {DATA byte*} -;; 4-runtime.watsup:63.1-69.21 +;; 4-runtime.watsup:75.1-81.21 syntax store = {FUNC funcinst*, GLOBAL globalinst*, TABLE tableinst*, MEM meminst*, ELEM eleminst*, DATA datainst*} -;; 4-runtime.watsup:80.1-82.24 +;; 4-runtime.watsup:92.1-94.24 syntax frame = {LOCAL val*, MODULE moduleinst} -;; 4-runtime.watsup:83.1-83.47 +;; 4-runtime.watsup:95.1-95.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:146.1-153.5 +;; 4-runtime.watsup:158.1-165.5 rec { -;; 4-runtime.watsup:146.1-153.5 +;; 4-runtime.watsup:158.1-165.5 syntax admininstr = | UNREACHABLE | NOP @@ -7975,12 +7961,6 @@ syntax admininstr = | TRAP } -def admininstr_globalinst : globalinst -> admininstr - def {x0 : numtype, x1 : c_numtype} admininstr_globalinst(CONST_val(x0, x1)) = CONST_admininstr(x0, x1) - def {x : reftype} admininstr_globalinst(REF.NULL_val(x)) = REF.NULL_admininstr(x) - def {x : funcaddr} admininstr_globalinst(REF.FUNC_ADDR_val(x)) = REF.FUNC_ADDR_admininstr(x) - def {x : hostaddr} admininstr_globalinst(REF.HOST_ADDR_val(x)) = REF.HOST_ADDR_admininstr(x) - def admininstr_instr : instr -> admininstr def admininstr_instr(UNREACHABLE_instr) = UNREACHABLE_admininstr def admininstr_instr(NOP_instr) = NOP_admininstr @@ -8038,98 +8018,98 @@ def admininstr_val : val -> admininstr def {x : funcaddr} admininstr_val(REF.FUNC_ADDR_val(x)) = REF.FUNC_ADDR_admininstr(x) def {x : hostaddr} admininstr_val(REF.HOST_ADDR_val(x)) = REF.HOST_ADDR_admininstr(x) -;; 4-runtime.watsup:84.1-84.62 +;; 4-runtime.watsup:96.1-96.62 syntax config = `%;%*`(state, admininstr*) -;; 4-runtime.watsup:102.1-102.59 +;; 4-runtime.watsup:114.1-114.59 def funcaddr : state -> funcaddr* - ;; 4-runtime.watsup:103.1-103.38 + ;; 4-runtime.watsup:115.1-115.38 def {f : frame, s : store} funcaddr(`%;%`(s, f)) = f.MODULE_frame.FUNC_moduleinst -;; 4-runtime.watsup:105.1-105.52 +;; 4-runtime.watsup:117.1-117.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:106.1-106.31 + ;; 4-runtime.watsup:118.1-118.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:108.1-108.67 +;; 4-runtime.watsup:120.1-120.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:116.1-116.48 + ;; 4-runtime.watsup:128.1-128.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:109.1-109.69 +;; 4-runtime.watsup:121.1-121.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:117.1-117.54 + ;; 4-runtime.watsup:129.1-129.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:110.1-110.68 +;; 4-runtime.watsup:122.1-122.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:118.1-118.51 + ;; 4-runtime.watsup:130.1-130.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:111.1-111.66 +;; 4-runtime.watsup:123.1-123.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:119.1-119.45 + ;; 4-runtime.watsup:131.1-131.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:112.1-112.67 +;; 4-runtime.watsup:124.1-124.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:120.1-120.48 + ;; 4-runtime.watsup:132.1-132.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:113.1-113.67 +;; 4-runtime.watsup:125.1-125.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:121.1-121.48 + ;; 4-runtime.watsup:133.1-133.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:114.1-114.68 +;; 4-runtime.watsup:126.1-126.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:122.1-122.35 + ;; 4-runtime.watsup:134.1-134.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:125.1-125.78 +;; 4-runtime.watsup:137.1-137.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:134.1-134.52 + ;; 4-runtime.watsup:146.1-146.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:126.1-126.79 +;; 4-runtime.watsup:138.1-138.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:135.1-135.71 - def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] = v], f) + ;; 4-runtime.watsup:147.1-147.77 + def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:127.1-127.83 +;; 4-runtime.watsup:139.1-139.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:136.1-136.74 - def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]][i] = r], f) + ;; 4-runtime.watsup:148.1-148.79 + def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:128.1-128.80 +;; 4-runtime.watsup:140.1-140.85 def with_tableext : (state, tableidx, ref*) -> state - ;; 4-runtime.watsup:137.1-137.75 - def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] =.. r*{r}], f) + ;; 4-runtime.watsup:149.1-149.80 + def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst =.. r*{r}], f) -;; 4-runtime.watsup:129.1-129.90 +;; 4-runtime.watsup:141.1-141.95 def with_mem : (state, tableidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:138.1-138.77 - def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]][i : j] = b*{b}], f) + ;; 4-runtime.watsup:150.1-150.82 + def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:130.1-130.78 +;; 4-runtime.watsup:142.1-142.83 def with_memext : (state, tableidx, byte*) -> state - ;; 4-runtime.watsup:139.1-139.69 - def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] =.. b*{b}], f) + ;; 4-runtime.watsup:151.1-151.74 + def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst =.. b*{b}], f) -;; 4-runtime.watsup:131.1-131.77 +;; 4-runtime.watsup:143.1-143.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:140.1-140.67 - def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] = r*{r}], f) + ;; 4-runtime.watsup:152.1-152.72 + def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:132.1-132.77 +;; 4-runtime.watsup:144.1-144.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:141.1-141.67 - def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]] = b*{b}], f) + ;; 4-runtime.watsup:153.1-153.72 + def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:155.1-158.21 +;; 4-runtime.watsup:167.1-170.21 rec { -;; 4-runtime.watsup:155.1-158.21 +;; 4-runtime.watsup:167.1-170.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -8236,74 +8216,74 @@ relation Step_pure: `%*~>%*`(admininstr*, admininstr*) `%*~>%*`([CONST_admininstr(I32_numtype, i) BR_TABLE_admininstr(l*{l}, l')], [BR_admininstr(l')]) -- if (i >= |l*{l}|) - ;; 6-reduction.watsup:101.1-102.35 + ;; 6-reduction.watsup:102.1-103.35 rule frame-vals {f : frame, n : n, val^n : val^n}: `%*~>%*`([FRAME__admininstr(n, f, $admininstr_val(val)^n{val})], $admininstr_val(val)^n{val}) - ;; 6-reduction.watsup:104.1-105.55 + ;; 6-reduction.watsup:105.1-106.55 rule return-frame {f : frame, instr* : instr*, n : n, val^n : val^n, val'* : val*}: `%*~>%*`([FRAME__admininstr(n, f, $admininstr_val(val')*{val'} :: $admininstr_val(val)^n{val} :: [RETURN_admininstr] :: $admininstr_instr(instr)*{instr})], $admininstr_val(val)^n{val}) - ;; 6-reduction.watsup:107.1-108.60 + ;; 6-reduction.watsup:108.1-109.60 rule return-label {instr* : instr*, instr'* : instr*, k : nat, val* : val*}: `%*~>%*`([LABEL__admininstr(k, instr'*{instr'}, $admininstr_val(val)*{val} :: [RETURN_admininstr] :: $admininstr_instr(instr)*{instr})], $admininstr_val(val)*{val} :: [RETURN_admininstr]) - ;; 6-reduction.watsup:111.1-113.33 + ;; 6-reduction.watsup:112.1-114.33 rule unop-val {c : c_numtype, c_1 : c_numtype, nt : numtype, unop : unop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) UNOP_admininstr(nt, unop)], [CONST_admininstr(nt, c)]) -- if ($unop(unop, nt, c_1) = [c]) - ;; 6-reduction.watsup:115.1-117.39 + ;; 6-reduction.watsup:116.1-118.39 rule unop-trap {c_1 : c_numtype, nt : numtype, unop : unop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) UNOP_admininstr(nt, unop)], [TRAP_admininstr]) -- if ($unop(unop, nt, c_1) = []) - ;; 6-reduction.watsup:120.1-122.40 + ;; 6-reduction.watsup:121.1-123.40 rule binop-val {binop : binop_numtype, c : c_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) BINOP_admininstr(nt, binop)], [CONST_admininstr(nt, c)]) -- if ($binop(binop, nt, c_1, c_2) = [c]) - ;; 6-reduction.watsup:124.1-126.46 + ;; 6-reduction.watsup:125.1-127.46 rule binop-trap {binop : binop_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) BINOP_admininstr(nt, binop)], [TRAP_admininstr]) -- if ($binop(binop, nt, c_1, c_2) = []) - ;; 6-reduction.watsup:129.1-131.37 + ;; 6-reduction.watsup:130.1-132.37 rule testop {c : c_numtype, c_1 : c_numtype, nt : numtype, testop : testop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) TESTOP_admininstr(nt, testop)], [CONST_admininstr(I32_numtype, c)]) -- if (c = $testop(testop, nt, c_1)) - ;; 6-reduction.watsup:133.1-135.40 + ;; 6-reduction.watsup:134.1-136.40 rule relop {c : c_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype, relop : relop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) RELOP_admininstr(nt, relop)], [CONST_admininstr(I32_numtype, c)]) -- if (c = $relop(relop, nt, c_1, c_2)) - ;; 6-reduction.watsup:138.1-139.70 + ;; 6-reduction.watsup:139.1-140.70 rule extend {c : c_numtype, n : n, nt : numtype, o0 : nat}: `%*~>%*`([CONST_admininstr(nt, c) EXTEND_admininstr(nt, n)], [CONST_admininstr(nt, $ext(n, o0, S_sx, c))]) -- if ($size($valtype_numtype(nt)) = ?(o0)) - ;; 6-reduction.watsup:142.1-144.48 + ;; 6-reduction.watsup:143.1-145.48 rule cvtop-val {c : c_numtype, c_1 : c_numtype, cvtop : cvtop, nt_1 : numtype, nt_2 : numtype, sx? : sx?}: `%*~>%*`([CONST_admininstr(nt_1, c_1) CVTOP_admininstr(nt_2, cvtop, nt_1, sx?{sx})], [CONST_admininstr(nt_2, c)]) -- if ($cvtop(nt_1, cvtop, nt_2, sx?{sx}, c_1) = [c]) - ;; 6-reduction.watsup:146.1-148.54 + ;; 6-reduction.watsup:147.1-149.54 rule cvtop-trap {c_1 : c_numtype, cvtop : cvtop, nt_1 : numtype, nt_2 : numtype, sx? : sx?}: `%*~>%*`([CONST_admininstr(nt_1, c_1) CVTOP_admininstr(nt_2, cvtop, nt_1, sx?{sx})], [TRAP_admininstr]) -- if ($cvtop(nt_1, cvtop, nt_2, sx?{sx}, c_1) = []) - ;; 6-reduction.watsup:155.1-157.28 + ;; 6-reduction.watsup:156.1-158.28 rule ref.is_null-true {rt : reftype, val : val}: `%*~>%*`([$admininstr_val(val) REF.IS_NULL_admininstr], [CONST_admininstr(I32_numtype, 1)]) -- if (val = REF.NULL_val(rt)) - ;; 6-reduction.watsup:159.1-161.15 + ;; 6-reduction.watsup:160.1-162.15 rule ref.is_null-false {val : val}: `%*~>%*`([$admininstr_val(val) REF.IS_NULL_admininstr], [CONST_admininstr(I32_numtype, 0)]) -- otherwise - ;; 6-reduction.watsup:170.1-171.47 + ;; 6-reduction.watsup:171.1-172.47 rule local.tee {val : val, x : idx}: `%*~>%*`([$admininstr_val(val) LOCAL.TEE_admininstr(x)], [$admininstr_val(val) $admininstr_val(val) LOCAL.SET_admininstr(x)]) @@ -8314,10 +8294,10 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [CALL_admininstr(x)]), [CALL_ADDR_admininstr($funcaddr(z)[x])]) ;; 6-reduction.watsup:85.1-89.17 - rule call_indirect-call {a : addr, ft : functype, ft' : functype, i : nat, instr* : instr*, m : moduleinst, t* : valtype*, x : idx, z : state}: + rule call_indirect-call {a : addr, ft : functype, ft' : functype, i : nat, instr* : instr*, t* : valtype*, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CALL_INDIRECT_admininstr(x, ft)]), [CALL_ADDR_admininstr(a)]) - -- if ($table(z, x)[i] = REF.FUNC_ADDR_ref(a)) - -- if ($funcinst(z)[a] = `%;%`(m, `FUNC%%*%`(ft', t*{t}, instr*{instr}))) + -- if ($table(z, x).ELEM_tableinst[i] = REF.FUNC_ADDR_ref(a)) + -- if ($funcinst(z)[a].CODE_funcinst = `FUNC%%*%`(ft', t*{t}, instr*{instr})) -- if (ft = ft') ;; 6-reduction.watsup:91.1-93.15 @@ -8325,175 +8305,176 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CALL_INDIRECT_admininstr(x, ft)]), [TRAP_admininstr]) -- otherwise - ;; 6-reduction.watsup:95.1-98.52 - rule call_addr {a : addr, f : frame, instr* : instr*, k : nat, m : moduleinst, n : n, t* : valtype*, t_1^k : valtype^k, t_2^n : valtype^n, val^k : val^k, z : state, o0* : val*}: + ;; 6-reduction.watsup:95.1-99.52 + rule call_addr {a : addr, f : frame, func : func, instr* : instr*, k : nat, m : moduleinst, n : n, t* : valtype*, t_1^k : valtype^k, t_2^n : valtype^n, val^k : val^k, z : state, o0* : val*}: `%~>%*`(`%;%*`(z, $admininstr_val(val)^k{val} :: [CALL_ADDR_admininstr(a)]), [FRAME__admininstr(n, f, [LABEL__admininstr(n, [], $admininstr_instr(instr)*{instr})])]) -- (if ($default_(t) = ?(o0)))*{t o0} - -- if ($funcinst(z)[a] = `%;%`(m, `FUNC%%*%`(`%->%`(t_1^k{t_1}, t_2^n{t_2}), t*{t}, instr*{instr}))) + -- if ($funcinst(z)[a] = {MODULE m, CODE func}) + -- if (func = `FUNC%%*%`(`%->%`(t_1^k{t_1}, t_2^n{t_2}), t*{t}, instr*{instr})) -- if (f = {LOCAL val^k{val} :: o0*{o0}, MODULE m}) - ;; 6-reduction.watsup:151.1-152.53 + ;; 6-reduction.watsup:152.1-153.53 rule ref.func {x : idx, z : state}: `%~>%*`(`%;%*`(z, [REF.FUNC_admininstr(x)]), [REF.FUNC_ADDR_admininstr($funcaddr(z)[x])]) - ;; 6-reduction.watsup:164.1-165.37 + ;; 6-reduction.watsup:165.1-166.37 rule local.get {x : idx, z : state}: `%~>%*`(`%;%*`(z, [LOCAL.GET_admininstr(x)]), [$admininstr_val($local(z, x))]) - ;; 6-reduction.watsup:174.1-175.39 + ;; 6-reduction.watsup:175.1-176.45 rule global.get {x : idx, z : state}: - `%~>%*`(`%;%*`(z, [GLOBAL.GET_admininstr(x)]), [$admininstr_globalinst($global(z, x))]) + `%~>%*`(`%;%*`(z, [GLOBAL.GET_admininstr(x)]), [$admininstr_val($global(z, x).VALUE_globalinst)]) - ;; 6-reduction.watsup:181.1-183.28 + ;; 6-reduction.watsup:182.1-184.33 rule table.get-trap {i : nat, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [TRAP_admininstr]) - -- if (i >= |$table(z, x)|) + -- if (i >= |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:185.1-187.27 + ;; 6-reduction.watsup:186.1-188.32 rule table.get-val {i : nat, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [$admininstr_ref($table(z, x)[i])]) - -- if (i < |$table(z, x)|) + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [$admininstr_ref($table(z, x).ELEM_tableinst[i])]) + -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:198.1-200.27 + ;; 6-reduction.watsup:199.1-201.32 rule table.size {n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) - -- if (|$table(z, x)| = n) + -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:210.1-212.34 + ;; 6-reduction.watsup:211.1-213.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) - -- if ((i + n) > |$table(z, x)|) + -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:214.1-217.14 + ;; 6-reduction.watsup:215.1-218.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:219.1-223.15 + ;; 6-reduction.watsup:220.1-224.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:226.1-228.63 + ;; 6-reduction.watsup:227.1-229.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) - -- if (((i + n) > |$table(z, y)|) \/ ((j + n) > |$table(z, x)|)) + -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:230.1-233.14 + ;; 6-reduction.watsup:231.1-234.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:235.1-240.15 + ;; 6-reduction.watsup:236.1-241.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:242.1-246.15 + ;; 6-reduction.watsup:243.1-247.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:249.1-251.62 + ;; 6-reduction.watsup:250.1-252.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) - -- if (((i + n) > |$elem(z, y)|) \/ ((j + n) > |$table(z, x)|)) + -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:253.1-256.14 + ;; 6-reduction.watsup:254.1-257.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:258.1-262.15 + ;; 6-reduction.watsup:259.1-263.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y)[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y).ELEM_eleminst[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:269.1-271.48 + ;; 6-reduction.watsup:270.1-272.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- if ($size($valtype_numtype(nt)) = ?(o0)) - -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:273.1-275.66 + ;; 6-reduction.watsup:274.1-276.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($size($valtype_numtype(nt)) = ?(o1)) - -- if ($bytes_(o0, c) = $mem(z, 0)[(i + n_O) : (o1 / 8)]) + -- if ($bytes_(o0, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (o1 / 8)]) - ;; 6-reduction.watsup:277.1-279.40 + ;; 6-reduction.watsup:278.1-280.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) - -- if (((i + n_O) + (n / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:281.1-283.50 + ;; 6-reduction.watsup:282.1-284.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, o0, sx, c))]) -- if ($size($valtype_numtype(nt)) = ?(o0)) - -- if ($bytes_(n, c) = $mem(z, 0)[(i + n_O) : (n / 8)]) + -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:303.1-305.39 + ;; 6-reduction.watsup:304.1-306.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) - -- if (((n * 64) * $Ki) = |$mem(z, 0)|) + -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:315.1-317.32 + ;; 6-reduction.watsup:316.1-318.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) - -- if ((i + n) > |$mem(z, 0)|) + -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:319.1-322.14 + ;; 6-reduction.watsup:320.1-323.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:324.1-328.15 + ;; 6-reduction.watsup:325.1-329.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:331.1-333.59 + ;; 6-reduction.watsup:332.1-334.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) - -- if (((i + n) > |$mem(z, 0)|) \/ ((j + n) > |$mem(z, 0)|)) + -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:335.1-338.14 + ;; 6-reduction.watsup:336.1-339.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:340.1-345.15 + ;; 6-reduction.watsup:341.1-346.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:347.1-351.15 + ;; 6-reduction.watsup:348.1-352.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:354.1-356.60 + ;; 6-reduction.watsup:355.1-357.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) - -- if (((i + n) > |$data(z, x)|) \/ ((j + n) > |$mem(z, 0)|)) + -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:358.1-361.14 + ;; 6-reduction.watsup:359.1-362.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:363.1-367.15 + ;; 6-reduction.watsup:364.1-368.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x)[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise ;; 6-reduction.watsup:3.1-3.63 @@ -8508,69 +8489,69 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, $admininstr_instr(instr)*{instr}), `%;%*`(z, $admininstr_instr(instr')*{instr'})) -- Step_read: `%~>%*`(`%;%*`(z, $admininstr_instr(instr)*{instr}), $admininstr_instr(instr')*{instr'}) - ;; 6-reduction.watsup:167.1-168.60 + ;; 6-reduction.watsup:168.1-169.60 rule local.set {val : val, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_val(val) LOCAL.SET_admininstr(x)]), `%;%*`($with_local(z, x, val), [])) - ;; 6-reduction.watsup:177.1-178.62 + ;; 6-reduction.watsup:178.1-179.62 rule global.set {val : val, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_val(val) GLOBAL.SET_admininstr(x)]), `%;%*`($with_global(z, x, val), [])) - ;; 6-reduction.watsup:189.1-191.28 + ;; 6-reduction.watsup:190.1-192.33 rule table.set-trap {i : nat, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`(z, [TRAP_admininstr])) - -- if (i >= |$table(z, x)|) + -- if (i >= |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:193.1-195.27 + ;; 6-reduction.watsup:194.1-196.32 rule table.set-val {i : nat, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) - -- if (i < |$table(z, x)|) + -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:203.1-204.102 + ;; 6-reduction.watsup:204.1-205.107 rule table.grow-succeed {n : n, ref : ref, x : idx, z : state}: - `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x)|)])) + `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - ;; 6-reduction.watsup:206.1-207.64 + ;; 6-reduction.watsup:207.1-208.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:265.1-266.59 + ;; 6-reduction.watsup:266.1-267.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:286.1-288.48 + ;; 6-reduction.watsup:287.1-289.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if ($size($valtype_numtype(nt)) = ?(o0)) - -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:290.1-292.35 + ;; 6-reduction.watsup:291.1-293.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (o0 / 8), b*{b}), [])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($size($valtype_numtype(nt)) = ?(o1)) -- if (b*{b} = $bytes_(o1, c)) - ;; 6-reduction.watsup:294.1-296.40 + ;; 6-reduction.watsup:295.1-297.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) - -- if (((i + n_O) + (n / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:298.1-300.50 + ;; 6-reduction.watsup:299.1-301.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (b*{b} = $bytes_(n, $wrap_((o0, n), c))) - ;; 6-reduction.watsup:308.1-309.117 + ;; 6-reduction.watsup:309.1-310.122 rule memory.grow-succeed {n : n, z : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0)| / (64 * $Ki)))])) + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - ;; 6-reduction.watsup:311.1-312.59 + ;; 6-reduction.watsup:312.1-313.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:370.1-371.59 + ;; 6-reduction.watsup:371.1-372.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) @@ -9678,43 +9659,43 @@ def default_ : valtype -> val? def default_(EXTERNREF_valtype) = ?(REF.NULL_val(EXTERNREF_reftype)) def {x : valtype} default_(x) = ?() -;; 4-runtime.watsup:61.1-61.71 -syntax exportinst = EXPORT(name, externval) +;; 4-runtime.watsup:71.1-73.22 +syntax exportinst = {NAME name, VALUE externval} -;; 4-runtime.watsup:71.1-78.25 +;; 4-runtime.watsup:83.1-90.25 syntax moduleinst = {FUNC funcaddr*, GLOBAL globaladdr*, TABLE tableaddr*, MEM memaddr*, ELEM elemaddr*, DATA dataaddr*, EXPORT exportinst*} -;; 4-runtime.watsup:55.1-55.66 -syntax funcinst = `%;%`(moduleinst, func) +;; 4-runtime.watsup:55.1-57.16 +syntax funcinst = {MODULE moduleinst, CODE func} -;; 4-runtime.watsup:56.1-56.53 -syntax globalinst = val +;; 4-runtime.watsup:58.1-60.16 +syntax globalinst = {TYPE globaltype, VALUE val} -;; 4-runtime.watsup:57.1-57.52 -syntax tableinst = ref* +;; 4-runtime.watsup:61.1-63.16 +syntax tableinst = {TYPE tabletype, ELEM ref*} -;; 4-runtime.watsup:58.1-58.52 -syntax meminst = byte* +;; 4-runtime.watsup:64.1-66.17 +syntax meminst = {TYPE memtype, DATA byte*} -;; 4-runtime.watsup:59.1-59.53 -syntax eleminst = ref* +;; 4-runtime.watsup:67.1-68.16 +syntax eleminst = {ELEM ref*} -;; 4-runtime.watsup:60.1-60.51 -syntax datainst = byte* +;; 4-runtime.watsup:69.1-70.17 +syntax datainst = {DATA byte*} -;; 4-runtime.watsup:63.1-69.21 +;; 4-runtime.watsup:75.1-81.21 syntax store = {FUNC funcinst*, GLOBAL globalinst*, TABLE tableinst*, MEM meminst*, ELEM eleminst*, DATA datainst*} -;; 4-runtime.watsup:80.1-82.24 +;; 4-runtime.watsup:92.1-94.24 syntax frame = {LOCAL val*, MODULE moduleinst} -;; 4-runtime.watsup:83.1-83.47 +;; 4-runtime.watsup:95.1-95.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:146.1-153.5 +;; 4-runtime.watsup:158.1-165.5 rec { -;; 4-runtime.watsup:146.1-153.5 +;; 4-runtime.watsup:158.1-165.5 syntax admininstr = | UNREACHABLE | NOP @@ -9768,12 +9749,6 @@ syntax admininstr = | TRAP } -def admininstr_globalinst : globalinst -> admininstr - def {x0 : numtype, x1 : c_numtype} admininstr_globalinst(CONST_val(x0, x1)) = CONST_admininstr(x0, x1) - def {x : reftype} admininstr_globalinst(REF.NULL_val(x)) = REF.NULL_admininstr(x) - def {x : funcaddr} admininstr_globalinst(REF.FUNC_ADDR_val(x)) = REF.FUNC_ADDR_admininstr(x) - def {x : hostaddr} admininstr_globalinst(REF.HOST_ADDR_val(x)) = REF.HOST_ADDR_admininstr(x) - def admininstr_instr : instr -> admininstr def admininstr_instr(UNREACHABLE_instr) = UNREACHABLE_admininstr def admininstr_instr(NOP_instr) = NOP_admininstr @@ -9831,98 +9806,98 @@ def admininstr_val : val -> admininstr def {x : funcaddr} admininstr_val(REF.FUNC_ADDR_val(x)) = REF.FUNC_ADDR_admininstr(x) def {x : hostaddr} admininstr_val(REF.HOST_ADDR_val(x)) = REF.HOST_ADDR_admininstr(x) -;; 4-runtime.watsup:84.1-84.62 +;; 4-runtime.watsup:96.1-96.62 syntax config = `%;%*`(state, admininstr*) -;; 4-runtime.watsup:102.1-102.59 +;; 4-runtime.watsup:114.1-114.59 def funcaddr : state -> funcaddr* - ;; 4-runtime.watsup:103.1-103.38 + ;; 4-runtime.watsup:115.1-115.38 def {f : frame, s : store} funcaddr(`%;%`(s, f)) = f.MODULE_frame.FUNC_moduleinst -;; 4-runtime.watsup:105.1-105.52 +;; 4-runtime.watsup:117.1-117.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:106.1-106.31 + ;; 4-runtime.watsup:118.1-118.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:108.1-108.67 +;; 4-runtime.watsup:120.1-120.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:116.1-116.48 + ;; 4-runtime.watsup:128.1-128.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:109.1-109.69 +;; 4-runtime.watsup:121.1-121.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:117.1-117.54 + ;; 4-runtime.watsup:129.1-129.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:110.1-110.68 +;; 4-runtime.watsup:122.1-122.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:118.1-118.51 + ;; 4-runtime.watsup:130.1-130.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:111.1-111.66 +;; 4-runtime.watsup:123.1-123.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:119.1-119.45 + ;; 4-runtime.watsup:131.1-131.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:112.1-112.67 +;; 4-runtime.watsup:124.1-124.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:120.1-120.48 + ;; 4-runtime.watsup:132.1-132.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:113.1-113.67 +;; 4-runtime.watsup:125.1-125.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:121.1-121.48 + ;; 4-runtime.watsup:133.1-133.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:114.1-114.68 +;; 4-runtime.watsup:126.1-126.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:122.1-122.35 + ;; 4-runtime.watsup:134.1-134.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:125.1-125.78 +;; 4-runtime.watsup:137.1-137.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:134.1-134.52 + ;; 4-runtime.watsup:146.1-146.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:126.1-126.79 +;; 4-runtime.watsup:138.1-138.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:135.1-135.71 - def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] = v], f) + ;; 4-runtime.watsup:147.1-147.77 + def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:127.1-127.83 +;; 4-runtime.watsup:139.1-139.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:136.1-136.74 - def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]][i] = r], f) + ;; 4-runtime.watsup:148.1-148.79 + def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:128.1-128.80 +;; 4-runtime.watsup:140.1-140.85 def with_tableext : (state, tableidx, ref*) -> state - ;; 4-runtime.watsup:137.1-137.75 - def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] =.. r*{r}], f) + ;; 4-runtime.watsup:149.1-149.80 + def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst =.. r*{r}], f) -;; 4-runtime.watsup:129.1-129.90 +;; 4-runtime.watsup:141.1-141.95 def with_mem : (state, tableidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:138.1-138.77 - def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]][i : j] = b*{b}], f) + ;; 4-runtime.watsup:150.1-150.82 + def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:130.1-130.78 +;; 4-runtime.watsup:142.1-142.83 def with_memext : (state, tableidx, byte*) -> state - ;; 4-runtime.watsup:139.1-139.69 - def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] =.. b*{b}], f) + ;; 4-runtime.watsup:151.1-151.74 + def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst =.. b*{b}], f) -;; 4-runtime.watsup:131.1-131.77 +;; 4-runtime.watsup:143.1-143.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:140.1-140.67 - def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] = r*{r}], f) + ;; 4-runtime.watsup:152.1-152.72 + def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:132.1-132.77 +;; 4-runtime.watsup:144.1-144.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:141.1-141.67 - def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]] = b*{b}], f) + ;; 4-runtime.watsup:153.1-153.72 + def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:155.1-158.21 +;; 4-runtime.watsup:167.1-170.21 rec { -;; 4-runtime.watsup:155.1-158.21 +;; 4-runtime.watsup:167.1-170.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -10029,74 +10004,74 @@ relation Step_pure: `%*~>%*`(admininstr*, admininstr*) `%*~>%*`([CONST_admininstr(I32_numtype, i) BR_TABLE_admininstr(l*{l}, l')], [BR_admininstr(l')]) -- if (i >= |l*{l}|) - ;; 6-reduction.watsup:101.1-102.35 + ;; 6-reduction.watsup:102.1-103.35 rule frame-vals {f : frame, n : n, val^n : val^n}: `%*~>%*`([FRAME__admininstr(n, f, $admininstr_val(val)^n{val})], $admininstr_val(val)^n{val}) - ;; 6-reduction.watsup:104.1-105.55 + ;; 6-reduction.watsup:105.1-106.55 rule return-frame {f : frame, instr* : instr*, n : n, val^n : val^n, val'* : val*}: `%*~>%*`([FRAME__admininstr(n, f, $admininstr_val(val')*{val'} :: $admininstr_val(val)^n{val} :: [RETURN_admininstr] :: $admininstr_instr(instr)*{instr})], $admininstr_val(val)^n{val}) - ;; 6-reduction.watsup:107.1-108.60 + ;; 6-reduction.watsup:108.1-109.60 rule return-label {instr* : instr*, instr'* : instr*, k : nat, val* : val*}: `%*~>%*`([LABEL__admininstr(k, instr'*{instr'}, $admininstr_val(val)*{val} :: [RETURN_admininstr] :: $admininstr_instr(instr)*{instr})], $admininstr_val(val)*{val} :: [RETURN_admininstr]) - ;; 6-reduction.watsup:111.1-113.33 + ;; 6-reduction.watsup:112.1-114.33 rule unop-val {c : c_numtype, c_1 : c_numtype, nt : numtype, unop : unop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) UNOP_admininstr(nt, unop)], [CONST_admininstr(nt, c)]) -- if ($unop(unop, nt, c_1) = [c]) - ;; 6-reduction.watsup:115.1-117.39 + ;; 6-reduction.watsup:116.1-118.39 rule unop-trap {c_1 : c_numtype, nt : numtype, unop : unop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) UNOP_admininstr(nt, unop)], [TRAP_admininstr]) -- if ($unop(unop, nt, c_1) = []) - ;; 6-reduction.watsup:120.1-122.40 + ;; 6-reduction.watsup:121.1-123.40 rule binop-val {binop : binop_numtype, c : c_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) BINOP_admininstr(nt, binop)], [CONST_admininstr(nt, c)]) -- if ($binop(binop, nt, c_1, c_2) = [c]) - ;; 6-reduction.watsup:124.1-126.46 + ;; 6-reduction.watsup:125.1-127.46 rule binop-trap {binop : binop_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) BINOP_admininstr(nt, binop)], [TRAP_admininstr]) -- if ($binop(binop, nt, c_1, c_2) = []) - ;; 6-reduction.watsup:129.1-131.37 + ;; 6-reduction.watsup:130.1-132.37 rule testop {c : c_numtype, c_1 : c_numtype, nt : numtype, testop : testop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) TESTOP_admininstr(nt, testop)], [CONST_admininstr(I32_numtype, c)]) -- if (c = $testop(testop, nt, c_1)) - ;; 6-reduction.watsup:133.1-135.40 + ;; 6-reduction.watsup:134.1-136.40 rule relop {c : c_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype, relop : relop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) RELOP_admininstr(nt, relop)], [CONST_admininstr(I32_numtype, c)]) -- if (c = $relop(relop, nt, c_1, c_2)) - ;; 6-reduction.watsup:138.1-139.70 + ;; 6-reduction.watsup:139.1-140.70 rule extend {c : c_numtype, n : n, nt : numtype, o0 : nat}: `%*~>%*`([CONST_admininstr(nt, c) EXTEND_admininstr(nt, n)], [CONST_admininstr(nt, $ext(n, o0, S_sx, c))]) -- if ($size($valtype_numtype(nt)) = ?(o0)) - ;; 6-reduction.watsup:142.1-144.48 + ;; 6-reduction.watsup:143.1-145.48 rule cvtop-val {c : c_numtype, c_1 : c_numtype, cvtop : cvtop, nt_1 : numtype, nt_2 : numtype, sx? : sx?}: `%*~>%*`([CONST_admininstr(nt_1, c_1) CVTOP_admininstr(nt_2, cvtop, nt_1, sx?{sx})], [CONST_admininstr(nt_2, c)]) -- if ($cvtop(nt_1, cvtop, nt_2, sx?{sx}, c_1) = [c]) - ;; 6-reduction.watsup:146.1-148.54 + ;; 6-reduction.watsup:147.1-149.54 rule cvtop-trap {c_1 : c_numtype, cvtop : cvtop, nt_1 : numtype, nt_2 : numtype, sx? : sx?}: `%*~>%*`([CONST_admininstr(nt_1, c_1) CVTOP_admininstr(nt_2, cvtop, nt_1, sx?{sx})], [TRAP_admininstr]) -- if ($cvtop(nt_1, cvtop, nt_2, sx?{sx}, c_1) = []) - ;; 6-reduction.watsup:155.1-157.28 + ;; 6-reduction.watsup:156.1-158.28 rule ref.is_null-true {rt : reftype, val : val}: `%*~>%*`([$admininstr_val(val) REF.IS_NULL_admininstr], [CONST_admininstr(I32_numtype, 1)]) -- if (val = REF.NULL_val(rt)) - ;; 6-reduction.watsup:159.1-161.15 + ;; 6-reduction.watsup:160.1-162.15 rule ref.is_null-false {val : val}: `%*~>%*`([$admininstr_val(val) REF.IS_NULL_admininstr], [CONST_admininstr(I32_numtype, 0)]) -- otherwise - ;; 6-reduction.watsup:170.1-171.47 + ;; 6-reduction.watsup:171.1-172.47 rule local.tee {val : val, x : idx}: `%*~>%*`([$admininstr_val(val) LOCAL.TEE_admininstr(x)], [$admininstr_val(val) $admininstr_val(val) LOCAL.SET_admininstr(x)]) @@ -10108,12 +10083,12 @@ relation Step_read: `%~>%*`(config, admininstr*) -- if (x < |$funcaddr(z)|) ;; 6-reduction.watsup:85.1-89.17 - rule call_indirect-call {a : addr, ft : functype, ft' : functype, i : nat, instr* : instr*, m : moduleinst, t* : valtype*, x : idx, z : state}: + rule call_indirect-call {a : addr, ft : functype, ft' : functype, i : nat, instr* : instr*, t* : valtype*, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CALL_INDIRECT_admininstr(x, ft)]), [CALL_ADDR_admininstr(a)]) - -- if (i < |$table(z, x)|) + -- if (i < |$table(z, x).ELEM_tableinst|) -- if (a < |$funcinst(z)|) - -- if ($table(z, x)[i] = REF.FUNC_ADDR_ref(a)) - -- if ($funcinst(z)[a] = `%;%`(m, `FUNC%%*%`(ft', t*{t}, instr*{instr}))) + -- if ($table(z, x).ELEM_tableinst[i] = REF.FUNC_ADDR_ref(a)) + -- if ($funcinst(z)[a].CODE_funcinst = `FUNC%%*%`(ft', t*{t}, instr*{instr})) -- if (ft = ft') ;; 6-reduction.watsup:91.1-93.15 @@ -10121,180 +10096,181 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CALL_INDIRECT_admininstr(x, ft)]), [TRAP_admininstr]) -- otherwise - ;; 6-reduction.watsup:95.1-98.52 - rule call_addr {a : addr, f : frame, instr* : instr*, k : nat, m : moduleinst, n : n, t* : valtype*, t_1^k : valtype^k, t_2^n : valtype^n, val^k : val^k, z : state, o0* : val*}: + ;; 6-reduction.watsup:95.1-99.52 + rule call_addr {a : addr, f : frame, func : func, instr* : instr*, k : nat, m : moduleinst, n : n, t* : valtype*, t_1^k : valtype^k, t_2^n : valtype^n, val^k : val^k, z : state, o0* : val*}: `%~>%*`(`%;%*`(z, $admininstr_val(val)^k{val} :: [CALL_ADDR_admininstr(a)]), [FRAME__admininstr(n, f, [LABEL__admininstr(n, [], $admininstr_instr(instr)*{instr})])]) -- if (|t*{t}| = |o0*{o0}|) -- if (a < |$funcinst(z)|) -- (if ($default_(t) = ?(o0)))*{t o0} - -- if ($funcinst(z)[a] = `%;%`(m, `FUNC%%*%`(`%->%`(t_1^k{t_1}, t_2^n{t_2}), t*{t}, instr*{instr}))) + -- if ($funcinst(z)[a] = {MODULE m, CODE func}) + -- if (func = `FUNC%%*%`(`%->%`(t_1^k{t_1}, t_2^n{t_2}), t*{t}, instr*{instr})) -- if (f = {LOCAL val^k{val} :: o0*{o0}, MODULE m}) - ;; 6-reduction.watsup:151.1-152.53 + ;; 6-reduction.watsup:152.1-153.53 rule ref.func {x : idx, z : state}: `%~>%*`(`%;%*`(z, [REF.FUNC_admininstr(x)]), [REF.FUNC_ADDR_admininstr($funcaddr(z)[x])]) -- if (x < |$funcaddr(z)|) - ;; 6-reduction.watsup:164.1-165.37 + ;; 6-reduction.watsup:165.1-166.37 rule local.get {x : idx, z : state}: `%~>%*`(`%;%*`(z, [LOCAL.GET_admininstr(x)]), [$admininstr_val($local(z, x))]) - ;; 6-reduction.watsup:174.1-175.39 + ;; 6-reduction.watsup:175.1-176.45 rule global.get {x : idx, z : state}: - `%~>%*`(`%;%*`(z, [GLOBAL.GET_admininstr(x)]), [$admininstr_globalinst($global(z, x))]) + `%~>%*`(`%;%*`(z, [GLOBAL.GET_admininstr(x)]), [$admininstr_val($global(z, x).VALUE_globalinst)]) - ;; 6-reduction.watsup:181.1-183.28 + ;; 6-reduction.watsup:182.1-184.33 rule table.get-trap {i : nat, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [TRAP_admininstr]) - -- if (i >= |$table(z, x)|) + -- if (i >= |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:185.1-187.27 + ;; 6-reduction.watsup:186.1-188.32 rule table.get-val {i : nat, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [$admininstr_ref($table(z, x)[i])]) - -- if (i < |$table(z, x)|) + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [$admininstr_ref($table(z, x).ELEM_tableinst[i])]) + -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:198.1-200.27 + ;; 6-reduction.watsup:199.1-201.32 rule table.size {n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) - -- if (|$table(z, x)| = n) + -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:210.1-212.34 + ;; 6-reduction.watsup:211.1-213.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) - -- if ((i + n) > |$table(z, x)|) + -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:214.1-217.14 + ;; 6-reduction.watsup:215.1-218.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:219.1-223.15 + ;; 6-reduction.watsup:220.1-224.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:226.1-228.63 + ;; 6-reduction.watsup:227.1-229.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) - -- if (((i + n) > |$table(z, y)|) \/ ((j + n) > |$table(z, x)|)) + -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:230.1-233.14 + ;; 6-reduction.watsup:231.1-234.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:235.1-240.15 + ;; 6-reduction.watsup:236.1-241.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:242.1-246.15 + ;; 6-reduction.watsup:243.1-247.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:249.1-251.62 + ;; 6-reduction.watsup:250.1-252.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) - -- if (((i + n) > |$elem(z, y)|) \/ ((j + n) > |$table(z, x)|)) + -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:253.1-256.14 + ;; 6-reduction.watsup:254.1-257.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:258.1-262.15 + ;; 6-reduction.watsup:259.1-263.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y)[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) - -- if (i < |$elem(z, y)|) + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y).ELEM_eleminst[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) + -- if (i < |$elem(z, y).ELEM_eleminst|) -- otherwise - ;; 6-reduction.watsup:269.1-271.48 + ;; 6-reduction.watsup:270.1-272.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- if ($size($valtype_numtype(nt)) = ?(o0)) - -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:273.1-275.66 + ;; 6-reduction.watsup:274.1-276.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($size($valtype_numtype(nt)) = ?(o1)) - -- if ($bytes_(o0, c) = $mem(z, 0)[(i + n_O) : (o1 / 8)]) + -- if ($bytes_(o0, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (o1 / 8)]) - ;; 6-reduction.watsup:277.1-279.40 + ;; 6-reduction.watsup:278.1-280.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) - -- if (((i + n_O) + (n / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:281.1-283.50 + ;; 6-reduction.watsup:282.1-284.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, o0, sx, c))]) -- if ($size($valtype_numtype(nt)) = ?(o0)) - -- if ($bytes_(n, c) = $mem(z, 0)[(i + n_O) : (n / 8)]) + -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:303.1-305.39 + ;; 6-reduction.watsup:304.1-306.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) - -- if (((n * 64) * $Ki) = |$mem(z, 0)|) + -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:315.1-317.32 + ;; 6-reduction.watsup:316.1-318.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) - -- if ((i + n) > |$mem(z, 0)|) + -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:319.1-322.14 + ;; 6-reduction.watsup:320.1-323.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:324.1-328.15 + ;; 6-reduction.watsup:325.1-329.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:331.1-333.59 + ;; 6-reduction.watsup:332.1-334.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) - -- if (((i + n) > |$mem(z, 0)|) \/ ((j + n) > |$mem(z, 0)|)) + -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:335.1-338.14 + ;; 6-reduction.watsup:336.1-339.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:340.1-345.15 + ;; 6-reduction.watsup:341.1-346.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:347.1-351.15 + ;; 6-reduction.watsup:348.1-352.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:354.1-356.60 + ;; 6-reduction.watsup:355.1-357.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) - -- if (((i + n) > |$data(z, x)|) \/ ((j + n) > |$mem(z, 0)|)) + -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:358.1-361.14 + ;; 6-reduction.watsup:359.1-362.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:363.1-367.15 + ;; 6-reduction.watsup:364.1-368.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x)[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) - -- if (i < |$data(z, x)|) + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) + -- if (i < |$data(z, x).DATA_datainst|) -- otherwise ;; 6-reduction.watsup:3.1-3.63 @@ -10309,77 +10285,77 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, $admininstr_instr(instr)*{instr}), `%;%*`(z, $admininstr_instr(instr')*{instr'})) -- Step_read: `%~>%*`(`%;%*`(z, $admininstr_instr(instr)*{instr}), $admininstr_instr(instr')*{instr'}) - ;; 6-reduction.watsup:167.1-168.60 + ;; 6-reduction.watsup:168.1-169.60 rule local.set {val : val, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_val(val) LOCAL.SET_admininstr(x)]), `%;%*`($with_local(z, x, val), [])) - ;; 6-reduction.watsup:177.1-178.62 + ;; 6-reduction.watsup:178.1-179.62 rule global.set {val : val, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_val(val) GLOBAL.SET_admininstr(x)]), `%;%*`($with_global(z, x, val), [])) - ;; 6-reduction.watsup:189.1-191.28 + ;; 6-reduction.watsup:190.1-192.33 rule table.set-trap {i : nat, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`(z, [TRAP_admininstr])) - -- if (i >= |$table(z, x)|) + -- if (i >= |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:193.1-195.27 + ;; 6-reduction.watsup:194.1-196.32 rule table.set-val {i : nat, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) - -- if (i < |$table(z, x)|) + -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:203.1-204.102 + ;; 6-reduction.watsup:204.1-205.107 rule table.grow-succeed {n : n, ref : ref, x : idx, z : state}: - `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x)|)])) + `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - ;; 6-reduction.watsup:206.1-207.64 + ;; 6-reduction.watsup:207.1-208.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:265.1-266.59 + ;; 6-reduction.watsup:266.1-267.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:286.1-288.48 + ;; 6-reduction.watsup:287.1-289.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if ($size($valtype_numtype(nt)) = ?(o0)) - -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:290.1-292.35 + ;; 6-reduction.watsup:291.1-293.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (o0 / 8), b*{b}), [])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($size($valtype_numtype(nt)) = ?(o1)) -- if (b*{b} = $bytes_(o1, c)) - ;; 6-reduction.watsup:294.1-296.40 + ;; 6-reduction.watsup:295.1-297.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) - -- if (((i + n_O) + (n / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:298.1-300.50 + ;; 6-reduction.watsup:299.1-301.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (b*{b} = $bytes_(n, $wrap_((o0, n), c))) - ;; 6-reduction.watsup:308.1-309.117 + ;; 6-reduction.watsup:309.1-310.122 rule memory.grow-succeed {n : n, z : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0)| / (64 * $Ki)))])) + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - ;; 6-reduction.watsup:311.1-312.59 + ;; 6-reduction.watsup:312.1-313.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:370.1-371.59 + ;; 6-reduction.watsup:371.1-372.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) == IL Validation... == Running pass animate -Animation failed:if ($funcinst(z)[a] = `%;%`(m, `FUNC%%*%`(ft', t*{t}, instr*{instr}))) -Animation failed:if ($bytes_(o0, c) = $mem(z, 0)[(i + n_O) : (o1 / 8)]) -Animation failed:if ($bytes_(n, c) = $mem(z, 0)[(i + n_O) : (n / 8)]) +Animation failed:if ($funcinst(z)[a].CODE_funcinst = `FUNC%%*%`(ft', t*{t}, instr*{instr})) +Animation failed:if ($bytes_(o0, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (o1 / 8)]) +Animation failed:if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) ;; 1-syntax.watsup:3.1-3.15 syntax n = nat @@ -11482,43 +11458,43 @@ def default_ : valtype -> val? def default_(EXTERNREF_valtype) = ?(REF.NULL_val(EXTERNREF_reftype)) def {x : valtype} default_(x) = ?() -;; 4-runtime.watsup:61.1-61.71 -syntax exportinst = EXPORT(name, externval) +;; 4-runtime.watsup:71.1-73.22 +syntax exportinst = {NAME name, VALUE externval} -;; 4-runtime.watsup:71.1-78.25 +;; 4-runtime.watsup:83.1-90.25 syntax moduleinst = {FUNC funcaddr*, GLOBAL globaladdr*, TABLE tableaddr*, MEM memaddr*, ELEM elemaddr*, DATA dataaddr*, EXPORT exportinst*} -;; 4-runtime.watsup:55.1-55.66 -syntax funcinst = `%;%`(moduleinst, func) +;; 4-runtime.watsup:55.1-57.16 +syntax funcinst = {MODULE moduleinst, CODE func} -;; 4-runtime.watsup:56.1-56.53 -syntax globalinst = val +;; 4-runtime.watsup:58.1-60.16 +syntax globalinst = {TYPE globaltype, VALUE val} -;; 4-runtime.watsup:57.1-57.52 -syntax tableinst = ref* +;; 4-runtime.watsup:61.1-63.16 +syntax tableinst = {TYPE tabletype, ELEM ref*} -;; 4-runtime.watsup:58.1-58.52 -syntax meminst = byte* +;; 4-runtime.watsup:64.1-66.17 +syntax meminst = {TYPE memtype, DATA byte*} -;; 4-runtime.watsup:59.1-59.53 -syntax eleminst = ref* +;; 4-runtime.watsup:67.1-68.16 +syntax eleminst = {ELEM ref*} -;; 4-runtime.watsup:60.1-60.51 -syntax datainst = byte* +;; 4-runtime.watsup:69.1-70.17 +syntax datainst = {DATA byte*} -;; 4-runtime.watsup:63.1-69.21 +;; 4-runtime.watsup:75.1-81.21 syntax store = {FUNC funcinst*, GLOBAL globalinst*, TABLE tableinst*, MEM meminst*, ELEM eleminst*, DATA datainst*} -;; 4-runtime.watsup:80.1-82.24 +;; 4-runtime.watsup:92.1-94.24 syntax frame = {LOCAL val*, MODULE moduleinst} -;; 4-runtime.watsup:83.1-83.47 +;; 4-runtime.watsup:95.1-95.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:146.1-153.5 +;; 4-runtime.watsup:158.1-165.5 rec { -;; 4-runtime.watsup:146.1-153.5 +;; 4-runtime.watsup:158.1-165.5 syntax admininstr = | UNREACHABLE | NOP @@ -11572,12 +11548,6 @@ syntax admininstr = | TRAP } -def admininstr_globalinst : globalinst -> admininstr - def {x0 : numtype, x1 : c_numtype} admininstr_globalinst(CONST_val(x0, x1)) = CONST_admininstr(x0, x1) - def {x : reftype} admininstr_globalinst(REF.NULL_val(x)) = REF.NULL_admininstr(x) - def {x : funcaddr} admininstr_globalinst(REF.FUNC_ADDR_val(x)) = REF.FUNC_ADDR_admininstr(x) - def {x : hostaddr} admininstr_globalinst(REF.HOST_ADDR_val(x)) = REF.HOST_ADDR_admininstr(x) - def admininstr_instr : instr -> admininstr def admininstr_instr(UNREACHABLE_instr) = UNREACHABLE_admininstr def admininstr_instr(NOP_instr) = NOP_admininstr @@ -11635,98 +11605,98 @@ def admininstr_val : val -> admininstr def {x : funcaddr} admininstr_val(REF.FUNC_ADDR_val(x)) = REF.FUNC_ADDR_admininstr(x) def {x : hostaddr} admininstr_val(REF.HOST_ADDR_val(x)) = REF.HOST_ADDR_admininstr(x) -;; 4-runtime.watsup:84.1-84.62 +;; 4-runtime.watsup:96.1-96.62 syntax config = `%;%*`(state, admininstr*) -;; 4-runtime.watsup:102.1-102.59 +;; 4-runtime.watsup:114.1-114.59 def funcaddr : state -> funcaddr* - ;; 4-runtime.watsup:103.1-103.38 + ;; 4-runtime.watsup:115.1-115.38 def {f : frame, s : store} funcaddr(`%;%`(s, f)) = f.MODULE_frame.FUNC_moduleinst -;; 4-runtime.watsup:105.1-105.52 +;; 4-runtime.watsup:117.1-117.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:106.1-106.31 + ;; 4-runtime.watsup:118.1-118.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:108.1-108.67 +;; 4-runtime.watsup:120.1-120.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:116.1-116.48 + ;; 4-runtime.watsup:128.1-128.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:109.1-109.69 +;; 4-runtime.watsup:121.1-121.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:117.1-117.54 + ;; 4-runtime.watsup:129.1-129.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:110.1-110.68 +;; 4-runtime.watsup:122.1-122.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:118.1-118.51 + ;; 4-runtime.watsup:130.1-130.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:111.1-111.66 +;; 4-runtime.watsup:123.1-123.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:119.1-119.45 + ;; 4-runtime.watsup:131.1-131.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:112.1-112.67 +;; 4-runtime.watsup:124.1-124.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:120.1-120.48 + ;; 4-runtime.watsup:132.1-132.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:113.1-113.67 +;; 4-runtime.watsup:125.1-125.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:121.1-121.48 + ;; 4-runtime.watsup:133.1-133.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:114.1-114.68 +;; 4-runtime.watsup:126.1-126.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:122.1-122.35 + ;; 4-runtime.watsup:134.1-134.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:125.1-125.78 +;; 4-runtime.watsup:137.1-137.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:134.1-134.52 + ;; 4-runtime.watsup:146.1-146.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:126.1-126.79 +;; 4-runtime.watsup:138.1-138.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:135.1-135.71 - def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] = v], f) + ;; 4-runtime.watsup:147.1-147.77 + def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:127.1-127.83 +;; 4-runtime.watsup:139.1-139.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:136.1-136.74 - def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]][i] = r], f) + ;; 4-runtime.watsup:148.1-148.79 + def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:128.1-128.80 +;; 4-runtime.watsup:140.1-140.85 def with_tableext : (state, tableidx, ref*) -> state - ;; 4-runtime.watsup:137.1-137.75 - def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] =.. r*{r}], f) + ;; 4-runtime.watsup:149.1-149.80 + def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst =.. r*{r}], f) -;; 4-runtime.watsup:129.1-129.90 +;; 4-runtime.watsup:141.1-141.95 def with_mem : (state, tableidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:138.1-138.77 - def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]][i : j] = b*{b}], f) + ;; 4-runtime.watsup:150.1-150.82 + def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:130.1-130.78 +;; 4-runtime.watsup:142.1-142.83 def with_memext : (state, tableidx, byte*) -> state - ;; 4-runtime.watsup:139.1-139.69 - def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] =.. b*{b}], f) + ;; 4-runtime.watsup:151.1-151.74 + def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst =.. b*{b}], f) -;; 4-runtime.watsup:131.1-131.77 +;; 4-runtime.watsup:143.1-143.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:140.1-140.67 - def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] = r*{r}], f) + ;; 4-runtime.watsup:152.1-152.72 + def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:132.1-132.77 +;; 4-runtime.watsup:144.1-144.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:141.1-141.67 - def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]] = b*{b}], f) + ;; 4-runtime.watsup:153.1-153.72 + def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:155.1-158.21 +;; 4-runtime.watsup:167.1-170.21 rec { -;; 4-runtime.watsup:155.1-158.21 +;; 4-runtime.watsup:167.1-170.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -11833,74 +11803,74 @@ relation Step_pure: `%*~>%*`(admininstr*, admininstr*) `%*~>%*`([CONST_admininstr(I32_numtype, i) BR_TABLE_admininstr(l*{l}, l')], [BR_admininstr(l')]) -- if (i >= |l*{l}|) - ;; 6-reduction.watsup:101.1-102.35 + ;; 6-reduction.watsup:102.1-103.35 rule frame-vals {f : frame, n : n, val^n : val^n}: `%*~>%*`([FRAME__admininstr(n, f, $admininstr_val(val)^n{val})], $admininstr_val(val)^n{val}) - ;; 6-reduction.watsup:104.1-105.55 + ;; 6-reduction.watsup:105.1-106.55 rule return-frame {f : frame, instr* : instr*, n : n, val^n : val^n, val'* : val*}: `%*~>%*`([FRAME__admininstr(n, f, $admininstr_val(val')*{val'} :: $admininstr_val(val)^n{val} :: [RETURN_admininstr] :: $admininstr_instr(instr)*{instr})], $admininstr_val(val)^n{val}) - ;; 6-reduction.watsup:107.1-108.60 + ;; 6-reduction.watsup:108.1-109.60 rule return-label {instr* : instr*, instr'* : instr*, k : nat, val* : val*}: `%*~>%*`([LABEL__admininstr(k, instr'*{instr'}, $admininstr_val(val)*{val} :: [RETURN_admininstr] :: $admininstr_instr(instr)*{instr})], $admininstr_val(val)*{val} :: [RETURN_admininstr]) - ;; 6-reduction.watsup:111.1-113.33 + ;; 6-reduction.watsup:112.1-114.33 rule unop-val {c : c_numtype, c_1 : c_numtype, nt : numtype, unop : unop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) UNOP_admininstr(nt, unop)], [CONST_admininstr(nt, c)]) -- where [c] = $unop(unop, nt, c_1) - ;; 6-reduction.watsup:115.1-117.39 + ;; 6-reduction.watsup:116.1-118.39 rule unop-trap {c_1 : c_numtype, nt : numtype, unop : unop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) UNOP_admininstr(nt, unop)], [TRAP_admininstr]) -- if ($unop(unop, nt, c_1) = []) - ;; 6-reduction.watsup:120.1-122.40 + ;; 6-reduction.watsup:121.1-123.40 rule binop-val {binop : binop_numtype, c : c_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) BINOP_admininstr(nt, binop)], [CONST_admininstr(nt, c)]) -- where [c] = $binop(binop, nt, c_1, c_2) - ;; 6-reduction.watsup:124.1-126.46 + ;; 6-reduction.watsup:125.1-127.46 rule binop-trap {binop : binop_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) BINOP_admininstr(nt, binop)], [TRAP_admininstr]) -- if ($binop(binop, nt, c_1, c_2) = []) - ;; 6-reduction.watsup:129.1-131.37 + ;; 6-reduction.watsup:130.1-132.37 rule testop {c : c_numtype, c_1 : c_numtype, nt : numtype, testop : testop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) TESTOP_admininstr(nt, testop)], [CONST_admininstr(I32_numtype, c)]) -- where c = $testop(testop, nt, c_1) - ;; 6-reduction.watsup:133.1-135.40 + ;; 6-reduction.watsup:134.1-136.40 rule relop {c : c_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype, relop : relop_numtype}: `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) RELOP_admininstr(nt, relop)], [CONST_admininstr(I32_numtype, c)]) -- where c = $relop(relop, nt, c_1, c_2) - ;; 6-reduction.watsup:138.1-139.70 + ;; 6-reduction.watsup:139.1-140.70 rule extend {c : c_numtype, n : n, nt : numtype, o0 : nat}: `%*~>%*`([CONST_admininstr(nt, c) EXTEND_admininstr(nt, n)], [CONST_admininstr(nt, $ext(n, o0, S_sx, c))]) -- where ?(o0) = $size($valtype_numtype(nt)) - ;; 6-reduction.watsup:142.1-144.48 + ;; 6-reduction.watsup:143.1-145.48 rule cvtop-val {c : c_numtype, c_1 : c_numtype, cvtop : cvtop, nt_1 : numtype, nt_2 : numtype, sx? : sx?}: `%*~>%*`([CONST_admininstr(nt_1, c_1) CVTOP_admininstr(nt_2, cvtop, nt_1, sx?{sx})], [CONST_admininstr(nt_2, c)]) -- where [c] = $cvtop(nt_1, cvtop, nt_2, sx?{sx}, c_1) - ;; 6-reduction.watsup:146.1-148.54 + ;; 6-reduction.watsup:147.1-149.54 rule cvtop-trap {c_1 : c_numtype, cvtop : cvtop, nt_1 : numtype, nt_2 : numtype, sx? : sx?}: `%*~>%*`([CONST_admininstr(nt_1, c_1) CVTOP_admininstr(nt_2, cvtop, nt_1, sx?{sx})], [TRAP_admininstr]) -- if ($cvtop(nt_1, cvtop, nt_2, sx?{sx}, c_1) = []) - ;; 6-reduction.watsup:155.1-157.28 + ;; 6-reduction.watsup:156.1-158.28 rule ref.is_null-true {rt : reftype, val : val}: `%*~>%*`([$admininstr_val(val) REF.IS_NULL_admininstr], [CONST_admininstr(I32_numtype, 1)]) -- where REF.NULL_val(rt) = val - ;; 6-reduction.watsup:159.1-161.15 + ;; 6-reduction.watsup:160.1-162.15 rule ref.is_null-false {val : val}: `%*~>%*`([$admininstr_val(val) REF.IS_NULL_admininstr], [CONST_admininstr(I32_numtype, 0)]) -- otherwise - ;; 6-reduction.watsup:170.1-171.47 + ;; 6-reduction.watsup:171.1-172.47 rule local.tee {val : val, x : idx}: `%*~>%*`([$admininstr_val(val) LOCAL.TEE_admininstr(x)], [$admininstr_val(val) $admininstr_val(val) LOCAL.SET_admininstr(x)]) @@ -11912,194 +11882,195 @@ relation Step_read: `%~>%*`(config, admininstr*) -- if (x < |$funcaddr(z)|) ;; 6-reduction.watsup:85.1-89.17 - rule call_indirect-call {a : addr, ft : functype, ft' : functype, i : nat, instr* : instr*, m : moduleinst, t* : valtype*, x : idx, z : state}: + rule call_indirect-call {a : addr, ft : functype, ft' : functype, i : nat, instr* : instr*, t* : valtype*, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CALL_INDIRECT_admininstr(x, ft)]), [CALL_ADDR_admininstr(a)]) - -- if (i < |$table(z, x)|) - -- where REF.FUNC_ADDR_ref(a) = $table(z, x)[i] + -- if (i < |$table(z, x).ELEM_tableinst|) + -- where REF.FUNC_ADDR_ref(a) = $table(z, x).ELEM_tableinst[i] -- where ft' = ft -- if (a < |$funcinst(z)|) - -- where `%;%`(m, `FUNC%%*%`(ft', t*{t}, instr*{instr})) = $funcinst(z)[a] + -- where `FUNC%%*%`(ft', t*{t}, instr*{instr}) = $funcinst(z)[a].CODE_funcinst ;; 6-reduction.watsup:91.1-93.15 rule call_indirect-trap {ft : functype, i : nat, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CALL_INDIRECT_admininstr(x, ft)]), [TRAP_admininstr]) -- otherwise - ;; 6-reduction.watsup:95.1-98.52 - rule call_addr {a : addr, f : frame, instr* : instr*, k : nat, m : moduleinst, n : n, t* : valtype*, t_1^k : valtype^k, t_2^n : valtype^n, val^k : val^k, z : state, o0* : val*}: + ;; 6-reduction.watsup:95.1-99.52 + rule call_addr {a : addr, f : frame, func : func, instr* : instr*, k : nat, m : moduleinst, n : n, t* : valtype*, t_1^k : valtype^k, t_2^n : valtype^n, val^k : val^k, z : state, o0* : val*}: `%~>%*`(`%;%*`(z, $admininstr_val(val)^k{val} :: [CALL_ADDR_admininstr(a)]), [FRAME__admininstr(n, f, [LABEL__admininstr(n, [], $admininstr_instr(instr)*{instr})])]) -- if (a < |$funcinst(z)|) - -- where `%;%`(m, `FUNC%%*%`(`%->%`(t_1^k{t_1}, t_2^n{t_2}), t*{t}, instr*{instr})) = $funcinst(z)[a] + -- where {MODULE m, CODE func} = $funcinst(z)[a] + -- where `FUNC%%*%`(`%->%`(t_1^k{t_1}, t_2^n{t_2}), t*{t}, instr*{instr}) = func -- where |o0*{o0}| = |t*{t}| -- (if ($default_(t) = ?(o0)))*{t o0} -- where f = {LOCAL val^k{val} :: o0*{o0}, MODULE m} - ;; 6-reduction.watsup:151.1-152.53 + ;; 6-reduction.watsup:152.1-153.53 rule ref.func {x : idx, z : state}: `%~>%*`(`%;%*`(z, [REF.FUNC_admininstr(x)]), [REF.FUNC_ADDR_admininstr($funcaddr(z)[x])]) -- if (x < |$funcaddr(z)|) - ;; 6-reduction.watsup:164.1-165.37 + ;; 6-reduction.watsup:165.1-166.37 rule local.get {x : idx, z : state}: `%~>%*`(`%;%*`(z, [LOCAL.GET_admininstr(x)]), [$admininstr_val($local(z, x))]) - ;; 6-reduction.watsup:174.1-175.39 + ;; 6-reduction.watsup:175.1-176.45 rule global.get {x : idx, z : state}: - `%~>%*`(`%;%*`(z, [GLOBAL.GET_admininstr(x)]), [$admininstr_globalinst($global(z, x))]) + `%~>%*`(`%;%*`(z, [GLOBAL.GET_admininstr(x)]), [$admininstr_val($global(z, x).VALUE_globalinst)]) - ;; 6-reduction.watsup:181.1-183.28 + ;; 6-reduction.watsup:182.1-184.33 rule table.get-trap {i : nat, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [TRAP_admininstr]) - -- if (i >= |$table(z, x)|) + -- if (i >= |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:185.1-187.27 + ;; 6-reduction.watsup:186.1-188.32 rule table.get-val {i : nat, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [$admininstr_ref($table(z, x)[i])]) - -- if (i < |$table(z, x)|) + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [$admininstr_ref($table(z, x).ELEM_tableinst[i])]) + -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:198.1-200.27 + ;; 6-reduction.watsup:199.1-201.32 rule table.size {n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) - -- where n = |$table(z, x)| + -- where n = |$table(z, x).ELEM_tableinst| - ;; 6-reduction.watsup:210.1-212.34 + ;; 6-reduction.watsup:211.1-213.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) - -- if ((i + n) > |$table(z, x)|) + -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:214.1-217.14 + ;; 6-reduction.watsup:215.1-218.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:219.1-223.15 + ;; 6-reduction.watsup:220.1-224.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:226.1-228.63 + ;; 6-reduction.watsup:227.1-229.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) - -- if (((i + n) > |$table(z, y)|) \/ ((j + n) > |$table(z, x)|)) + -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:230.1-233.14 + ;; 6-reduction.watsup:231.1-234.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:235.1-240.15 + ;; 6-reduction.watsup:236.1-241.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:242.1-246.15 + ;; 6-reduction.watsup:243.1-247.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:249.1-251.62 + ;; 6-reduction.watsup:250.1-252.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) - -- if (((i + n) > |$elem(z, y)|) \/ ((j + n) > |$table(z, x)|)) + -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:253.1-256.14 + ;; 6-reduction.watsup:254.1-257.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:258.1-262.15 + ;; 6-reduction.watsup:259.1-263.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y)[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y).ELEM_eleminst[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise - -- if (i < |$elem(z, y)|) + -- if (i < |$elem(z, y).ELEM_eleminst|) - ;; 6-reduction.watsup:269.1-271.48 + ;; 6-reduction.watsup:270.1-272.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- where ?(o0) = $size($valtype_numtype(nt)) - -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:273.1-275.66 + ;; 6-reduction.watsup:274.1-276.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- where ?(o0) = $size($valtype_numtype(nt)) -- where ?(o1) = $size($valtype_numtype(nt)) - -- where $bytes_(o0, c) = $mem(z, 0)[(i + n_O) : (o1 / 8)] + -- where $bytes_(o0, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (o1 / 8)] - ;; 6-reduction.watsup:277.1-279.40 + ;; 6-reduction.watsup:278.1-280.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) - -- if (((i + n_O) + (n / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:281.1-283.50 + ;; 6-reduction.watsup:282.1-284.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, o0, sx, c))]) -- where ?(o0) = $size($valtype_numtype(nt)) - -- where $bytes_(n, c) = $mem(z, 0)[(i + n_O) : (n / 8)] + -- where $bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)] - ;; 6-reduction.watsup:303.1-305.39 + ;; 6-reduction.watsup:304.1-306.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) - -- where ((n * 64) * $Ki) = |$mem(z, 0)| + -- where ((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst| - ;; 6-reduction.watsup:315.1-317.32 + ;; 6-reduction.watsup:316.1-318.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) - -- if ((i + n) > |$mem(z, 0)|) + -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:319.1-322.14 + ;; 6-reduction.watsup:320.1-323.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:324.1-328.15 + ;; 6-reduction.watsup:325.1-329.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:331.1-333.59 + ;; 6-reduction.watsup:332.1-334.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) - -- if (((i + n) > |$mem(z, 0)|) \/ ((j + n) > |$mem(z, 0)|)) + -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:335.1-338.14 + ;; 6-reduction.watsup:336.1-339.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:340.1-345.15 + ;; 6-reduction.watsup:341.1-346.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:347.1-351.15 + ;; 6-reduction.watsup:348.1-352.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:354.1-356.60 + ;; 6-reduction.watsup:355.1-357.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) - -- if (((i + n) > |$data(z, x)|) \/ ((j + n) > |$mem(z, 0)|)) + -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:358.1-361.14 + ;; 6-reduction.watsup:359.1-362.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:363.1-367.15 + ;; 6-reduction.watsup:364.1-368.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x)[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise - -- if (i < |$data(z, x)|) + -- if (i < |$data(z, x).DATA_datainst|) ;; 6-reduction.watsup:3.1-3.63 relation Step: `%~>%`(config, config) @@ -12113,69 +12084,69 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, $admininstr_instr(instr)*{instr}), `%;%*`(z, $admininstr_instr(instr')*{instr'})) -- Step_read: `%~>%*`(`%;%*`(z, $admininstr_instr(instr)*{instr}), $admininstr_instr(instr')*{instr'}) - ;; 6-reduction.watsup:167.1-168.60 + ;; 6-reduction.watsup:168.1-169.60 rule local.set {val : val, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_val(val) LOCAL.SET_admininstr(x)]), `%;%*`($with_local(z, x, val), [])) - ;; 6-reduction.watsup:177.1-178.62 + ;; 6-reduction.watsup:178.1-179.62 rule global.set {val : val, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_val(val) GLOBAL.SET_admininstr(x)]), `%;%*`($with_global(z, x, val), [])) - ;; 6-reduction.watsup:189.1-191.28 + ;; 6-reduction.watsup:190.1-192.33 rule table.set-trap {i : nat, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`(z, [TRAP_admininstr])) - -- if (i >= |$table(z, x)|) + -- if (i >= |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:193.1-195.27 + ;; 6-reduction.watsup:194.1-196.32 rule table.set-val {i : nat, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) - -- if (i < |$table(z, x)|) + -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:203.1-204.102 + ;; 6-reduction.watsup:204.1-205.107 rule table.grow-succeed {n : n, ref : ref, x : idx, z : state}: - `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x)|)])) + `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - ;; 6-reduction.watsup:206.1-207.64 + ;; 6-reduction.watsup:207.1-208.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:265.1-266.59 + ;; 6-reduction.watsup:266.1-267.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:286.1-288.48 + ;; 6-reduction.watsup:287.1-289.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- where ?(o0) = $size($valtype_numtype(nt)) - -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:290.1-292.35 + ;; 6-reduction.watsup:291.1-293.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (o0 / 8), b*{b}), [])) -- where ?(o0) = $size($valtype_numtype(nt)) -- where ?(o1) = $size($valtype_numtype(nt)) -- where b*{b} = $bytes_(o1, c) - ;; 6-reduction.watsup:294.1-296.40 + ;; 6-reduction.watsup:295.1-297.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) - -- if (((i + n_O) + (n / 8)) > |$mem(z, 0)|) + -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:298.1-300.50 + ;; 6-reduction.watsup:299.1-301.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- where ?(o0) = $size($valtype_numtype(nt)) -- where b*{b} = $bytes_(n, $wrap_((o0, n), c)) - ;; 6-reduction.watsup:308.1-309.117 + ;; 6-reduction.watsup:309.1-310.122 rule memory.grow-succeed {n : n, z : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0)| / (64 * $Ki)))])) + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - ;; 6-reduction.watsup:311.1-312.59 + ;; 6-reduction.watsup:312.1-313.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:370.1-371.59 + ;; 6-reduction.watsup:371.1-372.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) diff --git a/spectec/test-prose/TEST.md b/spectec/test-prose/TEST.md index ae94410189..427cbb156a 100644 --- a/spectec/test-prose/TEST.md +++ b/spectec/test-prose/TEST.md @@ -9,9 +9,9 @@ watsup 0.3 generator == Running pass sideconditions == IL Validation... == Running pass animate -Animation failed:if ($funcinst(z)[a] = `%;%`(m, `FUNC%%*%`(ft', t*{t}, instr*{instr}))) -Animation failed:if ($bytes_($size(nt <: valtype), c) = $mem(z, 0)[(i + n_O) : ($size(nt <: valtype) / 8)]) -Animation failed:if ($bytes_(n, c) = $mem(z, 0)[(i + n_O) : (n / 8)]) +Animation failed:if ($funcinst(z)[a].CODE_funcinst = `FUNC%%*%`(ft', t*{t}, instr*{instr})) +Animation failed:if ($bytes_($size(nt <: valtype), c) = $mem(z, 0).DATA_meminst[(i + n_O) : ($size(nt <: valtype) / 8)]) +Animation failed:if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) == IL Validation... == Prose Generation... unreachable @@ -175,7 +175,7 @@ local.get 1. Push YetE (($local(z, x) <: admininstr)) to the stack. global.get -1. Push YetE (($global(z, x) <: admininstr)) to the stack. +1. Push YetE (($global(z, x).VALUE_globalinst <: admininstr)) to the stack. table.get 1. Assert: Due to validation, a value of value type i32 is on the top of the stack. @@ -183,7 +183,7 @@ table.get 3. If YetC (), then: a. Trap. 4. If YetC (), then: - a. Push YetE (($table(z, x)[i] <: admininstr)) to the stack. + a. Push YetE (($table(z, x).ELEM_tableinst[i] <: admininstr)) to the stack. table.size 1. Push YetE (CONST_admininstr(I32_numtype, n)) to the stack. @@ -251,7 +251,7 @@ table.init a. Do nothing. 9. If YetC (), then: a. Push YetE (CONST_admininstr(I32_numtype, j)) to the stack. - b. Push YetE (($elem(z, y)[i] <: admininstr)) to the stack. + b. Push YetE (($elem(z, y).ELEM_eleminst[i] <: admininstr)) to the stack. c. Execute (TABLE.SET YetE (x)). d. Push YetE (CONST_admininstr(I32_numtype, (j + 1))) to the stack. e. Push YetE (CONST_admininstr(I32_numtype, (i + 1))) to the stack. @@ -336,7 +336,7 @@ memory.init a. Do nothing. 9. If YetC (), then: a. Push YetE (CONST_admininstr(I32_numtype, j)) to the stack. - b. Push YetE (CONST_admininstr(I32_numtype, $data(z, x)[i])) to the stack. + b. Push YetE (CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i])) to the stack. c. Execute (STORE YetE (I32_numtype) YetE (?(8)) YetE (0) YetE (0)). d. Push YetE (CONST_admininstr(I32_numtype, (j + 1))) to the stack. e. Push YetE (CONST_admininstr(I32_numtype, (i + 1))) to the stack. @@ -371,7 +371,7 @@ table.grow 4. Pop YetE ((ref <: admininstr)) from the stack. 5. If YetC (), then: a. YetI: Perform $with_tableext(z, x, ref^n{}). - b. Push YetE (CONST_admininstr(I32_numtype, |$table(z, x)|)) to the stack. + b. Push YetE (CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)) to the stack. 6. If YetC (), then: a. YetI: Perform z. b. Push YetE (CONST_admininstr(I32_numtype, - 1)) to the stack. @@ -400,7 +400,7 @@ memory.grow 2. Pop YetE (CONST_admininstr(I32_numtype, n)) from the stack. 3. If YetC (), then: a. YetI: Perform $with_memext(z, 0, 0^((n * 64) * $Ki){}). - b. Push YetE (CONST_admininstr(I32_numtype, (|$mem(z, 0)| / (64 * $Ki)))) to the stack. + b. Push YetE (CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))) to the stack. 4. If YetC (), then: a. YetI: Perform z. b. Push YetE (CONST_admininstr(I32_numtype, - 1)) to the stack. From a1c51f917197aa3037fcee2a818cab235855f03d Mon Sep 17 00:00:00 2001 From: Wonho Date: Tue, 13 Jun 2023 17:40:08 +0900 Subject: [PATCH 02/49] Add limits check in grow reduction rules --- spectec/spec/6-reduction.watsup | 4 + spectec/test-frontend/TEST.md | 86 ++--- spectec/test-middlend/TEST.md | 546 +++++++++++++++++--------------- 3 files changed, 338 insertions(+), 298 deletions(-) diff --git a/spectec/spec/6-reduction.watsup b/spectec/spec/6-reduction.watsup index 4e92cf743c..c7c63f81e9 100644 --- a/spectec/spec/6-reduction.watsup +++ b/spectec/spec/6-reduction.watsup @@ -203,6 +203,8 @@ rule Step_read/table.size: rule Step/table.grow-succeed: z; ref (CONST I32 n) (TABLE.GROW x) ~> $with_tableext(z, x, ref^n); (CONST I32 $(|$table(z, x).ELEM|)) + -- if $table(z, 0).TYPE = tabletype + -- Tabletype_ok: |- tabletype : OK rule Step/table.grow-fail: z; ref (CONST I32 n) (TABLE.GROW x) ~> z; (CONST I32 $(-1)) @@ -308,6 +310,8 @@ rule Step_read/memory.size: rule Step/memory.grow-succeed: z; (CONST I32 n) (MEMORY.GROW) ~> $with_memext(z, 0, 0^(n * 64 * $Ki)); (CONST I32 $(|$mem(z, 0).DATA| / (64 * $Ki))) + -- if $mem(z, 0).TYPE = memtype + -- Memtype_ok: |- memtype : OK rule Step/memory.grow-fail: z; (CONST I32 n) (MEMORY.GROW) ~> z; (CONST I32 $(-1)) diff --git a/spectec/test-frontend/TEST.md b/spectec/test-frontend/TEST.md index b32ad7760b..db35d72632 100644 --- a/spectec/test-frontend/TEST.md +++ b/spectec/test-frontend/TEST.md @@ -1429,135 +1429,135 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:211.1-213.39 + ;; 6-reduction.watsup:213.1-215.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:215.1-218.14 + ;; 6-reduction.watsup:217.1-220.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:220.1-224.15 + ;; 6-reduction.watsup:222.1-226.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) (val <: admininstr) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) (val <: admininstr) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:227.1-229.73 + ;; 6-reduction.watsup:229.1-231.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:231.1-234.14 + ;; 6-reduction.watsup:233.1-236.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:236.1-241.15 + ;; 6-reduction.watsup:238.1-243.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:243.1-247.15 + ;; 6-reduction.watsup:245.1-249.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:250.1-252.72 + ;; 6-reduction.watsup:252.1-254.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:254.1-257.14 + ;; 6-reduction.watsup:256.1-259.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:259.1-263.15 + ;; 6-reduction.watsup:261.1-265.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) ($elem(z, y).ELEM_eleminst[i] <: admininstr) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:270.1-272.53 + ;; 6-reduction.watsup:272.1-274.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + ($size(nt <: valtype) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:274.1-276.71 + ;; 6-reduction.watsup:276.1-278.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- if ($bytes_($size(nt <: valtype), c) = $mem(z, 0).DATA_meminst[(i + n_O) : ($size(nt <: valtype) / 8)]) - ;; 6-reduction.watsup:278.1-280.45 + ;; 6-reduction.watsup:280.1-282.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:282.1-284.55 + ;; 6-reduction.watsup:284.1-286.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, $size(nt <: valtype), sx, c))]) -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:304.1-306.44 + ;; 6-reduction.watsup:306.1-308.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:316.1-318.37 + ;; 6-reduction.watsup:320.1-322.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:320.1-323.14 + ;; 6-reduction.watsup:324.1-327.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:325.1-329.15 + ;; 6-reduction.watsup:329.1-333.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) (val <: admininstr) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) (val <: admininstr) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:332.1-334.69 + ;; 6-reduction.watsup:336.1-338.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:336.1-339.14 + ;; 6-reduction.watsup:340.1-343.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:341.1-346.15 + ;; 6-reduction.watsup:345.1-350.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:348.1-352.15 + ;; 6-reduction.watsup:352.1-356.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:355.1-357.70 + ;; 6-reduction.watsup:359.1-361.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:359.1-362.14 + ;; 6-reduction.watsup:363.1-366.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:364.1-368.15 + ;; 6-reduction.watsup:368.1-372.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise @@ -1592,47 +1592,51 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (ref <: admininstr) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-205.107 - rule table.grow-succeed {n : n, ref : ref, x : idx, z : state}: + ;; 6-reduction.watsup:204.1-207.37 + rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state}: `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($table(z, 0).TYPE_tableinst = tabletype) + -- Tabletype_ok: `|-%:OK`(tabletype) - ;; 6-reduction.watsup:207.1-208.64 + ;; 6-reduction.watsup:209.1-210.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:266.1-267.59 + ;; 6-reduction.watsup:268.1-269.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:287.1-289.53 + ;; 6-reduction.watsup:289.1-291.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + ($size(nt <: valtype) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:291.1-293.35 + ;; 6-reduction.watsup:293.1-295.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), ($size(nt <: valtype) / 8), b*{b}), [])) -- if (b*{b} = $bytes_($size(nt <: valtype), c)) - ;; 6-reduction.watsup:295.1-297.45 + ;; 6-reduction.watsup:297.1-299.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:299.1-301.50 + ;; 6-reduction.watsup:301.1-303.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if (b*{b} = $bytes_(n, $wrap_(($size(nt <: valtype), n), c))) - ;; 6-reduction.watsup:309.1-310.122 - rule memory.grow-succeed {n : n, z : state}: + ;; 6-reduction.watsup:311.1-314.33 + rule memory.grow-succeed {memtype : memtype, n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($mem(z, 0).TYPE_meminst = memtype) + -- Memtype_ok: `|-%:OK`(memtype) - ;; 6-reduction.watsup:312.1-313.59 + ;; 6-reduction.watsup:316.1-317.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:371.1-372.59 + ;; 6-reduction.watsup:375.1-376.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) @@ -3590,7 +3594,9 @@ $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}table.grow{-}succeed}]} \quad & \mathit{z} ; \mathit{ref}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.grow}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{table}[\mathit{x}].\mathsf{elem} = ..{\mathit{ref}^{\mathit{n}}}] ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~{|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}.\mathsf{elem}|}) & \\ +{[\textsc{\scriptsize E{-}table.grow{-}succeed}]} \quad & \mathit{z} ; \mathit{ref}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.grow}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{table}[\mathit{x}].\mathsf{elem} = ..{\mathit{ref}^{\mathit{n}}}] ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~{|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}.\mathsf{elem}|}) &\quad + \mbox{if}~{\mathit{z}.\mathsf{table}}{[0]}.\mathsf{type} = \mathit{tabletype} \\ + &&&&\quad {\land}~{ \vdash }\;\mathit{tabletype} : \mathsf{ok} \\ {[\textsc{\scriptsize E{-}table.grow{-}fail}]} \quad & \mathit{z} ; \mathit{ref}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.grow}~\mathit{x}) &\hookrightarrow& \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~-1) & \\ \end{array} $$ @@ -3687,7 +3693,9 @@ $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}memory.grow{-}succeed}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.grow}) &\hookrightarrow& \mathit{z}[\mathsf{mem}[0].\mathsf{data} = ..{0^{\mathit{n} \cdot 64 \cdot \mathrm{Ki}}}] ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~{|{\mathit{z}.\mathsf{mem}}{[0]}.\mathsf{data}|} / (64 \cdot \mathrm{Ki})) & \\ +{[\textsc{\scriptsize E{-}memory.grow{-}succeed}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.grow}) &\hookrightarrow& \mathit{z}[\mathsf{mem}[0].\mathsf{data} = ..{0^{\mathit{n} \cdot 64 \cdot \mathrm{Ki}}}] ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~{|{\mathit{z}.\mathsf{mem}}{[0]}.\mathsf{data}|} / (64 \cdot \mathrm{Ki})) &\quad + \mbox{if}~{\mathit{z}.\mathsf{mem}}{[0]}.\mathsf{type} = \mathit{memtype} \\ + &&&&\quad {\land}~{ \vdash }\;\mathit{memtype} : \mathsf{ok} \\ {[\textsc{\scriptsize E{-}memory.grow{-}fail}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.grow}) &\hookrightarrow& \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~-1) & \\ \end{array} $$ diff --git a/spectec/test-middlend/TEST.md b/spectec/test-middlend/TEST.md index 067e52faf8..89b249fd18 100644 --- a/spectec/test-middlend/TEST.md +++ b/spectec/test-middlend/TEST.md @@ -1428,135 +1428,135 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:211.1-213.39 + ;; 6-reduction.watsup:213.1-215.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:215.1-218.14 + ;; 6-reduction.watsup:217.1-220.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:220.1-224.15 + ;; 6-reduction.watsup:222.1-226.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) (val <: admininstr) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) (val <: admininstr) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:227.1-229.73 + ;; 6-reduction.watsup:229.1-231.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:231.1-234.14 + ;; 6-reduction.watsup:233.1-236.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:236.1-241.15 + ;; 6-reduction.watsup:238.1-243.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:243.1-247.15 + ;; 6-reduction.watsup:245.1-249.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:250.1-252.72 + ;; 6-reduction.watsup:252.1-254.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:254.1-257.14 + ;; 6-reduction.watsup:256.1-259.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:259.1-263.15 + ;; 6-reduction.watsup:261.1-265.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) ($elem(z, y).ELEM_eleminst[i] <: admininstr) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:270.1-272.53 + ;; 6-reduction.watsup:272.1-274.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + ($size(nt <: valtype) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:274.1-276.71 + ;; 6-reduction.watsup:276.1-278.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- if ($bytes_($size(nt <: valtype), c) = $mem(z, 0).DATA_meminst[(i + n_O) : ($size(nt <: valtype) / 8)]) - ;; 6-reduction.watsup:278.1-280.45 + ;; 6-reduction.watsup:280.1-282.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:282.1-284.55 + ;; 6-reduction.watsup:284.1-286.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, $size(nt <: valtype), sx, c))]) -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:304.1-306.44 + ;; 6-reduction.watsup:306.1-308.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:316.1-318.37 + ;; 6-reduction.watsup:320.1-322.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:320.1-323.14 + ;; 6-reduction.watsup:324.1-327.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:325.1-329.15 + ;; 6-reduction.watsup:329.1-333.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) (val <: admininstr) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) (val <: admininstr) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:332.1-334.69 + ;; 6-reduction.watsup:336.1-338.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:336.1-339.14 + ;; 6-reduction.watsup:340.1-343.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:341.1-346.15 + ;; 6-reduction.watsup:345.1-350.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:348.1-352.15 + ;; 6-reduction.watsup:352.1-356.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:355.1-357.70 + ;; 6-reduction.watsup:359.1-361.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:359.1-362.14 + ;; 6-reduction.watsup:363.1-366.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:364.1-368.15 + ;; 6-reduction.watsup:368.1-372.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise @@ -1591,47 +1591,51 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (ref <: admininstr) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-205.107 - rule table.grow-succeed {n : n, ref : ref, x : idx, z : state}: + ;; 6-reduction.watsup:204.1-207.37 + rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state}: `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($table(z, 0).TYPE_tableinst = tabletype) + -- Tabletype_ok: `|-%:OK`(tabletype) - ;; 6-reduction.watsup:207.1-208.64 + ;; 6-reduction.watsup:209.1-210.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:266.1-267.59 + ;; 6-reduction.watsup:268.1-269.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:287.1-289.53 + ;; 6-reduction.watsup:289.1-291.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + ($size(nt <: valtype) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:291.1-293.35 + ;; 6-reduction.watsup:293.1-295.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), ($size(nt <: valtype) / 8), b*{b}), [])) -- if (b*{b} = $bytes_($size(nt <: valtype), c)) - ;; 6-reduction.watsup:295.1-297.45 + ;; 6-reduction.watsup:297.1-299.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:299.1-301.50 + ;; 6-reduction.watsup:301.1-303.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if (b*{b} = $bytes_(n, $wrap_(($size(nt <: valtype), n), c))) - ;; 6-reduction.watsup:309.1-310.122 - rule memory.grow-succeed {n : n, z : state}: + ;; 6-reduction.watsup:311.1-314.33 + rule memory.grow-succeed {memtype : memtype, n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($mem(z, 0).TYPE_meminst = memtype) + -- Memtype_ok: `|-%:OK`(memtype) - ;; 6-reduction.watsup:312.1-313.59 + ;; 6-reduction.watsup:316.1-317.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:371.1-372.59 + ;; 6-reduction.watsup:375.1-376.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) @@ -3147,135 +3151,135 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:211.1-213.39 + ;; 6-reduction.watsup:213.1-215.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:215.1-218.14 + ;; 6-reduction.watsup:217.1-220.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:220.1-224.15 + ;; 6-reduction.watsup:222.1-226.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:227.1-229.73 + ;; 6-reduction.watsup:229.1-231.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:231.1-234.14 + ;; 6-reduction.watsup:233.1-236.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:236.1-241.15 + ;; 6-reduction.watsup:238.1-243.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:243.1-247.15 + ;; 6-reduction.watsup:245.1-249.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:250.1-252.72 + ;; 6-reduction.watsup:252.1-254.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:254.1-257.14 + ;; 6-reduction.watsup:256.1-259.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:259.1-263.15 + ;; 6-reduction.watsup:261.1-265.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y).ELEM_eleminst[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:270.1-272.53 + ;; 6-reduction.watsup:272.1-274.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + ($size($valtype_numtype(nt)) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:274.1-276.71 + ;; 6-reduction.watsup:276.1-278.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- if ($bytes_($size($valtype_numtype(nt)), c) = $mem(z, 0).DATA_meminst[(i + n_O) : ($size($valtype_numtype(nt)) / 8)]) - ;; 6-reduction.watsup:278.1-280.45 + ;; 6-reduction.watsup:280.1-282.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:282.1-284.55 + ;; 6-reduction.watsup:284.1-286.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, $size($valtype_numtype(nt)), sx, c))]) -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:304.1-306.44 + ;; 6-reduction.watsup:306.1-308.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:316.1-318.37 + ;; 6-reduction.watsup:320.1-322.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:320.1-323.14 + ;; 6-reduction.watsup:324.1-327.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:325.1-329.15 + ;; 6-reduction.watsup:329.1-333.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:332.1-334.69 + ;; 6-reduction.watsup:336.1-338.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:336.1-339.14 + ;; 6-reduction.watsup:340.1-343.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:341.1-346.15 + ;; 6-reduction.watsup:345.1-350.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:348.1-352.15 + ;; 6-reduction.watsup:352.1-356.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:355.1-357.70 + ;; 6-reduction.watsup:359.1-361.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:359.1-362.14 + ;; 6-reduction.watsup:363.1-366.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:364.1-368.15 + ;; 6-reduction.watsup:368.1-372.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise @@ -3310,47 +3314,51 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-205.107 - rule table.grow-succeed {n : n, ref : ref, x : idx, z : state}: + ;; 6-reduction.watsup:204.1-207.37 + rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($table(z, 0).TYPE_tableinst = tabletype) + -- Tabletype_ok: `|-%:OK`(tabletype) - ;; 6-reduction.watsup:207.1-208.64 + ;; 6-reduction.watsup:209.1-210.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:266.1-267.59 + ;; 6-reduction.watsup:268.1-269.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:287.1-289.53 + ;; 6-reduction.watsup:289.1-291.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + ($size($valtype_numtype(nt)) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:291.1-293.35 + ;; 6-reduction.watsup:293.1-295.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), ($size($valtype_numtype(nt)) / 8), b*{b}), [])) -- if (b*{b} = $bytes_($size($valtype_numtype(nt)), c)) - ;; 6-reduction.watsup:295.1-297.45 + ;; 6-reduction.watsup:297.1-299.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:299.1-301.50 + ;; 6-reduction.watsup:301.1-303.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if (b*{b} = $bytes_(n, $wrap_(($size($valtype_numtype(nt)), n), c))) - ;; 6-reduction.watsup:309.1-310.122 - rule memory.grow-succeed {n : n, z : state}: + ;; 6-reduction.watsup:311.1-314.33 + rule memory.grow-succeed {memtype : memtype, n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($mem(z, 0).TYPE_meminst = memtype) + -- Memtype_ok: `|-%:OK`(memtype) - ;; 6-reduction.watsup:312.1-313.59 + ;; 6-reduction.watsup:316.1-317.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:371.1-372.59 + ;; 6-reduction.watsup:375.1-376.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) @@ -4868,135 +4876,135 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:211.1-213.39 + ;; 6-reduction.watsup:213.1-215.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:215.1-218.14 + ;; 6-reduction.watsup:217.1-220.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:220.1-224.15 + ;; 6-reduction.watsup:222.1-226.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:227.1-229.73 + ;; 6-reduction.watsup:229.1-231.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:231.1-234.14 + ;; 6-reduction.watsup:233.1-236.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:236.1-241.15 + ;; 6-reduction.watsup:238.1-243.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:243.1-247.15 + ;; 6-reduction.watsup:245.1-249.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:250.1-252.72 + ;; 6-reduction.watsup:252.1-254.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:254.1-257.14 + ;; 6-reduction.watsup:256.1-259.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:259.1-263.15 + ;; 6-reduction.watsup:261.1-265.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y).ELEM_eleminst[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:270.1-272.53 + ;; 6-reduction.watsup:272.1-274.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (!($size($valtype_numtype(nt))) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:274.1-276.71 + ;; 6-reduction.watsup:276.1-278.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- if ($bytes_(!($size($valtype_numtype(nt))), c) = $mem(z, 0).DATA_meminst[(i + n_O) : (!($size($valtype_numtype(nt))) / 8)]) - ;; 6-reduction.watsup:278.1-280.45 + ;; 6-reduction.watsup:280.1-282.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:282.1-284.55 + ;; 6-reduction.watsup:284.1-286.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, !($size($valtype_numtype(nt))), sx, c))]) -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:304.1-306.44 + ;; 6-reduction.watsup:306.1-308.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:316.1-318.37 + ;; 6-reduction.watsup:320.1-322.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:320.1-323.14 + ;; 6-reduction.watsup:324.1-327.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:325.1-329.15 + ;; 6-reduction.watsup:329.1-333.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:332.1-334.69 + ;; 6-reduction.watsup:336.1-338.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:336.1-339.14 + ;; 6-reduction.watsup:340.1-343.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:341.1-346.15 + ;; 6-reduction.watsup:345.1-350.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:348.1-352.15 + ;; 6-reduction.watsup:352.1-356.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:355.1-357.70 + ;; 6-reduction.watsup:359.1-361.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:359.1-362.14 + ;; 6-reduction.watsup:363.1-366.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:364.1-368.15 + ;; 6-reduction.watsup:368.1-372.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise @@ -5031,47 +5039,51 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-205.107 - rule table.grow-succeed {n : n, ref : ref, x : idx, z : state}: + ;; 6-reduction.watsup:204.1-207.37 + rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($table(z, 0).TYPE_tableinst = tabletype) + -- Tabletype_ok: `|-%:OK`(tabletype) - ;; 6-reduction.watsup:207.1-208.64 + ;; 6-reduction.watsup:209.1-210.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:266.1-267.59 + ;; 6-reduction.watsup:268.1-269.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:287.1-289.53 + ;; 6-reduction.watsup:289.1-291.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (!($size($valtype_numtype(nt))) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:291.1-293.35 + ;; 6-reduction.watsup:293.1-295.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (!($size($valtype_numtype(nt))) / 8), b*{b}), [])) -- if (b*{b} = $bytes_(!($size($valtype_numtype(nt))), c)) - ;; 6-reduction.watsup:295.1-297.45 + ;; 6-reduction.watsup:297.1-299.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:299.1-301.50 + ;; 6-reduction.watsup:301.1-303.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if (b*{b} = $bytes_(n, $wrap_((!($size($valtype_numtype(nt))), n), c))) - ;; 6-reduction.watsup:309.1-310.122 - rule memory.grow-succeed {n : n, z : state}: + ;; 6-reduction.watsup:311.1-314.33 + rule memory.grow-succeed {memtype : memtype, n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($mem(z, 0).TYPE_meminst = memtype) + -- Memtype_ok: `|-%:OK`(memtype) - ;; 6-reduction.watsup:312.1-313.59 + ;; 6-reduction.watsup:316.1-317.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:371.1-372.59 + ;; 6-reduction.watsup:375.1-376.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) @@ -6600,139 +6612,139 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:211.1-213.39 + ;; 6-reduction.watsup:213.1-215.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:215.1-218.14 + ;; 6-reduction.watsup:217.1-220.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:220.1-224.15 + ;; 6-reduction.watsup:222.1-226.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:227.1-229.73 + ;; 6-reduction.watsup:229.1-231.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:231.1-234.14 + ;; 6-reduction.watsup:233.1-236.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:236.1-241.15 + ;; 6-reduction.watsup:238.1-243.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:243.1-247.15 + ;; 6-reduction.watsup:245.1-249.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:250.1-252.72 + ;; 6-reduction.watsup:252.1-254.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:254.1-257.14 + ;; 6-reduction.watsup:256.1-259.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:259.1-263.15 + ;; 6-reduction.watsup:261.1-265.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y).ELEM_eleminst[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:270.1-272.53 + ;; 6-reduction.watsup:272.1-274.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:274.1-276.71 + ;; 6-reduction.watsup:276.1-278.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($size($valtype_numtype(nt)) = ?(o1)) -- if ($bytes_(o0, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (o1 / 8)]) - ;; 6-reduction.watsup:278.1-280.45 + ;; 6-reduction.watsup:280.1-282.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:282.1-284.55 + ;; 6-reduction.watsup:284.1-286.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, o0, sx, c))]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:304.1-306.44 + ;; 6-reduction.watsup:306.1-308.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:316.1-318.37 + ;; 6-reduction.watsup:320.1-322.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:320.1-323.14 + ;; 6-reduction.watsup:324.1-327.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:325.1-329.15 + ;; 6-reduction.watsup:329.1-333.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:332.1-334.69 + ;; 6-reduction.watsup:336.1-338.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:336.1-339.14 + ;; 6-reduction.watsup:340.1-343.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:341.1-346.15 + ;; 6-reduction.watsup:345.1-350.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:348.1-352.15 + ;; 6-reduction.watsup:352.1-356.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:355.1-357.70 + ;; 6-reduction.watsup:359.1-361.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:359.1-362.14 + ;; 6-reduction.watsup:363.1-366.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:364.1-368.15 + ;; 6-reduction.watsup:368.1-372.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise @@ -6767,51 +6779,55 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-205.107 - rule table.grow-succeed {n : n, ref : ref, x : idx, z : state}: + ;; 6-reduction.watsup:204.1-207.37 + rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($table(z, 0).TYPE_tableinst = tabletype) + -- Tabletype_ok: `|-%:OK`(tabletype) - ;; 6-reduction.watsup:207.1-208.64 + ;; 6-reduction.watsup:209.1-210.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:266.1-267.59 + ;; 6-reduction.watsup:268.1-269.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:287.1-289.53 + ;; 6-reduction.watsup:289.1-291.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:291.1-293.35 + ;; 6-reduction.watsup:293.1-295.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (o0 / 8), b*{b}), [])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($size($valtype_numtype(nt)) = ?(o1)) -- if (b*{b} = $bytes_(o1, c)) - ;; 6-reduction.watsup:295.1-297.45 + ;; 6-reduction.watsup:297.1-299.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:299.1-301.50 + ;; 6-reduction.watsup:301.1-303.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (b*{b} = $bytes_(n, $wrap_((o0, n), c))) - ;; 6-reduction.watsup:309.1-310.122 - rule memory.grow-succeed {n : n, z : state}: + ;; 6-reduction.watsup:311.1-314.33 + rule memory.grow-succeed {memtype : memtype, n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($mem(z, 0).TYPE_meminst = memtype) + -- Memtype_ok: `|-%:OK`(memtype) - ;; 6-reduction.watsup:312.1-313.59 + ;; 6-reduction.watsup:316.1-317.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:371.1-372.59 + ;; 6-reduction.watsup:375.1-376.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) @@ -8340,139 +8356,139 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:211.1-213.39 + ;; 6-reduction.watsup:213.1-215.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:215.1-218.14 + ;; 6-reduction.watsup:217.1-220.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:220.1-224.15 + ;; 6-reduction.watsup:222.1-226.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:227.1-229.73 + ;; 6-reduction.watsup:229.1-231.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:231.1-234.14 + ;; 6-reduction.watsup:233.1-236.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:236.1-241.15 + ;; 6-reduction.watsup:238.1-243.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:243.1-247.15 + ;; 6-reduction.watsup:245.1-249.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:250.1-252.72 + ;; 6-reduction.watsup:252.1-254.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:254.1-257.14 + ;; 6-reduction.watsup:256.1-259.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:259.1-263.15 + ;; 6-reduction.watsup:261.1-265.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y).ELEM_eleminst[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:270.1-272.53 + ;; 6-reduction.watsup:272.1-274.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:274.1-276.71 + ;; 6-reduction.watsup:276.1-278.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($size($valtype_numtype(nt)) = ?(o1)) -- if ($bytes_(o0, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (o1 / 8)]) - ;; 6-reduction.watsup:278.1-280.45 + ;; 6-reduction.watsup:280.1-282.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:282.1-284.55 + ;; 6-reduction.watsup:284.1-286.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, o0, sx, c))]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:304.1-306.44 + ;; 6-reduction.watsup:306.1-308.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:316.1-318.37 + ;; 6-reduction.watsup:320.1-322.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:320.1-323.14 + ;; 6-reduction.watsup:324.1-327.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:325.1-329.15 + ;; 6-reduction.watsup:329.1-333.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:332.1-334.69 + ;; 6-reduction.watsup:336.1-338.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:336.1-339.14 + ;; 6-reduction.watsup:340.1-343.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:341.1-346.15 + ;; 6-reduction.watsup:345.1-350.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:348.1-352.15 + ;; 6-reduction.watsup:352.1-356.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:355.1-357.70 + ;; 6-reduction.watsup:359.1-361.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:359.1-362.14 + ;; 6-reduction.watsup:363.1-366.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:364.1-368.15 + ;; 6-reduction.watsup:368.1-372.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise @@ -8507,51 +8523,55 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-205.107 - rule table.grow-succeed {n : n, ref : ref, x : idx, z : state}: + ;; 6-reduction.watsup:204.1-207.37 + rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($table(z, 0).TYPE_tableinst = tabletype) + -- Tabletype_ok: `|-%:OK`(tabletype) - ;; 6-reduction.watsup:207.1-208.64 + ;; 6-reduction.watsup:209.1-210.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:266.1-267.59 + ;; 6-reduction.watsup:268.1-269.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:287.1-289.53 + ;; 6-reduction.watsup:289.1-291.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:291.1-293.35 + ;; 6-reduction.watsup:293.1-295.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (o0 / 8), b*{b}), [])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($size($valtype_numtype(nt)) = ?(o1)) -- if (b*{b} = $bytes_(o1, c)) - ;; 6-reduction.watsup:295.1-297.45 + ;; 6-reduction.watsup:297.1-299.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:299.1-301.50 + ;; 6-reduction.watsup:301.1-303.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (b*{b} = $bytes_(n, $wrap_((o0, n), c))) - ;; 6-reduction.watsup:309.1-310.122 - rule memory.grow-succeed {n : n, z : state}: + ;; 6-reduction.watsup:311.1-314.33 + rule memory.grow-succeed {memtype : memtype, n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($mem(z, 0).TYPE_meminst = memtype) + -- Memtype_ok: `|-%:OK`(memtype) - ;; 6-reduction.watsup:312.1-313.59 + ;; 6-reduction.watsup:316.1-317.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:371.1-372.59 + ;; 6-reduction.watsup:375.1-376.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) @@ -10134,140 +10154,140 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:211.1-213.39 + ;; 6-reduction.watsup:213.1-215.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:215.1-218.14 + ;; 6-reduction.watsup:217.1-220.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:220.1-224.15 + ;; 6-reduction.watsup:222.1-226.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:227.1-229.73 + ;; 6-reduction.watsup:229.1-231.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:231.1-234.14 + ;; 6-reduction.watsup:233.1-236.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:236.1-241.15 + ;; 6-reduction.watsup:238.1-243.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:243.1-247.15 + ;; 6-reduction.watsup:245.1-249.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:250.1-252.72 + ;; 6-reduction.watsup:252.1-254.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:254.1-257.14 + ;; 6-reduction.watsup:256.1-259.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:259.1-263.15 + ;; 6-reduction.watsup:261.1-265.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y).ELEM_eleminst[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- if (i < |$elem(z, y).ELEM_eleminst|) -- otherwise - ;; 6-reduction.watsup:270.1-272.53 + ;; 6-reduction.watsup:272.1-274.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:274.1-276.71 + ;; 6-reduction.watsup:276.1-278.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($size($valtype_numtype(nt)) = ?(o1)) -- if ($bytes_(o0, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (o1 / 8)]) - ;; 6-reduction.watsup:278.1-280.45 + ;; 6-reduction.watsup:280.1-282.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:282.1-284.55 + ;; 6-reduction.watsup:284.1-286.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, o0, sx, c))]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:304.1-306.44 + ;; 6-reduction.watsup:306.1-308.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:316.1-318.37 + ;; 6-reduction.watsup:320.1-322.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:320.1-323.14 + ;; 6-reduction.watsup:324.1-327.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:325.1-329.15 + ;; 6-reduction.watsup:329.1-333.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:332.1-334.69 + ;; 6-reduction.watsup:336.1-338.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:336.1-339.14 + ;; 6-reduction.watsup:340.1-343.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:341.1-346.15 + ;; 6-reduction.watsup:345.1-350.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:348.1-352.15 + ;; 6-reduction.watsup:352.1-356.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:355.1-357.70 + ;; 6-reduction.watsup:359.1-361.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:359.1-362.14 + ;; 6-reduction.watsup:363.1-366.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:364.1-368.15 + ;; 6-reduction.watsup:368.1-372.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- if (i < |$data(z, x).DATA_datainst|) @@ -10303,51 +10323,55 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-205.107 - rule table.grow-succeed {n : n, ref : ref, x : idx, z : state}: + ;; 6-reduction.watsup:204.1-207.37 + rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($table(z, 0).TYPE_tableinst = tabletype) + -- Tabletype_ok: `|-%:OK`(tabletype) - ;; 6-reduction.watsup:207.1-208.64 + ;; 6-reduction.watsup:209.1-210.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:266.1-267.59 + ;; 6-reduction.watsup:268.1-269.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:287.1-289.53 + ;; 6-reduction.watsup:289.1-291.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:291.1-293.35 + ;; 6-reduction.watsup:293.1-295.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (o0 / 8), b*{b}), [])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($size($valtype_numtype(nt)) = ?(o1)) -- if (b*{b} = $bytes_(o1, c)) - ;; 6-reduction.watsup:295.1-297.45 + ;; 6-reduction.watsup:297.1-299.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:299.1-301.50 + ;; 6-reduction.watsup:301.1-303.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (b*{b} = $bytes_(n, $wrap_((o0, n), c))) - ;; 6-reduction.watsup:309.1-310.122 - rule memory.grow-succeed {n : n, z : state}: + ;; 6-reduction.watsup:311.1-314.33 + rule memory.grow-succeed {memtype : memtype, n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($mem(z, 0).TYPE_meminst = memtype) + -- Memtype_ok: `|-%:OK`(memtype) - ;; 6-reduction.watsup:312.1-313.59 + ;; 6-reduction.watsup:316.1-317.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:371.1-372.59 + ;; 6-reduction.watsup:375.1-376.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) @@ -11933,140 +11957,140 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) -- where n = |$table(z, x).ELEM_tableinst| - ;; 6-reduction.watsup:211.1-213.39 + ;; 6-reduction.watsup:213.1-215.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:215.1-218.14 + ;; 6-reduction.watsup:217.1-220.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:220.1-224.15 + ;; 6-reduction.watsup:222.1-226.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:227.1-229.73 + ;; 6-reduction.watsup:229.1-231.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:231.1-234.14 + ;; 6-reduction.watsup:233.1-236.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:236.1-241.15 + ;; 6-reduction.watsup:238.1-243.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:243.1-247.15 + ;; 6-reduction.watsup:245.1-249.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:250.1-252.72 + ;; 6-reduction.watsup:252.1-254.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:254.1-257.14 + ;; 6-reduction.watsup:256.1-259.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:259.1-263.15 + ;; 6-reduction.watsup:261.1-265.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y).ELEM_eleminst[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise -- if (i < |$elem(z, y).ELEM_eleminst|) - ;; 6-reduction.watsup:270.1-272.53 + ;; 6-reduction.watsup:272.1-274.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- where ?(o0) = $size($valtype_numtype(nt)) -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:274.1-276.71 + ;; 6-reduction.watsup:276.1-278.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- where ?(o0) = $size($valtype_numtype(nt)) -- where ?(o1) = $size($valtype_numtype(nt)) -- where $bytes_(o0, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (o1 / 8)] - ;; 6-reduction.watsup:278.1-280.45 + ;; 6-reduction.watsup:280.1-282.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:282.1-284.55 + ;; 6-reduction.watsup:284.1-286.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, o0, sx, c))]) -- where ?(o0) = $size($valtype_numtype(nt)) -- where $bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)] - ;; 6-reduction.watsup:304.1-306.44 + ;; 6-reduction.watsup:306.1-308.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) -- where ((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst| - ;; 6-reduction.watsup:316.1-318.37 + ;; 6-reduction.watsup:320.1-322.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:320.1-323.14 + ;; 6-reduction.watsup:324.1-327.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:325.1-329.15 + ;; 6-reduction.watsup:329.1-333.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:332.1-334.69 + ;; 6-reduction.watsup:336.1-338.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:336.1-339.14 + ;; 6-reduction.watsup:340.1-343.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:341.1-346.15 + ;; 6-reduction.watsup:345.1-350.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:348.1-352.15 + ;; 6-reduction.watsup:352.1-356.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:355.1-357.70 + ;; 6-reduction.watsup:359.1-361.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:359.1-362.14 + ;; 6-reduction.watsup:363.1-366.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:364.1-368.15 + ;; 6-reduction.watsup:368.1-372.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise @@ -12102,51 +12126,55 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-205.107 - rule table.grow-succeed {n : n, ref : ref, x : idx, z : state}: + ;; 6-reduction.watsup:204.1-207.37 + rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- where tabletype = $table(z, 0).TYPE_tableinst + -- Tabletype_ok: `|-%:OK`(tabletype) - ;; 6-reduction.watsup:207.1-208.64 + ;; 6-reduction.watsup:209.1-210.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:266.1-267.59 + ;; 6-reduction.watsup:268.1-269.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:287.1-289.53 + ;; 6-reduction.watsup:289.1-291.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- where ?(o0) = $size($valtype_numtype(nt)) -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:291.1-293.35 + ;; 6-reduction.watsup:293.1-295.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (o0 / 8), b*{b}), [])) -- where ?(o0) = $size($valtype_numtype(nt)) -- where ?(o1) = $size($valtype_numtype(nt)) -- where b*{b} = $bytes_(o1, c) - ;; 6-reduction.watsup:295.1-297.45 + ;; 6-reduction.watsup:297.1-299.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:299.1-301.50 + ;; 6-reduction.watsup:301.1-303.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- where ?(o0) = $size($valtype_numtype(nt)) -- where b*{b} = $bytes_(n, $wrap_((o0, n), c)) - ;; 6-reduction.watsup:309.1-310.122 - rule memory.grow-succeed {n : n, z : state}: + ;; 6-reduction.watsup:311.1-314.33 + rule memory.grow-succeed {memtype : memtype, n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- where memtype = $mem(z, 0).TYPE_meminst + -- Memtype_ok: `|-%:OK`(memtype) - ;; 6-reduction.watsup:312.1-313.59 + ;; 6-reduction.watsup:316.1-317.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:371.1-372.59 + ;; 6-reduction.watsup:375.1-376.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) From 5380d7697b6086bb0584e8bfedb8544063a89b35 Mon Sep 17 00:00:00 2001 From: Wonho Date: Wed, 14 Jun 2023 20:39:12 +0900 Subject: [PATCH 03/49] Add type field in eleminst --- spectec/spec/4-runtime.watsup | 3 +- spectec/test-frontend/TEST.md | 97 ++--- spectec/test-middlend/TEST.md | 658 +++++++++++++++++----------------- 3 files changed, 380 insertions(+), 378 deletions(-) diff --git a/spectec/spec/4-runtime.watsup b/spectec/spec/4-runtime.watsup index 3a0cdcaca9..11982f54e3 100644 --- a/spectec/spec/4-runtime.watsup +++ b/spectec/spec/4-runtime.watsup @@ -65,7 +65,8 @@ syntax meminst hint(desc "memory instance") = { TYPE memtype, DATA byte* } syntax eleminst hint(desc "element instance") = - { ELEM ref* } + { TYPE elemtype, + ELEM ref* } syntax datainst hint(desc "data instance") = { DATA byte* } syntax exportinst hint(desc "export instance") = diff --git a/spectec/test-frontend/TEST.md b/spectec/test-frontend/TEST.md index db35d72632..a6b7f837dd 100644 --- a/spectec/test-frontend/TEST.md +++ b/spectec/test-frontend/TEST.md @@ -1019,10 +1019,10 @@ def default_ : valtype -> val ;; 4-runtime.watsup:50.1-50.48 def default_(EXTERNREF_valtype) = REF.NULL_val(EXTERNREF_reftype) -;; 4-runtime.watsup:71.1-73.22 +;; 4-runtime.watsup:72.1-74.22 syntax exportinst = {NAME name, VALUE externval} -;; 4-runtime.watsup:83.1-90.25 +;; 4-runtime.watsup:84.1-91.25 syntax moduleinst = {FUNC funcaddr*, GLOBAL globaladdr*, TABLE tableaddr*, MEM memaddr*, ELEM elemaddr*, DATA dataaddr*, EXPORT exportinst*} ;; 4-runtime.watsup:55.1-57.16 @@ -1037,25 +1037,25 @@ syntax tableinst = {TYPE tabletype, ELEM ref*} ;; 4-runtime.watsup:64.1-66.17 syntax meminst = {TYPE memtype, DATA byte*} -;; 4-runtime.watsup:67.1-68.16 -syntax eleminst = {ELEM ref*} +;; 4-runtime.watsup:67.1-69.16 +syntax eleminst = {TYPE elemtype, ELEM ref*} -;; 4-runtime.watsup:69.1-70.17 +;; 4-runtime.watsup:70.1-71.17 syntax datainst = {DATA byte*} -;; 4-runtime.watsup:75.1-81.21 +;; 4-runtime.watsup:76.1-82.21 syntax store = {FUNC funcinst*, GLOBAL globalinst*, TABLE tableinst*, MEM meminst*, ELEM eleminst*, DATA datainst*} -;; 4-runtime.watsup:92.1-94.24 +;; 4-runtime.watsup:93.1-95.24 syntax frame = {LOCAL val*, MODULE moduleinst} -;; 4-runtime.watsup:95.1-95.47 +;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:158.1-165.5 +;; 4-runtime.watsup:159.1-166.5 rec { -;; 4-runtime.watsup:158.1-165.5 +;; 4-runtime.watsup:159.1-166.5 syntax admininstr = | UNREACHABLE | NOP @@ -1109,98 +1109,98 @@ syntax admininstr = | TRAP } -;; 4-runtime.watsup:96.1-96.62 +;; 4-runtime.watsup:97.1-97.62 syntax config = `%;%*`(state, admininstr*) -;; 4-runtime.watsup:114.1-114.59 +;; 4-runtime.watsup:115.1-115.59 def funcaddr : state -> funcaddr* - ;; 4-runtime.watsup:115.1-115.38 + ;; 4-runtime.watsup:116.1-116.38 def {f : frame, s : store} funcaddr(`%;%`(s, f)) = f.MODULE_frame.FUNC_moduleinst -;; 4-runtime.watsup:117.1-117.52 +;; 4-runtime.watsup:118.1-118.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:118.1-118.31 + ;; 4-runtime.watsup:119.1-119.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:120.1-120.67 +;; 4-runtime.watsup:121.1-121.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:128.1-128.48 + ;; 4-runtime.watsup:129.1-129.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:121.1-121.69 +;; 4-runtime.watsup:122.1-122.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:129.1-129.54 + ;; 4-runtime.watsup:130.1-130.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:122.1-122.68 +;; 4-runtime.watsup:123.1-123.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:130.1-130.51 + ;; 4-runtime.watsup:131.1-131.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:123.1-123.66 +;; 4-runtime.watsup:124.1-124.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:131.1-131.45 + ;; 4-runtime.watsup:132.1-132.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:124.1-124.67 +;; 4-runtime.watsup:125.1-125.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:132.1-132.48 + ;; 4-runtime.watsup:133.1-133.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:125.1-125.67 +;; 4-runtime.watsup:126.1-126.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:133.1-133.48 + ;; 4-runtime.watsup:134.1-134.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:126.1-126.68 +;; 4-runtime.watsup:127.1-127.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:134.1-134.35 + ;; 4-runtime.watsup:135.1-135.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:137.1-137.78 +;; 4-runtime.watsup:138.1-138.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:146.1-146.52 + ;; 4-runtime.watsup:147.1-147.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:138.1-138.85 +;; 4-runtime.watsup:139.1-139.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:147.1-147.77 + ;; 4-runtime.watsup:148.1-148.77 def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:139.1-139.88 +;; 4-runtime.watsup:140.1-140.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:148.1-148.79 + ;; 4-runtime.watsup:149.1-149.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:140.1-140.85 +;; 4-runtime.watsup:141.1-141.85 def with_tableext : (state, tableidx, ref*) -> state - ;; 4-runtime.watsup:149.1-149.80 + ;; 4-runtime.watsup:150.1-150.80 def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst =.. r*{r}], f) -;; 4-runtime.watsup:141.1-141.95 +;; 4-runtime.watsup:142.1-142.95 def with_mem : (state, tableidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:150.1-150.82 + ;; 4-runtime.watsup:151.1-151.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:142.1-142.83 +;; 4-runtime.watsup:143.1-143.83 def with_memext : (state, tableidx, byte*) -> state - ;; 4-runtime.watsup:151.1-151.74 + ;; 4-runtime.watsup:152.1-152.74 def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst =.. b*{b}], f) -;; 4-runtime.watsup:143.1-143.82 +;; 4-runtime.watsup:144.1-144.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:152.1-152.72 + ;; 4-runtime.watsup:153.1-153.72 def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:144.1-144.82 +;; 4-runtime.watsup:145.1-145.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:153.1-153.72 + ;; 4-runtime.watsup:154.1-154.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:167.1-170.21 +;; 4-runtime.watsup:168.1-171.21 rec { -;; 4-runtime.watsup:167.1-170.21 +;; 4-runtime.watsup:168.1-171.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -3184,7 +3184,8 @@ $$ \mathsf{type}~\mathit{memtype},\; \\ \mathsf{data}~{\mathit{byte}^\ast} \;\}\end{array} \\ \mbox{(element instance)} & \mathit{eleminst} &::=& \{\; \begin{array}[t]{@{}l@{}} -\mathsf{elem}~{\mathit{ref}^\ast} \;\}\end{array} \\ +\mathsf{type}~\mathit{elemtype},\; \\ + \mathsf{elem}~{\mathit{ref}^\ast} \;\}\end{array} \\ \mbox{(data instance)} & \mathit{datainst} &::=& \{\; \begin{array}[t]{@{}l@{}} \mathsf{data}~{\mathit{byte}^\ast} \;\}\end{array} \\ \mbox{(export instance)} & \mathit{exportinst} &::=& \{\; \begin{array}[t]{@{}l@{}} diff --git a/spectec/test-middlend/TEST.md b/spectec/test-middlend/TEST.md index 89b249fd18..5bba225803 100644 --- a/spectec/test-middlend/TEST.md +++ b/spectec/test-middlend/TEST.md @@ -1018,10 +1018,10 @@ def default_ : valtype -> val ;; 4-runtime.watsup:50.1-50.48 def default_(EXTERNREF_valtype) = REF.NULL_val(EXTERNREF_reftype) -;; 4-runtime.watsup:71.1-73.22 +;; 4-runtime.watsup:72.1-74.22 syntax exportinst = {NAME name, VALUE externval} -;; 4-runtime.watsup:83.1-90.25 +;; 4-runtime.watsup:84.1-91.25 syntax moduleinst = {FUNC funcaddr*, GLOBAL globaladdr*, TABLE tableaddr*, MEM memaddr*, ELEM elemaddr*, DATA dataaddr*, EXPORT exportinst*} ;; 4-runtime.watsup:55.1-57.16 @@ -1036,25 +1036,25 @@ syntax tableinst = {TYPE tabletype, ELEM ref*} ;; 4-runtime.watsup:64.1-66.17 syntax meminst = {TYPE memtype, DATA byte*} -;; 4-runtime.watsup:67.1-68.16 -syntax eleminst = {ELEM ref*} +;; 4-runtime.watsup:67.1-69.16 +syntax eleminst = {TYPE elemtype, ELEM ref*} -;; 4-runtime.watsup:69.1-70.17 +;; 4-runtime.watsup:70.1-71.17 syntax datainst = {DATA byte*} -;; 4-runtime.watsup:75.1-81.21 +;; 4-runtime.watsup:76.1-82.21 syntax store = {FUNC funcinst*, GLOBAL globalinst*, TABLE tableinst*, MEM meminst*, ELEM eleminst*, DATA datainst*} -;; 4-runtime.watsup:92.1-94.24 +;; 4-runtime.watsup:93.1-95.24 syntax frame = {LOCAL val*, MODULE moduleinst} -;; 4-runtime.watsup:95.1-95.47 +;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:158.1-165.5 +;; 4-runtime.watsup:159.1-166.5 rec { -;; 4-runtime.watsup:158.1-165.5 +;; 4-runtime.watsup:159.1-166.5 syntax admininstr = | UNREACHABLE | NOP @@ -1108,98 +1108,98 @@ syntax admininstr = | TRAP } -;; 4-runtime.watsup:96.1-96.62 +;; 4-runtime.watsup:97.1-97.62 syntax config = `%;%*`(state, admininstr*) -;; 4-runtime.watsup:114.1-114.59 +;; 4-runtime.watsup:115.1-115.59 def funcaddr : state -> funcaddr* - ;; 4-runtime.watsup:115.1-115.38 + ;; 4-runtime.watsup:116.1-116.38 def {f : frame, s : store} funcaddr(`%;%`(s, f)) = f.MODULE_frame.FUNC_moduleinst -;; 4-runtime.watsup:117.1-117.52 +;; 4-runtime.watsup:118.1-118.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:118.1-118.31 + ;; 4-runtime.watsup:119.1-119.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:120.1-120.67 +;; 4-runtime.watsup:121.1-121.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:128.1-128.48 + ;; 4-runtime.watsup:129.1-129.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:121.1-121.69 +;; 4-runtime.watsup:122.1-122.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:129.1-129.54 + ;; 4-runtime.watsup:130.1-130.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:122.1-122.68 +;; 4-runtime.watsup:123.1-123.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:130.1-130.51 + ;; 4-runtime.watsup:131.1-131.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:123.1-123.66 +;; 4-runtime.watsup:124.1-124.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:131.1-131.45 + ;; 4-runtime.watsup:132.1-132.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:124.1-124.67 +;; 4-runtime.watsup:125.1-125.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:132.1-132.48 + ;; 4-runtime.watsup:133.1-133.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:125.1-125.67 +;; 4-runtime.watsup:126.1-126.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:133.1-133.48 + ;; 4-runtime.watsup:134.1-134.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:126.1-126.68 +;; 4-runtime.watsup:127.1-127.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:134.1-134.35 + ;; 4-runtime.watsup:135.1-135.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:137.1-137.78 +;; 4-runtime.watsup:138.1-138.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:146.1-146.52 + ;; 4-runtime.watsup:147.1-147.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:138.1-138.85 +;; 4-runtime.watsup:139.1-139.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:147.1-147.77 + ;; 4-runtime.watsup:148.1-148.77 def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:139.1-139.88 +;; 4-runtime.watsup:140.1-140.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:148.1-148.79 + ;; 4-runtime.watsup:149.1-149.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:140.1-140.85 +;; 4-runtime.watsup:141.1-141.85 def with_tableext : (state, tableidx, ref*) -> state - ;; 4-runtime.watsup:149.1-149.80 + ;; 4-runtime.watsup:150.1-150.80 def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst =.. r*{r}], f) -;; 4-runtime.watsup:141.1-141.95 +;; 4-runtime.watsup:142.1-142.95 def with_mem : (state, tableidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:150.1-150.82 + ;; 4-runtime.watsup:151.1-151.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:142.1-142.83 +;; 4-runtime.watsup:143.1-143.83 def with_memext : (state, tableidx, byte*) -> state - ;; 4-runtime.watsup:151.1-151.74 + ;; 4-runtime.watsup:152.1-152.74 def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst =.. b*{b}], f) -;; 4-runtime.watsup:143.1-143.82 +;; 4-runtime.watsup:144.1-144.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:152.1-152.72 + ;; 4-runtime.watsup:153.1-153.72 def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:144.1-144.82 +;; 4-runtime.watsup:145.1-145.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:153.1-153.72 + ;; 4-runtime.watsup:154.1-154.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:167.1-170.21 +;; 4-runtime.watsup:168.1-171.21 rec { -;; 4-runtime.watsup:167.1-170.21 +;; 4-runtime.watsup:168.1-171.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -2684,10 +2684,10 @@ def default_ : valtype -> val ;; 4-runtime.watsup:50.1-50.48 def default_(EXTERNREF_valtype) = REF.NULL_val(EXTERNREF_reftype) -;; 4-runtime.watsup:71.1-73.22 +;; 4-runtime.watsup:72.1-74.22 syntax exportinst = {NAME name, VALUE externval} -;; 4-runtime.watsup:83.1-90.25 +;; 4-runtime.watsup:84.1-91.25 syntax moduleinst = {FUNC funcaddr*, GLOBAL globaladdr*, TABLE tableaddr*, MEM memaddr*, ELEM elemaddr*, DATA dataaddr*, EXPORT exportinst*} ;; 4-runtime.watsup:55.1-57.16 @@ -2702,25 +2702,25 @@ syntax tableinst = {TYPE tabletype, ELEM ref*} ;; 4-runtime.watsup:64.1-66.17 syntax meminst = {TYPE memtype, DATA byte*} -;; 4-runtime.watsup:67.1-68.16 -syntax eleminst = {ELEM ref*} +;; 4-runtime.watsup:67.1-69.16 +syntax eleminst = {TYPE elemtype, ELEM ref*} -;; 4-runtime.watsup:69.1-70.17 +;; 4-runtime.watsup:70.1-71.17 syntax datainst = {DATA byte*} -;; 4-runtime.watsup:75.1-81.21 +;; 4-runtime.watsup:76.1-82.21 syntax store = {FUNC funcinst*, GLOBAL globalinst*, TABLE tableinst*, MEM meminst*, ELEM eleminst*, DATA datainst*} -;; 4-runtime.watsup:92.1-94.24 +;; 4-runtime.watsup:93.1-95.24 syntax frame = {LOCAL val*, MODULE moduleinst} -;; 4-runtime.watsup:95.1-95.47 +;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:158.1-165.5 +;; 4-runtime.watsup:159.1-166.5 rec { -;; 4-runtime.watsup:158.1-165.5 +;; 4-runtime.watsup:159.1-166.5 syntax admininstr = | UNREACHABLE | NOP @@ -2831,98 +2831,98 @@ def admininstr_val : val -> admininstr def {x : funcaddr} admininstr_val(REF.FUNC_ADDR_val(x)) = REF.FUNC_ADDR_admininstr(x) def {x : hostaddr} admininstr_val(REF.HOST_ADDR_val(x)) = REF.HOST_ADDR_admininstr(x) -;; 4-runtime.watsup:96.1-96.62 +;; 4-runtime.watsup:97.1-97.62 syntax config = `%;%*`(state, admininstr*) -;; 4-runtime.watsup:114.1-114.59 +;; 4-runtime.watsup:115.1-115.59 def funcaddr : state -> funcaddr* - ;; 4-runtime.watsup:115.1-115.38 + ;; 4-runtime.watsup:116.1-116.38 def {f : frame, s : store} funcaddr(`%;%`(s, f)) = f.MODULE_frame.FUNC_moduleinst -;; 4-runtime.watsup:117.1-117.52 +;; 4-runtime.watsup:118.1-118.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:118.1-118.31 + ;; 4-runtime.watsup:119.1-119.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:120.1-120.67 +;; 4-runtime.watsup:121.1-121.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:128.1-128.48 + ;; 4-runtime.watsup:129.1-129.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:121.1-121.69 +;; 4-runtime.watsup:122.1-122.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:129.1-129.54 + ;; 4-runtime.watsup:130.1-130.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:122.1-122.68 +;; 4-runtime.watsup:123.1-123.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:130.1-130.51 + ;; 4-runtime.watsup:131.1-131.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:123.1-123.66 +;; 4-runtime.watsup:124.1-124.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:131.1-131.45 + ;; 4-runtime.watsup:132.1-132.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:124.1-124.67 +;; 4-runtime.watsup:125.1-125.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:132.1-132.48 + ;; 4-runtime.watsup:133.1-133.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:125.1-125.67 +;; 4-runtime.watsup:126.1-126.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:133.1-133.48 + ;; 4-runtime.watsup:134.1-134.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:126.1-126.68 +;; 4-runtime.watsup:127.1-127.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:134.1-134.35 + ;; 4-runtime.watsup:135.1-135.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:137.1-137.78 +;; 4-runtime.watsup:138.1-138.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:146.1-146.52 + ;; 4-runtime.watsup:147.1-147.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:138.1-138.85 +;; 4-runtime.watsup:139.1-139.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:147.1-147.77 + ;; 4-runtime.watsup:148.1-148.77 def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:139.1-139.88 +;; 4-runtime.watsup:140.1-140.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:148.1-148.79 + ;; 4-runtime.watsup:149.1-149.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:140.1-140.85 +;; 4-runtime.watsup:141.1-141.85 def with_tableext : (state, tableidx, ref*) -> state - ;; 4-runtime.watsup:149.1-149.80 + ;; 4-runtime.watsup:150.1-150.80 def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst =.. r*{r}], f) -;; 4-runtime.watsup:141.1-141.95 +;; 4-runtime.watsup:142.1-142.95 def with_mem : (state, tableidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:150.1-150.82 + ;; 4-runtime.watsup:151.1-151.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:142.1-142.83 +;; 4-runtime.watsup:143.1-143.83 def with_memext : (state, tableidx, byte*) -> state - ;; 4-runtime.watsup:151.1-151.74 + ;; 4-runtime.watsup:152.1-152.74 def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst =.. b*{b}], f) -;; 4-runtime.watsup:143.1-143.82 +;; 4-runtime.watsup:144.1-144.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:152.1-152.72 + ;; 4-runtime.watsup:153.1-153.72 def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:144.1-144.82 +;; 4-runtime.watsup:145.1-145.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:153.1-153.72 + ;; 4-runtime.watsup:154.1-154.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:167.1-170.21 +;; 4-runtime.watsup:168.1-171.21 rec { -;; 4-runtime.watsup:167.1-170.21 +;; 4-runtime.watsup:168.1-171.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -4409,10 +4409,10 @@ def default_ : valtype -> val? def default_(EXTERNREF_valtype) = ?(REF.NULL_val(EXTERNREF_reftype)) def {x : valtype} default_(x) = ?() -;; 4-runtime.watsup:71.1-73.22 +;; 4-runtime.watsup:72.1-74.22 syntax exportinst = {NAME name, VALUE externval} -;; 4-runtime.watsup:83.1-90.25 +;; 4-runtime.watsup:84.1-91.25 syntax moduleinst = {FUNC funcaddr*, GLOBAL globaladdr*, TABLE tableaddr*, MEM memaddr*, ELEM elemaddr*, DATA dataaddr*, EXPORT exportinst*} ;; 4-runtime.watsup:55.1-57.16 @@ -4427,25 +4427,25 @@ syntax tableinst = {TYPE tabletype, ELEM ref*} ;; 4-runtime.watsup:64.1-66.17 syntax meminst = {TYPE memtype, DATA byte*} -;; 4-runtime.watsup:67.1-68.16 -syntax eleminst = {ELEM ref*} +;; 4-runtime.watsup:67.1-69.16 +syntax eleminst = {TYPE elemtype, ELEM ref*} -;; 4-runtime.watsup:69.1-70.17 +;; 4-runtime.watsup:70.1-71.17 syntax datainst = {DATA byte*} -;; 4-runtime.watsup:75.1-81.21 +;; 4-runtime.watsup:76.1-82.21 syntax store = {FUNC funcinst*, GLOBAL globalinst*, TABLE tableinst*, MEM meminst*, ELEM eleminst*, DATA datainst*} -;; 4-runtime.watsup:92.1-94.24 +;; 4-runtime.watsup:93.1-95.24 syntax frame = {LOCAL val*, MODULE moduleinst} -;; 4-runtime.watsup:95.1-95.47 +;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:158.1-165.5 +;; 4-runtime.watsup:159.1-166.5 rec { -;; 4-runtime.watsup:158.1-165.5 +;; 4-runtime.watsup:159.1-166.5 syntax admininstr = | UNREACHABLE | NOP @@ -4556,98 +4556,98 @@ def admininstr_val : val -> admininstr def {x : funcaddr} admininstr_val(REF.FUNC_ADDR_val(x)) = REF.FUNC_ADDR_admininstr(x) def {x : hostaddr} admininstr_val(REF.HOST_ADDR_val(x)) = REF.HOST_ADDR_admininstr(x) -;; 4-runtime.watsup:96.1-96.62 +;; 4-runtime.watsup:97.1-97.62 syntax config = `%;%*`(state, admininstr*) -;; 4-runtime.watsup:114.1-114.59 +;; 4-runtime.watsup:115.1-115.59 def funcaddr : state -> funcaddr* - ;; 4-runtime.watsup:115.1-115.38 + ;; 4-runtime.watsup:116.1-116.38 def {f : frame, s : store} funcaddr(`%;%`(s, f)) = f.MODULE_frame.FUNC_moduleinst -;; 4-runtime.watsup:117.1-117.52 +;; 4-runtime.watsup:118.1-118.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:118.1-118.31 + ;; 4-runtime.watsup:119.1-119.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:120.1-120.67 +;; 4-runtime.watsup:121.1-121.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:128.1-128.48 + ;; 4-runtime.watsup:129.1-129.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:121.1-121.69 +;; 4-runtime.watsup:122.1-122.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:129.1-129.54 + ;; 4-runtime.watsup:130.1-130.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:122.1-122.68 +;; 4-runtime.watsup:123.1-123.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:130.1-130.51 + ;; 4-runtime.watsup:131.1-131.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:123.1-123.66 +;; 4-runtime.watsup:124.1-124.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:131.1-131.45 + ;; 4-runtime.watsup:132.1-132.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:124.1-124.67 +;; 4-runtime.watsup:125.1-125.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:132.1-132.48 + ;; 4-runtime.watsup:133.1-133.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:125.1-125.67 +;; 4-runtime.watsup:126.1-126.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:133.1-133.48 + ;; 4-runtime.watsup:134.1-134.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:126.1-126.68 +;; 4-runtime.watsup:127.1-127.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:134.1-134.35 + ;; 4-runtime.watsup:135.1-135.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:137.1-137.78 +;; 4-runtime.watsup:138.1-138.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:146.1-146.52 + ;; 4-runtime.watsup:147.1-147.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:138.1-138.85 +;; 4-runtime.watsup:139.1-139.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:147.1-147.77 + ;; 4-runtime.watsup:148.1-148.77 def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:139.1-139.88 +;; 4-runtime.watsup:140.1-140.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:148.1-148.79 + ;; 4-runtime.watsup:149.1-149.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:140.1-140.85 +;; 4-runtime.watsup:141.1-141.85 def with_tableext : (state, tableidx, ref*) -> state - ;; 4-runtime.watsup:149.1-149.80 + ;; 4-runtime.watsup:150.1-150.80 def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst =.. r*{r}], f) -;; 4-runtime.watsup:141.1-141.95 +;; 4-runtime.watsup:142.1-142.95 def with_mem : (state, tableidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:150.1-150.82 + ;; 4-runtime.watsup:151.1-151.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:142.1-142.83 +;; 4-runtime.watsup:143.1-143.83 def with_memext : (state, tableidx, byte*) -> state - ;; 4-runtime.watsup:151.1-151.74 + ;; 4-runtime.watsup:152.1-152.74 def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst =.. b*{b}], f) -;; 4-runtime.watsup:143.1-143.82 +;; 4-runtime.watsup:144.1-144.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:152.1-152.72 + ;; 4-runtime.watsup:153.1-153.72 def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:144.1-144.82 +;; 4-runtime.watsup:145.1-145.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:153.1-153.72 + ;; 4-runtime.watsup:154.1-154.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:167.1-170.21 +;; 4-runtime.watsup:168.1-171.21 rec { -;; 4-runtime.watsup:167.1-170.21 +;; 4-runtime.watsup:168.1-171.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -6143,10 +6143,10 @@ def default_ : valtype -> val? def default_(EXTERNREF_valtype) = ?(REF.NULL_val(EXTERNREF_reftype)) def {x : valtype} default_(x) = ?() -;; 4-runtime.watsup:71.1-73.22 +;; 4-runtime.watsup:72.1-74.22 syntax exportinst = {NAME name, VALUE externval} -;; 4-runtime.watsup:83.1-90.25 +;; 4-runtime.watsup:84.1-91.25 syntax moduleinst = {FUNC funcaddr*, GLOBAL globaladdr*, TABLE tableaddr*, MEM memaddr*, ELEM elemaddr*, DATA dataaddr*, EXPORT exportinst*} ;; 4-runtime.watsup:55.1-57.16 @@ -6161,25 +6161,25 @@ syntax tableinst = {TYPE tabletype, ELEM ref*} ;; 4-runtime.watsup:64.1-66.17 syntax meminst = {TYPE memtype, DATA byte*} -;; 4-runtime.watsup:67.1-68.16 -syntax eleminst = {ELEM ref*} +;; 4-runtime.watsup:67.1-69.16 +syntax eleminst = {TYPE elemtype, ELEM ref*} -;; 4-runtime.watsup:69.1-70.17 +;; 4-runtime.watsup:70.1-71.17 syntax datainst = {DATA byte*} -;; 4-runtime.watsup:75.1-81.21 +;; 4-runtime.watsup:76.1-82.21 syntax store = {FUNC funcinst*, GLOBAL globalinst*, TABLE tableinst*, MEM meminst*, ELEM eleminst*, DATA datainst*} -;; 4-runtime.watsup:92.1-94.24 +;; 4-runtime.watsup:93.1-95.24 syntax frame = {LOCAL val*, MODULE moduleinst} -;; 4-runtime.watsup:95.1-95.47 +;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:158.1-165.5 +;; 4-runtime.watsup:159.1-166.5 rec { -;; 4-runtime.watsup:158.1-165.5 +;; 4-runtime.watsup:159.1-166.5 syntax admininstr = | UNREACHABLE | NOP @@ -6290,98 +6290,98 @@ def admininstr_val : val -> admininstr def {x : funcaddr} admininstr_val(REF.FUNC_ADDR_val(x)) = REF.FUNC_ADDR_admininstr(x) def {x : hostaddr} admininstr_val(REF.HOST_ADDR_val(x)) = REF.HOST_ADDR_admininstr(x) -;; 4-runtime.watsup:96.1-96.62 +;; 4-runtime.watsup:97.1-97.62 syntax config = `%;%*`(state, admininstr*) -;; 4-runtime.watsup:114.1-114.59 +;; 4-runtime.watsup:115.1-115.59 def funcaddr : state -> funcaddr* - ;; 4-runtime.watsup:115.1-115.38 + ;; 4-runtime.watsup:116.1-116.38 def {f : frame, s : store} funcaddr(`%;%`(s, f)) = f.MODULE_frame.FUNC_moduleinst -;; 4-runtime.watsup:117.1-117.52 +;; 4-runtime.watsup:118.1-118.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:118.1-118.31 + ;; 4-runtime.watsup:119.1-119.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:120.1-120.67 +;; 4-runtime.watsup:121.1-121.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:128.1-128.48 + ;; 4-runtime.watsup:129.1-129.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:121.1-121.69 +;; 4-runtime.watsup:122.1-122.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:129.1-129.54 + ;; 4-runtime.watsup:130.1-130.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:122.1-122.68 +;; 4-runtime.watsup:123.1-123.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:130.1-130.51 + ;; 4-runtime.watsup:131.1-131.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:123.1-123.66 +;; 4-runtime.watsup:124.1-124.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:131.1-131.45 + ;; 4-runtime.watsup:132.1-132.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:124.1-124.67 +;; 4-runtime.watsup:125.1-125.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:132.1-132.48 + ;; 4-runtime.watsup:133.1-133.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:125.1-125.67 +;; 4-runtime.watsup:126.1-126.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:133.1-133.48 + ;; 4-runtime.watsup:134.1-134.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:126.1-126.68 +;; 4-runtime.watsup:127.1-127.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:134.1-134.35 + ;; 4-runtime.watsup:135.1-135.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:137.1-137.78 +;; 4-runtime.watsup:138.1-138.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:146.1-146.52 + ;; 4-runtime.watsup:147.1-147.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:138.1-138.85 +;; 4-runtime.watsup:139.1-139.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:147.1-147.77 + ;; 4-runtime.watsup:148.1-148.77 def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:139.1-139.88 +;; 4-runtime.watsup:140.1-140.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:148.1-148.79 + ;; 4-runtime.watsup:149.1-149.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:140.1-140.85 +;; 4-runtime.watsup:141.1-141.85 def with_tableext : (state, tableidx, ref*) -> state - ;; 4-runtime.watsup:149.1-149.80 + ;; 4-runtime.watsup:150.1-150.80 def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst =.. r*{r}], f) -;; 4-runtime.watsup:141.1-141.95 +;; 4-runtime.watsup:142.1-142.95 def with_mem : (state, tableidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:150.1-150.82 + ;; 4-runtime.watsup:151.1-151.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:142.1-142.83 +;; 4-runtime.watsup:143.1-143.83 def with_memext : (state, tableidx, byte*) -> state - ;; 4-runtime.watsup:151.1-151.74 + ;; 4-runtime.watsup:152.1-152.74 def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst =.. b*{b}], f) -;; 4-runtime.watsup:143.1-143.82 +;; 4-runtime.watsup:144.1-144.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:152.1-152.72 + ;; 4-runtime.watsup:153.1-153.72 def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:144.1-144.82 +;; 4-runtime.watsup:145.1-145.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:153.1-153.72 + ;; 4-runtime.watsup:154.1-154.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:167.1-170.21 +;; 4-runtime.watsup:168.1-171.21 rec { -;; 4-runtime.watsup:167.1-170.21 +;; 4-runtime.watsup:168.1-171.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -7887,10 +7887,10 @@ def default_ : valtype -> val? def default_(EXTERNREF_valtype) = ?(REF.NULL_val(EXTERNREF_reftype)) def {x : valtype} default_(x) = ?() -;; 4-runtime.watsup:71.1-73.22 +;; 4-runtime.watsup:72.1-74.22 syntax exportinst = {NAME name, VALUE externval} -;; 4-runtime.watsup:83.1-90.25 +;; 4-runtime.watsup:84.1-91.25 syntax moduleinst = {FUNC funcaddr*, GLOBAL globaladdr*, TABLE tableaddr*, MEM memaddr*, ELEM elemaddr*, DATA dataaddr*, EXPORT exportinst*} ;; 4-runtime.watsup:55.1-57.16 @@ -7905,25 +7905,25 @@ syntax tableinst = {TYPE tabletype, ELEM ref*} ;; 4-runtime.watsup:64.1-66.17 syntax meminst = {TYPE memtype, DATA byte*} -;; 4-runtime.watsup:67.1-68.16 -syntax eleminst = {ELEM ref*} +;; 4-runtime.watsup:67.1-69.16 +syntax eleminst = {TYPE elemtype, ELEM ref*} -;; 4-runtime.watsup:69.1-70.17 +;; 4-runtime.watsup:70.1-71.17 syntax datainst = {DATA byte*} -;; 4-runtime.watsup:75.1-81.21 +;; 4-runtime.watsup:76.1-82.21 syntax store = {FUNC funcinst*, GLOBAL globalinst*, TABLE tableinst*, MEM meminst*, ELEM eleminst*, DATA datainst*} -;; 4-runtime.watsup:92.1-94.24 +;; 4-runtime.watsup:93.1-95.24 syntax frame = {LOCAL val*, MODULE moduleinst} -;; 4-runtime.watsup:95.1-95.47 +;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:158.1-165.5 +;; 4-runtime.watsup:159.1-166.5 rec { -;; 4-runtime.watsup:158.1-165.5 +;; 4-runtime.watsup:159.1-166.5 syntax admininstr = | UNREACHABLE | NOP @@ -8034,98 +8034,98 @@ def admininstr_val : val -> admininstr def {x : funcaddr} admininstr_val(REF.FUNC_ADDR_val(x)) = REF.FUNC_ADDR_admininstr(x) def {x : hostaddr} admininstr_val(REF.HOST_ADDR_val(x)) = REF.HOST_ADDR_admininstr(x) -;; 4-runtime.watsup:96.1-96.62 +;; 4-runtime.watsup:97.1-97.62 syntax config = `%;%*`(state, admininstr*) -;; 4-runtime.watsup:114.1-114.59 +;; 4-runtime.watsup:115.1-115.59 def funcaddr : state -> funcaddr* - ;; 4-runtime.watsup:115.1-115.38 + ;; 4-runtime.watsup:116.1-116.38 def {f : frame, s : store} funcaddr(`%;%`(s, f)) = f.MODULE_frame.FUNC_moduleinst -;; 4-runtime.watsup:117.1-117.52 +;; 4-runtime.watsup:118.1-118.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:118.1-118.31 + ;; 4-runtime.watsup:119.1-119.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:120.1-120.67 +;; 4-runtime.watsup:121.1-121.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:128.1-128.48 + ;; 4-runtime.watsup:129.1-129.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:121.1-121.69 +;; 4-runtime.watsup:122.1-122.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:129.1-129.54 + ;; 4-runtime.watsup:130.1-130.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:122.1-122.68 +;; 4-runtime.watsup:123.1-123.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:130.1-130.51 + ;; 4-runtime.watsup:131.1-131.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:123.1-123.66 +;; 4-runtime.watsup:124.1-124.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:131.1-131.45 + ;; 4-runtime.watsup:132.1-132.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:124.1-124.67 +;; 4-runtime.watsup:125.1-125.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:132.1-132.48 + ;; 4-runtime.watsup:133.1-133.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:125.1-125.67 +;; 4-runtime.watsup:126.1-126.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:133.1-133.48 + ;; 4-runtime.watsup:134.1-134.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:126.1-126.68 +;; 4-runtime.watsup:127.1-127.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:134.1-134.35 + ;; 4-runtime.watsup:135.1-135.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:137.1-137.78 +;; 4-runtime.watsup:138.1-138.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:146.1-146.52 + ;; 4-runtime.watsup:147.1-147.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:138.1-138.85 +;; 4-runtime.watsup:139.1-139.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:147.1-147.77 + ;; 4-runtime.watsup:148.1-148.77 def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:139.1-139.88 +;; 4-runtime.watsup:140.1-140.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:148.1-148.79 + ;; 4-runtime.watsup:149.1-149.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:140.1-140.85 +;; 4-runtime.watsup:141.1-141.85 def with_tableext : (state, tableidx, ref*) -> state - ;; 4-runtime.watsup:149.1-149.80 + ;; 4-runtime.watsup:150.1-150.80 def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst =.. r*{r}], f) -;; 4-runtime.watsup:141.1-141.95 +;; 4-runtime.watsup:142.1-142.95 def with_mem : (state, tableidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:150.1-150.82 + ;; 4-runtime.watsup:151.1-151.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:142.1-142.83 +;; 4-runtime.watsup:143.1-143.83 def with_memext : (state, tableidx, byte*) -> state - ;; 4-runtime.watsup:151.1-151.74 + ;; 4-runtime.watsup:152.1-152.74 def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst =.. b*{b}], f) -;; 4-runtime.watsup:143.1-143.82 +;; 4-runtime.watsup:144.1-144.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:152.1-152.72 + ;; 4-runtime.watsup:153.1-153.72 def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:144.1-144.82 +;; 4-runtime.watsup:145.1-145.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:153.1-153.72 + ;; 4-runtime.watsup:154.1-154.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:167.1-170.21 +;; 4-runtime.watsup:168.1-171.21 rec { -;; 4-runtime.watsup:167.1-170.21 +;; 4-runtime.watsup:168.1-171.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -9679,10 +9679,10 @@ def default_ : valtype -> val? def default_(EXTERNREF_valtype) = ?(REF.NULL_val(EXTERNREF_reftype)) def {x : valtype} default_(x) = ?() -;; 4-runtime.watsup:71.1-73.22 +;; 4-runtime.watsup:72.1-74.22 syntax exportinst = {NAME name, VALUE externval} -;; 4-runtime.watsup:83.1-90.25 +;; 4-runtime.watsup:84.1-91.25 syntax moduleinst = {FUNC funcaddr*, GLOBAL globaladdr*, TABLE tableaddr*, MEM memaddr*, ELEM elemaddr*, DATA dataaddr*, EXPORT exportinst*} ;; 4-runtime.watsup:55.1-57.16 @@ -9697,25 +9697,25 @@ syntax tableinst = {TYPE tabletype, ELEM ref*} ;; 4-runtime.watsup:64.1-66.17 syntax meminst = {TYPE memtype, DATA byte*} -;; 4-runtime.watsup:67.1-68.16 -syntax eleminst = {ELEM ref*} +;; 4-runtime.watsup:67.1-69.16 +syntax eleminst = {TYPE elemtype, ELEM ref*} -;; 4-runtime.watsup:69.1-70.17 +;; 4-runtime.watsup:70.1-71.17 syntax datainst = {DATA byte*} -;; 4-runtime.watsup:75.1-81.21 +;; 4-runtime.watsup:76.1-82.21 syntax store = {FUNC funcinst*, GLOBAL globalinst*, TABLE tableinst*, MEM meminst*, ELEM eleminst*, DATA datainst*} -;; 4-runtime.watsup:92.1-94.24 +;; 4-runtime.watsup:93.1-95.24 syntax frame = {LOCAL val*, MODULE moduleinst} -;; 4-runtime.watsup:95.1-95.47 +;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:158.1-165.5 +;; 4-runtime.watsup:159.1-166.5 rec { -;; 4-runtime.watsup:158.1-165.5 +;; 4-runtime.watsup:159.1-166.5 syntax admininstr = | UNREACHABLE | NOP @@ -9826,98 +9826,98 @@ def admininstr_val : val -> admininstr def {x : funcaddr} admininstr_val(REF.FUNC_ADDR_val(x)) = REF.FUNC_ADDR_admininstr(x) def {x : hostaddr} admininstr_val(REF.HOST_ADDR_val(x)) = REF.HOST_ADDR_admininstr(x) -;; 4-runtime.watsup:96.1-96.62 +;; 4-runtime.watsup:97.1-97.62 syntax config = `%;%*`(state, admininstr*) -;; 4-runtime.watsup:114.1-114.59 +;; 4-runtime.watsup:115.1-115.59 def funcaddr : state -> funcaddr* - ;; 4-runtime.watsup:115.1-115.38 + ;; 4-runtime.watsup:116.1-116.38 def {f : frame, s : store} funcaddr(`%;%`(s, f)) = f.MODULE_frame.FUNC_moduleinst -;; 4-runtime.watsup:117.1-117.52 +;; 4-runtime.watsup:118.1-118.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:118.1-118.31 + ;; 4-runtime.watsup:119.1-119.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:120.1-120.67 +;; 4-runtime.watsup:121.1-121.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:128.1-128.48 + ;; 4-runtime.watsup:129.1-129.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:121.1-121.69 +;; 4-runtime.watsup:122.1-122.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:129.1-129.54 + ;; 4-runtime.watsup:130.1-130.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:122.1-122.68 +;; 4-runtime.watsup:123.1-123.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:130.1-130.51 + ;; 4-runtime.watsup:131.1-131.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:123.1-123.66 +;; 4-runtime.watsup:124.1-124.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:131.1-131.45 + ;; 4-runtime.watsup:132.1-132.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:124.1-124.67 +;; 4-runtime.watsup:125.1-125.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:132.1-132.48 + ;; 4-runtime.watsup:133.1-133.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:125.1-125.67 +;; 4-runtime.watsup:126.1-126.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:133.1-133.48 + ;; 4-runtime.watsup:134.1-134.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:126.1-126.68 +;; 4-runtime.watsup:127.1-127.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:134.1-134.35 + ;; 4-runtime.watsup:135.1-135.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:137.1-137.78 +;; 4-runtime.watsup:138.1-138.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:146.1-146.52 + ;; 4-runtime.watsup:147.1-147.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:138.1-138.85 +;; 4-runtime.watsup:139.1-139.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:147.1-147.77 + ;; 4-runtime.watsup:148.1-148.77 def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:139.1-139.88 +;; 4-runtime.watsup:140.1-140.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:148.1-148.79 + ;; 4-runtime.watsup:149.1-149.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:140.1-140.85 +;; 4-runtime.watsup:141.1-141.85 def with_tableext : (state, tableidx, ref*) -> state - ;; 4-runtime.watsup:149.1-149.80 + ;; 4-runtime.watsup:150.1-150.80 def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst =.. r*{r}], f) -;; 4-runtime.watsup:141.1-141.95 +;; 4-runtime.watsup:142.1-142.95 def with_mem : (state, tableidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:150.1-150.82 + ;; 4-runtime.watsup:151.1-151.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:142.1-142.83 +;; 4-runtime.watsup:143.1-143.83 def with_memext : (state, tableidx, byte*) -> state - ;; 4-runtime.watsup:151.1-151.74 + ;; 4-runtime.watsup:152.1-152.74 def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst =.. b*{b}], f) -;; 4-runtime.watsup:143.1-143.82 +;; 4-runtime.watsup:144.1-144.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:152.1-152.72 + ;; 4-runtime.watsup:153.1-153.72 def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:144.1-144.82 +;; 4-runtime.watsup:145.1-145.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:153.1-153.72 + ;; 4-runtime.watsup:154.1-154.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:167.1-170.21 +;; 4-runtime.watsup:168.1-171.21 rec { -;; 4-runtime.watsup:167.1-170.21 +;; 4-runtime.watsup:168.1-171.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -11482,10 +11482,10 @@ def default_ : valtype -> val? def default_(EXTERNREF_valtype) = ?(REF.NULL_val(EXTERNREF_reftype)) def {x : valtype} default_(x) = ?() -;; 4-runtime.watsup:71.1-73.22 +;; 4-runtime.watsup:72.1-74.22 syntax exportinst = {NAME name, VALUE externval} -;; 4-runtime.watsup:83.1-90.25 +;; 4-runtime.watsup:84.1-91.25 syntax moduleinst = {FUNC funcaddr*, GLOBAL globaladdr*, TABLE tableaddr*, MEM memaddr*, ELEM elemaddr*, DATA dataaddr*, EXPORT exportinst*} ;; 4-runtime.watsup:55.1-57.16 @@ -11500,25 +11500,25 @@ syntax tableinst = {TYPE tabletype, ELEM ref*} ;; 4-runtime.watsup:64.1-66.17 syntax meminst = {TYPE memtype, DATA byte*} -;; 4-runtime.watsup:67.1-68.16 -syntax eleminst = {ELEM ref*} +;; 4-runtime.watsup:67.1-69.16 +syntax eleminst = {TYPE elemtype, ELEM ref*} -;; 4-runtime.watsup:69.1-70.17 +;; 4-runtime.watsup:70.1-71.17 syntax datainst = {DATA byte*} -;; 4-runtime.watsup:75.1-81.21 +;; 4-runtime.watsup:76.1-82.21 syntax store = {FUNC funcinst*, GLOBAL globalinst*, TABLE tableinst*, MEM meminst*, ELEM eleminst*, DATA datainst*} -;; 4-runtime.watsup:92.1-94.24 +;; 4-runtime.watsup:93.1-95.24 syntax frame = {LOCAL val*, MODULE moduleinst} -;; 4-runtime.watsup:95.1-95.47 +;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:158.1-165.5 +;; 4-runtime.watsup:159.1-166.5 rec { -;; 4-runtime.watsup:158.1-165.5 +;; 4-runtime.watsup:159.1-166.5 syntax admininstr = | UNREACHABLE | NOP @@ -11629,98 +11629,98 @@ def admininstr_val : val -> admininstr def {x : funcaddr} admininstr_val(REF.FUNC_ADDR_val(x)) = REF.FUNC_ADDR_admininstr(x) def {x : hostaddr} admininstr_val(REF.HOST_ADDR_val(x)) = REF.HOST_ADDR_admininstr(x) -;; 4-runtime.watsup:96.1-96.62 +;; 4-runtime.watsup:97.1-97.62 syntax config = `%;%*`(state, admininstr*) -;; 4-runtime.watsup:114.1-114.59 +;; 4-runtime.watsup:115.1-115.59 def funcaddr : state -> funcaddr* - ;; 4-runtime.watsup:115.1-115.38 + ;; 4-runtime.watsup:116.1-116.38 def {f : frame, s : store} funcaddr(`%;%`(s, f)) = f.MODULE_frame.FUNC_moduleinst -;; 4-runtime.watsup:117.1-117.52 +;; 4-runtime.watsup:118.1-118.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:118.1-118.31 + ;; 4-runtime.watsup:119.1-119.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:120.1-120.67 +;; 4-runtime.watsup:121.1-121.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:128.1-128.48 + ;; 4-runtime.watsup:129.1-129.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:121.1-121.69 +;; 4-runtime.watsup:122.1-122.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:129.1-129.54 + ;; 4-runtime.watsup:130.1-130.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:122.1-122.68 +;; 4-runtime.watsup:123.1-123.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:130.1-130.51 + ;; 4-runtime.watsup:131.1-131.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:123.1-123.66 +;; 4-runtime.watsup:124.1-124.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:131.1-131.45 + ;; 4-runtime.watsup:132.1-132.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:124.1-124.67 +;; 4-runtime.watsup:125.1-125.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:132.1-132.48 + ;; 4-runtime.watsup:133.1-133.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:125.1-125.67 +;; 4-runtime.watsup:126.1-126.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:133.1-133.48 + ;; 4-runtime.watsup:134.1-134.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:126.1-126.68 +;; 4-runtime.watsup:127.1-127.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:134.1-134.35 + ;; 4-runtime.watsup:135.1-135.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:137.1-137.78 +;; 4-runtime.watsup:138.1-138.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:146.1-146.52 + ;; 4-runtime.watsup:147.1-147.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:138.1-138.85 +;; 4-runtime.watsup:139.1-139.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:147.1-147.77 + ;; 4-runtime.watsup:148.1-148.77 def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:139.1-139.88 +;; 4-runtime.watsup:140.1-140.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:148.1-148.79 + ;; 4-runtime.watsup:149.1-149.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:140.1-140.85 +;; 4-runtime.watsup:141.1-141.85 def with_tableext : (state, tableidx, ref*) -> state - ;; 4-runtime.watsup:149.1-149.80 + ;; 4-runtime.watsup:150.1-150.80 def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst =.. r*{r}], f) -;; 4-runtime.watsup:141.1-141.95 +;; 4-runtime.watsup:142.1-142.95 def with_mem : (state, tableidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:150.1-150.82 + ;; 4-runtime.watsup:151.1-151.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:142.1-142.83 +;; 4-runtime.watsup:143.1-143.83 def with_memext : (state, tableidx, byte*) -> state - ;; 4-runtime.watsup:151.1-151.74 + ;; 4-runtime.watsup:152.1-152.74 def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst =.. b*{b}], f) -;; 4-runtime.watsup:143.1-143.82 +;; 4-runtime.watsup:144.1-144.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:152.1-152.72 + ;; 4-runtime.watsup:153.1-153.72 def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:144.1-144.82 +;; 4-runtime.watsup:145.1-145.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:153.1-153.72 + ;; 4-runtime.watsup:154.1-154.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:167.1-170.21 +;; 4-runtime.watsup:168.1-171.21 rec { -;; 4-runtime.watsup:167.1-170.21 +;; 4-runtime.watsup:168.1-171.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) From 2b82dcce0ed7cb75579eed3c9c2914fce30550a5 Mon Sep 17 00:00:00 2001 From: Wonho Shin Date: Thu, 15 Jun 2023 13:33:45 +0900 Subject: [PATCH 04/49] Type check from updated store --- spectec/spec/6-reduction.watsup | 10 +- spectec/test-frontend/TEST.md | 94 ++--- spectec/test-middlend/TEST.md | 588 ++++++++++++++++---------------- spectec/test-prose/TEST.md | 4 +- 4 files changed, 358 insertions(+), 338 deletions(-) diff --git a/spectec/spec/6-reduction.watsup b/spectec/spec/6-reduction.watsup index c7c63f81e9..0d120e844a 100644 --- a/spectec/spec/6-reduction.watsup +++ b/spectec/spec/6-reduction.watsup @@ -202,8 +202,9 @@ rule Step_read/table.size: rule Step/table.grow-succeed: - z; ref (CONST I32 n) (TABLE.GROW x) ~> $with_tableext(z, x, ref^n); (CONST I32 $(|$table(z, x).ELEM|)) - -- if $table(z, 0).TYPE = tabletype + z; ref (CONST I32 n) (TABLE.GROW x) ~> z'; (CONST I32 $(|$table(z, x).ELEM|)) + -- if $with_tableext(z, x, ref^n) = z' + -- if $table(z', 0).TYPE = tabletype -- Tabletype_ok: |- tabletype : OK rule Step/table.grow-fail: @@ -309,8 +310,9 @@ rule Step_read/memory.size: rule Step/memory.grow-succeed: - z; (CONST I32 n) (MEMORY.GROW) ~> $with_memext(z, 0, 0^(n * 64 * $Ki)); (CONST I32 $(|$mem(z, 0).DATA| / (64 * $Ki))) - -- if $mem(z, 0).TYPE = memtype + z; (CONST I32 n) (MEMORY.GROW) ~> z'; (CONST I32 $(|$mem(z, 0).DATA| / (64 * $Ki))) + -- if $with_memext(z, 0, 0^(n * 64 * $Ki)) = z' + -- if $mem(z', 0).TYPE = memtype -- Memtype_ok: |- memtype : OK rule Step/memory.grow-fail: diff --git a/spectec/test-frontend/TEST.md b/spectec/test-frontend/TEST.md index a6b7f837dd..6039efbb58 100644 --- a/spectec/test-frontend/TEST.md +++ b/spectec/test-frontend/TEST.md @@ -1429,135 +1429,135 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:213.1-215.39 + ;; 6-reduction.watsup:214.1-216.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:217.1-220.14 + ;; 6-reduction.watsup:218.1-221.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:222.1-226.15 + ;; 6-reduction.watsup:223.1-227.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) (val <: admininstr) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) (val <: admininstr) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:229.1-231.73 + ;; 6-reduction.watsup:230.1-232.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:233.1-236.14 + ;; 6-reduction.watsup:234.1-237.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:238.1-243.15 + ;; 6-reduction.watsup:239.1-244.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:245.1-249.15 + ;; 6-reduction.watsup:246.1-250.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:252.1-254.72 + ;; 6-reduction.watsup:253.1-255.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:256.1-259.14 + ;; 6-reduction.watsup:257.1-260.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:261.1-265.15 + ;; 6-reduction.watsup:262.1-266.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) ($elem(z, y).ELEM_eleminst[i] <: admininstr) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:272.1-274.53 + ;; 6-reduction.watsup:273.1-275.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + ($size(nt <: valtype) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:276.1-278.71 + ;; 6-reduction.watsup:277.1-279.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- if ($bytes_($size(nt <: valtype), c) = $mem(z, 0).DATA_meminst[(i + n_O) : ($size(nt <: valtype) / 8)]) - ;; 6-reduction.watsup:280.1-282.45 + ;; 6-reduction.watsup:281.1-283.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:284.1-286.55 + ;; 6-reduction.watsup:285.1-287.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, $size(nt <: valtype), sx, c))]) -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:306.1-308.44 + ;; 6-reduction.watsup:307.1-309.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:320.1-322.37 + ;; 6-reduction.watsup:322.1-324.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:324.1-327.14 + ;; 6-reduction.watsup:326.1-329.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:329.1-333.15 + ;; 6-reduction.watsup:331.1-335.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) (val <: admininstr) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) (val <: admininstr) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:336.1-338.69 + ;; 6-reduction.watsup:338.1-340.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:340.1-343.14 + ;; 6-reduction.watsup:342.1-345.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:345.1-350.15 + ;; 6-reduction.watsup:347.1-352.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:352.1-356.15 + ;; 6-reduction.watsup:354.1-358.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:359.1-361.70 + ;; 6-reduction.watsup:361.1-363.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:363.1-366.14 + ;; 6-reduction.watsup:365.1-368.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:368.1-372.15 + ;; 6-reduction.watsup:370.1-374.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise @@ -1592,51 +1592,53 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (ref <: admininstr) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-207.37 - rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state}: - `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($table(z, 0).TYPE_tableinst = tabletype) + ;; 6-reduction.watsup:204.1-208.37 + rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state, z' : state}: + `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z', [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($with_tableext(z, x, ref^n{}) = z') + -- if ($table(z', 0).TYPE_tableinst = tabletype) -- Tabletype_ok: `|-%:OK`(tabletype) - ;; 6-reduction.watsup:209.1-210.64 + ;; 6-reduction.watsup:210.1-211.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:268.1-269.59 + ;; 6-reduction.watsup:269.1-270.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:289.1-291.53 + ;; 6-reduction.watsup:290.1-292.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + ($size(nt <: valtype) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:293.1-295.35 + ;; 6-reduction.watsup:294.1-296.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), ($size(nt <: valtype) / 8), b*{b}), [])) -- if (b*{b} = $bytes_($size(nt <: valtype), c)) - ;; 6-reduction.watsup:297.1-299.45 + ;; 6-reduction.watsup:298.1-300.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:301.1-303.50 + ;; 6-reduction.watsup:302.1-304.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if (b*{b} = $bytes_(n, $wrap_(($size(nt <: valtype), n), c))) - ;; 6-reduction.watsup:311.1-314.33 - rule memory.grow-succeed {memtype : memtype, n : n, z : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - -- if ($mem(z, 0).TYPE_meminst = memtype) + ;; 6-reduction.watsup:312.1-316.33 + rule memory.grow-succeed {memtype : memtype, n : n, z : state, z' : state}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z', [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($with_memext(z, 0, 0^((n * 64) * $Ki){}) = z') + -- if ($mem(z', 0).TYPE_meminst = memtype) -- Memtype_ok: `|-%:OK`(memtype) - ;; 6-reduction.watsup:316.1-317.59 + ;; 6-reduction.watsup:318.1-319.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:375.1-376.59 + ;; 6-reduction.watsup:377.1-378.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) @@ -3595,8 +3597,9 @@ $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}table.grow{-}succeed}]} \quad & \mathit{z} ; \mathit{ref}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.grow}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{table}[\mathit{x}].\mathsf{elem} = ..{\mathit{ref}^{\mathit{n}}}] ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~{|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}.\mathsf{elem}|}) &\quad - \mbox{if}~{\mathit{z}.\mathsf{table}}{[0]}.\mathsf{type} = \mathit{tabletype} \\ +{[\textsc{\scriptsize E{-}table.grow{-}succeed}]} \quad & \mathit{z} ; \mathit{ref}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.grow}~\mathit{x}) &\hookrightarrow& {\mathit{z}'} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~{|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}.\mathsf{elem}|}) &\quad + \mbox{if}~\mathit{z}[\mathsf{table}[\mathit{x}].\mathsf{elem} = ..{\mathit{ref}^{\mathit{n}}}] = {\mathit{z}'} \\ + &&&&\quad {\land}~{{\mathit{z}'}.\mathsf{table}}{[0]}.\mathsf{type} = \mathit{tabletype} \\ &&&&\quad {\land}~{ \vdash }\;\mathit{tabletype} : \mathsf{ok} \\ {[\textsc{\scriptsize E{-}table.grow{-}fail}]} \quad & \mathit{z} ; \mathit{ref}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.grow}~\mathit{x}) &\hookrightarrow& \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~-1) & \\ \end{array} @@ -3694,8 +3697,9 @@ $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}memory.grow{-}succeed}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.grow}) &\hookrightarrow& \mathit{z}[\mathsf{mem}[0].\mathsf{data} = ..{0^{\mathit{n} \cdot 64 \cdot \mathrm{Ki}}}] ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~{|{\mathit{z}.\mathsf{mem}}{[0]}.\mathsf{data}|} / (64 \cdot \mathrm{Ki})) &\quad - \mbox{if}~{\mathit{z}.\mathsf{mem}}{[0]}.\mathsf{type} = \mathit{memtype} \\ +{[\textsc{\scriptsize E{-}memory.grow{-}succeed}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.grow}) &\hookrightarrow& {\mathit{z}'} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~{|{\mathit{z}.\mathsf{mem}}{[0]}.\mathsf{data}|} / (64 \cdot \mathrm{Ki})) &\quad + \mbox{if}~\mathit{z}[\mathsf{mem}[0].\mathsf{data} = ..{0^{\mathit{n} \cdot 64 \cdot \mathrm{Ki}}}] = {\mathit{z}'} \\ + &&&&\quad {\land}~{{\mathit{z}'}.\mathsf{mem}}{[0]}.\mathsf{type} = \mathit{memtype} \\ &&&&\quad {\land}~{ \vdash }\;\mathit{memtype} : \mathsf{ok} \\ {[\textsc{\scriptsize E{-}memory.grow{-}fail}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.grow}) &\hookrightarrow& \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~-1) & \\ \end{array} diff --git a/spectec/test-middlend/TEST.md b/spectec/test-middlend/TEST.md index 5bba225803..57ffcf8a3e 100644 --- a/spectec/test-middlend/TEST.md +++ b/spectec/test-middlend/TEST.md @@ -1428,135 +1428,135 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:213.1-215.39 + ;; 6-reduction.watsup:214.1-216.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:217.1-220.14 + ;; 6-reduction.watsup:218.1-221.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:222.1-226.15 + ;; 6-reduction.watsup:223.1-227.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) (val <: admininstr) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) (val <: admininstr) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:229.1-231.73 + ;; 6-reduction.watsup:230.1-232.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:233.1-236.14 + ;; 6-reduction.watsup:234.1-237.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:238.1-243.15 + ;; 6-reduction.watsup:239.1-244.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:245.1-249.15 + ;; 6-reduction.watsup:246.1-250.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:252.1-254.72 + ;; 6-reduction.watsup:253.1-255.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:256.1-259.14 + ;; 6-reduction.watsup:257.1-260.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:261.1-265.15 + ;; 6-reduction.watsup:262.1-266.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) ($elem(z, y).ELEM_eleminst[i] <: admininstr) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:272.1-274.53 + ;; 6-reduction.watsup:273.1-275.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + ($size(nt <: valtype) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:276.1-278.71 + ;; 6-reduction.watsup:277.1-279.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- if ($bytes_($size(nt <: valtype), c) = $mem(z, 0).DATA_meminst[(i + n_O) : ($size(nt <: valtype) / 8)]) - ;; 6-reduction.watsup:280.1-282.45 + ;; 6-reduction.watsup:281.1-283.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:284.1-286.55 + ;; 6-reduction.watsup:285.1-287.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, $size(nt <: valtype), sx, c))]) -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:306.1-308.44 + ;; 6-reduction.watsup:307.1-309.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:320.1-322.37 + ;; 6-reduction.watsup:322.1-324.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:324.1-327.14 + ;; 6-reduction.watsup:326.1-329.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:329.1-333.15 + ;; 6-reduction.watsup:331.1-335.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) (val <: admininstr) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) (val <: admininstr) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:336.1-338.69 + ;; 6-reduction.watsup:338.1-340.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:340.1-343.14 + ;; 6-reduction.watsup:342.1-345.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:345.1-350.15 + ;; 6-reduction.watsup:347.1-352.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:352.1-356.15 + ;; 6-reduction.watsup:354.1-358.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:359.1-361.70 + ;; 6-reduction.watsup:361.1-363.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:363.1-366.14 + ;; 6-reduction.watsup:365.1-368.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:368.1-372.15 + ;; 6-reduction.watsup:370.1-374.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise @@ -1591,51 +1591,53 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (ref <: admininstr) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-207.37 - rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state}: - `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($table(z, 0).TYPE_tableinst = tabletype) + ;; 6-reduction.watsup:204.1-208.37 + rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state, z' : state}: + `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z', [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($with_tableext(z, x, ref^n{}) = z') + -- if ($table(z', 0).TYPE_tableinst = tabletype) -- Tabletype_ok: `|-%:OK`(tabletype) - ;; 6-reduction.watsup:209.1-210.64 + ;; 6-reduction.watsup:210.1-211.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:268.1-269.59 + ;; 6-reduction.watsup:269.1-270.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:289.1-291.53 + ;; 6-reduction.watsup:290.1-292.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + ($size(nt <: valtype) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:293.1-295.35 + ;; 6-reduction.watsup:294.1-296.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), ($size(nt <: valtype) / 8), b*{b}), [])) -- if (b*{b} = $bytes_($size(nt <: valtype), c)) - ;; 6-reduction.watsup:297.1-299.45 + ;; 6-reduction.watsup:298.1-300.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:301.1-303.50 + ;; 6-reduction.watsup:302.1-304.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if (b*{b} = $bytes_(n, $wrap_(($size(nt <: valtype), n), c))) - ;; 6-reduction.watsup:311.1-314.33 - rule memory.grow-succeed {memtype : memtype, n : n, z : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - -- if ($mem(z, 0).TYPE_meminst = memtype) + ;; 6-reduction.watsup:312.1-316.33 + rule memory.grow-succeed {memtype : memtype, n : n, z : state, z' : state}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z', [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($with_memext(z, 0, 0^((n * 64) * $Ki){}) = z') + -- if ($mem(z', 0).TYPE_meminst = memtype) -- Memtype_ok: `|-%:OK`(memtype) - ;; 6-reduction.watsup:316.1-317.59 + ;; 6-reduction.watsup:318.1-319.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:375.1-376.59 + ;; 6-reduction.watsup:377.1-378.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) @@ -3151,135 +3153,135 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:213.1-215.39 + ;; 6-reduction.watsup:214.1-216.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:217.1-220.14 + ;; 6-reduction.watsup:218.1-221.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:222.1-226.15 + ;; 6-reduction.watsup:223.1-227.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:229.1-231.73 + ;; 6-reduction.watsup:230.1-232.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:233.1-236.14 + ;; 6-reduction.watsup:234.1-237.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:238.1-243.15 + ;; 6-reduction.watsup:239.1-244.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:245.1-249.15 + ;; 6-reduction.watsup:246.1-250.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:252.1-254.72 + ;; 6-reduction.watsup:253.1-255.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:256.1-259.14 + ;; 6-reduction.watsup:257.1-260.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:261.1-265.15 + ;; 6-reduction.watsup:262.1-266.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y).ELEM_eleminst[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:272.1-274.53 + ;; 6-reduction.watsup:273.1-275.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + ($size($valtype_numtype(nt)) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:276.1-278.71 + ;; 6-reduction.watsup:277.1-279.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- if ($bytes_($size($valtype_numtype(nt)), c) = $mem(z, 0).DATA_meminst[(i + n_O) : ($size($valtype_numtype(nt)) / 8)]) - ;; 6-reduction.watsup:280.1-282.45 + ;; 6-reduction.watsup:281.1-283.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:284.1-286.55 + ;; 6-reduction.watsup:285.1-287.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, $size($valtype_numtype(nt)), sx, c))]) -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:306.1-308.44 + ;; 6-reduction.watsup:307.1-309.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:320.1-322.37 + ;; 6-reduction.watsup:322.1-324.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:324.1-327.14 + ;; 6-reduction.watsup:326.1-329.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:329.1-333.15 + ;; 6-reduction.watsup:331.1-335.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:336.1-338.69 + ;; 6-reduction.watsup:338.1-340.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:340.1-343.14 + ;; 6-reduction.watsup:342.1-345.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:345.1-350.15 + ;; 6-reduction.watsup:347.1-352.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:352.1-356.15 + ;; 6-reduction.watsup:354.1-358.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:359.1-361.70 + ;; 6-reduction.watsup:361.1-363.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:363.1-366.14 + ;; 6-reduction.watsup:365.1-368.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:368.1-372.15 + ;; 6-reduction.watsup:370.1-374.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise @@ -3314,51 +3316,53 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-207.37 - rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state}: - `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($table(z, 0).TYPE_tableinst = tabletype) + ;; 6-reduction.watsup:204.1-208.37 + rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state, z' : state}: + `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z', [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($with_tableext(z, x, ref^n{}) = z') + -- if ($table(z', 0).TYPE_tableinst = tabletype) -- Tabletype_ok: `|-%:OK`(tabletype) - ;; 6-reduction.watsup:209.1-210.64 + ;; 6-reduction.watsup:210.1-211.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:268.1-269.59 + ;; 6-reduction.watsup:269.1-270.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:289.1-291.53 + ;; 6-reduction.watsup:290.1-292.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + ($size($valtype_numtype(nt)) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:293.1-295.35 + ;; 6-reduction.watsup:294.1-296.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), ($size($valtype_numtype(nt)) / 8), b*{b}), [])) -- if (b*{b} = $bytes_($size($valtype_numtype(nt)), c)) - ;; 6-reduction.watsup:297.1-299.45 + ;; 6-reduction.watsup:298.1-300.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:301.1-303.50 + ;; 6-reduction.watsup:302.1-304.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if (b*{b} = $bytes_(n, $wrap_(($size($valtype_numtype(nt)), n), c))) - ;; 6-reduction.watsup:311.1-314.33 - rule memory.grow-succeed {memtype : memtype, n : n, z : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - -- if ($mem(z, 0).TYPE_meminst = memtype) + ;; 6-reduction.watsup:312.1-316.33 + rule memory.grow-succeed {memtype : memtype, n : n, z : state, z' : state}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z', [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($with_memext(z, 0, 0^((n * 64) * $Ki){}) = z') + -- if ($mem(z', 0).TYPE_meminst = memtype) -- Memtype_ok: `|-%:OK`(memtype) - ;; 6-reduction.watsup:316.1-317.59 + ;; 6-reduction.watsup:318.1-319.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:375.1-376.59 + ;; 6-reduction.watsup:377.1-378.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) @@ -4876,135 +4880,135 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:213.1-215.39 + ;; 6-reduction.watsup:214.1-216.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:217.1-220.14 + ;; 6-reduction.watsup:218.1-221.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:222.1-226.15 + ;; 6-reduction.watsup:223.1-227.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:229.1-231.73 + ;; 6-reduction.watsup:230.1-232.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:233.1-236.14 + ;; 6-reduction.watsup:234.1-237.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:238.1-243.15 + ;; 6-reduction.watsup:239.1-244.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:245.1-249.15 + ;; 6-reduction.watsup:246.1-250.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:252.1-254.72 + ;; 6-reduction.watsup:253.1-255.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:256.1-259.14 + ;; 6-reduction.watsup:257.1-260.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:261.1-265.15 + ;; 6-reduction.watsup:262.1-266.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y).ELEM_eleminst[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:272.1-274.53 + ;; 6-reduction.watsup:273.1-275.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (!($size($valtype_numtype(nt))) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:276.1-278.71 + ;; 6-reduction.watsup:277.1-279.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- if ($bytes_(!($size($valtype_numtype(nt))), c) = $mem(z, 0).DATA_meminst[(i + n_O) : (!($size($valtype_numtype(nt))) / 8)]) - ;; 6-reduction.watsup:280.1-282.45 + ;; 6-reduction.watsup:281.1-283.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:284.1-286.55 + ;; 6-reduction.watsup:285.1-287.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, !($size($valtype_numtype(nt))), sx, c))]) -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:306.1-308.44 + ;; 6-reduction.watsup:307.1-309.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:320.1-322.37 + ;; 6-reduction.watsup:322.1-324.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:324.1-327.14 + ;; 6-reduction.watsup:326.1-329.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:329.1-333.15 + ;; 6-reduction.watsup:331.1-335.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:336.1-338.69 + ;; 6-reduction.watsup:338.1-340.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:340.1-343.14 + ;; 6-reduction.watsup:342.1-345.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:345.1-350.15 + ;; 6-reduction.watsup:347.1-352.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:352.1-356.15 + ;; 6-reduction.watsup:354.1-358.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:359.1-361.70 + ;; 6-reduction.watsup:361.1-363.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:363.1-366.14 + ;; 6-reduction.watsup:365.1-368.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:368.1-372.15 + ;; 6-reduction.watsup:370.1-374.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise @@ -5039,51 +5043,53 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-207.37 - rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state}: - `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($table(z, 0).TYPE_tableinst = tabletype) + ;; 6-reduction.watsup:204.1-208.37 + rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state, z' : state}: + `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z', [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($with_tableext(z, x, ref^n{}) = z') + -- if ($table(z', 0).TYPE_tableinst = tabletype) -- Tabletype_ok: `|-%:OK`(tabletype) - ;; 6-reduction.watsup:209.1-210.64 + ;; 6-reduction.watsup:210.1-211.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:268.1-269.59 + ;; 6-reduction.watsup:269.1-270.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:289.1-291.53 + ;; 6-reduction.watsup:290.1-292.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (!($size($valtype_numtype(nt))) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:293.1-295.35 + ;; 6-reduction.watsup:294.1-296.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (!($size($valtype_numtype(nt))) / 8), b*{b}), [])) -- if (b*{b} = $bytes_(!($size($valtype_numtype(nt))), c)) - ;; 6-reduction.watsup:297.1-299.45 + ;; 6-reduction.watsup:298.1-300.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:301.1-303.50 + ;; 6-reduction.watsup:302.1-304.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if (b*{b} = $bytes_(n, $wrap_((!($size($valtype_numtype(nt))), n), c))) - ;; 6-reduction.watsup:311.1-314.33 - rule memory.grow-succeed {memtype : memtype, n : n, z : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - -- if ($mem(z, 0).TYPE_meminst = memtype) + ;; 6-reduction.watsup:312.1-316.33 + rule memory.grow-succeed {memtype : memtype, n : n, z : state, z' : state}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z', [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($with_memext(z, 0, 0^((n * 64) * $Ki){}) = z') + -- if ($mem(z', 0).TYPE_meminst = memtype) -- Memtype_ok: `|-%:OK`(memtype) - ;; 6-reduction.watsup:316.1-317.59 + ;; 6-reduction.watsup:318.1-319.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:375.1-376.59 + ;; 6-reduction.watsup:377.1-378.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) @@ -6612,139 +6618,139 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:213.1-215.39 + ;; 6-reduction.watsup:214.1-216.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:217.1-220.14 + ;; 6-reduction.watsup:218.1-221.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:222.1-226.15 + ;; 6-reduction.watsup:223.1-227.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:229.1-231.73 + ;; 6-reduction.watsup:230.1-232.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:233.1-236.14 + ;; 6-reduction.watsup:234.1-237.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:238.1-243.15 + ;; 6-reduction.watsup:239.1-244.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:245.1-249.15 + ;; 6-reduction.watsup:246.1-250.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:252.1-254.72 + ;; 6-reduction.watsup:253.1-255.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:256.1-259.14 + ;; 6-reduction.watsup:257.1-260.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:261.1-265.15 + ;; 6-reduction.watsup:262.1-266.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y).ELEM_eleminst[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:272.1-274.53 + ;; 6-reduction.watsup:273.1-275.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:276.1-278.71 + ;; 6-reduction.watsup:277.1-279.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($size($valtype_numtype(nt)) = ?(o1)) -- if ($bytes_(o0, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (o1 / 8)]) - ;; 6-reduction.watsup:280.1-282.45 + ;; 6-reduction.watsup:281.1-283.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:284.1-286.55 + ;; 6-reduction.watsup:285.1-287.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, o0, sx, c))]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:306.1-308.44 + ;; 6-reduction.watsup:307.1-309.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:320.1-322.37 + ;; 6-reduction.watsup:322.1-324.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:324.1-327.14 + ;; 6-reduction.watsup:326.1-329.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:329.1-333.15 + ;; 6-reduction.watsup:331.1-335.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:336.1-338.69 + ;; 6-reduction.watsup:338.1-340.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:340.1-343.14 + ;; 6-reduction.watsup:342.1-345.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:345.1-350.15 + ;; 6-reduction.watsup:347.1-352.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:352.1-356.15 + ;; 6-reduction.watsup:354.1-358.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:359.1-361.70 + ;; 6-reduction.watsup:361.1-363.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:363.1-366.14 + ;; 6-reduction.watsup:365.1-368.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:368.1-372.15 + ;; 6-reduction.watsup:370.1-374.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise @@ -6779,55 +6785,57 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-207.37 - rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state}: - `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($table(z, 0).TYPE_tableinst = tabletype) + ;; 6-reduction.watsup:204.1-208.37 + rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state, z' : state}: + `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z', [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($with_tableext(z, x, ref^n{}) = z') + -- if ($table(z', 0).TYPE_tableinst = tabletype) -- Tabletype_ok: `|-%:OK`(tabletype) - ;; 6-reduction.watsup:209.1-210.64 + ;; 6-reduction.watsup:210.1-211.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:268.1-269.59 + ;; 6-reduction.watsup:269.1-270.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:289.1-291.53 + ;; 6-reduction.watsup:290.1-292.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:293.1-295.35 + ;; 6-reduction.watsup:294.1-296.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (o0 / 8), b*{b}), [])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($size($valtype_numtype(nt)) = ?(o1)) -- if (b*{b} = $bytes_(o1, c)) - ;; 6-reduction.watsup:297.1-299.45 + ;; 6-reduction.watsup:298.1-300.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:301.1-303.50 + ;; 6-reduction.watsup:302.1-304.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (b*{b} = $bytes_(n, $wrap_((o0, n), c))) - ;; 6-reduction.watsup:311.1-314.33 - rule memory.grow-succeed {memtype : memtype, n : n, z : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - -- if ($mem(z, 0).TYPE_meminst = memtype) + ;; 6-reduction.watsup:312.1-316.33 + rule memory.grow-succeed {memtype : memtype, n : n, z : state, z' : state}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z', [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($with_memext(z, 0, 0^((n * 64) * $Ki){}) = z') + -- if ($mem(z', 0).TYPE_meminst = memtype) -- Memtype_ok: `|-%:OK`(memtype) - ;; 6-reduction.watsup:316.1-317.59 + ;; 6-reduction.watsup:318.1-319.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:375.1-376.59 + ;; 6-reduction.watsup:377.1-378.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) @@ -8356,139 +8364,139 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:213.1-215.39 + ;; 6-reduction.watsup:214.1-216.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:217.1-220.14 + ;; 6-reduction.watsup:218.1-221.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:222.1-226.15 + ;; 6-reduction.watsup:223.1-227.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:229.1-231.73 + ;; 6-reduction.watsup:230.1-232.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:233.1-236.14 + ;; 6-reduction.watsup:234.1-237.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:238.1-243.15 + ;; 6-reduction.watsup:239.1-244.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:245.1-249.15 + ;; 6-reduction.watsup:246.1-250.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:252.1-254.72 + ;; 6-reduction.watsup:253.1-255.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:256.1-259.14 + ;; 6-reduction.watsup:257.1-260.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:261.1-265.15 + ;; 6-reduction.watsup:262.1-266.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y).ELEM_eleminst[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:272.1-274.53 + ;; 6-reduction.watsup:273.1-275.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:276.1-278.71 + ;; 6-reduction.watsup:277.1-279.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($size($valtype_numtype(nt)) = ?(o1)) -- if ($bytes_(o0, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (o1 / 8)]) - ;; 6-reduction.watsup:280.1-282.45 + ;; 6-reduction.watsup:281.1-283.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:284.1-286.55 + ;; 6-reduction.watsup:285.1-287.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, o0, sx, c))]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:306.1-308.44 + ;; 6-reduction.watsup:307.1-309.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:320.1-322.37 + ;; 6-reduction.watsup:322.1-324.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:324.1-327.14 + ;; 6-reduction.watsup:326.1-329.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:329.1-333.15 + ;; 6-reduction.watsup:331.1-335.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:336.1-338.69 + ;; 6-reduction.watsup:338.1-340.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:340.1-343.14 + ;; 6-reduction.watsup:342.1-345.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:345.1-350.15 + ;; 6-reduction.watsup:347.1-352.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:352.1-356.15 + ;; 6-reduction.watsup:354.1-358.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:359.1-361.70 + ;; 6-reduction.watsup:361.1-363.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:363.1-366.14 + ;; 6-reduction.watsup:365.1-368.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:368.1-372.15 + ;; 6-reduction.watsup:370.1-374.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise @@ -8523,55 +8531,57 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-207.37 - rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state}: - `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($table(z, 0).TYPE_tableinst = tabletype) + ;; 6-reduction.watsup:204.1-208.37 + rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state, z' : state}: + `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z', [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($with_tableext(z, x, ref^n{}) = z') + -- if ($table(z', 0).TYPE_tableinst = tabletype) -- Tabletype_ok: `|-%:OK`(tabletype) - ;; 6-reduction.watsup:209.1-210.64 + ;; 6-reduction.watsup:210.1-211.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:268.1-269.59 + ;; 6-reduction.watsup:269.1-270.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:289.1-291.53 + ;; 6-reduction.watsup:290.1-292.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:293.1-295.35 + ;; 6-reduction.watsup:294.1-296.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (o0 / 8), b*{b}), [])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($size($valtype_numtype(nt)) = ?(o1)) -- if (b*{b} = $bytes_(o1, c)) - ;; 6-reduction.watsup:297.1-299.45 + ;; 6-reduction.watsup:298.1-300.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:301.1-303.50 + ;; 6-reduction.watsup:302.1-304.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (b*{b} = $bytes_(n, $wrap_((o0, n), c))) - ;; 6-reduction.watsup:311.1-314.33 - rule memory.grow-succeed {memtype : memtype, n : n, z : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - -- if ($mem(z, 0).TYPE_meminst = memtype) + ;; 6-reduction.watsup:312.1-316.33 + rule memory.grow-succeed {memtype : memtype, n : n, z : state, z' : state}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z', [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($with_memext(z, 0, 0^((n * 64) * $Ki){}) = z') + -- if ($mem(z', 0).TYPE_meminst = memtype) -- Memtype_ok: `|-%:OK`(memtype) - ;; 6-reduction.watsup:316.1-317.59 + ;; 6-reduction.watsup:318.1-319.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:375.1-376.59 + ;; 6-reduction.watsup:377.1-378.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) @@ -10154,140 +10164,140 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:213.1-215.39 + ;; 6-reduction.watsup:214.1-216.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:217.1-220.14 + ;; 6-reduction.watsup:218.1-221.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:222.1-226.15 + ;; 6-reduction.watsup:223.1-227.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:229.1-231.73 + ;; 6-reduction.watsup:230.1-232.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:233.1-236.14 + ;; 6-reduction.watsup:234.1-237.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:238.1-243.15 + ;; 6-reduction.watsup:239.1-244.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:245.1-249.15 + ;; 6-reduction.watsup:246.1-250.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:252.1-254.72 + ;; 6-reduction.watsup:253.1-255.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:256.1-259.14 + ;; 6-reduction.watsup:257.1-260.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:261.1-265.15 + ;; 6-reduction.watsup:262.1-266.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y).ELEM_eleminst[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- if (i < |$elem(z, y).ELEM_eleminst|) -- otherwise - ;; 6-reduction.watsup:272.1-274.53 + ;; 6-reduction.watsup:273.1-275.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:276.1-278.71 + ;; 6-reduction.watsup:277.1-279.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($size($valtype_numtype(nt)) = ?(o1)) -- if ($bytes_(o0, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (o1 / 8)]) - ;; 6-reduction.watsup:280.1-282.45 + ;; 6-reduction.watsup:281.1-283.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:284.1-286.55 + ;; 6-reduction.watsup:285.1-287.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, o0, sx, c))]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:306.1-308.44 + ;; 6-reduction.watsup:307.1-309.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:320.1-322.37 + ;; 6-reduction.watsup:322.1-324.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:324.1-327.14 + ;; 6-reduction.watsup:326.1-329.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:329.1-333.15 + ;; 6-reduction.watsup:331.1-335.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:336.1-338.69 + ;; 6-reduction.watsup:338.1-340.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:340.1-343.14 + ;; 6-reduction.watsup:342.1-345.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:345.1-350.15 + ;; 6-reduction.watsup:347.1-352.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:352.1-356.15 + ;; 6-reduction.watsup:354.1-358.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:359.1-361.70 + ;; 6-reduction.watsup:361.1-363.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:363.1-366.14 + ;; 6-reduction.watsup:365.1-368.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:368.1-372.15 + ;; 6-reduction.watsup:370.1-374.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- if (i < |$data(z, x).DATA_datainst|) @@ -10323,55 +10333,57 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-207.37 - rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state}: - `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($table(z, 0).TYPE_tableinst = tabletype) + ;; 6-reduction.watsup:204.1-208.37 + rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state, z' : state}: + `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z', [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($with_tableext(z, x, ref^n{}) = z') + -- if ($table(z', 0).TYPE_tableinst = tabletype) -- Tabletype_ok: `|-%:OK`(tabletype) - ;; 6-reduction.watsup:209.1-210.64 + ;; 6-reduction.watsup:210.1-211.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:268.1-269.59 + ;; 6-reduction.watsup:269.1-270.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:289.1-291.53 + ;; 6-reduction.watsup:290.1-292.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:293.1-295.35 + ;; 6-reduction.watsup:294.1-296.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (o0 / 8), b*{b}), [])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($size($valtype_numtype(nt)) = ?(o1)) -- if (b*{b} = $bytes_(o1, c)) - ;; 6-reduction.watsup:297.1-299.45 + ;; 6-reduction.watsup:298.1-300.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:301.1-303.50 + ;; 6-reduction.watsup:302.1-304.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (b*{b} = $bytes_(n, $wrap_((o0, n), c))) - ;; 6-reduction.watsup:311.1-314.33 - rule memory.grow-succeed {memtype : memtype, n : n, z : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - -- if ($mem(z, 0).TYPE_meminst = memtype) + ;; 6-reduction.watsup:312.1-316.33 + rule memory.grow-succeed {memtype : memtype, n : n, z : state, z' : state}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z', [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($with_memext(z, 0, 0^((n * 64) * $Ki){}) = z') + -- if ($mem(z', 0).TYPE_meminst = memtype) -- Memtype_ok: `|-%:OK`(memtype) - ;; 6-reduction.watsup:316.1-317.59 + ;; 6-reduction.watsup:318.1-319.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:375.1-376.59 + ;; 6-reduction.watsup:377.1-378.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) @@ -11957,140 +11969,140 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) -- where n = |$table(z, x).ELEM_tableinst| - ;; 6-reduction.watsup:213.1-215.39 + ;; 6-reduction.watsup:214.1-216.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:217.1-220.14 + ;; 6-reduction.watsup:218.1-221.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:222.1-226.15 + ;; 6-reduction.watsup:223.1-227.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:229.1-231.73 + ;; 6-reduction.watsup:230.1-232.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:233.1-236.14 + ;; 6-reduction.watsup:234.1-237.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:238.1-243.15 + ;; 6-reduction.watsup:239.1-244.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:245.1-249.15 + ;; 6-reduction.watsup:246.1-250.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:252.1-254.72 + ;; 6-reduction.watsup:253.1-255.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:256.1-259.14 + ;; 6-reduction.watsup:257.1-260.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:261.1-265.15 + ;; 6-reduction.watsup:262.1-266.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y).ELEM_eleminst[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise -- if (i < |$elem(z, y).ELEM_eleminst|) - ;; 6-reduction.watsup:272.1-274.53 + ;; 6-reduction.watsup:273.1-275.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- where ?(o0) = $size($valtype_numtype(nt)) -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:276.1-278.71 + ;; 6-reduction.watsup:277.1-279.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- where ?(o0) = $size($valtype_numtype(nt)) -- where ?(o1) = $size($valtype_numtype(nt)) -- where $bytes_(o0, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (o1 / 8)] - ;; 6-reduction.watsup:280.1-282.45 + ;; 6-reduction.watsup:281.1-283.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:284.1-286.55 + ;; 6-reduction.watsup:285.1-287.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, o0, sx, c))]) -- where ?(o0) = $size($valtype_numtype(nt)) -- where $bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)] - ;; 6-reduction.watsup:306.1-308.44 + ;; 6-reduction.watsup:307.1-309.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) -- where ((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst| - ;; 6-reduction.watsup:320.1-322.37 + ;; 6-reduction.watsup:322.1-324.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:324.1-327.14 + ;; 6-reduction.watsup:326.1-329.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:329.1-333.15 + ;; 6-reduction.watsup:331.1-335.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:336.1-338.69 + ;; 6-reduction.watsup:338.1-340.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:340.1-343.14 + ;; 6-reduction.watsup:342.1-345.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:345.1-350.15 + ;; 6-reduction.watsup:347.1-352.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:352.1-356.15 + ;; 6-reduction.watsup:354.1-358.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:359.1-361.70 + ;; 6-reduction.watsup:361.1-363.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:363.1-366.14 + ;; 6-reduction.watsup:365.1-368.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:368.1-372.15 + ;; 6-reduction.watsup:370.1-374.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise @@ -12126,55 +12138,57 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-207.37 - rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state}: - `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- where tabletype = $table(z, 0).TYPE_tableinst + ;; 6-reduction.watsup:204.1-208.37 + rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state, z' : state}: + `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z', [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- where z' = $with_tableext(z, x, ref^n{}) + -- where tabletype = $table(z', 0).TYPE_tableinst -- Tabletype_ok: `|-%:OK`(tabletype) - ;; 6-reduction.watsup:209.1-210.64 + ;; 6-reduction.watsup:210.1-211.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:268.1-269.59 + ;; 6-reduction.watsup:269.1-270.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:289.1-291.53 + ;; 6-reduction.watsup:290.1-292.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- where ?(o0) = $size($valtype_numtype(nt)) -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:293.1-295.35 + ;; 6-reduction.watsup:294.1-296.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (o0 / 8), b*{b}), [])) -- where ?(o0) = $size($valtype_numtype(nt)) -- where ?(o1) = $size($valtype_numtype(nt)) -- where b*{b} = $bytes_(o1, c) - ;; 6-reduction.watsup:297.1-299.45 + ;; 6-reduction.watsup:298.1-300.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:301.1-303.50 + ;; 6-reduction.watsup:302.1-304.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- where ?(o0) = $size($valtype_numtype(nt)) -- where b*{b} = $bytes_(n, $wrap_((o0, n), c)) - ;; 6-reduction.watsup:311.1-314.33 - rule memory.grow-succeed {memtype : memtype, n : n, z : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_memext(z, 0, 0^((n * 64) * $Ki){}), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - -- where memtype = $mem(z, 0).TYPE_meminst + ;; 6-reduction.watsup:312.1-316.33 + rule memory.grow-succeed {memtype : memtype, n : n, z : state, z' : state}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z', [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- where z' = $with_memext(z, 0, 0^((n * 64) * $Ki){}) + -- where memtype = $mem(z', 0).TYPE_meminst -- Memtype_ok: `|-%:OK`(memtype) - ;; 6-reduction.watsup:316.1-317.59 + ;; 6-reduction.watsup:318.1-319.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:375.1-376.59 + ;; 6-reduction.watsup:377.1-378.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) diff --git a/spectec/test-prose/TEST.md b/spectec/test-prose/TEST.md index 427cbb156a..6e5c47d6e0 100644 --- a/spectec/test-prose/TEST.md +++ b/spectec/test-prose/TEST.md @@ -370,7 +370,7 @@ table.grow 3. Assert: Due to validation, a value is on the top of the stack. 4. Pop YetE ((ref <: admininstr)) from the stack. 5. If YetC (), then: - a. YetI: Perform $with_tableext(z, x, ref^n{}). + a. YetI: Perform z'. b. Push YetE (CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)) to the stack. 6. If YetC (), then: a. YetI: Perform z. @@ -399,7 +399,7 @@ memory.grow 1. Assert: Due to validation, a value of value type i32 is on the top of the stack. 2. Pop YetE (CONST_admininstr(I32_numtype, n)) from the stack. 3. If YetC (), then: - a. YetI: Perform $with_memext(z, 0, 0^((n * 64) * $Ki){}). + a. YetI: Perform z'. b. Push YetE (CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))) to the stack. 4. If YetC (), then: a. YetI: Perform z. From 6b6bd3285c6452251c44d756c3d6179c20dc19de Mon Sep 17 00:00:00 2001 From: Wonho Date: Fri, 16 Jun 2023 13:38:38 +0900 Subject: [PATCH 05/49] Consider free variables in premises of DefD --- spectec/src/frontend/elab.ml | 6 +++++- spectec/src/il/validation.ml | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/spectec/src/frontend/elab.ml b/spectec/src/frontend/elab.ml index 22f268d3d6..0676b79153 100644 --- a/spectec/src/frontend/elab.ml +++ b/spectec/src/frontend/elab.ml @@ -1042,7 +1042,11 @@ let elab_def env d : Il.def list = let e2' = Multiplicity.annot_exp dims' (elab_exp env e2 t2) in let prems' = List.map (Multiplicity.annot_prem dims') (map_nl_list (elab_prem env) prems) in - let free_rh = Free.(Set.diff (free_exp e2).varid (free_exp e1).varid) in + let free_prems = + List.filter_map (function Nl -> None | Elem e -> Some e) prems + |> Free.(free_list free_prem) in + let free_rh = + Free.(Set.diff (Set.diff (free_exp e2).varid (free_exp e1).varid) free_prems.varid) in if free_rh <> Free.Set.empty then error d.at ("definition contains unbound variable(s) `" ^ String.concat "`, `" (Free.Set.elements free_rh) ^ "`"); diff --git a/spectec/src/il/validation.ml b/spectec/src/il/validation.ml index 5d717b6bd9..4a3994359c 100644 --- a/spectec/src/il/validation.ml +++ b/spectec/src/il/validation.ml @@ -524,7 +524,9 @@ let valid_clause env t1 t2 clause = valid_exp env e2 t2; List.iter (valid_prem env) prems; env.vars <- Env.empty; - let free_rh = Free.(Set.diff (free_exp e2).varid (free_exp e1).varid) in + let free_prems = Free.(free_list free_prem prems) in + let free_rh = + Free.(Set.diff (Set.diff (free_exp e2).varid (free_exp e1).varid) free_prems.varid) in if free_rh <> Free.Set.empty then error clause.at ("definition contains unbound variable(s) `" ^ String.concat "`, `" (Free.Set.elements free_rh) ^ "`") From 835bf0da7fa454c1396dfeb0810e63c30144d7b2 Mon Sep 17 00:00:00 2001 From: Wonho Date: Fri, 16 Jun 2023 14:04:28 +0900 Subject: [PATCH 06/49] Add grow helper functions --- spectec/spec/4-runtime.watsup | 20 +- spectec/spec/6-reduction.watsup | 16 +- spectec/test-frontend/TEST.md | 110 +++++--- spectec/test-latex/TEST.md | 6 +- spectec/test-middlend/TEST.md | 476 ++++++++++++++++++++------------ spectec/test-prose/TEST.md | 4 +- 6 files changed, 396 insertions(+), 236 deletions(-) diff --git a/spectec/spec/4-runtime.watsup b/spectec/spec/4-runtime.watsup index 11982f54e3..3d9dc15687 100644 --- a/spectec/spec/4-runtime.watsup +++ b/spectec/spec/4-runtime.watsup @@ -138,21 +138,31 @@ def $local((s; f), x) = f.LOCAL[x] def $with_local(state, localidx, val) : state hint(show %[.LOCAL[%] = %]) def $with_global(state, globalidx, val) : state hint(show %[.GLOBAL[%].VALUE = %]) def $with_table(state, tableidx, nat, ref) : state hint(show %[.TABLE[%].ELEM[%] = %]) -def $with_tableext(state, tableidx, ref*) : state hint(show %[.TABLE[%].ELEM =.. %]) -def $with_mem(state, tableidx, nat, nat, byte*) : state hint(show %[.MEM[%].DATA[% : %] = %]) -def $with_memext(state, tableidx, byte*) : state hint(show %[.MEM[%].DATA =.. %]) +def $with_tableinst(state, tableidx, tableinst) : state hint(show %[.TABLE[%] = %]) +def $with_mem(state, memidx, nat, nat, byte*) : state hint(show %[.MEM[%].DATA[% : %] = %]) +def $with_meminst(state, memidx, meminst) : state hint(show %[.MEM[%] = %]) def $with_elem(state, elemidx, ref*) : state hint(show %[.ELEM[%].ELEM = %]) def $with_data(state, dataidx, byte*) : state hint(show %[.DATA[%].DATA = %]) def $with_local((s; f), x, v) = s; f[.LOCAL[x] = v] def $with_global((s; f), x, v) = s[.GLOBAL[f.MODULE.GLOBAL[x]].VALUE = v]; f def $with_table((s; f), x, i, r) = s[.TABLE[f.MODULE.TABLE[x]].ELEM[i] = r]; f -def $with_tableext((s; f), x, r*) = s[.TABLE[f.MODULE.TABLE[x]].ELEM =.. r*]; f +def $with_tableinst((s; f), x, ti) = s[.TABLE[f.MODULE.TABLE[x]] = ti]; f def $with_mem((s; f), x, i, j, b*) = s[.MEM[f.MODULE.MEM[x]].DATA[i : j] = b*]; f -def $with_memext((s; f), x, b*) = s[.MEM[f.MODULE.MEM[x]].DATA =.. b*]; f +def $with_meminst((s; f), x, mi) = s[.MEM[f.MODULE.MEM[x]] = mi]; f def $with_elem((s; f), x, r*) = s[.ELEM[f.MODULE.ELEM[x]].ELEM = r*]; f def $with_data((s; f), x, b*) = s[.DATA[f.MODULE.DATA[x]].DATA = b*]; f +def $grow_table(tableinst, nat, ref) : tableinst +def $grow_memory(meminst, nat) : meminst +def $grow_table(ti, n, r) = ti' + -- if ti = { TYPE `[i .. j] reftype, ELEM r'* } + -- if i' = $(|r*| + n) + -- if ti' = { TYPE `[i' .. j] reftype, ELEM r'* r^n } +def $grow_memory(mi, n) = mi' + -- if mi = { TYPE (`[i .. j] I8), DATA b* } + -- if i' = $(|b*| + n) + -- if mi' = { TYPE (`[i' .. j] I8), DATA b* $(0^(n * 64 * $Ki)) } ;; Administrative Instructions diff --git a/spectec/spec/6-reduction.watsup b/spectec/spec/6-reduction.watsup index 0d120e844a..46bf3ab182 100644 --- a/spectec/spec/6-reduction.watsup +++ b/spectec/spec/6-reduction.watsup @@ -202,10 +202,10 @@ rule Step_read/table.size: rule Step/table.grow-succeed: - z; ref (CONST I32 n) (TABLE.GROW x) ~> z'; (CONST I32 $(|$table(z, x).ELEM|)) - -- if $with_tableext(z, x, ref^n) = z' - -- if $table(z', 0).TYPE = tabletype - -- Tabletype_ok: |- tabletype : OK + z; ref (CONST I32 n) (TABLE.GROW x) ~> $with_tableinst(z, x, ti'); (CONST I32 $(|$table(z, x).ELEM|)) + -- if $table(z, 0) = ti + -- if $grow_table(ti, n, ref) = ti' + -- Tabletype_ok: |- ti'.TYPE : OK rule Step/table.grow-fail: z; ref (CONST I32 n) (TABLE.GROW x) ~> z; (CONST I32 $(-1)) @@ -310,10 +310,10 @@ rule Step_read/memory.size: rule Step/memory.grow-succeed: - z; (CONST I32 n) (MEMORY.GROW) ~> z'; (CONST I32 $(|$mem(z, 0).DATA| / (64 * $Ki))) - -- if $with_memext(z, 0, 0^(n * 64 * $Ki)) = z' - -- if $mem(z', 0).TYPE = memtype - -- Memtype_ok: |- memtype : OK + z; (CONST I32 n) (MEMORY.GROW) ~> $with_meminst(z, 0, mi'); (CONST I32 $(|$mem(z, 0).DATA| / (64 * $Ki))) + -- if $mem(z, 0) = mi + -- if $grow_memory(mi, n) = mi' + -- Memtype_ok: |- mi'.TYPE : OK rule Step/memory.grow-fail: z; (CONST I32 n) (MEMORY.GROW) ~> z; (CONST I32 $(-1)) diff --git a/spectec/test-frontend/TEST.md b/spectec/test-frontend/TEST.md index 6039efbb58..a704335cc2 100644 --- a/spectec/test-frontend/TEST.md +++ b/spectec/test-frontend/TEST.md @@ -1052,10 +1052,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:159.1-166.5 +;; 4-runtime.watsup:169.1-176.5 rec { -;; 4-runtime.watsup:159.1-166.5 +;; 4-runtime.watsup:169.1-176.5 syntax admininstr = | UNREACHABLE | NOP @@ -1172,20 +1172,20 @@ def with_table : (state, tableidx, nat, ref) -> state ;; 4-runtime.watsup:149.1-149.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:141.1-141.85 -def with_tableext : (state, tableidx, ref*) -> state - ;; 4-runtime.watsup:150.1-150.80 - def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst =.. r*{r}], f) +;; 4-runtime.watsup:141.1-141.84 +def with_tableinst : (state, tableidx, tableinst) -> state + ;; 4-runtime.watsup:150.1-150.74 + def {f : frame, s : store, ti : tableinst, x : idx} with_tableinst(`%;%`(s, f), x, ti) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] = ti], f) -;; 4-runtime.watsup:142.1-142.95 -def with_mem : (state, tableidx, nat, nat, byte*) -> state +;; 4-runtime.watsup:142.1-142.93 +def with_mem : (state, memidx, nat, nat, byte*) -> state ;; 4-runtime.watsup:151.1-151.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:143.1-143.83 -def with_memext : (state, tableidx, byte*) -> state - ;; 4-runtime.watsup:152.1-152.74 - def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst =.. b*{b}], f) +;; 4-runtime.watsup:143.1-143.77 +def with_meminst : (state, memidx, meminst) -> state + ;; 4-runtime.watsup:152.1-152.68 + def {f : frame, mi : meminst, s : store, x : idx} with_meminst(`%;%`(s, f), x, mi) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] = mi], f) ;; 4-runtime.watsup:144.1-144.82 def with_elem : (state, elemidx, ref*) -> state @@ -1197,10 +1197,26 @@ def with_data : (state, dataidx, byte*) -> state ;; 4-runtime.watsup:154.1-154.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:168.1-171.21 +;; 4-runtime.watsup:156.1-156.49 +def grow_table : (tableinst, nat, ref) -> tableinst + ;; 4-runtime.watsup:158.1-161.56 + def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), reftype), ELEM r'*{r'}}) + -- if (i' = (|r*{}| + n)) + -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), reftype), ELEM r'*{r'} :: r^n{}}) + +;; 4-runtime.watsup:157.1-157.41 +def grow_memory : (meminst, nat) -> meminst + ;; 4-runtime.watsup:162.1-165.68 + def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) + -- if (i' = (|b*{b}| + n)) + -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: [(0 ^ ((n * 64) * $Ki))]}) + +;; 4-runtime.watsup:178.1-181.21 rec { -;; 4-runtime.watsup:168.1-171.21 +;; 4-runtime.watsup:178.1-181.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -1592,12 +1608,12 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (ref <: admininstr) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-208.37 - rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state, z' : state}: - `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z', [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($with_tableext(z, x, ref^n{}) = z') - -- if ($table(z', 0).TYPE_tableinst = tabletype) - -- Tabletype_ok: `|-%:OK`(tabletype) + ;; 6-reduction.watsup:204.1-208.36 + rule table.grow-succeed {n : n, ref : ref, ti : tableinst, ti' : tableinst, x : idx, z : state}: + `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti'), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($table(z, 0) = ti) + -- if ($grow_table(ti, n, ref) = ti') + -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) ;; 6-reduction.watsup:210.1-211.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: @@ -1627,12 +1643,12 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if (b*{b} = $bytes_(n, $wrap_(($size(nt <: valtype), n), c))) - ;; 6-reduction.watsup:312.1-316.33 - rule memory.grow-succeed {memtype : memtype, n : n, z : state, z' : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z', [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - -- if ($with_memext(z, 0, 0^((n * 64) * $Ki){}) = z') - -- if ($mem(z', 0).TYPE_meminst = memtype) - -- Memtype_ok: `|-%:OK`(memtype) + ;; 6-reduction.watsup:312.1-316.34 + rule memory.grow-succeed {mi : meminst, mi' : meminst, n : n, z : state}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_meminst(z, 0, mi'), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($mem(z, 0) = mi) + -- if ($grow_memory(mi, n) = mi') + -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) ;; 6-reduction.watsup:318.1-319.59 rule memory.grow-fail {n : n, z : state}: @@ -3294,7 +3310,7 @@ $$ $$ \begin{array}{@{}lcl@{}l@{}} -(\mathit{s} ; \mathit{f})[\mathsf{table}[\mathit{x}].\mathsf{elem} = ..{\mathit{r}^\ast}] &=& \mathit{s}[\mathsf{table}[\mathit{f}.\mathsf{module}.\mathsf{table}[\mathit{x}]].\mathsf{elem} = ..{\mathit{r}^\ast}] ; \mathit{f} & \\ +(\mathit{s} ; \mathit{f})[\mathsf{table}[\mathit{x}] = \mathit{ti}] &=& \mathit{s}[\mathsf{table}[\mathit{f}.\mathsf{module}.\mathsf{table}[\mathit{x}]] = \mathit{ti}] ; \mathit{f} & \\ \end{array} $$ @@ -3306,7 +3322,7 @@ $$ $$ \begin{array}{@{}lcl@{}l@{}} -(\mathit{s} ; \mathit{f})[\mathsf{mem}[\mathit{x}].\mathsf{data} = ..{\mathit{b}^\ast}] &=& \mathit{s}[\mathsf{mem}[\mathit{f}.\mathsf{module}.\mathsf{mem}[\mathit{x}]].\mathsf{data} = ..{\mathit{b}^\ast}] ; \mathit{f} & \\ +(\mathit{s} ; \mathit{f})[\mathsf{mem}[\mathit{x}] = \mathit{mi}] &=& \mathit{s}[\mathsf{mem}[\mathit{f}.\mathsf{module}.\mathsf{mem}[\mathit{x}]] = \mathit{mi}] ; \mathit{f} & \\ \end{array} $$ @@ -3322,7 +3338,27 @@ $$ \end{array} $$ -\vspace{1ex} +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{grow}_{\mathit{table}}(\mathit{ti},\, \mathit{n},\, \mathit{r}) &=& {\mathit{ti}'} &\quad + \mbox{if}~\mathit{ti} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{type}~[\mathit{i} .. \mathit{j}]~\mathit{reftype},\; \mathsf{elem}~{{\mathit{r}'}^\ast} \}\end{array} \\ + &&&&\quad {\land}~{\mathit{i}'} = {|{\mathit{r}^\ast}|} + \mathit{n} \\ + &&&&\quad {\land}~{\mathit{ti}'} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{type}~[{\mathit{i}'} .. \mathit{j}]~\mathit{reftype},\; \mathsf{elem}~{{\mathit{r}'}^\ast}~{\mathit{r}^{\mathit{n}}} \}\end{array} \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{grow}_{\mathit{memory}}(\mathit{mi},\, \mathit{n}) &=& {\mathit{mi}'} &\quad + \mbox{if}~\mathit{mi} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{type}~([\mathit{i} .. \mathit{j}]~\mathsf{i{\scriptstyle8}}),\; \mathsf{data}~{\mathit{b}^\ast} \}\end{array} \\ + &&&&\quad {\land}~{\mathit{i}'} = {|{\mathit{b}^\ast}|} + \mathit{n} \\ + &&&&\quad {\land}~{\mathit{mi}'} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{type}~([{\mathit{i}'} .. \mathit{j}]~\mathsf{i{\scriptstyle8}}),\; \mathsf{data}~{\mathit{b}^\ast}~{0^{\mathit{n} \cdot 64 \cdot \mathrm{Ki}}} \}\end{array} \\ +\end{array} +$$ $$ \begin{array}{@{}lrrl@{}} @@ -3597,10 +3633,10 @@ $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}table.grow{-}succeed}]} \quad & \mathit{z} ; \mathit{ref}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.grow}~\mathit{x}) &\hookrightarrow& {\mathit{z}'} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~{|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}.\mathsf{elem}|}) &\quad - \mbox{if}~\mathit{z}[\mathsf{table}[\mathit{x}].\mathsf{elem} = ..{\mathit{ref}^{\mathit{n}}}] = {\mathit{z}'} \\ - &&&&\quad {\land}~{{\mathit{z}'}.\mathsf{table}}{[0]}.\mathsf{type} = \mathit{tabletype} \\ - &&&&\quad {\land}~{ \vdash }\;\mathit{tabletype} : \mathsf{ok} \\ +{[\textsc{\scriptsize E{-}table.grow{-}succeed}]} \quad & \mathit{z} ; \mathit{ref}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.grow}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{table}[\mathit{x}] = {\mathit{ti}'}] ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~{|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}.\mathsf{elem}|}) &\quad + \mbox{if}~{\mathit{z}.\mathsf{table}}{[0]} = \mathit{ti} \\ + &&&&\quad {\land}~\mathrm{grow}_{\mathit{table}}(\mathit{ti},\, \mathit{n},\, \mathit{ref}) = {\mathit{ti}'} \\ + &&&&\quad {\land}~{ \vdash }\;{\mathit{ti}'}.\mathsf{type} : \mathsf{ok} \\ {[\textsc{\scriptsize E{-}table.grow{-}fail}]} \quad & \mathit{z} ; \mathit{ref}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.grow}~\mathit{x}) &\hookrightarrow& \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~-1) & \\ \end{array} $$ @@ -3697,10 +3733,10 @@ $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}memory.grow{-}succeed}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.grow}) &\hookrightarrow& {\mathit{z}'} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~{|{\mathit{z}.\mathsf{mem}}{[0]}.\mathsf{data}|} / (64 \cdot \mathrm{Ki})) &\quad - \mbox{if}~\mathit{z}[\mathsf{mem}[0].\mathsf{data} = ..{0^{\mathit{n} \cdot 64 \cdot \mathrm{Ki}}}] = {\mathit{z}'} \\ - &&&&\quad {\land}~{{\mathit{z}'}.\mathsf{mem}}{[0]}.\mathsf{type} = \mathit{memtype} \\ - &&&&\quad {\land}~{ \vdash }\;\mathit{memtype} : \mathsf{ok} \\ +{[\textsc{\scriptsize E{-}memory.grow{-}succeed}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.grow}) &\hookrightarrow& \mathit{z}[\mathsf{mem}[0] = {\mathit{mi}'}] ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~{|{\mathit{z}.\mathsf{mem}}{[0]}.\mathsf{data}|} / (64 \cdot \mathrm{Ki})) &\quad + \mbox{if}~{\mathit{z}.\mathsf{mem}}{[0]} = \mathit{mi} \\ + &&&&\quad {\land}~\mathrm{grow}_{\mathit{memory}}(\mathit{mi},\, \mathit{n}) = {\mathit{mi}'} \\ + &&&&\quad {\land}~{ \vdash }\;{\mathit{mi}'}.\mathsf{type} : \mathsf{ok} \\ {[\textsc{\scriptsize E{-}memory.grow{-}fail}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.grow}) &\hookrightarrow& \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~-1) & \\ \end{array} $$ diff --git a/spectec/test-latex/TEST.md b/spectec/test-latex/TEST.md index 38434e3249..14c2a410b7 100644 --- a/spectec/test-latex/TEST.md +++ b/spectec/test-latex/TEST.md @@ -257,6 +257,8 @@ warning: definition `data` was never spliced warning: definition `elem` was never spliced warning: definition `ext` was never spliced warning: definition `global` was never spliced +warning: definition `grow_memory` was never spliced +warning: definition `grow_table` was never spliced warning: definition `local` was never spliced warning: definition `mem` was never spliced warning: definition `min` was never spliced @@ -268,9 +270,9 @@ warning: definition `with_elem` was never spliced warning: definition `with_global` was never spliced warning: definition `with_local` was never spliced warning: definition `with_mem` was never spliced -warning: definition `with_memext` was never spliced +warning: definition `with_meminst` was never spliced warning: definition `with_table` was never spliced -warning: definition `with_tableext` was never spliced +warning: definition `with_tableinst` was never spliced warning: definition `wrap_` was never spliced == Complete. ``` diff --git a/spectec/test-middlend/TEST.md b/spectec/test-middlend/TEST.md index 57ffcf8a3e..8846cd5c0a 100644 --- a/spectec/test-middlend/TEST.md +++ b/spectec/test-middlend/TEST.md @@ -1051,10 +1051,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:159.1-166.5 +;; 4-runtime.watsup:169.1-176.5 rec { -;; 4-runtime.watsup:159.1-166.5 +;; 4-runtime.watsup:169.1-176.5 syntax admininstr = | UNREACHABLE | NOP @@ -1171,20 +1171,20 @@ def with_table : (state, tableidx, nat, ref) -> state ;; 4-runtime.watsup:149.1-149.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:141.1-141.85 -def with_tableext : (state, tableidx, ref*) -> state - ;; 4-runtime.watsup:150.1-150.80 - def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst =.. r*{r}], f) +;; 4-runtime.watsup:141.1-141.84 +def with_tableinst : (state, tableidx, tableinst) -> state + ;; 4-runtime.watsup:150.1-150.74 + def {f : frame, s : store, ti : tableinst, x : idx} with_tableinst(`%;%`(s, f), x, ti) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] = ti], f) -;; 4-runtime.watsup:142.1-142.95 -def with_mem : (state, tableidx, nat, nat, byte*) -> state +;; 4-runtime.watsup:142.1-142.93 +def with_mem : (state, memidx, nat, nat, byte*) -> state ;; 4-runtime.watsup:151.1-151.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:143.1-143.83 -def with_memext : (state, tableidx, byte*) -> state - ;; 4-runtime.watsup:152.1-152.74 - def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst =.. b*{b}], f) +;; 4-runtime.watsup:143.1-143.77 +def with_meminst : (state, memidx, meminst) -> state + ;; 4-runtime.watsup:152.1-152.68 + def {f : frame, mi : meminst, s : store, x : idx} with_meminst(`%;%`(s, f), x, mi) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] = mi], f) ;; 4-runtime.watsup:144.1-144.82 def with_elem : (state, elemidx, ref*) -> state @@ -1196,10 +1196,26 @@ def with_data : (state, dataidx, byte*) -> state ;; 4-runtime.watsup:154.1-154.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:168.1-171.21 +;; 4-runtime.watsup:156.1-156.49 +def grow_table : (tableinst, nat, ref) -> tableinst + ;; 4-runtime.watsup:158.1-161.56 + def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), reftype), ELEM r'*{r'}}) + -- if (i' = (|r*{}| + n)) + -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), reftype), ELEM r'*{r'} :: r^n{}}) + +;; 4-runtime.watsup:157.1-157.41 +def grow_memory : (meminst, nat) -> meminst + ;; 4-runtime.watsup:162.1-165.68 + def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) + -- if (i' = (|b*{b}| + n)) + -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: [(0 ^ ((n * 64) * $Ki))]}) + +;; 4-runtime.watsup:178.1-181.21 rec { -;; 4-runtime.watsup:168.1-171.21 +;; 4-runtime.watsup:178.1-181.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -1591,12 +1607,12 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (ref <: admininstr) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-208.37 - rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state, z' : state}: - `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z', [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($with_tableext(z, x, ref^n{}) = z') - -- if ($table(z', 0).TYPE_tableinst = tabletype) - -- Tabletype_ok: `|-%:OK`(tabletype) + ;; 6-reduction.watsup:204.1-208.36 + rule table.grow-succeed {n : n, ref : ref, ti : tableinst, ti' : tableinst, x : idx, z : state}: + `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti'), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($table(z, 0) = ti) + -- if ($grow_table(ti, n, ref) = ti') + -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) ;; 6-reduction.watsup:210.1-211.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: @@ -1626,12 +1642,12 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if (b*{b} = $bytes_(n, $wrap_(($size(nt <: valtype), n), c))) - ;; 6-reduction.watsup:312.1-316.33 - rule memory.grow-succeed {memtype : memtype, n : n, z : state, z' : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z', [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - -- if ($with_memext(z, 0, 0^((n * 64) * $Ki){}) = z') - -- if ($mem(z', 0).TYPE_meminst = memtype) - -- Memtype_ok: `|-%:OK`(memtype) + ;; 6-reduction.watsup:312.1-316.34 + rule memory.grow-succeed {mi : meminst, mi' : meminst, n : n, z : state}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_meminst(z, 0, mi'), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($mem(z, 0) = mi) + -- if ($grow_memory(mi, n) = mi') + -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) ;; 6-reduction.watsup:318.1-319.59 rule memory.grow-fail {n : n, z : state}: @@ -2719,10 +2735,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:159.1-166.5 +;; 4-runtime.watsup:169.1-176.5 rec { -;; 4-runtime.watsup:159.1-166.5 +;; 4-runtime.watsup:169.1-176.5 syntax admininstr = | UNREACHABLE | NOP @@ -2896,20 +2912,20 @@ def with_table : (state, tableidx, nat, ref) -> state ;; 4-runtime.watsup:149.1-149.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:141.1-141.85 -def with_tableext : (state, tableidx, ref*) -> state - ;; 4-runtime.watsup:150.1-150.80 - def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst =.. r*{r}], f) +;; 4-runtime.watsup:141.1-141.84 +def with_tableinst : (state, tableidx, tableinst) -> state + ;; 4-runtime.watsup:150.1-150.74 + def {f : frame, s : store, ti : tableinst, x : idx} with_tableinst(`%;%`(s, f), x, ti) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] = ti], f) -;; 4-runtime.watsup:142.1-142.95 -def with_mem : (state, tableidx, nat, nat, byte*) -> state +;; 4-runtime.watsup:142.1-142.93 +def with_mem : (state, memidx, nat, nat, byte*) -> state ;; 4-runtime.watsup:151.1-151.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:143.1-143.83 -def with_memext : (state, tableidx, byte*) -> state - ;; 4-runtime.watsup:152.1-152.74 - def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst =.. b*{b}], f) +;; 4-runtime.watsup:143.1-143.77 +def with_meminst : (state, memidx, meminst) -> state + ;; 4-runtime.watsup:152.1-152.68 + def {f : frame, mi : meminst, s : store, x : idx} with_meminst(`%;%`(s, f), x, mi) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] = mi], f) ;; 4-runtime.watsup:144.1-144.82 def with_elem : (state, elemidx, ref*) -> state @@ -2921,10 +2937,26 @@ def with_data : (state, dataidx, byte*) -> state ;; 4-runtime.watsup:154.1-154.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:168.1-171.21 +;; 4-runtime.watsup:156.1-156.49 +def grow_table : (tableinst, nat, ref) -> tableinst + ;; 4-runtime.watsup:158.1-161.56 + def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), reftype), ELEM r'*{r'}}) + -- if (i' = (|r*{}| + n)) + -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), reftype), ELEM r'*{r'} :: r^n{}}) + +;; 4-runtime.watsup:157.1-157.41 +def grow_memory : (meminst, nat) -> meminst + ;; 4-runtime.watsup:162.1-165.68 + def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) + -- if (i' = (|b*{b}| + n)) + -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: [(0 ^ ((n * 64) * $Ki))]}) + +;; 4-runtime.watsup:178.1-181.21 rec { -;; 4-runtime.watsup:168.1-171.21 +;; 4-runtime.watsup:178.1-181.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -3316,12 +3348,12 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-208.37 - rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state, z' : state}: - `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z', [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($with_tableext(z, x, ref^n{}) = z') - -- if ($table(z', 0).TYPE_tableinst = tabletype) - -- Tabletype_ok: `|-%:OK`(tabletype) + ;; 6-reduction.watsup:204.1-208.36 + rule table.grow-succeed {n : n, ref : ref, ti : tableinst, ti' : tableinst, x : idx, z : state}: + `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti'), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($table(z, 0) = ti) + -- if ($grow_table(ti, n, ref) = ti') + -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) ;; 6-reduction.watsup:210.1-211.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: @@ -3351,12 +3383,12 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if (b*{b} = $bytes_(n, $wrap_(($size($valtype_numtype(nt)), n), c))) - ;; 6-reduction.watsup:312.1-316.33 - rule memory.grow-succeed {memtype : memtype, n : n, z : state, z' : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z', [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - -- if ($with_memext(z, 0, 0^((n * 64) * $Ki){}) = z') - -- if ($mem(z', 0).TYPE_meminst = memtype) - -- Memtype_ok: `|-%:OK`(memtype) + ;; 6-reduction.watsup:312.1-316.34 + rule memory.grow-succeed {mi : meminst, mi' : meminst, n : n, z : state}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_meminst(z, 0, mi'), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($mem(z, 0) = mi) + -- if ($grow_memory(mi, n) = mi') + -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) ;; 6-reduction.watsup:318.1-319.59 rule memory.grow-fail {n : n, z : state}: @@ -4446,10 +4478,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:159.1-166.5 +;; 4-runtime.watsup:169.1-176.5 rec { -;; 4-runtime.watsup:159.1-166.5 +;; 4-runtime.watsup:169.1-176.5 syntax admininstr = | UNREACHABLE | NOP @@ -4623,20 +4655,20 @@ def with_table : (state, tableidx, nat, ref) -> state ;; 4-runtime.watsup:149.1-149.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:141.1-141.85 -def with_tableext : (state, tableidx, ref*) -> state - ;; 4-runtime.watsup:150.1-150.80 - def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst =.. r*{r}], f) +;; 4-runtime.watsup:141.1-141.84 +def with_tableinst : (state, tableidx, tableinst) -> state + ;; 4-runtime.watsup:150.1-150.74 + def {f : frame, s : store, ti : tableinst, x : idx} with_tableinst(`%;%`(s, f), x, ti) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] = ti], f) -;; 4-runtime.watsup:142.1-142.95 -def with_mem : (state, tableidx, nat, nat, byte*) -> state +;; 4-runtime.watsup:142.1-142.93 +def with_mem : (state, memidx, nat, nat, byte*) -> state ;; 4-runtime.watsup:151.1-151.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:143.1-143.83 -def with_memext : (state, tableidx, byte*) -> state - ;; 4-runtime.watsup:152.1-152.74 - def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst =.. b*{b}], f) +;; 4-runtime.watsup:143.1-143.77 +def with_meminst : (state, memidx, meminst) -> state + ;; 4-runtime.watsup:152.1-152.68 + def {f : frame, mi : meminst, s : store, x : idx} with_meminst(`%;%`(s, f), x, mi) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] = mi], f) ;; 4-runtime.watsup:144.1-144.82 def with_elem : (state, elemidx, ref*) -> state @@ -4648,10 +4680,26 @@ def with_data : (state, dataidx, byte*) -> state ;; 4-runtime.watsup:154.1-154.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:168.1-171.21 +;; 4-runtime.watsup:156.1-156.49 +def grow_table : (tableinst, nat, ref) -> tableinst + ;; 4-runtime.watsup:158.1-161.56 + def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), reftype), ELEM r'*{r'}}) + -- if (i' = (|r*{}| + n)) + -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), reftype), ELEM r'*{r'} :: r^n{}}) + +;; 4-runtime.watsup:157.1-157.41 +def grow_memory : (meminst, nat) -> meminst + ;; 4-runtime.watsup:162.1-165.68 + def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) + -- if (i' = (|b*{b}| + n)) + -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: [(0 ^ ((n * 64) * $Ki))]}) + +;; 4-runtime.watsup:178.1-181.21 rec { -;; 4-runtime.watsup:168.1-171.21 +;; 4-runtime.watsup:178.1-181.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -5043,12 +5091,12 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-208.37 - rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state, z' : state}: - `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z', [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($with_tableext(z, x, ref^n{}) = z') - -- if ($table(z', 0).TYPE_tableinst = tabletype) - -- Tabletype_ok: `|-%:OK`(tabletype) + ;; 6-reduction.watsup:204.1-208.36 + rule table.grow-succeed {n : n, ref : ref, ti : tableinst, ti' : tableinst, x : idx, z : state}: + `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti'), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($table(z, 0) = ti) + -- if ($grow_table(ti, n, ref) = ti') + -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) ;; 6-reduction.watsup:210.1-211.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: @@ -5078,12 +5126,12 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if (b*{b} = $bytes_(n, $wrap_((!($size($valtype_numtype(nt))), n), c))) - ;; 6-reduction.watsup:312.1-316.33 - rule memory.grow-succeed {memtype : memtype, n : n, z : state, z' : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z', [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - -- if ($with_memext(z, 0, 0^((n * 64) * $Ki){}) = z') - -- if ($mem(z', 0).TYPE_meminst = memtype) - -- Memtype_ok: `|-%:OK`(memtype) + ;; 6-reduction.watsup:312.1-316.34 + rule memory.grow-succeed {mi : meminst, mi' : meminst, n : n, z : state}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_meminst(z, 0, mi'), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($mem(z, 0) = mi) + -- if ($grow_memory(mi, n) = mi') + -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) ;; 6-reduction.watsup:318.1-319.59 rule memory.grow-fail {n : n, z : state}: @@ -6182,10 +6230,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:159.1-166.5 +;; 4-runtime.watsup:169.1-176.5 rec { -;; 4-runtime.watsup:159.1-166.5 +;; 4-runtime.watsup:169.1-176.5 syntax admininstr = | UNREACHABLE | NOP @@ -6359,20 +6407,20 @@ def with_table : (state, tableidx, nat, ref) -> state ;; 4-runtime.watsup:149.1-149.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:141.1-141.85 -def with_tableext : (state, tableidx, ref*) -> state - ;; 4-runtime.watsup:150.1-150.80 - def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst =.. r*{r}], f) +;; 4-runtime.watsup:141.1-141.84 +def with_tableinst : (state, tableidx, tableinst) -> state + ;; 4-runtime.watsup:150.1-150.74 + def {f : frame, s : store, ti : tableinst, x : idx} with_tableinst(`%;%`(s, f), x, ti) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] = ti], f) -;; 4-runtime.watsup:142.1-142.95 -def with_mem : (state, tableidx, nat, nat, byte*) -> state +;; 4-runtime.watsup:142.1-142.93 +def with_mem : (state, memidx, nat, nat, byte*) -> state ;; 4-runtime.watsup:151.1-151.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:143.1-143.83 -def with_memext : (state, tableidx, byte*) -> state - ;; 4-runtime.watsup:152.1-152.74 - def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst =.. b*{b}], f) +;; 4-runtime.watsup:143.1-143.77 +def with_meminst : (state, memidx, meminst) -> state + ;; 4-runtime.watsup:152.1-152.68 + def {f : frame, mi : meminst, s : store, x : idx} with_meminst(`%;%`(s, f), x, mi) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] = mi], f) ;; 4-runtime.watsup:144.1-144.82 def with_elem : (state, elemidx, ref*) -> state @@ -6384,10 +6432,26 @@ def with_data : (state, dataidx, byte*) -> state ;; 4-runtime.watsup:154.1-154.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:168.1-171.21 +;; 4-runtime.watsup:156.1-156.49 +def grow_table : (tableinst, nat, ref) -> tableinst + ;; 4-runtime.watsup:158.1-161.56 + def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), reftype), ELEM r'*{r'}}) + -- if (i' = (|r*{}| + n)) + -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), reftype), ELEM r'*{r'} :: r^n{}}) + +;; 4-runtime.watsup:157.1-157.41 +def grow_memory : (meminst, nat) -> meminst + ;; 4-runtime.watsup:162.1-165.68 + def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) + -- if (i' = (|b*{b}| + n)) + -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: [(0 ^ ((n * 64) * $Ki))]}) + +;; 4-runtime.watsup:178.1-181.21 rec { -;; 4-runtime.watsup:168.1-171.21 +;; 4-runtime.watsup:178.1-181.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -6785,12 +6849,12 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-208.37 - rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state, z' : state}: - `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z', [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($with_tableext(z, x, ref^n{}) = z') - -- if ($table(z', 0).TYPE_tableinst = tabletype) - -- Tabletype_ok: `|-%:OK`(tabletype) + ;; 6-reduction.watsup:204.1-208.36 + rule table.grow-succeed {n : n, ref : ref, ti : tableinst, ti' : tableinst, x : idx, z : state}: + `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti'), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($table(z, 0) = ti) + -- if ($grow_table(ti, n, ref) = ti') + -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) ;; 6-reduction.watsup:210.1-211.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: @@ -6824,12 +6888,12 @@ relation Step: `%~>%`(config, config) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (b*{b} = $bytes_(n, $wrap_((o0, n), c))) - ;; 6-reduction.watsup:312.1-316.33 - rule memory.grow-succeed {memtype : memtype, n : n, z : state, z' : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z', [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - -- if ($with_memext(z, 0, 0^((n * 64) * $Ki){}) = z') - -- if ($mem(z', 0).TYPE_meminst = memtype) - -- Memtype_ok: `|-%:OK`(memtype) + ;; 6-reduction.watsup:312.1-316.34 + rule memory.grow-succeed {mi : meminst, mi' : meminst, n : n, z : state}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_meminst(z, 0, mi'), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($mem(z, 0) = mi) + -- if ($grow_memory(mi, n) = mi') + -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) ;; 6-reduction.watsup:318.1-319.59 rule memory.grow-fail {n : n, z : state}: @@ -7928,10 +7992,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:159.1-166.5 +;; 4-runtime.watsup:169.1-176.5 rec { -;; 4-runtime.watsup:159.1-166.5 +;; 4-runtime.watsup:169.1-176.5 syntax admininstr = | UNREACHABLE | NOP @@ -8105,20 +8169,20 @@ def with_table : (state, tableidx, nat, ref) -> state ;; 4-runtime.watsup:149.1-149.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:141.1-141.85 -def with_tableext : (state, tableidx, ref*) -> state - ;; 4-runtime.watsup:150.1-150.80 - def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst =.. r*{r}], f) +;; 4-runtime.watsup:141.1-141.84 +def with_tableinst : (state, tableidx, tableinst) -> state + ;; 4-runtime.watsup:150.1-150.74 + def {f : frame, s : store, ti : tableinst, x : idx} with_tableinst(`%;%`(s, f), x, ti) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] = ti], f) -;; 4-runtime.watsup:142.1-142.95 -def with_mem : (state, tableidx, nat, nat, byte*) -> state +;; 4-runtime.watsup:142.1-142.93 +def with_mem : (state, memidx, nat, nat, byte*) -> state ;; 4-runtime.watsup:151.1-151.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:143.1-143.83 -def with_memext : (state, tableidx, byte*) -> state - ;; 4-runtime.watsup:152.1-152.74 - def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst =.. b*{b}], f) +;; 4-runtime.watsup:143.1-143.77 +def with_meminst : (state, memidx, meminst) -> state + ;; 4-runtime.watsup:152.1-152.68 + def {f : frame, mi : meminst, s : store, x : idx} with_meminst(`%;%`(s, f), x, mi) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] = mi], f) ;; 4-runtime.watsup:144.1-144.82 def with_elem : (state, elemidx, ref*) -> state @@ -8130,10 +8194,26 @@ def with_data : (state, dataidx, byte*) -> state ;; 4-runtime.watsup:154.1-154.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:168.1-171.21 +;; 4-runtime.watsup:156.1-156.49 +def grow_table : (tableinst, nat, ref) -> tableinst + ;; 4-runtime.watsup:158.1-161.56 + def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), reftype), ELEM r'*{r'}}) + -- if (i' = (|r*{}| + n)) + -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), reftype), ELEM r'*{r'} :: r^n{}}) + +;; 4-runtime.watsup:157.1-157.41 +def grow_memory : (meminst, nat) -> meminst + ;; 4-runtime.watsup:162.1-165.68 + def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) + -- if (i' = (|b*{b}| + n)) + -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: [(0 ^ ((n * 64) * $Ki))]}) + +;; 4-runtime.watsup:178.1-181.21 rec { -;; 4-runtime.watsup:168.1-171.21 +;; 4-runtime.watsup:178.1-181.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -8531,12 +8611,12 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-208.37 - rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state, z' : state}: - `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z', [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($with_tableext(z, x, ref^n{}) = z') - -- if ($table(z', 0).TYPE_tableinst = tabletype) - -- Tabletype_ok: `|-%:OK`(tabletype) + ;; 6-reduction.watsup:204.1-208.36 + rule table.grow-succeed {n : n, ref : ref, ti : tableinst, ti' : tableinst, x : idx, z : state}: + `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti'), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($table(z, 0) = ti) + -- if ($grow_table(ti, n, ref) = ti') + -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) ;; 6-reduction.watsup:210.1-211.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: @@ -8570,12 +8650,12 @@ relation Step: `%~>%`(config, config) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (b*{b} = $bytes_(n, $wrap_((o0, n), c))) - ;; 6-reduction.watsup:312.1-316.33 - rule memory.grow-succeed {memtype : memtype, n : n, z : state, z' : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z', [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - -- if ($with_memext(z, 0, 0^((n * 64) * $Ki){}) = z') - -- if ($mem(z', 0).TYPE_meminst = memtype) - -- Memtype_ok: `|-%:OK`(memtype) + ;; 6-reduction.watsup:312.1-316.34 + rule memory.grow-succeed {mi : meminst, mi' : meminst, n : n, z : state}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_meminst(z, 0, mi'), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($mem(z, 0) = mi) + -- if ($grow_memory(mi, n) = mi') + -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) ;; 6-reduction.watsup:318.1-319.59 rule memory.grow-fail {n : n, z : state}: @@ -9722,10 +9802,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:159.1-166.5 +;; 4-runtime.watsup:169.1-176.5 rec { -;; 4-runtime.watsup:159.1-166.5 +;; 4-runtime.watsup:169.1-176.5 syntax admininstr = | UNREACHABLE | NOP @@ -9899,20 +9979,20 @@ def with_table : (state, tableidx, nat, ref) -> state ;; 4-runtime.watsup:149.1-149.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:141.1-141.85 -def with_tableext : (state, tableidx, ref*) -> state - ;; 4-runtime.watsup:150.1-150.80 - def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst =.. r*{r}], f) +;; 4-runtime.watsup:141.1-141.84 +def with_tableinst : (state, tableidx, tableinst) -> state + ;; 4-runtime.watsup:150.1-150.74 + def {f : frame, s : store, ti : tableinst, x : idx} with_tableinst(`%;%`(s, f), x, ti) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] = ti], f) -;; 4-runtime.watsup:142.1-142.95 -def with_mem : (state, tableidx, nat, nat, byte*) -> state +;; 4-runtime.watsup:142.1-142.93 +def with_mem : (state, memidx, nat, nat, byte*) -> state ;; 4-runtime.watsup:151.1-151.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:143.1-143.83 -def with_memext : (state, tableidx, byte*) -> state - ;; 4-runtime.watsup:152.1-152.74 - def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst =.. b*{b}], f) +;; 4-runtime.watsup:143.1-143.77 +def with_meminst : (state, memidx, meminst) -> state + ;; 4-runtime.watsup:152.1-152.68 + def {f : frame, mi : meminst, s : store, x : idx} with_meminst(`%;%`(s, f), x, mi) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] = mi], f) ;; 4-runtime.watsup:144.1-144.82 def with_elem : (state, elemidx, ref*) -> state @@ -9924,10 +10004,26 @@ def with_data : (state, dataidx, byte*) -> state ;; 4-runtime.watsup:154.1-154.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:168.1-171.21 +;; 4-runtime.watsup:156.1-156.49 +def grow_table : (tableinst, nat, ref) -> tableinst + ;; 4-runtime.watsup:158.1-161.56 + def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), reftype), ELEM r'*{r'}}) + -- if (i' = (|r*{}| + n)) + -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), reftype), ELEM r'*{r'} :: r^n{}}) + +;; 4-runtime.watsup:157.1-157.41 +def grow_memory : (meminst, nat) -> meminst + ;; 4-runtime.watsup:162.1-165.68 + def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) + -- if (i' = (|b*{b}| + n)) + -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: [(0 ^ ((n * 64) * $Ki))]}) + +;; 4-runtime.watsup:178.1-181.21 rec { -;; 4-runtime.watsup:168.1-171.21 +;; 4-runtime.watsup:178.1-181.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -10333,12 +10429,12 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-208.37 - rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state, z' : state}: - `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z', [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($with_tableext(z, x, ref^n{}) = z') - -- if ($table(z', 0).TYPE_tableinst = tabletype) - -- Tabletype_ok: `|-%:OK`(tabletype) + ;; 6-reduction.watsup:204.1-208.36 + rule table.grow-succeed {n : n, ref : ref, ti : tableinst, ti' : tableinst, x : idx, z : state}: + `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti'), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($table(z, 0) = ti) + -- if ($grow_table(ti, n, ref) = ti') + -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) ;; 6-reduction.watsup:210.1-211.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: @@ -10372,12 +10468,12 @@ relation Step: `%~>%`(config, config) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (b*{b} = $bytes_(n, $wrap_((o0, n), c))) - ;; 6-reduction.watsup:312.1-316.33 - rule memory.grow-succeed {memtype : memtype, n : n, z : state, z' : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z', [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - -- if ($with_memext(z, 0, 0^((n * 64) * $Ki){}) = z') - -- if ($mem(z', 0).TYPE_meminst = memtype) - -- Memtype_ok: `|-%:OK`(memtype) + ;; 6-reduction.watsup:312.1-316.34 + rule memory.grow-succeed {mi : meminst, mi' : meminst, n : n, z : state}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_meminst(z, 0, mi'), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($mem(z, 0) = mi) + -- if ($grow_memory(mi, n) = mi') + -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) ;; 6-reduction.watsup:318.1-319.59 rule memory.grow-fail {n : n, z : state}: @@ -11527,10 +11623,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:159.1-166.5 +;; 4-runtime.watsup:169.1-176.5 rec { -;; 4-runtime.watsup:159.1-166.5 +;; 4-runtime.watsup:169.1-176.5 syntax admininstr = | UNREACHABLE | NOP @@ -11704,20 +11800,20 @@ def with_table : (state, tableidx, nat, ref) -> state ;; 4-runtime.watsup:149.1-149.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:141.1-141.85 -def with_tableext : (state, tableidx, ref*) -> state - ;; 4-runtime.watsup:150.1-150.80 - def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst =.. r*{r}], f) +;; 4-runtime.watsup:141.1-141.84 +def with_tableinst : (state, tableidx, tableinst) -> state + ;; 4-runtime.watsup:150.1-150.74 + def {f : frame, s : store, ti : tableinst, x : idx} with_tableinst(`%;%`(s, f), x, ti) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] = ti], f) -;; 4-runtime.watsup:142.1-142.95 -def with_mem : (state, tableidx, nat, nat, byte*) -> state +;; 4-runtime.watsup:142.1-142.93 +def with_mem : (state, memidx, nat, nat, byte*) -> state ;; 4-runtime.watsup:151.1-151.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:143.1-143.83 -def with_memext : (state, tableidx, byte*) -> state - ;; 4-runtime.watsup:152.1-152.74 - def {b* : byte*, f : frame, s : store, x : idx} with_memext(`%;%`(s, f), x, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst =.. b*{b}], f) +;; 4-runtime.watsup:143.1-143.77 +def with_meminst : (state, memidx, meminst) -> state + ;; 4-runtime.watsup:152.1-152.68 + def {f : frame, mi : meminst, s : store, x : idx} with_meminst(`%;%`(s, f), x, mi) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] = mi], f) ;; 4-runtime.watsup:144.1-144.82 def with_elem : (state, elemidx, ref*) -> state @@ -11729,10 +11825,26 @@ def with_data : (state, dataidx, byte*) -> state ;; 4-runtime.watsup:154.1-154.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:168.1-171.21 +;; 4-runtime.watsup:156.1-156.49 +def grow_table : (tableinst, nat, ref) -> tableinst + ;; 4-runtime.watsup:158.1-161.56 + def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), reftype), ELEM r'*{r'}}) + -- if (i' = (|r*{}| + n)) + -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), reftype), ELEM r'*{r'} :: r^n{}}) + +;; 4-runtime.watsup:157.1-157.41 +def grow_memory : (meminst, nat) -> meminst + ;; 4-runtime.watsup:162.1-165.68 + def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) + -- if (i' = (|b*{b}| + n)) + -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: [(0 ^ ((n * 64) * $Ki))]}) + +;; 4-runtime.watsup:178.1-181.21 rec { -;; 4-runtime.watsup:168.1-171.21 +;; 4-runtime.watsup:178.1-181.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -12138,12 +12250,12 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-208.37 - rule table.grow-succeed {n : n, ref : ref, tabletype : tabletype, x : idx, z : state, z' : state}: - `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z', [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- where z' = $with_tableext(z, x, ref^n{}) - -- where tabletype = $table(z', 0).TYPE_tableinst - -- Tabletype_ok: `|-%:OK`(tabletype) + ;; 6-reduction.watsup:204.1-208.36 + rule table.grow-succeed {n : n, ref : ref, ti : tableinst, ti' : tableinst, x : idx, z : state}: + `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti'), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- where ti = $table(z, 0) + -- where ti' = $grow_table(ti, n, ref) + -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) ;; 6-reduction.watsup:210.1-211.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: @@ -12177,12 +12289,12 @@ relation Step: `%~>%`(config, config) -- where ?(o0) = $size($valtype_numtype(nt)) -- where b*{b} = $bytes_(n, $wrap_((o0, n), c)) - ;; 6-reduction.watsup:312.1-316.33 - rule memory.grow-succeed {memtype : memtype, n : n, z : state, z' : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z', [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - -- where z' = $with_memext(z, 0, 0^((n * 64) * $Ki){}) - -- where memtype = $mem(z', 0).TYPE_meminst - -- Memtype_ok: `|-%:OK`(memtype) + ;; 6-reduction.watsup:312.1-316.34 + rule memory.grow-succeed {mi : meminst, mi' : meminst, n : n, z : state}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_meminst(z, 0, mi'), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- where mi = $mem(z, 0) + -- where mi' = $grow_memory(mi, n) + -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) ;; 6-reduction.watsup:318.1-319.59 rule memory.grow-fail {n : n, z : state}: diff --git a/spectec/test-prose/TEST.md b/spectec/test-prose/TEST.md index 6e5c47d6e0..92ef363de5 100644 --- a/spectec/test-prose/TEST.md +++ b/spectec/test-prose/TEST.md @@ -370,7 +370,7 @@ table.grow 3. Assert: Due to validation, a value is on the top of the stack. 4. Pop YetE ((ref <: admininstr)) from the stack. 5. If YetC (), then: - a. YetI: Perform z'. + a. YetI: Perform $with_tableinst(z, x, ti'). b. Push YetE (CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)) to the stack. 6. If YetC (), then: a. YetI: Perform z. @@ -399,7 +399,7 @@ memory.grow 1. Assert: Due to validation, a value of value type i32 is on the top of the stack. 2. Pop YetE (CONST_admininstr(I32_numtype, n)) from the stack. 3. If YetC (), then: - a. YetI: Perform z'. + a. YetI: Perform $with_meminst(z, 0, mi'). b. Push YetE (CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))) to the stack. 4. If YetC (), then: a. YetI: Perform z. From 7d757da9c2323e599f2fa4ce079971c6b6b7022b Mon Sep 17 00:00:00 2001 From: Wonho Date: Fri, 16 Jun 2023 17:16:26 +0900 Subject: [PATCH 07/49] Fix typos --- spectec/spec/1-syntax.watsup | 2 +- spectec/spec/4-runtime.watsup | 12 +- spectec/spec/6-reduction.watsup | 2 +- spectec/test-frontend/TEST.md | 46 +++---- spectec/test-middlend/TEST.md | 210 ++++++++++++++++---------------- 5 files changed, 136 insertions(+), 136 deletions(-) diff --git a/spectec/spec/1-syntax.watsup b/spectec/spec/1-syntax.watsup index 1ef353c052..76a297e91c 100644 --- a/spectec/spec/1-syntax.watsup +++ b/spectec/spec/1-syntax.watsup @@ -57,7 +57,7 @@ syntax resulttype hint(desc "result type") = valtype* syntax limits hint(desc "limits") = - `[u32 .. u32] + `[u32 .. u32?] syntax globaltype hint(desc "global type") = MUT? valtype syntax functype hint(desc "function type") = diff --git a/spectec/spec/4-runtime.watsup b/spectec/spec/4-runtime.watsup index 3d9dc15687..1fe9c44a5d 100644 --- a/spectec/spec/4-runtime.watsup +++ b/spectec/spec/4-runtime.watsup @@ -156,13 +156,13 @@ def $with_data((s; f), x, b*) = s[.DATA[f.MODULE.DATA[x]].DATA = b*]; f def $grow_table(tableinst, nat, ref) : tableinst def $grow_memory(meminst, nat) : meminst def $grow_table(ti, n, r) = ti' - -- if ti = { TYPE `[i .. j] reftype, ELEM r'* } - -- if i' = $(|r*| + n) - -- if ti' = { TYPE `[i' .. j] reftype, ELEM r'* r^n } + -- if ti = { TYPE `[i .. j?] reftype, ELEM r'* } + -- if i' = $(|r'*| + n) + -- if ti' = { TYPE `[i' .. j?] reftype, ELEM r'* r^n } def $grow_memory(mi, n) = mi' - -- if mi = { TYPE (`[i .. j] I8), DATA b* } - -- if i' = $(|b*| + n) - -- if mi' = { TYPE (`[i' .. j] I8), DATA b* $(0^(n * 64 * $Ki)) } + -- if mi = { TYPE (`[i .. j?] I8), DATA b* } + -- if i' = $(|b*| / (64 * $Ki) + n) + -- if mi' = { TYPE (`[i' .. j?] I8), DATA b* 0^(n * 64 * $Ki) } ;; Administrative Instructions diff --git a/spectec/spec/6-reduction.watsup b/spectec/spec/6-reduction.watsup index 46bf3ab182..b987bc51da 100644 --- a/spectec/spec/6-reduction.watsup +++ b/spectec/spec/6-reduction.watsup @@ -203,7 +203,7 @@ rule Step_read/table.size: rule Step/table.grow-succeed: z; ref (CONST I32 n) (TABLE.GROW x) ~> $with_tableinst(z, x, ti'); (CONST I32 $(|$table(z, x).ELEM|)) - -- if $table(z, 0) = ti + -- if $table(z, x) = ti -- if $grow_table(ti, n, ref) = ti' -- Tabletype_ok: |- ti'.TYPE : OK diff --git a/spectec/test-frontend/TEST.md b/spectec/test-frontend/TEST.md index a704335cc2..cc823d5eb4 100644 --- a/spectec/test-frontend/TEST.md +++ b/spectec/test-frontend/TEST.md @@ -85,8 +85,8 @@ syntax fn = ;; 1-syntax.watsup:56.1-57.11 syntax resulttype = valtype* -;; 1-syntax.watsup:59.1-60.16 -syntax limits = `[%..%]`(u32, u32) +;; 1-syntax.watsup:59.1-60.17 +syntax limits = `[%..%?]`(u32, u32?) ;; 1-syntax.watsup:61.1-62.15 syntax globaltype = `MUT%?%`(()?, valtype) @@ -379,7 +379,7 @@ syntax context = {FUNC functype*, GLOBAL globaltype*, TABLE tabletype*, MEM memt relation Limits_ok: `|-%:%`(limits, nat) ;; 3-typing.watsup:22.1-24.24 rule _ {k : nat, n_1 : n, n_2 : n}: - `|-%:%`(`[%..%]`(n_1, n_2), k) + `|-%:%`(`[%..%?]`(n_1, ?(n_2)), k) -- if ((n_1 <= n_2) /\ (n_2 <= k)) ;; 3-typing.watsup:15.1-15.64 @@ -451,7 +451,7 @@ relation Resulttype_sub: `|-%*<:%*`(valtype*, valtype*) relation Limits_sub: `|-%<:%`(limits, limits) ;; 3-typing.watsup:83.1-86.21 rule _ {n_11 : n, n_12 : n, n_21 : n, n_22 : n}: - `|-%<:%`(`[%..%]`(n_11, n_12), `[%..%]`(n_21, n_22)) + `|-%<:%`(`[%..%?]`(n_11, ?(n_12)), `[%..%?]`(n_21, ?(n_22))) -- if (n_11 >= n_21) -- if (n_12 <= n_22) @@ -1199,19 +1199,19 @@ def with_data : (state, dataidx, byte*) -> state ;; 4-runtime.watsup:156.1-156.49 def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:158.1-161.56 - def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' - -- if (ti = {TYPE `%%`(`[%..%]`(i, j), reftype), ELEM r'*{r'}}) - -- if (i' = (|r*{}| + n)) - -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), reftype), ELEM r'*{r'} :: r^n{}}) + ;; 4-runtime.watsup:158.1-161.57 + def {i : nat, i' : nat, j? : nat?, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' + -- if (ti = {TYPE `%%`(`[%..%?]`(i, j?{j}), reftype), ELEM r'*{r'}}) + -- if (i' = (|r'*{r'}| + n)) + -- if (ti' = {TYPE `%%`(`[%..%?]`(i', j?{j}), reftype), ELEM r'*{r'} :: r^n{}}) ;; 4-runtime.watsup:157.1-157.41 def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:162.1-165.68 - def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' - -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) - -- if (i' = (|b*{b}| + n)) - -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: [(0 ^ ((n * 64) * $Ki))]}) + ;; 4-runtime.watsup:162.1-165.66 + def {b* : byte*, i : nat, i' : nat, j? : nat?, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' + -- if (mi = {TYPE `%I8`(`[%..%?]`(i, j?{j})), DATA b*{b}}) + -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) + -- if (mi' = {TYPE `%I8`(`[%..%?]`(i', j?{j})), DATA b*{b} :: 0^((n * 64) * $Ki){}}) ;; 4-runtime.watsup:178.1-181.21 rec { @@ -1611,7 +1611,7 @@ relation Step: `%~>%`(config, config) ;; 6-reduction.watsup:204.1-208.36 rule table.grow-succeed {n : n, ref : ref, ti : tableinst, ti' : tableinst, x : idx, z : state}: `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti'), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($table(z, 0) = ti) + -- if ($table(z, x) = ti) -- if ($grow_table(ti, n, ref) = ti') -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) @@ -1713,7 +1713,7 @@ $$ $$ \begin{array}{@{}lrrl@{}} \mbox{(result type)} & \mathit{resulttype} &::=& {\mathit{valtype}^\ast} \\ -\mbox{(limits)} & \mathit{limits} &::=& [\mathit{u{\scriptstyle32}} .. \mathit{u{\scriptstyle32}}] \\ +\mbox{(limits)} & \mathit{limits} &::=& [\mathit{u{\scriptstyle32}} .. {\mathit{u{\scriptstyle32}}^?}] \\ \mbox{(global type)} & \mathit{globaltype} &::=& {\mathsf{mut}^?}~\mathit{valtype} \\ \mbox{(function type)} & \mathit{functype} &::=& \mathit{resulttype} \rightarrow \mathit{resulttype} \\ \mbox{(table type)} & \mathit{tabletype} &::=& \mathit{limits}~\mathit{reftype} \\ @@ -3342,10 +3342,10 @@ $$ \begin{array}{@{}lcl@{}l@{}} \mathrm{grow}_{\mathit{table}}(\mathit{ti},\, \mathit{n},\, \mathit{r}) &=& {\mathit{ti}'} &\quad \mbox{if}~\mathit{ti} = \{ \begin{array}[t]{@{}l@{}} -\mathsf{type}~[\mathit{i} .. \mathit{j}]~\mathit{reftype},\; \mathsf{elem}~{{\mathit{r}'}^\ast} \}\end{array} \\ - &&&&\quad {\land}~{\mathit{i}'} = {|{\mathit{r}^\ast}|} + \mathit{n} \\ +\mathsf{type}~[\mathit{i} .. {\mathit{j}^?}]~\mathit{reftype},\; \mathsf{elem}~{{\mathit{r}'}^\ast} \}\end{array} \\ + &&&&\quad {\land}~{\mathit{i}'} = {|{{\mathit{r}'}^\ast}|} + \mathit{n} \\ &&&&\quad {\land}~{\mathit{ti}'} = \{ \begin{array}[t]{@{}l@{}} -\mathsf{type}~[{\mathit{i}'} .. \mathit{j}]~\mathit{reftype},\; \mathsf{elem}~{{\mathit{r}'}^\ast}~{\mathit{r}^{\mathit{n}}} \}\end{array} \\ +\mathsf{type}~[{\mathit{i}'} .. {\mathit{j}^?}]~\mathit{reftype},\; \mathsf{elem}~{{\mathit{r}'}^\ast}~{\mathit{r}^{\mathit{n}}} \}\end{array} \\ \end{array} $$ @@ -3353,10 +3353,10 @@ $$ \begin{array}{@{}lcl@{}l@{}} \mathrm{grow}_{\mathit{memory}}(\mathit{mi},\, \mathit{n}) &=& {\mathit{mi}'} &\quad \mbox{if}~\mathit{mi} = \{ \begin{array}[t]{@{}l@{}} -\mathsf{type}~([\mathit{i} .. \mathit{j}]~\mathsf{i{\scriptstyle8}}),\; \mathsf{data}~{\mathit{b}^\ast} \}\end{array} \\ - &&&&\quad {\land}~{\mathit{i}'} = {|{\mathit{b}^\ast}|} + \mathit{n} \\ +\mathsf{type}~([\mathit{i} .. {\mathit{j}^?}]~\mathsf{i{\scriptstyle8}}),\; \mathsf{data}~{\mathit{b}^\ast} \}\end{array} \\ + &&&&\quad {\land}~{\mathit{i}'} = {|{\mathit{b}^\ast}|} / (64 \cdot \mathrm{Ki}) + \mathit{n} \\ &&&&\quad {\land}~{\mathit{mi}'} = \{ \begin{array}[t]{@{}l@{}} -\mathsf{type}~([{\mathit{i}'} .. \mathit{j}]~\mathsf{i{\scriptstyle8}}),\; \mathsf{data}~{\mathit{b}^\ast}~{0^{\mathit{n} \cdot 64 \cdot \mathrm{Ki}}} \}\end{array} \\ +\mathsf{type}~([{\mathit{i}'} .. {\mathit{j}^?}]~\mathsf{i{\scriptstyle8}}),\; \mathsf{data}~{\mathit{b}^\ast}~{0^{\mathit{n} \cdot 64 \cdot \mathrm{Ki}}} \}\end{array} \\ \end{array} $$ @@ -3634,7 +3634,7 @@ $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} {[\textsc{\scriptsize E{-}table.grow{-}succeed}]} \quad & \mathit{z} ; \mathit{ref}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.grow}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{table}[\mathit{x}] = {\mathit{ti}'}] ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~{|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}.\mathsf{elem}|}) &\quad - \mbox{if}~{\mathit{z}.\mathsf{table}}{[0]} = \mathit{ti} \\ + \mbox{if}~{\mathit{z}.\mathsf{table}}{[\mathit{x}]} = \mathit{ti} \\ &&&&\quad {\land}~\mathrm{grow}_{\mathit{table}}(\mathit{ti},\, \mathit{n},\, \mathit{ref}) = {\mathit{ti}'} \\ &&&&\quad {\land}~{ \vdash }\;{\mathit{ti}'}.\mathsf{type} : \mathsf{ok} \\ {[\textsc{\scriptsize E{-}table.grow{-}fail}]} \quad & \mathit{z} ; \mathit{ref}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.grow}~\mathit{x}) &\hookrightarrow& \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~-1) & \\ diff --git a/spectec/test-middlend/TEST.md b/spectec/test-middlend/TEST.md index 8846cd5c0a..706bfa0ea8 100644 --- a/spectec/test-middlend/TEST.md +++ b/spectec/test-middlend/TEST.md @@ -84,8 +84,8 @@ syntax fn = ;; 1-syntax.watsup:56.1-57.11 syntax resulttype = valtype* -;; 1-syntax.watsup:59.1-60.16 -syntax limits = `[%..%]`(u32, u32) +;; 1-syntax.watsup:59.1-60.17 +syntax limits = `[%..%?]`(u32, u32?) ;; 1-syntax.watsup:61.1-62.15 syntax globaltype = `MUT%?%`(()?, valtype) @@ -378,7 +378,7 @@ syntax context = {FUNC functype*, GLOBAL globaltype*, TABLE tabletype*, MEM memt relation Limits_ok: `|-%:%`(limits, nat) ;; 3-typing.watsup:22.1-24.24 rule _ {k : nat, n_1 : n, n_2 : n}: - `|-%:%`(`[%..%]`(n_1, n_2), k) + `|-%:%`(`[%..%?]`(n_1, ?(n_2)), k) -- if ((n_1 <= n_2) /\ (n_2 <= k)) ;; 3-typing.watsup:15.1-15.64 @@ -450,7 +450,7 @@ relation Resulttype_sub: `|-%*<:%*`(valtype*, valtype*) relation Limits_sub: `|-%<:%`(limits, limits) ;; 3-typing.watsup:83.1-86.21 rule _ {n_11 : n, n_12 : n, n_21 : n, n_22 : n}: - `|-%<:%`(`[%..%]`(n_11, n_12), `[%..%]`(n_21, n_22)) + `|-%<:%`(`[%..%?]`(n_11, ?(n_12)), `[%..%?]`(n_21, ?(n_22))) -- if (n_11 >= n_21) -- if (n_12 <= n_22) @@ -1198,19 +1198,19 @@ def with_data : (state, dataidx, byte*) -> state ;; 4-runtime.watsup:156.1-156.49 def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:158.1-161.56 - def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' - -- if (ti = {TYPE `%%`(`[%..%]`(i, j), reftype), ELEM r'*{r'}}) - -- if (i' = (|r*{}| + n)) - -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), reftype), ELEM r'*{r'} :: r^n{}}) + ;; 4-runtime.watsup:158.1-161.57 + def {i : nat, i' : nat, j? : nat?, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' + -- if (ti = {TYPE `%%`(`[%..%?]`(i, j?{j}), reftype), ELEM r'*{r'}}) + -- if (i' = (|r'*{r'}| + n)) + -- if (ti' = {TYPE `%%`(`[%..%?]`(i', j?{j}), reftype), ELEM r'*{r'} :: r^n{}}) ;; 4-runtime.watsup:157.1-157.41 def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:162.1-165.68 - def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' - -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) - -- if (i' = (|b*{b}| + n)) - -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: [(0 ^ ((n * 64) * $Ki))]}) + ;; 4-runtime.watsup:162.1-165.66 + def {b* : byte*, i : nat, i' : nat, j? : nat?, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' + -- if (mi = {TYPE `%I8`(`[%..%?]`(i, j?{j})), DATA b*{b}}) + -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) + -- if (mi' = {TYPE `%I8`(`[%..%?]`(i', j?{j})), DATA b*{b} :: 0^((n * 64) * $Ki){}}) ;; 4-runtime.watsup:178.1-181.21 rec { @@ -1610,7 +1610,7 @@ relation Step: `%~>%`(config, config) ;; 6-reduction.watsup:204.1-208.36 rule table.grow-succeed {n : n, ref : ref, ti : tableinst, ti' : tableinst, x : idx, z : state}: `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti'), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($table(z, 0) = ti) + -- if ($table(z, x) = ti) -- if ($grow_table(ti, n, ref) = ti') -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) @@ -1768,8 +1768,8 @@ def valtype_fn : fn -> valtype ;; 1-syntax.watsup:56.1-57.11 syntax resulttype = valtype* -;; 1-syntax.watsup:59.1-60.16 -syntax limits = `[%..%]`(u32, u32) +;; 1-syntax.watsup:59.1-60.17 +syntax limits = `[%..%?]`(u32, u32?) ;; 1-syntax.watsup:61.1-62.15 syntax globaltype = `MUT%?%`(()?, valtype) @@ -2062,7 +2062,7 @@ syntax context = {FUNC functype*, GLOBAL globaltype*, TABLE tabletype*, MEM memt relation Limits_ok: `|-%:%`(limits, nat) ;; 3-typing.watsup:22.1-24.24 rule _ {k : nat, n_1 : n, n_2 : n}: - `|-%:%`(`[%..%]`(n_1, n_2), k) + `|-%:%`(`[%..%?]`(n_1, ?(n_2)), k) -- if ((n_1 <= n_2) /\ (n_2 <= k)) ;; 3-typing.watsup:15.1-15.64 @@ -2134,7 +2134,7 @@ relation Resulttype_sub: `|-%*<:%*`(valtype*, valtype*) relation Limits_sub: `|-%<:%`(limits, limits) ;; 3-typing.watsup:83.1-86.21 rule _ {n_11 : n, n_12 : n, n_21 : n, n_22 : n}: - `|-%<:%`(`[%..%]`(n_11, n_12), `[%..%]`(n_21, n_22)) + `|-%<:%`(`[%..%?]`(n_11, ?(n_12)), `[%..%?]`(n_21, ?(n_22))) -- if (n_11 >= n_21) -- if (n_12 <= n_22) @@ -2939,19 +2939,19 @@ def with_data : (state, dataidx, byte*) -> state ;; 4-runtime.watsup:156.1-156.49 def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:158.1-161.56 - def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' - -- if (ti = {TYPE `%%`(`[%..%]`(i, j), reftype), ELEM r'*{r'}}) - -- if (i' = (|r*{}| + n)) - -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), reftype), ELEM r'*{r'} :: r^n{}}) + ;; 4-runtime.watsup:158.1-161.57 + def {i : nat, i' : nat, j? : nat?, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' + -- if (ti = {TYPE `%%`(`[%..%?]`(i, j?{j}), reftype), ELEM r'*{r'}}) + -- if (i' = (|r'*{r'}| + n)) + -- if (ti' = {TYPE `%%`(`[%..%?]`(i', j?{j}), reftype), ELEM r'*{r'} :: r^n{}}) ;; 4-runtime.watsup:157.1-157.41 def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:162.1-165.68 - def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' - -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) - -- if (i' = (|b*{b}| + n)) - -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: [(0 ^ ((n * 64) * $Ki))]}) + ;; 4-runtime.watsup:162.1-165.66 + def {b* : byte*, i : nat, i' : nat, j? : nat?, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' + -- if (mi = {TYPE `%I8`(`[%..%?]`(i, j?{j})), DATA b*{b}}) + -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) + -- if (mi' = {TYPE `%I8`(`[%..%?]`(i', j?{j})), DATA b*{b} :: 0^((n * 64) * $Ki){}}) ;; 4-runtime.watsup:178.1-181.21 rec { @@ -3351,7 +3351,7 @@ relation Step: `%~>%`(config, config) ;; 6-reduction.watsup:204.1-208.36 rule table.grow-succeed {n : n, ref : ref, ti : tableinst, ti' : tableinst, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti'), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($table(z, 0) = ti) + -- if ($table(z, x) = ti) -- if ($grow_table(ti, n, ref) = ti') -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) @@ -3509,8 +3509,8 @@ def valtype_fn : fn -> valtype ;; 1-syntax.watsup:56.1-57.11 syntax resulttype = valtype* -;; 1-syntax.watsup:59.1-60.16 -syntax limits = `[%..%]`(u32, u32) +;; 1-syntax.watsup:59.1-60.17 +syntax limits = `[%..%?]`(u32, u32?) ;; 1-syntax.watsup:61.1-62.15 syntax globaltype = `MUT%?%`(()?, valtype) @@ -3804,7 +3804,7 @@ syntax context = {FUNC functype*, GLOBAL globaltype*, TABLE tabletype*, MEM memt relation Limits_ok: `|-%:%`(limits, nat) ;; 3-typing.watsup:22.1-24.24 rule _ {k : nat, n_1 : n, n_2 : n}: - `|-%:%`(`[%..%]`(n_1, n_2), k) + `|-%:%`(`[%..%?]`(n_1, ?(n_2)), k) -- if ((n_1 <= n_2) /\ (n_2 <= k)) ;; 3-typing.watsup:15.1-15.64 @@ -3876,7 +3876,7 @@ relation Resulttype_sub: `|-%*<:%*`(valtype*, valtype*) relation Limits_sub: `|-%<:%`(limits, limits) ;; 3-typing.watsup:83.1-86.21 rule _ {n_11 : n, n_12 : n, n_21 : n, n_22 : n}: - `|-%<:%`(`[%..%]`(n_11, n_12), `[%..%]`(n_21, n_22)) + `|-%<:%`(`[%..%?]`(n_11, ?(n_12)), `[%..%?]`(n_21, ?(n_22))) -- if (n_11 >= n_21) -- if (n_12 <= n_22) @@ -4682,19 +4682,19 @@ def with_data : (state, dataidx, byte*) -> state ;; 4-runtime.watsup:156.1-156.49 def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:158.1-161.56 - def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' - -- if (ti = {TYPE `%%`(`[%..%]`(i, j), reftype), ELEM r'*{r'}}) - -- if (i' = (|r*{}| + n)) - -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), reftype), ELEM r'*{r'} :: r^n{}}) + ;; 4-runtime.watsup:158.1-161.57 + def {i : nat, i' : nat, j? : nat?, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' + -- if (ti = {TYPE `%%`(`[%..%?]`(i, j?{j}), reftype), ELEM r'*{r'}}) + -- if (i' = (|r'*{r'}| + n)) + -- if (ti' = {TYPE `%%`(`[%..%?]`(i', j?{j}), reftype), ELEM r'*{r'} :: r^n{}}) ;; 4-runtime.watsup:157.1-157.41 def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:162.1-165.68 - def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' - -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) - -- if (i' = (|b*{b}| + n)) - -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: [(0 ^ ((n * 64) * $Ki))]}) + ;; 4-runtime.watsup:162.1-165.66 + def {b* : byte*, i : nat, i' : nat, j? : nat?, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' + -- if (mi = {TYPE `%I8`(`[%..%?]`(i, j?{j})), DATA b*{b}}) + -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) + -- if (mi' = {TYPE `%I8`(`[%..%?]`(i', j?{j})), DATA b*{b} :: 0^((n * 64) * $Ki){}}) ;; 4-runtime.watsup:178.1-181.21 rec { @@ -5094,7 +5094,7 @@ relation Step: `%~>%`(config, config) ;; 6-reduction.watsup:204.1-208.36 rule table.grow-succeed {n : n, ref : ref, ti : tableinst, ti' : tableinst, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti'), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($table(z, 0) = ti) + -- if ($table(z, x) = ti) -- if ($grow_table(ti, n, ref) = ti') -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) @@ -5252,8 +5252,8 @@ def valtype_fn : fn -> valtype ;; 1-syntax.watsup:56.1-57.11 syntax resulttype = valtype* -;; 1-syntax.watsup:59.1-60.16 -syntax limits = `[%..%]`(u32, u32) +;; 1-syntax.watsup:59.1-60.17 +syntax limits = `[%..%?]`(u32, u32?) ;; 1-syntax.watsup:61.1-62.15 syntax globaltype = `MUT%?%`(()?, valtype) @@ -5547,7 +5547,7 @@ syntax context = {FUNC functype*, GLOBAL globaltype*, TABLE tabletype*, MEM memt relation Limits_ok: `|-%:%`(limits, nat) ;; 3-typing.watsup:22.1-24.24 rule _ {k : nat, n_1 : n, n_2 : n}: - `|-%:%`(`[%..%]`(n_1, n_2), k) + `|-%:%`(`[%..%?]`(n_1, ?(n_2)), k) -- if ((n_1 <= n_2) /\ (n_2 <= k)) ;; 3-typing.watsup:15.1-15.64 @@ -5619,7 +5619,7 @@ relation Resulttype_sub: `|-%*<:%*`(valtype*, valtype*) relation Limits_sub: `|-%<:%`(limits, limits) ;; 3-typing.watsup:83.1-86.21 rule _ {n_11 : n, n_12 : n, n_21 : n, n_22 : n}: - `|-%<:%`(`[%..%]`(n_11, n_12), `[%..%]`(n_21, n_22)) + `|-%<:%`(`[%..%?]`(n_11, ?(n_12)), `[%..%?]`(n_21, ?(n_22))) -- if (n_11 >= n_21) -- if (n_12 <= n_22) @@ -6434,19 +6434,19 @@ def with_data : (state, dataidx, byte*) -> state ;; 4-runtime.watsup:156.1-156.49 def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:158.1-161.56 - def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' - -- if (ti = {TYPE `%%`(`[%..%]`(i, j), reftype), ELEM r'*{r'}}) - -- if (i' = (|r*{}| + n)) - -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), reftype), ELEM r'*{r'} :: r^n{}}) + ;; 4-runtime.watsup:158.1-161.57 + def {i : nat, i' : nat, j? : nat?, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' + -- if (ti = {TYPE `%%`(`[%..%?]`(i, j?{j}), reftype), ELEM r'*{r'}}) + -- if (i' = (|r'*{r'}| + n)) + -- if (ti' = {TYPE `%%`(`[%..%?]`(i', j?{j}), reftype), ELEM r'*{r'} :: r^n{}}) ;; 4-runtime.watsup:157.1-157.41 def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:162.1-165.68 - def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' - -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) - -- if (i' = (|b*{b}| + n)) - -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: [(0 ^ ((n * 64) * $Ki))]}) + ;; 4-runtime.watsup:162.1-165.66 + def {b* : byte*, i : nat, i' : nat, j? : nat?, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' + -- if (mi = {TYPE `%I8`(`[%..%?]`(i, j?{j})), DATA b*{b}}) + -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) + -- if (mi' = {TYPE `%I8`(`[%..%?]`(i', j?{j})), DATA b*{b} :: 0^((n * 64) * $Ki){}}) ;; 4-runtime.watsup:178.1-181.21 rec { @@ -6852,7 +6852,7 @@ relation Step: `%~>%`(config, config) ;; 6-reduction.watsup:204.1-208.36 rule table.grow-succeed {n : n, ref : ref, ti : tableinst, ti' : tableinst, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti'), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($table(z, 0) = ti) + -- if ($table(z, x) = ti) -- if ($grow_table(ti, n, ref) = ti') -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) @@ -7014,8 +7014,8 @@ def valtype_fn : fn -> valtype ;; 1-syntax.watsup:56.1-57.11 syntax resulttype = valtype* -;; 1-syntax.watsup:59.1-60.16 -syntax limits = `[%..%]`(u32, u32) +;; 1-syntax.watsup:59.1-60.17 +syntax limits = `[%..%?]`(u32, u32?) ;; 1-syntax.watsup:61.1-62.15 syntax globaltype = `MUT%?%`(()?, valtype) @@ -7309,7 +7309,7 @@ syntax context = {FUNC functype*, GLOBAL globaltype*, TABLE tabletype*, MEM memt relation Limits_ok: `|-%:%`(limits, nat) ;; 3-typing.watsup:22.1-24.24 rule _ {k : nat, n_1 : n, n_2 : n}: - `|-%:%`(`[%..%]`(n_1, n_2), k) + `|-%:%`(`[%..%?]`(n_1, ?(n_2)), k) -- if ((n_1 <= n_2) /\ (n_2 <= k)) ;; 3-typing.watsup:15.1-15.64 @@ -7381,7 +7381,7 @@ relation Resulttype_sub: `|-%*<:%*`(valtype*, valtype*) relation Limits_sub: `|-%<:%`(limits, limits) ;; 3-typing.watsup:83.1-86.21 rule _ {n_11 : n, n_12 : n, n_21 : n, n_22 : n}: - `|-%<:%`(`[%..%]`(n_11, n_12), `[%..%]`(n_21, n_22)) + `|-%<:%`(`[%..%?]`(n_11, ?(n_12)), `[%..%?]`(n_21, ?(n_22))) -- if (n_11 >= n_21) -- if (n_12 <= n_22) @@ -8196,19 +8196,19 @@ def with_data : (state, dataidx, byte*) -> state ;; 4-runtime.watsup:156.1-156.49 def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:158.1-161.56 - def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' - -- if (ti = {TYPE `%%`(`[%..%]`(i, j), reftype), ELEM r'*{r'}}) - -- if (i' = (|r*{}| + n)) - -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), reftype), ELEM r'*{r'} :: r^n{}}) + ;; 4-runtime.watsup:158.1-161.57 + def {i : nat, i' : nat, j? : nat?, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' + -- if (ti = {TYPE `%%`(`[%..%?]`(i, j?{j}), reftype), ELEM r'*{r'}}) + -- if (i' = (|r'*{r'}| + n)) + -- if (ti' = {TYPE `%%`(`[%..%?]`(i', j?{j}), reftype), ELEM r'*{r'} :: r^n{}}) ;; 4-runtime.watsup:157.1-157.41 def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:162.1-165.68 - def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' - -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) - -- if (i' = (|b*{b}| + n)) - -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: [(0 ^ ((n * 64) * $Ki))]}) + ;; 4-runtime.watsup:162.1-165.66 + def {b* : byte*, i : nat, i' : nat, j? : nat?, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' + -- if (mi = {TYPE `%I8`(`[%..%?]`(i, j?{j})), DATA b*{b}}) + -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) + -- if (mi' = {TYPE `%I8`(`[%..%?]`(i', j?{j})), DATA b*{b} :: 0^((n * 64) * $Ki){}}) ;; 4-runtime.watsup:178.1-181.21 rec { @@ -8614,7 +8614,7 @@ relation Step: `%~>%`(config, config) ;; 6-reduction.watsup:204.1-208.36 rule table.grow-succeed {n : n, ref : ref, ti : tableinst, ti' : tableinst, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti'), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($table(z, 0) = ti) + -- if ($table(z, x) = ti) -- if ($grow_table(ti, n, ref) = ti') -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) @@ -8776,8 +8776,8 @@ def valtype_fn : fn -> valtype ;; 1-syntax.watsup:56.1-57.11 syntax resulttype = valtype* -;; 1-syntax.watsup:59.1-60.16 -syntax limits = `[%..%]`(u32, u32) +;; 1-syntax.watsup:59.1-60.17 +syntax limits = `[%..%?]`(u32, u32?) ;; 1-syntax.watsup:61.1-62.15 syntax globaltype = `MUT%?%`(()?, valtype) @@ -9071,7 +9071,7 @@ syntax context = {FUNC functype*, GLOBAL globaltype*, TABLE tabletype*, MEM memt relation Limits_ok: `|-%:%`(limits, nat) ;; 3-typing.watsup:22.1-24.24 rule _ {k : nat, n_1 : n, n_2 : n}: - `|-%:%`(`[%..%]`(n_1, n_2), k) + `|-%:%`(`[%..%?]`(n_1, ?(n_2)), k) -- if ((n_1 <= n_2) /\ (n_2 <= k)) ;; 3-typing.watsup:15.1-15.64 @@ -9144,7 +9144,7 @@ relation Resulttype_sub: `|-%*<:%*`(valtype*, valtype*) relation Limits_sub: `|-%<:%`(limits, limits) ;; 3-typing.watsup:83.1-86.21 rule _ {n_11 : n, n_12 : n, n_21 : n, n_22 : n}: - `|-%<:%`(`[%..%]`(n_11, n_12), `[%..%]`(n_21, n_22)) + `|-%<:%`(`[%..%?]`(n_11, ?(n_12)), `[%..%?]`(n_21, ?(n_22))) -- if (n_11 >= n_21) -- if (n_12 <= n_22) @@ -10006,19 +10006,19 @@ def with_data : (state, dataidx, byte*) -> state ;; 4-runtime.watsup:156.1-156.49 def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:158.1-161.56 - def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' - -- if (ti = {TYPE `%%`(`[%..%]`(i, j), reftype), ELEM r'*{r'}}) - -- if (i' = (|r*{}| + n)) - -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), reftype), ELEM r'*{r'} :: r^n{}}) + ;; 4-runtime.watsup:158.1-161.57 + def {i : nat, i' : nat, j? : nat?, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' + -- if (ti = {TYPE `%%`(`[%..%?]`(i, j?{j}), reftype), ELEM r'*{r'}}) + -- if (i' = (|r'*{r'}| + n)) + -- if (ti' = {TYPE `%%`(`[%..%?]`(i', j?{j}), reftype), ELEM r'*{r'} :: r^n{}}) ;; 4-runtime.watsup:157.1-157.41 def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:162.1-165.68 - def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' - -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) - -- if (i' = (|b*{b}| + n)) - -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: [(0 ^ ((n * 64) * $Ki))]}) + ;; 4-runtime.watsup:162.1-165.66 + def {b* : byte*, i : nat, i' : nat, j? : nat?, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' + -- if (mi = {TYPE `%I8`(`[%..%?]`(i, j?{j})), DATA b*{b}}) + -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) + -- if (mi' = {TYPE `%I8`(`[%..%?]`(i', j?{j})), DATA b*{b} :: 0^((n * 64) * $Ki){}}) ;; 4-runtime.watsup:178.1-181.21 rec { @@ -10432,7 +10432,7 @@ relation Step: `%~>%`(config, config) ;; 6-reduction.watsup:204.1-208.36 rule table.grow-succeed {n : n, ref : ref, ti : tableinst, ti' : tableinst, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti'), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($table(z, 0) = ti) + -- if ($table(z, x) = ti) -- if ($grow_table(ti, n, ref) = ti') -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) @@ -10597,8 +10597,8 @@ def valtype_fn : fn -> valtype ;; 1-syntax.watsup:56.1-57.11 syntax resulttype = valtype* -;; 1-syntax.watsup:59.1-60.16 -syntax limits = `[%..%]`(u32, u32) +;; 1-syntax.watsup:59.1-60.17 +syntax limits = `[%..%?]`(u32, u32?) ;; 1-syntax.watsup:61.1-62.15 syntax globaltype = `MUT%?%`(()?, valtype) @@ -10892,7 +10892,7 @@ syntax context = {FUNC functype*, GLOBAL globaltype*, TABLE tabletype*, MEM memt relation Limits_ok: `|-%:%`(limits, nat) ;; 3-typing.watsup:22.1-24.24 rule _ {k : nat, n_1 : n, n_2 : n}: - `|-%:%`(`[%..%]`(n_1, n_2), k) + `|-%:%`(`[%..%?]`(n_1, ?(n_2)), k) -- if ((n_1 <= n_2) /\ (n_2 <= k)) ;; 3-typing.watsup:15.1-15.64 @@ -10965,7 +10965,7 @@ relation Resulttype_sub: `|-%*<:%*`(valtype*, valtype*) relation Limits_sub: `|-%<:%`(limits, limits) ;; 3-typing.watsup:83.1-86.21 rule _ {n_11 : n, n_12 : n, n_21 : n, n_22 : n}: - `|-%<:%`(`[%..%]`(n_11, n_12), `[%..%]`(n_21, n_22)) + `|-%<:%`(`[%..%?]`(n_11, ?(n_12)), `[%..%?]`(n_21, ?(n_22))) -- if (n_11 >= n_21) -- if (n_12 <= n_22) @@ -11827,19 +11827,19 @@ def with_data : (state, dataidx, byte*) -> state ;; 4-runtime.watsup:156.1-156.49 def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:158.1-161.56 - def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' - -- if (ti = {TYPE `%%`(`[%..%]`(i, j), reftype), ELEM r'*{r'}}) - -- if (i' = (|r*{}| + n)) - -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), reftype), ELEM r'*{r'} :: r^n{}}) + ;; 4-runtime.watsup:158.1-161.57 + def {i : nat, i' : nat, j? : nat?, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' + -- if (ti = {TYPE `%%`(`[%..%?]`(i, j?{j}), reftype), ELEM r'*{r'}}) + -- if (i' = (|r'*{r'}| + n)) + -- if (ti' = {TYPE `%%`(`[%..%?]`(i', j?{j}), reftype), ELEM r'*{r'} :: r^n{}}) ;; 4-runtime.watsup:157.1-157.41 def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:162.1-165.68 - def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' - -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) - -- if (i' = (|b*{b}| + n)) - -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: [(0 ^ ((n * 64) * $Ki))]}) + ;; 4-runtime.watsup:162.1-165.66 + def {b* : byte*, i : nat, i' : nat, j? : nat?, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' + -- if (mi = {TYPE `%I8`(`[%..%?]`(i, j?{j})), DATA b*{b}}) + -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) + -- if (mi' = {TYPE `%I8`(`[%..%?]`(i', j?{j})), DATA b*{b} :: 0^((n * 64) * $Ki){}}) ;; 4-runtime.watsup:178.1-181.21 rec { @@ -12253,7 +12253,7 @@ relation Step: `%~>%`(config, config) ;; 6-reduction.watsup:204.1-208.36 rule table.grow-succeed {n : n, ref : ref, ti : tableinst, ti' : tableinst, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti'), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- where ti = $table(z, 0) + -- where ti = $table(z, x) -- where ti' = $grow_table(ti, n, ref) -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) From 7aaff6092b4fbdf3d02e4f1eed9e21e9c7768b19 Mon Sep 17 00:00:00 2001 From: Wonho Shin Date: Thu, 22 Jun 2023 14:27:39 +0900 Subject: [PATCH 08/49] Fix typo in data segment --- spectec/spec/1-syntax.watsup | 2 +- spectec/spec/3-typing.watsup | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spectec/spec/1-syntax.watsup b/spectec/spec/1-syntax.watsup index 76a297e91c..2780ae5170 100644 --- a/spectec/spec/1-syntax.watsup +++ b/spectec/spec/1-syntax.watsup @@ -198,7 +198,7 @@ syntax mem hint(desc "memory") = syntax elem hint(desc "table segment") = ELEM reftype expr* elemmode? syntax data hint(desc "memory segment") = - DATA (byte*)* datamode? + DATA byte* datamode? syntax start hint(desc "start function") = START funcidx diff --git a/spectec/spec/3-typing.watsup b/spectec/spec/3-typing.watsup index 8a6f392642..c5a01d6fd8 100644 --- a/spectec/spec/3-typing.watsup +++ b/spectec/spec/3-typing.watsup @@ -431,7 +431,7 @@ rule Elem_ok: -- (Elemmode_ok: C |- elemmode : rt)? rule Data_ok: - C |- DATA (b*)* datamode? : OK + C |- DATA b* datamode? : OK -- (Datamode_ok: C |- datamode : OK)? rule Elemmode_ok/active: From cecacb598e99ac169e62e7239f00986e3932dcc4 Mon Sep 17 00:00:00 2001 From: Wonho Shin Date: Thu, 22 Jun 2023 16:22:36 +0900 Subject: [PATCH 09/49] Draft for module semantics --- spectec/spec/4-runtime.watsup | 11 ++++ spectec/spec/6-reduction.watsup | 107 ++++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+) diff --git a/spectec/spec/4-runtime.watsup b/spectec/spec/4-runtime.watsup index 1fe9c44a5d..f70f7e0b67 100644 --- a/spectec/spec/4-runtime.watsup +++ b/spectec/spec/4-runtime.watsup @@ -116,7 +116,18 @@ def $funcaddr(state) : funcaddr* hint(show %.MODULE.FUNC) def $funcaddr((s; f)) = f.MODULE.FUNC def $funcinst(state) : funcinst* hint(show %.FUNC) +def $globalinst(state) : globalinst* hint(show %.GLOBAL) +def $tableinst(state) : tableinst* hint(show %.TABLE) +def $meminst(state) : meminst* hint(show %.MEM) +def $eleminst(state) : eleminst* hint(show %.ELEM) +def $datainst(state) : datainst* hint(show %.DATA) + def $funcinst((s; f)) = s.FUNC +def $globalinst((s; f)) = s.GLOBAL +def $tableinst((s; f)) = s.TABLE +def $meminst((s; f)) = s.MEM +def $eleminst((s; f)) = s.ELEM +def $datainst((s; f)) = s.DATA def $func(state, funcidx) : funcinst hint(show %.FUNC#`[%]) def $global(state, globalidx) : globalinst hint(show %.GLOBAL#`[%]) diff --git a/spectec/spec/6-reduction.watsup b/spectec/spec/6-reduction.watsup index b987bc51da..c54f4b587a 100644 --- a/spectec/spec/6-reduction.watsup +++ b/spectec/spec/6-reduction.watsup @@ -376,3 +376,110 @@ rule Step_read/memory.init-succ: rule Step/data.drop: z; (DATA.DROP x) ~> $with_data(z, x, epsilon); epsilon + + +;; Module Semantics + +def $alloc_func(state, func) : (funcaddr, funcinst) +def $alloc_global(state, global) : (globaladdr, globalinst) +def $alloc_table(state, table) : (tableaddr, tableinst) +def $alloc_mem(state, mem) : (memaddr, meminst) +def $alloc_elem(state, elem) : (elemaddr, eleminst) +def $alloc_data(state, data) : (dataaddr, datainst) + +def $alloc_func((s; f), func) = (fa, fi) + -- if fi = { MODULE f.MODULE, CODE func } + -- if fa = |$funcinst((s; f))| + +def $alloc_global((s; f), global) = (ga, gi) + -- if global = GLOBAL globaltype instr* + -- Step_read : s; f; instr* ~> val + -- if gi = { TYPE globaltype, VALUE val } + -- if ga = |$globalinst((s; f))| + +def $alloc_table((s; f), table) = (ta, ti) + -- if table = TABLE (`[i .. j?] reftype) + -- if ti = { TYPE `[i .. j?] reftype, ELEM (REF.NULL reftype)^i } + -- if ta = |$tableinst((s; f))| + +def $alloc_mem((s; f), mem) = (ma, mi) + -- if mem = MEMORY (`[i .. j?] I8) + -- if mi = { TYPE (`[i .. j? ] I8), DATA 0^(i * 64 * $Ki()) } + -- if ma = |$meminst((s; f))| + +def $alloc_elem((s; f), elem) = (ea, ei) + -- if elem = ELEM reftype (instr*)* elemmode? + -- (Step_read : s; f; instr* ~> ref)* + -- if ei = { TYPE reftype, ELEM ref* } + -- if ea = |$eleminst((s; f))| + +def $alloc_data((s; f), data) = (da, di) + -- if data = DATA byte* datamode? + -- if di = { DATA byte* } + -- if da = |$datainst((s; f))| + + +def $alloc_module(store, module) : (store, moduleinst) + +;; TODO: fold store, replace moduleinst +def $alloc_module(s, module) = (s, m) + -- if module = MODULE import* func* global* table* mem* elem* data* start? export* + -- if m' = { FUNC epsilon, GLOBAL epsilon, TABLE epsilon, MEM epsilon, ELEM epsilon, DATA epsilon, EXPORT epsilon } + -- if f = { LOCAL epsilon, MODULE m' } + -- if $alloc_func((s; f), func)* = (fa, fi)* + -- if $alloc_global((s; f), global)* = (ga, gi)* + -- if $alloc_table((s; f), table)* = (ta, ti)* + -- if $alloc_mem((s; f), mem)* = (ma, mi)* + -- if $alloc_elem((s; f), elem)* = (ea, ei)* + -- if $alloc_data((s; f), data)* = (da, di)* + -- if m = { FUNC fa*, GLOBAL ga*, TABLE ta*, MEM ma*, ELEM ea*, DATA da*, EXPORT epsilon } + + +def $run_elem(state, elem) : state +def $run_data(state, data) : state + +def $run_elem((s; f), elem) = (s; f) + -- if elem = ELEM reftype expr* + +;; TODO: get index i +def $run_elem((s; f), elem) = (s'; f') + -- if elem = ELEM reftype expr^n elemmode + -- if elemmode = TABLE x instr* + -- Step : s; f; instr* (CONST I32 0) (CONST I32 n) (TABLE.INIT x i) (ELEM.DROP i) ~> s'; f'; epsilon + +def $run_elem((s; f), elem) = (s'; f') + -- if elem = ELEM reftype expr* elemmode + -- if elemmode = DECLARE + -- Step : s; f; (ELEM.DROP i) ~> s'; f'; epsilon + +def $run_data((s; f), data) = (s; f) + -- if data = DATA byte* + +;; TODO: get index i +def $run_data((s; f), data) = (s'; f') + -- if data = DATA byte^n datamode + -- if datamode = MEMORY 0 instr* + -- Step : s; f; instr* (CONST I32 0) (CONST I32 n) (MEMORY.INIT i) (DATA.DROP i) ~> s'; f'; epsilon + + +def $instantiation(store, module) : (store, moduleinst) + +;; TODO: fold store +def $instantiation(s, module) = (s, m) + -- if module = MODULE import* func* global* table* mem* elem* data* start? export* + -- if $alloc_module(s, module) = (s_alloc, m) + -- if f = { LOCAL epsilon, MODULE m } + -- if $run_elem((s; f), elem)* = (s'; f')* + -- if $run_data((s; f), data)* = (s''; f'')* + + +def $invocation(store, funcaddr, val*) : (store, val*) + +def $invocation(s, fa, val^i) = (s', val'^j) + -- if m = { FUNC epsilon, GLOBAL epsilon, TABLE epsilon, MEM epsilon, ELEM epsilon, DATA epsilon, EXPORT epsilon } + -- if f = { LOCAL epsilon, MODULE m } + -- if $funcinst((s; f))[fa].CODE = FUNC functype valtype* expr + -- if functype = valtype* -> valtype'* + -- if i = |valtype*| + -- if j = |valtype'*| + -- Step : s; f; val^i (CALL_ADDR fa) ~> s'; f'; val'^j From 2a158db2fd936cc00587aa280695c251643cb719 Mon Sep 17 00:00:00 2001 From: Wonho Shin Date: Thu, 22 Jun 2023 19:56:34 +0900 Subject: [PATCH 10/49] Add premises for updating store --- spectec/spec/6-reduction.watsup | 151 ++++++++++++++++++++++---------- 1 file changed, 103 insertions(+), 48 deletions(-) diff --git a/spectec/spec/6-reduction.watsup b/spectec/spec/6-reduction.watsup index c54f4b587a..3c493d0869 100644 --- a/spectec/spec/6-reduction.watsup +++ b/spectec/spec/6-reduction.watsup @@ -380,106 +380,161 @@ rule Step/data.drop: ;; Module Semantics -def $alloc_func(state, func) : (funcaddr, funcinst) -def $alloc_global(state, global) : (globaladdr, globalinst) -def $alloc_table(state, table) : (tableaddr, tableinst) -def $alloc_mem(state, mem) : (memaddr, meminst) -def $alloc_elem(state, elem) : (elemaddr, eleminst) -def $alloc_data(state, data) : (dataaddr, datainst) - -def $alloc_func((s; f), func) = (fa, fi) +def $alloc_func(state, func*) : (store, funcaddr*) + +def $alloc_func((s; f), epsilon) = (s, epsilon) + +def $alloc_func((s; f), func func'*) = (s_res, fa fa'*) -- if fi = { MODULE f.MODULE, CODE func } -- if fa = |$funcinst((s; f))| + -- if s_new = s[.FUNC =.. fi] + -- if (s_res, fa'*) = $alloc_func((s_new; f), func'*) + + +def $alloc_global(state, global*) : (store, globaladdr*) -def $alloc_global((s; f), global) = (ga, gi) +def $alloc_global((s; f), epsilon) = (s, epsilon) + +def $alloc_global((s; f), global global'*) = (s_res, ga ga'*) -- if global = GLOBAL globaltype instr* -- Step_read : s; f; instr* ~> val -- if gi = { TYPE globaltype, VALUE val } -- if ga = |$globalinst((s; f))| + -- if s_new = s[.GLOBAL =.. gi] + -- if (s_res, ga'*) = $alloc_global((s_new; f), global'*) + + +def $alloc_table(state, table*) : (store, tableaddr*) -def $alloc_table((s; f), table) = (ta, ti) - -- if table = TABLE (`[i .. j?] reftype) - -- if ti = { TYPE `[i .. j?] reftype, ELEM (REF.NULL reftype)^i } +def $alloc_table((s; f), epsilon) = (s, epsilon) + +def $alloc_table((s; f), table table'*) = (s_res, ta ta'*) + -- if table = TABLE tabletype + -- if tabletype = `[i .. j?] reftype + -- if ti = { TYPE tabletype, ELEM (REF.NULL reftype)^i } -- if ta = |$tableinst((s; f))| + -- if s_new = s[.TABLE =.. ti] + -- if (s_res, ta'*) = $alloc_table((s_new; f), table'*) + + +def $alloc_mem(state, mem*) : (store, memaddr*) -def $alloc_mem((s; f), mem) = (ma, mi) - -- if mem = MEMORY (`[i .. j?] I8) - -- if mi = { TYPE (`[i .. j? ] I8), DATA 0^(i * 64 * $Ki()) } +def $alloc_mem((s; f), epsilon) = (s, epsilon) + +def $alloc_mem((s; f), mem mem'*) = (s_res, ma ma'*) + -- if mem = MEMORY memtype + -- if memtype = `[i .. j?] I8 + -- if mi = { TYPE memtype, DATA 0^(i * 64 * $Ki()) } -- if ma = |$meminst((s; f))| + -- if s_new = s[.MEM =.. mi] + -- if (s_res, ma'*) = $alloc_mem((s_new; f), mem'*) + + +def $alloc_elem(state, elem*) : (store, elemaddr*) -def $alloc_elem((s; f), elem) = (ea, ei) +def $alloc_elem((s; f), epsilon) = (s, epsilon) + +def $alloc_elem((s; f), elem elem'*) = (s_res, ea ea'*) -- if elem = ELEM reftype (instr*)* elemmode? -- (Step_read : s; f; instr* ~> ref)* -- if ei = { TYPE reftype, ELEM ref* } -- if ea = |$eleminst((s; f))| + -- if s_new = s[.ELEM =.. ei] + -- if (s_res, ea'*) = $alloc_elem((s_new; f), elem'*) + + +def $alloc_data(state, data*) : (store, dataaddr*) + +def $alloc_data((s; f), epsilon) = (s, epsilon) -def $alloc_data((s; f), data) = (da, di) +def $alloc_data((s; f), data data'*) = (s_res, da da'*) -- if data = DATA byte* datamode? -- if di = { DATA byte* } -- if da = |$datainst((s; f))| + -- if s_new = s[.DATA =.. di] + -- if (s_res, da'*) = $alloc_data((s_new; f), data'*) + + +def $replace_moduleinst(store, funcaddr*, moduleinst) : store + +def $replace_moduleinst(s, epsilon, m) = s + +def $replace_moduleinst(s, fa fa'*, m) = s_res + -- if s_new = s[.FUNC[fa].MODULE = m] + -- if s_res = $replace_moduleinst(s_new, fa'*, m) def $alloc_module(store, module) : (store, moduleinst) -;; TODO: fold store, replace moduleinst -def $alloc_module(s, module) = (s, m) +def $alloc_module(s, module) = (s_res, m) -- if module = MODULE import* func* global* table* mem* elem* data* start? export* -- if m' = { FUNC epsilon, GLOBAL epsilon, TABLE epsilon, MEM epsilon, ELEM epsilon, DATA epsilon, EXPORT epsilon } -- if f = { LOCAL epsilon, MODULE m' } - -- if $alloc_func((s; f), func)* = (fa, fi)* - -- if $alloc_global((s; f), global)* = (ga, gi)* - -- if $alloc_table((s; f), table)* = (ta, ti)* - -- if $alloc_mem((s; f), mem)* = (ma, mi)* - -- if $alloc_elem((s; f), elem)* = (ea, ei)* - -- if $alloc_data((s; f), data)* = (da, di)* + -- if (s_func, fa*) = $alloc_func((s; f), func*) + -- if (s_global, ga*) = $alloc_global((s_func; f), global*) + -- if (s_table, ta*) = $alloc_table((s_global; f), table*) + -- if (s_mem, ma*) = $alloc_mem((s_table; f), mem*) + -- if (s_elem, ea*) = $alloc_elem((s_mem; f), elem*) + -- if (s_data, da*) = $alloc_data((s_elem; f), data*) -- if m = { FUNC fa*, GLOBAL ga*, TABLE ta*, MEM ma*, ELEM ea*, DATA da*, EXPORT epsilon } + -- if s_res = $replace_moduleinst(s_elem, fa*, m) + +def $run_elem(state, elem*, idx) : state -def $run_elem(state, elem) : state -def $run_data(state, data) : state +def $run_elem((s; f), epsilon, i) = s; f -def $run_elem((s; f), elem) = (s; f) +def $run_elem((s; f), elem elem'*, i) = s_res; f_res -- if elem = ELEM reftype expr* + -- if $run_elem((s; f), elem'*, $(i + 1)) = s_res; f_res -;; TODO: get index i -def $run_elem((s; f), elem) = (s'; f') - -- if elem = ELEM reftype expr^n elemmode +def $run_elem((s; f), elem elem'*, i) = s_res; f_res + -- if elem = ELEM reftype expr* elemmode + -- if n = |expr*| -- if elemmode = TABLE x instr* - -- Step : s; f; instr* (CONST I32 0) (CONST I32 n) (TABLE.INIT x i) (ELEM.DROP i) ~> s'; f'; epsilon + -- Step : s; f; instr* (CONST I32 0) (CONST I32 n) (TABLE.INIT x i) (ELEM.DROP i) ~> s_new; f_new; epsilon + -- if $run_elem((s_new; f_new), elem'*, $(i + 1)) = s_res; f_res -def $run_elem((s; f), elem) = (s'; f') +def $run_elem((s; f), elem elem'*, i) = s_res; f_res -- if elem = ELEM reftype expr* elemmode -- if elemmode = DECLARE - -- Step : s; f; (ELEM.DROP i) ~> s'; f'; epsilon + -- Step : s; f; (ELEM.DROP i) ~> s_new; f_new; epsilon + -- if $run_elem((s_new; f_new), elem'*, $(i + 1)) = s_res; f_res + + +def $run_data(state, data*, idx) : state + +def $run_data((s; f), epsilon, i) = s; f -def $run_data((s; f), data) = (s; f) +def $run_data((s; f), data data'*, i) = s_res; f_res -- if data = DATA byte* + -- if $run_data((s; f), data'*, $(i + 1)) = s_res; f_res -;; TODO: get index i -def $run_data((s; f), data) = (s'; f') - -- if data = DATA byte^n datamode +def $run_data((s; f), data data'*, i) = s_res; f_res + -- if data = DATA byte* datamode + -- if n = |byte*| -- if datamode = MEMORY 0 instr* - -- Step : s; f; instr* (CONST I32 0) (CONST I32 n) (MEMORY.INIT i) (DATA.DROP i) ~> s'; f'; epsilon + -- Step : s; f; instr* (CONST I32 0) (CONST I32 n) (MEMORY.INIT i) (DATA.DROP i) ~> s_new; f_new; epsilon + -- if $run_data((s_new; f_new), data'*, $(i + 1)) = s_res; f_res def $instantiation(store, module) : (store, moduleinst) -;; TODO: fold store -def $instantiation(s, module) = (s, m) +def $instantiation(s, module) = (s_res, m) -- if module = MODULE import* func* global* table* mem* elem* data* start? export* - -- if $alloc_module(s, module) = (s_alloc, m) + -- if (s_alloc, m) = $alloc_module(s, module) -- if f = { LOCAL epsilon, MODULE m } - -- if $run_elem((s; f), elem)* = (s'; f')* - -- if $run_data((s; f), data)* = (s''; f'')* + -- if $run_elem((s_alloc; f_alloc), elem*, 0) = s_elem; f_elem + -- if $run_data((s_elem; f_elem), data*, 0) = s_res; f_res def $invocation(store, funcaddr, val*) : (store, val*) -def $invocation(s, fa, val^i) = (s', val'^j) +def $invocation(s, fa, val*) = (s', val'*) -- if m = { FUNC epsilon, GLOBAL epsilon, TABLE epsilon, MEM epsilon, ELEM epsilon, DATA epsilon, EXPORT epsilon } -- if f = { LOCAL epsilon, MODULE m } -- if $funcinst((s; f))[fa].CODE = FUNC functype valtype* expr -- if functype = valtype* -> valtype'* - -- if i = |valtype*| - -- if j = |valtype'*| - -- Step : s; f; val^i (CALL_ADDR fa) ~> s'; f'; val'^j + -- if |val*| = |valtype*| + -- if |val'*| = |valtype'*| + -- Step : s; f; val* (CALL_ADDR fa) ~> s'; f'; val'* From 066f8c326661547cb1ed0663cce080b99fe136e5 Mon Sep 17 00:00:00 2001 From: Wonho Shin Date: Thu, 22 Jun 2023 20:10:06 +0900 Subject: [PATCH 11/49] Add premises for start function --- spectec/spec/6-reduction.watsup | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/spectec/spec/6-reduction.watsup b/spectec/spec/6-reduction.watsup index 3c493d0869..81a3d66b64 100644 --- a/spectec/spec/6-reduction.watsup +++ b/spectec/spec/6-reduction.watsup @@ -521,12 +521,21 @@ def $run_data((s; f), data data'*, i) = s_res; f_res def $instantiation(store, module) : (store, moduleinst) def $instantiation(s, module) = (s_res, m) - -- if module = MODULE import* func* global* table* mem* elem* data* start? export* + -- if module = MODULE import* func* global* table* mem* elem* data* export* -- if (s_alloc, m) = $alloc_module(s, module) -- if f = { LOCAL epsilon, MODULE m } -- if $run_elem((s_alloc; f_alloc), elem*, 0) = s_elem; f_elem -- if $run_data((s_elem; f_elem), data*, 0) = s_res; f_res +def $instantiation(s, module) = (s_res, m) + -- if module = MODULE import* func* global* table* mem* elem* data* start export* + -- if (s_alloc, m) = $alloc_module(s, module) + -- if f = { LOCAL epsilon, MODULE m } + -- if $run_elem((s_alloc; f_alloc), elem*, 0) = s_elem; f_elem + -- if $run_data((s_elem; f_elem), data*, 0) = s_data; f_data + -- if start = START x + -- Step : s_data; f_data; (CALL x) ~> s_res; f_res; epsilon + def $invocation(store, funcaddr, val*) : (store, val*) From 6c7d379463d4bede23a595d6bd8c9590ee9ae220 Mon Sep 17 00:00:00 2001 From: Wonho Shin Date: Thu, 22 Jun 2023 20:27:03 +0900 Subject: [PATCH 12/49] Add export allocation --- spectec/spec/6-reduction.watsup | 39 ++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/spectec/spec/6-reduction.watsup b/spectec/spec/6-reduction.watsup index 81a3d66b64..f1bcfdaeef 100644 --- a/spectec/spec/6-reduction.watsup +++ b/spectec/spec/6-reduction.watsup @@ -464,20 +464,49 @@ def $replace_moduleinst(s, fa fa'*, m) = s_res -- if s_res = $replace_moduleinst(s_new, fa'*, m) +def $alloc_export(moduleinst, export) : exportinst + +def $alloc_export(m, export) = xi + -- if export = EXPORT name externuse + -- if externuse = FUNC x + -- if externval = FUNC m.FUNC[x] + -- if xi = { NAME name, VALUE externval } + +def $alloc_export(m, export) = xi + -- if export = EXPORT name externuse + -- if externuse = GLOBAL x + -- if externval = GLOBAL m.GLOBAL[x] + -- if xi = { NAME name, VALUE externval } + +def $alloc_export(m, export) = xi + -- if export = EXPORT name externuse + -- if externuse = TABLE x + -- if externval = TABLE m.TABLE[x] + -- if xi = { NAME name, VALUE externval } + +def $alloc_export(m, export) = xi + -- if export = EXPORT name externuse + -- if externuse = MEM x + -- if externval = MEM m.MEM[x] + -- if xi = { NAME name, VALUE externval } + + def $alloc_module(store, module) : (store, moduleinst) -def $alloc_module(s, module) = (s_res, m) +def $alloc_module(s, module) = (s_res, m_res) -- if module = MODULE import* func* global* table* mem* elem* data* start? export* - -- if m' = { FUNC epsilon, GLOBAL epsilon, TABLE epsilon, MEM epsilon, ELEM epsilon, DATA epsilon, EXPORT epsilon } - -- if f = { LOCAL epsilon, MODULE m' } + -- if m_init = { FUNC epsilon, GLOBAL epsilon, TABLE epsilon, MEM epsilon, ELEM epsilon, DATA epsilon, EXPORT epsilon } + -- if f = { LOCAL epsilon, MODULE m_init } -- if (s_func, fa*) = $alloc_func((s; f), func*) -- if (s_global, ga*) = $alloc_global((s_func; f), global*) -- if (s_table, ta*) = $alloc_table((s_global; f), table*) -- if (s_mem, ma*) = $alloc_mem((s_table; f), mem*) -- if (s_elem, ea*) = $alloc_elem((s_mem; f), elem*) -- if (s_data, da*) = $alloc_data((s_elem; f), data*) - -- if m = { FUNC fa*, GLOBAL ga*, TABLE ta*, MEM ma*, ELEM ea*, DATA da*, EXPORT epsilon } - -- if s_res = $replace_moduleinst(s_elem, fa*, m) + -- if m_ex = { FUNC fa*, GLOBAL ga*, TABLE ta*, MEM ma*, ELEM ea*, DATA da*, EXPORT epsilon } + -- if xi* = $alloc_export(m_ex, export)* + -- if m_res = m[.EXPORT = xi*] + -- if s_res = $replace_moduleinst(s_data, fa*, m_res) def $run_elem(state, elem*, idx) : state From 97d3fe644fc5c2c36d47333ee00a299d0c030aee Mon Sep 17 00:00:00 2001 From: Wonho Shin Date: Thu, 22 Jun 2023 20:37:15 +0900 Subject: [PATCH 13/49] Add import allocation --- spectec/spec/6-reduction.watsup | 55 +++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 10 deletions(-) diff --git a/spectec/spec/6-reduction.watsup b/spectec/spec/6-reduction.watsup index f1bcfdaeef..2aac9e1de7 100644 --- a/spectec/spec/6-reduction.watsup +++ b/spectec/spec/6-reduction.watsup @@ -380,6 +380,39 @@ rule Step/data.drop: ;; Module Semantics +def $alloc_import(moduleinst, import*, externval*) : moduleinst + +def $alloc_import(m, epsilon, epsilon) = m + +def $alloc_import(m, import import'*, externval externval'*) = m_res + -- if import = IMPORT name name' externtype + -- if externtype = FUNC functype + -- if externval = FUNC fa + -- if m_new = m[.FUNC =.. fa] + -- if m_res = $alloc_import(m_new, import'*, externval'*) + +def $alloc_import(m, import import'*, externval externval'*) = m_res + -- if import = IMPORT name name' externtype + -- if externtype = GLOBAL globaltype + -- if externval = GLOBAL ga + -- if m_new = m[.GLOBAL =.. ga] + -- if m_res = $alloc_import(m_new, import'*, externval'*) + +def $alloc_import(m, import import'*, externval externval'*) = m_res + -- if import = IMPORT name name' externtype + -- if externtype = TABLE tabletype + -- if externval = TABLE ta + -- if m_new = m[.TABLE =.. ta] + -- if m_res = $alloc_import(m_new, import'*, externval'*) + +def $alloc_import(m, import import'*, externval externval'*) = m_res + -- if import = IMPORT name name' externtype + -- if externtype = MEM memtype + -- if externval = MEM ma + -- if m_new = m[.MEM =.. ma] + -- if m_res = $alloc_import(m_new, import'*, externval'*) + + def $alloc_func(state, func*) : (store, funcaddr*) def $alloc_func((s; f), epsilon) = (s, epsilon) @@ -491,21 +524,23 @@ def $alloc_export(m, export) = xi -- if xi = { NAME name, VALUE externval } -def $alloc_module(store, module) : (store, moduleinst) +def $alloc_module(store, module, externval*) : (store, moduleinst) -def $alloc_module(s, module) = (s_res, m_res) +def $alloc_module(s, module, externval*) = (s_res, m_res) -- if module = MODULE import* func* global* table* mem* elem* data* start? export* -- if m_init = { FUNC epsilon, GLOBAL epsilon, TABLE epsilon, MEM epsilon, ELEM epsilon, DATA epsilon, EXPORT epsilon } - -- if f = { LOCAL epsilon, MODULE m_init } + -- if m_im = $alloc_import(m_init, import*, externval*) + -- if f = { LOCAL epsilon, MODULE m_im } -- if (s_func, fa*) = $alloc_func((s; f), func*) -- if (s_global, ga*) = $alloc_global((s_func; f), global*) -- if (s_table, ta*) = $alloc_table((s_global; f), table*) -- if (s_mem, ma*) = $alloc_mem((s_table; f), mem*) -- if (s_elem, ea*) = $alloc_elem((s_mem; f), elem*) -- if (s_data, da*) = $alloc_data((s_elem; f), data*) - -- if m_ex = { FUNC fa*, GLOBAL ga*, TABLE ta*, MEM ma*, ELEM ea*, DATA da*, EXPORT epsilon } + -- if m_im = { FUNC fa'*, GLOBAL ga'*, TABLE ta'*, MEM ma'*, ELEM epsilon, DATA epsilon, EXPORT epsilon } + -- if m_ex = { FUNC fa'* fa*, GLOBAL ga'* ga*, TABLE ta'* ta*, MEM ma'* ma*, ELEM ea*, DATA da*, EXPORT epsilon } -- if xi* = $alloc_export(m_ex, export)* - -- if m_res = m[.EXPORT = xi*] + -- if m_res = m_ex[.EXPORT = xi*] -- if s_res = $replace_moduleinst(s_data, fa*, m_res) @@ -547,18 +582,18 @@ def $run_data((s; f), data data'*, i) = s_res; f_res -- if $run_data((s_new; f_new), data'*, $(i + 1)) = s_res; f_res -def $instantiation(store, module) : (store, moduleinst) +def $instantiation(store, module, externval*) : (store, moduleinst) -def $instantiation(s, module) = (s_res, m) +def $instantiation(s, module, externval*) = (s_res, m) -- if module = MODULE import* func* global* table* mem* elem* data* export* - -- if (s_alloc, m) = $alloc_module(s, module) + -- if (s_alloc, m) = $alloc_module(s, module, externval*) -- if f = { LOCAL epsilon, MODULE m } -- if $run_elem((s_alloc; f_alloc), elem*, 0) = s_elem; f_elem -- if $run_data((s_elem; f_elem), data*, 0) = s_res; f_res -def $instantiation(s, module) = (s_res, m) +def $instantiation(s, module, externval*) = (s_res, m) -- if module = MODULE import* func* global* table* mem* elem* data* start export* - -- if (s_alloc, m) = $alloc_module(s, module) + -- if (s_alloc, m) = $alloc_module(s, module, externval*) -- if f = { LOCAL epsilon, MODULE m } -- if $run_elem((s_alloc; f_alloc), elem*, 0) = s_elem; f_elem -- if $run_data((s_elem; f_elem), data*, 0) = s_data; f_data From 68c60670a840ed409763bc79cb0072ff667bf108 Mon Sep 17 00:00:00 2001 From: Wonho Date: Mon, 26 Jun 2023 14:23:30 +0900 Subject: [PATCH 14/49] Add 7-module.watsup --- spectec/spec/6-reduction.watsup | 235 ------------------------------- spectec/spec/7-module.watsup | 236 ++++++++++++++++++++++++++++++++ 2 files changed, 236 insertions(+), 235 deletions(-) create mode 100644 spectec/spec/7-module.watsup diff --git a/spectec/spec/6-reduction.watsup b/spectec/spec/6-reduction.watsup index 2aac9e1de7..b987bc51da 100644 --- a/spectec/spec/6-reduction.watsup +++ b/spectec/spec/6-reduction.watsup @@ -376,238 +376,3 @@ rule Step_read/memory.init-succ: rule Step/data.drop: z; (DATA.DROP x) ~> $with_data(z, x, epsilon); epsilon - - -;; Module Semantics - -def $alloc_import(moduleinst, import*, externval*) : moduleinst - -def $alloc_import(m, epsilon, epsilon) = m - -def $alloc_import(m, import import'*, externval externval'*) = m_res - -- if import = IMPORT name name' externtype - -- if externtype = FUNC functype - -- if externval = FUNC fa - -- if m_new = m[.FUNC =.. fa] - -- if m_res = $alloc_import(m_new, import'*, externval'*) - -def $alloc_import(m, import import'*, externval externval'*) = m_res - -- if import = IMPORT name name' externtype - -- if externtype = GLOBAL globaltype - -- if externval = GLOBAL ga - -- if m_new = m[.GLOBAL =.. ga] - -- if m_res = $alloc_import(m_new, import'*, externval'*) - -def $alloc_import(m, import import'*, externval externval'*) = m_res - -- if import = IMPORT name name' externtype - -- if externtype = TABLE tabletype - -- if externval = TABLE ta - -- if m_new = m[.TABLE =.. ta] - -- if m_res = $alloc_import(m_new, import'*, externval'*) - -def $alloc_import(m, import import'*, externval externval'*) = m_res - -- if import = IMPORT name name' externtype - -- if externtype = MEM memtype - -- if externval = MEM ma - -- if m_new = m[.MEM =.. ma] - -- if m_res = $alloc_import(m_new, import'*, externval'*) - - -def $alloc_func(state, func*) : (store, funcaddr*) - -def $alloc_func((s; f), epsilon) = (s, epsilon) - -def $alloc_func((s; f), func func'*) = (s_res, fa fa'*) - -- if fi = { MODULE f.MODULE, CODE func } - -- if fa = |$funcinst((s; f))| - -- if s_new = s[.FUNC =.. fi] - -- if (s_res, fa'*) = $alloc_func((s_new; f), func'*) - - -def $alloc_global(state, global*) : (store, globaladdr*) - -def $alloc_global((s; f), epsilon) = (s, epsilon) - -def $alloc_global((s; f), global global'*) = (s_res, ga ga'*) - -- if global = GLOBAL globaltype instr* - -- Step_read : s; f; instr* ~> val - -- if gi = { TYPE globaltype, VALUE val } - -- if ga = |$globalinst((s; f))| - -- if s_new = s[.GLOBAL =.. gi] - -- if (s_res, ga'*) = $alloc_global((s_new; f), global'*) - - -def $alloc_table(state, table*) : (store, tableaddr*) - -def $alloc_table((s; f), epsilon) = (s, epsilon) - -def $alloc_table((s; f), table table'*) = (s_res, ta ta'*) - -- if table = TABLE tabletype - -- if tabletype = `[i .. j?] reftype - -- if ti = { TYPE tabletype, ELEM (REF.NULL reftype)^i } - -- if ta = |$tableinst((s; f))| - -- if s_new = s[.TABLE =.. ti] - -- if (s_res, ta'*) = $alloc_table((s_new; f), table'*) - - -def $alloc_mem(state, mem*) : (store, memaddr*) - -def $alloc_mem((s; f), epsilon) = (s, epsilon) - -def $alloc_mem((s; f), mem mem'*) = (s_res, ma ma'*) - -- if mem = MEMORY memtype - -- if memtype = `[i .. j?] I8 - -- if mi = { TYPE memtype, DATA 0^(i * 64 * $Ki()) } - -- if ma = |$meminst((s; f))| - -- if s_new = s[.MEM =.. mi] - -- if (s_res, ma'*) = $alloc_mem((s_new; f), mem'*) - - -def $alloc_elem(state, elem*) : (store, elemaddr*) - -def $alloc_elem((s; f), epsilon) = (s, epsilon) - -def $alloc_elem((s; f), elem elem'*) = (s_res, ea ea'*) - -- if elem = ELEM reftype (instr*)* elemmode? - -- (Step_read : s; f; instr* ~> ref)* - -- if ei = { TYPE reftype, ELEM ref* } - -- if ea = |$eleminst((s; f))| - -- if s_new = s[.ELEM =.. ei] - -- if (s_res, ea'*) = $alloc_elem((s_new; f), elem'*) - - -def $alloc_data(state, data*) : (store, dataaddr*) - -def $alloc_data((s; f), epsilon) = (s, epsilon) - -def $alloc_data((s; f), data data'*) = (s_res, da da'*) - -- if data = DATA byte* datamode? - -- if di = { DATA byte* } - -- if da = |$datainst((s; f))| - -- if s_new = s[.DATA =.. di] - -- if (s_res, da'*) = $alloc_data((s_new; f), data'*) - - -def $replace_moduleinst(store, funcaddr*, moduleinst) : store - -def $replace_moduleinst(s, epsilon, m) = s - -def $replace_moduleinst(s, fa fa'*, m) = s_res - -- if s_new = s[.FUNC[fa].MODULE = m] - -- if s_res = $replace_moduleinst(s_new, fa'*, m) - - -def $alloc_export(moduleinst, export) : exportinst - -def $alloc_export(m, export) = xi - -- if export = EXPORT name externuse - -- if externuse = FUNC x - -- if externval = FUNC m.FUNC[x] - -- if xi = { NAME name, VALUE externval } - -def $alloc_export(m, export) = xi - -- if export = EXPORT name externuse - -- if externuse = GLOBAL x - -- if externval = GLOBAL m.GLOBAL[x] - -- if xi = { NAME name, VALUE externval } - -def $alloc_export(m, export) = xi - -- if export = EXPORT name externuse - -- if externuse = TABLE x - -- if externval = TABLE m.TABLE[x] - -- if xi = { NAME name, VALUE externval } - -def $alloc_export(m, export) = xi - -- if export = EXPORT name externuse - -- if externuse = MEM x - -- if externval = MEM m.MEM[x] - -- if xi = { NAME name, VALUE externval } - - -def $alloc_module(store, module, externval*) : (store, moduleinst) - -def $alloc_module(s, module, externval*) = (s_res, m_res) - -- if module = MODULE import* func* global* table* mem* elem* data* start? export* - -- if m_init = { FUNC epsilon, GLOBAL epsilon, TABLE epsilon, MEM epsilon, ELEM epsilon, DATA epsilon, EXPORT epsilon } - -- if m_im = $alloc_import(m_init, import*, externval*) - -- if f = { LOCAL epsilon, MODULE m_im } - -- if (s_func, fa*) = $alloc_func((s; f), func*) - -- if (s_global, ga*) = $alloc_global((s_func; f), global*) - -- if (s_table, ta*) = $alloc_table((s_global; f), table*) - -- if (s_mem, ma*) = $alloc_mem((s_table; f), mem*) - -- if (s_elem, ea*) = $alloc_elem((s_mem; f), elem*) - -- if (s_data, da*) = $alloc_data((s_elem; f), data*) - -- if m_im = { FUNC fa'*, GLOBAL ga'*, TABLE ta'*, MEM ma'*, ELEM epsilon, DATA epsilon, EXPORT epsilon } - -- if m_ex = { FUNC fa'* fa*, GLOBAL ga'* ga*, TABLE ta'* ta*, MEM ma'* ma*, ELEM ea*, DATA da*, EXPORT epsilon } - -- if xi* = $alloc_export(m_ex, export)* - -- if m_res = m_ex[.EXPORT = xi*] - -- if s_res = $replace_moduleinst(s_data, fa*, m_res) - - -def $run_elem(state, elem*, idx) : state - -def $run_elem((s; f), epsilon, i) = s; f - -def $run_elem((s; f), elem elem'*, i) = s_res; f_res - -- if elem = ELEM reftype expr* - -- if $run_elem((s; f), elem'*, $(i + 1)) = s_res; f_res - -def $run_elem((s; f), elem elem'*, i) = s_res; f_res - -- if elem = ELEM reftype expr* elemmode - -- if n = |expr*| - -- if elemmode = TABLE x instr* - -- Step : s; f; instr* (CONST I32 0) (CONST I32 n) (TABLE.INIT x i) (ELEM.DROP i) ~> s_new; f_new; epsilon - -- if $run_elem((s_new; f_new), elem'*, $(i + 1)) = s_res; f_res - -def $run_elem((s; f), elem elem'*, i) = s_res; f_res - -- if elem = ELEM reftype expr* elemmode - -- if elemmode = DECLARE - -- Step : s; f; (ELEM.DROP i) ~> s_new; f_new; epsilon - -- if $run_elem((s_new; f_new), elem'*, $(i + 1)) = s_res; f_res - - -def $run_data(state, data*, idx) : state - -def $run_data((s; f), epsilon, i) = s; f - -def $run_data((s; f), data data'*, i) = s_res; f_res - -- if data = DATA byte* - -- if $run_data((s; f), data'*, $(i + 1)) = s_res; f_res - -def $run_data((s; f), data data'*, i) = s_res; f_res - -- if data = DATA byte* datamode - -- if n = |byte*| - -- if datamode = MEMORY 0 instr* - -- Step : s; f; instr* (CONST I32 0) (CONST I32 n) (MEMORY.INIT i) (DATA.DROP i) ~> s_new; f_new; epsilon - -- if $run_data((s_new; f_new), data'*, $(i + 1)) = s_res; f_res - - -def $instantiation(store, module, externval*) : (store, moduleinst) - -def $instantiation(s, module, externval*) = (s_res, m) - -- if module = MODULE import* func* global* table* mem* elem* data* export* - -- if (s_alloc, m) = $alloc_module(s, module, externval*) - -- if f = { LOCAL epsilon, MODULE m } - -- if $run_elem((s_alloc; f_alloc), elem*, 0) = s_elem; f_elem - -- if $run_data((s_elem; f_elem), data*, 0) = s_res; f_res - -def $instantiation(s, module, externval*) = (s_res, m) - -- if module = MODULE import* func* global* table* mem* elem* data* start export* - -- if (s_alloc, m) = $alloc_module(s, module, externval*) - -- if f = { LOCAL epsilon, MODULE m } - -- if $run_elem((s_alloc; f_alloc), elem*, 0) = s_elem; f_elem - -- if $run_data((s_elem; f_elem), data*, 0) = s_data; f_data - -- if start = START x - -- Step : s_data; f_data; (CALL x) ~> s_res; f_res; epsilon - - -def $invocation(store, funcaddr, val*) : (store, val*) - -def $invocation(s, fa, val*) = (s', val'*) - -- if m = { FUNC epsilon, GLOBAL epsilon, TABLE epsilon, MEM epsilon, ELEM epsilon, DATA epsilon, EXPORT epsilon } - -- if f = { LOCAL epsilon, MODULE m } - -- if $funcinst((s; f))[fa].CODE = FUNC functype valtype* expr - -- if functype = valtype* -> valtype'* - -- if |val*| = |valtype*| - -- if |val'*| = |valtype'*| - -- Step : s; f; val* (CALL_ADDR fa) ~> s'; f'; val'* diff --git a/spectec/spec/7-module.watsup b/spectec/spec/7-module.watsup new file mode 100644 index 0000000000..1dea48e598 --- /dev/null +++ b/spectec/spec/7-module.watsup @@ -0,0 +1,236 @@ +;; Allocation + +def $alloc_import(moduleinst, import*, externval*) : moduleinst + +def $alloc_import(m, epsilon, epsilon) = m + +def $alloc_import(m, import import'*, externval externval'*) = m_res + -- if import = IMPORT name name' externtype + -- if externtype = FUNC functype + -- if externval = FUNC fa + -- if m_new = m[.FUNC =.. fa] + -- if m_res = $alloc_import(m_new, import'*, externval'*) + +def $alloc_import(m, import import'*, externval externval'*) = m_res + -- if import = IMPORT name name' externtype + -- if externtype = GLOBAL globaltype + -- if externval = GLOBAL ga + -- if m_new = m[.GLOBAL =.. ga] + -- if m_res = $alloc_import(m_new, import'*, externval'*) + +def $alloc_import(m, import import'*, externval externval'*) = m_res + -- if import = IMPORT name name' externtype + -- if externtype = TABLE tabletype + -- if externval = TABLE ta + -- if m_new = m[.TABLE =.. ta] + -- if m_res = $alloc_import(m_new, import'*, externval'*) + +def $alloc_import(m, import import'*, externval externval'*) = m_res + -- if import = IMPORT name name' externtype + -- if externtype = MEM memtype + -- if externval = MEM ma + -- if m_new = m[.MEM =.. ma] + -- if m_res = $alloc_import(m_new, import'*, externval'*) + + +def $alloc_func(state, func*) : (store, funcaddr*) + +def $alloc_func((s; f), epsilon) = (s, epsilon) + +def $alloc_func((s; f), func func'*) = (s_res, fa fa'*) + -- if fi = { MODULE f.MODULE, CODE func } + -- if fa = |$funcinst((s; f))| + -- if s_new = s[.FUNC =.. fi] + -- if (s_res, fa'*) = $alloc_func((s_new; f), func'*) + + +def $alloc_global(state, global*) : (store, globaladdr*) + +def $alloc_global((s; f), epsilon) = (s, epsilon) + +def $alloc_global((s; f), global global'*) = (s_res, ga ga'*) + -- if global = GLOBAL globaltype instr* + -- Step_read : s; f; instr* ~> val + -- if gi = { TYPE globaltype, VALUE val } + -- if ga = |$globalinst((s; f))| + -- if s_new = s[.GLOBAL =.. gi] + -- if (s_res, ga'*) = $alloc_global((s_new; f), global'*) + + +def $alloc_table(state, table*) : (store, tableaddr*) + +def $alloc_table((s; f), epsilon) = (s, epsilon) + +def $alloc_table((s; f), table table'*) = (s_res, ta ta'*) + -- if table = TABLE tabletype + -- if tabletype = `[i .. j?] reftype + -- if ti = { TYPE tabletype, ELEM (REF.NULL reftype)^i } + -- if ta = |$tableinst((s; f))| + -- if s_new = s[.TABLE =.. ti] + -- if (s_res, ta'*) = $alloc_table((s_new; f), table'*) + + +def $alloc_mem(state, mem*) : (store, memaddr*) + +def $alloc_mem((s; f), epsilon) = (s, epsilon) + +def $alloc_mem((s; f), mem mem'*) = (s_res, ma ma'*) + -- if mem = MEMORY memtype + -- if memtype = `[i .. j?] I8 + -- if mi = { TYPE memtype, DATA 0^(i * 64 * $Ki()) } + -- if ma = |$meminst((s; f))| + -- if s_new = s[.MEM =.. mi] + -- if (s_res, ma'*) = $alloc_mem((s_new; f), mem'*) + + +def $alloc_elem(state, elem*) : (store, elemaddr*) + +def $alloc_elem((s; f), epsilon) = (s, epsilon) + +def $alloc_elem((s; f), elem elem'*) = (s_res, ea ea'*) + -- if elem = ELEM reftype (instr*)* elemmode? + -- (Step_read : s; f; instr* ~> ref)* + -- if ei = { TYPE reftype, ELEM ref* } + -- if ea = |$eleminst((s; f))| + -- if s_new = s[.ELEM =.. ei] + -- if (s_res, ea'*) = $alloc_elem((s_new; f), elem'*) + + +def $alloc_data(state, data*) : (store, dataaddr*) + +def $alloc_data((s; f), epsilon) = (s, epsilon) + +def $alloc_data((s; f), data data'*) = (s_res, da da'*) + -- if data = DATA byte* datamode? + -- if di = { DATA byte* } + -- if da = |$datainst((s; f))| + -- if s_new = s[.DATA =.. di] + -- if (s_res, da'*) = $alloc_data((s_new; f), data'*) + + +def $replace_moduleinst(store, funcaddr*, moduleinst) : store + +def $replace_moduleinst(s, epsilon, m) = s + +def $replace_moduleinst(s, fa fa'*, m) = s_res + -- if s_new = s[.FUNC[fa].MODULE = m] + -- if s_res = $replace_moduleinst(s_new, fa'*, m) + + +def $alloc_export(moduleinst, export) : exportinst + +def $alloc_export(m, export) = xi + -- if export = EXPORT name externuse + -- if externuse = FUNC x + -- if externval = FUNC m.FUNC[x] + -- if xi = { NAME name, VALUE externval } + +def $alloc_export(m, export) = xi + -- if export = EXPORT name externuse + -- if externuse = GLOBAL x + -- if externval = GLOBAL m.GLOBAL[x] + -- if xi = { NAME name, VALUE externval } + +def $alloc_export(m, export) = xi + -- if export = EXPORT name externuse + -- if externuse = TABLE x + -- if externval = TABLE m.TABLE[x] + -- if xi = { NAME name, VALUE externval } + +def $alloc_export(m, export) = xi + -- if export = EXPORT name externuse + -- if externuse = MEM x + -- if externval = MEM m.MEM[x] + -- if xi = { NAME name, VALUE externval } + + +def $alloc_module(store, module, externval*) : (store, moduleinst) + +def $alloc_module(s, module, externval*) = (s_res, m_res) + -- if module = MODULE import* func* global* table* mem* elem* data* start? export* + -- if m_init = { FUNC epsilon, GLOBAL epsilon, TABLE epsilon, MEM epsilon, ELEM epsilon, DATA epsilon, EXPORT epsilon } + -- if m_im = $alloc_import(m_init, import*, externval*) + -- if f = { LOCAL epsilon, MODULE m_im } + -- if (s_func, fa*) = $alloc_func((s; f), func*) + -- if (s_global, ga*) = $alloc_global((s_func; f), global*) + -- if (s_table, ta*) = $alloc_table((s_global; f), table*) + -- if (s_mem, ma*) = $alloc_mem((s_table; f), mem*) + -- if (s_elem, ea*) = $alloc_elem((s_mem; f), elem*) + -- if (s_data, da*) = $alloc_data((s_elem; f), data*) + -- if m_ex = m_im ++ { FUNC fa*, GLOBAL ga*, TABLE ta*, MEM ma*, ELEM ea*, DATA da*, EXPORT epsilon } + -- if xi* = $alloc_export(m_ex, export)* + -- if m_res = m_ex[.EXPORT = xi*] + -- if s_res = $replace_moduleinst(s_data, fa*, m_res) + + +def $run_elem(state, elem*, idx) : state + +def $run_elem((s; f), epsilon, i) = s; f + +def $run_elem((s; f), elem elem'*, i) = s_res; f_res + -- if elem = ELEM reftype expr* + -- if $run_elem((s; f), elem'*, $(i + 1)) = s_res; f_res + +def $run_elem((s; f), elem elem'*, i) = s_res; f_res + -- if elem = ELEM reftype expr* elemmode + -- if n = |expr*| + -- if elemmode = TABLE x instr* + -- Step : s; f; instr* (CONST I32 0) (CONST I32 n) (TABLE.INIT x i) (ELEM.DROP i) ~> s_new; f_new; epsilon + -- if $run_elem((s_new; f_new), elem'*, $(i + 1)) = s_res; f_res + +def $run_elem((s; f), elem elem'*, i) = s_res; f_res + -- if elem = ELEM reftype expr* elemmode + -- if elemmode = DECLARE + -- Step : s; f; (ELEM.DROP i) ~> s_new; f_new; epsilon + -- if $run_elem((s_new; f_new), elem'*, $(i + 1)) = s_res; f_res + + +def $run_data(state, data*, idx) : state + +def $run_data((s; f), epsilon, i) = s; f + +def $run_data((s; f), data data'*, i) = s_res; f_res + -- if data = DATA byte* + -- if $run_data((s; f), data'*, $(i + 1)) = s_res; f_res + +def $run_data((s; f), data data'*, i) = s_res; f_res + -- if data = DATA byte* datamode + -- if n = |byte*| + -- if datamode = MEMORY 0 instr* + -- Step : s; f; instr* (CONST I32 0) (CONST I32 n) (MEMORY.INIT i) (DATA.DROP i) ~> s_new; f_new; epsilon + -- if $run_data((s_new; f_new), data'*, $(i + 1)) = s_res; f_res + + +;; Instantiation + +def $instantiation(store, module, externval*) : (store, moduleinst) + +def $instantiation(s, module, externval*) = (s_res, m) + -- if module = MODULE import* func* global* table* mem* elem* data* export* + -- if (s_alloc, m) = $alloc_module(s, module, externval*) + -- if f = { LOCAL epsilon, MODULE m } + -- if $run_elem((s_alloc; f_alloc), elem*, 0) = s_elem; f_elem + -- if $run_data((s_elem; f_elem), data*, 0) = s_res; f_res + +def $instantiation(s, module, externval*) = (s_res, m) + -- if module = MODULE import* func* global* table* mem* elem* data* start export* + -- if (s_alloc, m) = $alloc_module(s, module, externval*) + -- if f = { LOCAL epsilon, MODULE m } + -- if $run_elem((s_alloc; f_alloc), elem*, 0) = s_elem; f_elem + -- if $run_data((s_elem; f_elem), data*, 0) = s_data; f_data + -- if start = START x + -- Step : s_data; f_data; (CALL x) ~> s_res; f_res; epsilon + + +;; Invocation + +def $invocation(store, funcaddr, val*) : (store, val*) + +def $invocation(s, fa, val*) = (s', val'*) + -- if m = { FUNC epsilon, GLOBAL epsilon, TABLE epsilon, MEM epsilon, ELEM epsilon, DATA epsilon, EXPORT epsilon } + -- if f = { LOCAL epsilon, MODULE m } + -- if $funcinst((s; f))[fa].CODE = FUNC functype valtype* expr + -- if functype = valtype* -> valtype'* + -- if |val*| = |valtype*| + -- if |val'*| = |valtype'*| + -- Step : s; f; val* (CALL_ADDR fa) ~> s'; f'; val'* From b8681db6b6ad58f9a6c62231320c8ed88c921401 Mon Sep 17 00:00:00 2001 From: Wonho Date: Mon, 26 Jun 2023 14:24:34 +0900 Subject: [PATCH 15/49] Update TEST.md --- spectec/test-frontend/TEST.md | 686 ++++++++- spectec/test-latex/TEST.md | 19 + spectec/test-middlend/TEST.md | 2681 +++++++++++++++++++++++++++++---- 3 files changed, 3040 insertions(+), 346 deletions(-) diff --git a/spectec/test-frontend/TEST.md b/spectec/test-frontend/TEST.md index cc823d5eb4..75aa963b32 100644 --- a/spectec/test-frontend/TEST.md +++ b/spectec/test-frontend/TEST.md @@ -297,8 +297,8 @@ syntax mem = MEMORY(memtype) ;; 1-syntax.watsup:198.1-199.31 syntax elem = `ELEM%%*%?`(reftype, expr*, elemmode?) -;; 1-syntax.watsup:200.1-201.26 -syntax data = `DATA(*)%*%?`(byte**, datamode?) +;; 1-syntax.watsup:200.1-201.23 +syntax data = `DATA%*%?`(byte*, datamode?) ;; 1-syntax.watsup:202.1-203.16 syntax start = START(funcidx) @@ -886,8 +886,8 @@ relation Datamode_ok: `%|-%:OK`(context, datamode) ;; 3-typing.watsup:402.1-402.73 relation Data_ok: `%|-%:OK`(context, data) ;; 3-typing.watsup:433.1-435.40 - rule _ {C : context, b** : byte**, datamode? : datamode?}: - `%|-%:OK`(C, `DATA(*)%*%?`(b*{b}*{b}, datamode?{datamode})) + rule _ {C : context, b* : byte*, datamode? : datamode?}: + `%|-%:OK`(C, `DATA%*%?`(b*{b}, datamode?{datamode})) -- (Datamode_ok: `%|-%:OK`(C, datamode))?{datamode} ;; 3-typing.watsup:405.1-405.74 @@ -1052,10 +1052,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:169.1-176.5 +;; 4-runtime.watsup:180.1-187.5 rec { -;; 4-runtime.watsup:169.1-176.5 +;; 4-runtime.watsup:180.1-187.5 syntax admininstr = | UNREACHABLE | NOP @@ -1119,104 +1119,129 @@ def funcaddr : state -> funcaddr* ;; 4-runtime.watsup:118.1-118.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:119.1-119.31 + ;; 4-runtime.watsup:125.1-125.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:121.1-121.67 +;; 4-runtime.watsup:119.1-119.58 +def globalinst : state -> globalinst* + ;; 4-runtime.watsup:126.1-126.35 + def {f : frame, s : store} globalinst(`%;%`(s, f)) = s.GLOBAL_store + +;; 4-runtime.watsup:120.1-120.55 +def tableinst : state -> tableinst* + ;; 4-runtime.watsup:127.1-127.33 + def {f : frame, s : store} tableinst(`%;%`(s, f)) = s.TABLE_store + +;; 4-runtime.watsup:121.1-121.49 +def meminst : state -> meminst* + ;; 4-runtime.watsup:128.1-128.29 + def {f : frame, s : store} meminst(`%;%`(s, f)) = s.MEM_store + +;; 4-runtime.watsup:122.1-122.52 +def eleminst : state -> eleminst* + ;; 4-runtime.watsup:129.1-129.31 + def {f : frame, s : store} eleminst(`%;%`(s, f)) = s.ELEM_store + +;; 4-runtime.watsup:123.1-123.52 +def datainst : state -> datainst* + ;; 4-runtime.watsup:130.1-130.31 + def {f : frame, s : store} datainst(`%;%`(s, f)) = s.DATA_store + +;; 4-runtime.watsup:132.1-132.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:129.1-129.48 + ;; 4-runtime.watsup:140.1-140.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:122.1-122.69 +;; 4-runtime.watsup:133.1-133.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:130.1-130.54 + ;; 4-runtime.watsup:141.1-141.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:123.1-123.68 +;; 4-runtime.watsup:134.1-134.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:131.1-131.51 + ;; 4-runtime.watsup:142.1-142.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:124.1-124.66 +;; 4-runtime.watsup:135.1-135.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:132.1-132.45 + ;; 4-runtime.watsup:143.1-143.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:125.1-125.67 +;; 4-runtime.watsup:136.1-136.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:133.1-133.48 + ;; 4-runtime.watsup:144.1-144.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:126.1-126.67 +;; 4-runtime.watsup:137.1-137.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:134.1-134.48 + ;; 4-runtime.watsup:145.1-145.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:127.1-127.68 +;; 4-runtime.watsup:138.1-138.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:135.1-135.35 + ;; 4-runtime.watsup:146.1-146.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:138.1-138.78 +;; 4-runtime.watsup:149.1-149.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:147.1-147.52 + ;; 4-runtime.watsup:158.1-158.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:139.1-139.85 +;; 4-runtime.watsup:150.1-150.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:148.1-148.77 + ;; 4-runtime.watsup:159.1-159.77 def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:140.1-140.88 +;; 4-runtime.watsup:151.1-151.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:149.1-149.79 + ;; 4-runtime.watsup:160.1-160.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:141.1-141.84 +;; 4-runtime.watsup:152.1-152.84 def with_tableinst : (state, tableidx, tableinst) -> state - ;; 4-runtime.watsup:150.1-150.74 + ;; 4-runtime.watsup:161.1-161.74 def {f : frame, s : store, ti : tableinst, x : idx} with_tableinst(`%;%`(s, f), x, ti) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] = ti], f) -;; 4-runtime.watsup:142.1-142.93 +;; 4-runtime.watsup:153.1-153.93 def with_mem : (state, memidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:151.1-151.82 + ;; 4-runtime.watsup:162.1-162.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:143.1-143.77 +;; 4-runtime.watsup:154.1-154.77 def with_meminst : (state, memidx, meminst) -> state - ;; 4-runtime.watsup:152.1-152.68 + ;; 4-runtime.watsup:163.1-163.68 def {f : frame, mi : meminst, s : store, x : idx} with_meminst(`%;%`(s, f), x, mi) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] = mi], f) -;; 4-runtime.watsup:144.1-144.82 +;; 4-runtime.watsup:155.1-155.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:153.1-153.72 + ;; 4-runtime.watsup:164.1-164.72 def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:145.1-145.82 +;; 4-runtime.watsup:156.1-156.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:154.1-154.72 + ;; 4-runtime.watsup:165.1-165.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:156.1-156.49 +;; 4-runtime.watsup:167.1-167.49 def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:158.1-161.57 + ;; 4-runtime.watsup:169.1-172.57 def {i : nat, i' : nat, j? : nat?, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' -- if (ti = {TYPE `%%`(`[%..%?]`(i, j?{j}), reftype), ELEM r'*{r'}}) -- if (i' = (|r'*{r'}| + n)) -- if (ti' = {TYPE `%%`(`[%..%?]`(i', j?{j}), reftype), ELEM r'*{r'} :: r^n{}}) -;; 4-runtime.watsup:157.1-157.41 +;; 4-runtime.watsup:168.1-168.41 def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:162.1-165.66 + ;; 4-runtime.watsup:173.1-176.66 def {b* : byte*, i : nat, i' : nat, j? : nat?, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' -- if (mi = {TYPE `%I8`(`[%..%?]`(i, j?{j})), DATA b*{b}}) -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) -- if (mi' = {TYPE `%I8`(`[%..%?]`(i', j?{j})), DATA b*{b} :: 0^((n * 64) * $Ki){}}) -;; 4-runtime.watsup:178.1-181.21 +;; 4-runtime.watsup:189.1-192.21 rec { -;; 4-runtime.watsup:178.1-181.21 +;; 4-runtime.watsup:189.1-192.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -1658,6 +1683,278 @@ relation Step: `%~>%`(config, config) rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) +;; 7-module.watsup:3.1-3.64 +rec { + +;; 7-module.watsup:3.1-3.64 +def alloc_import : (moduleinst, import*, externval*) -> moduleinst + ;; 7-module.watsup:5.1-5.43 + def {m : moduleinst} alloc_import(m, [], []) = m + ;; 7-module.watsup:7.1-12.60 + def {externtype : externtype, externval : externval, externval'* : externval*, fa : funcaddr, functype : functype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = FUNC_externtype(functype)) + -- if (externval = FUNC_externval(fa)) + -- if (m_new = m[FUNC_moduleinst =.. [fa]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) + ;; 7-module.watsup:14.1-19.60 + def {externtype : externtype, externval : externval, externval'* : externval*, ga : globaladdr, globaltype : globaltype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = GLOBAL_externtype(globaltype)) + -- if (externval = GLOBAL_externval(ga)) + -- if (m_new = m[GLOBAL_moduleinst =.. [ga]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) + ;; 7-module.watsup:21.1-26.60 + def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name, ta : tableaddr, tabletype : tabletype} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = TABLE_externtype(tabletype)) + -- if (externval = TABLE_externval(ta)) + -- if (m_new = m[TABLE_moduleinst =.. [ta]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) + ;; 7-module.watsup:28.1-33.60 + def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, ma : memaddr, memtype : memtype, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = MEM_externtype(memtype)) + -- if (externval = MEM_externval(ma)) + -- if (m_new = m[MEM_moduleinst =.. [ma]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) +} + +;; 7-module.watsup:36.1-36.51 +rec { + +;; 7-module.watsup:36.1-36.51 +def alloc_func : (state, func*) -> (store, funcaddr*) + ;; 7-module.watsup:38.1-38.48 + def {f : frame, s : store} alloc_func(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:40.1-44.56 + def {f : frame, fa : funcaddr, fa'* : funcaddr*, fi : funcinst, func : func, func'* : func*, s : store, s_new : store, s_res : store} alloc_func(`%;%`(s, f), [func] :: func'*{func'}) = (s_res, [fa] :: fa'*{fa'}) + -- if (fi = {MODULE f.MODULE_frame, CODE func}) + -- if (fa = |$funcinst(`%;%`(s, f))|) + -- if (s_new = s[FUNC_store =.. [fi]]) + -- if ((s_res, fa'*{fa'}) = $alloc_func(`%;%`(s_new, f), func'*{func'})) +} + +;; 7-module.watsup:47.1-47.57 +rec { + +;; 7-module.watsup:47.1-47.57 +def alloc_global : (state, global*) -> (store, globaladdr*) + ;; 7-module.watsup:49.1-49.50 + def {f : frame, s : store} alloc_global(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:51.1-57.60 + def {f : frame, ga : globaladdr, ga'* : globaladdr*, gi : globalinst, global : global, global'* : global*, globaltype : globaltype, instr* : instr*, s : store, s_new : store, s_res : store, val : val} alloc_global(`%;%`(s, f), [global] :: global'*{global'}) = (s_res, [ga] :: ga'*{ga'}) + -- if (global = GLOBAL(globaltype, instr*{instr})) + -- Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), (instr <: admininstr)*{instr}), [(val <: admininstr)]) + -- if (gi = {TYPE globaltype, VALUE val}) + -- if (ga = |$globalinst(`%;%`(s, f))|) + -- if (s_new = s[GLOBAL_store =.. [gi]]) + -- if ((s_res, ga'*{ga'}) = $alloc_global(`%;%`(s_new, f), global'*{global'})) +} + +;; 7-module.watsup:60.1-60.54 +rec { + +;; 7-module.watsup:60.1-60.54 +def alloc_table : (state, table*) -> (store, tableaddr*) + ;; 7-module.watsup:62.1-62.49 + def {f : frame, s : store} alloc_table(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:64.1-70.58 + def {f : frame, i : nat, j? : nat?, reftype : reftype, s : store, s_new : store, s_res : store, ta : tableaddr, ta'* : tableaddr*, table : table, table'* : table*, tabletype : tabletype, ti : tableinst} alloc_table(`%;%`(s, f), [table] :: table'*{table'}) = (s_res, [ta] :: ta'*{ta'}) + -- if (table = TABLE(tabletype)) + -- if (tabletype = `%%`(`[%..%?]`(i, j?{j}), reftype)) + -- if (ti = {TYPE tabletype, ELEM REF.NULL_ref(reftype)^i{}}) + -- if (ta = |$tableinst(`%;%`(s, f))|) + -- if (s_new = s[TABLE_store =.. [ti]]) + -- if ((s_res, ta'*{ta'}) = $alloc_table(`%;%`(s_new, f), table'*{table'})) +} + +;; 7-module.watsup:73.1-73.48 +rec { + +;; 7-module.watsup:73.1-73.48 +def alloc_mem : (state, mem*) -> (store, memaddr*) + ;; 7-module.watsup:75.1-75.47 + def {f : frame, s : store} alloc_mem(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:77.1-83.54 + def {f : frame, i : nat, j? : nat?, ma : memaddr, ma'* : memaddr*, mem : mem, mem'* : mem*, memtype : memtype, mi : meminst, s : store, s_new : store, s_res : store} alloc_mem(`%;%`(s, f), [mem] :: mem'*{mem'}) = (s_res, [ma] :: ma'*{ma'}) + -- if (mem = MEMORY(memtype)) + -- if (memtype = `%I8`(`[%..%?]`(i, j?{j}))) + -- if (mi = {TYPE memtype, DATA 0^((i * 64) * $Ki){}}) + -- if (ma = |$meminst(`%;%`(s, f))|) + -- if (s_new = s[MEM_store =.. [mi]]) + -- if ((s_res, ma'*{ma'}) = $alloc_mem(`%;%`(s_new, f), mem'*{mem'})) +} + +;; 7-module.watsup:86.1-86.51 +rec { + +;; 7-module.watsup:86.1-86.51 +def alloc_elem : (state, elem*) -> (store, elemaddr*) + ;; 7-module.watsup:88.1-88.48 + def {f : frame, s : store} alloc_elem(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:90.1-96.56 + def {ea : elemaddr, ea'* : elemaddr*, ei : eleminst, elem : elem, elem'* : elem*, elemmode? : elemmode?, f : frame, instr** : instr**, ref* : ref*, reftype : reftype, s : store, s_new : store, s_res : store} alloc_elem(`%;%`(s, f), [elem] :: elem'*{elem'}) = (s_res, [ea] :: ea'*{ea'}) + -- if (elem = `ELEM%%*%?`(reftype, instr*{instr}*{instr}, elemmode?{elemmode})) + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), (instr <: admininstr)*{instr}), [(ref <: admininstr)]))*{instr ref} + -- if (ei = {TYPE reftype, ELEM ref*{ref}}) + -- if (ea = |$eleminst(`%;%`(s, f))|) + -- if (s_new = s[ELEM_store =.. [ei]]) + -- if ((s_res, ea'*{ea'}) = $alloc_elem(`%;%`(s_new, f), elem'*{elem'})) +} + +;; 7-module.watsup:99.1-99.51 +rec { + +;; 7-module.watsup:99.1-99.51 +def alloc_data : (state, data*) -> (store, dataaddr*) + ;; 7-module.watsup:101.1-101.48 + def {f : frame, s : store} alloc_data(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:103.1-108.56 + def {byte* : byte*, da : dataaddr, da'* : dataaddr*, data : data, data'* : data*, datamode? : datamode?, di : datainst, f : frame, s : store, s_new : store, s_res : store} alloc_data(`%;%`(s, f), [data] :: data'*{data'}) = (s_res, [da] :: da'*{da'}) + -- if (data = `DATA%*%?`(byte*{byte}, datamode?{datamode})) + -- if (di = {DATA byte*{byte}}) + -- if (da = |$datainst(`%;%`(s, f))|) + -- if (s_new = s[DATA_store =.. [di]]) + -- if ((s_res, da'*{da'}) = $alloc_data(`%;%`(s_new, f), data'*{data'})) +} + +;; 7-module.watsup:111.1-111.62 +rec { + +;; 7-module.watsup:111.1-111.62 +def replace_moduleinst : (store, funcaddr*, moduleinst) -> store + ;; 7-module.watsup:113.1-113.43 + def {m : moduleinst, s : store} replace_moduleinst(s, [], m) = s + ;; 7-module.watsup:115.1-117.52 + def {fa : funcaddr, fa'* : funcaddr*, m : moduleinst, s : store, s_new : store, s_res : store} replace_moduleinst(s, [fa] :: fa'*{fa'}, m) = s_res + -- if (s_new = s[FUNC_store[fa].MODULE_funcinst = m]) + -- if (s_res = $replace_moduleinst(s_new, fa'*{fa'}, m)) +} + +;; 7-module.watsup:120.1-120.51 +def alloc_export : (moduleinst, export) -> exportinst + ;; 7-module.watsup:122.1-126.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = FUNC_externuse(x)) + -- if (externval = FUNC_externval(m.FUNC_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + ;; 7-module.watsup:128.1-132.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = GLOBAL_externuse(x)) + -- if (externval = GLOBAL_externval(m.GLOBAL_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + ;; 7-module.watsup:134.1-138.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = TABLE_externuse(x)) + -- if (externval = TABLE_externval(m.TABLE_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + ;; 7-module.watsup:140.1-144.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = MEM_externuse(x)) + -- if (externval = MEM_externval(m.MEM_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + +;; 7-module.watsup:147.1-147.67 +def alloc_module : (store, module, externval*) -> (store, moduleinst) + ;; 7-module.watsup:149.1-163.56 + def {da* : dataaddr*, data* : data*, ea* : elemaddr*, elem* : elem*, export* : export*, externval* : externval*, f : frame, fa* : funcaddr*, func* : func*, ga* : globaladdr*, global* : global*, import* : import*, m_ex : moduleinst, m_im : moduleinst, m_init : moduleinst, m_res : moduleinst, ma* : memaddr*, mem* : mem*, module : module, s : store, s_data : store, s_elem : store, s_func : store, s_global : store, s_mem : store, s_res : store, s_table : store, start? : start?, ta* : tableaddr*, table* : table*, xi* : exportinst*} alloc_module(s, module, externval*{externval}) = (s_res, m_res) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) + -- if (m_init = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (m_im = $alloc_import(m_init, import*{import}, externval*{externval})) + -- if (f = {LOCAL [], MODULE m_im}) + -- if ((s_func, fa*{fa}) = $alloc_func(`%;%`(s, f), func*{func})) + -- if ((s_global, ga*{ga}) = $alloc_global(`%;%`(s_func, f), global*{global})) + -- if ((s_table, ta*{ta}) = $alloc_table(`%;%`(s_global, f), table*{table})) + -- if ((s_mem, ma*{ma}) = $alloc_mem(`%;%`(s_table, f), mem*{mem})) + -- if ((s_elem, ea*{ea}) = $alloc_elem(`%;%`(s_mem, f), elem*{elem})) + -- if ((s_data, da*{da}) = $alloc_data(`%;%`(s_elem, f), data*{data})) + -- if (m_ex = m_im ++ {FUNC fa*{fa}, GLOBAL ga*{ga}, TABLE ta*{ta}, MEM ma*{ma}, ELEM ea*{ea}, DATA da*{da}, EXPORT []}) + -- if (xi*{xi} = $alloc_export(m_ex, export)*{export}) + -- if (m_res = m_ex[EXPORT_moduleinst = xi*{xi}]) + -- if (s_res = $replace_moduleinst(s_data, fa*{fa}, m_res)) + +;; 7-module.watsup:166.1-166.41 +rec { + +;; 7-module.watsup:166.1-166.41 +def run_elem : (state, elem*, idx) -> state + ;; 7-module.watsup:168.1-168.41 + def {f : frame, i : nat, s : store} run_elem(`%;%`(s, f), [], i) = `%;%`(s, f) + ;; 7-module.watsup:170.1-172.59 + def {elem : elem, elem'* : elem*, expr* : expr*, f : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) + -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?())) + -- if ($run_elem(`%;%`(s, f), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:174.1-179.67 + def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, reftype : reftype, s : store, s_new : store, s_res : store, x : idx} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) + -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) + -- if (n = |expr*{expr}|) + -- if (elemmode = TABLE_elemmode(x, instr*{instr})) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), (instr <: admininstr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, i) ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) + -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:181.1-185.67 + def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_new : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) + -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) + -- if (elemmode = DECLARE_elemmode) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), [ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) + -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) +} + +;; 7-module.watsup:188.1-188.41 +rec { + +;; 7-module.watsup:188.1-188.41 +def run_data : (state, data*, idx) -> state + ;; 7-module.watsup:190.1-190.41 + def {f : frame, i : nat, s : store} run_data(`%;%`(s, f), [], i) = `%;%`(s, f) + ;; 7-module.watsup:192.1-194.59 + def {byte* : byte*, data : data, data'* : data*, f : frame, f_res : frame, i : nat, s : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) + -- if (data = `DATA%*%?`(byte*{byte}, ?())) + -- if ($run_data(`%;%`(s, f), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:196.1-201.67 + def {byte* : byte*, data : data, data'* : data*, datamode : datamode, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, s : store, s_new : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) + -- if (data = `DATA%*%?`(byte*{byte}, ?(datamode))) + -- if (n = |byte*{byte}|) + -- if (datamode = MEMORY_datamode(0, instr*{instr})) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), (instr <: admininstr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(i) DATA.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) + -- if ($run_data(`%;%`(s_new, f_new), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) +} + +;; 7-module.watsup:206.1-206.68 +def instantiation : (store, module, externval*) -> (store, moduleinst) + ;; 7-module.watsup:208.1-213.61 + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(), export*{export})) + -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) + -- if (f = {LOCAL [], MODULE m}) + -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:215.1-222.62 + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(start), export*{export})) + -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) + -- if (f = {LOCAL [], MODULE m}) + -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_data, f_data)) + -- if (start = START(x)) + -- Step: `%~>%`(`%;%*`(`%;%`(s_data, f_data), [CALL_admininstr(x)]), `%;%*`(`%;%`(s_res, f_res), [])) + +;; 7-module.watsup:227.1-227.55 +def invocation : (store, funcaddr, val*) -> (store, val*) + ;; 7-module.watsup:229.1-236.55 + def {expr : expr, f : frame, f' : frame, fa : funcaddr, functype : functype, m : moduleinst, s : store, s' : store, val* : val*, val'* : val*, valtype* : valtype*, valtype'* : valtype*} invocation(s, fa, val*{val}) = (s', val'*{val'}) + -- if (m = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f = {LOCAL [], MODULE m}) + -- if ($funcinst(`%;%`(s, f))[fa].CODE_funcinst = `FUNC%%*%`(functype, valtype*{valtype}, expr)) + -- if (functype = `%->%`(valtype*{valtype}, valtype'*{valtype'})) + -- if (|val*{val}| = |valtype*{valtype}|) + -- if (|val'*{val'}| = |valtype'*{valtype'}|) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), (val <: admininstr)*{val} :: [CALL_ADDR_admininstr(fa)]), `%;%*`(`%;%`(s', f'), (val' <: admininstr)*{val'})) + == IL Validation... == Latex Generation... $$ @@ -1822,7 +2119,7 @@ $$ \mbox{(table)} & \mathit{table} &::=& \mathsf{table}~\mathit{tabletype} \\ \mbox{(memory)} & \mathit{mem} &::=& \mathsf{memory}~\mathit{memtype} \\ \mbox{(table segment)} & \mathit{elem} &::=& \mathsf{elem}~\mathit{reftype}~{\mathit{expr}^\ast}~{\mathit{elemmode}^?} \\ -\mbox{(memory segment)} & \mathit{data} &::=& \mathsf{data}~{({\mathit{byte}^\ast})^\ast}~{\mathit{datamode}^?} \\ +\mbox{(memory segment)} & \mathit{data} &::=& \mathsf{data}~{\mathit{byte}^\ast}~{\mathit{datamode}^?} \\ \mbox{(start function)} & \mathit{start} &::=& \mathsf{start}~\mathit{funcidx} \\ \mbox{(external use)} & \mathit{externuse} &::=& \mathsf{func}~\mathit{funcidx} ~|~ \mathsf{global}~\mathit{globalidx} ~|~ \mathsf{table}~\mathit{tableidx} ~|~ \mathsf{mem}~\mathit{memidx} \\ \mbox{(export)} & \mathit{export} &::=& \mathsf{export}~\mathit{name}~\mathit{externuse} \\ @@ -2980,7 +3277,7 @@ $$ \frac{ (\mathit{C} \vdash \mathit{datamode} : \mathsf{ok})^? }{ -\mathit{C} \vdash \mathsf{data}~{({\mathit{b}^\ast})^\ast}~{\mathit{datamode}^?} : \mathsf{ok} +\mathit{C} \vdash \mathsf{data}~{\mathit{b}^\ast}~{\mathit{datamode}^?} : \mathsf{ok} } \, {[\textsc{\scriptsize T{-}data}]} \qquad \end{array} @@ -3246,6 +3543,36 @@ $$ \end{array} $$ +$$ +\begin{array}{@{}lcl@{}l@{}} +(\mathit{s} ; \mathit{f}).\mathsf{global} &=& \mathit{s}.\mathsf{global} & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +(\mathit{s} ; \mathit{f}).\mathsf{table} &=& \mathit{s}.\mathsf{table} & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +(\mathit{s} ; \mathit{f}).\mathsf{mem} &=& \mathit{s}.\mathsf{mem} & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +(\mathit{s} ; \mathit{f}).\mathsf{elem} &=& \mathit{s}.\mathsf{elem} & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +(\mathit{s} ; \mathit{f}).\mathsf{data} &=& \mathit{s}.\mathsf{data} & \\ +\end{array} +$$ + $$ \begin{array}{@{}lcl@{}l@{}} {(\mathit{s} ; \mathit{f}).\mathsf{func}}{[\mathit{x}]} &=& \mathit{s}.\mathsf{func}[\mathit{f}.\mathsf{module}.\mathsf{func}[\mathit{x}]] & \\ @@ -3790,6 +4117,275 @@ $$ \end{array} $$ +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{alloc}_{\mathit{import}}(\mathit{m},\, \epsilon,\, \epsilon) &=& \mathit{m} & \\ +\mathrm{alloc}_{\mathit{import}}(\mathit{m},\, \mathit{import}~{{\mathit{import}'}^\ast},\, \mathit{externval}~{{\mathit{externval}'}^\ast}) &=& \mathit{m}_{\mathit{res}} &\quad + \mbox{if}~\mathit{import} = \mathsf{import}~\mathit{name}~{\mathit{name}'}~\mathit{externtype} \\ + &&&&\quad {\land}~\mathit{externtype} = \mathsf{func}~\mathit{functype} \\ + &&&&\quad {\land}~\mathit{externval} = \mathsf{func}~\mathit{fa} \\ + &&&&\quad {\land}~\mathit{m}_{\mathit{new}} = \mathit{m}[\mathsf{func} = ..\mathit{fa}] \\ + &&&&\quad {\land}~\mathit{m}_{\mathit{res}} = \mathrm{alloc}_{\mathit{import}}(\mathit{m}_{\mathit{new}},\, {{\mathit{import}'}^\ast},\, {{\mathit{externval}'}^\ast}) \\ +\mathrm{alloc}_{\mathit{import}}(\mathit{m},\, \mathit{import}~{{\mathit{import}'}^\ast},\, \mathit{externval}~{{\mathit{externval}'}^\ast}) &=& \mathit{m}_{\mathit{res}} &\quad + \mbox{if}~\mathit{import} = \mathsf{import}~\mathit{name}~{\mathit{name}'}~\mathit{externtype} \\ + &&&&\quad {\land}~\mathit{externtype} = \mathsf{global}~\mathit{globaltype} \\ + &&&&\quad {\land}~\mathit{externval} = \mathsf{global}~\mathit{ga} \\ + &&&&\quad {\land}~\mathit{m}_{\mathit{new}} = \mathit{m}[\mathsf{global} = ..\mathit{ga}] \\ + &&&&\quad {\land}~\mathit{m}_{\mathit{res}} = \mathrm{alloc}_{\mathit{import}}(\mathit{m}_{\mathit{new}},\, {{\mathit{import}'}^\ast},\, {{\mathit{externval}'}^\ast}) \\ +\mathrm{alloc}_{\mathit{import}}(\mathit{m},\, \mathit{import}~{{\mathit{import}'}^\ast},\, \mathit{externval}~{{\mathit{externval}'}^\ast}) &=& \mathit{m}_{\mathit{res}} &\quad + \mbox{if}~\mathit{import} = \mathsf{import}~\mathit{name}~{\mathit{name}'}~\mathit{externtype} \\ + &&&&\quad {\land}~\mathit{externtype} = \mathsf{table}~\mathit{tabletype} \\ + &&&&\quad {\land}~\mathit{externval} = \mathsf{table}~\mathit{ta} \\ + &&&&\quad {\land}~\mathit{m}_{\mathit{new}} = \mathit{m}[\mathsf{table} = ..\mathit{ta}] \\ + &&&&\quad {\land}~\mathit{m}_{\mathit{res}} = \mathrm{alloc}_{\mathit{import}}(\mathit{m}_{\mathit{new}},\, {{\mathit{import}'}^\ast},\, {{\mathit{externval}'}^\ast}) \\ +\mathrm{alloc}_{\mathit{import}}(\mathit{m},\, \mathit{import}~{{\mathit{import}'}^\ast},\, \mathit{externval}~{{\mathit{externval}'}^\ast}) &=& \mathit{m}_{\mathit{res}} &\quad + \mbox{if}~\mathit{import} = \mathsf{import}~\mathit{name}~{\mathit{name}'}~\mathit{externtype} \\ + &&&&\quad {\land}~\mathit{externtype} = \mathsf{mem}~\mathit{memtype} \\ + &&&&\quad {\land}~\mathit{externval} = \mathsf{mem}~\mathit{ma} \\ + &&&&\quad {\land}~\mathit{m}_{\mathit{new}} = \mathit{m}[\mathsf{mem} = ..\mathit{ma}] \\ + &&&&\quad {\land}~\mathit{m}_{\mathit{res}} = \mathrm{alloc}_{\mathit{import}}(\mathit{m}_{\mathit{new}},\, {{\mathit{import}'}^\ast},\, {{\mathit{externval}'}^\ast}) \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{alloc}_{\mathit{func}}((\mathit{s} ; \mathit{f}),\, \epsilon) &=& (\mathit{s},\, \epsilon) & \\ +\mathrm{alloc}_{\mathit{func}}((\mathit{s} ; \mathit{f}),\, \mathit{func}~{{\mathit{func}'}^\ast}) &=& (\mathit{s}_{\mathit{res}},\, \mathit{fa}~{{\mathit{fa}'}^\ast}) &\quad + \mbox{if}~\mathit{fi} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{module}~\mathit{f}.\mathsf{module},\; \mathsf{code}~\mathit{func} \}\end{array} \\ + &&&&\quad {\land}~\mathit{fa} = {|(\mathit{s} ; \mathit{f}).\mathsf{func}|} \\ + &&&&\quad {\land}~\mathit{s}_{\mathit{new}} = \mathit{s}[\mathsf{func} = ..\mathit{fi}] \\ + &&&&\quad {\land}~(\mathit{s}_{\mathit{res}},\, {{\mathit{fa}'}^\ast}) = \mathrm{alloc}_{\mathit{func}}((\mathit{s}_{\mathit{new}} ; \mathit{f}),\, {{\mathit{func}'}^\ast}) \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{alloc}_{\mathit{global}}((\mathit{s} ; \mathit{f}),\, \epsilon) &=& (\mathit{s},\, \epsilon) & \\ +\mathrm{alloc}_{\mathit{global}}((\mathit{s} ; \mathit{f}),\, \mathit{global}~{{\mathit{global}'}^\ast}) &=& (\mathit{s}_{\mathit{res}},\, \mathit{ga}~{{\mathit{ga}'}^\ast}) &\quad + \mbox{if}~\mathit{global} = \mathsf{global}~\mathit{globaltype}~{\mathit{instr}^\ast} \\ + &&&&\quad {\land}~\mathit{s} ; \mathit{f} ; {\mathit{instr}^\ast} \hookrightarrow \mathit{val} \\ + &&&&\quad {\land}~\mathit{gi} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{type}~\mathit{globaltype},\; \mathsf{value}~\mathit{val} \}\end{array} \\ + &&&&\quad {\land}~\mathit{ga} = {|(\mathit{s} ; \mathit{f}).\mathsf{global}|} \\ + &&&&\quad {\land}~\mathit{s}_{\mathit{new}} = \mathit{s}[\mathsf{global} = ..\mathit{gi}] \\ + &&&&\quad {\land}~(\mathit{s}_{\mathit{res}},\, {{\mathit{ga}'}^\ast}) = \mathrm{alloc}_{\mathit{global}}((\mathit{s}_{\mathit{new}} ; \mathit{f}),\, {{\mathit{global}'}^\ast}) \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{alloc}_{\mathit{table}}((\mathit{s} ; \mathit{f}),\, \epsilon) &=& (\mathit{s},\, \epsilon) & \\ +\mathrm{alloc}_{\mathit{table}}((\mathit{s} ; \mathit{f}),\, \mathit{table}~{{\mathit{table}'}^\ast}) &=& (\mathit{s}_{\mathit{res}},\, \mathit{ta}~{{\mathit{ta}'}^\ast}) &\quad + \mbox{if}~\mathit{table} = \mathsf{table}~\mathit{tabletype} \\ + &&&&\quad {\land}~\mathit{tabletype} = [\mathit{i} .. {\mathit{j}^?}]~\mathit{reftype} \\ + &&&&\quad {\land}~\mathit{ti} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{type}~\mathit{tabletype},\; \mathsf{elem}~{(\mathsf{ref.null}~\mathit{reftype})^{\mathit{i}}} \}\end{array} \\ + &&&&\quad {\land}~\mathit{ta} = {|(\mathit{s} ; \mathit{f}).\mathsf{table}|} \\ + &&&&\quad {\land}~\mathit{s}_{\mathit{new}} = \mathit{s}[\mathsf{table} = ..\mathit{ti}] \\ + &&&&\quad {\land}~(\mathit{s}_{\mathit{res}},\, {{\mathit{ta}'}^\ast}) = \mathrm{alloc}_{\mathit{table}}((\mathit{s}_{\mathit{new}} ; \mathit{f}),\, {{\mathit{table}'}^\ast}) \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{alloc}_{\mathit{mem}}((\mathit{s} ; \mathit{f}),\, \epsilon) &=& (\mathit{s},\, \epsilon) & \\ +\mathrm{alloc}_{\mathit{mem}}((\mathit{s} ; \mathit{f}),\, \mathit{mem}~{{\mathit{mem}'}^\ast}) &=& (\mathit{s}_{\mathit{res}},\, \mathit{ma}~{{\mathit{ma}'}^\ast}) &\quad + \mbox{if}~\mathit{mem} = \mathsf{memory}~\mathit{memtype} \\ + &&&&\quad {\land}~\mathit{memtype} = [\mathit{i} .. {\mathit{j}^?}]~\mathsf{i{\scriptstyle8}} \\ + &&&&\quad {\land}~\mathit{mi} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{type}~\mathit{memtype},\; \mathsf{data}~{0^{\mathit{i} \cdot 64 \cdot \mathrm{Ki}}} \}\end{array} \\ + &&&&\quad {\land}~\mathit{ma} = {|(\mathit{s} ; \mathit{f}).\mathsf{mem}|} \\ + &&&&\quad {\land}~\mathit{s}_{\mathit{new}} = \mathit{s}[\mathsf{mem} = ..\mathit{mi}] \\ + &&&&\quad {\land}~(\mathit{s}_{\mathit{res}},\, {{\mathit{ma}'}^\ast}) = \mathrm{alloc}_{\mathit{mem}}((\mathit{s}_{\mathit{new}} ; \mathit{f}),\, {{\mathit{mem}'}^\ast}) \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{alloc}_{\mathit{elem}}((\mathit{s} ; \mathit{f}),\, \epsilon) &=& (\mathit{s},\, \epsilon) & \\ +\mathrm{alloc}_{\mathit{elem}}((\mathit{s} ; \mathit{f}),\, \mathit{elem}~{{\mathit{elem}'}^\ast}) &=& (\mathit{s}_{\mathit{res}},\, \mathit{ea}~{{\mathit{ea}'}^\ast}) &\quad + \mbox{if}~\mathit{elem} = \mathsf{elem}~\mathit{reftype}~{({\mathit{instr}^\ast})^\ast}~{\mathit{elemmode}^?} \\ + &&&&\quad {\land}~(\mathit{s} ; \mathit{f} ; {\mathit{instr}^\ast} \hookrightarrow \mathit{ref})^\ast \\ + &&&&\quad {\land}~\mathit{ei} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{type}~\mathit{reftype},\; \mathsf{elem}~{\mathit{ref}^\ast} \}\end{array} \\ + &&&&\quad {\land}~\mathit{ea} = {|(\mathit{s} ; \mathit{f}).\mathsf{elem}|} \\ + &&&&\quad {\land}~\mathit{s}_{\mathit{new}} = \mathit{s}[\mathsf{elem} = ..\mathit{ei}] \\ + &&&&\quad {\land}~(\mathit{s}_{\mathit{res}},\, {{\mathit{ea}'}^\ast}) = \mathrm{alloc}_{\mathit{elem}}((\mathit{s}_{\mathit{new}} ; \mathit{f}),\, {{\mathit{elem}'}^\ast}) \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{alloc}_{\mathit{data}}((\mathit{s} ; \mathit{f}),\, \epsilon) &=& (\mathit{s},\, \epsilon) & \\ +\mathrm{alloc}_{\mathit{data}}((\mathit{s} ; \mathit{f}),\, \mathit{data}~{{\mathit{data}'}^\ast}) &=& (\mathit{s}_{\mathit{res}},\, \mathit{da}~{{\mathit{da}'}^\ast}) &\quad + \mbox{if}~\mathit{data} = \mathsf{data}~{\mathit{byte}^\ast}~{\mathit{datamode}^?} \\ + &&&&\quad {\land}~\mathit{di} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{data}~{\mathit{byte}^\ast} \}\end{array} \\ + &&&&\quad {\land}~\mathit{da} = {|(\mathit{s} ; \mathit{f}).\mathsf{data}|} \\ + &&&&\quad {\land}~\mathit{s}_{\mathit{new}} = \mathit{s}[\mathsf{data} = ..\mathit{di}] \\ + &&&&\quad {\land}~(\mathit{s}_{\mathit{res}},\, {{\mathit{da}'}^\ast}) = \mathrm{alloc}_{\mathit{data}}((\mathit{s}_{\mathit{new}} ; \mathit{f}),\, {{\mathit{data}'}^\ast}) \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{replace}_{\mathit{moduleinst}}(\mathit{s},\, \epsilon,\, \mathit{m}) &=& \mathit{s} & \\ +\mathrm{replace}_{\mathit{moduleinst}}(\mathit{s},\, \mathit{fa}~{{\mathit{fa}'}^\ast},\, \mathit{m}) &=& \mathit{s}_{\mathit{res}} &\quad + \mbox{if}~\mathit{s}_{\mathit{new}} = \mathit{s}[\mathsf{func}[\mathit{fa}].\mathsf{module} = \mathit{m}] \\ + &&&&\quad {\land}~\mathit{s}_{\mathit{res}} = \mathrm{replace}_{\mathit{moduleinst}}(\mathit{s}_{\mathit{new}},\, {{\mathit{fa}'}^\ast},\, \mathit{m}) \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{alloc}_{\mathit{export}}(\mathit{m},\, \mathit{export}) &=& \mathit{xi} &\quad + \mbox{if}~\mathit{export} = \mathsf{export}~\mathit{name}~\mathit{externuse} \\ + &&&&\quad {\land}~\mathit{externuse} = \mathsf{func}~\mathit{x} \\ + &&&&\quad {\land}~\mathit{externval} = \mathsf{func}~\mathit{m}.\mathsf{func}[\mathit{x}] \\ + &&&&\quad {\land}~\mathit{xi} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{name}~\mathit{name},\; \mathsf{value}~\mathit{externval} \}\end{array} \\ +\mathrm{alloc}_{\mathit{export}}(\mathit{m},\, \mathit{export}) &=& \mathit{xi} &\quad + \mbox{if}~\mathit{export} = \mathsf{export}~\mathit{name}~\mathit{externuse} \\ + &&&&\quad {\land}~\mathit{externuse} = \mathsf{global}~\mathit{x} \\ + &&&&\quad {\land}~\mathit{externval} = \mathsf{global}~\mathit{m}.\mathsf{global}[\mathit{x}] \\ + &&&&\quad {\land}~\mathit{xi} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{name}~\mathit{name},\; \mathsf{value}~\mathit{externval} \}\end{array} \\ +\mathrm{alloc}_{\mathit{export}}(\mathit{m},\, \mathit{export}) &=& \mathit{xi} &\quad + \mbox{if}~\mathit{export} = \mathsf{export}~\mathit{name}~\mathit{externuse} \\ + &&&&\quad {\land}~\mathit{externuse} = \mathsf{table}~\mathit{x} \\ + &&&&\quad {\land}~\mathit{externval} = \mathsf{table}~\mathit{m}.\mathsf{table}[\mathit{x}] \\ + &&&&\quad {\land}~\mathit{xi} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{name}~\mathit{name},\; \mathsf{value}~\mathit{externval} \}\end{array} \\ +\mathrm{alloc}_{\mathit{export}}(\mathit{m},\, \mathit{export}) &=& \mathit{xi} &\quad + \mbox{if}~\mathit{export} = \mathsf{export}~\mathit{name}~\mathit{externuse} \\ + &&&&\quad {\land}~\mathit{externuse} = \mathsf{mem}~\mathit{x} \\ + &&&&\quad {\land}~\mathit{externval} = \mathsf{mem}~\mathit{m}.\mathsf{mem}[\mathit{x}] \\ + &&&&\quad {\land}~\mathit{xi} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{name}~\mathit{name},\; \mathsf{value}~\mathit{externval} \}\end{array} \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{alloc}_{\mathit{module}}(\mathit{s},\, \mathit{module},\, {\mathit{externval}^\ast}) &=& (\mathit{s}_{\mathit{res}},\, \mathit{m}_{\mathit{res}}) &\quad + \mbox{if}~\mathit{module} = \mathsf{module}~{\mathit{import}^\ast}~{\mathit{func}^\ast}~{\mathit{global}^\ast}~{\mathit{table}^\ast}~{\mathit{mem}^\ast}~{\mathit{elem}^\ast}~{\mathit{data}^\ast}~{\mathit{start}^?}~{\mathit{export}^\ast} \\ + &&&&\quad {\land}~\mathit{m}_{\mathit{init}} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{func}~\epsilon,\; \mathsf{global}~\epsilon,\; \mathsf{table}~\epsilon,\; \mathsf{mem}~\epsilon,\; \mathsf{elem}~\epsilon,\; \mathsf{data}~\epsilon,\; \mathsf{export}~\epsilon \}\end{array} \\ + &&&&\quad {\land}~\mathit{m}_{\mathit{im}} = \mathrm{alloc}_{\mathit{import}}(\mathit{m}_{\mathit{init}},\, {\mathit{import}^\ast},\, {\mathit{externval}^\ast}) \\ + &&&&\quad {\land}~\mathit{f} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{local}~\epsilon,\; \mathsf{module}~\mathit{m}_{\mathit{im}} \}\end{array} \\ + &&&&\quad {\land}~(\mathit{s}_{\mathit{func}},\, {\mathit{fa}^\ast}) = \mathrm{alloc}_{\mathit{func}}((\mathit{s} ; \mathit{f}),\, {\mathit{func}^\ast}) \\ + &&&&\quad {\land}~(\mathit{s}_{\mathit{global}},\, {\mathit{ga}^\ast}) = \mathrm{alloc}_{\mathit{global}}((\mathit{s}_{\mathit{func}} ; \mathit{f}),\, {\mathit{global}^\ast}) \\ + &&&&\quad {\land}~(\mathit{s}_{\mathit{table}},\, {\mathit{ta}^\ast}) = \mathrm{alloc}_{\mathit{table}}((\mathit{s}_{\mathit{global}} ; \mathit{f}),\, {\mathit{table}^\ast}) \\ + &&&&\quad {\land}~(\mathit{s}_{\mathit{mem}},\, {\mathit{ma}^\ast}) = \mathrm{alloc}_{\mathit{mem}}((\mathit{s}_{\mathit{table}} ; \mathit{f}),\, {\mathit{mem}^\ast}) \\ + &&&&\quad {\land}~(\mathit{s}_{\mathit{elem}},\, {\mathit{ea}^\ast}) = \mathrm{alloc}_{\mathit{elem}}((\mathit{s}_{\mathit{mem}} ; \mathit{f}),\, {\mathit{elem}^\ast}) \\ + &&&&\quad {\land}~(\mathit{s}_{\mathit{data}},\, {\mathit{da}^\ast}) = \mathrm{alloc}_{\mathit{data}}((\mathit{s}_{\mathit{elem}} ; \mathit{f}),\, {\mathit{data}^\ast}) \\ + &&&&\quad {\land}~\mathit{m}_{\mathit{ex}} = \mathit{m}_{\mathit{im}} \oplus \{ \begin{array}[t]{@{}l@{}} +\mathsf{func}~{\mathit{fa}^\ast},\; \mathsf{global}~{\mathit{ga}^\ast},\; \mathsf{table}~{\mathit{ta}^\ast},\; \mathsf{mem}~{\mathit{ma}^\ast},\; \mathsf{elem}~{\mathit{ea}^\ast},\; \mathsf{data}~{\mathit{da}^\ast},\; \mathsf{export}~\epsilon \}\end{array} \\ + &&&&\quad {\land}~{\mathit{xi}^\ast} = {\mathrm{alloc}_{\mathit{export}}(\mathit{m}_{\mathit{ex}},\, \mathit{export})^\ast} \\ + &&&&\quad {\land}~\mathit{m}_{\mathit{res}} = \mathit{m}_{\mathit{ex}}[\mathsf{export} = {\mathit{xi}^\ast}] \\ + &&&&\quad {\land}~\mathit{s}_{\mathit{res}} = \mathrm{replace}_{\mathit{moduleinst}}(\mathit{s}_{\mathit{data}},\, {\mathit{fa}^\ast},\, \mathit{m}_{\mathit{res}}) \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{run}_{\mathit{elem}}((\mathit{s} ; \mathit{f}),\, \epsilon,\, \mathit{i}) &=& \mathit{s} ; \mathit{f} & \\ +\mathrm{run}_{\mathit{elem}}((\mathit{s} ; \mathit{f}),\, \mathit{elem}~{{\mathit{elem}'}^\ast},\, \mathit{i}) &=& \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} &\quad + \mbox{if}~\mathit{elem} = \mathsf{elem}~\mathit{reftype}~{\mathit{expr}^\ast} \\ + &&&&\quad {\land}~\mathrm{run}_{\mathit{elem}}((\mathit{s} ; \mathit{f}),\, {{\mathit{elem}'}^\ast},\, \mathit{i} + 1) = \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} \\ +\mathrm{run}_{\mathit{elem}}((\mathit{s} ; \mathit{f}),\, \mathit{elem}~{{\mathit{elem}'}^\ast},\, \mathit{i}) &=& \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} &\quad + \mbox{if}~\mathit{elem} = \mathsf{elem}~\mathit{reftype}~{\mathit{expr}^\ast}~\mathit{elemmode} \\ + &&&&\quad {\land}~\mathit{n} = {|{\mathit{expr}^\ast}|} \\ + &&&&\quad {\land}~\mathit{elemmode} = \mathsf{table}~\mathit{x}~{\mathit{instr}^\ast} \\ + &&&&\quad {\land}~\mathit{s} ; \mathit{f} ; {\mathit{instr}^\ast}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~0)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.init}~\mathit{x}~\mathit{i})~(\mathsf{elem.drop}~\mathit{i}) \hookrightarrow \mathit{s}_{\mathit{new}} ; \mathit{f}_{\mathit{new}} ; \epsilon \\ + &&&&\quad {\land}~\mathrm{run}_{\mathit{elem}}((\mathit{s}_{\mathit{new}} ; \mathit{f}_{\mathit{new}}),\, {{\mathit{elem}'}^\ast},\, \mathit{i} + 1) = \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} \\ +\mathrm{run}_{\mathit{elem}}((\mathit{s} ; \mathit{f}),\, \mathit{elem}~{{\mathit{elem}'}^\ast},\, \mathit{i}) &=& \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} &\quad + \mbox{if}~\mathit{elem} = \mathsf{elem}~\mathit{reftype}~{\mathit{expr}^\ast}~\mathit{elemmode} \\ + &&&&\quad {\land}~\mathit{elemmode} = \mathsf{declare} \\ + &&&&\quad {\land}~\mathit{s} ; \mathit{f} ; (\mathsf{elem.drop}~\mathit{i}) \hookrightarrow \mathit{s}_{\mathit{new}} ; \mathit{f}_{\mathit{new}} ; \epsilon \\ + &&&&\quad {\land}~\mathrm{run}_{\mathit{elem}}((\mathit{s}_{\mathit{new}} ; \mathit{f}_{\mathit{new}}),\, {{\mathit{elem}'}^\ast},\, \mathit{i} + 1) = \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{run}_{\mathit{data}}((\mathit{s} ; \mathit{f}),\, \epsilon,\, \mathit{i}) &=& \mathit{s} ; \mathit{f} & \\ +\mathrm{run}_{\mathit{data}}((\mathit{s} ; \mathit{f}),\, \mathit{data}~{{\mathit{data}'}^\ast},\, \mathit{i}) &=& \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} &\quad + \mbox{if}~\mathit{data} = \mathsf{data}~{\mathit{byte}^\ast} \\ + &&&&\quad {\land}~\mathrm{run}_{\mathit{data}}((\mathit{s} ; \mathit{f}),\, {{\mathit{data}'}^\ast},\, \mathit{i} + 1) = \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} \\ +\mathrm{run}_{\mathit{data}}((\mathit{s} ; \mathit{f}),\, \mathit{data}~{{\mathit{data}'}^\ast},\, \mathit{i}) &=& \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} &\quad + \mbox{if}~\mathit{data} = \mathsf{data}~{\mathit{byte}^\ast}~\mathit{datamode} \\ + &&&&\quad {\land}~\mathit{n} = {|{\mathit{byte}^\ast}|} \\ + &&&&\quad {\land}~\mathit{datamode} = \mathsf{memory}~0~{\mathit{instr}^\ast} \\ + &&&&\quad {\land}~\mathit{s} ; \mathit{f} ; {\mathit{instr}^\ast}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~0)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.init}~\mathit{i})~(\mathsf{data.drop}~\mathit{i}) \hookrightarrow \mathit{s}_{\mathit{new}} ; \mathit{f}_{\mathit{new}} ; \epsilon \\ + &&&&\quad {\land}~\mathrm{run}_{\mathit{data}}((\mathit{s}_{\mathit{new}} ; \mathit{f}_{\mathit{new}}),\, {{\mathit{data}'}^\ast},\, \mathit{i} + 1) = \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{instantiation}(\mathit{s},\, \mathit{module},\, {\mathit{externval}^\ast}) &=& (\mathit{s}_{\mathit{res}},\, \mathit{m}) &\quad + \mbox{if}~\mathit{module} = \mathsf{module}~{\mathit{import}^\ast}~{\mathit{func}^\ast}~{\mathit{global}^\ast}~{\mathit{table}^\ast}~{\mathit{mem}^\ast}~{\mathit{elem}^\ast}~{\mathit{data}^\ast}~{\mathit{export}^\ast} \\ + &&&&\quad {\land}~(\mathit{s}_{\mathit{alloc}},\, \mathit{m}) = \mathrm{alloc}_{\mathit{module}}(\mathit{s},\, \mathit{module},\, {\mathit{externval}^\ast}) \\ + &&&&\quad {\land}~\mathit{f} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{local}~\epsilon,\; \mathsf{module}~\mathit{m} \}\end{array} \\ + &&&&\quad {\land}~\mathrm{run}_{\mathit{elem}}((\mathit{s}_{\mathit{alloc}} ; \mathit{f}_{\mathit{alloc}}),\, {\mathit{elem}^\ast},\, 0) = \mathit{s}_{\mathit{elem}} ; \mathit{f}_{\mathit{elem}} \\ + &&&&\quad {\land}~\mathrm{run}_{\mathit{data}}((\mathit{s}_{\mathit{elem}} ; \mathit{f}_{\mathit{elem}}),\, {\mathit{data}^\ast},\, 0) = \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} \\ +\mathrm{instantiation}(\mathit{s},\, \mathit{module},\, {\mathit{externval}^\ast}) &=& (\mathit{s}_{\mathit{res}},\, \mathit{m}) &\quad + \mbox{if}~\mathit{module} = \mathsf{module}~{\mathit{import}^\ast}~{\mathit{func}^\ast}~{\mathit{global}^\ast}~{\mathit{table}^\ast}~{\mathit{mem}^\ast}~{\mathit{elem}^\ast}~{\mathit{data}^\ast}~\mathit{start}~{\mathit{export}^\ast} \\ + &&&&\quad {\land}~(\mathit{s}_{\mathit{alloc}},\, \mathit{m}) = \mathrm{alloc}_{\mathit{module}}(\mathit{s},\, \mathit{module},\, {\mathit{externval}^\ast}) \\ + &&&&\quad {\land}~\mathit{f} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{local}~\epsilon,\; \mathsf{module}~\mathit{m} \}\end{array} \\ + &&&&\quad {\land}~\mathrm{run}_{\mathit{elem}}((\mathit{s}_{\mathit{alloc}} ; \mathit{f}_{\mathit{alloc}}),\, {\mathit{elem}^\ast},\, 0) = \mathit{s}_{\mathit{elem}} ; \mathit{f}_{\mathit{elem}} \\ + &&&&\quad {\land}~\mathrm{run}_{\mathit{data}}((\mathit{s}_{\mathit{elem}} ; \mathit{f}_{\mathit{elem}}),\, {\mathit{data}^\ast},\, 0) = \mathit{s}_{\mathit{data}} ; \mathit{f}_{\mathit{data}} \\ + &&&&\quad {\land}~\mathit{start} = \mathsf{start}~\mathit{x} \\ + &&&&\quad {\land}~\mathit{s}_{\mathit{data}} ; \mathit{f}_{\mathit{data}} ; (\mathsf{call}~\mathit{x}) \hookrightarrow \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} ; \epsilon \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{invocation}(\mathit{s},\, \mathit{fa},\, {\mathit{val}^\ast}) &=& ({\mathit{s}'},\, {{\mathit{val}'}^\ast}) &\quad + \mbox{if}~\mathit{m} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{func}~\epsilon,\; \mathsf{global}~\epsilon,\; \mathsf{table}~\epsilon,\; \mathsf{mem}~\epsilon,\; \mathsf{elem}~\epsilon,\; \mathsf{data}~\epsilon,\; \mathsf{export}~\epsilon \}\end{array} \\ + &&&&\quad {\land}~\mathit{f} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{local}~\epsilon,\; \mathsf{module}~\mathit{m} \}\end{array} \\ + &&&&\quad {\land}~(\mathit{s} ; \mathit{f}).\mathsf{func}[\mathit{fa}].\mathsf{code} = \mathsf{func}~\mathit{functype}~{\mathit{valtype}^\ast}~\mathit{expr} \\ + &&&&\quad {\land}~\mathit{functype} = {\mathit{valtype}^\ast} \rightarrow {{\mathit{valtype}'}^\ast} \\ + &&&&\quad {\land}~{|{\mathit{val}^\ast}|} = {|{\mathit{valtype}^\ast}|} \\ + &&&&\quad {\land}~{|{{\mathit{val}'}^\ast}|} = {|{{\mathit{valtype}'}^\ast}|} \\ + &&&&\quad {\land}~\mathit{s} ; \mathit{f} ; {\mathit{val}^\ast}~(\mathsf{call}~\mathit{fa}) \hookrightarrow {\mathit{s}'} ; {\mathit{f}'} ; {{\mathit{val}'}^\ast} \\ +\end{array} +$$ + == Complete. ``` diff --git a/spectec/test-latex/TEST.md b/spectec/test-latex/TEST.md index 14c2a410b7..d9848c8a48 100644 --- a/spectec/test-latex/TEST.md +++ b/spectec/test-latex/TEST.md @@ -250,19 +250,38 @@ warning: rule `Tabletype_sub` was never spliced warning: rule `Valtype_sub/refl` was never spliced warning: rule `Valtype_sub/bot` was never spliced warning: definition `Ki` was never spliced +warning: definition `alloc_data` was never spliced +warning: definition `alloc_elem` was never spliced +warning: definition `alloc_export` was never spliced +warning: definition `alloc_func` was never spliced +warning: definition `alloc_global` was never spliced +warning: definition `alloc_import` was never spliced +warning: definition `alloc_mem` was never spliced +warning: definition `alloc_module` was never spliced +warning: definition `alloc_table` was never spliced warning: definition `binop` was never spliced warning: definition `bytes_` was never spliced warning: definition `cvtop` was never spliced warning: definition `data` was never spliced +warning: definition `datainst` was never spliced warning: definition `elem` was never spliced +warning: definition `eleminst` was never spliced warning: definition `ext` was never spliced warning: definition `global` was never spliced +warning: definition `globalinst` was never spliced warning: definition `grow_memory` was never spliced warning: definition `grow_table` was never spliced +warning: definition `instantiation` was never spliced +warning: definition `invocation` was never spliced warning: definition `local` was never spliced warning: definition `mem` was never spliced +warning: definition `meminst` was never spliced warning: definition `min` was never spliced warning: definition `relop` was never spliced +warning: definition `replace_moduleinst` was never spliced +warning: definition `run_data` was never spliced +warning: definition `run_elem` was never spliced +warning: definition `tableinst` was never spliced warning: definition `testop` was never spliced warning: definition `unop` was never spliced warning: definition `with_data` was never spliced diff --git a/spectec/test-middlend/TEST.md b/spectec/test-middlend/TEST.md index 706bfa0ea8..89ed831ebf 100644 --- a/spectec/test-middlend/TEST.md +++ b/spectec/test-middlend/TEST.md @@ -296,8 +296,8 @@ syntax mem = MEMORY(memtype) ;; 1-syntax.watsup:198.1-199.31 syntax elem = `ELEM%%*%?`(reftype, expr*, elemmode?) -;; 1-syntax.watsup:200.1-201.26 -syntax data = `DATA(*)%*%?`(byte**, datamode?) +;; 1-syntax.watsup:200.1-201.23 +syntax data = `DATA%*%?`(byte*, datamode?) ;; 1-syntax.watsup:202.1-203.16 syntax start = START(funcidx) @@ -885,8 +885,8 @@ relation Datamode_ok: `%|-%:OK`(context, datamode) ;; 3-typing.watsup:402.1-402.73 relation Data_ok: `%|-%:OK`(context, data) ;; 3-typing.watsup:433.1-435.40 - rule _ {C : context, b** : byte**, datamode? : datamode?}: - `%|-%:OK`(C, `DATA(*)%*%?`(b*{b}*{b}, datamode?{datamode})) + rule _ {C : context, b* : byte*, datamode? : datamode?}: + `%|-%:OK`(C, `DATA%*%?`(b*{b}, datamode?{datamode})) -- (Datamode_ok: `%|-%:OK`(C, datamode))?{datamode} ;; 3-typing.watsup:405.1-405.74 @@ -1051,10 +1051,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:169.1-176.5 +;; 4-runtime.watsup:180.1-187.5 rec { -;; 4-runtime.watsup:169.1-176.5 +;; 4-runtime.watsup:180.1-187.5 syntax admininstr = | UNREACHABLE | NOP @@ -1118,104 +1118,129 @@ def funcaddr : state -> funcaddr* ;; 4-runtime.watsup:118.1-118.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:119.1-119.31 + ;; 4-runtime.watsup:125.1-125.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:121.1-121.67 +;; 4-runtime.watsup:119.1-119.58 +def globalinst : state -> globalinst* + ;; 4-runtime.watsup:126.1-126.35 + def {f : frame, s : store} globalinst(`%;%`(s, f)) = s.GLOBAL_store + +;; 4-runtime.watsup:120.1-120.55 +def tableinst : state -> tableinst* + ;; 4-runtime.watsup:127.1-127.33 + def {f : frame, s : store} tableinst(`%;%`(s, f)) = s.TABLE_store + +;; 4-runtime.watsup:121.1-121.49 +def meminst : state -> meminst* + ;; 4-runtime.watsup:128.1-128.29 + def {f : frame, s : store} meminst(`%;%`(s, f)) = s.MEM_store + +;; 4-runtime.watsup:122.1-122.52 +def eleminst : state -> eleminst* + ;; 4-runtime.watsup:129.1-129.31 + def {f : frame, s : store} eleminst(`%;%`(s, f)) = s.ELEM_store + +;; 4-runtime.watsup:123.1-123.52 +def datainst : state -> datainst* + ;; 4-runtime.watsup:130.1-130.31 + def {f : frame, s : store} datainst(`%;%`(s, f)) = s.DATA_store + +;; 4-runtime.watsup:132.1-132.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:129.1-129.48 + ;; 4-runtime.watsup:140.1-140.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:122.1-122.69 +;; 4-runtime.watsup:133.1-133.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:130.1-130.54 + ;; 4-runtime.watsup:141.1-141.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:123.1-123.68 +;; 4-runtime.watsup:134.1-134.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:131.1-131.51 + ;; 4-runtime.watsup:142.1-142.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:124.1-124.66 +;; 4-runtime.watsup:135.1-135.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:132.1-132.45 + ;; 4-runtime.watsup:143.1-143.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:125.1-125.67 +;; 4-runtime.watsup:136.1-136.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:133.1-133.48 + ;; 4-runtime.watsup:144.1-144.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:126.1-126.67 +;; 4-runtime.watsup:137.1-137.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:134.1-134.48 + ;; 4-runtime.watsup:145.1-145.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:127.1-127.68 +;; 4-runtime.watsup:138.1-138.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:135.1-135.35 + ;; 4-runtime.watsup:146.1-146.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:138.1-138.78 +;; 4-runtime.watsup:149.1-149.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:147.1-147.52 + ;; 4-runtime.watsup:158.1-158.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:139.1-139.85 +;; 4-runtime.watsup:150.1-150.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:148.1-148.77 + ;; 4-runtime.watsup:159.1-159.77 def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:140.1-140.88 +;; 4-runtime.watsup:151.1-151.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:149.1-149.79 + ;; 4-runtime.watsup:160.1-160.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:141.1-141.84 +;; 4-runtime.watsup:152.1-152.84 def with_tableinst : (state, tableidx, tableinst) -> state - ;; 4-runtime.watsup:150.1-150.74 + ;; 4-runtime.watsup:161.1-161.74 def {f : frame, s : store, ti : tableinst, x : idx} with_tableinst(`%;%`(s, f), x, ti) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] = ti], f) -;; 4-runtime.watsup:142.1-142.93 +;; 4-runtime.watsup:153.1-153.93 def with_mem : (state, memidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:151.1-151.82 + ;; 4-runtime.watsup:162.1-162.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:143.1-143.77 +;; 4-runtime.watsup:154.1-154.77 def with_meminst : (state, memidx, meminst) -> state - ;; 4-runtime.watsup:152.1-152.68 + ;; 4-runtime.watsup:163.1-163.68 def {f : frame, mi : meminst, s : store, x : idx} with_meminst(`%;%`(s, f), x, mi) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] = mi], f) -;; 4-runtime.watsup:144.1-144.82 +;; 4-runtime.watsup:155.1-155.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:153.1-153.72 + ;; 4-runtime.watsup:164.1-164.72 def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:145.1-145.82 +;; 4-runtime.watsup:156.1-156.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:154.1-154.72 + ;; 4-runtime.watsup:165.1-165.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:156.1-156.49 +;; 4-runtime.watsup:167.1-167.49 def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:158.1-161.57 + ;; 4-runtime.watsup:169.1-172.57 def {i : nat, i' : nat, j? : nat?, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' -- if (ti = {TYPE `%%`(`[%..%?]`(i, j?{j}), reftype), ELEM r'*{r'}}) -- if (i' = (|r'*{r'}| + n)) -- if (ti' = {TYPE `%%`(`[%..%?]`(i', j?{j}), reftype), ELEM r'*{r'} :: r^n{}}) -;; 4-runtime.watsup:157.1-157.41 +;; 4-runtime.watsup:168.1-168.41 def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:162.1-165.66 + ;; 4-runtime.watsup:173.1-176.66 def {b* : byte*, i : nat, i' : nat, j? : nat?, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' -- if (mi = {TYPE `%I8`(`[%..%?]`(i, j?{j})), DATA b*{b}}) -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) -- if (mi' = {TYPE `%I8`(`[%..%?]`(i', j?{j})), DATA b*{b} :: 0^((n * 64) * $Ki){}}) -;; 4-runtime.watsup:178.1-181.21 +;; 4-runtime.watsup:189.1-192.21 rec { -;; 4-runtime.watsup:178.1-181.21 +;; 4-runtime.watsup:189.1-192.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -1657,6 +1682,278 @@ relation Step: `%~>%`(config, config) rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) +;; 7-module.watsup:3.1-3.64 +rec { + +;; 7-module.watsup:3.1-3.64 +def alloc_import : (moduleinst, import*, externval*) -> moduleinst + ;; 7-module.watsup:5.1-5.43 + def {m : moduleinst} alloc_import(m, [], []) = m + ;; 7-module.watsup:7.1-12.60 + def {externtype : externtype, externval : externval, externval'* : externval*, fa : funcaddr, functype : functype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = FUNC_externtype(functype)) + -- if (externval = FUNC_externval(fa)) + -- if (m_new = m[FUNC_moduleinst =.. [fa]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) + ;; 7-module.watsup:14.1-19.60 + def {externtype : externtype, externval : externval, externval'* : externval*, ga : globaladdr, globaltype : globaltype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = GLOBAL_externtype(globaltype)) + -- if (externval = GLOBAL_externval(ga)) + -- if (m_new = m[GLOBAL_moduleinst =.. [ga]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) + ;; 7-module.watsup:21.1-26.60 + def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name, ta : tableaddr, tabletype : tabletype} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = TABLE_externtype(tabletype)) + -- if (externval = TABLE_externval(ta)) + -- if (m_new = m[TABLE_moduleinst =.. [ta]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) + ;; 7-module.watsup:28.1-33.60 + def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, ma : memaddr, memtype : memtype, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = MEM_externtype(memtype)) + -- if (externval = MEM_externval(ma)) + -- if (m_new = m[MEM_moduleinst =.. [ma]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) +} + +;; 7-module.watsup:36.1-36.51 +rec { + +;; 7-module.watsup:36.1-36.51 +def alloc_func : (state, func*) -> (store, funcaddr*) + ;; 7-module.watsup:38.1-38.48 + def {f : frame, s : store} alloc_func(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:40.1-44.56 + def {f : frame, fa : funcaddr, fa'* : funcaddr*, fi : funcinst, func : func, func'* : func*, s : store, s_new : store, s_res : store} alloc_func(`%;%`(s, f), [func] :: func'*{func'}) = (s_res, [fa] :: fa'*{fa'}) + -- if (fi = {MODULE f.MODULE_frame, CODE func}) + -- if (fa = |$funcinst(`%;%`(s, f))|) + -- if (s_new = s[FUNC_store =.. [fi]]) + -- if ((s_res, fa'*{fa'}) = $alloc_func(`%;%`(s_new, f), func'*{func'})) +} + +;; 7-module.watsup:47.1-47.57 +rec { + +;; 7-module.watsup:47.1-47.57 +def alloc_global : (state, global*) -> (store, globaladdr*) + ;; 7-module.watsup:49.1-49.50 + def {f : frame, s : store} alloc_global(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:51.1-57.60 + def {f : frame, ga : globaladdr, ga'* : globaladdr*, gi : globalinst, global : global, global'* : global*, globaltype : globaltype, instr* : instr*, s : store, s_new : store, s_res : store, val : val} alloc_global(`%;%`(s, f), [global] :: global'*{global'}) = (s_res, [ga] :: ga'*{ga'}) + -- if (global = GLOBAL(globaltype, instr*{instr})) + -- Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), (instr <: admininstr)*{instr}), [(val <: admininstr)]) + -- if (gi = {TYPE globaltype, VALUE val}) + -- if (ga = |$globalinst(`%;%`(s, f))|) + -- if (s_new = s[GLOBAL_store =.. [gi]]) + -- if ((s_res, ga'*{ga'}) = $alloc_global(`%;%`(s_new, f), global'*{global'})) +} + +;; 7-module.watsup:60.1-60.54 +rec { + +;; 7-module.watsup:60.1-60.54 +def alloc_table : (state, table*) -> (store, tableaddr*) + ;; 7-module.watsup:62.1-62.49 + def {f : frame, s : store} alloc_table(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:64.1-70.58 + def {f : frame, i : nat, j? : nat?, reftype : reftype, s : store, s_new : store, s_res : store, ta : tableaddr, ta'* : tableaddr*, table : table, table'* : table*, tabletype : tabletype, ti : tableinst} alloc_table(`%;%`(s, f), [table] :: table'*{table'}) = (s_res, [ta] :: ta'*{ta'}) + -- if (table = TABLE(tabletype)) + -- if (tabletype = `%%`(`[%..%?]`(i, j?{j}), reftype)) + -- if (ti = {TYPE tabletype, ELEM REF.NULL_ref(reftype)^i{}}) + -- if (ta = |$tableinst(`%;%`(s, f))|) + -- if (s_new = s[TABLE_store =.. [ti]]) + -- if ((s_res, ta'*{ta'}) = $alloc_table(`%;%`(s_new, f), table'*{table'})) +} + +;; 7-module.watsup:73.1-73.48 +rec { + +;; 7-module.watsup:73.1-73.48 +def alloc_mem : (state, mem*) -> (store, memaddr*) + ;; 7-module.watsup:75.1-75.47 + def {f : frame, s : store} alloc_mem(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:77.1-83.54 + def {f : frame, i : nat, j? : nat?, ma : memaddr, ma'* : memaddr*, mem : mem, mem'* : mem*, memtype : memtype, mi : meminst, s : store, s_new : store, s_res : store} alloc_mem(`%;%`(s, f), [mem] :: mem'*{mem'}) = (s_res, [ma] :: ma'*{ma'}) + -- if (mem = MEMORY(memtype)) + -- if (memtype = `%I8`(`[%..%?]`(i, j?{j}))) + -- if (mi = {TYPE memtype, DATA 0^((i * 64) * $Ki){}}) + -- if (ma = |$meminst(`%;%`(s, f))|) + -- if (s_new = s[MEM_store =.. [mi]]) + -- if ((s_res, ma'*{ma'}) = $alloc_mem(`%;%`(s_new, f), mem'*{mem'})) +} + +;; 7-module.watsup:86.1-86.51 +rec { + +;; 7-module.watsup:86.1-86.51 +def alloc_elem : (state, elem*) -> (store, elemaddr*) + ;; 7-module.watsup:88.1-88.48 + def {f : frame, s : store} alloc_elem(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:90.1-96.56 + def {ea : elemaddr, ea'* : elemaddr*, ei : eleminst, elem : elem, elem'* : elem*, elemmode? : elemmode?, f : frame, instr** : instr**, ref* : ref*, reftype : reftype, s : store, s_new : store, s_res : store} alloc_elem(`%;%`(s, f), [elem] :: elem'*{elem'}) = (s_res, [ea] :: ea'*{ea'}) + -- if (elem = `ELEM%%*%?`(reftype, instr*{instr}*{instr}, elemmode?{elemmode})) + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), (instr <: admininstr)*{instr}), [(ref <: admininstr)]))*{instr ref} + -- if (ei = {TYPE reftype, ELEM ref*{ref}}) + -- if (ea = |$eleminst(`%;%`(s, f))|) + -- if (s_new = s[ELEM_store =.. [ei]]) + -- if ((s_res, ea'*{ea'}) = $alloc_elem(`%;%`(s_new, f), elem'*{elem'})) +} + +;; 7-module.watsup:99.1-99.51 +rec { + +;; 7-module.watsup:99.1-99.51 +def alloc_data : (state, data*) -> (store, dataaddr*) + ;; 7-module.watsup:101.1-101.48 + def {f : frame, s : store} alloc_data(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:103.1-108.56 + def {byte* : byte*, da : dataaddr, da'* : dataaddr*, data : data, data'* : data*, datamode? : datamode?, di : datainst, f : frame, s : store, s_new : store, s_res : store} alloc_data(`%;%`(s, f), [data] :: data'*{data'}) = (s_res, [da] :: da'*{da'}) + -- if (data = `DATA%*%?`(byte*{byte}, datamode?{datamode})) + -- if (di = {DATA byte*{byte}}) + -- if (da = |$datainst(`%;%`(s, f))|) + -- if (s_new = s[DATA_store =.. [di]]) + -- if ((s_res, da'*{da'}) = $alloc_data(`%;%`(s_new, f), data'*{data'})) +} + +;; 7-module.watsup:111.1-111.62 +rec { + +;; 7-module.watsup:111.1-111.62 +def replace_moduleinst : (store, funcaddr*, moduleinst) -> store + ;; 7-module.watsup:113.1-113.43 + def {m : moduleinst, s : store} replace_moduleinst(s, [], m) = s + ;; 7-module.watsup:115.1-117.52 + def {fa : funcaddr, fa'* : funcaddr*, m : moduleinst, s : store, s_new : store, s_res : store} replace_moduleinst(s, [fa] :: fa'*{fa'}, m) = s_res + -- if (s_new = s[FUNC_store[fa].MODULE_funcinst = m]) + -- if (s_res = $replace_moduleinst(s_new, fa'*{fa'}, m)) +} + +;; 7-module.watsup:120.1-120.51 +def alloc_export : (moduleinst, export) -> exportinst + ;; 7-module.watsup:122.1-126.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = FUNC_externuse(x)) + -- if (externval = FUNC_externval(m.FUNC_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + ;; 7-module.watsup:128.1-132.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = GLOBAL_externuse(x)) + -- if (externval = GLOBAL_externval(m.GLOBAL_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + ;; 7-module.watsup:134.1-138.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = TABLE_externuse(x)) + -- if (externval = TABLE_externval(m.TABLE_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + ;; 7-module.watsup:140.1-144.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = MEM_externuse(x)) + -- if (externval = MEM_externval(m.MEM_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + +;; 7-module.watsup:147.1-147.67 +def alloc_module : (store, module, externval*) -> (store, moduleinst) + ;; 7-module.watsup:149.1-163.56 + def {da* : dataaddr*, data* : data*, ea* : elemaddr*, elem* : elem*, export* : export*, externval* : externval*, f : frame, fa* : funcaddr*, func* : func*, ga* : globaladdr*, global* : global*, import* : import*, m_ex : moduleinst, m_im : moduleinst, m_init : moduleinst, m_res : moduleinst, ma* : memaddr*, mem* : mem*, module : module, s : store, s_data : store, s_elem : store, s_func : store, s_global : store, s_mem : store, s_res : store, s_table : store, start? : start?, ta* : tableaddr*, table* : table*, xi* : exportinst*} alloc_module(s, module, externval*{externval}) = (s_res, m_res) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) + -- if (m_init = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (m_im = $alloc_import(m_init, import*{import}, externval*{externval})) + -- if (f = {LOCAL [], MODULE m_im}) + -- if ((s_func, fa*{fa}) = $alloc_func(`%;%`(s, f), func*{func})) + -- if ((s_global, ga*{ga}) = $alloc_global(`%;%`(s_func, f), global*{global})) + -- if ((s_table, ta*{ta}) = $alloc_table(`%;%`(s_global, f), table*{table})) + -- if ((s_mem, ma*{ma}) = $alloc_mem(`%;%`(s_table, f), mem*{mem})) + -- if ((s_elem, ea*{ea}) = $alloc_elem(`%;%`(s_mem, f), elem*{elem})) + -- if ((s_data, da*{da}) = $alloc_data(`%;%`(s_elem, f), data*{data})) + -- if (m_ex = m_im ++ {FUNC fa*{fa}, GLOBAL ga*{ga}, TABLE ta*{ta}, MEM ma*{ma}, ELEM ea*{ea}, DATA da*{da}, EXPORT []}) + -- if (xi*{xi} = $alloc_export(m_ex, export)*{export}) + -- if (m_res = m_ex[EXPORT_moduleinst = xi*{xi}]) + -- if (s_res = $replace_moduleinst(s_data, fa*{fa}, m_res)) + +;; 7-module.watsup:166.1-166.41 +rec { + +;; 7-module.watsup:166.1-166.41 +def run_elem : (state, elem*, idx) -> state + ;; 7-module.watsup:168.1-168.41 + def {f : frame, i : nat, s : store} run_elem(`%;%`(s, f), [], i) = `%;%`(s, f) + ;; 7-module.watsup:170.1-172.59 + def {elem : elem, elem'* : elem*, expr* : expr*, f : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) + -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?())) + -- if ($run_elem(`%;%`(s, f), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:174.1-179.67 + def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, reftype : reftype, s : store, s_new : store, s_res : store, x : idx} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) + -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) + -- if (n = |expr*{expr}|) + -- if (elemmode = TABLE_elemmode(x, instr*{instr})) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), (instr <: admininstr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, i) ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) + -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:181.1-185.67 + def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_new : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) + -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) + -- if (elemmode = DECLARE_elemmode) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), [ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) + -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) +} + +;; 7-module.watsup:188.1-188.41 +rec { + +;; 7-module.watsup:188.1-188.41 +def run_data : (state, data*, idx) -> state + ;; 7-module.watsup:190.1-190.41 + def {f : frame, i : nat, s : store} run_data(`%;%`(s, f), [], i) = `%;%`(s, f) + ;; 7-module.watsup:192.1-194.59 + def {byte* : byte*, data : data, data'* : data*, f : frame, f_res : frame, i : nat, s : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) + -- if (data = `DATA%*%?`(byte*{byte}, ?())) + -- if ($run_data(`%;%`(s, f), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:196.1-201.67 + def {byte* : byte*, data : data, data'* : data*, datamode : datamode, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, s : store, s_new : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) + -- if (data = `DATA%*%?`(byte*{byte}, ?(datamode))) + -- if (n = |byte*{byte}|) + -- if (datamode = MEMORY_datamode(0, instr*{instr})) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), (instr <: admininstr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(i) DATA.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) + -- if ($run_data(`%;%`(s_new, f_new), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) +} + +;; 7-module.watsup:206.1-206.68 +def instantiation : (store, module, externval*) -> (store, moduleinst) + ;; 7-module.watsup:208.1-213.61 + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(), export*{export})) + -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) + -- if (f = {LOCAL [], MODULE m}) + -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:215.1-222.62 + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(start), export*{export})) + -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) + -- if (f = {LOCAL [], MODULE m}) + -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_data, f_data)) + -- if (start = START(x)) + -- Step: `%~>%`(`%;%*`(`%;%`(s_data, f_data), [CALL_admininstr(x)]), `%;%*`(`%;%`(s_res, f_res), [])) + +;; 7-module.watsup:227.1-227.55 +def invocation : (store, funcaddr, val*) -> (store, val*) + ;; 7-module.watsup:229.1-236.55 + def {expr : expr, f : frame, f' : frame, fa : funcaddr, functype : functype, m : moduleinst, s : store, s' : store, val* : val*, val'* : val*, valtype* : valtype*, valtype'* : valtype*} invocation(s, fa, val*{val}) = (s', val'*{val'}) + -- if (m = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f = {LOCAL [], MODULE m}) + -- if ($funcinst(`%;%`(s, f))[fa].CODE_funcinst = `FUNC%%*%`(functype, valtype*{valtype}, expr)) + -- if (functype = `%->%`(valtype*{valtype}, valtype'*{valtype'})) + -- if (|val*{val}| = |valtype*{valtype}|) + -- if (|val'*{val'}| = |valtype'*{valtype'}|) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), (val <: admininstr)*{val} :: [CALL_ADDR_admininstr(fa)]), `%;%*`(`%;%`(s', f'), (val' <: admininstr)*{val'})) + == IL Validation... == Running pass sub @@ -1980,8 +2277,8 @@ syntax mem = MEMORY(memtype) ;; 1-syntax.watsup:198.1-199.31 syntax elem = `ELEM%%*%?`(reftype, expr*, elemmode?) -;; 1-syntax.watsup:200.1-201.26 -syntax data = `DATA(*)%*%?`(byte**, datamode?) +;; 1-syntax.watsup:200.1-201.23 +syntax data = `DATA%*%?`(byte*, datamode?) ;; 1-syntax.watsup:202.1-203.16 syntax start = START(funcidx) @@ -2569,8 +2866,8 @@ relation Datamode_ok: `%|-%:OK`(context, datamode) ;; 3-typing.watsup:402.1-402.73 relation Data_ok: `%|-%:OK`(context, data) ;; 3-typing.watsup:433.1-435.40 - rule _ {C : context, b** : byte**, datamode? : datamode?}: - `%|-%:OK`(C, `DATA(*)%*%?`(b*{b}*{b}, datamode?{datamode})) + rule _ {C : context, b* : byte*, datamode? : datamode?}: + `%|-%:OK`(C, `DATA%*%?`(b*{b}, datamode?{datamode})) -- (Datamode_ok: `%|-%:OK`(C, datamode))?{datamode} ;; 3-typing.watsup:405.1-405.74 @@ -2735,10 +3032,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:169.1-176.5 +;; 4-runtime.watsup:180.1-187.5 rec { -;; 4-runtime.watsup:169.1-176.5 +;; 4-runtime.watsup:180.1-187.5 syntax admininstr = | UNREACHABLE | NOP @@ -2859,104 +3156,129 @@ def funcaddr : state -> funcaddr* ;; 4-runtime.watsup:118.1-118.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:119.1-119.31 + ;; 4-runtime.watsup:125.1-125.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:121.1-121.67 +;; 4-runtime.watsup:119.1-119.58 +def globalinst : state -> globalinst* + ;; 4-runtime.watsup:126.1-126.35 + def {f : frame, s : store} globalinst(`%;%`(s, f)) = s.GLOBAL_store + +;; 4-runtime.watsup:120.1-120.55 +def tableinst : state -> tableinst* + ;; 4-runtime.watsup:127.1-127.33 + def {f : frame, s : store} tableinst(`%;%`(s, f)) = s.TABLE_store + +;; 4-runtime.watsup:121.1-121.49 +def meminst : state -> meminst* + ;; 4-runtime.watsup:128.1-128.29 + def {f : frame, s : store} meminst(`%;%`(s, f)) = s.MEM_store + +;; 4-runtime.watsup:122.1-122.52 +def eleminst : state -> eleminst* + ;; 4-runtime.watsup:129.1-129.31 + def {f : frame, s : store} eleminst(`%;%`(s, f)) = s.ELEM_store + +;; 4-runtime.watsup:123.1-123.52 +def datainst : state -> datainst* + ;; 4-runtime.watsup:130.1-130.31 + def {f : frame, s : store} datainst(`%;%`(s, f)) = s.DATA_store + +;; 4-runtime.watsup:132.1-132.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:129.1-129.48 + ;; 4-runtime.watsup:140.1-140.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:122.1-122.69 +;; 4-runtime.watsup:133.1-133.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:130.1-130.54 + ;; 4-runtime.watsup:141.1-141.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:123.1-123.68 +;; 4-runtime.watsup:134.1-134.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:131.1-131.51 + ;; 4-runtime.watsup:142.1-142.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:124.1-124.66 +;; 4-runtime.watsup:135.1-135.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:132.1-132.45 + ;; 4-runtime.watsup:143.1-143.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:125.1-125.67 +;; 4-runtime.watsup:136.1-136.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:133.1-133.48 + ;; 4-runtime.watsup:144.1-144.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:126.1-126.67 +;; 4-runtime.watsup:137.1-137.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:134.1-134.48 + ;; 4-runtime.watsup:145.1-145.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:127.1-127.68 +;; 4-runtime.watsup:138.1-138.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:135.1-135.35 + ;; 4-runtime.watsup:146.1-146.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:138.1-138.78 +;; 4-runtime.watsup:149.1-149.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:147.1-147.52 + ;; 4-runtime.watsup:158.1-158.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:139.1-139.85 +;; 4-runtime.watsup:150.1-150.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:148.1-148.77 + ;; 4-runtime.watsup:159.1-159.77 def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:140.1-140.88 +;; 4-runtime.watsup:151.1-151.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:149.1-149.79 + ;; 4-runtime.watsup:160.1-160.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:141.1-141.84 +;; 4-runtime.watsup:152.1-152.84 def with_tableinst : (state, tableidx, tableinst) -> state - ;; 4-runtime.watsup:150.1-150.74 + ;; 4-runtime.watsup:161.1-161.74 def {f : frame, s : store, ti : tableinst, x : idx} with_tableinst(`%;%`(s, f), x, ti) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] = ti], f) -;; 4-runtime.watsup:142.1-142.93 +;; 4-runtime.watsup:153.1-153.93 def with_mem : (state, memidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:151.1-151.82 + ;; 4-runtime.watsup:162.1-162.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:143.1-143.77 +;; 4-runtime.watsup:154.1-154.77 def with_meminst : (state, memidx, meminst) -> state - ;; 4-runtime.watsup:152.1-152.68 + ;; 4-runtime.watsup:163.1-163.68 def {f : frame, mi : meminst, s : store, x : idx} with_meminst(`%;%`(s, f), x, mi) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] = mi], f) -;; 4-runtime.watsup:144.1-144.82 +;; 4-runtime.watsup:155.1-155.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:153.1-153.72 + ;; 4-runtime.watsup:164.1-164.72 def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:145.1-145.82 +;; 4-runtime.watsup:156.1-156.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:154.1-154.72 + ;; 4-runtime.watsup:165.1-165.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:156.1-156.49 +;; 4-runtime.watsup:167.1-167.49 def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:158.1-161.57 + ;; 4-runtime.watsup:169.1-172.57 def {i : nat, i' : nat, j? : nat?, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' -- if (ti = {TYPE `%%`(`[%..%?]`(i, j?{j}), reftype), ELEM r'*{r'}}) -- if (i' = (|r'*{r'}| + n)) -- if (ti' = {TYPE `%%`(`[%..%?]`(i', j?{j}), reftype), ELEM r'*{r'} :: r^n{}}) -;; 4-runtime.watsup:157.1-157.41 +;; 4-runtime.watsup:168.1-168.41 def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:162.1-165.66 + ;; 4-runtime.watsup:173.1-176.66 def {b* : byte*, i : nat, i' : nat, j? : nat?, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' -- if (mi = {TYPE `%I8`(`[%..%?]`(i, j?{j})), DATA b*{b}}) -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) -- if (mi' = {TYPE `%I8`(`[%..%?]`(i', j?{j})), DATA b*{b} :: 0^((n * 64) * $Ki){}}) -;; 4-runtime.watsup:178.1-181.21 +;; 4-runtime.watsup:189.1-192.21 rec { -;; 4-runtime.watsup:178.1-181.21 +;; 4-runtime.watsup:189.1-192.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -3398,6 +3720,278 @@ relation Step: `%~>%`(config, config) rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) +;; 7-module.watsup:3.1-3.64 +rec { + +;; 7-module.watsup:3.1-3.64 +def alloc_import : (moduleinst, import*, externval*) -> moduleinst + ;; 7-module.watsup:5.1-5.43 + def {m : moduleinst} alloc_import(m, [], []) = m + ;; 7-module.watsup:7.1-12.60 + def {externtype : externtype, externval : externval, externval'* : externval*, fa : funcaddr, functype : functype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = FUNC_externtype(functype)) + -- if (externval = FUNC_externval(fa)) + -- if (m_new = m[FUNC_moduleinst =.. [fa]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) + ;; 7-module.watsup:14.1-19.60 + def {externtype : externtype, externval : externval, externval'* : externval*, ga : globaladdr, globaltype : globaltype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = GLOBAL_externtype(globaltype)) + -- if (externval = GLOBAL_externval(ga)) + -- if (m_new = m[GLOBAL_moduleinst =.. [ga]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) + ;; 7-module.watsup:21.1-26.60 + def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name, ta : tableaddr, tabletype : tabletype} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = TABLE_externtype(tabletype)) + -- if (externval = TABLE_externval(ta)) + -- if (m_new = m[TABLE_moduleinst =.. [ta]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) + ;; 7-module.watsup:28.1-33.60 + def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, ma : memaddr, memtype : memtype, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = MEM_externtype(memtype)) + -- if (externval = MEM_externval(ma)) + -- if (m_new = m[MEM_moduleinst =.. [ma]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) +} + +;; 7-module.watsup:36.1-36.51 +rec { + +;; 7-module.watsup:36.1-36.51 +def alloc_func : (state, func*) -> (store, funcaddr*) + ;; 7-module.watsup:38.1-38.48 + def {f : frame, s : store} alloc_func(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:40.1-44.56 + def {f : frame, fa : funcaddr, fa'* : funcaddr*, fi : funcinst, func : func, func'* : func*, s : store, s_new : store, s_res : store} alloc_func(`%;%`(s, f), [func] :: func'*{func'}) = (s_res, [fa] :: fa'*{fa'}) + -- if (fi = {MODULE f.MODULE_frame, CODE func}) + -- if (fa = |$funcinst(`%;%`(s, f))|) + -- if (s_new = s[FUNC_store =.. [fi]]) + -- if ((s_res, fa'*{fa'}) = $alloc_func(`%;%`(s_new, f), func'*{func'})) +} + +;; 7-module.watsup:47.1-47.57 +rec { + +;; 7-module.watsup:47.1-47.57 +def alloc_global : (state, global*) -> (store, globaladdr*) + ;; 7-module.watsup:49.1-49.50 + def {f : frame, s : store} alloc_global(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:51.1-57.60 + def {f : frame, ga : globaladdr, ga'* : globaladdr*, gi : globalinst, global : global, global'* : global*, globaltype : globaltype, instr* : instr*, s : store, s_new : store, s_res : store, val : val} alloc_global(`%;%`(s, f), [global] :: global'*{global'}) = (s_res, [ga] :: ga'*{ga'}) + -- if (global = GLOBAL(globaltype, instr*{instr})) + -- Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr}), [$admininstr_val(val)]) + -- if (gi = {TYPE globaltype, VALUE val}) + -- if (ga = |$globalinst(`%;%`(s, f))|) + -- if (s_new = s[GLOBAL_store =.. [gi]]) + -- if ((s_res, ga'*{ga'}) = $alloc_global(`%;%`(s_new, f), global'*{global'})) +} + +;; 7-module.watsup:60.1-60.54 +rec { + +;; 7-module.watsup:60.1-60.54 +def alloc_table : (state, table*) -> (store, tableaddr*) + ;; 7-module.watsup:62.1-62.49 + def {f : frame, s : store} alloc_table(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:64.1-70.58 + def {f : frame, i : nat, j? : nat?, reftype : reftype, s : store, s_new : store, s_res : store, ta : tableaddr, ta'* : tableaddr*, table : table, table'* : table*, tabletype : tabletype, ti : tableinst} alloc_table(`%;%`(s, f), [table] :: table'*{table'}) = (s_res, [ta] :: ta'*{ta'}) + -- if (table = TABLE(tabletype)) + -- if (tabletype = `%%`(`[%..%?]`(i, j?{j}), reftype)) + -- if (ti = {TYPE tabletype, ELEM REF.NULL_ref(reftype)^i{}}) + -- if (ta = |$tableinst(`%;%`(s, f))|) + -- if (s_new = s[TABLE_store =.. [ti]]) + -- if ((s_res, ta'*{ta'}) = $alloc_table(`%;%`(s_new, f), table'*{table'})) +} + +;; 7-module.watsup:73.1-73.48 +rec { + +;; 7-module.watsup:73.1-73.48 +def alloc_mem : (state, mem*) -> (store, memaddr*) + ;; 7-module.watsup:75.1-75.47 + def {f : frame, s : store} alloc_mem(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:77.1-83.54 + def {f : frame, i : nat, j? : nat?, ma : memaddr, ma'* : memaddr*, mem : mem, mem'* : mem*, memtype : memtype, mi : meminst, s : store, s_new : store, s_res : store} alloc_mem(`%;%`(s, f), [mem] :: mem'*{mem'}) = (s_res, [ma] :: ma'*{ma'}) + -- if (mem = MEMORY(memtype)) + -- if (memtype = `%I8`(`[%..%?]`(i, j?{j}))) + -- if (mi = {TYPE memtype, DATA 0^((i * 64) * $Ki){}}) + -- if (ma = |$meminst(`%;%`(s, f))|) + -- if (s_new = s[MEM_store =.. [mi]]) + -- if ((s_res, ma'*{ma'}) = $alloc_mem(`%;%`(s_new, f), mem'*{mem'})) +} + +;; 7-module.watsup:86.1-86.51 +rec { + +;; 7-module.watsup:86.1-86.51 +def alloc_elem : (state, elem*) -> (store, elemaddr*) + ;; 7-module.watsup:88.1-88.48 + def {f : frame, s : store} alloc_elem(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:90.1-96.56 + def {ea : elemaddr, ea'* : elemaddr*, ei : eleminst, elem : elem, elem'* : elem*, elemmode? : elemmode?, f : frame, instr** : instr**, ref* : ref*, reftype : reftype, s : store, s_new : store, s_res : store} alloc_elem(`%;%`(s, f), [elem] :: elem'*{elem'}) = (s_res, [ea] :: ea'*{ea'}) + -- if (elem = `ELEM%%*%?`(reftype, instr*{instr}*{instr}, elemmode?{elemmode})) + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr}), [$admininstr_ref(ref)]))*{instr ref} + -- if (ei = {TYPE reftype, ELEM ref*{ref}}) + -- if (ea = |$eleminst(`%;%`(s, f))|) + -- if (s_new = s[ELEM_store =.. [ei]]) + -- if ((s_res, ea'*{ea'}) = $alloc_elem(`%;%`(s_new, f), elem'*{elem'})) +} + +;; 7-module.watsup:99.1-99.51 +rec { + +;; 7-module.watsup:99.1-99.51 +def alloc_data : (state, data*) -> (store, dataaddr*) + ;; 7-module.watsup:101.1-101.48 + def {f : frame, s : store} alloc_data(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:103.1-108.56 + def {byte* : byte*, da : dataaddr, da'* : dataaddr*, data : data, data'* : data*, datamode? : datamode?, di : datainst, f : frame, s : store, s_new : store, s_res : store} alloc_data(`%;%`(s, f), [data] :: data'*{data'}) = (s_res, [da] :: da'*{da'}) + -- if (data = `DATA%*%?`(byte*{byte}, datamode?{datamode})) + -- if (di = {DATA byte*{byte}}) + -- if (da = |$datainst(`%;%`(s, f))|) + -- if (s_new = s[DATA_store =.. [di]]) + -- if ((s_res, da'*{da'}) = $alloc_data(`%;%`(s_new, f), data'*{data'})) +} + +;; 7-module.watsup:111.1-111.62 +rec { + +;; 7-module.watsup:111.1-111.62 +def replace_moduleinst : (store, funcaddr*, moduleinst) -> store + ;; 7-module.watsup:113.1-113.43 + def {m : moduleinst, s : store} replace_moduleinst(s, [], m) = s + ;; 7-module.watsup:115.1-117.52 + def {fa : funcaddr, fa'* : funcaddr*, m : moduleinst, s : store, s_new : store, s_res : store} replace_moduleinst(s, [fa] :: fa'*{fa'}, m) = s_res + -- if (s_new = s[FUNC_store[fa].MODULE_funcinst = m]) + -- if (s_res = $replace_moduleinst(s_new, fa'*{fa'}, m)) +} + +;; 7-module.watsup:120.1-120.51 +def alloc_export : (moduleinst, export) -> exportinst + ;; 7-module.watsup:122.1-126.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = FUNC_externuse(x)) + -- if (externval = FUNC_externval(m.FUNC_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + ;; 7-module.watsup:128.1-132.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = GLOBAL_externuse(x)) + -- if (externval = GLOBAL_externval(m.GLOBAL_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + ;; 7-module.watsup:134.1-138.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = TABLE_externuse(x)) + -- if (externval = TABLE_externval(m.TABLE_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + ;; 7-module.watsup:140.1-144.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = MEM_externuse(x)) + -- if (externval = MEM_externval(m.MEM_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + +;; 7-module.watsup:147.1-147.67 +def alloc_module : (store, module, externval*) -> (store, moduleinst) + ;; 7-module.watsup:149.1-163.56 + def {da* : dataaddr*, data* : data*, ea* : elemaddr*, elem* : elem*, export* : export*, externval* : externval*, f : frame, fa* : funcaddr*, func* : func*, ga* : globaladdr*, global* : global*, import* : import*, m_ex : moduleinst, m_im : moduleinst, m_init : moduleinst, m_res : moduleinst, ma* : memaddr*, mem* : mem*, module : module, s : store, s_data : store, s_elem : store, s_func : store, s_global : store, s_mem : store, s_res : store, s_table : store, start? : start?, ta* : tableaddr*, table* : table*, xi* : exportinst*} alloc_module(s, module, externval*{externval}) = (s_res, m_res) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) + -- if (m_init = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (m_im = $alloc_import(m_init, import*{import}, externval*{externval})) + -- if (f = {LOCAL [], MODULE m_im}) + -- if ((s_func, fa*{fa}) = $alloc_func(`%;%`(s, f), func*{func})) + -- if ((s_global, ga*{ga}) = $alloc_global(`%;%`(s_func, f), global*{global})) + -- if ((s_table, ta*{ta}) = $alloc_table(`%;%`(s_global, f), table*{table})) + -- if ((s_mem, ma*{ma}) = $alloc_mem(`%;%`(s_table, f), mem*{mem})) + -- if ((s_elem, ea*{ea}) = $alloc_elem(`%;%`(s_mem, f), elem*{elem})) + -- if ((s_data, da*{da}) = $alloc_data(`%;%`(s_elem, f), data*{data})) + -- if (m_ex = m_im ++ {FUNC fa*{fa}, GLOBAL ga*{ga}, TABLE ta*{ta}, MEM ma*{ma}, ELEM ea*{ea}, DATA da*{da}, EXPORT []}) + -- if (xi*{xi} = $alloc_export(m_ex, export)*{export}) + -- if (m_res = m_ex[EXPORT_moduleinst = xi*{xi}]) + -- if (s_res = $replace_moduleinst(s_data, fa*{fa}, m_res)) + +;; 7-module.watsup:166.1-166.41 +rec { + +;; 7-module.watsup:166.1-166.41 +def run_elem : (state, elem*, idx) -> state + ;; 7-module.watsup:168.1-168.41 + def {f : frame, i : nat, s : store} run_elem(`%;%`(s, f), [], i) = `%;%`(s, f) + ;; 7-module.watsup:170.1-172.59 + def {elem : elem, elem'* : elem*, expr* : expr*, f : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) + -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?())) + -- if ($run_elem(`%;%`(s, f), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:174.1-179.67 + def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, reftype : reftype, s : store, s_new : store, s_res : store, x : idx} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) + -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) + -- if (n = |expr*{expr}|) + -- if (elemmode = TABLE_elemmode(x, instr*{instr})) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, i) ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) + -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:181.1-185.67 + def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_new : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) + -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) + -- if (elemmode = DECLARE_elemmode) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), [ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) + -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) +} + +;; 7-module.watsup:188.1-188.41 +rec { + +;; 7-module.watsup:188.1-188.41 +def run_data : (state, data*, idx) -> state + ;; 7-module.watsup:190.1-190.41 + def {f : frame, i : nat, s : store} run_data(`%;%`(s, f), [], i) = `%;%`(s, f) + ;; 7-module.watsup:192.1-194.59 + def {byte* : byte*, data : data, data'* : data*, f : frame, f_res : frame, i : nat, s : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) + -- if (data = `DATA%*%?`(byte*{byte}, ?())) + -- if ($run_data(`%;%`(s, f), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:196.1-201.67 + def {byte* : byte*, data : data, data'* : data*, datamode : datamode, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, s : store, s_new : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) + -- if (data = `DATA%*%?`(byte*{byte}, ?(datamode))) + -- if (n = |byte*{byte}|) + -- if (datamode = MEMORY_datamode(0, instr*{instr})) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(i) DATA.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) + -- if ($run_data(`%;%`(s_new, f_new), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) +} + +;; 7-module.watsup:206.1-206.68 +def instantiation : (store, module, externval*) -> (store, moduleinst) + ;; 7-module.watsup:208.1-213.61 + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(), export*{export})) + -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) + -- if (f = {LOCAL [], MODULE m}) + -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:215.1-222.62 + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(start), export*{export})) + -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) + -- if (f = {LOCAL [], MODULE m}) + -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_data, f_data)) + -- if (start = START(x)) + -- Step: `%~>%`(`%;%*`(`%;%`(s_data, f_data), [CALL_admininstr(x)]), `%;%*`(`%;%`(s_res, f_res), [])) + +;; 7-module.watsup:227.1-227.55 +def invocation : (store, funcaddr, val*) -> (store, val*) + ;; 7-module.watsup:229.1-236.55 + def {expr : expr, f : frame, f' : frame, fa : funcaddr, functype : functype, m : moduleinst, s : store, s' : store, val* : val*, val'* : val*, valtype* : valtype*, valtype'* : valtype*} invocation(s, fa, val*{val}) = (s', val'*{val'}) + -- if (m = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f = {LOCAL [], MODULE m}) + -- if ($funcinst(`%;%`(s, f))[fa].CODE_funcinst = `FUNC%%*%`(functype, valtype*{valtype}, expr)) + -- if (functype = `%->%`(valtype*{valtype}, valtype'*{valtype'})) + -- if (|val*{val}| = |valtype*{valtype}|) + -- if (|val'*{val'}| = |valtype'*{valtype'}|) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_val(val)*{val} :: [CALL_ADDR_admininstr(fa)]), `%;%*`(`%;%`(s', f'), $admininstr_val(val')*{val'})) + == IL Validation... == Running pass totalize @@ -3721,8 +4315,8 @@ syntax mem = MEMORY(memtype) ;; 1-syntax.watsup:198.1-199.31 syntax elem = `ELEM%%*%?`(reftype, expr*, elemmode?) -;; 1-syntax.watsup:200.1-201.26 -syntax data = `DATA(*)%*%?`(byte**, datamode?) +;; 1-syntax.watsup:200.1-201.23 +syntax data = `DATA%*%?`(byte*, datamode?) ;; 1-syntax.watsup:202.1-203.16 syntax start = START(funcidx) @@ -4311,8 +4905,8 @@ relation Datamode_ok: `%|-%:OK`(context, datamode) ;; 3-typing.watsup:402.1-402.73 relation Data_ok: `%|-%:OK`(context, data) ;; 3-typing.watsup:433.1-435.40 - rule _ {C : context, b** : byte**, datamode? : datamode?}: - `%|-%:OK`(C, `DATA(*)%*%?`(b*{b}*{b}, datamode?{datamode})) + rule _ {C : context, b* : byte*, datamode? : datamode?}: + `%|-%:OK`(C, `DATA%*%?`(b*{b}, datamode?{datamode})) -- (Datamode_ok: `%|-%:OK`(C, datamode))?{datamode} ;; 3-typing.watsup:405.1-405.74 @@ -4478,10 +5072,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:169.1-176.5 +;; 4-runtime.watsup:180.1-187.5 rec { -;; 4-runtime.watsup:169.1-176.5 +;; 4-runtime.watsup:180.1-187.5 syntax admininstr = | UNREACHABLE | NOP @@ -4602,104 +5196,129 @@ def funcaddr : state -> funcaddr* ;; 4-runtime.watsup:118.1-118.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:119.1-119.31 + ;; 4-runtime.watsup:125.1-125.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:121.1-121.67 +;; 4-runtime.watsup:119.1-119.58 +def globalinst : state -> globalinst* + ;; 4-runtime.watsup:126.1-126.35 + def {f : frame, s : store} globalinst(`%;%`(s, f)) = s.GLOBAL_store + +;; 4-runtime.watsup:120.1-120.55 +def tableinst : state -> tableinst* + ;; 4-runtime.watsup:127.1-127.33 + def {f : frame, s : store} tableinst(`%;%`(s, f)) = s.TABLE_store + +;; 4-runtime.watsup:121.1-121.49 +def meminst : state -> meminst* + ;; 4-runtime.watsup:128.1-128.29 + def {f : frame, s : store} meminst(`%;%`(s, f)) = s.MEM_store + +;; 4-runtime.watsup:122.1-122.52 +def eleminst : state -> eleminst* + ;; 4-runtime.watsup:129.1-129.31 + def {f : frame, s : store} eleminst(`%;%`(s, f)) = s.ELEM_store + +;; 4-runtime.watsup:123.1-123.52 +def datainst : state -> datainst* + ;; 4-runtime.watsup:130.1-130.31 + def {f : frame, s : store} datainst(`%;%`(s, f)) = s.DATA_store + +;; 4-runtime.watsup:132.1-132.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:129.1-129.48 + ;; 4-runtime.watsup:140.1-140.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:122.1-122.69 +;; 4-runtime.watsup:133.1-133.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:130.1-130.54 + ;; 4-runtime.watsup:141.1-141.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:123.1-123.68 +;; 4-runtime.watsup:134.1-134.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:131.1-131.51 + ;; 4-runtime.watsup:142.1-142.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:124.1-124.66 +;; 4-runtime.watsup:135.1-135.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:132.1-132.45 + ;; 4-runtime.watsup:143.1-143.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:125.1-125.67 +;; 4-runtime.watsup:136.1-136.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:133.1-133.48 + ;; 4-runtime.watsup:144.1-144.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:126.1-126.67 +;; 4-runtime.watsup:137.1-137.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:134.1-134.48 + ;; 4-runtime.watsup:145.1-145.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:127.1-127.68 +;; 4-runtime.watsup:138.1-138.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:135.1-135.35 + ;; 4-runtime.watsup:146.1-146.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:138.1-138.78 +;; 4-runtime.watsup:149.1-149.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:147.1-147.52 + ;; 4-runtime.watsup:158.1-158.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:139.1-139.85 +;; 4-runtime.watsup:150.1-150.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:148.1-148.77 + ;; 4-runtime.watsup:159.1-159.77 def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:140.1-140.88 +;; 4-runtime.watsup:151.1-151.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:149.1-149.79 + ;; 4-runtime.watsup:160.1-160.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:141.1-141.84 +;; 4-runtime.watsup:152.1-152.84 def with_tableinst : (state, tableidx, tableinst) -> state - ;; 4-runtime.watsup:150.1-150.74 + ;; 4-runtime.watsup:161.1-161.74 def {f : frame, s : store, ti : tableinst, x : idx} with_tableinst(`%;%`(s, f), x, ti) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] = ti], f) -;; 4-runtime.watsup:142.1-142.93 +;; 4-runtime.watsup:153.1-153.93 def with_mem : (state, memidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:151.1-151.82 + ;; 4-runtime.watsup:162.1-162.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:143.1-143.77 +;; 4-runtime.watsup:154.1-154.77 def with_meminst : (state, memidx, meminst) -> state - ;; 4-runtime.watsup:152.1-152.68 + ;; 4-runtime.watsup:163.1-163.68 def {f : frame, mi : meminst, s : store, x : idx} with_meminst(`%;%`(s, f), x, mi) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] = mi], f) -;; 4-runtime.watsup:144.1-144.82 +;; 4-runtime.watsup:155.1-155.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:153.1-153.72 + ;; 4-runtime.watsup:164.1-164.72 def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:145.1-145.82 +;; 4-runtime.watsup:156.1-156.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:154.1-154.72 + ;; 4-runtime.watsup:165.1-165.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:156.1-156.49 +;; 4-runtime.watsup:167.1-167.49 def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:158.1-161.57 + ;; 4-runtime.watsup:169.1-172.57 def {i : nat, i' : nat, j? : nat?, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' -- if (ti = {TYPE `%%`(`[%..%?]`(i, j?{j}), reftype), ELEM r'*{r'}}) -- if (i' = (|r'*{r'}| + n)) -- if (ti' = {TYPE `%%`(`[%..%?]`(i', j?{j}), reftype), ELEM r'*{r'} :: r^n{}}) -;; 4-runtime.watsup:157.1-157.41 +;; 4-runtime.watsup:168.1-168.41 def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:162.1-165.66 + ;; 4-runtime.watsup:173.1-176.66 def {b* : byte*, i : nat, i' : nat, j? : nat?, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' -- if (mi = {TYPE `%I8`(`[%..%?]`(i, j?{j})), DATA b*{b}}) -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) -- if (mi' = {TYPE `%I8`(`[%..%?]`(i', j?{j})), DATA b*{b} :: 0^((n * 64) * $Ki){}}) -;; 4-runtime.watsup:178.1-181.21 +;; 4-runtime.watsup:189.1-192.21 rec { -;; 4-runtime.watsup:178.1-181.21 +;; 4-runtime.watsup:189.1-192.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -5141,6 +5760,278 @@ relation Step: `%~>%`(config, config) rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) +;; 7-module.watsup:3.1-3.64 +rec { + +;; 7-module.watsup:3.1-3.64 +def alloc_import : (moduleinst, import*, externval*) -> moduleinst + ;; 7-module.watsup:5.1-5.43 + def {m : moduleinst} alloc_import(m, [], []) = m + ;; 7-module.watsup:7.1-12.60 + def {externtype : externtype, externval : externval, externval'* : externval*, fa : funcaddr, functype : functype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = FUNC_externtype(functype)) + -- if (externval = FUNC_externval(fa)) + -- if (m_new = m[FUNC_moduleinst =.. [fa]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) + ;; 7-module.watsup:14.1-19.60 + def {externtype : externtype, externval : externval, externval'* : externval*, ga : globaladdr, globaltype : globaltype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = GLOBAL_externtype(globaltype)) + -- if (externval = GLOBAL_externval(ga)) + -- if (m_new = m[GLOBAL_moduleinst =.. [ga]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) + ;; 7-module.watsup:21.1-26.60 + def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name, ta : tableaddr, tabletype : tabletype} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = TABLE_externtype(tabletype)) + -- if (externval = TABLE_externval(ta)) + -- if (m_new = m[TABLE_moduleinst =.. [ta]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) + ;; 7-module.watsup:28.1-33.60 + def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, ma : memaddr, memtype : memtype, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = MEM_externtype(memtype)) + -- if (externval = MEM_externval(ma)) + -- if (m_new = m[MEM_moduleinst =.. [ma]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) +} + +;; 7-module.watsup:36.1-36.51 +rec { + +;; 7-module.watsup:36.1-36.51 +def alloc_func : (state, func*) -> (store, funcaddr*) + ;; 7-module.watsup:38.1-38.48 + def {f : frame, s : store} alloc_func(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:40.1-44.56 + def {f : frame, fa : funcaddr, fa'* : funcaddr*, fi : funcinst, func : func, func'* : func*, s : store, s_new : store, s_res : store} alloc_func(`%;%`(s, f), [func] :: func'*{func'}) = (s_res, [fa] :: fa'*{fa'}) + -- if (fi = {MODULE f.MODULE_frame, CODE func}) + -- if (fa = |$funcinst(`%;%`(s, f))|) + -- if (s_new = s[FUNC_store =.. [fi]]) + -- if ((s_res, fa'*{fa'}) = $alloc_func(`%;%`(s_new, f), func'*{func'})) +} + +;; 7-module.watsup:47.1-47.57 +rec { + +;; 7-module.watsup:47.1-47.57 +def alloc_global : (state, global*) -> (store, globaladdr*) + ;; 7-module.watsup:49.1-49.50 + def {f : frame, s : store} alloc_global(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:51.1-57.60 + def {f : frame, ga : globaladdr, ga'* : globaladdr*, gi : globalinst, global : global, global'* : global*, globaltype : globaltype, instr* : instr*, s : store, s_new : store, s_res : store, val : val} alloc_global(`%;%`(s, f), [global] :: global'*{global'}) = (s_res, [ga] :: ga'*{ga'}) + -- if (global = GLOBAL(globaltype, instr*{instr})) + -- Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr}), [$admininstr_val(val)]) + -- if (gi = {TYPE globaltype, VALUE val}) + -- if (ga = |$globalinst(`%;%`(s, f))|) + -- if (s_new = s[GLOBAL_store =.. [gi]]) + -- if ((s_res, ga'*{ga'}) = $alloc_global(`%;%`(s_new, f), global'*{global'})) +} + +;; 7-module.watsup:60.1-60.54 +rec { + +;; 7-module.watsup:60.1-60.54 +def alloc_table : (state, table*) -> (store, tableaddr*) + ;; 7-module.watsup:62.1-62.49 + def {f : frame, s : store} alloc_table(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:64.1-70.58 + def {f : frame, i : nat, j? : nat?, reftype : reftype, s : store, s_new : store, s_res : store, ta : tableaddr, ta'* : tableaddr*, table : table, table'* : table*, tabletype : tabletype, ti : tableinst} alloc_table(`%;%`(s, f), [table] :: table'*{table'}) = (s_res, [ta] :: ta'*{ta'}) + -- if (table = TABLE(tabletype)) + -- if (tabletype = `%%`(`[%..%?]`(i, j?{j}), reftype)) + -- if (ti = {TYPE tabletype, ELEM REF.NULL_ref(reftype)^i{}}) + -- if (ta = |$tableinst(`%;%`(s, f))|) + -- if (s_new = s[TABLE_store =.. [ti]]) + -- if ((s_res, ta'*{ta'}) = $alloc_table(`%;%`(s_new, f), table'*{table'})) +} + +;; 7-module.watsup:73.1-73.48 +rec { + +;; 7-module.watsup:73.1-73.48 +def alloc_mem : (state, mem*) -> (store, memaddr*) + ;; 7-module.watsup:75.1-75.47 + def {f : frame, s : store} alloc_mem(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:77.1-83.54 + def {f : frame, i : nat, j? : nat?, ma : memaddr, ma'* : memaddr*, mem : mem, mem'* : mem*, memtype : memtype, mi : meminst, s : store, s_new : store, s_res : store} alloc_mem(`%;%`(s, f), [mem] :: mem'*{mem'}) = (s_res, [ma] :: ma'*{ma'}) + -- if (mem = MEMORY(memtype)) + -- if (memtype = `%I8`(`[%..%?]`(i, j?{j}))) + -- if (mi = {TYPE memtype, DATA 0^((i * 64) * $Ki){}}) + -- if (ma = |$meminst(`%;%`(s, f))|) + -- if (s_new = s[MEM_store =.. [mi]]) + -- if ((s_res, ma'*{ma'}) = $alloc_mem(`%;%`(s_new, f), mem'*{mem'})) +} + +;; 7-module.watsup:86.1-86.51 +rec { + +;; 7-module.watsup:86.1-86.51 +def alloc_elem : (state, elem*) -> (store, elemaddr*) + ;; 7-module.watsup:88.1-88.48 + def {f : frame, s : store} alloc_elem(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:90.1-96.56 + def {ea : elemaddr, ea'* : elemaddr*, ei : eleminst, elem : elem, elem'* : elem*, elemmode? : elemmode?, f : frame, instr** : instr**, ref* : ref*, reftype : reftype, s : store, s_new : store, s_res : store} alloc_elem(`%;%`(s, f), [elem] :: elem'*{elem'}) = (s_res, [ea] :: ea'*{ea'}) + -- if (elem = `ELEM%%*%?`(reftype, instr*{instr}*{instr}, elemmode?{elemmode})) + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr}), [$admininstr_ref(ref)]))*{instr ref} + -- if (ei = {TYPE reftype, ELEM ref*{ref}}) + -- if (ea = |$eleminst(`%;%`(s, f))|) + -- if (s_new = s[ELEM_store =.. [ei]]) + -- if ((s_res, ea'*{ea'}) = $alloc_elem(`%;%`(s_new, f), elem'*{elem'})) +} + +;; 7-module.watsup:99.1-99.51 +rec { + +;; 7-module.watsup:99.1-99.51 +def alloc_data : (state, data*) -> (store, dataaddr*) + ;; 7-module.watsup:101.1-101.48 + def {f : frame, s : store} alloc_data(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:103.1-108.56 + def {byte* : byte*, da : dataaddr, da'* : dataaddr*, data : data, data'* : data*, datamode? : datamode?, di : datainst, f : frame, s : store, s_new : store, s_res : store} alloc_data(`%;%`(s, f), [data] :: data'*{data'}) = (s_res, [da] :: da'*{da'}) + -- if (data = `DATA%*%?`(byte*{byte}, datamode?{datamode})) + -- if (di = {DATA byte*{byte}}) + -- if (da = |$datainst(`%;%`(s, f))|) + -- if (s_new = s[DATA_store =.. [di]]) + -- if ((s_res, da'*{da'}) = $alloc_data(`%;%`(s_new, f), data'*{data'})) +} + +;; 7-module.watsup:111.1-111.62 +rec { + +;; 7-module.watsup:111.1-111.62 +def replace_moduleinst : (store, funcaddr*, moduleinst) -> store + ;; 7-module.watsup:113.1-113.43 + def {m : moduleinst, s : store} replace_moduleinst(s, [], m) = s + ;; 7-module.watsup:115.1-117.52 + def {fa : funcaddr, fa'* : funcaddr*, m : moduleinst, s : store, s_new : store, s_res : store} replace_moduleinst(s, [fa] :: fa'*{fa'}, m) = s_res + -- if (s_new = s[FUNC_store[fa].MODULE_funcinst = m]) + -- if (s_res = $replace_moduleinst(s_new, fa'*{fa'}, m)) +} + +;; 7-module.watsup:120.1-120.51 +def alloc_export : (moduleinst, export) -> exportinst + ;; 7-module.watsup:122.1-126.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = FUNC_externuse(x)) + -- if (externval = FUNC_externval(m.FUNC_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + ;; 7-module.watsup:128.1-132.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = GLOBAL_externuse(x)) + -- if (externval = GLOBAL_externval(m.GLOBAL_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + ;; 7-module.watsup:134.1-138.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = TABLE_externuse(x)) + -- if (externval = TABLE_externval(m.TABLE_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + ;; 7-module.watsup:140.1-144.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = MEM_externuse(x)) + -- if (externval = MEM_externval(m.MEM_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + +;; 7-module.watsup:147.1-147.67 +def alloc_module : (store, module, externval*) -> (store, moduleinst) + ;; 7-module.watsup:149.1-163.56 + def {da* : dataaddr*, data* : data*, ea* : elemaddr*, elem* : elem*, export* : export*, externval* : externval*, f : frame, fa* : funcaddr*, func* : func*, ga* : globaladdr*, global* : global*, import* : import*, m_ex : moduleinst, m_im : moduleinst, m_init : moduleinst, m_res : moduleinst, ma* : memaddr*, mem* : mem*, module : module, s : store, s_data : store, s_elem : store, s_func : store, s_global : store, s_mem : store, s_res : store, s_table : store, start? : start?, ta* : tableaddr*, table* : table*, xi* : exportinst*} alloc_module(s, module, externval*{externval}) = (s_res, m_res) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) + -- if (m_init = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (m_im = $alloc_import(m_init, import*{import}, externval*{externval})) + -- if (f = {LOCAL [], MODULE m_im}) + -- if ((s_func, fa*{fa}) = $alloc_func(`%;%`(s, f), func*{func})) + -- if ((s_global, ga*{ga}) = $alloc_global(`%;%`(s_func, f), global*{global})) + -- if ((s_table, ta*{ta}) = $alloc_table(`%;%`(s_global, f), table*{table})) + -- if ((s_mem, ma*{ma}) = $alloc_mem(`%;%`(s_table, f), mem*{mem})) + -- if ((s_elem, ea*{ea}) = $alloc_elem(`%;%`(s_mem, f), elem*{elem})) + -- if ((s_data, da*{da}) = $alloc_data(`%;%`(s_elem, f), data*{data})) + -- if (m_ex = m_im ++ {FUNC fa*{fa}, GLOBAL ga*{ga}, TABLE ta*{ta}, MEM ma*{ma}, ELEM ea*{ea}, DATA da*{da}, EXPORT []}) + -- if (xi*{xi} = $alloc_export(m_ex, export)*{export}) + -- if (m_res = m_ex[EXPORT_moduleinst = xi*{xi}]) + -- if (s_res = $replace_moduleinst(s_data, fa*{fa}, m_res)) + +;; 7-module.watsup:166.1-166.41 +rec { + +;; 7-module.watsup:166.1-166.41 +def run_elem : (state, elem*, idx) -> state + ;; 7-module.watsup:168.1-168.41 + def {f : frame, i : nat, s : store} run_elem(`%;%`(s, f), [], i) = `%;%`(s, f) + ;; 7-module.watsup:170.1-172.59 + def {elem : elem, elem'* : elem*, expr* : expr*, f : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) + -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?())) + -- if ($run_elem(`%;%`(s, f), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:174.1-179.67 + def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, reftype : reftype, s : store, s_new : store, s_res : store, x : idx} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) + -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) + -- if (n = |expr*{expr}|) + -- if (elemmode = TABLE_elemmode(x, instr*{instr})) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, i) ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) + -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:181.1-185.67 + def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_new : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) + -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) + -- if (elemmode = DECLARE_elemmode) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), [ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) + -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) +} + +;; 7-module.watsup:188.1-188.41 +rec { + +;; 7-module.watsup:188.1-188.41 +def run_data : (state, data*, idx) -> state + ;; 7-module.watsup:190.1-190.41 + def {f : frame, i : nat, s : store} run_data(`%;%`(s, f), [], i) = `%;%`(s, f) + ;; 7-module.watsup:192.1-194.59 + def {byte* : byte*, data : data, data'* : data*, f : frame, f_res : frame, i : nat, s : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) + -- if (data = `DATA%*%?`(byte*{byte}, ?())) + -- if ($run_data(`%;%`(s, f), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:196.1-201.67 + def {byte* : byte*, data : data, data'* : data*, datamode : datamode, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, s : store, s_new : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) + -- if (data = `DATA%*%?`(byte*{byte}, ?(datamode))) + -- if (n = |byte*{byte}|) + -- if (datamode = MEMORY_datamode(0, instr*{instr})) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(i) DATA.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) + -- if ($run_data(`%;%`(s_new, f_new), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) +} + +;; 7-module.watsup:206.1-206.68 +def instantiation : (store, module, externval*) -> (store, moduleinst) + ;; 7-module.watsup:208.1-213.61 + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(), export*{export})) + -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) + -- if (f = {LOCAL [], MODULE m}) + -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:215.1-222.62 + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(start), export*{export})) + -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) + -- if (f = {LOCAL [], MODULE m}) + -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_data, f_data)) + -- if (start = START(x)) + -- Step: `%~>%`(`%;%*`(`%;%`(s_data, f_data), [CALL_admininstr(x)]), `%;%*`(`%;%`(s_res, f_res), [])) + +;; 7-module.watsup:227.1-227.55 +def invocation : (store, funcaddr, val*) -> (store, val*) + ;; 7-module.watsup:229.1-236.55 + def {expr : expr, f : frame, f' : frame, fa : funcaddr, functype : functype, m : moduleinst, s : store, s' : store, val* : val*, val'* : val*, valtype* : valtype*, valtype'* : valtype*} invocation(s, fa, val*{val}) = (s', val'*{val'}) + -- if (m = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f = {LOCAL [], MODULE m}) + -- if ($funcinst(`%;%`(s, f))[fa].CODE_funcinst = `FUNC%%*%`(functype, valtype*{valtype}, expr)) + -- if (functype = `%->%`(valtype*{valtype}, valtype'*{valtype'})) + -- if (|val*{val}| = |valtype*{valtype}|) + -- if (|val'*{val'}| = |valtype'*{valtype'}|) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_val(val)*{val} :: [CALL_ADDR_admininstr(fa)]), `%;%*`(`%;%`(s', f'), $admininstr_val(val')*{val'})) + == IL Validation... == Running pass the-elimination @@ -5464,8 +6355,8 @@ syntax mem = MEMORY(memtype) ;; 1-syntax.watsup:198.1-199.31 syntax elem = `ELEM%%*%?`(reftype, expr*, elemmode?) -;; 1-syntax.watsup:200.1-201.26 -syntax data = `DATA(*)%*%?`(byte**, datamode?) +;; 1-syntax.watsup:200.1-201.23 +syntax data = `DATA%*%?`(byte*, datamode?) ;; 1-syntax.watsup:202.1-203.16 syntax start = START(funcidx) @@ -6063,8 +6954,8 @@ relation Datamode_ok: `%|-%:OK`(context, datamode) ;; 3-typing.watsup:402.1-402.73 relation Data_ok: `%|-%:OK`(context, data) ;; 3-typing.watsup:433.1-435.40 - rule _ {C : context, b** : byte**, datamode? : datamode?}: - `%|-%:OK`(C, `DATA(*)%*%?`(b*{b}*{b}, datamode?{datamode})) + rule _ {C : context, b* : byte*, datamode? : datamode?}: + `%|-%:OK`(C, `DATA%*%?`(b*{b}, datamode?{datamode})) -- (Datamode_ok: `%|-%:OK`(C, datamode))?{datamode} ;; 3-typing.watsup:405.1-405.74 @@ -6230,10 +7121,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:169.1-176.5 +;; 4-runtime.watsup:180.1-187.5 rec { -;; 4-runtime.watsup:169.1-176.5 +;; 4-runtime.watsup:180.1-187.5 syntax admininstr = | UNREACHABLE | NOP @@ -6354,104 +7245,129 @@ def funcaddr : state -> funcaddr* ;; 4-runtime.watsup:118.1-118.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:119.1-119.31 + ;; 4-runtime.watsup:125.1-125.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:121.1-121.67 +;; 4-runtime.watsup:119.1-119.58 +def globalinst : state -> globalinst* + ;; 4-runtime.watsup:126.1-126.35 + def {f : frame, s : store} globalinst(`%;%`(s, f)) = s.GLOBAL_store + +;; 4-runtime.watsup:120.1-120.55 +def tableinst : state -> tableinst* + ;; 4-runtime.watsup:127.1-127.33 + def {f : frame, s : store} tableinst(`%;%`(s, f)) = s.TABLE_store + +;; 4-runtime.watsup:121.1-121.49 +def meminst : state -> meminst* + ;; 4-runtime.watsup:128.1-128.29 + def {f : frame, s : store} meminst(`%;%`(s, f)) = s.MEM_store + +;; 4-runtime.watsup:122.1-122.52 +def eleminst : state -> eleminst* + ;; 4-runtime.watsup:129.1-129.31 + def {f : frame, s : store} eleminst(`%;%`(s, f)) = s.ELEM_store + +;; 4-runtime.watsup:123.1-123.52 +def datainst : state -> datainst* + ;; 4-runtime.watsup:130.1-130.31 + def {f : frame, s : store} datainst(`%;%`(s, f)) = s.DATA_store + +;; 4-runtime.watsup:132.1-132.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:129.1-129.48 + ;; 4-runtime.watsup:140.1-140.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:122.1-122.69 +;; 4-runtime.watsup:133.1-133.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:130.1-130.54 + ;; 4-runtime.watsup:141.1-141.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:123.1-123.68 +;; 4-runtime.watsup:134.1-134.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:131.1-131.51 + ;; 4-runtime.watsup:142.1-142.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:124.1-124.66 +;; 4-runtime.watsup:135.1-135.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:132.1-132.45 + ;; 4-runtime.watsup:143.1-143.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:125.1-125.67 +;; 4-runtime.watsup:136.1-136.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:133.1-133.48 + ;; 4-runtime.watsup:144.1-144.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:126.1-126.67 +;; 4-runtime.watsup:137.1-137.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:134.1-134.48 + ;; 4-runtime.watsup:145.1-145.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:127.1-127.68 +;; 4-runtime.watsup:138.1-138.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:135.1-135.35 + ;; 4-runtime.watsup:146.1-146.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:138.1-138.78 +;; 4-runtime.watsup:149.1-149.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:147.1-147.52 + ;; 4-runtime.watsup:158.1-158.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:139.1-139.85 +;; 4-runtime.watsup:150.1-150.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:148.1-148.77 + ;; 4-runtime.watsup:159.1-159.77 def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:140.1-140.88 +;; 4-runtime.watsup:151.1-151.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:149.1-149.79 + ;; 4-runtime.watsup:160.1-160.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:141.1-141.84 +;; 4-runtime.watsup:152.1-152.84 def with_tableinst : (state, tableidx, tableinst) -> state - ;; 4-runtime.watsup:150.1-150.74 + ;; 4-runtime.watsup:161.1-161.74 def {f : frame, s : store, ti : tableinst, x : idx} with_tableinst(`%;%`(s, f), x, ti) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] = ti], f) -;; 4-runtime.watsup:142.1-142.93 +;; 4-runtime.watsup:153.1-153.93 def with_mem : (state, memidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:151.1-151.82 + ;; 4-runtime.watsup:162.1-162.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:143.1-143.77 +;; 4-runtime.watsup:154.1-154.77 def with_meminst : (state, memidx, meminst) -> state - ;; 4-runtime.watsup:152.1-152.68 + ;; 4-runtime.watsup:163.1-163.68 def {f : frame, mi : meminst, s : store, x : idx} with_meminst(`%;%`(s, f), x, mi) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] = mi], f) -;; 4-runtime.watsup:144.1-144.82 +;; 4-runtime.watsup:155.1-155.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:153.1-153.72 + ;; 4-runtime.watsup:164.1-164.72 def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:145.1-145.82 +;; 4-runtime.watsup:156.1-156.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:154.1-154.72 + ;; 4-runtime.watsup:165.1-165.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:156.1-156.49 +;; 4-runtime.watsup:167.1-167.49 def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:158.1-161.57 + ;; 4-runtime.watsup:169.1-172.57 def {i : nat, i' : nat, j? : nat?, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' -- if (ti = {TYPE `%%`(`[%..%?]`(i, j?{j}), reftype), ELEM r'*{r'}}) -- if (i' = (|r'*{r'}| + n)) -- if (ti' = {TYPE `%%`(`[%..%?]`(i', j?{j}), reftype), ELEM r'*{r'} :: r^n{}}) -;; 4-runtime.watsup:157.1-157.41 +;; 4-runtime.watsup:168.1-168.41 def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:162.1-165.66 + ;; 4-runtime.watsup:173.1-176.66 def {b* : byte*, i : nat, i' : nat, j? : nat?, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' -- if (mi = {TYPE `%I8`(`[%..%?]`(i, j?{j})), DATA b*{b}}) -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) -- if (mi' = {TYPE `%I8`(`[%..%?]`(i', j?{j})), DATA b*{b} :: 0^((n * 64) * $Ki){}}) -;; 4-runtime.watsup:178.1-181.21 +;; 4-runtime.watsup:189.1-192.21 rec { -;; 4-runtime.watsup:178.1-181.21 +;; 4-runtime.watsup:189.1-192.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -6903,6 +7819,278 @@ relation Step: `%~>%`(config, config) rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) +;; 7-module.watsup:3.1-3.64 +rec { + +;; 7-module.watsup:3.1-3.64 +def alloc_import : (moduleinst, import*, externval*) -> moduleinst + ;; 7-module.watsup:5.1-5.43 + def {m : moduleinst} alloc_import(m, [], []) = m + ;; 7-module.watsup:7.1-12.60 + def {externtype : externtype, externval : externval, externval'* : externval*, fa : funcaddr, functype : functype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = FUNC_externtype(functype)) + -- if (externval = FUNC_externval(fa)) + -- if (m_new = m[FUNC_moduleinst =.. [fa]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) + ;; 7-module.watsup:14.1-19.60 + def {externtype : externtype, externval : externval, externval'* : externval*, ga : globaladdr, globaltype : globaltype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = GLOBAL_externtype(globaltype)) + -- if (externval = GLOBAL_externval(ga)) + -- if (m_new = m[GLOBAL_moduleinst =.. [ga]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) + ;; 7-module.watsup:21.1-26.60 + def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name, ta : tableaddr, tabletype : tabletype} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = TABLE_externtype(tabletype)) + -- if (externval = TABLE_externval(ta)) + -- if (m_new = m[TABLE_moduleinst =.. [ta]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) + ;; 7-module.watsup:28.1-33.60 + def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, ma : memaddr, memtype : memtype, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = MEM_externtype(memtype)) + -- if (externval = MEM_externval(ma)) + -- if (m_new = m[MEM_moduleinst =.. [ma]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) +} + +;; 7-module.watsup:36.1-36.51 +rec { + +;; 7-module.watsup:36.1-36.51 +def alloc_func : (state, func*) -> (store, funcaddr*) + ;; 7-module.watsup:38.1-38.48 + def {f : frame, s : store} alloc_func(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:40.1-44.56 + def {f : frame, fa : funcaddr, fa'* : funcaddr*, fi : funcinst, func : func, func'* : func*, s : store, s_new : store, s_res : store} alloc_func(`%;%`(s, f), [func] :: func'*{func'}) = (s_res, [fa] :: fa'*{fa'}) + -- if (fi = {MODULE f.MODULE_frame, CODE func}) + -- if (fa = |$funcinst(`%;%`(s, f))|) + -- if (s_new = s[FUNC_store =.. [fi]]) + -- if ((s_res, fa'*{fa'}) = $alloc_func(`%;%`(s_new, f), func'*{func'})) +} + +;; 7-module.watsup:47.1-47.57 +rec { + +;; 7-module.watsup:47.1-47.57 +def alloc_global : (state, global*) -> (store, globaladdr*) + ;; 7-module.watsup:49.1-49.50 + def {f : frame, s : store} alloc_global(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:51.1-57.60 + def {f : frame, ga : globaladdr, ga'* : globaladdr*, gi : globalinst, global : global, global'* : global*, globaltype : globaltype, instr* : instr*, s : store, s_new : store, s_res : store, val : val} alloc_global(`%;%`(s, f), [global] :: global'*{global'}) = (s_res, [ga] :: ga'*{ga'}) + -- if (global = GLOBAL(globaltype, instr*{instr})) + -- Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr}), [$admininstr_val(val)]) + -- if (gi = {TYPE globaltype, VALUE val}) + -- if (ga = |$globalinst(`%;%`(s, f))|) + -- if (s_new = s[GLOBAL_store =.. [gi]]) + -- if ((s_res, ga'*{ga'}) = $alloc_global(`%;%`(s_new, f), global'*{global'})) +} + +;; 7-module.watsup:60.1-60.54 +rec { + +;; 7-module.watsup:60.1-60.54 +def alloc_table : (state, table*) -> (store, tableaddr*) + ;; 7-module.watsup:62.1-62.49 + def {f : frame, s : store} alloc_table(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:64.1-70.58 + def {f : frame, i : nat, j? : nat?, reftype : reftype, s : store, s_new : store, s_res : store, ta : tableaddr, ta'* : tableaddr*, table : table, table'* : table*, tabletype : tabletype, ti : tableinst} alloc_table(`%;%`(s, f), [table] :: table'*{table'}) = (s_res, [ta] :: ta'*{ta'}) + -- if (table = TABLE(tabletype)) + -- if (tabletype = `%%`(`[%..%?]`(i, j?{j}), reftype)) + -- if (ti = {TYPE tabletype, ELEM REF.NULL_ref(reftype)^i{}}) + -- if (ta = |$tableinst(`%;%`(s, f))|) + -- if (s_new = s[TABLE_store =.. [ti]]) + -- if ((s_res, ta'*{ta'}) = $alloc_table(`%;%`(s_new, f), table'*{table'})) +} + +;; 7-module.watsup:73.1-73.48 +rec { + +;; 7-module.watsup:73.1-73.48 +def alloc_mem : (state, mem*) -> (store, memaddr*) + ;; 7-module.watsup:75.1-75.47 + def {f : frame, s : store} alloc_mem(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:77.1-83.54 + def {f : frame, i : nat, j? : nat?, ma : memaddr, ma'* : memaddr*, mem : mem, mem'* : mem*, memtype : memtype, mi : meminst, s : store, s_new : store, s_res : store} alloc_mem(`%;%`(s, f), [mem] :: mem'*{mem'}) = (s_res, [ma] :: ma'*{ma'}) + -- if (mem = MEMORY(memtype)) + -- if (memtype = `%I8`(`[%..%?]`(i, j?{j}))) + -- if (mi = {TYPE memtype, DATA 0^((i * 64) * $Ki){}}) + -- if (ma = |$meminst(`%;%`(s, f))|) + -- if (s_new = s[MEM_store =.. [mi]]) + -- if ((s_res, ma'*{ma'}) = $alloc_mem(`%;%`(s_new, f), mem'*{mem'})) +} + +;; 7-module.watsup:86.1-86.51 +rec { + +;; 7-module.watsup:86.1-86.51 +def alloc_elem : (state, elem*) -> (store, elemaddr*) + ;; 7-module.watsup:88.1-88.48 + def {f : frame, s : store} alloc_elem(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:90.1-96.56 + def {ea : elemaddr, ea'* : elemaddr*, ei : eleminst, elem : elem, elem'* : elem*, elemmode? : elemmode?, f : frame, instr** : instr**, ref* : ref*, reftype : reftype, s : store, s_new : store, s_res : store} alloc_elem(`%;%`(s, f), [elem] :: elem'*{elem'}) = (s_res, [ea] :: ea'*{ea'}) + -- if (elem = `ELEM%%*%?`(reftype, instr*{instr}*{instr}, elemmode?{elemmode})) + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr}), [$admininstr_ref(ref)]))*{instr ref} + -- if (ei = {TYPE reftype, ELEM ref*{ref}}) + -- if (ea = |$eleminst(`%;%`(s, f))|) + -- if (s_new = s[ELEM_store =.. [ei]]) + -- if ((s_res, ea'*{ea'}) = $alloc_elem(`%;%`(s_new, f), elem'*{elem'})) +} + +;; 7-module.watsup:99.1-99.51 +rec { + +;; 7-module.watsup:99.1-99.51 +def alloc_data : (state, data*) -> (store, dataaddr*) + ;; 7-module.watsup:101.1-101.48 + def {f : frame, s : store} alloc_data(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:103.1-108.56 + def {byte* : byte*, da : dataaddr, da'* : dataaddr*, data : data, data'* : data*, datamode? : datamode?, di : datainst, f : frame, s : store, s_new : store, s_res : store} alloc_data(`%;%`(s, f), [data] :: data'*{data'}) = (s_res, [da] :: da'*{da'}) + -- if (data = `DATA%*%?`(byte*{byte}, datamode?{datamode})) + -- if (di = {DATA byte*{byte}}) + -- if (da = |$datainst(`%;%`(s, f))|) + -- if (s_new = s[DATA_store =.. [di]]) + -- if ((s_res, da'*{da'}) = $alloc_data(`%;%`(s_new, f), data'*{data'})) +} + +;; 7-module.watsup:111.1-111.62 +rec { + +;; 7-module.watsup:111.1-111.62 +def replace_moduleinst : (store, funcaddr*, moduleinst) -> store + ;; 7-module.watsup:113.1-113.43 + def {m : moduleinst, s : store} replace_moduleinst(s, [], m) = s + ;; 7-module.watsup:115.1-117.52 + def {fa : funcaddr, fa'* : funcaddr*, m : moduleinst, s : store, s_new : store, s_res : store} replace_moduleinst(s, [fa] :: fa'*{fa'}, m) = s_res + -- if (s_new = s[FUNC_store[fa].MODULE_funcinst = m]) + -- if (s_res = $replace_moduleinst(s_new, fa'*{fa'}, m)) +} + +;; 7-module.watsup:120.1-120.51 +def alloc_export : (moduleinst, export) -> exportinst + ;; 7-module.watsup:122.1-126.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = FUNC_externuse(x)) + -- if (externval = FUNC_externval(m.FUNC_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + ;; 7-module.watsup:128.1-132.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = GLOBAL_externuse(x)) + -- if (externval = GLOBAL_externval(m.GLOBAL_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + ;; 7-module.watsup:134.1-138.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = TABLE_externuse(x)) + -- if (externval = TABLE_externval(m.TABLE_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + ;; 7-module.watsup:140.1-144.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = MEM_externuse(x)) + -- if (externval = MEM_externval(m.MEM_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + +;; 7-module.watsup:147.1-147.67 +def alloc_module : (store, module, externval*) -> (store, moduleinst) + ;; 7-module.watsup:149.1-163.56 + def {da* : dataaddr*, data* : data*, ea* : elemaddr*, elem* : elem*, export* : export*, externval* : externval*, f : frame, fa* : funcaddr*, func* : func*, ga* : globaladdr*, global* : global*, import* : import*, m_ex : moduleinst, m_im : moduleinst, m_init : moduleinst, m_res : moduleinst, ma* : memaddr*, mem* : mem*, module : module, s : store, s_data : store, s_elem : store, s_func : store, s_global : store, s_mem : store, s_res : store, s_table : store, start? : start?, ta* : tableaddr*, table* : table*, xi* : exportinst*} alloc_module(s, module, externval*{externval}) = (s_res, m_res) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) + -- if (m_init = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (m_im = $alloc_import(m_init, import*{import}, externval*{externval})) + -- if (f = {LOCAL [], MODULE m_im}) + -- if ((s_func, fa*{fa}) = $alloc_func(`%;%`(s, f), func*{func})) + -- if ((s_global, ga*{ga}) = $alloc_global(`%;%`(s_func, f), global*{global})) + -- if ((s_table, ta*{ta}) = $alloc_table(`%;%`(s_global, f), table*{table})) + -- if ((s_mem, ma*{ma}) = $alloc_mem(`%;%`(s_table, f), mem*{mem})) + -- if ((s_elem, ea*{ea}) = $alloc_elem(`%;%`(s_mem, f), elem*{elem})) + -- if ((s_data, da*{da}) = $alloc_data(`%;%`(s_elem, f), data*{data})) + -- if (m_ex = m_im ++ {FUNC fa*{fa}, GLOBAL ga*{ga}, TABLE ta*{ta}, MEM ma*{ma}, ELEM ea*{ea}, DATA da*{da}, EXPORT []}) + -- if (xi*{xi} = $alloc_export(m_ex, export)*{export}) + -- if (m_res = m_ex[EXPORT_moduleinst = xi*{xi}]) + -- if (s_res = $replace_moduleinst(s_data, fa*{fa}, m_res)) + +;; 7-module.watsup:166.1-166.41 +rec { + +;; 7-module.watsup:166.1-166.41 +def run_elem : (state, elem*, idx) -> state + ;; 7-module.watsup:168.1-168.41 + def {f : frame, i : nat, s : store} run_elem(`%;%`(s, f), [], i) = `%;%`(s, f) + ;; 7-module.watsup:170.1-172.59 + def {elem : elem, elem'* : elem*, expr* : expr*, f : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) + -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?())) + -- if ($run_elem(`%;%`(s, f), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:174.1-179.67 + def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, reftype : reftype, s : store, s_new : store, s_res : store, x : idx} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) + -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) + -- if (n = |expr*{expr}|) + -- if (elemmode = TABLE_elemmode(x, instr*{instr})) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, i) ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) + -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:181.1-185.67 + def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_new : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) + -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) + -- if (elemmode = DECLARE_elemmode) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), [ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) + -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) +} + +;; 7-module.watsup:188.1-188.41 +rec { + +;; 7-module.watsup:188.1-188.41 +def run_data : (state, data*, idx) -> state + ;; 7-module.watsup:190.1-190.41 + def {f : frame, i : nat, s : store} run_data(`%;%`(s, f), [], i) = `%;%`(s, f) + ;; 7-module.watsup:192.1-194.59 + def {byte* : byte*, data : data, data'* : data*, f : frame, f_res : frame, i : nat, s : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) + -- if (data = `DATA%*%?`(byte*{byte}, ?())) + -- if ($run_data(`%;%`(s, f), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:196.1-201.67 + def {byte* : byte*, data : data, data'* : data*, datamode : datamode, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, s : store, s_new : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) + -- if (data = `DATA%*%?`(byte*{byte}, ?(datamode))) + -- if (n = |byte*{byte}|) + -- if (datamode = MEMORY_datamode(0, instr*{instr})) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(i) DATA.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) + -- if ($run_data(`%;%`(s_new, f_new), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) +} + +;; 7-module.watsup:206.1-206.68 +def instantiation : (store, module, externval*) -> (store, moduleinst) + ;; 7-module.watsup:208.1-213.61 + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(), export*{export})) + -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) + -- if (f = {LOCAL [], MODULE m}) + -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:215.1-222.62 + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(start), export*{export})) + -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) + -- if (f = {LOCAL [], MODULE m}) + -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_data, f_data)) + -- if (start = START(x)) + -- Step: `%~>%`(`%;%*`(`%;%`(s_data, f_data), [CALL_admininstr(x)]), `%;%*`(`%;%`(s_res, f_res), [])) + +;; 7-module.watsup:227.1-227.55 +def invocation : (store, funcaddr, val*) -> (store, val*) + ;; 7-module.watsup:229.1-236.55 + def {expr : expr, f : frame, f' : frame, fa : funcaddr, functype : functype, m : moduleinst, s : store, s' : store, val* : val*, val'* : val*, valtype* : valtype*, valtype'* : valtype*} invocation(s, fa, val*{val}) = (s', val'*{val'}) + -- if (m = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f = {LOCAL [], MODULE m}) + -- if ($funcinst(`%;%`(s, f))[fa].CODE_funcinst = `FUNC%%*%`(functype, valtype*{valtype}, expr)) + -- if (functype = `%->%`(valtype*{valtype}, valtype'*{valtype'})) + -- if (|val*{val}| = |valtype*{valtype}|) + -- if (|val'*{val'}| = |valtype'*{valtype'}|) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_val(val)*{val} :: [CALL_ADDR_admininstr(fa)]), `%;%*`(`%;%`(s', f'), $admininstr_val(val')*{val'})) + == IL Validation... == Running pass wildcards @@ -7226,8 +8414,8 @@ syntax mem = MEMORY(memtype) ;; 1-syntax.watsup:198.1-199.31 syntax elem = `ELEM%%*%?`(reftype, expr*, elemmode?) -;; 1-syntax.watsup:200.1-201.26 -syntax data = `DATA(*)%*%?`(byte**, datamode?) +;; 1-syntax.watsup:200.1-201.23 +syntax data = `DATA%*%?`(byte*, datamode?) ;; 1-syntax.watsup:202.1-203.16 syntax start = START(funcidx) @@ -7825,8 +9013,8 @@ relation Datamode_ok: `%|-%:OK`(context, datamode) ;; 3-typing.watsup:402.1-402.73 relation Data_ok: `%|-%:OK`(context, data) ;; 3-typing.watsup:433.1-435.40 - rule _ {C : context, b** : byte**, datamode? : datamode?}: - `%|-%:OK`(C, `DATA(*)%*%?`(b*{b}*{b}, datamode?{datamode})) + rule _ {C : context, b* : byte*, datamode? : datamode?}: + `%|-%:OK`(C, `DATA%*%?`(b*{b}, datamode?{datamode})) -- (Datamode_ok: `%|-%:OK`(C, datamode))?{datamode} ;; 3-typing.watsup:405.1-405.74 @@ -7992,10 +9180,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:169.1-176.5 +;; 4-runtime.watsup:180.1-187.5 rec { -;; 4-runtime.watsup:169.1-176.5 +;; 4-runtime.watsup:180.1-187.5 syntax admininstr = | UNREACHABLE | NOP @@ -8116,104 +9304,129 @@ def funcaddr : state -> funcaddr* ;; 4-runtime.watsup:118.1-118.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:119.1-119.31 + ;; 4-runtime.watsup:125.1-125.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:121.1-121.67 +;; 4-runtime.watsup:119.1-119.58 +def globalinst : state -> globalinst* + ;; 4-runtime.watsup:126.1-126.35 + def {f : frame, s : store} globalinst(`%;%`(s, f)) = s.GLOBAL_store + +;; 4-runtime.watsup:120.1-120.55 +def tableinst : state -> tableinst* + ;; 4-runtime.watsup:127.1-127.33 + def {f : frame, s : store} tableinst(`%;%`(s, f)) = s.TABLE_store + +;; 4-runtime.watsup:121.1-121.49 +def meminst : state -> meminst* + ;; 4-runtime.watsup:128.1-128.29 + def {f : frame, s : store} meminst(`%;%`(s, f)) = s.MEM_store + +;; 4-runtime.watsup:122.1-122.52 +def eleminst : state -> eleminst* + ;; 4-runtime.watsup:129.1-129.31 + def {f : frame, s : store} eleminst(`%;%`(s, f)) = s.ELEM_store + +;; 4-runtime.watsup:123.1-123.52 +def datainst : state -> datainst* + ;; 4-runtime.watsup:130.1-130.31 + def {f : frame, s : store} datainst(`%;%`(s, f)) = s.DATA_store + +;; 4-runtime.watsup:132.1-132.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:129.1-129.48 + ;; 4-runtime.watsup:140.1-140.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:122.1-122.69 +;; 4-runtime.watsup:133.1-133.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:130.1-130.54 + ;; 4-runtime.watsup:141.1-141.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:123.1-123.68 +;; 4-runtime.watsup:134.1-134.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:131.1-131.51 + ;; 4-runtime.watsup:142.1-142.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:124.1-124.66 +;; 4-runtime.watsup:135.1-135.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:132.1-132.45 + ;; 4-runtime.watsup:143.1-143.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:125.1-125.67 +;; 4-runtime.watsup:136.1-136.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:133.1-133.48 + ;; 4-runtime.watsup:144.1-144.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:126.1-126.67 +;; 4-runtime.watsup:137.1-137.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:134.1-134.48 + ;; 4-runtime.watsup:145.1-145.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:127.1-127.68 +;; 4-runtime.watsup:138.1-138.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:135.1-135.35 + ;; 4-runtime.watsup:146.1-146.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:138.1-138.78 +;; 4-runtime.watsup:149.1-149.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:147.1-147.52 + ;; 4-runtime.watsup:158.1-158.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:139.1-139.85 +;; 4-runtime.watsup:150.1-150.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:148.1-148.77 + ;; 4-runtime.watsup:159.1-159.77 def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:140.1-140.88 +;; 4-runtime.watsup:151.1-151.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:149.1-149.79 + ;; 4-runtime.watsup:160.1-160.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:141.1-141.84 +;; 4-runtime.watsup:152.1-152.84 def with_tableinst : (state, tableidx, tableinst) -> state - ;; 4-runtime.watsup:150.1-150.74 + ;; 4-runtime.watsup:161.1-161.74 def {f : frame, s : store, ti : tableinst, x : idx} with_tableinst(`%;%`(s, f), x, ti) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] = ti], f) -;; 4-runtime.watsup:142.1-142.93 +;; 4-runtime.watsup:153.1-153.93 def with_mem : (state, memidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:151.1-151.82 + ;; 4-runtime.watsup:162.1-162.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:143.1-143.77 +;; 4-runtime.watsup:154.1-154.77 def with_meminst : (state, memidx, meminst) -> state - ;; 4-runtime.watsup:152.1-152.68 + ;; 4-runtime.watsup:163.1-163.68 def {f : frame, mi : meminst, s : store, x : idx} with_meminst(`%;%`(s, f), x, mi) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] = mi], f) -;; 4-runtime.watsup:144.1-144.82 +;; 4-runtime.watsup:155.1-155.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:153.1-153.72 + ;; 4-runtime.watsup:164.1-164.72 def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:145.1-145.82 +;; 4-runtime.watsup:156.1-156.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:154.1-154.72 + ;; 4-runtime.watsup:165.1-165.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:156.1-156.49 +;; 4-runtime.watsup:167.1-167.49 def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:158.1-161.57 + ;; 4-runtime.watsup:169.1-172.57 def {i : nat, i' : nat, j? : nat?, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' -- if (ti = {TYPE `%%`(`[%..%?]`(i, j?{j}), reftype), ELEM r'*{r'}}) -- if (i' = (|r'*{r'}| + n)) -- if (ti' = {TYPE `%%`(`[%..%?]`(i', j?{j}), reftype), ELEM r'*{r'} :: r^n{}}) -;; 4-runtime.watsup:157.1-157.41 +;; 4-runtime.watsup:168.1-168.41 def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:162.1-165.66 + ;; 4-runtime.watsup:173.1-176.66 def {b* : byte*, i : nat, i' : nat, j? : nat?, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' -- if (mi = {TYPE `%I8`(`[%..%?]`(i, j?{j})), DATA b*{b}}) -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) -- if (mi' = {TYPE `%I8`(`[%..%?]`(i', j?{j})), DATA b*{b} :: 0^((n * 64) * $Ki){}}) -;; 4-runtime.watsup:178.1-181.21 +;; 4-runtime.watsup:189.1-192.21 rec { -;; 4-runtime.watsup:178.1-181.21 +;; 4-runtime.watsup:189.1-192.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -8665,6 +9878,278 @@ relation Step: `%~>%`(config, config) rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) +;; 7-module.watsup:3.1-3.64 +rec { + +;; 7-module.watsup:3.1-3.64 +def alloc_import : (moduleinst, import*, externval*) -> moduleinst + ;; 7-module.watsup:5.1-5.43 + def {m : moduleinst} alloc_import(m, [], []) = m + ;; 7-module.watsup:7.1-12.60 + def {externtype : externtype, externval : externval, externval'* : externval*, fa : funcaddr, functype : functype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = FUNC_externtype(functype)) + -- if (externval = FUNC_externval(fa)) + -- if (m_new = m[FUNC_moduleinst =.. [fa]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) + ;; 7-module.watsup:14.1-19.60 + def {externtype : externtype, externval : externval, externval'* : externval*, ga : globaladdr, globaltype : globaltype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = GLOBAL_externtype(globaltype)) + -- if (externval = GLOBAL_externval(ga)) + -- if (m_new = m[GLOBAL_moduleinst =.. [ga]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) + ;; 7-module.watsup:21.1-26.60 + def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name, ta : tableaddr, tabletype : tabletype} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = TABLE_externtype(tabletype)) + -- if (externval = TABLE_externval(ta)) + -- if (m_new = m[TABLE_moduleinst =.. [ta]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) + ;; 7-module.watsup:28.1-33.60 + def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, ma : memaddr, memtype : memtype, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = MEM_externtype(memtype)) + -- if (externval = MEM_externval(ma)) + -- if (m_new = m[MEM_moduleinst =.. [ma]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) +} + +;; 7-module.watsup:36.1-36.51 +rec { + +;; 7-module.watsup:36.1-36.51 +def alloc_func : (state, func*) -> (store, funcaddr*) + ;; 7-module.watsup:38.1-38.48 + def {f : frame, s : store} alloc_func(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:40.1-44.56 + def {f : frame, fa : funcaddr, fa'* : funcaddr*, fi : funcinst, func : func, func'* : func*, s : store, s_new : store, s_res : store} alloc_func(`%;%`(s, f), [func] :: func'*{func'}) = (s_res, [fa] :: fa'*{fa'}) + -- if (fi = {MODULE f.MODULE_frame, CODE func}) + -- if (fa = |$funcinst(`%;%`(s, f))|) + -- if (s_new = s[FUNC_store =.. [fi]]) + -- if ((s_res, fa'*{fa'}) = $alloc_func(`%;%`(s_new, f), func'*{func'})) +} + +;; 7-module.watsup:47.1-47.57 +rec { + +;; 7-module.watsup:47.1-47.57 +def alloc_global : (state, global*) -> (store, globaladdr*) + ;; 7-module.watsup:49.1-49.50 + def {f : frame, s : store} alloc_global(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:51.1-57.60 + def {f : frame, ga : globaladdr, ga'* : globaladdr*, gi : globalinst, global : global, global'* : global*, globaltype : globaltype, instr* : instr*, s : store, s_new : store, s_res : store, val : val} alloc_global(`%;%`(s, f), [global] :: global'*{global'}) = (s_res, [ga] :: ga'*{ga'}) + -- if (global = GLOBAL(globaltype, instr*{instr})) + -- Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr}), [$admininstr_val(val)]) + -- if (gi = {TYPE globaltype, VALUE val}) + -- if (ga = |$globalinst(`%;%`(s, f))|) + -- if (s_new = s[GLOBAL_store =.. [gi]]) + -- if ((s_res, ga'*{ga'}) = $alloc_global(`%;%`(s_new, f), global'*{global'})) +} + +;; 7-module.watsup:60.1-60.54 +rec { + +;; 7-module.watsup:60.1-60.54 +def alloc_table : (state, table*) -> (store, tableaddr*) + ;; 7-module.watsup:62.1-62.49 + def {f : frame, s : store} alloc_table(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:64.1-70.58 + def {f : frame, i : nat, j? : nat?, reftype : reftype, s : store, s_new : store, s_res : store, ta : tableaddr, ta'* : tableaddr*, table : table, table'* : table*, tabletype : tabletype, ti : tableinst} alloc_table(`%;%`(s, f), [table] :: table'*{table'}) = (s_res, [ta] :: ta'*{ta'}) + -- if (table = TABLE(tabletype)) + -- if (tabletype = `%%`(`[%..%?]`(i, j?{j}), reftype)) + -- if (ti = {TYPE tabletype, ELEM REF.NULL_ref(reftype)^i{}}) + -- if (ta = |$tableinst(`%;%`(s, f))|) + -- if (s_new = s[TABLE_store =.. [ti]]) + -- if ((s_res, ta'*{ta'}) = $alloc_table(`%;%`(s_new, f), table'*{table'})) +} + +;; 7-module.watsup:73.1-73.48 +rec { + +;; 7-module.watsup:73.1-73.48 +def alloc_mem : (state, mem*) -> (store, memaddr*) + ;; 7-module.watsup:75.1-75.47 + def {f : frame, s : store} alloc_mem(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:77.1-83.54 + def {f : frame, i : nat, j? : nat?, ma : memaddr, ma'* : memaddr*, mem : mem, mem'* : mem*, memtype : memtype, mi : meminst, s : store, s_new : store, s_res : store} alloc_mem(`%;%`(s, f), [mem] :: mem'*{mem'}) = (s_res, [ma] :: ma'*{ma'}) + -- if (mem = MEMORY(memtype)) + -- if (memtype = `%I8`(`[%..%?]`(i, j?{j}))) + -- if (mi = {TYPE memtype, DATA 0^((i * 64) * $Ki){}}) + -- if (ma = |$meminst(`%;%`(s, f))|) + -- if (s_new = s[MEM_store =.. [mi]]) + -- if ((s_res, ma'*{ma'}) = $alloc_mem(`%;%`(s_new, f), mem'*{mem'})) +} + +;; 7-module.watsup:86.1-86.51 +rec { + +;; 7-module.watsup:86.1-86.51 +def alloc_elem : (state, elem*) -> (store, elemaddr*) + ;; 7-module.watsup:88.1-88.48 + def {f : frame, s : store} alloc_elem(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:90.1-96.56 + def {ea : elemaddr, ea'* : elemaddr*, ei : eleminst, elem : elem, elem'* : elem*, elemmode? : elemmode?, f : frame, instr** : instr**, ref* : ref*, reftype : reftype, s : store, s_new : store, s_res : store} alloc_elem(`%;%`(s, f), [elem] :: elem'*{elem'}) = (s_res, [ea] :: ea'*{ea'}) + -- if (elem = `ELEM%%*%?`(reftype, instr*{instr}*{instr}, elemmode?{elemmode})) + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr}), [$admininstr_ref(ref)]))*{instr ref} + -- if (ei = {TYPE reftype, ELEM ref*{ref}}) + -- if (ea = |$eleminst(`%;%`(s, f))|) + -- if (s_new = s[ELEM_store =.. [ei]]) + -- if ((s_res, ea'*{ea'}) = $alloc_elem(`%;%`(s_new, f), elem'*{elem'})) +} + +;; 7-module.watsup:99.1-99.51 +rec { + +;; 7-module.watsup:99.1-99.51 +def alloc_data : (state, data*) -> (store, dataaddr*) + ;; 7-module.watsup:101.1-101.48 + def {f : frame, s : store} alloc_data(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:103.1-108.56 + def {byte* : byte*, da : dataaddr, da'* : dataaddr*, data : data, data'* : data*, datamode? : datamode?, di : datainst, f : frame, s : store, s_new : store, s_res : store} alloc_data(`%;%`(s, f), [data] :: data'*{data'}) = (s_res, [da] :: da'*{da'}) + -- if (data = `DATA%*%?`(byte*{byte}, datamode?{datamode})) + -- if (di = {DATA byte*{byte}}) + -- if (da = |$datainst(`%;%`(s, f))|) + -- if (s_new = s[DATA_store =.. [di]]) + -- if ((s_res, da'*{da'}) = $alloc_data(`%;%`(s_new, f), data'*{data'})) +} + +;; 7-module.watsup:111.1-111.62 +rec { + +;; 7-module.watsup:111.1-111.62 +def replace_moduleinst : (store, funcaddr*, moduleinst) -> store + ;; 7-module.watsup:113.1-113.43 + def {m : moduleinst, s : store} replace_moduleinst(s, [], m) = s + ;; 7-module.watsup:115.1-117.52 + def {fa : funcaddr, fa'* : funcaddr*, m : moduleinst, s : store, s_new : store, s_res : store} replace_moduleinst(s, [fa] :: fa'*{fa'}, m) = s_res + -- if (s_new = s[FUNC_store[fa].MODULE_funcinst = m]) + -- if (s_res = $replace_moduleinst(s_new, fa'*{fa'}, m)) +} + +;; 7-module.watsup:120.1-120.51 +def alloc_export : (moduleinst, export) -> exportinst + ;; 7-module.watsup:122.1-126.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = FUNC_externuse(x)) + -- if (externval = FUNC_externval(m.FUNC_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + ;; 7-module.watsup:128.1-132.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = GLOBAL_externuse(x)) + -- if (externval = GLOBAL_externval(m.GLOBAL_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + ;; 7-module.watsup:134.1-138.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = TABLE_externuse(x)) + -- if (externval = TABLE_externval(m.TABLE_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + ;; 7-module.watsup:140.1-144.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = MEM_externuse(x)) + -- if (externval = MEM_externval(m.MEM_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + +;; 7-module.watsup:147.1-147.67 +def alloc_module : (store, module, externval*) -> (store, moduleinst) + ;; 7-module.watsup:149.1-163.56 + def {da* : dataaddr*, data* : data*, ea* : elemaddr*, elem* : elem*, export* : export*, externval* : externval*, f : frame, fa* : funcaddr*, func* : func*, ga* : globaladdr*, global* : global*, import* : import*, m_ex : moduleinst, m_im : moduleinst, m_init : moduleinst, m_res : moduleinst, ma* : memaddr*, mem* : mem*, module : module, s : store, s_data : store, s_elem : store, s_func : store, s_global : store, s_mem : store, s_res : store, s_table : store, start? : start?, ta* : tableaddr*, table* : table*, xi* : exportinst*} alloc_module(s, module, externval*{externval}) = (s_res, m_res) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) + -- if (m_init = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (m_im = $alloc_import(m_init, import*{import}, externval*{externval})) + -- if (f = {LOCAL [], MODULE m_im}) + -- if ((s_func, fa*{fa}) = $alloc_func(`%;%`(s, f), func*{func})) + -- if ((s_global, ga*{ga}) = $alloc_global(`%;%`(s_func, f), global*{global})) + -- if ((s_table, ta*{ta}) = $alloc_table(`%;%`(s_global, f), table*{table})) + -- if ((s_mem, ma*{ma}) = $alloc_mem(`%;%`(s_table, f), mem*{mem})) + -- if ((s_elem, ea*{ea}) = $alloc_elem(`%;%`(s_mem, f), elem*{elem})) + -- if ((s_data, da*{da}) = $alloc_data(`%;%`(s_elem, f), data*{data})) + -- if (m_ex = m_im ++ {FUNC fa*{fa}, GLOBAL ga*{ga}, TABLE ta*{ta}, MEM ma*{ma}, ELEM ea*{ea}, DATA da*{da}, EXPORT []}) + -- if (xi*{xi} = $alloc_export(m_ex, export)*{export}) + -- if (m_res = m_ex[EXPORT_moduleinst = xi*{xi}]) + -- if (s_res = $replace_moduleinst(s_data, fa*{fa}, m_res)) + +;; 7-module.watsup:166.1-166.41 +rec { + +;; 7-module.watsup:166.1-166.41 +def run_elem : (state, elem*, idx) -> state + ;; 7-module.watsup:168.1-168.41 + def {f : frame, i : nat, s : store} run_elem(`%;%`(s, f), [], i) = `%;%`(s, f) + ;; 7-module.watsup:170.1-172.59 + def {elem : elem, elem'* : elem*, expr* : expr*, f : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) + -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?())) + -- if ($run_elem(`%;%`(s, f), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:174.1-179.67 + def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, reftype : reftype, s : store, s_new : store, s_res : store, x : idx} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) + -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) + -- if (n = |expr*{expr}|) + -- if (elemmode = TABLE_elemmode(x, instr*{instr})) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, i) ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) + -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:181.1-185.67 + def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_new : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) + -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) + -- if (elemmode = DECLARE_elemmode) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), [ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) + -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) +} + +;; 7-module.watsup:188.1-188.41 +rec { + +;; 7-module.watsup:188.1-188.41 +def run_data : (state, data*, idx) -> state + ;; 7-module.watsup:190.1-190.41 + def {f : frame, i : nat, s : store} run_data(`%;%`(s, f), [], i) = `%;%`(s, f) + ;; 7-module.watsup:192.1-194.59 + def {byte* : byte*, data : data, data'* : data*, f : frame, f_res : frame, i : nat, s : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) + -- if (data = `DATA%*%?`(byte*{byte}, ?())) + -- if ($run_data(`%;%`(s, f), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:196.1-201.67 + def {byte* : byte*, data : data, data'* : data*, datamode : datamode, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, s : store, s_new : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) + -- if (data = `DATA%*%?`(byte*{byte}, ?(datamode))) + -- if (n = |byte*{byte}|) + -- if (datamode = MEMORY_datamode(0, instr*{instr})) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(i) DATA.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) + -- if ($run_data(`%;%`(s_new, f_new), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) +} + +;; 7-module.watsup:206.1-206.68 +def instantiation : (store, module, externval*) -> (store, moduleinst) + ;; 7-module.watsup:208.1-213.61 + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(), export*{export})) + -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) + -- if (f = {LOCAL [], MODULE m}) + -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:215.1-222.62 + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(start), export*{export})) + -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) + -- if (f = {LOCAL [], MODULE m}) + -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_data, f_data)) + -- if (start = START(x)) + -- Step: `%~>%`(`%;%*`(`%;%`(s_data, f_data), [CALL_admininstr(x)]), `%;%*`(`%;%`(s_res, f_res), [])) + +;; 7-module.watsup:227.1-227.55 +def invocation : (store, funcaddr, val*) -> (store, val*) + ;; 7-module.watsup:229.1-236.55 + def {expr : expr, f : frame, f' : frame, fa : funcaddr, functype : functype, m : moduleinst, s : store, s' : store, val* : val*, val'* : val*, valtype* : valtype*, valtype'* : valtype*} invocation(s, fa, val*{val}) = (s', val'*{val'}) + -- if (m = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f = {LOCAL [], MODULE m}) + -- if ($funcinst(`%;%`(s, f))[fa].CODE_funcinst = `FUNC%%*%`(functype, valtype*{valtype}, expr)) + -- if (functype = `%->%`(valtype*{valtype}, valtype'*{valtype'})) + -- if (|val*{val}| = |valtype*{valtype}|) + -- if (|val'*{val'}| = |valtype'*{valtype'}|) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_val(val)*{val} :: [CALL_ADDR_admininstr(fa)]), `%;%*`(`%;%`(s', f'), $admininstr_val(val')*{val'})) + == IL Validation... == Running pass sideconditions @@ -8988,8 +10473,8 @@ syntax mem = MEMORY(memtype) ;; 1-syntax.watsup:198.1-199.31 syntax elem = `ELEM%%*%?`(reftype, expr*, elemmode?) -;; 1-syntax.watsup:200.1-201.26 -syntax data = `DATA(*)%*%?`(byte**, datamode?) +;; 1-syntax.watsup:200.1-201.23 +syntax data = `DATA%*%?`(byte*, datamode?) ;; 1-syntax.watsup:202.1-203.16 syntax start = START(funcidx) @@ -9625,8 +11110,8 @@ relation Datamode_ok: `%|-%:OK`(context, datamode) ;; 3-typing.watsup:402.1-402.73 relation Data_ok: `%|-%:OK`(context, data) ;; 3-typing.watsup:433.1-435.40 - rule _ {C : context, b** : byte**, datamode? : datamode?}: - `%|-%:OK`(C, `DATA(*)%*%?`(b*{b}*{b}, datamode?{datamode})) + rule _ {C : context, b* : byte*, datamode? : datamode?}: + `%|-%:OK`(C, `DATA%*%?`(b*{b}, datamode?{datamode})) -- (Datamode_ok: `%|-%:OK`(C, datamode))?{datamode} ;; 3-typing.watsup:405.1-405.74 @@ -9802,10 +11287,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:169.1-176.5 +;; 4-runtime.watsup:180.1-187.5 rec { -;; 4-runtime.watsup:169.1-176.5 +;; 4-runtime.watsup:180.1-187.5 syntax admininstr = | UNREACHABLE | NOP @@ -9926,104 +11411,129 @@ def funcaddr : state -> funcaddr* ;; 4-runtime.watsup:118.1-118.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:119.1-119.31 + ;; 4-runtime.watsup:125.1-125.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:121.1-121.67 +;; 4-runtime.watsup:119.1-119.58 +def globalinst : state -> globalinst* + ;; 4-runtime.watsup:126.1-126.35 + def {f : frame, s : store} globalinst(`%;%`(s, f)) = s.GLOBAL_store + +;; 4-runtime.watsup:120.1-120.55 +def tableinst : state -> tableinst* + ;; 4-runtime.watsup:127.1-127.33 + def {f : frame, s : store} tableinst(`%;%`(s, f)) = s.TABLE_store + +;; 4-runtime.watsup:121.1-121.49 +def meminst : state -> meminst* + ;; 4-runtime.watsup:128.1-128.29 + def {f : frame, s : store} meminst(`%;%`(s, f)) = s.MEM_store + +;; 4-runtime.watsup:122.1-122.52 +def eleminst : state -> eleminst* + ;; 4-runtime.watsup:129.1-129.31 + def {f : frame, s : store} eleminst(`%;%`(s, f)) = s.ELEM_store + +;; 4-runtime.watsup:123.1-123.52 +def datainst : state -> datainst* + ;; 4-runtime.watsup:130.1-130.31 + def {f : frame, s : store} datainst(`%;%`(s, f)) = s.DATA_store + +;; 4-runtime.watsup:132.1-132.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:129.1-129.48 + ;; 4-runtime.watsup:140.1-140.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:122.1-122.69 +;; 4-runtime.watsup:133.1-133.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:130.1-130.54 + ;; 4-runtime.watsup:141.1-141.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:123.1-123.68 +;; 4-runtime.watsup:134.1-134.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:131.1-131.51 + ;; 4-runtime.watsup:142.1-142.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:124.1-124.66 +;; 4-runtime.watsup:135.1-135.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:132.1-132.45 + ;; 4-runtime.watsup:143.1-143.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:125.1-125.67 +;; 4-runtime.watsup:136.1-136.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:133.1-133.48 + ;; 4-runtime.watsup:144.1-144.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:126.1-126.67 +;; 4-runtime.watsup:137.1-137.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:134.1-134.48 + ;; 4-runtime.watsup:145.1-145.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:127.1-127.68 +;; 4-runtime.watsup:138.1-138.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:135.1-135.35 + ;; 4-runtime.watsup:146.1-146.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:138.1-138.78 +;; 4-runtime.watsup:149.1-149.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:147.1-147.52 + ;; 4-runtime.watsup:158.1-158.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:139.1-139.85 +;; 4-runtime.watsup:150.1-150.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:148.1-148.77 + ;; 4-runtime.watsup:159.1-159.77 def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:140.1-140.88 +;; 4-runtime.watsup:151.1-151.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:149.1-149.79 + ;; 4-runtime.watsup:160.1-160.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:141.1-141.84 +;; 4-runtime.watsup:152.1-152.84 def with_tableinst : (state, tableidx, tableinst) -> state - ;; 4-runtime.watsup:150.1-150.74 + ;; 4-runtime.watsup:161.1-161.74 def {f : frame, s : store, ti : tableinst, x : idx} with_tableinst(`%;%`(s, f), x, ti) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] = ti], f) -;; 4-runtime.watsup:142.1-142.93 +;; 4-runtime.watsup:153.1-153.93 def with_mem : (state, memidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:151.1-151.82 + ;; 4-runtime.watsup:162.1-162.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:143.1-143.77 +;; 4-runtime.watsup:154.1-154.77 def with_meminst : (state, memidx, meminst) -> state - ;; 4-runtime.watsup:152.1-152.68 + ;; 4-runtime.watsup:163.1-163.68 def {f : frame, mi : meminst, s : store, x : idx} with_meminst(`%;%`(s, f), x, mi) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] = mi], f) -;; 4-runtime.watsup:144.1-144.82 +;; 4-runtime.watsup:155.1-155.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:153.1-153.72 + ;; 4-runtime.watsup:164.1-164.72 def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:145.1-145.82 +;; 4-runtime.watsup:156.1-156.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:154.1-154.72 + ;; 4-runtime.watsup:165.1-165.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:156.1-156.49 +;; 4-runtime.watsup:167.1-167.49 def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:158.1-161.57 + ;; 4-runtime.watsup:169.1-172.57 def {i : nat, i' : nat, j? : nat?, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' -- if (ti = {TYPE `%%`(`[%..%?]`(i, j?{j}), reftype), ELEM r'*{r'}}) -- if (i' = (|r'*{r'}| + n)) -- if (ti' = {TYPE `%%`(`[%..%?]`(i', j?{j}), reftype), ELEM r'*{r'} :: r^n{}}) -;; 4-runtime.watsup:157.1-157.41 +;; 4-runtime.watsup:168.1-168.41 def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:162.1-165.66 + ;; 4-runtime.watsup:173.1-176.66 def {b* : byte*, i : nat, i' : nat, j? : nat?, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' -- if (mi = {TYPE `%I8`(`[%..%?]`(i, j?{j})), DATA b*{b}}) -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) -- if (mi' = {TYPE `%I8`(`[%..%?]`(i', j?{j})), DATA b*{b} :: 0^((n * 64) * $Ki){}}) -;; 4-runtime.watsup:178.1-181.21 +;; 4-runtime.watsup:189.1-192.21 rec { -;; 4-runtime.watsup:178.1-181.21 +;; 4-runtime.watsup:189.1-192.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -10483,6 +11993,278 @@ relation Step: `%~>%`(config, config) rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) +;; 7-module.watsup:3.1-3.64 +rec { + +;; 7-module.watsup:3.1-3.64 +def alloc_import : (moduleinst, import*, externval*) -> moduleinst + ;; 7-module.watsup:5.1-5.43 + def {m : moduleinst} alloc_import(m, [], []) = m + ;; 7-module.watsup:7.1-12.60 + def {externtype : externtype, externval : externval, externval'* : externval*, fa : funcaddr, functype : functype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = FUNC_externtype(functype)) + -- if (externval = FUNC_externval(fa)) + -- if (m_new = m[FUNC_moduleinst =.. [fa]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) + ;; 7-module.watsup:14.1-19.60 + def {externtype : externtype, externval : externval, externval'* : externval*, ga : globaladdr, globaltype : globaltype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = GLOBAL_externtype(globaltype)) + -- if (externval = GLOBAL_externval(ga)) + -- if (m_new = m[GLOBAL_moduleinst =.. [ga]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) + ;; 7-module.watsup:21.1-26.60 + def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name, ta : tableaddr, tabletype : tabletype} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = TABLE_externtype(tabletype)) + -- if (externval = TABLE_externval(ta)) + -- if (m_new = m[TABLE_moduleinst =.. [ta]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) + ;; 7-module.watsup:28.1-33.60 + def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, ma : memaddr, memtype : memtype, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = MEM_externtype(memtype)) + -- if (externval = MEM_externval(ma)) + -- if (m_new = m[MEM_moduleinst =.. [ma]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) +} + +;; 7-module.watsup:36.1-36.51 +rec { + +;; 7-module.watsup:36.1-36.51 +def alloc_func : (state, func*) -> (store, funcaddr*) + ;; 7-module.watsup:38.1-38.48 + def {f : frame, s : store} alloc_func(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:40.1-44.56 + def {f : frame, fa : funcaddr, fa'* : funcaddr*, fi : funcinst, func : func, func'* : func*, s : store, s_new : store, s_res : store} alloc_func(`%;%`(s, f), [func] :: func'*{func'}) = (s_res, [fa] :: fa'*{fa'}) + -- if (fi = {MODULE f.MODULE_frame, CODE func}) + -- if (fa = |$funcinst(`%;%`(s, f))|) + -- if (s_new = s[FUNC_store =.. [fi]]) + -- if ((s_res, fa'*{fa'}) = $alloc_func(`%;%`(s_new, f), func'*{func'})) +} + +;; 7-module.watsup:47.1-47.57 +rec { + +;; 7-module.watsup:47.1-47.57 +def alloc_global : (state, global*) -> (store, globaladdr*) + ;; 7-module.watsup:49.1-49.50 + def {f : frame, s : store} alloc_global(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:51.1-57.60 + def {f : frame, ga : globaladdr, ga'* : globaladdr*, gi : globalinst, global : global, global'* : global*, globaltype : globaltype, instr* : instr*, s : store, s_new : store, s_res : store, val : val} alloc_global(`%;%`(s, f), [global] :: global'*{global'}) = (s_res, [ga] :: ga'*{ga'}) + -- if (global = GLOBAL(globaltype, instr*{instr})) + -- Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr}), [$admininstr_val(val)]) + -- if (gi = {TYPE globaltype, VALUE val}) + -- if (ga = |$globalinst(`%;%`(s, f))|) + -- if (s_new = s[GLOBAL_store =.. [gi]]) + -- if ((s_res, ga'*{ga'}) = $alloc_global(`%;%`(s_new, f), global'*{global'})) +} + +;; 7-module.watsup:60.1-60.54 +rec { + +;; 7-module.watsup:60.1-60.54 +def alloc_table : (state, table*) -> (store, tableaddr*) + ;; 7-module.watsup:62.1-62.49 + def {f : frame, s : store} alloc_table(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:64.1-70.58 + def {f : frame, i : nat, j? : nat?, reftype : reftype, s : store, s_new : store, s_res : store, ta : tableaddr, ta'* : tableaddr*, table : table, table'* : table*, tabletype : tabletype, ti : tableinst} alloc_table(`%;%`(s, f), [table] :: table'*{table'}) = (s_res, [ta] :: ta'*{ta'}) + -- if (table = TABLE(tabletype)) + -- if (tabletype = `%%`(`[%..%?]`(i, j?{j}), reftype)) + -- if (ti = {TYPE tabletype, ELEM REF.NULL_ref(reftype)^i{}}) + -- if (ta = |$tableinst(`%;%`(s, f))|) + -- if (s_new = s[TABLE_store =.. [ti]]) + -- if ((s_res, ta'*{ta'}) = $alloc_table(`%;%`(s_new, f), table'*{table'})) +} + +;; 7-module.watsup:73.1-73.48 +rec { + +;; 7-module.watsup:73.1-73.48 +def alloc_mem : (state, mem*) -> (store, memaddr*) + ;; 7-module.watsup:75.1-75.47 + def {f : frame, s : store} alloc_mem(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:77.1-83.54 + def {f : frame, i : nat, j? : nat?, ma : memaddr, ma'* : memaddr*, mem : mem, mem'* : mem*, memtype : memtype, mi : meminst, s : store, s_new : store, s_res : store} alloc_mem(`%;%`(s, f), [mem] :: mem'*{mem'}) = (s_res, [ma] :: ma'*{ma'}) + -- if (mem = MEMORY(memtype)) + -- if (memtype = `%I8`(`[%..%?]`(i, j?{j}))) + -- if (mi = {TYPE memtype, DATA 0^((i * 64) * $Ki){}}) + -- if (ma = |$meminst(`%;%`(s, f))|) + -- if (s_new = s[MEM_store =.. [mi]]) + -- if ((s_res, ma'*{ma'}) = $alloc_mem(`%;%`(s_new, f), mem'*{mem'})) +} + +;; 7-module.watsup:86.1-86.51 +rec { + +;; 7-module.watsup:86.1-86.51 +def alloc_elem : (state, elem*) -> (store, elemaddr*) + ;; 7-module.watsup:88.1-88.48 + def {f : frame, s : store} alloc_elem(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:90.1-96.56 + def {ea : elemaddr, ea'* : elemaddr*, ei : eleminst, elem : elem, elem'* : elem*, elemmode? : elemmode?, f : frame, instr** : instr**, ref* : ref*, reftype : reftype, s : store, s_new : store, s_res : store} alloc_elem(`%;%`(s, f), [elem] :: elem'*{elem'}) = (s_res, [ea] :: ea'*{ea'}) + -- if (elem = `ELEM%%*%?`(reftype, instr*{instr}*{instr}, elemmode?{elemmode})) + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr}), [$admininstr_ref(ref)]))*{instr ref} + -- if (ei = {TYPE reftype, ELEM ref*{ref}}) + -- if (ea = |$eleminst(`%;%`(s, f))|) + -- if (s_new = s[ELEM_store =.. [ei]]) + -- if ((s_res, ea'*{ea'}) = $alloc_elem(`%;%`(s_new, f), elem'*{elem'})) +} + +;; 7-module.watsup:99.1-99.51 +rec { + +;; 7-module.watsup:99.1-99.51 +def alloc_data : (state, data*) -> (store, dataaddr*) + ;; 7-module.watsup:101.1-101.48 + def {f : frame, s : store} alloc_data(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:103.1-108.56 + def {byte* : byte*, da : dataaddr, da'* : dataaddr*, data : data, data'* : data*, datamode? : datamode?, di : datainst, f : frame, s : store, s_new : store, s_res : store} alloc_data(`%;%`(s, f), [data] :: data'*{data'}) = (s_res, [da] :: da'*{da'}) + -- if (data = `DATA%*%?`(byte*{byte}, datamode?{datamode})) + -- if (di = {DATA byte*{byte}}) + -- if (da = |$datainst(`%;%`(s, f))|) + -- if (s_new = s[DATA_store =.. [di]]) + -- if ((s_res, da'*{da'}) = $alloc_data(`%;%`(s_new, f), data'*{data'})) +} + +;; 7-module.watsup:111.1-111.62 +rec { + +;; 7-module.watsup:111.1-111.62 +def replace_moduleinst : (store, funcaddr*, moduleinst) -> store + ;; 7-module.watsup:113.1-113.43 + def {m : moduleinst, s : store} replace_moduleinst(s, [], m) = s + ;; 7-module.watsup:115.1-117.52 + def {fa : funcaddr, fa'* : funcaddr*, m : moduleinst, s : store, s_new : store, s_res : store} replace_moduleinst(s, [fa] :: fa'*{fa'}, m) = s_res + -- if (s_new = s[FUNC_store[fa].MODULE_funcinst = m]) + -- if (s_res = $replace_moduleinst(s_new, fa'*{fa'}, m)) +} + +;; 7-module.watsup:120.1-120.51 +def alloc_export : (moduleinst, export) -> exportinst + ;; 7-module.watsup:122.1-126.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = FUNC_externuse(x)) + -- if (externval = FUNC_externval(m.FUNC_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + ;; 7-module.watsup:128.1-132.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = GLOBAL_externuse(x)) + -- if (externval = GLOBAL_externval(m.GLOBAL_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + ;; 7-module.watsup:134.1-138.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = TABLE_externuse(x)) + -- if (externval = TABLE_externval(m.TABLE_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + ;; 7-module.watsup:140.1-144.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = MEM_externuse(x)) + -- if (externval = MEM_externval(m.MEM_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + +;; 7-module.watsup:147.1-147.67 +def alloc_module : (store, module, externval*) -> (store, moduleinst) + ;; 7-module.watsup:149.1-163.56 + def {da* : dataaddr*, data* : data*, ea* : elemaddr*, elem* : elem*, export* : export*, externval* : externval*, f : frame, fa* : funcaddr*, func* : func*, ga* : globaladdr*, global* : global*, import* : import*, m_ex : moduleinst, m_im : moduleinst, m_init : moduleinst, m_res : moduleinst, ma* : memaddr*, mem* : mem*, module : module, s : store, s_data : store, s_elem : store, s_func : store, s_global : store, s_mem : store, s_res : store, s_table : store, start? : start?, ta* : tableaddr*, table* : table*, xi* : exportinst*} alloc_module(s, module, externval*{externval}) = (s_res, m_res) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) + -- if (m_init = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (m_im = $alloc_import(m_init, import*{import}, externval*{externval})) + -- if (f = {LOCAL [], MODULE m_im}) + -- if ((s_func, fa*{fa}) = $alloc_func(`%;%`(s, f), func*{func})) + -- if ((s_global, ga*{ga}) = $alloc_global(`%;%`(s_func, f), global*{global})) + -- if ((s_table, ta*{ta}) = $alloc_table(`%;%`(s_global, f), table*{table})) + -- if ((s_mem, ma*{ma}) = $alloc_mem(`%;%`(s_table, f), mem*{mem})) + -- if ((s_elem, ea*{ea}) = $alloc_elem(`%;%`(s_mem, f), elem*{elem})) + -- if ((s_data, da*{da}) = $alloc_data(`%;%`(s_elem, f), data*{data})) + -- if (m_ex = m_im ++ {FUNC fa*{fa}, GLOBAL ga*{ga}, TABLE ta*{ta}, MEM ma*{ma}, ELEM ea*{ea}, DATA da*{da}, EXPORT []}) + -- if (xi*{xi} = $alloc_export(m_ex, export)*{export}) + -- if (m_res = m_ex[EXPORT_moduleinst = xi*{xi}]) + -- if (s_res = $replace_moduleinst(s_data, fa*{fa}, m_res)) + +;; 7-module.watsup:166.1-166.41 +rec { + +;; 7-module.watsup:166.1-166.41 +def run_elem : (state, elem*, idx) -> state + ;; 7-module.watsup:168.1-168.41 + def {f : frame, i : nat, s : store} run_elem(`%;%`(s, f), [], i) = `%;%`(s, f) + ;; 7-module.watsup:170.1-172.59 + def {elem : elem, elem'* : elem*, expr* : expr*, f : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) + -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?())) + -- if ($run_elem(`%;%`(s, f), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:174.1-179.67 + def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, reftype : reftype, s : store, s_new : store, s_res : store, x : idx} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) + -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) + -- if (n = |expr*{expr}|) + -- if (elemmode = TABLE_elemmode(x, instr*{instr})) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, i) ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) + -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:181.1-185.67 + def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_new : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) + -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) + -- if (elemmode = DECLARE_elemmode) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), [ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) + -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) +} + +;; 7-module.watsup:188.1-188.41 +rec { + +;; 7-module.watsup:188.1-188.41 +def run_data : (state, data*, idx) -> state + ;; 7-module.watsup:190.1-190.41 + def {f : frame, i : nat, s : store} run_data(`%;%`(s, f), [], i) = `%;%`(s, f) + ;; 7-module.watsup:192.1-194.59 + def {byte* : byte*, data : data, data'* : data*, f : frame, f_res : frame, i : nat, s : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) + -- if (data = `DATA%*%?`(byte*{byte}, ?())) + -- if ($run_data(`%;%`(s, f), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:196.1-201.67 + def {byte* : byte*, data : data, data'* : data*, datamode : datamode, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, s : store, s_new : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) + -- if (data = `DATA%*%?`(byte*{byte}, ?(datamode))) + -- if (n = |byte*{byte}|) + -- if (datamode = MEMORY_datamode(0, instr*{instr})) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(i) DATA.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) + -- if ($run_data(`%;%`(s_new, f_new), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) +} + +;; 7-module.watsup:206.1-206.68 +def instantiation : (store, module, externval*) -> (store, moduleinst) + ;; 7-module.watsup:208.1-213.61 + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(), export*{export})) + -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) + -- if (f = {LOCAL [], MODULE m}) + -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:215.1-222.62 + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(start), export*{export})) + -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) + -- if (f = {LOCAL [], MODULE m}) + -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_data, f_data)) + -- if (start = START(x)) + -- Step: `%~>%`(`%;%*`(`%;%`(s_data, f_data), [CALL_admininstr(x)]), `%;%*`(`%;%`(s_res, f_res), [])) + +;; 7-module.watsup:227.1-227.55 +def invocation : (store, funcaddr, val*) -> (store, val*) + ;; 7-module.watsup:229.1-236.55 + def {expr : expr, f : frame, f' : frame, fa : funcaddr, functype : functype, m : moduleinst, s : store, s' : store, val* : val*, val'* : val*, valtype* : valtype*, valtype'* : valtype*} invocation(s, fa, val*{val}) = (s', val'*{val'}) + -- if (m = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f = {LOCAL [], MODULE m}) + -- if ($funcinst(`%;%`(s, f))[fa].CODE_funcinst = `FUNC%%*%`(functype, valtype*{valtype}, expr)) + -- if (functype = `%->%`(valtype*{valtype}, valtype'*{valtype'})) + -- if (|val*{val}| = |valtype*{valtype}|) + -- if (|val'*{val'}| = |valtype'*{valtype'}|) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_val(val)*{val} :: [CALL_ADDR_admininstr(fa)]), `%;%*`(`%;%`(s', f'), $admininstr_val(val')*{val'})) + == IL Validation... == Running pass animate Animation failed:if ($funcinst(z)[a].CODE_funcinst = `FUNC%%*%`(ft', t*{t}, instr*{instr})) @@ -10809,8 +12591,8 @@ syntax mem = MEMORY(memtype) ;; 1-syntax.watsup:198.1-199.31 syntax elem = `ELEM%%*%?`(reftype, expr*, elemmode?) -;; 1-syntax.watsup:200.1-201.26 -syntax data = `DATA(*)%*%?`(byte**, datamode?) +;; 1-syntax.watsup:200.1-201.23 +syntax data = `DATA%*%?`(byte*, datamode?) ;; 1-syntax.watsup:202.1-203.16 syntax start = START(funcidx) @@ -11446,8 +13228,8 @@ relation Datamode_ok: `%|-%:OK`(context, datamode) ;; 3-typing.watsup:402.1-402.73 relation Data_ok: `%|-%:OK`(context, data) ;; 3-typing.watsup:433.1-435.40 - rule _ {C : context, b** : byte**, datamode? : datamode?}: - `%|-%:OK`(C, `DATA(*)%*%?`(b*{b}*{b}, datamode?{datamode})) + rule _ {C : context, b* : byte*, datamode? : datamode?}: + `%|-%:OK`(C, `DATA%*%?`(b*{b}, datamode?{datamode})) -- (Datamode_ok: `%|-%:OK`(C, datamode))?{datamode} ;; 3-typing.watsup:405.1-405.74 @@ -11623,10 +13405,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:169.1-176.5 +;; 4-runtime.watsup:180.1-187.5 rec { -;; 4-runtime.watsup:169.1-176.5 +;; 4-runtime.watsup:180.1-187.5 syntax admininstr = | UNREACHABLE | NOP @@ -11747,104 +13529,129 @@ def funcaddr : state -> funcaddr* ;; 4-runtime.watsup:118.1-118.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:119.1-119.31 + ;; 4-runtime.watsup:125.1-125.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:121.1-121.67 +;; 4-runtime.watsup:119.1-119.58 +def globalinst : state -> globalinst* + ;; 4-runtime.watsup:126.1-126.35 + def {f : frame, s : store} globalinst(`%;%`(s, f)) = s.GLOBAL_store + +;; 4-runtime.watsup:120.1-120.55 +def tableinst : state -> tableinst* + ;; 4-runtime.watsup:127.1-127.33 + def {f : frame, s : store} tableinst(`%;%`(s, f)) = s.TABLE_store + +;; 4-runtime.watsup:121.1-121.49 +def meminst : state -> meminst* + ;; 4-runtime.watsup:128.1-128.29 + def {f : frame, s : store} meminst(`%;%`(s, f)) = s.MEM_store + +;; 4-runtime.watsup:122.1-122.52 +def eleminst : state -> eleminst* + ;; 4-runtime.watsup:129.1-129.31 + def {f : frame, s : store} eleminst(`%;%`(s, f)) = s.ELEM_store + +;; 4-runtime.watsup:123.1-123.52 +def datainst : state -> datainst* + ;; 4-runtime.watsup:130.1-130.31 + def {f : frame, s : store} datainst(`%;%`(s, f)) = s.DATA_store + +;; 4-runtime.watsup:132.1-132.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:129.1-129.48 + ;; 4-runtime.watsup:140.1-140.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:122.1-122.69 +;; 4-runtime.watsup:133.1-133.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:130.1-130.54 + ;; 4-runtime.watsup:141.1-141.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:123.1-123.68 +;; 4-runtime.watsup:134.1-134.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:131.1-131.51 + ;; 4-runtime.watsup:142.1-142.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:124.1-124.66 +;; 4-runtime.watsup:135.1-135.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:132.1-132.45 + ;; 4-runtime.watsup:143.1-143.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:125.1-125.67 +;; 4-runtime.watsup:136.1-136.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:133.1-133.48 + ;; 4-runtime.watsup:144.1-144.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:126.1-126.67 +;; 4-runtime.watsup:137.1-137.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:134.1-134.48 + ;; 4-runtime.watsup:145.1-145.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:127.1-127.68 +;; 4-runtime.watsup:138.1-138.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:135.1-135.35 + ;; 4-runtime.watsup:146.1-146.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:138.1-138.78 +;; 4-runtime.watsup:149.1-149.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:147.1-147.52 + ;; 4-runtime.watsup:158.1-158.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:139.1-139.85 +;; 4-runtime.watsup:150.1-150.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:148.1-148.77 + ;; 4-runtime.watsup:159.1-159.77 def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:140.1-140.88 +;; 4-runtime.watsup:151.1-151.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:149.1-149.79 + ;; 4-runtime.watsup:160.1-160.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:141.1-141.84 +;; 4-runtime.watsup:152.1-152.84 def with_tableinst : (state, tableidx, tableinst) -> state - ;; 4-runtime.watsup:150.1-150.74 + ;; 4-runtime.watsup:161.1-161.74 def {f : frame, s : store, ti : tableinst, x : idx} with_tableinst(`%;%`(s, f), x, ti) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] = ti], f) -;; 4-runtime.watsup:142.1-142.93 +;; 4-runtime.watsup:153.1-153.93 def with_mem : (state, memidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:151.1-151.82 + ;; 4-runtime.watsup:162.1-162.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:143.1-143.77 +;; 4-runtime.watsup:154.1-154.77 def with_meminst : (state, memidx, meminst) -> state - ;; 4-runtime.watsup:152.1-152.68 + ;; 4-runtime.watsup:163.1-163.68 def {f : frame, mi : meminst, s : store, x : idx} with_meminst(`%;%`(s, f), x, mi) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] = mi], f) -;; 4-runtime.watsup:144.1-144.82 +;; 4-runtime.watsup:155.1-155.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:153.1-153.72 + ;; 4-runtime.watsup:164.1-164.72 def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:145.1-145.82 +;; 4-runtime.watsup:156.1-156.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:154.1-154.72 + ;; 4-runtime.watsup:165.1-165.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:156.1-156.49 +;; 4-runtime.watsup:167.1-167.49 def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:158.1-161.57 + ;; 4-runtime.watsup:169.1-172.57 def {i : nat, i' : nat, j? : nat?, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' -- if (ti = {TYPE `%%`(`[%..%?]`(i, j?{j}), reftype), ELEM r'*{r'}}) -- if (i' = (|r'*{r'}| + n)) -- if (ti' = {TYPE `%%`(`[%..%?]`(i', j?{j}), reftype), ELEM r'*{r'} :: r^n{}}) -;; 4-runtime.watsup:157.1-157.41 +;; 4-runtime.watsup:168.1-168.41 def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:162.1-165.66 + ;; 4-runtime.watsup:173.1-176.66 def {b* : byte*, i : nat, i' : nat, j? : nat?, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' -- if (mi = {TYPE `%I8`(`[%..%?]`(i, j?{j})), DATA b*{b}}) -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) -- if (mi' = {TYPE `%I8`(`[%..%?]`(i', j?{j})), DATA b*{b} :: 0^((n * 64) * $Ki){}}) -;; 4-runtime.watsup:178.1-181.21 +;; 4-runtime.watsup:189.1-192.21 rec { -;; 4-runtime.watsup:178.1-181.21 +;; 4-runtime.watsup:189.1-192.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -12304,6 +14111,278 @@ relation Step: `%~>%`(config, config) rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) +;; 7-module.watsup:3.1-3.64 +rec { + +;; 7-module.watsup:3.1-3.64 +def alloc_import : (moduleinst, import*, externval*) -> moduleinst + ;; 7-module.watsup:5.1-5.43 + def {m : moduleinst} alloc_import(m, [], []) = m + ;; 7-module.watsup:7.1-12.60 + def {externtype : externtype, externval : externval, externval'* : externval*, fa : funcaddr, functype : functype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = FUNC_externtype(functype)) + -- if (externval = FUNC_externval(fa)) + -- if (m_new = m[FUNC_moduleinst =.. [fa]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) + ;; 7-module.watsup:14.1-19.60 + def {externtype : externtype, externval : externval, externval'* : externval*, ga : globaladdr, globaltype : globaltype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = GLOBAL_externtype(globaltype)) + -- if (externval = GLOBAL_externval(ga)) + -- if (m_new = m[GLOBAL_moduleinst =.. [ga]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) + ;; 7-module.watsup:21.1-26.60 + def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name, ta : tableaddr, tabletype : tabletype} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = TABLE_externtype(tabletype)) + -- if (externval = TABLE_externval(ta)) + -- if (m_new = m[TABLE_moduleinst =.. [ta]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) + ;; 7-module.watsup:28.1-33.60 + def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, ma : memaddr, memtype : memtype, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res + -- if (import = IMPORT(name, name', externtype)) + -- if (externtype = MEM_externtype(memtype)) + -- if (externval = MEM_externval(ma)) + -- if (m_new = m[MEM_moduleinst =.. [ma]]) + -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) +} + +;; 7-module.watsup:36.1-36.51 +rec { + +;; 7-module.watsup:36.1-36.51 +def alloc_func : (state, func*) -> (store, funcaddr*) + ;; 7-module.watsup:38.1-38.48 + def {f : frame, s : store} alloc_func(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:40.1-44.56 + def {f : frame, fa : funcaddr, fa'* : funcaddr*, fi : funcinst, func : func, func'* : func*, s : store, s_new : store, s_res : store} alloc_func(`%;%`(s, f), [func] :: func'*{func'}) = (s_res, [fa] :: fa'*{fa'}) + -- if (fi = {MODULE f.MODULE_frame, CODE func}) + -- if (fa = |$funcinst(`%;%`(s, f))|) + -- if (s_new = s[FUNC_store =.. [fi]]) + -- if ((s_res, fa'*{fa'}) = $alloc_func(`%;%`(s_new, f), func'*{func'})) +} + +;; 7-module.watsup:47.1-47.57 +rec { + +;; 7-module.watsup:47.1-47.57 +def alloc_global : (state, global*) -> (store, globaladdr*) + ;; 7-module.watsup:49.1-49.50 + def {f : frame, s : store} alloc_global(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:51.1-57.60 + def {f : frame, ga : globaladdr, ga'* : globaladdr*, gi : globalinst, global : global, global'* : global*, globaltype : globaltype, instr* : instr*, s : store, s_new : store, s_res : store, val : val} alloc_global(`%;%`(s, f), [global] :: global'*{global'}) = (s_res, [ga] :: ga'*{ga'}) + -- if (global = GLOBAL(globaltype, instr*{instr})) + -- Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr}), [$admininstr_val(val)]) + -- if (gi = {TYPE globaltype, VALUE val}) + -- if (ga = |$globalinst(`%;%`(s, f))|) + -- if (s_new = s[GLOBAL_store =.. [gi]]) + -- if ((s_res, ga'*{ga'}) = $alloc_global(`%;%`(s_new, f), global'*{global'})) +} + +;; 7-module.watsup:60.1-60.54 +rec { + +;; 7-module.watsup:60.1-60.54 +def alloc_table : (state, table*) -> (store, tableaddr*) + ;; 7-module.watsup:62.1-62.49 + def {f : frame, s : store} alloc_table(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:64.1-70.58 + def {f : frame, i : nat, j? : nat?, reftype : reftype, s : store, s_new : store, s_res : store, ta : tableaddr, ta'* : tableaddr*, table : table, table'* : table*, tabletype : tabletype, ti : tableinst} alloc_table(`%;%`(s, f), [table] :: table'*{table'}) = (s_res, [ta] :: ta'*{ta'}) + -- if (table = TABLE(tabletype)) + -- if (tabletype = `%%`(`[%..%?]`(i, j?{j}), reftype)) + -- if (ti = {TYPE tabletype, ELEM REF.NULL_ref(reftype)^i{}}) + -- if (ta = |$tableinst(`%;%`(s, f))|) + -- if (s_new = s[TABLE_store =.. [ti]]) + -- if ((s_res, ta'*{ta'}) = $alloc_table(`%;%`(s_new, f), table'*{table'})) +} + +;; 7-module.watsup:73.1-73.48 +rec { + +;; 7-module.watsup:73.1-73.48 +def alloc_mem : (state, mem*) -> (store, memaddr*) + ;; 7-module.watsup:75.1-75.47 + def {f : frame, s : store} alloc_mem(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:77.1-83.54 + def {f : frame, i : nat, j? : nat?, ma : memaddr, ma'* : memaddr*, mem : mem, mem'* : mem*, memtype : memtype, mi : meminst, s : store, s_new : store, s_res : store} alloc_mem(`%;%`(s, f), [mem] :: mem'*{mem'}) = (s_res, [ma] :: ma'*{ma'}) + -- if (mem = MEMORY(memtype)) + -- if (memtype = `%I8`(`[%..%?]`(i, j?{j}))) + -- if (mi = {TYPE memtype, DATA 0^((i * 64) * $Ki){}}) + -- if (ma = |$meminst(`%;%`(s, f))|) + -- if (s_new = s[MEM_store =.. [mi]]) + -- if ((s_res, ma'*{ma'}) = $alloc_mem(`%;%`(s_new, f), mem'*{mem'})) +} + +;; 7-module.watsup:86.1-86.51 +rec { + +;; 7-module.watsup:86.1-86.51 +def alloc_elem : (state, elem*) -> (store, elemaddr*) + ;; 7-module.watsup:88.1-88.48 + def {f : frame, s : store} alloc_elem(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:90.1-96.56 + def {ea : elemaddr, ea'* : elemaddr*, ei : eleminst, elem : elem, elem'* : elem*, elemmode? : elemmode?, f : frame, instr** : instr**, ref* : ref*, reftype : reftype, s : store, s_new : store, s_res : store} alloc_elem(`%;%`(s, f), [elem] :: elem'*{elem'}) = (s_res, [ea] :: ea'*{ea'}) + -- if (elem = `ELEM%%*%?`(reftype, instr*{instr}*{instr}, elemmode?{elemmode})) + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr}), [$admininstr_ref(ref)]))*{instr ref} + -- if (ei = {TYPE reftype, ELEM ref*{ref}}) + -- if (ea = |$eleminst(`%;%`(s, f))|) + -- if (s_new = s[ELEM_store =.. [ei]]) + -- if ((s_res, ea'*{ea'}) = $alloc_elem(`%;%`(s_new, f), elem'*{elem'})) +} + +;; 7-module.watsup:99.1-99.51 +rec { + +;; 7-module.watsup:99.1-99.51 +def alloc_data : (state, data*) -> (store, dataaddr*) + ;; 7-module.watsup:101.1-101.48 + def {f : frame, s : store} alloc_data(`%;%`(s, f), []) = (s, []) + ;; 7-module.watsup:103.1-108.56 + def {byte* : byte*, da : dataaddr, da'* : dataaddr*, data : data, data'* : data*, datamode? : datamode?, di : datainst, f : frame, s : store, s_new : store, s_res : store} alloc_data(`%;%`(s, f), [data] :: data'*{data'}) = (s_res, [da] :: da'*{da'}) + -- if (data = `DATA%*%?`(byte*{byte}, datamode?{datamode})) + -- if (di = {DATA byte*{byte}}) + -- if (da = |$datainst(`%;%`(s, f))|) + -- if (s_new = s[DATA_store =.. [di]]) + -- if ((s_res, da'*{da'}) = $alloc_data(`%;%`(s_new, f), data'*{data'})) +} + +;; 7-module.watsup:111.1-111.62 +rec { + +;; 7-module.watsup:111.1-111.62 +def replace_moduleinst : (store, funcaddr*, moduleinst) -> store + ;; 7-module.watsup:113.1-113.43 + def {m : moduleinst, s : store} replace_moduleinst(s, [], m) = s + ;; 7-module.watsup:115.1-117.52 + def {fa : funcaddr, fa'* : funcaddr*, m : moduleinst, s : store, s_new : store, s_res : store} replace_moduleinst(s, [fa] :: fa'*{fa'}, m) = s_res + -- if (s_new = s[FUNC_store[fa].MODULE_funcinst = m]) + -- if (s_res = $replace_moduleinst(s_new, fa'*{fa'}, m)) +} + +;; 7-module.watsup:120.1-120.51 +def alloc_export : (moduleinst, export) -> exportinst + ;; 7-module.watsup:122.1-126.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = FUNC_externuse(x)) + -- if (externval = FUNC_externval(m.FUNC_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + ;; 7-module.watsup:128.1-132.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = GLOBAL_externuse(x)) + -- if (externval = GLOBAL_externval(m.GLOBAL_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + ;; 7-module.watsup:134.1-138.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = TABLE_externuse(x)) + -- if (externval = TABLE_externval(m.TABLE_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + ;; 7-module.watsup:140.1-144.44 + def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi + -- if (export = EXPORT(name, externuse)) + -- if (externuse = MEM_externuse(x)) + -- if (externval = MEM_externval(m.MEM_moduleinst[x])) + -- if (xi = {NAME name, VALUE externval}) + +;; 7-module.watsup:147.1-147.67 +def alloc_module : (store, module, externval*) -> (store, moduleinst) + ;; 7-module.watsup:149.1-163.56 + def {da* : dataaddr*, data* : data*, ea* : elemaddr*, elem* : elem*, export* : export*, externval* : externval*, f : frame, fa* : funcaddr*, func* : func*, ga* : globaladdr*, global* : global*, import* : import*, m_ex : moduleinst, m_im : moduleinst, m_init : moduleinst, m_res : moduleinst, ma* : memaddr*, mem* : mem*, module : module, s : store, s_data : store, s_elem : store, s_func : store, s_global : store, s_mem : store, s_res : store, s_table : store, start? : start?, ta* : tableaddr*, table* : table*, xi* : exportinst*} alloc_module(s, module, externval*{externval}) = (s_res, m_res) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) + -- if (m_init = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (m_im = $alloc_import(m_init, import*{import}, externval*{externval})) + -- if (f = {LOCAL [], MODULE m_im}) + -- if ((s_func, fa*{fa}) = $alloc_func(`%;%`(s, f), func*{func})) + -- if ((s_global, ga*{ga}) = $alloc_global(`%;%`(s_func, f), global*{global})) + -- if ((s_table, ta*{ta}) = $alloc_table(`%;%`(s_global, f), table*{table})) + -- if ((s_mem, ma*{ma}) = $alloc_mem(`%;%`(s_table, f), mem*{mem})) + -- if ((s_elem, ea*{ea}) = $alloc_elem(`%;%`(s_mem, f), elem*{elem})) + -- if ((s_data, da*{da}) = $alloc_data(`%;%`(s_elem, f), data*{data})) + -- if (m_ex = m_im ++ {FUNC fa*{fa}, GLOBAL ga*{ga}, TABLE ta*{ta}, MEM ma*{ma}, ELEM ea*{ea}, DATA da*{da}, EXPORT []}) + -- if (xi*{xi} = $alloc_export(m_ex, export)*{export}) + -- if (m_res = m_ex[EXPORT_moduleinst = xi*{xi}]) + -- if (s_res = $replace_moduleinst(s_data, fa*{fa}, m_res)) + +;; 7-module.watsup:166.1-166.41 +rec { + +;; 7-module.watsup:166.1-166.41 +def run_elem : (state, elem*, idx) -> state + ;; 7-module.watsup:168.1-168.41 + def {f : frame, i : nat, s : store} run_elem(`%;%`(s, f), [], i) = `%;%`(s, f) + ;; 7-module.watsup:170.1-172.59 + def {elem : elem, elem'* : elem*, expr* : expr*, f : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) + -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?())) + -- if ($run_elem(`%;%`(s, f), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:174.1-179.67 + def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, reftype : reftype, s : store, s_new : store, s_res : store, x : idx} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) + -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) + -- if (n = |expr*{expr}|) + -- if (elemmode = TABLE_elemmode(x, instr*{instr})) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, i) ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) + -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:181.1-185.67 + def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_new : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) + -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) + -- if (elemmode = DECLARE_elemmode) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), [ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) + -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) +} + +;; 7-module.watsup:188.1-188.41 +rec { + +;; 7-module.watsup:188.1-188.41 +def run_data : (state, data*, idx) -> state + ;; 7-module.watsup:190.1-190.41 + def {f : frame, i : nat, s : store} run_data(`%;%`(s, f), [], i) = `%;%`(s, f) + ;; 7-module.watsup:192.1-194.59 + def {byte* : byte*, data : data, data'* : data*, f : frame, f_res : frame, i : nat, s : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) + -- if (data = `DATA%*%?`(byte*{byte}, ?())) + -- if ($run_data(`%;%`(s, f), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:196.1-201.67 + def {byte* : byte*, data : data, data'* : data*, datamode : datamode, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, s : store, s_new : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) + -- if (data = `DATA%*%?`(byte*{byte}, ?(datamode))) + -- if (n = |byte*{byte}|) + -- if (datamode = MEMORY_datamode(0, instr*{instr})) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(i) DATA.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) + -- if ($run_data(`%;%`(s_new, f_new), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) +} + +;; 7-module.watsup:206.1-206.68 +def instantiation : (store, module, externval*) -> (store, moduleinst) + ;; 7-module.watsup:208.1-213.61 + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(), export*{export})) + -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) + -- if (f = {LOCAL [], MODULE m}) + -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_res, f_res)) + ;; 7-module.watsup:215.1-222.62 + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(start), export*{export})) + -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) + -- if (f = {LOCAL [], MODULE m}) + -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_data, f_data)) + -- if (start = START(x)) + -- Step: `%~>%`(`%;%*`(`%;%`(s_data, f_data), [CALL_admininstr(x)]), `%;%*`(`%;%`(s_res, f_res), [])) + +;; 7-module.watsup:227.1-227.55 +def invocation : (store, funcaddr, val*) -> (store, val*) + ;; 7-module.watsup:229.1-236.55 + def {expr : expr, f : frame, f' : frame, fa : funcaddr, functype : functype, m : moduleinst, s : store, s' : store, val* : val*, val'* : val*, valtype* : valtype*, valtype'* : valtype*} invocation(s, fa, val*{val}) = (s', val'*{val'}) + -- if (m = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f = {LOCAL [], MODULE m}) + -- if ($funcinst(`%;%`(s, f))[fa].CODE_funcinst = `FUNC%%*%`(functype, valtype*{valtype}, expr)) + -- if (functype = `%->%`(valtype*{valtype}, valtype'*{valtype'})) + -- if (|val*{val}| = |valtype*{valtype}|) + -- if (|val'*{val'}| = |valtype'*{valtype'}|) + -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_val(val)*{val} :: [CALL_ADDR_admininstr(fa)]), `%;%*`(`%;%`(s', f'), $admininstr_val(val')*{val'})) + == IL Validation... == Complete. ``` From 9b3e6e33684000bba3f45692852092874cc8e1bd Mon Sep 17 00:00:00 2001 From: Wonho Date: Mon, 26 Jun 2023 14:47:16 +0900 Subject: [PATCH 16/49] Fix typo in instantiation --- spectec/spec/7-module.watsup | 4 +-- spectec/test-frontend/TEST.md | 12 ++++---- spectec/test-middlend/TEST.md | 56 +++++++++++++++++------------------ 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/spectec/spec/7-module.watsup b/spectec/spec/7-module.watsup index 1dea48e598..5b2fededc4 100644 --- a/spectec/spec/7-module.watsup +++ b/spectec/spec/7-module.watsup @@ -209,14 +209,14 @@ def $instantiation(s, module, externval*) = (s_res, m) -- if module = MODULE import* func* global* table* mem* elem* data* export* -- if (s_alloc, m) = $alloc_module(s, module, externval*) -- if f = { LOCAL epsilon, MODULE m } - -- if $run_elem((s_alloc; f_alloc), elem*, 0) = s_elem; f_elem + -- if $run_elem((s_alloc; f), elem*, 0) = s_elem; f_elem -- if $run_data((s_elem; f_elem), data*, 0) = s_res; f_res def $instantiation(s, module, externval*) = (s_res, m) -- if module = MODULE import* func* global* table* mem* elem* data* start export* -- if (s_alloc, m) = $alloc_module(s, module, externval*) -- if f = { LOCAL epsilon, MODULE m } - -- if $run_elem((s_alloc; f_alloc), elem*, 0) = s_elem; f_elem + -- if $run_elem((s_alloc; f), elem*, 0) = s_elem; f_elem -- if $run_data((s_elem; f_elem), data*, 0) = s_data; f_data -- if start = START x -- Step : s_data; f_data; (CALL x) ~> s_res; f_res; epsilon diff --git a/spectec/test-frontend/TEST.md b/spectec/test-frontend/TEST.md index 75aa963b32..4fc0b320d6 100644 --- a/spectec/test-frontend/TEST.md +++ b/spectec/test-frontend/TEST.md @@ -1927,18 +1927,18 @@ def run_data : (state, data*, idx) -> state ;; 7-module.watsup:206.1-206.68 def instantiation : (store, module, externval*) -> (store, moduleinst) ;; 7-module.watsup:208.1-213.61 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(), export*{export})) -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_res, f_res)) ;; 7-module.watsup:215.1-222.62 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(start), export*{export})) -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_data, f_data)) -- if (start = START(x)) -- Step: `%~>%`(`%;%*`(`%;%`(s_data, f_data), [CALL_admininstr(x)]), `%;%*`(`%;%`(s_res, f_res), [])) @@ -4355,14 +4355,14 @@ $$ &&&&\quad {\land}~(\mathit{s}_{\mathit{alloc}},\, \mathit{m}) = \mathrm{alloc}_{\mathit{module}}(\mathit{s},\, \mathit{module},\, {\mathit{externval}^\ast}) \\ &&&&\quad {\land}~\mathit{f} = \{ \begin{array}[t]{@{}l@{}} \mathsf{local}~\epsilon,\; \mathsf{module}~\mathit{m} \}\end{array} \\ - &&&&\quad {\land}~\mathrm{run}_{\mathit{elem}}((\mathit{s}_{\mathit{alloc}} ; \mathit{f}_{\mathit{alloc}}),\, {\mathit{elem}^\ast},\, 0) = \mathit{s}_{\mathit{elem}} ; \mathit{f}_{\mathit{elem}} \\ + &&&&\quad {\land}~\mathrm{run}_{\mathit{elem}}((\mathit{s}_{\mathit{alloc}} ; \mathit{f}),\, {\mathit{elem}^\ast},\, 0) = \mathit{s}_{\mathit{elem}} ; \mathit{f}_{\mathit{elem}} \\ &&&&\quad {\land}~\mathrm{run}_{\mathit{data}}((\mathit{s}_{\mathit{elem}} ; \mathit{f}_{\mathit{elem}}),\, {\mathit{data}^\ast},\, 0) = \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} \\ \mathrm{instantiation}(\mathit{s},\, \mathit{module},\, {\mathit{externval}^\ast}) &=& (\mathit{s}_{\mathit{res}},\, \mathit{m}) &\quad \mbox{if}~\mathit{module} = \mathsf{module}~{\mathit{import}^\ast}~{\mathit{func}^\ast}~{\mathit{global}^\ast}~{\mathit{table}^\ast}~{\mathit{mem}^\ast}~{\mathit{elem}^\ast}~{\mathit{data}^\ast}~\mathit{start}~{\mathit{export}^\ast} \\ &&&&\quad {\land}~(\mathit{s}_{\mathit{alloc}},\, \mathit{m}) = \mathrm{alloc}_{\mathit{module}}(\mathit{s},\, \mathit{module},\, {\mathit{externval}^\ast}) \\ &&&&\quad {\land}~\mathit{f} = \{ \begin{array}[t]{@{}l@{}} \mathsf{local}~\epsilon,\; \mathsf{module}~\mathit{m} \}\end{array} \\ - &&&&\quad {\land}~\mathrm{run}_{\mathit{elem}}((\mathit{s}_{\mathit{alloc}} ; \mathit{f}_{\mathit{alloc}}),\, {\mathit{elem}^\ast},\, 0) = \mathit{s}_{\mathit{elem}} ; \mathit{f}_{\mathit{elem}} \\ + &&&&\quad {\land}~\mathrm{run}_{\mathit{elem}}((\mathit{s}_{\mathit{alloc}} ; \mathit{f}),\, {\mathit{elem}^\ast},\, 0) = \mathit{s}_{\mathit{elem}} ; \mathit{f}_{\mathit{elem}} \\ &&&&\quad {\land}~\mathrm{run}_{\mathit{data}}((\mathit{s}_{\mathit{elem}} ; \mathit{f}_{\mathit{elem}}),\, {\mathit{data}^\ast},\, 0) = \mathit{s}_{\mathit{data}} ; \mathit{f}_{\mathit{data}} \\ &&&&\quad {\land}~\mathit{start} = \mathsf{start}~\mathit{x} \\ &&&&\quad {\land}~\mathit{s}_{\mathit{data}} ; \mathit{f}_{\mathit{data}} ; (\mathsf{call}~\mathit{x}) \hookrightarrow \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} ; \epsilon \\ diff --git a/spectec/test-middlend/TEST.md b/spectec/test-middlend/TEST.md index 89ed831ebf..e60ed580bb 100644 --- a/spectec/test-middlend/TEST.md +++ b/spectec/test-middlend/TEST.md @@ -1926,18 +1926,18 @@ def run_data : (state, data*, idx) -> state ;; 7-module.watsup:206.1-206.68 def instantiation : (store, module, externval*) -> (store, moduleinst) ;; 7-module.watsup:208.1-213.61 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(), export*{export})) -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_res, f_res)) ;; 7-module.watsup:215.1-222.62 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(start), export*{export})) -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_data, f_data)) -- if (start = START(x)) -- Step: `%~>%`(`%;%*`(`%;%`(s_data, f_data), [CALL_admininstr(x)]), `%;%*`(`%;%`(s_res, f_res), [])) @@ -3964,18 +3964,18 @@ def run_data : (state, data*, idx) -> state ;; 7-module.watsup:206.1-206.68 def instantiation : (store, module, externval*) -> (store, moduleinst) ;; 7-module.watsup:208.1-213.61 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(), export*{export})) -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_res, f_res)) ;; 7-module.watsup:215.1-222.62 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(start), export*{export})) -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_data, f_data)) -- if (start = START(x)) -- Step: `%~>%`(`%;%*`(`%;%`(s_data, f_data), [CALL_admininstr(x)]), `%;%*`(`%;%`(s_res, f_res), [])) @@ -6004,18 +6004,18 @@ def run_data : (state, data*, idx) -> state ;; 7-module.watsup:206.1-206.68 def instantiation : (store, module, externval*) -> (store, moduleinst) ;; 7-module.watsup:208.1-213.61 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(), export*{export})) -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_res, f_res)) ;; 7-module.watsup:215.1-222.62 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(start), export*{export})) -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_data, f_data)) -- if (start = START(x)) -- Step: `%~>%`(`%;%*`(`%;%`(s_data, f_data), [CALL_admininstr(x)]), `%;%*`(`%;%`(s_res, f_res), [])) @@ -8063,18 +8063,18 @@ def run_data : (state, data*, idx) -> state ;; 7-module.watsup:206.1-206.68 def instantiation : (store, module, externval*) -> (store, moduleinst) ;; 7-module.watsup:208.1-213.61 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(), export*{export})) -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_res, f_res)) ;; 7-module.watsup:215.1-222.62 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(start), export*{export})) -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_data, f_data)) -- if (start = START(x)) -- Step: `%~>%`(`%;%*`(`%;%`(s_data, f_data), [CALL_admininstr(x)]), `%;%*`(`%;%`(s_res, f_res), [])) @@ -10122,18 +10122,18 @@ def run_data : (state, data*, idx) -> state ;; 7-module.watsup:206.1-206.68 def instantiation : (store, module, externval*) -> (store, moduleinst) ;; 7-module.watsup:208.1-213.61 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(), export*{export})) -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_res, f_res)) ;; 7-module.watsup:215.1-222.62 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(start), export*{export})) -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_data, f_data)) -- if (start = START(x)) -- Step: `%~>%`(`%;%*`(`%;%`(s_data, f_data), [CALL_admininstr(x)]), `%;%*`(`%;%`(s_res, f_res), [])) @@ -12237,18 +12237,18 @@ def run_data : (state, data*, idx) -> state ;; 7-module.watsup:206.1-206.68 def instantiation : (store, module, externval*) -> (store, moduleinst) ;; 7-module.watsup:208.1-213.61 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(), export*{export})) -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_res, f_res)) ;; 7-module.watsup:215.1-222.62 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(start), export*{export})) -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_data, f_data)) -- if (start = START(x)) -- Step: `%~>%`(`%;%*`(`%;%`(s_data, f_data), [CALL_admininstr(x)]), `%;%*`(`%;%`(s_res, f_res), [])) @@ -14355,18 +14355,18 @@ def run_data : (state, data*, idx) -> state ;; 7-module.watsup:206.1-206.68 def instantiation : (store, module, externval*) -> (store, moduleinst) ;; 7-module.watsup:208.1-213.61 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(), export*{export})) -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_res, f_res)) ;; 7-module.watsup:215.1-222.62 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_alloc : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) + def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(start), export*{export})) -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f_alloc), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) + -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_data, f_data)) -- if (start = START(x)) -- Step: `%~>%`(`%;%*`(`%;%`(s_data, f_data), [CALL_admininstr(x)]), `%;%*`(`%;%`(s_res, f_res), [])) From 030a3a86f26961e532d2cb34cfa9da3acd32e166 Mon Sep 17 00:00:00 2001 From: Wonho Date: Wed, 28 Jun 2023 16:17:53 +0900 Subject: [PATCH 17/49] Update grow helper functions --- spectec/spec/1-syntax.watsup | 2 +- spectec/spec/4-runtime.watsup | 15 +++++++++------ spectec/spec/6-reduction.watsup | 12 ++++-------- spectec/spec/7-module.watsup | 4 ++-- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/spectec/spec/1-syntax.watsup b/spectec/spec/1-syntax.watsup index 2780ae5170..9b13a6c93f 100644 --- a/spectec/spec/1-syntax.watsup +++ b/spectec/spec/1-syntax.watsup @@ -57,7 +57,7 @@ syntax resulttype hint(desc "result type") = valtype* syntax limits hint(desc "limits") = - `[u32 .. u32?] + `[u32 .. u32] syntax globaltype hint(desc "global type") = MUT? valtype syntax functype hint(desc "function type") = diff --git a/spectec/spec/4-runtime.watsup b/spectec/spec/4-runtime.watsup index f70f7e0b67..8d6d7af442 100644 --- a/spectec/spec/4-runtime.watsup +++ b/spectec/spec/4-runtime.watsup @@ -164,16 +164,19 @@ def $with_meminst((s; f), x, mi) = s[.MEM[f.MODULE.MEM[x]] = mi]; f def $with_elem((s; f), x, r*) = s[.ELEM[f.MODULE.ELEM[x]].ELEM = r*]; f def $with_data((s; f), x, b*) = s[.DATA[f.MODULE.DATA[x]].DATA = b*]; f -def $grow_table(tableinst, nat, ref) : tableinst -def $grow_memory(meminst, nat) : meminst +def $grow_table(tableinst, nat, ref) : tableinst hint(partial) +def $grow_memory(meminst, nat) : meminst hint(partial) + def $grow_table(ti, n, r) = ti' - -- if ti = { TYPE `[i .. j?] reftype, ELEM r'* } + -- if ti = { TYPE `[i .. j] rt, ELEM r'* } -- if i' = $(|r'*| + n) - -- if ti' = { TYPE `[i' .. j?] reftype, ELEM r'* r^n } + -- if ti' = { TYPE `[i' .. j] rt, ELEM r'* r^n } + -- Tabletype_ok: |- ti'.TYPE : OK def $grow_memory(mi, n) = mi' - -- if mi = { TYPE (`[i .. j?] I8), DATA b* } + -- if mi = { TYPE (`[i .. j] I8), DATA b* } -- if i' = $(|b*| / (64 * $Ki) + n) - -- if mi' = { TYPE (`[i' .. j?] I8), DATA b* 0^(n * 64 * $Ki) } + -- if mi' = { TYPE (`[i' .. j] I8), DATA b* 0^(n * 64 * $Ki) } + -- Memtype_ok: |- mi'.TYPE : OK ;; Administrative Instructions diff --git a/spectec/spec/6-reduction.watsup b/spectec/spec/6-reduction.watsup index b987bc51da..54471a1baf 100644 --- a/spectec/spec/6-reduction.watsup +++ b/spectec/spec/6-reduction.watsup @@ -202,10 +202,8 @@ rule Step_read/table.size: rule Step/table.grow-succeed: - z; ref (CONST I32 n) (TABLE.GROW x) ~> $with_tableinst(z, x, ti'); (CONST I32 $(|$table(z, x).ELEM|)) - -- if $table(z, x) = ti - -- if $grow_table(ti, n, ref) = ti' - -- Tabletype_ok: |- ti'.TYPE : OK + z; ref (CONST I32 n) (TABLE.GROW x) ~> $with_tableinst(z, x, ti); (CONST I32 $(|$table(z, x).ELEM|)) + -- if $grow_table($table(z, x), n, ref) = ti rule Step/table.grow-fail: z; ref (CONST I32 n) (TABLE.GROW x) ~> z; (CONST I32 $(-1)) @@ -310,10 +308,8 @@ rule Step_read/memory.size: rule Step/memory.grow-succeed: - z; (CONST I32 n) (MEMORY.GROW) ~> $with_meminst(z, 0, mi'); (CONST I32 $(|$mem(z, 0).DATA| / (64 * $Ki))) - -- if $mem(z, 0) = mi - -- if $grow_memory(mi, n) = mi' - -- Memtype_ok: |- mi'.TYPE : OK + z; (CONST I32 n) (MEMORY.GROW) ~> $with_meminst(z, 0, mi); (CONST I32 $(|$mem(z, 0).DATA| / (64 * $Ki))) + -- if $grow_memory($mem(z, 0), n) = mi rule Step/memory.grow-fail: z; (CONST I32 n) (MEMORY.GROW) ~> z; (CONST I32 $(-1)) diff --git a/spectec/spec/7-module.watsup b/spectec/spec/7-module.watsup index 5b2fededc4..f82b9a177e 100644 --- a/spectec/spec/7-module.watsup +++ b/spectec/spec/7-module.watsup @@ -63,7 +63,7 @@ def $alloc_table((s; f), epsilon) = (s, epsilon) def $alloc_table((s; f), table table'*) = (s_res, ta ta'*) -- if table = TABLE tabletype - -- if tabletype = `[i .. j?] reftype + -- if tabletype = `[i .. j] reftype -- if ti = { TYPE tabletype, ELEM (REF.NULL reftype)^i } -- if ta = |$tableinst((s; f))| -- if s_new = s[.TABLE =.. ti] @@ -76,7 +76,7 @@ def $alloc_mem((s; f), epsilon) = (s, epsilon) def $alloc_mem((s; f), mem mem'*) = (s_res, ma ma'*) -- if mem = MEMORY memtype - -- if memtype = `[i .. j?] I8 + -- if memtype = `[i .. j] I8 -- if mi = { TYPE memtype, DATA 0^(i * 64 * $Ki()) } -- if ma = |$meminst((s; f))| -- if s_new = s[.MEM =.. mi] From d9671071006b8827d36e3ddeb068b16f84567acd Mon Sep 17 00:00:00 2001 From: ShinWonho <50018375+ShinWonho@users.noreply.github.com> Date: Wed, 28 Jun 2023 15:26:36 +0900 Subject: [PATCH 18/49] Update spectec/src/frontend/elab.ml Co-authored-by: Andreas Rossberg --- spectec/src/frontend/elab.ml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spectec/src/frontend/elab.ml b/spectec/src/frontend/elab.ml index 0676b79153..4cebbc6ecd 100644 --- a/spectec/src/frontend/elab.ml +++ b/spectec/src/frontend/elab.ml @@ -1042,11 +1042,10 @@ let elab_def env d : Il.def list = let e2' = Multiplicity.annot_exp dims' (elab_exp env e2 t2) in let prems' = List.map (Multiplicity.annot_prem dims') (map_nl_list (elab_prem env) prems) in - let free_prems = - List.filter_map (function Nl -> None | Elem e -> Some e) prems - |> Free.(free_list free_prem) in let free_rh = - Free.(Set.diff (Set.diff (free_exp e2).varid (free_exp e1).varid) free_prems.varid) in + Free.(Set.diff (Set.diff (free_exp e2).varid + (free_exp e1).varid) (free_list free_prem (filter_nl prems)).varid) + in if free_rh <> Free.Set.empty then error d.at ("definition contains unbound variable(s) `" ^ String.concat "`, `" (Free.Set.elements free_rh) ^ "`"); From 8f6c59040b025b345d2778e679cb86d8b309f8c5 Mon Sep 17 00:00:00 2001 From: ShinWonho <50018375+ShinWonho@users.noreply.github.com> Date: Wed, 28 Jun 2023 15:26:45 +0900 Subject: [PATCH 19/49] Update spectec/src/il/validation.ml Co-authored-by: Andreas Rossberg --- spectec/src/il/validation.ml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spectec/src/il/validation.ml b/spectec/src/il/validation.ml index 4a3994359c..7703a0f951 100644 --- a/spectec/src/il/validation.ml +++ b/spectec/src/il/validation.ml @@ -524,9 +524,10 @@ let valid_clause env t1 t2 clause = valid_exp env e2 t2; List.iter (valid_prem env) prems; env.vars <- Env.empty; - let free_prems = Free.(free_list free_prem prems) in let free_rh = - Free.(Set.diff (Set.diff (free_exp e2).varid (free_exp e1).varid) free_prems.varid) in + Free.(Set.diff (Set.diff (free_exp e2).varid + (free_exp e1).varid) (free_list free_prem prems).varid) + in if free_rh <> Free.Set.empty then error clause.at ("definition contains unbound variable(s) `" ^ String.concat "`, `" (Free.Set.elements free_rh) ^ "`") From 0f48772bcdeee38a6d2b22362974f6441af9e47d Mon Sep 17 00:00:00 2001 From: Wonho Date: Thu, 29 Jun 2023 17:36:50 +0900 Subject: [PATCH 20/49] Refactor module semantics --- spectec/spec/7-module.watsup | 262 +++++++++-------------------------- 1 file changed, 67 insertions(+), 195 deletions(-) diff --git a/spectec/spec/7-module.watsup b/spectec/spec/7-module.watsup index f82b9a177e..06e3c179c9 100644 --- a/spectec/spec/7-module.watsup +++ b/spectec/spec/7-module.watsup @@ -1,236 +1,108 @@ ;; Allocation -def $alloc_import(moduleinst, import*, externval*) : moduleinst -def $alloc_import(m, epsilon, epsilon) = m +def $funcs(externval*) : funcaddr* +def $globals(externval*) : globaladdr* +def $tables(externval*) : tableaddr* +def $mems(externval*) : memaddr* -def $alloc_import(m, import import'*, externval externval'*) = m_res - -- if import = IMPORT name name' externtype - -- if externtype = FUNC functype - -- if externval = FUNC fa - -- if m_new = m[.FUNC =.. fa] - -- if m_res = $alloc_import(m_new, import'*, externval'*) +def $funcs(externval*) = [fa|FUNC fa ∈ externval] +def $globals(externval*) = [ga|GLOBAL ga ∈ externval] +def $tables(externval*) = [ta|TABLE ta ∈ externval] +def $mems(externval*) = [ma|MEM ma ∈ externval] -def $alloc_import(m, import import'*, externval externval'*) = m_res - -- if import = IMPORT name name' externtype - -- if externtype = GLOBAL globaltype - -- if externval = GLOBAL ga - -- if m_new = m[.GLOBAL =.. ga] - -- if m_res = $alloc_import(m_new, import'*, externval'*) -def $alloc_import(m, import import'*, externval externval'*) = m_res - -- if import = IMPORT name name' externtype - -- if externtype = TABLE tabletype - -- if externval = TABLE ta - -- if m_new = m[.TABLE =.. ta] - -- if m_res = $alloc_import(m_new, import'*, externval'*) +def $instantiate_export(funcaddr*, globaladdr*, tableaddr*, memaddr*, name, externuse) : exportinst +def $instantiate_export(fa*, ga*, ta*, ma*, EXPORT name (FUNC x)) = { NAME name, VALUE (FUNC fa*[x]) } +def $instantiate_export(fa*, ga*, ta*, ma*, EXPORT name (GLOBAL x)) = { NAME name, VALUE (GLOBAL ga*[x]) } +def $instantiate_export(fa*, ga*, ta*, ma*, EXPORT name (TABLE x)) = { NAME name, VALUE (TABLE ta*[x]) } +def $instantiate_export(fa*, ga*, ta*, ma*, EXPORT name (MEM x)) = { NAME name, VALUE (MEM ma*[x]) } -def $alloc_import(m, import import'*, externval externval'*) = m_res - -- if import = IMPORT name name' externtype - -- if externtype = MEM memtype - -- if externval = MEM ma - -- if m_new = m[.MEM =.. ma] - -- if m_res = $alloc_import(m_new, import'*, externval'*) +def $alloc_func(store, moduleinst func) : store +def $alloc_global(store, global, val) : store +def $alloc_table(store, table) : store +def $alloc_mem(store, mem) : store +def $alloc_elem(store, elem, ref*) : store +def $alloc_data(store, data) : store -def $alloc_func(state, func*) : (store, funcaddr*) +def $alloc_func(s, m, func) = s.[.FUNC =.. fi] + -- if fi = { MODULE m, CODE func } -def $alloc_func((s; f), epsilon) = (s, epsilon) - -def $alloc_func((s; f), func func'*) = (s_res, fa fa'*) - -- if fi = { MODULE f.MODULE, CODE func } - -- if fa = |$funcinst((s; f))| - -- if s_new = s[.FUNC =.. fi] - -- if (s_res, fa'*) = $alloc_func((s_new; f), func'*) - - -def $alloc_global(state, global*) : (store, globaladdr*) - -def $alloc_global((s; f), epsilon) = (s, epsilon) - -def $alloc_global((s; f), global global'*) = (s_res, ga ga'*) - -- if global = GLOBAL globaltype instr* - -- Step_read : s; f; instr* ~> val +def $alloc_global(s, GLOBAL globaltype instr*, val) = s[.GLOBAL =.. gi] -- if gi = { TYPE globaltype, VALUE val } - -- if ga = |$globalinst((s; f))| - -- if s_new = s[.GLOBAL =.. gi] - -- if (s_res, ga'*) = $alloc_global((s_new; f), global'*) - - -def $alloc_table(state, table*) : (store, tableaddr*) - -def $alloc_table((s; f), epsilon) = (s, epsilon) - -def $alloc_table((s; f), table table'*) = (s_res, ta ta'*) - -- if table = TABLE tabletype - -- if tabletype = `[i .. j] reftype - -- if ti = { TYPE tabletype, ELEM (REF.NULL reftype)^i } - -- if ta = |$tableinst((s; f))| - -- if s_new = s[.TABLE =.. ti] - -- if (s_res, ta'*) = $alloc_table((s_new; f), table'*) +def $alloc_table(s, TABLE tabletype) = s[.TABLE =.. ti] + -- if tabletype = `[i .. j] rt + -- if ti = { TYPE tabletype, ELEM (REF.NULL rt)^i } -def $alloc_mem(state, mem*) : (store, memaddr*) - -def $alloc_mem((s; f), epsilon) = (s, epsilon) - -def $alloc_mem((s; f), mem mem'*) = (s_res, ma ma'*) - -- if mem = MEMORY memtype +def $alloc_mem(s, MEMORY memtype) = s[.MEM =.. mi] -- if memtype = `[i .. j] I8 -- if mi = { TYPE memtype, DATA 0^(i * 64 * $Ki()) } - -- if ma = |$meminst((s; f))| - -- if s_new = s[.MEM =.. mi] - -- if (s_res, ma'*) = $alloc_mem((s_new; f), mem'*) - - -def $alloc_elem(state, elem*) : (store, elemaddr*) - -def $alloc_elem((s; f), epsilon) = (s, epsilon) - -def $alloc_elem((s; f), elem elem'*) = (s_res, ea ea'*) - -- if elem = ELEM reftype (instr*)* elemmode? - -- (Step_read : s; f; instr* ~> ref)* - -- if ei = { TYPE reftype, ELEM ref* } - -- if ea = |$eleminst((s; f))| - -- if s_new = s[.ELEM =.. ei] - -- if (s_res, ea'*) = $alloc_elem((s_new; f), elem'*) - - -def $alloc_data(state, data*) : (store, dataaddr*) -def $alloc_data((s; f), epsilon) = (s, epsilon) +def $alloc_elem(s, ELEM rt (instr*)* elemode?, ref*) = s[.ELEM =.. ei] + -- if ei = { TYPE rt, ELEM ref* } -def $alloc_data((s; f), data data'*) = (s_res, da da'*) - -- if data = DATA byte* datamode? +def $alloc_data(s, DATA byte* datamode?) = s[.DATA =.. di] -- if di = { DATA byte* } - -- if da = |$datainst((s; f))| - -- if s_new = s[.DATA =.. di] - -- if (s_res, da'*) = $alloc_data((s_new; f), data'*) -def $replace_moduleinst(store, funcaddr*, moduleinst) : store +def $alloc_module(store, module, externval*, val*, (ref*)*) : (store, moduleinst) -def $replace_moduleinst(s, epsilon, m) = s - -def $replace_moduleinst(s, fa fa'*, m) = s_res - -- if s_new = s[.FUNC[fa].MODULE = m] - -- if s_res = $replace_moduleinst(s_new, fa'*, m) - - -def $alloc_export(moduleinst, export) : exportinst - -def $alloc_export(m, export) = xi - -- if export = EXPORT name externuse - -- if externuse = FUNC x - -- if externval = FUNC m.FUNC[x] - -- if xi = { NAME name, VALUE externval } - -def $alloc_export(m, export) = xi - -- if export = EXPORT name externuse - -- if externuse = GLOBAL x - -- if externval = GLOBAL m.GLOBAL[x] - -- if xi = { NAME name, VALUE externval } - -def $alloc_export(m, export) = xi - -- if export = EXPORT name externuse - -- if externuse = TABLE x - -- if externval = TABLE m.TABLE[x] - -- if xi = { NAME name, VALUE externval } - -def $alloc_export(m, export) = xi - -- if export = EXPORT name externuse - -- if externuse = MEM x - -- if externval = MEM m.MEM[x] - -- if xi = { NAME name, VALUE externval } - - -def $alloc_module(store, module, externval*) : (store, moduleinst) - -def $alloc_module(s, module, externval*) = (s_res, m_res) +def $alloc_module(s, module, externval*, val*, (ref*)*) = (s_6, m) -- if module = MODULE import* func* global* table* mem* elem* data* start? export* - -- if m_init = { FUNC epsilon, GLOBAL epsilon, TABLE epsilon, MEM epsilon, ELEM epsilon, DATA epsilon, EXPORT epsilon } - -- if m_im = $alloc_import(m_init, import*, externval*) - -- if f = { LOCAL epsilon, MODULE m_im } - -- if (s_func, fa*) = $alloc_func((s; f), func*) - -- if (s_global, ga*) = $alloc_global((s_func; f), global*) - -- if (s_table, ta*) = $alloc_table((s_global; f), table*) - -- if (s_mem, ma*) = $alloc_mem((s_table; f), mem*) - -- if (s_elem, ea*) = $alloc_elem((s_mem; f), elem*) - -- if (s_data, da*) = $alloc_data((s_elem; f), data*) - -- if m_ex = m_im ++ { FUNC fa*, GLOBAL ga*, TABLE ta*, MEM ma*, ELEM ea*, DATA da*, EXPORT epsilon } - -- if xi* = $alloc_export(m_ex, export)* - -- if m_res = m_ex[.EXPORT = xi*] - -- if s_res = $replace_moduleinst(s_data, fa*, m_res) - - -def $run_elem(state, elem*, idx) : state - -def $run_elem((s; f), epsilon, i) = s; f + -- if fa* = $funcs(externval*) (|s.FUNC| ... $(|s.FUNC| + |func*| - 1)) + -- if ga* = $globals(externval*) (|s.GLOBAL| ... $(|s.GLOBAL| + |global*| - 1)) + -- if ta* = $tables(externval*) (|s.TABLE| ... $(|s.TABLE| + |table*| - 1)) + -- if ma* = $mems(externval*) (|s.MEM| ... $(|s.MEM| + |mem*| - 1)) + -- if ea* = |s.ELEM| ... $(|s.ELEM| + |elem*| - 1) + -- if da* = |s.DATA| ... $(|s.DATA| + |data*| - 1) + -- if xi* = $instantiate_export(fa*, ga*, ta*, ma*, export)* + -- if m = { FUNC fa*, GLOBAL ga*, TABLE ta*, MEM ma*, ELEM ea*, DATA da*, EXPORT xi* } + -- if s_1 = $alloc_func*(s, m, func*) + -- if s_2 = $alloc_global*(s_1, global, val*) + -- if s_3 = $alloc_table*(s_2, table*) + -- if s_4 = $alloc_mem*(s_3, mem*) + -- if s_5 = $alloc_elem*(s_4, (ref*)*) + -- if s_6 = $alloc_data*(s_5, data*) -def $run_elem((s; f), elem elem'*, i) = s_res; f_res - -- if elem = ELEM reftype expr* - -- if $run_elem((s; f), elem'*, $(i + 1)) = s_res; f_res -def $run_elem((s; f), elem elem'*, i) = s_res; f_res - -- if elem = ELEM reftype expr* elemmode - -- if n = |expr*| - -- if elemmode = TABLE x instr* - -- Step : s; f; instr* (CONST I32 0) (CONST I32 n) (TABLE.INIT x i) (ELEM.DROP i) ~> s_new; f_new; epsilon - -- if $run_elem((s_new; f_new), elem'*, $(i + 1)) = s_res; f_res +def $run_elem(state, elem, idx) : instr* -def $run_elem((s; f), elem elem'*, i) = s_res; f_res - -- if elem = ELEM reftype expr* elemmode - -- if elemmode = DECLARE - -- Step : s; f; (ELEM.DROP i) ~> s_new; f_new; epsilon - -- if $run_elem((s_new; f_new), elem'*, $(i + 1)) = s_res; f_res +def $run_elem((s; f), ELEM reftype expr*, i) = epsilon +def $run_elem((s; f), ELEM reftype expr* (TABLE x instr*), i) = instr* (CONST I32 0) (CONST I32 |expr*|) (TABLE.INIT x i) (ELEM.DROP i) -def $run_data(state, data*, idx) : state +def $run_elem((s; f), ELEM reftype expr* (DECLARE), i) = (ELEM.DROP i) -def $run_data((s; f), epsilon, i) = s; f -def $run_data((s; f), data data'*, i) = s_res; f_res - -- if data = DATA byte* - -- if $run_data((s; f), data'*, $(i + 1)) = s_res; f_res +def $run_data(state, data, idx) : instr* -def $run_data((s; f), data data'*, i) = s_res; f_res - -- if data = DATA byte* datamode - -- if n = |byte*| - -- if datamode = MEMORY 0 instr* - -- Step : s; f; instr* (CONST I32 0) (CONST I32 n) (MEMORY.INIT i) (DATA.DROP i) ~> s_new; f_new; epsilon - -- if $run_data((s_new; f_new), data'*, $(i + 1)) = s_res; f_res +def $run_data((s; f), DATA byte*, i) = epsilon +def $run_data((s; f), DATA byte* (MEMORY 0 instr*), i) = instr* (CONST I32 0) (CONST I32 |byte*|) (MEMORY.INIT i) (DATA.DROP i) -;; Instantiation -def $instantiation(store, module, externval*) : (store, moduleinst) +def $instantiation(store, module, externval*) : config -def $instantiation(s, module, externval*) = (s_res, m) - -- if module = MODULE import* func* global* table* mem* elem* data* export* - -- if (s_alloc, m) = $alloc_module(s, module, externval*) - -- if f = { LOCAL epsilon, MODULE m } - -- if $run_elem((s_alloc; f), elem*, 0) = s_elem; f_elem - -- if $run_data((s_elem; f_elem), data*, 0) = s_res; f_res - -def $instantiation(s, module, externval*) = (s_res, m) - -- if module = MODULE import* func* global* table* mem* elem* data* start export* - -- if (s_alloc, m) = $alloc_module(s, module, externval*) +def $instantiation(s, module, externval*) = s'; f; $run_elem(elem, i)* $run_data(data, j)* (CALL x)? + -- if module = MODULE import* func* global* table* mem* elem* data* start? export* + -- if m_init = { FUNC $funcs(externval*), GLOBAL $globals(externval*), TABEL epsilon, MEM epsilon, ELEM epsilon, DATA epsilon, EXPORT epsilon } + -- if f_init = { LOCAL epsilon, MODULE m_init } + -- (if global = GLOBAL globaltype instr*)* + -- (Step_read : s; f_init; instr* ~> val)* + -- (if elem = ELEM reftype (instr'*)* elemmode?)* + -- ((Step_read : s; f_init; instr'* ~> ref)*)* + -- if (s', m) = $alloc_module(s, module, externval*, val*, (ref*)*) -- if f = { LOCAL epsilon, MODULE m } - -- if $run_elem((s_alloc; f), elem*, 0) = s_elem; f_elem - -- if $run_data((s_elem; f_elem), data*, 0) = s_data; f_data - -- if start = START x - -- Step : s_data; f_data; (CALL x) ~> s_res; f_res; epsilon - + -- if i* = 0 ... $(|elem*| - 1) + -- if j* = 0 ... $(|data*| - 1) -;; Invocation -def $invocation(store, funcaddr, val*) : (store, val*) +def $invocation(store, funcaddr, val*) : config -def $invocation(s, fa, val*) = (s', val'*) +def $invocation(s, fa, val^n) = s; f; val^n (CALL_ADDR fa) -- if m = { FUNC epsilon, GLOBAL epsilon, TABLE epsilon, MEM epsilon, ELEM epsilon, DATA epsilon, EXPORT epsilon } -- if f = { LOCAL epsilon, MODULE m } -- if $funcinst((s; f))[fa].CODE = FUNC functype valtype* expr - -- if functype = valtype* -> valtype'* - -- if |val*| = |valtype*| - -- if |val'*| = |valtype'*| - -- Step : s; f; val* (CALL_ADDR fa) ~> s'; f'; val'* + -- if functype = valtype^n -> valtype'^k From 35be3dde538a80b29eb5c0ac4710fd13f8233e97 Mon Sep 17 00:00:00 2001 From: Wonho Shin Date: Thu, 29 Jun 2023 18:09:29 +0900 Subject: [PATCH 21/49] Minor changes --- spectec/spec/7-module.watsup | 73 +++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 26 deletions(-) diff --git a/spectec/spec/7-module.watsup b/spectec/spec/7-module.watsup index 06e3c179c9..39a5ff40dc 100644 --- a/spectec/spec/7-module.watsup +++ b/spectec/spec/7-module.watsup @@ -20,47 +20,57 @@ def $instantiate_export(fa*, ga*, ta*, ma*, EXPORT name (MEM x)) = { NAME name, def $alloc_func(store, moduleinst func) : store -def $alloc_global(store, global, val) : store -def $alloc_table(store, table) : store -def $alloc_mem(store, mem) : store -def $alloc_elem(store, elem, ref*) : store -def $alloc_data(store, data) : store - def $alloc_func(s, m, func) = s.[.FUNC =.. fi] -- if fi = { MODULE m, CODE func } +def $alloc_global(store, global, val) : store def $alloc_global(s, GLOBAL globaltype instr*, val) = s[.GLOBAL =.. gi] -- if gi = { TYPE globaltype, VALUE val } +def $alloc_table(store, table) : store def $alloc_table(s, TABLE tabletype) = s[.TABLE =.. ti] -- if tabletype = `[i .. j] rt -- if ti = { TYPE tabletype, ELEM (REF.NULL rt)^i } +def $alloc_mem(store, mem) : store def $alloc_mem(s, MEMORY memtype) = s[.MEM =.. mi] -- if memtype = `[i .. j] I8 -- if mi = { TYPE memtype, DATA 0^(i * 64 * $Ki()) } +def $alloc_elem(store, elem, ref*) : store def $alloc_elem(s, ELEM rt (instr*)* elemode?, ref*) = s[.ELEM =.. ei] -- if ei = { TYPE rt, ELEM ref* } +def $alloc_data(store, data) : store def $alloc_data(s, DATA byte* datamode?) = s[.DATA =.. di] -- if di = { DATA byte* } def $alloc_module(store, module, externval*, val*, (ref*)*) : (store, moduleinst) - def $alloc_module(s, module, externval*, val*, (ref*)*) = (s_6, m) -- if module = MODULE import* func* global* table* mem* elem* data* start? export* - -- if fa* = $funcs(externval*) (|s.FUNC| ... $(|s.FUNC| + |func*| - 1)) - -- if ga* = $globals(externval*) (|s.GLOBAL| ... $(|s.GLOBAL| + |global*| - 1)) - -- if ta* = $tables(externval*) (|s.TABLE| ... $(|s.TABLE| + |table*| - 1)) - -- if ma* = $mems(externval*) (|s.MEM| ... $(|s.MEM| + |mem*| - 1)) + -- if fa_ex* = $funcs(externval*) + -- if fa* = |s.FUNC| ... $(|s.FUNC| + |func*| - 1) + -- if ga_ex* = $globals(externval*) + -- if ga* = |s.GLOBAL| ... $(|s.GLOBAL| + |global*| - 1) + -- if ta_ex* = $tables(externval*) + -- if ta* = |s.TABLE| ... $(|s.TABLE| + |table*| - 1) + -- if ma_ex = $mems(externval*) + -- if ma* = |s.MEM| ... $(|s.MEM| + |mem*| - 1) -- if ea* = |s.ELEM| ... $(|s.ELEM| + |elem*| - 1) -- if da* = |s.DATA| ... $(|s.DATA| + |data*| - 1) - -- if xi* = $instantiate_export(fa*, ga*, ta*, ma*, export)* - -- if m = { FUNC fa*, GLOBAL ga*, TABLE ta*, MEM ma*, ELEM ea*, DATA da*, EXPORT xi* } + -- if xi* = $instantiate_export(fa_ex* fa*, ga_ex* ga*, ta_ex* ta*, ma_ex* ma*, export)* + -- if m = { + FUNC fa_ex* fa*, + GLOBAL ga_ex* ga*, + TABLE ta_ex* ta*, + MEM ma_ex* ma*, + ELEM ea*, + DATA da*, + EXPORT xi* + } -- if s_1 = $alloc_func*(s, m, func*) - -- if s_2 = $alloc_global*(s_1, global, val*) + -- if s_2 = $alloc_global*(s_1, global*, val*) -- if s_3 = $alloc_table*(s_2, table*) -- if s_4 = $alloc_mem*(s_3, mem*) -- if s_5 = $alloc_elem*(s_4, (ref*)*) @@ -68,26 +78,29 @@ def $alloc_module(s, module, externval*, val*, (ref*)*) = (s_6, m) def $run_elem(state, elem, idx) : instr* - def $run_elem((s; f), ELEM reftype expr*, i) = epsilon - -def $run_elem((s; f), ELEM reftype expr* (TABLE x instr*), i) = instr* (CONST I32 0) (CONST I32 |expr*|) (TABLE.INIT x i) (ELEM.DROP i) - def $run_elem((s; f), ELEM reftype expr* (DECLARE), i) = (ELEM.DROP i) - +def $run_elem((s; f), ELEM reftype expr* (TABLE x instr*), i) = + instr* (CONST I32 0) (CONST I32 |expr*|) (TABLE.INIT x i) (ELEM.DROP i) def $run_data(state, data, idx) : instr* - def $run_data((s; f), DATA byte*, i) = epsilon - -def $run_data((s; f), DATA byte* (MEMORY 0 instr*), i) = instr* (CONST I32 0) (CONST I32 |byte*|) (MEMORY.INIT i) (DATA.DROP i) +def $run_data((s; f), DATA byte* (MEMORY 0 instr*), i) = + instr* (CONST I32 0) (CONST I32 |byte*|) (MEMORY.INIT i) (DATA.DROP i) def $instantiation(store, module, externval*) : config - def $instantiation(s, module, externval*) = s'; f; $run_elem(elem, i)* $run_data(data, j)* (CALL x)? -- if module = MODULE import* func* global* table* mem* elem* data* start? export* - -- if m_init = { FUNC $funcs(externval*), GLOBAL $globals(externval*), TABEL epsilon, MEM epsilon, ELEM epsilon, DATA epsilon, EXPORT epsilon } + -- if m_init = { + FUNC $funcs(externval*), + GLOBAL $globals(externval*), + TABEL epsilon, + MEM epsilon, + ELEM epsilon, + DATA epsilon, + EXPORT epsilon + } -- if f_init = { LOCAL epsilon, MODULE m_init } -- (if global = GLOBAL globaltype instr*)* -- (Step_read : s; f_init; instr* ~> val)* @@ -97,12 +110,20 @@ def $instantiation(s, module, externval*) = s'; f; $run_elem(elem, i)* $run_data -- if f = { LOCAL epsilon, MODULE m } -- if i* = 0 ... $(|elem*| - 1) -- if j* = 0 ... $(|data*| - 1) + -- start? = (START x)? def $invocation(store, funcaddr, val*) : config - def $invocation(s, fa, val^n) = s; f; val^n (CALL_ADDR fa) - -- if m = { FUNC epsilon, GLOBAL epsilon, TABLE epsilon, MEM epsilon, ELEM epsilon, DATA epsilon, EXPORT epsilon } + -- if m = { + FUNC epsilon, + GLOBAL epsilon, + TABLE epsilon, + MEM epsilon, + ELEM epsilon, + DATA epsilon, + EXPORT epsilon + } -- if f = { LOCAL epsilon, MODULE m } -- if $funcinst((s; f))[fa].CODE = FUNC functype valtype* expr -- if functype = valtype^n -> valtype'^k From edda75e9b0da5c48bb23d9ae912b7ca7f29bd081 Mon Sep 17 00:00:00 2001 From: Wonho Shin Date: Thu, 29 Jun 2023 20:34:40 +0900 Subject: [PATCH 22/49] Minor changes --- spectec/spec/7-module.watsup | 70 ++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/spectec/spec/7-module.watsup b/spectec/spec/7-module.watsup index 39a5ff40dc..91d2e4a759 100644 --- a/spectec/spec/7-module.watsup +++ b/spectec/spec/7-module.watsup @@ -12,42 +12,42 @@ def $tables(externval*) = [ta|TABLE ta ∈ externval] def $mems(externval*) = [ma|MEM ma ∈ externval] -def $instantiate_export(funcaddr*, globaladdr*, tableaddr*, memaddr*, name, externuse) : exportinst -def $instantiate_export(fa*, ga*, ta*, ma*, EXPORT name (FUNC x)) = { NAME name, VALUE (FUNC fa*[x]) } -def $instantiate_export(fa*, ga*, ta*, ma*, EXPORT name (GLOBAL x)) = { NAME name, VALUE (GLOBAL ga*[x]) } -def $instantiate_export(fa*, ga*, ta*, ma*, EXPORT name (TABLE x)) = { NAME name, VALUE (TABLE ta*[x]) } -def $instantiate_export(fa*, ga*, ta*, ma*, EXPORT name (MEM x)) = { NAME name, VALUE (MEM ma*[x]) } +def $instexport(funcaddr*, globaladdr*, tableaddr*, memaddr*, name, externuse) : exportinst +def $instexport(fa*, ga*, ta*, ma*, EXPORT name (FUNC x)) = { NAME name, VALUE (FUNC fa*[x]) } +def $instexport(fa*, ga*, ta*, ma*, EXPORT name (GLOBAL x)) = { NAME name, VALUE (GLOBAL ga*[x]) } +def $instexport(fa*, ga*, ta*, ma*, EXPORT name (TABLE x)) = { NAME name, VALUE (TABLE ta*[x]) } +def $instexport(fa*, ga*, ta*, ma*, EXPORT name (MEM x)) = { NAME name, VALUE (MEM ma*[x]) } -def $alloc_func(store, moduleinst func) : store -def $alloc_func(s, m, func) = s.[.FUNC =.. fi] +def $allocfunc(store, moduleinst func) : store +def $allocfunc(s, m, func) = s.[.FUNC =.. fi] -- if fi = { MODULE m, CODE func } -def $alloc_global(store, global, val) : store -def $alloc_global(s, GLOBAL globaltype instr*, val) = s[.GLOBAL =.. gi] +def $allocglobal(store, global, val) : store +def $allocglobal(s, GLOBAL globaltype instr*, val) = s[.GLOBAL =.. gi] -- if gi = { TYPE globaltype, VALUE val } -def $alloc_table(store, table) : store -def $alloc_table(s, TABLE tabletype) = s[.TABLE =.. ti] +def $alloctable(store, table) : store +def $alloctable(s, TABLE tabletype) = s[.TABLE =.. ti] -- if tabletype = `[i .. j] rt -- if ti = { TYPE tabletype, ELEM (REF.NULL rt)^i } -def $alloc_mem(store, mem) : store -def $alloc_mem(s, MEMORY memtype) = s[.MEM =.. mi] +def $allocmem(store, mem) : store +def $allocmem(s, MEMORY memtype) = s[.MEM =.. mi] -- if memtype = `[i .. j] I8 -- if mi = { TYPE memtype, DATA 0^(i * 64 * $Ki()) } -def $alloc_elem(store, elem, ref*) : store -def $alloc_elem(s, ELEM rt (instr*)* elemode?, ref*) = s[.ELEM =.. ei] +def $allocelem(store, elem, ref*) : store +def $allocelem(s, ELEM rt (instr*)* elemode?, ref*) = s[.ELEM =.. ei] -- if ei = { TYPE rt, ELEM ref* } -def $alloc_data(store, data) : store -def $alloc_data(s, DATA byte* datamode?) = s[.DATA =.. di] +def $allocdata(store, data) : store +def $allocdata(s, DATA byte* datamode?) = s[.DATA =.. di] -- if di = { DATA byte* } -def $alloc_module(store, module, externval*, val*, (ref*)*) : (store, moduleinst) -def $alloc_module(s, module, externval*, val*, (ref*)*) = (s_6, m) +def $allocmodule(store, module, externval*, val*, (ref*)*) : (store, moduleinst) +def $allocmodule(s, module, externval*, val*, (ref*)*) = (s_6, m) -- if module = MODULE import* func* global* table* mem* elem* data* start? export* -- if fa_ex* = $funcs(externval*) -- if fa* = |s.FUNC| ... $(|s.FUNC| + |func*| - 1) @@ -69,28 +69,28 @@ def $alloc_module(s, module, externval*, val*, (ref*)*) = (s_6, m) DATA da*, EXPORT xi* } - -- if s_1 = $alloc_func*(s, m, func*) - -- if s_2 = $alloc_global*(s_1, global*, val*) - -- if s_3 = $alloc_table*(s_2, table*) - -- if s_4 = $alloc_mem*(s_3, mem*) - -- if s_5 = $alloc_elem*(s_4, (ref*)*) - -- if s_6 = $alloc_data*(s_5, data*) - - -def $run_elem(state, elem, idx) : instr* -def $run_elem((s; f), ELEM reftype expr*, i) = epsilon -def $run_elem((s; f), ELEM reftype expr* (DECLARE), i) = (ELEM.DROP i) -def $run_elem((s; f), ELEM reftype expr* (TABLE x instr*), i) = + -- if s_1 = $allocfunc*(s, m, func*) + -- if s_2 = $allocglobal*(s_1, global*, val*) + -- if s_3 = $alloctable*(s_2, table*) + -- if s_4 = $allocmem*(s_3, mem*) + -- if s_5 = $allocelem*(s_4, (ref*)*) + -- if s_6 = $allocdata*(s_5, data*) + + +def $runelem(state, elem, idx) : instr* +def $runelem((s; f), ELEM reftype expr*, i) = epsilon +def $runelem((s; f), ELEM reftype expr* (DECLARE), i) = (ELEM.DROP i) +def $runelem((s; f), ELEM reftype expr* (TABLE x instr*), i) = instr* (CONST I32 0) (CONST I32 |expr*|) (TABLE.INIT x i) (ELEM.DROP i) -def $run_data(state, data, idx) : instr* -def $run_data((s; f), DATA byte*, i) = epsilon -def $run_data((s; f), DATA byte* (MEMORY 0 instr*), i) = +def $rundata(state, data, idx) : instr* +def $rundata((s; f), DATA byte*, i) = epsilon +def $rundata((s; f), DATA byte* (MEMORY 0 instr*), i) = instr* (CONST I32 0) (CONST I32 |byte*|) (MEMORY.INIT i) (DATA.DROP i) def $instantiation(store, module, externval*) : config -def $instantiation(s, module, externval*) = s'; f; $run_elem(elem, i)* $run_data(data, j)* (CALL x)? +def $instantiation(s, module, externval*) = s'; f; $runelem(elem, i)* $rundata(data, j)* (CALL x)? -- if module = MODULE import* func* global* table* mem* elem* data* start? export* -- if m_init = { FUNC $funcs(externval*), From ff216fbee8a5b728cb430ea9163914f668377299 Mon Sep 17 00:00:00 2001 From: Wonho Shin Date: Fri, 30 Jun 2023 14:47:09 +0900 Subject: [PATCH 23/49] Update module semantics --- spectec/spec/7-module.watsup | 93 +++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 44 deletions(-) diff --git a/spectec/spec/7-module.watsup b/spectec/spec/7-module.watsup index 91d2e4a759..35edeb78ce 100644 --- a/spectec/spec/7-module.watsup +++ b/spectec/spec/7-module.watsup @@ -6,60 +6,62 @@ def $globals(externval*) : globaladdr* def $tables(externval*) : tableaddr* def $mems(externval*) : memaddr* -def $funcs(externval*) = [fa|FUNC fa ∈ externval] -def $globals(externval*) = [ga|GLOBAL ga ∈ externval] -def $tables(externval*) = [ta|TABLE ta ∈ externval] -def $mems(externval*) = [ma|MEM ma ∈ externval] +def $funcs(externval*) = [fa|FUNC fa <- externval] +def $globals(externval*) = [ga|GLOBAL ga <- externval] +def $tables(externval*) = [ta|TABLE ta <- externval] +def $mems(externval*) = [ma|MEM ma <- externval] -def $instexport(funcaddr*, globaladdr*, tableaddr*, memaddr*, name, externuse) : exportinst +def $instexport(funcaddr*, globaladdr*, tableaddr*, memaddr*, export) : exportinst def $instexport(fa*, ga*, ta*, ma*, EXPORT name (FUNC x)) = { NAME name, VALUE (FUNC fa*[x]) } def $instexport(fa*, ga*, ta*, ma*, EXPORT name (GLOBAL x)) = { NAME name, VALUE (GLOBAL ga*[x]) } def $instexport(fa*, ga*, ta*, ma*, EXPORT name (TABLE x)) = { NAME name, VALUE (TABLE ta*[x]) } def $instexport(fa*, ga*, ta*, ma*, EXPORT name (MEM x)) = { NAME name, VALUE (MEM ma*[x]) } -def $allocfunc(store, moduleinst func) : store -def $allocfunc(s, m, func) = s.[.FUNC =.. fi] - -- if fi = { MODULE m, CODE func } +def $allocfunc(moduleinst, func) : funcinst +def $allocfunc(m, func) = { MODULE m, CODE func } -def $allocglobal(store, global, val) : store -def $allocglobal(s, GLOBAL globaltype instr*, val) = s[.GLOBAL =.. gi] - -- if gi = { TYPE globaltype, VALUE val } +def $allocglobal(globaltype, val) : globalinst +def $allocglobal(globaltype, val) = { TYPE globaltype, VALUE val } -def $alloctable(store, table) : store -def $alloctable(s, TABLE tabletype) = s[.TABLE =.. ti] - -- if tabletype = `[i .. j] rt - -- if ti = { TYPE tabletype, ELEM (REF.NULL rt)^i } +def $alloctable(tabletype) : tableinst +def $alloctable(`[i .. j] rt) = { TYPE (`[i .. j] rt), ELEM (REF.NULL rt)^i } -def $allocmem(store, mem) : store -def $allocmem(s, MEMORY memtype) = s[.MEM =.. mi] - -- if memtype = `[i .. j] I8 - -- if mi = { TYPE memtype, DATA 0^(i * 64 * $Ki()) } +def $allocmem(memtype) : meminst +def $allocmem(`[i .. j] I8) = { TYPE (`[i .. j] I8), DATA 0^(i * 64 * $Ki()) } -def $allocelem(store, elem, ref*) : store -def $allocelem(s, ELEM rt (instr*)* elemode?, ref*) = s[.ELEM =.. ei] - -- if ei = { TYPE rt, ELEM ref* } +def $allocelem(reftype, ref*) : eleminst +def $allocelem(rt, ref*) = { TYPE rt, ELEM ref* } -def $allocdata(store, data) : store -def $allocdata(s, DATA byte* datamode?) = s[.DATA =.. di] - -- if di = { DATA byte* } +def $allocdata(byte*) : datainst +def $allocdata(byte*) = { DATA byte* } def $allocmodule(store, module, externval*, val*, (ref*)*) : (store, moduleinst) def $allocmodule(s, module, externval*, val*, (ref*)*) = (s_6, m) - -- if module = MODULE import* func* global* table* mem* elem* data* start? export* + -- if module = + MODULE + import* + func* + (GLOBAL globaltype expr)* + (TABLE tabletype)* + (MEMORY memtype)* + (ELEM rt expr* elemmode?)* + (DATA byte* datamode?)* + start? + export* -- if fa_ex* = $funcs(externval*) - -- if fa* = |s.FUNC| ... $(|s.FUNC| + |func*| - 1) -- if ga_ex* = $globals(externval*) - -- if ga* = |s.GLOBAL| ... $(|s.GLOBAL| + |global*| - 1) -- if ta_ex* = $tables(externval*) - -- if ta* = |s.TABLE| ... $(|s.TABLE| + |table*| - 1) -- if ma_ex = $mems(externval*) + -- if fa* = |s.FUNC| ... $(|s.FUNC| + |func*| - 1) + -- if ga* = |s.GLOBAL| ... $(|s.GLOBAL| + |global*| - 1) + -- if ta* = |s.TABLE| ... $(|s.TABLE| + |table*| - 1) -- if ma* = |s.MEM| ... $(|s.MEM| + |mem*| - 1) -- if ea* = |s.ELEM| ... $(|s.ELEM| + |elem*| - 1) -- if da* = |s.DATA| ... $(|s.DATA| + |data*| - 1) - -- if xi* = $instantiate_export(fa_ex* fa*, ga_ex* ga*, ta_ex* ta*, ma_ex* ma*, export)* + -- if xi* = $instexport(fa_ex* fa*, ga_ex* ga*, ta_ex* ta*, ma_ex* ma*, export)* -- if m = { FUNC fa_ex* fa*, GLOBAL ga_ex* ga*, @@ -69,33 +71,36 @@ def $allocmodule(s, module, externval*, val*, (ref*)*) = (s_6, m) DATA da*, EXPORT xi* } - -- if s_1 = $allocfunc*(s, m, func*) - -- if s_2 = $allocglobal*(s_1, global*, val*) - -- if s_3 = $alloctable*(s_2, table*) - -- if s_4 = $allocmem*(s_3, mem*) - -- if s_5 = $allocelem*(s_4, (ref*)*) - -- if s_6 = $allocdata*(s_5, data*) + -- if s_1 = s[.FUNC =.. $allocfunc(m, func)*] + -- if s_2 = s_1[.GLOBAL =.. $allocglobal(globaltype, val)*] + -- if s_3 = s_2[.TABLE =.. $alloctable(tabletype)*] + -- if s_4 = s_3[.MEM =.. $allocmem(memtype)*] + -- if s_5 = s_4[.ELEM =.. $allocelem(rt, ref*)*] + -- if s_6 = s_5[.DATA =.. $allocdata(byte*)*] def $runelem(state, elem, idx) : instr* def $runelem((s; f), ELEM reftype expr*, i) = epsilon def $runelem((s; f), ELEM reftype expr* (DECLARE), i) = (ELEM.DROP i) def $runelem((s; f), ELEM reftype expr* (TABLE x instr*), i) = - instr* (CONST I32 0) (CONST I32 |expr*|) (TABLE.INIT x i) (ELEM.DROP i) + instr* (CONST I32 0) (CONST I32 n) (TABLE.INIT x i) (ELEM.DROP i) + -- if n = |expr*| def $rundata(state, data, idx) : instr* def $rundata((s; f), DATA byte*, i) = epsilon def $rundata((s; f), DATA byte* (MEMORY 0 instr*), i) = - instr* (CONST I32 0) (CONST I32 |byte*|) (MEMORY.INIT i) (DATA.DROP i) + instr* (CONST I32 0) (CONST I32 n) (MEMORY.INIT i) (DATA.DROP i) + -- if n = |byte*| def $instantiation(store, module, externval*) : config -def $instantiation(s, module, externval*) = s'; f; $runelem(elem, i)* $rundata(data, j)* (CALL x)? +def $instantiation(s, module, externval*) = + s'; f; $runelem(elem*[i], i):_* $rundata(data*[j], j):_* (CALL x)? -- if module = MODULE import* func* global* table* mem* elem* data* start? export* -- if m_init = { FUNC $funcs(externval*), GLOBAL $globals(externval*), - TABEL epsilon, + TABLE epsilon, MEM epsilon, ELEM epsilon, DATA epsilon, @@ -105,12 +110,12 @@ def $instantiation(s, module, externval*) = s'; f; $runelem(elem, i)* $rundata(d -- (if global = GLOBAL globaltype instr*)* -- (Step_read : s; f_init; instr* ~> val)* -- (if elem = ELEM reftype (instr'*)* elemmode?)* - -- ((Step_read : s; f_init; instr'* ~> ref)*)* - -- if (s', m) = $alloc_module(s, module, externval*, val*, (ref*)*) + -- (Step_read : s; f_init; instr'* ~> ref)** + -- if (s', m) = $allocmodule(s, module, externval*, val*, (ref*)*) -- if f = { LOCAL epsilon, MODULE m } -- if i* = 0 ... $(|elem*| - 1) -- if j* = 0 ... $(|data*| - 1) - -- start? = (START x)? + -- if start? = (START x)? def $invocation(store, funcaddr, val*) : config @@ -126,4 +131,4 @@ def $invocation(s, fa, val^n) = s; f; val^n (CALL_ADDR fa) } -- if f = { LOCAL epsilon, MODULE m } -- if $funcinst((s; f))[fa].CODE = FUNC functype valtype* expr - -- if functype = valtype^n -> valtype'^k + -- if functype = valtype_param^n -> valtype_res^k From 21e0a94e4df332cb41d473fb778280156dca8686 Mon Sep 17 00:00:00 2001 From: Wonho Shin Date: Fri, 30 Jun 2023 15:03:51 +0900 Subject: [PATCH 24/49] Minor change --- spectec/spec/7-module.watsup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spectec/spec/7-module.watsup b/spectec/spec/7-module.watsup index 35edeb78ce..c26bfc295c 100644 --- a/spectec/spec/7-module.watsup +++ b/spectec/spec/7-module.watsup @@ -95,7 +95,7 @@ def $rundata((s; f), DATA byte* (MEMORY 0 instr*), i) = def $instantiation(store, module, externval*) : config def $instantiation(s, module, externval*) = - s'; f; $runelem(elem*[i], i):_* $rundata(data*[j], j):_* (CALL x)? + s'; f; ...$runelem(elem*[i], i)* ...$rundata(data*[j], j)* (CALL x)? -- if module = MODULE import* func* global* table* mem* elem* data* start? export* -- if m_init = { FUNC $funcs(externval*), From 236de048db80bbad5ee3d581f273c5eacbb58a64 Mon Sep 17 00:00:00 2001 From: Wonho Date: Mon, 3 Jul 2023 13:06:07 +0900 Subject: [PATCH 25/49] Minor change --- spectec/spec/7-module.watsup | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spectec/spec/7-module.watsup b/spectec/spec/7-module.watsup index c26bfc295c..530fceb62a 100644 --- a/spectec/spec/7-module.watsup +++ b/spectec/spec/7-module.watsup @@ -6,10 +6,10 @@ def $globals(externval*) : globaladdr* def $tables(externval*) : tableaddr* def $mems(externval*) : memaddr* -def $funcs(externval*) = [fa|FUNC fa <- externval] -def $globals(externval*) = [ga|GLOBAL ga <- externval] -def $tables(externval*) = [ta|TABLE ta <- externval] -def $mems(externval*) = [ma|MEM ma <- externval] +def $funcs(externval*) = `[fa|FUNC fa <- externval] +def $globals(externval*) = `[ga|GLOBAL ga <- externval] +def $tables(externval*) = `[ta|TABLE ta <- externval] +def $mems(externval*) = `[ma|MEM ma <- externval] def $instexport(funcaddr*, globaladdr*, tableaddr*, memaddr*, export) : exportinst From 1560490af7041ecad58f8d288b793c7d12b08f94 Mon Sep 17 00:00:00 2001 From: Wonho Date: Tue, 4 Jul 2023 16:46:45 +0900 Subject: [PATCH 26/49] Fix typo --- spectec/spec/7-module.watsup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spectec/spec/7-module.watsup b/spectec/spec/7-module.watsup index 530fceb62a..60d37df4af 100644 --- a/spectec/spec/7-module.watsup +++ b/spectec/spec/7-module.watsup @@ -54,7 +54,7 @@ def $allocmodule(s, module, externval*, val*, (ref*)*) = (s_6, m) -- if fa_ex* = $funcs(externval*) -- if ga_ex* = $globals(externval*) -- if ta_ex* = $tables(externval*) - -- if ma_ex = $mems(externval*) + -- if ma_ex* = $mems(externval*) -- if fa* = |s.FUNC| ... $(|s.FUNC| + |func*| - 1) -- if ga* = |s.GLOBAL| ... $(|s.GLOBAL| + |global*| - 1) -- if ta* = |s.TABLE| ... $(|s.TABLE| + |table*| - 1) From e7a5252bdb34ea8fa0a7e383cead2dbc63c344bf Mon Sep 17 00:00:00 2001 From: Wonho Date: Wed, 5 Jul 2023 17:03:06 +0900 Subject: [PATCH 27/49] Add iter with index Add concat helper function Revert to allocx lifting --- spectec/spec/7-module.watsup | 124 +++++++++++++++++++++++------------ 1 file changed, 82 insertions(+), 42 deletions(-) diff --git a/spectec/spec/7-module.watsup b/spectec/spec/7-module.watsup index 60d37df4af..13bda9d909 100644 --- a/spectec/spec/7-module.watsup +++ b/spectec/spec/7-module.watsup @@ -19,23 +19,56 @@ def $instexport(fa*, ga*, ta*, ma*, EXPORT name (TABLE x)) = { NAME name, VALUE def $instexport(fa*, ga*, ta*, ma*, EXPORT name (MEM x)) = { NAME name, VALUE (MEM ma*[x]) } -def $allocfunc(moduleinst, func) : funcinst -def $allocfunc(m, func) = { MODULE m, CODE func } +def $allocfunc(store, moduleinst, func) : store +def $allocfunc(s, m, func) = s[.FUNC =.. fi] + --if fi = { MODULE m, CODE func } -def $allocglobal(globaltype, val) : globalinst -def $allocglobal(globaltype, val) = { TYPE globaltype, VALUE val } +def $allocfuncs(store, moduleinst, func*) : store +def $allocfuncs(s, m, epsilon) = s +def $allocfuncs(s, m, func func'*) = $allocfuncs($allocfunc(s, m, func), m, func'*) -def $alloctable(tabletype) : tableinst -def $alloctable(`[i .. j] rt) = { TYPE (`[i .. j] rt), ELEM (REF.NULL rt)^i } +def $allocglobal(store, globaltype, val) : store +def $allocglobal(s, globaltype, val) = s[.GLOBAL =.. gi] + -- if gi = { TYPE globaltype, VALUE val } -def $allocmem(memtype) : meminst -def $allocmem(`[i .. j] I8) = { TYPE (`[i .. j] I8), DATA 0^(i * 64 * $Ki()) } +def $allocglobals(store, globaltype*, val*) : store +def $allocglobals(s, epsilon, epsilon) = s +def $allocglobals(s, globaltype globaltype'*, val val'*) = + $allocglobals($allocglobal(s, globaltype, val), globaltype'*, val'*) -def $allocelem(reftype, ref*) : eleminst -def $allocelem(rt, ref*) = { TYPE rt, ELEM ref* } +def $alloctable(store, tabletype) : store +def $alloctable(s, `[i .. j] rt) = s[.TABLE =.. ti] + -- if ti = { TYPE (`[i .. j] rt), ELEM (REF.NULL rt)^i } -def $allocdata(byte*) : datainst -def $allocdata(byte*) = { DATA byte* } +def $alloctables(store, tabletype*) : store +def $alloctables(s, epsilon) = s +def $alloctables(s, tabletype tabletype'*) = + $alloctables($alloctable(s, tabletype), tabletype'*) + +def $allocmem(store, memtype) : store +def $allocmem(s, `[i .. j] I8) = s[.MEM =.. mi] + -- if mi = { TYPE (`[i .. j] I8), DATA 0^(i * 64 * $Ki()) } + +def $allocmems(store, memtype*) : store +def $allocmems(s, epsilon) = s +def $allocmems(s, memtype memtype'*) = $allocmems($allocmem(s, memtype), memtype'*) + +def $allocelem(store, reftype, ref*) : store +def $allocelem(s, rt, ref*) = s[.ELEM =.. ei] + -- if ei = { TYPE rt, ELEM ref* } + +def $allocelems(store, reftype*, (ref*)*) : store +def $allocelems(s, epsilon, epsilon) = s +def $allocelems(s, rt rt'*, ref* ref'**) = + $allocelems($allocelem(s, rt, ref*), rt'*, ref'**) + +def $allocdata(store, byte*) : store +def $allocdata(s, byte*) = s[.DATA =.. di] + -- if di = { DATA byte* } + +def $allocdatas(store, byte**) : store +def $allocdatas(s, epsilon) = s +def $allocdatas(s, byte* byte'**) = $allocdatas($allocdata(s, byte*), byte'**) def $allocmodule(store, module, externval*, val*, (ref*)*) : (store, moduleinst) @@ -43,24 +76,24 @@ def $allocmodule(s, module, externval*, val*, (ref*)*) = (s_6, m) -- if module = MODULE import* - func* - (GLOBAL globaltype expr)* - (TABLE tabletype)* - (MEMORY memtype)* - (ELEM rt expr* elemmode?)* - (DATA byte* datamode?)* + func^n_func + (GLOBAL globaltype expr)^n_global + (TABLE tabletype)^n_table + (MEMORY memtype)^n_mem + (ELEM rt expr'* elemmode?)^n_elem + (DATA byte* datamode?)^n_data start? export* -- if fa_ex* = $funcs(externval*) -- if ga_ex* = $globals(externval*) -- if ta_ex* = $tables(externval*) -- if ma_ex* = $mems(externval*) - -- if fa* = |s.FUNC| ... $(|s.FUNC| + |func*| - 1) - -- if ga* = |s.GLOBAL| ... $(|s.GLOBAL| + |global*| - 1) - -- if ta* = |s.TABLE| ... $(|s.TABLE| + |table*| - 1) - -- if ma* = |s.MEM| ... $(|s.MEM| + |mem*| - 1) - -- if ea* = |s.ELEM| ... $(|s.ELEM| + |elem*| - 1) - -- if da* = |s.DATA| ... $(|s.DATA| + |data*| - 1) + -- if fa* = $(|s.FUNC|+i)^(i ref)** -- if (s', m) = $allocmodule(s, module, externval*, val*, (ref*)*) -- if f = { LOCAL epsilon, MODULE m } - -- if i* = 0 ... $(|elem*| - 1) - -- if j* = 0 ... $(|data*| - 1) + -- if n_elem = |elem*| + -- if instr_elem** = $runelem(elem*[i], i)^(i Date: Wed, 5 Jul 2023 17:06:35 +0900 Subject: [PATCH 28/49] Update elab and validation --- spectec/src/frontend/elab.ml | 6 +++++- spectec/src/il/validation.ml | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/spectec/src/frontend/elab.ml b/spectec/src/frontend/elab.ml index 4cebbc6ecd..7dc55970f3 100644 --- a/spectec/src/frontend/elab.ml +++ b/spectec/src/frontend/elab.ml @@ -336,7 +336,11 @@ let rec elab_iter env iter : Il.iter = | Opt -> Il.Opt | List -> Il.List | List1 -> Il.List1 - | ListN e -> Il.ListN (elab_exp env e (NatT $ e.at)) + | ListN e -> + match e.it with + | ParenE ({ it = CmpE _; _}, _) -> + Il.ListN (elab_exp env e (BoolT $ e.at)) + | _ -> Il.ListN (elab_exp env e (NatT $ e.at)) (* Types *) diff --git a/spectec/src/il/validation.ml b/spectec/src/il/validation.ml index 7703a0f951..1fccfb1ccf 100644 --- a/spectec/src/il/validation.ml +++ b/spectec/src/il/validation.ml @@ -241,7 +241,10 @@ let valid_list valid_x_y env xs ys at = let rec valid_iter env iter = match iter with | Opt | List | List1 -> () - | ListN e -> valid_exp env e (NatT $ e.at) + | ListN e -> + match e.it with + | CmpE _ -> valid_exp env e (BoolT $ e.at) + | _ -> valid_exp env e (NatT $ e.at) (* Types *) From 506306ea91a8e023efccb32572dce945c81112ef Mon Sep 17 00:00:00 2001 From: Wonho Date: Fri, 7 Jul 2023 14:02:52 +0900 Subject: [PATCH 29/49] Compute address in alloc func --- spectec/spec/7-module.watsup | 105 +++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 48 deletions(-) diff --git a/spectec/spec/7-module.watsup b/spectec/spec/7-module.watsup index 13bda9d909..fab5fdf548 100644 --- a/spectec/spec/7-module.watsup +++ b/spectec/spec/7-module.watsup @@ -19,56 +19,65 @@ def $instexport(fa*, ga*, ta*, ma*, EXPORT name (TABLE x)) = { NAME name, VALUE def $instexport(fa*, ga*, ta*, ma*, EXPORT name (MEM x)) = { NAME name, VALUE (MEM ma*[x]) } -def $allocfunc(store, moduleinst, func) : store -def $allocfunc(s, m, func) = s[.FUNC =.. fi] - --if fi = { MODULE m, CODE func } - -def $allocfuncs(store, moduleinst, func*) : store -def $allocfuncs(s, m, epsilon) = s -def $allocfuncs(s, m, func func'*) = $allocfuncs($allocfunc(s, m, func), m, func'*) - -def $allocglobal(store, globaltype, val) : store -def $allocglobal(s, globaltype, val) = s[.GLOBAL =.. gi] +def $allocfunc(store, moduleinst, func) : (store, funcaddr) +def $allocfunc(s, m, func) = (s[.FUNC =.. fi], |s.FUNC|) + -- if fi = { MODULE m, CODE func } + +def $allocfuncs(store, moduleinst, func*) : (store, funcaddr*) +def $allocfuncs(s, m, epsilon) = (s, epsilon) +def $allocfuncs(s, m, func func'*) = (s_2, fa fa'*) + -- if (s_1, fa) = $allocfunc(s, m, func) + -- if (s_2, fa'*) = $allocfuncs(s_1, m, func'*) + +def $allocglobal(store, globaltype, val) : (store, globaladdr) +def $allocglobal(s, globaltype, val) = (s[.GLOBAL =.. gi], |s.GLOBAL|) -- if gi = { TYPE globaltype, VALUE val } -def $allocglobals(store, globaltype*, val*) : store -def $allocglobals(s, epsilon, epsilon) = s -def $allocglobals(s, globaltype globaltype'*, val val'*) = - $allocglobals($allocglobal(s, globaltype, val), globaltype'*, val'*) +def $allocglobals(store, globaltype*, val*) : (store, globaladdr*) +def $allocglobals(s, epsilon, epsilon) = (s, epsilon) +def $allocglobals(s, globaltype globaltype'*, val val'*) = (s_2, ga ga'*) + -- if (s_1, ga) = $allocglobal(s, globaltype, val) + -- if (s_2, ga'*) = $allocglobals(s_1, globaltype'*, val'*) -def $alloctable(store, tabletype) : store -def $alloctable(s, `[i .. j] rt) = s[.TABLE =.. ti] +def $alloctable(store, tabletype) : (store, tableaddr) +def $alloctable(s, `[i .. j] rt) = (s[.TABLE =.. ti], |s.TABLE|) -- if ti = { TYPE (`[i .. j] rt), ELEM (REF.NULL rt)^i } -def $alloctables(store, tabletype*) : store -def $alloctables(s, epsilon) = s -def $alloctables(s, tabletype tabletype'*) = - $alloctables($alloctable(s, tabletype), tabletype'*) +def $alloctables(store, tabletype*) : (store, tableaddr*) +def $alloctables(s, epsilon) = (s, epsilon) +def $alloctables(s, tabletype tabletype'*) = (s_2, ta ta'*) + -- if (s_1, ta) = $alloctable(s, tabletype) + -- if (s_2, ta'*) = $alloctables(s_1, tabletype'*) -def $allocmem(store, memtype) : store -def $allocmem(s, `[i .. j] I8) = s[.MEM =.. mi] +def $allocmem(store, memtype) : (store, memaddr) +def $allocmem(s, `[i .. j] I8) = (s[.MEM =.. mi], |s.MEM|) -- if mi = { TYPE (`[i .. j] I8), DATA 0^(i * 64 * $Ki()) } -def $allocmems(store, memtype*) : store -def $allocmems(s, epsilon) = s -def $allocmems(s, memtype memtype'*) = $allocmems($allocmem(s, memtype), memtype'*) +def $allocmems(store, memtype*) : (store, memaddr*) +def $allocmems(s, epsilon) = (s, epsilon) +def $allocmems(s, memtype memtype'*) = (s_2, ma ma'*) + -- if (s_1, ma) = $allocmem(s, memtype) + -- if (s_2, ma'*) = $allocmems(s_1, memtype'*) -def $allocelem(store, reftype, ref*) : store -def $allocelem(s, rt, ref*) = s[.ELEM =.. ei] +def $allocelem(store, reftype, ref*) : (store, elemaddr) +def $allocelem(s, rt, ref*) = (s[.ELEM =.. ei], |s.ELEM|) -- if ei = { TYPE rt, ELEM ref* } -def $allocelems(store, reftype*, (ref*)*) : store -def $allocelems(s, epsilon, epsilon) = s -def $allocelems(s, rt rt'*, ref* ref'**) = - $allocelems($allocelem(s, rt, ref*), rt'*, ref'**) +def $allocelems(store, reftype*, (ref*)*) : (store, elemaddr*) +def $allocelems(s, epsilon, epsilon) = (s, epsilon) +def $allocelems(s, rt rt'*, ref* ref'**) = (s_2, ea ea'*) + -- if (s_1, ea) = $allocelem(s, rt, ref*) + -- if (s_2, ea'*) = $allocelems(s_2, rt'*, ref'**) -def $allocdata(store, byte*) : store -def $allocdata(s, byte*) = s[.DATA =.. di] +def $allocdata(store, byte*) : (store, dataaddr) +def $allocdata(s, byte*) = (s[.DATA =.. di], |s.DATA|) -- if di = { DATA byte* } -def $allocdatas(store, byte**) : store -def $allocdatas(s, epsilon) = s -def $allocdatas(s, byte* byte'**) = $allocdatas($allocdata(s, byte*), byte'**) +def $allocdatas(store, byte**) : (store, dataaddr*) +def $allocdatas(s, epsilon) = (s, epsilon) +def $allocdatas(s, byte* byte'**) = (s_2, da da'*) + -- if (s_1, da) = $allocdata(s, byte*) + -- if (s_2, da'*) = $allocdatas(s_1, byte'**) def $allocmodule(store, module, externval*, val*, (ref*)*) : (store, moduleinst) @@ -77,10 +86,10 @@ def $allocmodule(s, module, externval*, val*, (ref*)*) = (s_6, m) MODULE import* func^n_func - (GLOBAL globaltype expr)^n_global + (GLOBAL globaltype expr_1)^n_global (TABLE tabletype)^n_table (MEMORY memtype)^n_mem - (ELEM rt expr'* elemmode?)^n_elem + (ELEM rt expr_2* elemmode?)^n_elem (DATA byte* datamode?)^n_data start? export* @@ -104,12 +113,12 @@ def $allocmodule(s, module, externval*, val*, (ref*)*) = (s_6, m) DATA da*, EXPORT xi* } - -- if s_1 = $allocfuncs(s, m, func^n_func) - -- if s_2 = $allocglobals(s_1, globaltype^n_global, val*) - -- if s_3 = $alloctables(s_2, tabletype^n_table) - -- if s_4 = $allocmems(s_3, memtype^n_mem) - -- if s_5 = $allocelems(s_4, rt^n_elem, (ref*)*) - -- if s_6 = $allocdatas(s_5, (byte*)^n_data) + -- if (s_1, fa*) = $allocfuncs(s, m, func^n_func) + -- if (s_2, ga*) = $allocglobals(s_1, globaltype^n_global, val*) + -- if (s_3, ta*) = $alloctables(s_2, tabletype^n_table) + -- if (s_4, ma*) = $allocmems(s_3, memtype^n_mem) + -- if (s_5, ea*) = $allocelems(s_4, rt^n_elem, (ref*)*) + -- if (s_6, da*) = $allocdatas(s_5, (byte*)^n_data) def $runelem(elem, idx) : instr* @@ -145,10 +154,10 @@ def $instantiation(s, module, externval*) = EXPORT epsilon } -- if f_init = { LOCAL epsilon, MODULE m_init } - -- (if global = GLOBAL globaltype instr*)* - -- (Step_read : s; f_init; instr* ~> val)* - -- (if elem = ELEM reftype (instr'*)* elemmode?)* - -- (Step_read : s; f_init; instr'* ~> ref)** + -- (if global = GLOBAL globaltype instr_1*)* + -- (Step_read : s; f_init; instr_1* ~> val)* + -- (if elem = ELEM reftype (instr_2*)* elemmode?)* + -- (Step_read : s; f_init; instr_2* ~> ref)** -- if (s', m) = $allocmodule(s, module, externval*, val*, (ref*)*) -- if f = { LOCAL epsilon, MODULE m } -- if n_elem = |elem*| From eb57512fdc7ae607502ff017580c93586e2aa316 Mon Sep 17 00:00:00 2001 From: Wonho Date: Thu, 13 Jul 2023 16:56:57 +0900 Subject: [PATCH 30/49] Minor changes --- spectec/spec/7-module.watsup | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/spectec/spec/7-module.watsup b/spectec/spec/7-module.watsup index fab5fdf548..9a8759d0fe 100644 --- a/spectec/spec/7-module.watsup +++ b/spectec/spec/7-module.watsup @@ -6,10 +6,14 @@ def $globals(externval*) : globaladdr* def $tables(externval*) : tableaddr* def $mems(externval*) : memaddr* -def $funcs(externval*) = `[fa|FUNC fa <- externval] -def $globals(externval*) = `[ga|GLOBAL ga <- externval] -def $tables(externval*) = `[ta|TABLE ta <- externval] -def $mems(externval*) = `[ma|MEM ma <- externval] +def $funcs(externval*) = fa'* + -- if fa'* = `[fa|FUNC fa <- externval*] +def $globals(externval*) = ga'* + -- if ga'* = `[ga|GLOBAL ga <- externval*] +def $tables(externval*) = ta'* + -- if ta'* = `[ta|TABLE ta <- externval*] +def $mems(externval*) = ma'* + -- if ma'* = `[ma|MEM ma <- externval*] def $instexport(funcaddr*, globaladdr*, tableaddr*, memaddr*, export) : exportinst @@ -141,8 +145,7 @@ def $concat_instr(instr* instr'**) = instr* $concat_instr(instr'**) def $instantiation(store, module, externval*) : config -def $instantiation(s, module, externval*) = - s'; f; $concat_instr(instr_elem**) $concat_instr(instr_data**) (CALL x)? +def $instantiation(s, module, externval*) = s'; f; instr_elem* instr_data* (CALL x)? -- if module = MODULE import* func* global* table* mem* elem* data* start? export* -- if m_init = { FUNC $funcs(externval*), @@ -161,9 +164,9 @@ def $instantiation(s, module, externval*) = -- if (s', m) = $allocmodule(s, module, externval*, val*, (ref*)*) -- if f = { LOCAL epsilon, MODULE m } -- if n_elem = |elem*| - -- if instr_elem** = $runelem(elem*[i], i)^(i Date: Wed, 12 Jul 2023 20:30:47 +0900 Subject: [PATCH 31/49] Add iter with an index --- spectec/src/frontend/elab.ml | 4 ++-- spectec/src/frontend/multiplicity.ml | 3 +++ spectec/src/il/ast.ml | 1 + spectec/src/il/eq.ml | 2 ++ spectec/src/il/free.ml | 2 ++ spectec/src/il/print.ml | 2 ++ spectec/src/il/validation.ml | 16 ++++++++++------ spectec/src/middlend/sideconditions.ml | 6 +++--- spectec/src/middlend/sub.ml | 1 + spectec/src/middlend/totalize.ml | 1 + spectec/src/middlend/unthe.ml | 2 ++ spectec/src/middlend/wild.ml | 2 ++ 12 files changed, 31 insertions(+), 11 deletions(-) diff --git a/spectec/src/frontend/elab.ml b/spectec/src/frontend/elab.ml index 7dc55970f3..eab6f1dff9 100644 --- a/spectec/src/frontend/elab.ml +++ b/spectec/src/frontend/elab.ml @@ -338,8 +338,8 @@ let rec elab_iter env iter : Il.iter = | List1 -> Il.List1 | ListN e -> match e.it with - | ParenE ({ it = CmpE _; _}, _) -> - Il.ListN (elab_exp env e (BoolT $ e.at)) + | ParenE ({ it = CmpE ({ it = VarE id; _ }, LtOp, e); _}, _) -> + Il.IndexedListN (id, elab_exp env e (NatT $ e.at)) | _ -> Il.ListN (elab_exp env e (NatT $ e.at)) diff --git a/spectec/src/frontend/multiplicity.ml b/spectec/src/frontend/multiplicity.ml index 175b58c9ad..aebc8adc50 100644 --- a/spectec/src/frontend/multiplicity.ml +++ b/spectec/src/frontend/multiplicity.ml @@ -164,6 +164,9 @@ let rec annot_iter env iter : Il.Ast.iter * occur = | ListN e -> let e', occur = annot_exp env e in ListN e', occur + | IndexedListN (id, e) -> + let e', occur = annot_exp env e in + IndexedListN (id, e'), occur and annot_exp env e : Il.Ast.exp * occur = let it, occur = diff --git a/spectec/src/il/ast.ml b/spectec/src/il/ast.ml index 18cafd638e..f97a0ebdcd 100644 --- a/spectec/src/il/ast.ml +++ b/spectec/src/il/ast.ml @@ -42,6 +42,7 @@ type iter = | List (* `*` *) | List1 (* `+` *) | ListN of exp (* `^` exp *) + | IndexedListN of id * exp (* `^` exp *) (* Types *) diff --git a/spectec/src/il/eq.ml b/spectec/src/il/eq.ml index 61fb22f964..177ce77a69 100644 --- a/spectec/src/il/eq.ml +++ b/spectec/src/il/eq.ml @@ -25,6 +25,8 @@ let rec eq_iter iter1 iter2 = iter1 = iter2 || match iter1, iter2 with | ListN e1, ListN e2 -> eq_exp e1 e2 + | IndexedListN (id1, e1), IndexedListN (id2, e2) -> + id1.it = id2.it && eq_exp e1 e2 | _, _ -> false diff --git a/spectec/src/il/free.ml b/spectec/src/il/free.ml index 43bcd12d49..22d5e6d7ab 100644 --- a/spectec/src/il/free.ml +++ b/spectec/src/il/free.ml @@ -56,6 +56,8 @@ let rec free_iter iter = match iter with | Opt | List | List1 -> empty | ListN e -> free_exp e + | IndexedListN (id, e) -> + union (free_varid id) (free_exp e) (* Types *) diff --git a/spectec/src/il/print.ml b/spectec/src/il/print.ml index e33beff47a..268ae5e578 100644 --- a/spectec/src/il/print.ml +++ b/spectec/src/il/print.ml @@ -77,6 +77,8 @@ let rec string_of_iter iter = | List -> "*" | List1 -> "+" | ListN e -> "^" ^ string_of_exp e + | IndexedListN (id, e) -> + "^(" ^ id.it ^ "<" ^ string_of_exp e ^ ")" and string_of_typ t = match t.it with diff --git a/spectec/src/il/validation.ml b/spectec/src/il/validation.ml index 1fccfb1ccf..f6a3fb1280 100644 --- a/spectec/src/il/validation.ml +++ b/spectec/src/il/validation.ml @@ -100,7 +100,7 @@ let as_iter_typ iter phrase env dir t at : typ = let as_list_typ phrase env dir t at : typ = match expand' env t.it with - | IterT (t1, (List | List1 | ListN _)) -> t1 + | IterT (t1, (List | List1 | ListN _ | IndexedListN _)) -> t1 | _ -> as_error at phrase dir t "(_)*" let as_tup_typ phrase env dir t at : typ list = @@ -241,10 +241,8 @@ let valid_list valid_x_y env xs ys at = let rec valid_iter env iter = match iter with | Opt | List | List1 -> () - | ListN e -> - match e.it with - | CmpE _ -> valid_exp env e (BoolT $ e.at) - | _ -> valid_exp env e (NatT $ e.at) + | IndexedListN (_, e) + | ListN e -> valid_exp env e (NatT $ e.at) (* Types *) @@ -262,6 +260,7 @@ and valid_typ env t = List.iter (valid_typ env) ts | IterT (t1, iter) -> match iter with + | IndexedListN (_, e) | ListN e -> error e.at "definite iterator not allowed in type" | _ -> valid_typ env t1; valid_iter env iter @@ -317,7 +316,12 @@ and infer_exp env e : typ = | CallE (id, _) -> snd (find "function" env.defs id) | MixE _ -> error e.at "cannot infer type of mixin notation" | IterE (e1, iter) -> - let iter' = match fst iter with ListN _ -> List | iter' -> iter' in + let iter' = + match fst iter with + | IndexedListN _ + | ListN _ -> List + | iter' -> iter' + in IterT (infer_exp env e1, iter') $ e.at | OptE _ -> error e.at "cannot infer type of option" | TheE e1 -> as_iter_typ Opt "option" env Check (infer_exp env e1) e1.at diff --git a/spectec/src/middlend/sideconditions.ml b/spectec/src/middlend/sideconditions.ml index 2efc16feab..13a416f586 100644 --- a/spectec/src/middlend/sideconditions.ml +++ b/spectec/src/middlend/sideconditions.ml @@ -22,7 +22,7 @@ module Env = Map.Make(String) (* Smart constructor for LenE that optimizes |x^n| into n *) let lenE e = match e.it with -| IterE (_, (ListN ne, _)) -> ne +| IterE (_, ((ListN ne | IndexedListN (_, ne)), _)) -> ne | _ -> LenE e $$ no_region % (NatT $ no_region) let is_null e = CmpE (EqOp, e, OptE None $$ no_region % e.note) $$ no_region % (BoolT $ e.at) @@ -39,7 +39,7 @@ let iter_side_conditions env ((iter, vs) : iterexp) : premise list = | _, [] -> [] | Opt, (e::es) -> List.map (fun e' -> iffE (is_null e) (is_null e')) es | (List|List1), (e::es) -> List.map (same_len e) es - | ListN ne, es -> List.map (has_len ne) es + | (ListN ne | IndexedListN (_, ne)), es -> List.map (has_len ne) es (* Expr traversal *) let rec t_exp env e : premise list = @@ -87,7 +87,7 @@ let rec t_exp env e : premise list = and t_iterexp env (iter, _) = t_iter env iter and t_iter env = function - | ListN e -> t_exp env e + | IndexedListN (_, e) | ListN e -> t_exp env e | _ -> [] and t_path env path = match path.it with diff --git a/spectec/src/middlend/sub.ml b/spectec/src/middlend/sub.ml index 8950a17f54..0b4ea008d3 100644 --- a/spectec/src/middlend/sub.ml +++ b/spectec/src/middlend/sub.ml @@ -120,6 +120,7 @@ and t_exp' env = function and t_iter env = function | ListN e -> ListN (t_exp env e) + | IndexedListN (id, e) -> IndexedListN (id, t_exp env e) | i -> i and t_iterexp env (iter, vs) = (t_iter env iter, vs) diff --git a/spectec/src/middlend/totalize.ml b/spectec/src/middlend/totalize.ml index 53bc54d322..c8cbc3bbaf 100644 --- a/spectec/src/middlend/totalize.ml +++ b/spectec/src/middlend/totalize.ml @@ -79,6 +79,7 @@ and t_exp' env = function and t_iter env = function | ListN e -> ListN (t_exp env e) + | IndexedListN (id, e) -> IndexedListN (id, t_exp env e) | i -> i and t_iterexp env (iter, vs) = (t_iter env iter, vs) diff --git a/spectec/src/middlend/unthe.ml b/spectec/src/middlend/unthe.ml index a272bdb753..ba3f595ebb 100644 --- a/spectec/src/middlend/unthe.ml +++ b/spectec/src/middlend/unthe.ml @@ -157,6 +157,8 @@ and t_iterexp n (iter, vs) = and t_iter n iter = match iter with | ListN e -> unary t_exp n e (fun e' -> ListN e') + | IndexedListN (id, e) -> + unary t_exp n e (fun e' -> IndexedListN (id, e')) | _ -> [], iter and t_path n = phrase t_path' n diff --git a/spectec/src/middlend/wild.ml b/spectec/src/middlend/wild.ml index e79b15a8e5..97bc050415 100644 --- a/spectec/src/middlend/wild.ml +++ b/spectec/src/middlend/wild.ml @@ -181,6 +181,8 @@ and t_iterexp env (iter, vs) = and t_iter env iter = match iter with | ListN e -> unary t_exp env e (fun e' -> ListN e') + | IndexedListN (id, e) -> + unary t_exp env e (fun e' -> IndexedListN (id, e')) | _ -> [], iter and t_path env = phrase t_path' env From a453c69af468e5b3e376e6afbe66600edd793529 Mon Sep 17 00:00:00 2001 From: Wonho Date: Fri, 7 Jul 2023 16:14:44 +0900 Subject: [PATCH 32/49] Allow opt iter to have list iter type --- spectec/src/frontend/elab.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spectec/src/frontend/elab.ml b/spectec/src/frontend/elab.ml index eab6f1dff9..cca9840a23 100644 --- a/spectec/src/frontend/elab.ml +++ b/spectec/src/frontend/elab.ml @@ -766,7 +766,7 @@ and elab_exp_notation' env e t : Il.exp list = | (EpsE | SeqE _), IterT (t1, iter) -> [elab_exp_notation_iter env (unseq_exp e) (t1, iter) t e.at] | IterE (e1, iter1), IterT (t1, iter) -> - if (iter = Opt) <> (iter1 = Opt) then + if (iter = Opt) && (iter1 <> Opt) then error_typ e.at "iteration expression" t; let es1' = elab_exp_notation' env e1 t1 in let iter1' = elab_iter env iter1 in From 88fe94bdba0f567f083a7d8aeda0e420daa2deea Mon Sep 17 00:00:00 2001 From: DJ Date: Wed, 28 Jun 2023 17:26:34 +0900 Subject: [PATCH 33/49] Fix location of \land for conditions of funcdef --- spectec/src/backend-latex/render.ml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/spectec/src/backend-latex/render.ml b/spectec/src/backend-latex/render.ml index 25cdf317b0..80e1097be3 100644 --- a/spectec/src/backend-latex/render.ml +++ b/spectec/src/backend-latex/render.ml @@ -684,7 +684,7 @@ let render_ruledef env d = render_rule_deco env " \\, " id1 id2 "" | _ -> failwith "render_ruledef" -let render_conditions env = function +let render_red_conditions env = function | [] -> " & " | [Elem {it = ElsePr; _}] -> " &\\quad\n " ^ word "otherwise" | (Elem {it = ElsePr; _})::prems -> @@ -694,6 +694,16 @@ let render_conditions env = function " &\\quad\n " ^ word "if" ^ "~" ^ concat_map_nl " \\\\\n &&&&\\quad {\\land}~" "" (render_prem env) prems +let render_func_conditions env = function + | [] -> " & " + | [Elem {it = ElsePr; _}] -> " &\\quad\n " ^ word "otherwise" + | (Elem {it = ElsePr; _})::prems -> + " &\\quad\n " ^ word "otherwise, if" ^ "~" ^ + concat_map_nl " \\\\\n &&&\\quad {\\land}~" "" (render_prem env) prems + | prems -> + " &\\quad\n " ^ word "if" ^ "~" ^ + concat_map_nl " \\\\\n &&&\\quad {\\land}~" "" (render_prem env) prems + let render_reddef env d = match d.it with | RuleD (id1, id2, e, prems) -> @@ -704,14 +714,14 @@ let render_reddef env d = in render_rule_deco env "" id1 id2 " \\quad " ^ "& " ^ render_exp env e1 ^ " &" ^ render_atom env SqArrow ^ "& " ^ - render_exp env e2 ^ render_conditions env prems + render_exp env e2 ^ render_red_conditions env prems | _ -> failwith "render_reddef" let render_funcdef env d = match d.it with | DefD (id1, e1, e2, prems) -> render_exp env (CallE (id1, e1) $ d.at) ^ " &=& " ^ - render_exp env e2 ^ render_conditions env prems + render_exp env e2 ^ render_func_conditions env prems | _ -> failwith "render_funcdef" let rec render_sep_defs ?(sep = " \\\\\n") ?(br = " \\\\[0.8ex]\n") f = function From 42b276f192d8953bc031c2cc1181b0f94833cd5b Mon Sep 17 00:00:00 2001 From: Wonho Date: Fri, 14 Jul 2023 13:32:57 +0900 Subject: [PATCH 34/49] Filter with recursive --- spectec/spec/7-module.watsup | 28 +- spectec/test-frontend/TEST.md | 951 ++++---- spectec/test-latex/TEST.md | 33 +- spectec/test-middlend/TEST.md | 4000 ++++++++++++++++----------------- spectec/test-prose/TEST.md | 4 +- 5 files changed, 2478 insertions(+), 2538 deletions(-) diff --git a/spectec/spec/7-module.watsup b/spectec/spec/7-module.watsup index 9a8759d0fe..6cdfcd5879 100644 --- a/spectec/spec/7-module.watsup +++ b/spectec/spec/7-module.watsup @@ -2,18 +2,28 @@ def $funcs(externval*) : funcaddr* +def $funcs(epsilon) = epsilon +def $funcs((FUNC fa) externval'*) = fa $funcs(externval'*) +def $funcs(externval externval'*) = $funcs(externval'*) + -- otherwise + def $globals(externval*) : globaladdr* +def $globals(epsilon) = epsilon +def $globals((GLOBAL ga) externval'*) = ga $globals(externval'*) +def $globals(externval externval'*) = $globals(externval'*) + -- otherwise + def $tables(externval*) : tableaddr* -def $mems(externval*) : memaddr* +def $tables(epsilon) = epsilon +def $tables((TABLE ta) externval'*) = ta $tables(externval'*) +def $tables(externval externval'*) = $tables(externval'*) + -- otherwise -def $funcs(externval*) = fa'* - -- if fa'* = `[fa|FUNC fa <- externval*] -def $globals(externval*) = ga'* - -- if ga'* = `[ga|GLOBAL ga <- externval*] -def $tables(externval*) = ta'* - -- if ta'* = `[ta|TABLE ta <- externval*] -def $mems(externval*) = ma'* - -- if ma'* = `[ma|MEM ma <- externval*] +def $mems(externval*) : memaddr* +def $mems(epsilon) = epsilon +def $mems((MEM ma) externval'*) = ma $mems(externval'*) +def $mems(externval externval'*) = $mems(externval'*) + -- otherwise def $instexport(funcaddr*, globaladdr*, tableaddr*, memaddr*, export) : exportinst diff --git a/spectec/test-frontend/TEST.md b/spectec/test-frontend/TEST.md index 4fc0b320d6..8f7feef6ce 100644 --- a/spectec/test-frontend/TEST.md +++ b/spectec/test-frontend/TEST.md @@ -85,8 +85,8 @@ syntax fn = ;; 1-syntax.watsup:56.1-57.11 syntax resulttype = valtype* -;; 1-syntax.watsup:59.1-60.17 -syntax limits = `[%..%?]`(u32, u32?) +;; 1-syntax.watsup:59.1-60.16 +syntax limits = `[%..%]`(u32, u32) ;; 1-syntax.watsup:61.1-62.15 syntax globaltype = `MUT%?%`(()?, valtype) @@ -379,7 +379,7 @@ syntax context = {FUNC functype*, GLOBAL globaltype*, TABLE tabletype*, MEM memt relation Limits_ok: `|-%:%`(limits, nat) ;; 3-typing.watsup:22.1-24.24 rule _ {k : nat, n_1 : n, n_2 : n}: - `|-%:%`(`[%..%?]`(n_1, ?(n_2)), k) + `|-%:%`(`[%..%]`(n_1, n_2), k) -- if ((n_1 <= n_2) /\ (n_2 <= k)) ;; 3-typing.watsup:15.1-15.64 @@ -451,7 +451,7 @@ relation Resulttype_sub: `|-%*<:%*`(valtype*, valtype*) relation Limits_sub: `|-%<:%`(limits, limits) ;; 3-typing.watsup:83.1-86.21 rule _ {n_11 : n, n_12 : n, n_21 : n, n_22 : n}: - `|-%<:%`(`[%..%?]`(n_11, ?(n_12)), `[%..%?]`(n_21, ?(n_22))) + `|-%<:%`(`[%..%]`(n_11, n_12), `[%..%]`(n_21, n_22)) -- if (n_11 >= n_21) -- if (n_12 <= n_22) @@ -1052,10 +1052,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:180.1-187.5 +;; 4-runtime.watsup:183.1-190.5 rec { -;; 4-runtime.watsup:180.1-187.5 +;; 4-runtime.watsup:183.1-190.5 syntax admininstr = | UNREACHABLE | NOP @@ -1222,26 +1222,28 @@ def with_data : (state, dataidx, byte*) -> state ;; 4-runtime.watsup:165.1-165.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:167.1-167.49 +;; 4-runtime.watsup:167.1-167.63 def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:169.1-172.57 - def {i : nat, i' : nat, j? : nat?, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' - -- if (ti = {TYPE `%%`(`[%..%?]`(i, j?{j}), reftype), ELEM r'*{r'}}) + ;; 4-runtime.watsup:170.1-174.36 + def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, rt : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM r'*{r'}}) -- if (i' = (|r'*{r'}| + n)) - -- if (ti' = {TYPE `%%`(`[%..%?]`(i', j?{j}), reftype), ELEM r'*{r'} :: r^n{}}) + -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), rt), ELEM r'*{r'} :: r^n{}}) + -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) -;; 4-runtime.watsup:168.1-168.41 +;; 4-runtime.watsup:168.1-168.55 def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:173.1-176.66 - def {b* : byte*, i : nat, i' : nat, j? : nat?, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' - -- if (mi = {TYPE `%I8`(`[%..%?]`(i, j?{j})), DATA b*{b}}) + ;; 4-runtime.watsup:175.1-179.34 + def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) - -- if (mi' = {TYPE `%I8`(`[%..%?]`(i', j?{j})), DATA b*{b} :: 0^((n * 64) * $Ki){}}) + -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: 0^((n * 64) * $Ki){}}) + -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) -;; 4-runtime.watsup:189.1-192.21 +;; 4-runtime.watsup:192.1-195.21 rec { -;; 4-runtime.watsup:189.1-192.21 +;; 4-runtime.watsup:192.1-195.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -1470,135 +1472,135 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:214.1-216.39 + ;; 6-reduction.watsup:212.1-214.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:218.1-221.14 + ;; 6-reduction.watsup:216.1-219.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:223.1-227.15 + ;; 6-reduction.watsup:221.1-225.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) (val <: admininstr) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) (val <: admininstr) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:230.1-232.73 + ;; 6-reduction.watsup:228.1-230.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:234.1-237.14 + ;; 6-reduction.watsup:232.1-235.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:239.1-244.15 + ;; 6-reduction.watsup:237.1-242.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:246.1-250.15 + ;; 6-reduction.watsup:244.1-248.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:253.1-255.72 + ;; 6-reduction.watsup:251.1-253.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:257.1-260.14 + ;; 6-reduction.watsup:255.1-258.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:262.1-266.15 + ;; 6-reduction.watsup:260.1-264.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) ($elem(z, y).ELEM_eleminst[i] <: admininstr) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:273.1-275.53 + ;; 6-reduction.watsup:271.1-273.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + ($size(nt <: valtype) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:277.1-279.71 + ;; 6-reduction.watsup:275.1-277.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- if ($bytes_($size(nt <: valtype), c) = $mem(z, 0).DATA_meminst[(i + n_O) : ($size(nt <: valtype) / 8)]) - ;; 6-reduction.watsup:281.1-283.45 + ;; 6-reduction.watsup:279.1-281.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:285.1-287.55 + ;; 6-reduction.watsup:283.1-285.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, $size(nt <: valtype), sx, c))]) -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:307.1-309.44 + ;; 6-reduction.watsup:305.1-307.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:322.1-324.37 + ;; 6-reduction.watsup:318.1-320.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:326.1-329.14 + ;; 6-reduction.watsup:322.1-325.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:331.1-335.15 + ;; 6-reduction.watsup:327.1-331.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) (val <: admininstr) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) (val <: admininstr) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:338.1-340.69 + ;; 6-reduction.watsup:334.1-336.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:342.1-345.14 + ;; 6-reduction.watsup:338.1-341.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:347.1-352.15 + ;; 6-reduction.watsup:343.1-348.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:354.1-358.15 + ;; 6-reduction.watsup:350.1-354.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:361.1-363.70 + ;; 6-reduction.watsup:357.1-359.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:365.1-368.14 + ;; 6-reduction.watsup:361.1-364.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:370.1-374.15 + ;; 6-reduction.watsup:366.1-370.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise @@ -1633,327 +1635,313 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (ref <: admininstr) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-208.36 - rule table.grow-succeed {n : n, ref : ref, ti : tableinst, ti' : tableinst, x : idx, z : state}: - `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti'), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($table(z, x) = ti) - -- if ($grow_table(ti, n, ref) = ti') - -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) + ;; 6-reduction.watsup:204.1-206.47 + rule table.grow-succeed {n : n, ref : ref, ti : tableinst, x : idx, z : state}: + `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($grow_table($table(z, x), n, ref) = ti) - ;; 6-reduction.watsup:210.1-211.64 + ;; 6-reduction.watsup:208.1-209.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:269.1-270.59 + ;; 6-reduction.watsup:267.1-268.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:290.1-292.53 + ;; 6-reduction.watsup:288.1-290.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + ($size(nt <: valtype) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:294.1-296.35 + ;; 6-reduction.watsup:292.1-294.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), ($size(nt <: valtype) / 8), b*{b}), [])) -- if (b*{b} = $bytes_($size(nt <: valtype), c)) - ;; 6-reduction.watsup:298.1-300.45 + ;; 6-reduction.watsup:296.1-298.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:302.1-304.50 + ;; 6-reduction.watsup:300.1-302.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if (b*{b} = $bytes_(n, $wrap_(($size(nt <: valtype), n), c))) - ;; 6-reduction.watsup:312.1-316.34 - rule memory.grow-succeed {mi : meminst, mi' : meminst, n : n, z : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_meminst(z, 0, mi'), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - -- if ($mem(z, 0) = mi) - -- if ($grow_memory(mi, n) = mi') - -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) + ;; 6-reduction.watsup:310.1-312.41 + rule memory.grow-succeed {mi : meminst, n : n, z : state}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_meminst(z, 0, mi), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($grow_memory($mem(z, 0), n) = mi) - ;; 6-reduction.watsup:318.1-319.59 + ;; 6-reduction.watsup:314.1-315.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:377.1-378.59 + ;; 6-reduction.watsup:373.1-374.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) -;; 7-module.watsup:3.1-3.64 +;; 7-module.watsup:4.1-4.35 rec { -;; 7-module.watsup:3.1-3.64 -def alloc_import : (moduleinst, import*, externval*) -> moduleinst - ;; 7-module.watsup:5.1-5.43 - def {m : moduleinst} alloc_import(m, [], []) = m - ;; 7-module.watsup:7.1-12.60 - def {externtype : externtype, externval : externval, externval'* : externval*, fa : funcaddr, functype : functype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = FUNC_externtype(functype)) - -- if (externval = FUNC_externval(fa)) - -- if (m_new = m[FUNC_moduleinst =.. [fa]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) - ;; 7-module.watsup:14.1-19.60 - def {externtype : externtype, externval : externval, externval'* : externval*, ga : globaladdr, globaltype : globaltype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = GLOBAL_externtype(globaltype)) - -- if (externval = GLOBAL_externval(ga)) - -- if (m_new = m[GLOBAL_moduleinst =.. [ga]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) - ;; 7-module.watsup:21.1-26.60 - def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name, ta : tableaddr, tabletype : tabletype} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = TABLE_externtype(tabletype)) - -- if (externval = TABLE_externval(ta)) - -- if (m_new = m[TABLE_moduleinst =.. [ta]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) - ;; 7-module.watsup:28.1-33.60 - def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, ma : memaddr, memtype : memtype, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = MEM_externtype(memtype)) - -- if (externval = MEM_externval(ma)) - -- if (m_new = m[MEM_moduleinst =.. [ma]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) +;; 7-module.watsup:4.1-4.35 +def funcs : externval* -> funcaddr* + ;; 7-module.watsup:5.1-5.30 + def funcs([]) = [] + ;; 7-module.watsup:6.1-6.59 + def {externval'* : externval*, fa : funcaddr} funcs([FUNC_externval(fa)] :: externval'*{externval'}) = [fa] :: $funcs(externval'*{externval'}) + ;; 7-module.watsup:7.1-8.15 + def {externval : externval, externval'* : externval*} funcs([externval] :: externval'*{externval'}) = $funcs(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:36.1-36.51 +;; 7-module.watsup:10.1-10.39 rec { -;; 7-module.watsup:36.1-36.51 -def alloc_func : (state, func*) -> (store, funcaddr*) - ;; 7-module.watsup:38.1-38.48 - def {f : frame, s : store} alloc_func(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:40.1-44.56 - def {f : frame, fa : funcaddr, fa'* : funcaddr*, fi : funcinst, func : func, func'* : func*, s : store, s_new : store, s_res : store} alloc_func(`%;%`(s, f), [func] :: func'*{func'}) = (s_res, [fa] :: fa'*{fa'}) - -- if (fi = {MODULE f.MODULE_frame, CODE func}) - -- if (fa = |$funcinst(`%;%`(s, f))|) - -- if (s_new = s[FUNC_store =.. [fi]]) - -- if ((s_res, fa'*{fa'}) = $alloc_func(`%;%`(s_new, f), func'*{func'})) +;; 7-module.watsup:10.1-10.39 +def globals : externval* -> globaladdr* + ;; 7-module.watsup:11.1-11.32 + def globals([]) = [] + ;; 7-module.watsup:12.1-12.65 + def {externval'* : externval*, ga : globaladdr} globals([GLOBAL_externval(ga)] :: externval'*{externval'}) = [ga] :: $globals(externval'*{externval'}) + ;; 7-module.watsup:13.1-14.15 + def {externval : externval, externval'* : externval*} globals([externval] :: externval'*{externval'}) = $globals(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:47.1-47.57 +;; 7-module.watsup:16.1-16.37 rec { -;; 7-module.watsup:47.1-47.57 -def alloc_global : (state, global*) -> (store, globaladdr*) - ;; 7-module.watsup:49.1-49.50 - def {f : frame, s : store} alloc_global(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:51.1-57.60 - def {f : frame, ga : globaladdr, ga'* : globaladdr*, gi : globalinst, global : global, global'* : global*, globaltype : globaltype, instr* : instr*, s : store, s_new : store, s_res : store, val : val} alloc_global(`%;%`(s, f), [global] :: global'*{global'}) = (s_res, [ga] :: ga'*{ga'}) - -- if (global = GLOBAL(globaltype, instr*{instr})) - -- Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), (instr <: admininstr)*{instr}), [(val <: admininstr)]) - -- if (gi = {TYPE globaltype, VALUE val}) - -- if (ga = |$globalinst(`%;%`(s, f))|) - -- if (s_new = s[GLOBAL_store =.. [gi]]) - -- if ((s_res, ga'*{ga'}) = $alloc_global(`%;%`(s_new, f), global'*{global'})) +;; 7-module.watsup:16.1-16.37 +def tables : externval* -> tableaddr* + ;; 7-module.watsup:17.1-17.31 + def tables([]) = [] + ;; 7-module.watsup:18.1-18.62 + def {externval'* : externval*, ta : tableaddr} tables([TABLE_externval(ta)] :: externval'*{externval'}) = [ta] :: $tables(externval'*{externval'}) + ;; 7-module.watsup:19.1-20.15 + def {externval : externval, externval'* : externval*} tables([externval] :: externval'*{externval'}) = $tables(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:60.1-60.54 +;; 7-module.watsup:22.1-22.33 rec { -;; 7-module.watsup:60.1-60.54 -def alloc_table : (state, table*) -> (store, tableaddr*) - ;; 7-module.watsup:62.1-62.49 - def {f : frame, s : store} alloc_table(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:64.1-70.58 - def {f : frame, i : nat, j? : nat?, reftype : reftype, s : store, s_new : store, s_res : store, ta : tableaddr, ta'* : tableaddr*, table : table, table'* : table*, tabletype : tabletype, ti : tableinst} alloc_table(`%;%`(s, f), [table] :: table'*{table'}) = (s_res, [ta] :: ta'*{ta'}) - -- if (table = TABLE(tabletype)) - -- if (tabletype = `%%`(`[%..%?]`(i, j?{j}), reftype)) - -- if (ti = {TYPE tabletype, ELEM REF.NULL_ref(reftype)^i{}}) - -- if (ta = |$tableinst(`%;%`(s, f))|) - -- if (s_new = s[TABLE_store =.. [ti]]) - -- if ((s_res, ta'*{ta'}) = $alloc_table(`%;%`(s_new, f), table'*{table'})) +;; 7-module.watsup:22.1-22.33 +def mems : externval* -> memaddr* + ;; 7-module.watsup:23.1-23.29 + def mems([]) = [] + ;; 7-module.watsup:24.1-24.56 + def {externval'* : externval*, ma : memaddr} mems([MEM_externval(ma)] :: externval'*{externval'}) = [ma] :: $mems(externval'*{externval'}) + ;; 7-module.watsup:25.1-26.15 + def {externval : externval, externval'* : externval*} mems([externval] :: externval'*{externval'}) = $mems(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:73.1-73.48 +;; 7-module.watsup:29.1-29.83 +def instexport : (funcaddr*, globaladdr*, tableaddr*, memaddr*, export) -> exportinst + ;; 7-module.watsup:30.1-30.95 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, FUNC_externuse(x))) = {NAME name, VALUE FUNC_externval(fa*{fa}[x])} + ;; 7-module.watsup:31.1-31.99 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, GLOBAL_externuse(x))) = {NAME name, VALUE GLOBAL_externval(ga*{ga}[x])} + ;; 7-module.watsup:32.1-32.97 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, TABLE_externuse(x))) = {NAME name, VALUE TABLE_externval(ta*{ta}[x])} + ;; 7-module.watsup:33.1-33.93 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, MEM_externuse(x))) = {NAME name, VALUE MEM_externval(ma*{ma}[x])} + +;; 7-module.watsup:36.1-36.60 +def allocfunc : (store, moduleinst, func) -> (store, funcaddr) + ;; 7-module.watsup:37.1-38.37 + def {fi : funcinst, func : func, m : moduleinst, s : store} allocfunc(s, m, func) = (s[FUNC_store =.. [fi]], |s.FUNC_store|) + -- if (fi = {MODULE m, CODE func}) + +;; 7-module.watsup:40.1-40.63 rec { -;; 7-module.watsup:73.1-73.48 -def alloc_mem : (state, mem*) -> (store, memaddr*) - ;; 7-module.watsup:75.1-75.47 - def {f : frame, s : store} alloc_mem(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:77.1-83.54 - def {f : frame, i : nat, j? : nat?, ma : memaddr, ma'* : memaddr*, mem : mem, mem'* : mem*, memtype : memtype, mi : meminst, s : store, s_new : store, s_res : store} alloc_mem(`%;%`(s, f), [mem] :: mem'*{mem'}) = (s_res, [ma] :: ma'*{ma'}) - -- if (mem = MEMORY(memtype)) - -- if (memtype = `%I8`(`[%..%?]`(i, j?{j}))) - -- if (mi = {TYPE memtype, DATA 0^((i * 64) * $Ki){}}) - -- if (ma = |$meminst(`%;%`(s, f))|) - -- if (s_new = s[MEM_store =.. [mi]]) - -- if ((s_res, ma'*{ma'}) = $alloc_mem(`%;%`(s_new, f), mem'*{mem'})) +;; 7-module.watsup:40.1-40.63 +def allocfuncs : (store, moduleinst, func*) -> (store, funcaddr*) + ;; 7-module.watsup:41.1-41.46 + def {m : moduleinst, s : store} allocfuncs(s, m, []) = (s, []) + ;; 7-module.watsup:42.1-44.50 + def {fa : funcaddr, fa'* : funcaddr*, func : func, func'* : func*, m : moduleinst, s : store, s_1 : store, s_2 : store} allocfuncs(s, m, [func] :: func'*{func'}) = (s_2, [fa] :: fa'*{fa'}) + -- if ((s_1, fa) = $allocfunc(s, m, func)) + -- if ((s_2, fa'*{fa'}) = $allocfuncs(s_1, m, func'*{func'})) } -;; 7-module.watsup:86.1-86.51 +;; 7-module.watsup:46.1-46.63 +def allocglobal : (store, globaltype, val) -> (store, globaladdr) + ;; 7-module.watsup:47.1-48.44 + def {gi : globalinst, globaltype : globaltype, s : store, val : val} allocglobal(s, globaltype, val) = (s[GLOBAL_store =.. [gi]], |s.GLOBAL_store|) + -- if (gi = {TYPE globaltype, VALUE val}) + +;; 7-module.watsup:50.1-50.67 rec { -;; 7-module.watsup:86.1-86.51 -def alloc_elem : (state, elem*) -> (store, elemaddr*) - ;; 7-module.watsup:88.1-88.48 - def {f : frame, s : store} alloc_elem(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:90.1-96.56 - def {ea : elemaddr, ea'* : elemaddr*, ei : eleminst, elem : elem, elem'* : elem*, elemmode? : elemmode?, f : frame, instr** : instr**, ref* : ref*, reftype : reftype, s : store, s_new : store, s_res : store} alloc_elem(`%;%`(s, f), [elem] :: elem'*{elem'}) = (s_res, [ea] :: ea'*{ea'}) - -- if (elem = `ELEM%%*%?`(reftype, instr*{instr}*{instr}, elemmode?{elemmode})) - -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), (instr <: admininstr)*{instr}), [(ref <: admininstr)]))*{instr ref} - -- if (ei = {TYPE reftype, ELEM ref*{ref}}) - -- if (ea = |$eleminst(`%;%`(s, f))|) - -- if (s_new = s[ELEM_store =.. [ei]]) - -- if ((s_res, ea'*{ea'}) = $alloc_elem(`%;%`(s_new, f), elem'*{elem'})) +;; 7-module.watsup:50.1-50.67 +def allocglobals : (store, globaltype*, val*) -> (store, globaladdr*) + ;; 7-module.watsup:51.1-51.54 + def {s : store} allocglobals(s, [], []) = (s, []) + ;; 7-module.watsup:52.1-54.62 + def {ga : globaladdr, ga'* : globaladdr*, globaltype : globaltype, globaltype'* : globaltype*, s : store, s_1 : store, s_2 : store, val : val, val'* : val*} allocglobals(s, [globaltype] :: globaltype'*{globaltype'}, [val] :: val'*{val'}) = (s_2, [ga] :: ga'*{ga'}) + -- if ((s_1, ga) = $allocglobal(s, globaltype, val)) + -- if ((s_2, ga'*{ga'}) = $allocglobals(s_1, globaltype'*{globaltype'}, val'*{val'})) } -;; 7-module.watsup:99.1-99.51 +;; 7-module.watsup:56.1-56.55 +def alloctable : (store, tabletype) -> (store, tableaddr) + ;; 7-module.watsup:57.1-58.59 + def {i : nat, j : nat, rt : reftype, s : store, ti : tableinst} alloctable(s, `%%`(`[%..%]`(i, j), rt)) = (s[TABLE_store =.. [ti]], |s.TABLE_store|) + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM REF.NULL_ref(rt)^i{}}) + +;; 7-module.watsup:60.1-60.58 rec { -;; 7-module.watsup:99.1-99.51 -def alloc_data : (state, data*) -> (store, dataaddr*) - ;; 7-module.watsup:101.1-101.48 - def {f : frame, s : store} alloc_data(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:103.1-108.56 - def {byte* : byte*, da : dataaddr, da'* : dataaddr*, data : data, data'* : data*, datamode? : datamode?, di : datainst, f : frame, s : store, s_new : store, s_res : store} alloc_data(`%;%`(s, f), [data] :: data'*{data'}) = (s_res, [da] :: da'*{da'}) - -- if (data = `DATA%*%?`(byte*{byte}, datamode?{datamode})) - -- if (di = {DATA byte*{byte}}) - -- if (da = |$datainst(`%;%`(s, f))|) - -- if (s_new = s[DATA_store =.. [di]]) - -- if ((s_res, da'*{da'}) = $alloc_data(`%;%`(s_new, f), data'*{data'})) +;; 7-module.watsup:60.1-60.58 +def alloctables : (store, tabletype*) -> (store, tableaddr*) + ;; 7-module.watsup:61.1-61.44 + def {s : store} alloctables(s, []) = (s, []) + ;; 7-module.watsup:62.1-64.53 + def {s : store, s_1 : store, s_2 : store, ta : tableaddr, ta'* : tableaddr*, tabletype : tabletype, tabletype'* : tabletype*} alloctables(s, [tabletype] :: tabletype'*{tabletype'}) = (s_2, [ta] :: ta'*{ta'}) + -- if ((s_1, ta) = $alloctable(s, tabletype)) + -- if ((s_2, ta'*{ta'}) = $alloctables(s_1, tabletype'*{tabletype'})) } -;; 7-module.watsup:111.1-111.62 +;; 7-module.watsup:66.1-66.49 +def allocmem : (store, memtype) -> (store, memaddr) + ;; 7-module.watsup:67.1-68.62 + def {i : nat, j : nat, mi : meminst, s : store} allocmem(s, `%I8`(`[%..%]`(i, j))) = (s[MEM_store =.. [mi]], |s.MEM_store|) + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA 0^((i * 64) * $Ki){}}) + +;; 7-module.watsup:70.1-70.52 rec { -;; 7-module.watsup:111.1-111.62 -def replace_moduleinst : (store, funcaddr*, moduleinst) -> store - ;; 7-module.watsup:113.1-113.43 - def {m : moduleinst, s : store} replace_moduleinst(s, [], m) = s - ;; 7-module.watsup:115.1-117.52 - def {fa : funcaddr, fa'* : funcaddr*, m : moduleinst, s : store, s_new : store, s_res : store} replace_moduleinst(s, [fa] :: fa'*{fa'}, m) = s_res - -- if (s_new = s[FUNC_store[fa].MODULE_funcinst = m]) - -- if (s_res = $replace_moduleinst(s_new, fa'*{fa'}, m)) +;; 7-module.watsup:70.1-70.52 +def allocmems : (store, memtype*) -> (store, memaddr*) + ;; 7-module.watsup:71.1-71.42 + def {s : store} allocmems(s, []) = (s, []) + ;; 7-module.watsup:72.1-74.49 + def {ma : memaddr, ma'* : memaddr*, memtype : memtype, memtype'* : memtype*, s : store, s_1 : store, s_2 : store} allocmems(s, [memtype] :: memtype'*{memtype'}) = (s_2, [ma] :: ma'*{ma'}) + -- if ((s_1, ma) = $allocmem(s, memtype)) + -- if ((s_2, ma'*{ma'}) = $allocmems(s_1, memtype'*{memtype'})) } -;; 7-module.watsup:120.1-120.51 -def alloc_export : (moduleinst, export) -> exportinst - ;; 7-module.watsup:122.1-126.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = FUNC_externuse(x)) - -- if (externval = FUNC_externval(m.FUNC_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - ;; 7-module.watsup:128.1-132.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = GLOBAL_externuse(x)) - -- if (externval = GLOBAL_externval(m.GLOBAL_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - ;; 7-module.watsup:134.1-138.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = TABLE_externuse(x)) - -- if (externval = TABLE_externval(m.TABLE_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - ;; 7-module.watsup:140.1-144.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = MEM_externuse(x)) - -- if (externval = MEM_externval(m.MEM_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - -;; 7-module.watsup:147.1-147.67 -def alloc_module : (store, module, externval*) -> (store, moduleinst) - ;; 7-module.watsup:149.1-163.56 - def {da* : dataaddr*, data* : data*, ea* : elemaddr*, elem* : elem*, export* : export*, externval* : externval*, f : frame, fa* : funcaddr*, func* : func*, ga* : globaladdr*, global* : global*, import* : import*, m_ex : moduleinst, m_im : moduleinst, m_init : moduleinst, m_res : moduleinst, ma* : memaddr*, mem* : mem*, module : module, s : store, s_data : store, s_elem : store, s_func : store, s_global : store, s_mem : store, s_res : store, s_table : store, start? : start?, ta* : tableaddr*, table* : table*, xi* : exportinst*} alloc_module(s, module, externval*{externval}) = (s_res, m_res) - -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) - -- if (m_init = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) - -- if (m_im = $alloc_import(m_init, import*{import}, externval*{externval})) - -- if (f = {LOCAL [], MODULE m_im}) - -- if ((s_func, fa*{fa}) = $alloc_func(`%;%`(s, f), func*{func})) - -- if ((s_global, ga*{ga}) = $alloc_global(`%;%`(s_func, f), global*{global})) - -- if ((s_table, ta*{ta}) = $alloc_table(`%;%`(s_global, f), table*{table})) - -- if ((s_mem, ma*{ma}) = $alloc_mem(`%;%`(s_table, f), mem*{mem})) - -- if ((s_elem, ea*{ea}) = $alloc_elem(`%;%`(s_mem, f), elem*{elem})) - -- if ((s_data, da*{da}) = $alloc_data(`%;%`(s_elem, f), data*{data})) - -- if (m_ex = m_im ++ {FUNC fa*{fa}, GLOBAL ga*{ga}, TABLE ta*{ta}, MEM ma*{ma}, ELEM ea*{ea}, DATA da*{da}, EXPORT []}) - -- if (xi*{xi} = $alloc_export(m_ex, export)*{export}) - -- if (m_res = m_ex[EXPORT_moduleinst = xi*{xi}]) - -- if (s_res = $replace_moduleinst(s_data, fa*{fa}, m_res)) - -;; 7-module.watsup:166.1-166.41 +;; 7-module.watsup:76.1-76.57 +def allocelem : (store, reftype, ref*) -> (store, elemaddr) + ;; 7-module.watsup:77.1-78.36 + def {ei : eleminst, ref* : ref*, rt : reftype, s : store} allocelem(s, rt, ref*{ref}) = (s[ELEM_store =.. [ei]], |s.ELEM_store|) + -- if (ei = {TYPE rt, ELEM ref*{ref}}) + +;; 7-module.watsup:80.1-80.63 rec { -;; 7-module.watsup:166.1-166.41 -def run_elem : (state, elem*, idx) -> state - ;; 7-module.watsup:168.1-168.41 - def {f : frame, i : nat, s : store} run_elem(`%;%`(s, f), [], i) = `%;%`(s, f) - ;; 7-module.watsup:170.1-172.59 - def {elem : elem, elem'* : elem*, expr* : expr*, f : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) - -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?())) - -- if ($run_elem(`%;%`(s, f), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:174.1-179.67 - def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, reftype : reftype, s : store, s_new : store, s_res : store, x : idx} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) - -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) - -- if (n = |expr*{expr}|) - -- if (elemmode = TABLE_elemmode(x, instr*{instr})) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), (instr <: admininstr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, i) ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) - -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:181.1-185.67 - def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_new : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) - -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) - -- if (elemmode = DECLARE_elemmode) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), [ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) - -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) +;; 7-module.watsup:80.1-80.63 +def allocelems : (store, reftype*, ref**) -> (store, elemaddr*) + ;; 7-module.watsup:81.1-81.52 + def {s : store} allocelems(s, [], []) = (s, []) + ;; 7-module.watsup:82.1-84.53 + def {ea : elemaddr, ea'* : elemaddr*, ref* : ref*, ref'** : ref**, rt : reftype, rt'* : reftype*, s : store, s_1 : store, s_2 : store} allocelems(s, [rt] :: rt'*{rt'}, [ref]*{ref} :: ref'*{ref'}*{ref'}) = (s_2, [ea] :: ea'*{ea'}) + -- if ((s_1, ea) = $allocelem(s, rt, ref*{ref})) + -- if ((s_2, ea'*{ea'}) = $allocelems(s_2, rt'*{rt'}, ref'*{ref'}*{ref'})) } -;; 7-module.watsup:188.1-188.41 +;; 7-module.watsup:86.1-86.49 +def allocdata : (store, byte*) -> (store, dataaddr) + ;; 7-module.watsup:87.1-88.28 + def {byte* : byte*, di : datainst, s : store} allocdata(s, byte*{byte}) = (s[DATA_store =.. [di]], |s.DATA_store|) + -- if (di = {DATA byte*{byte}}) + +;; 7-module.watsup:90.1-90.52 rec { -;; 7-module.watsup:188.1-188.41 -def run_data : (state, data*, idx) -> state - ;; 7-module.watsup:190.1-190.41 - def {f : frame, i : nat, s : store} run_data(`%;%`(s, f), [], i) = `%;%`(s, f) - ;; 7-module.watsup:192.1-194.59 - def {byte* : byte*, data : data, data'* : data*, f : frame, f_res : frame, i : nat, s : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) - -- if (data = `DATA%*%?`(byte*{byte}, ?())) - -- if ($run_data(`%;%`(s, f), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:196.1-201.67 - def {byte* : byte*, data : data, data'* : data*, datamode : datamode, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, s : store, s_new : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) - -- if (data = `DATA%*%?`(byte*{byte}, ?(datamode))) +;; 7-module.watsup:90.1-90.52 +def allocdatas : (store, byte**) -> (store, dataaddr*) + ;; 7-module.watsup:91.1-91.43 + def {s : store} allocdatas(s, []) = (s, []) + ;; 7-module.watsup:92.1-94.48 + def {byte* : byte*, byte'** : byte**, da : dataaddr, da'* : dataaddr*, s : store, s_1 : store, s_2 : store} allocdatas(s, [byte]*{byte} :: byte'*{byte'}*{byte'}) = (s_2, [da] :: da'*{da'}) + -- if ((s_1, da) = $allocdata(s, byte*{byte})) + -- if ((s_2, da'*{da'}) = $allocdatas(s_1, byte'*{byte'}*{byte'})) +} + +;; 7-module.watsup:97.1-97.81 +def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) + ;; 7-module.watsup:98.1-135.54 + def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i : nat, import* : import*, m : moduleinst, ma* : memaddr*, ma_ex* : memaddr*, memtype^n_mem : memtype^n_mem, module : module, n_data : n, n_elem : n, n_func : n, n_global : n, n_mem : n, n_table : n, ref** : ref**, rt^n_elem : reftype^n_elem, s : store, s_1 : store, s_2 : store, s_3 : store, s_4 : store, s_5 : store, s_6 : store, start? : start?, ta* : tableaddr*, ta_ex* : tableaddr*, tabletype^n_table : tabletype^n_table, val* : val*, xi* : exportinst*} allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref}) = (s_6, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func^n_func{func}, GLOBAL(globaltype, expr_1)^n_global{expr_1 globaltype}, TABLE(tabletype)^n_table{tabletype}, MEMORY(memtype)^n_mem{memtype}, `ELEM%%*%?`(rt, expr_2*{expr_2}, elemmode?{elemmode})^n_elem{elemmode expr_2 rt}, `DATA%*%?`(byte*{byte}, datamode?{datamode})^n_data{byte datamode}, start?{start}, export*{export})) + -- if (fa_ex*{fa_ex} = $funcs(externval*{externval})) + -- if (ga_ex*{ga_ex} = $globals(externval*{externval})) + -- if (ta_ex*{ta_ex} = $tables(externval*{externval})) + -- if (ma_ex*{ma_ex} = $mems(externval*{externval})) + -- if (fa*{fa} = (|s.FUNC_store| + i)^(i instr* + ;; 7-module.watsup:139.1-139.46 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?()), i) = [] + ;; 7-module.watsup:140.1-140.62 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(DECLARE_elemmode)), i) = [ELEM.DROP_instr(i)] + ;; 7-module.watsup:141.1-143.20 + def {expr* : expr*, i : nat, instr* : instr*, n : n, reftype : reftype, x : idx} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(TABLE_elemmode(x, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) TABLE.INIT_instr(x, i) ELEM.DROP_instr(i)] + -- if (n = |expr*{expr}|) + +;; 7-module.watsup:145.1-145.33 +def rundata : (data, idx) -> instr* + ;; 7-module.watsup:146.1-146.38 + def {byte* : byte*, i : nat} rundata(`DATA%*%?`(byte*{byte}, ?()), i) = [] + ;; 7-module.watsup:147.1-149.20 + def {byte* : byte*, i : nat, instr* : instr*, n : n} rundata(`DATA%*%?`(byte*{byte}, ?(MEMORY_datamode(0, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) MEMORY.INIT_instr(i) DATA.DROP_instr(i)] -- if (n = |byte*{byte}|) - -- if (datamode = MEMORY_datamode(0, instr*{instr})) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), (instr <: admininstr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(i) DATA.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) - -- if ($run_data(`%;%`(s_new, f_new), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) + +;; 7-module.watsup:152.1-152.36 +rec { + +;; 7-module.watsup:152.1-152.36 +def concat_instr : instr** -> instr* + ;; 7-module.watsup:153.1-153.37 + def concat_instr([]) = [] + ;; 7-module.watsup:154.1-154.68 + def {instr* : instr*, instr'** : instr**} concat_instr([instr]*{instr} :: instr'*{instr'}*{instr'}) = instr*{instr} :: $concat_instr(instr'*{instr'}*{instr'}) } -;; 7-module.watsup:206.1-206.68 -def instantiation : (store, module, externval*) -> (store, moduleinst) - ;; 7-module.watsup:208.1-213.61 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) - -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(), export*{export})) - -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) - -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) - -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:215.1-222.62 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) - -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(start), export*{export})) - -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) +;; 7-module.watsup:157.1-157.55 +def instantiation : (store, module, externval*) -> config + ;; 7-module.watsup:158.1-180.28 + def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i : nat, import* : import*, instr_1** : instr**, instr_2*** : instr***, instr_data* : instr*, instr_elem* : instr*, j : nat, m : moduleinst, m_init : moduleinst, mem* : mem*, module : module, n_data : n, n_elem : n, ref** : ref**, reftype* : reftype*, s : store, s' : store, start? : start?, table* : table*, val* : val*, x? : idx?} instantiation(s, module, externval*{externval}) = `%;%*`(`%;%`(s', f), (instr_elem <: admininstr)*{instr_elem} :: (instr_data <: admininstr)*{instr_data} :: CALL_admininstr(x)?{x}) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) + -- if (m_init = {FUNC $funcs(externval*{externval}), GLOBAL $globals(externval*{externval}), TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f_init = {LOCAL [], MODULE m_init}) + -- (if (global = GLOBAL(globaltype, instr_1*{instr_1})))*{global globaltype instr_1} + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), (instr_1 <: admininstr)*{instr_1}), [(val <: admininstr)]))*{instr_1 val} + -- (if (elem = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})))*{elem elemmode instr_2 reftype} + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), (instr_2 <: admininstr)*{instr_2}), [(ref <: admininstr)]))*{instr_2 ref}*{instr_2 ref} + -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) - -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_data, f_data)) - -- if (start = START(x)) - -- Step: `%~>%`(`%;%*`(`%;%`(s_data, f_data), [CALL_admininstr(x)]), `%;%*`(`%;%`(s_res, f_res), [])) - -;; 7-module.watsup:227.1-227.55 -def invocation : (store, funcaddr, val*) -> (store, val*) - ;; 7-module.watsup:229.1-236.55 - def {expr : expr, f : frame, f' : frame, fa : funcaddr, functype : functype, m : moduleinst, s : store, s' : store, val* : val*, val'* : val*, valtype* : valtype*, valtype'* : valtype*} invocation(s, fa, val*{val}) = (s', val'*{val'}) + -- if (n_elem = |elem*{elem}|) + -- if (instr_elem*{instr_elem} = $concat_instr($runelem(elem*{elem}[i], i)^(i config + ;; 7-module.watsup:184.1-196.52 + def {expr : expr, f : frame, fa : funcaddr, functype : functype, k : nat, m : moduleinst, n : n, s : store, val^n : val^n, valtype* : valtype*, valtype_param^n : valtype^n, valtype_res^k : valtype^k} invocation(s, fa, val^n{val}) = `%;%*`(`%;%`(s, f), (val <: admininstr)^n{val} :: [CALL_ADDR_admininstr(fa)]) -- if (m = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) -- if (f = {LOCAL [], MODULE m}) -- if ($funcinst(`%;%`(s, f))[fa].CODE_funcinst = `FUNC%%*%`(functype, valtype*{valtype}, expr)) - -- if (functype = `%->%`(valtype*{valtype}, valtype'*{valtype'})) - -- if (|val*{val}| = |valtype*{valtype}|) - -- if (|val'*{val'}| = |valtype'*{valtype'}|) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), (val <: admininstr)*{val} :: [CALL_ADDR_admininstr(fa)]), `%;%*`(`%;%`(s', f'), (val' <: admininstr)*{val'})) + -- if (functype = `%->%`(valtype_param^n{valtype_param}, valtype_res^k{valtype_res})) == IL Validation... == Latex Generation... @@ -2010,7 +1998,7 @@ $$ $$ \begin{array}{@{}lrrl@{}} \mbox{(result type)} & \mathit{resulttype} &::=& {\mathit{valtype}^\ast} \\ -\mbox{(limits)} & \mathit{limits} &::=& [\mathit{u{\scriptstyle32}} .. {\mathit{u{\scriptstyle32}}^?}] \\ +\mbox{(limits)} & \mathit{limits} &::=& [\mathit{u{\scriptstyle32}} .. \mathit{u{\scriptstyle32}}] \\ \mbox{(global type)} & \mathit{globaltype} &::=& {\mathsf{mut}^?}~\mathit{valtype} \\ \mbox{(function type)} & \mathit{functype} &::=& \mathit{resulttype} \rightarrow \mathit{resulttype} \\ \mbox{(table type)} & \mathit{tabletype} &::=& \mathit{limits}~\mathit{reftype} \\ @@ -3669,10 +3657,11 @@ $$ \begin{array}{@{}lcl@{}l@{}} \mathrm{grow}_{\mathit{table}}(\mathit{ti},\, \mathit{n},\, \mathit{r}) &=& {\mathit{ti}'} &\quad \mbox{if}~\mathit{ti} = \{ \begin{array}[t]{@{}l@{}} -\mathsf{type}~[\mathit{i} .. {\mathit{j}^?}]~\mathit{reftype},\; \mathsf{elem}~{{\mathit{r}'}^\ast} \}\end{array} \\ - &&&&\quad {\land}~{\mathit{i}'} = {|{{\mathit{r}'}^\ast}|} + \mathit{n} \\ - &&&&\quad {\land}~{\mathit{ti}'} = \{ \begin{array}[t]{@{}l@{}} -\mathsf{type}~[{\mathit{i}'} .. {\mathit{j}^?}]~\mathit{reftype},\; \mathsf{elem}~{{\mathit{r}'}^\ast}~{\mathit{r}^{\mathit{n}}} \}\end{array} \\ +\mathsf{type}~[\mathit{i} .. \mathit{j}]~\mathit{rt},\; \mathsf{elem}~{{\mathit{r}'}^\ast} \}\end{array} \\ + &&&\quad {\land}~{\mathit{i}'} = {|{{\mathit{r}'}^\ast}|} + \mathit{n} \\ + &&&\quad {\land}~{\mathit{ti}'} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{type}~[{\mathit{i}'} .. \mathit{j}]~\mathit{rt},\; \mathsf{elem}~{{\mathit{r}'}^\ast}~{\mathit{r}^{\mathit{n}}} \}\end{array} \\ + &&&\quad {\land}~{ \vdash }\;{\mathit{ti}'}.\mathsf{type} : \mathsf{ok} \\ \end{array} $$ @@ -3680,10 +3669,11 @@ $$ \begin{array}{@{}lcl@{}l@{}} \mathrm{grow}_{\mathit{memory}}(\mathit{mi},\, \mathit{n}) &=& {\mathit{mi}'} &\quad \mbox{if}~\mathit{mi} = \{ \begin{array}[t]{@{}l@{}} -\mathsf{type}~([\mathit{i} .. {\mathit{j}^?}]~\mathsf{i{\scriptstyle8}}),\; \mathsf{data}~{\mathit{b}^\ast} \}\end{array} \\ - &&&&\quad {\land}~{\mathit{i}'} = {|{\mathit{b}^\ast}|} / (64 \cdot \mathrm{Ki}) + \mathit{n} \\ - &&&&\quad {\land}~{\mathit{mi}'} = \{ \begin{array}[t]{@{}l@{}} -\mathsf{type}~([{\mathit{i}'} .. {\mathit{j}^?}]~\mathsf{i{\scriptstyle8}}),\; \mathsf{data}~{\mathit{b}^\ast}~{0^{\mathit{n} \cdot 64 \cdot \mathrm{Ki}}} \}\end{array} \\ +\mathsf{type}~([\mathit{i} .. \mathit{j}]~\mathsf{i{\scriptstyle8}}),\; \mathsf{data}~{\mathit{b}^\ast} \}\end{array} \\ + &&&\quad {\land}~{\mathit{i}'} = {|{\mathit{b}^\ast}|} / (64 \cdot \mathrm{Ki}) + \mathit{n} \\ + &&&\quad {\land}~{\mathit{mi}'} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{type}~([{\mathit{i}'} .. \mathit{j}]~\mathsf{i{\scriptstyle8}}),\; \mathsf{data}~{\mathit{b}^\ast}~{0^{\mathit{n} \cdot 64 \cdot \mathrm{Ki}}} \}\end{array} \\ + &&&\quad {\land}~{ \vdash }\;{\mathit{mi}'}.\mathsf{type} : \mathsf{ok} \\ \end{array} $$ @@ -3960,10 +3950,8 @@ $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}table.grow{-}succeed}]} \quad & \mathit{z} ; \mathit{ref}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.grow}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{table}[\mathit{x}] = {\mathit{ti}'}] ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~{|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}.\mathsf{elem}|}) &\quad - \mbox{if}~{\mathit{z}.\mathsf{table}}{[\mathit{x}]} = \mathit{ti} \\ - &&&&\quad {\land}~\mathrm{grow}_{\mathit{table}}(\mathit{ti},\, \mathit{n},\, \mathit{ref}) = {\mathit{ti}'} \\ - &&&&\quad {\land}~{ \vdash }\;{\mathit{ti}'}.\mathsf{type} : \mathsf{ok} \\ +{[\textsc{\scriptsize E{-}table.grow{-}succeed}]} \quad & \mathit{z} ; \mathit{ref}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.grow}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{table}[\mathit{x}] = \mathit{ti}] ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~{|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}.\mathsf{elem}|}) &\quad + \mbox{if}~\mathrm{grow}_{\mathit{table}}({\mathit{z}.\mathsf{table}}{[\mathit{x}]},\, \mathit{n},\, \mathit{ref}) = \mathit{ti} \\ {[\textsc{\scriptsize E{-}table.grow{-}fail}]} \quad & \mathit{z} ; \mathit{ref}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.grow}~\mathit{x}) &\hookrightarrow& \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~-1) & \\ \end{array} $$ @@ -4060,10 +4048,8 @@ $$ $$ \begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}memory.grow{-}succeed}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.grow}) &\hookrightarrow& \mathit{z}[\mathsf{mem}[0] = {\mathit{mi}'}] ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~{|{\mathit{z}.\mathsf{mem}}{[0]}.\mathsf{data}|} / (64 \cdot \mathrm{Ki})) &\quad - \mbox{if}~{\mathit{z}.\mathsf{mem}}{[0]} = \mathit{mi} \\ - &&&&\quad {\land}~\mathrm{grow}_{\mathit{memory}}(\mathit{mi},\, \mathit{n}) = {\mathit{mi}'} \\ - &&&&\quad {\land}~{ \vdash }\;{\mathit{mi}'}.\mathsf{type} : \mathsf{ok} \\ +{[\textsc{\scriptsize E{-}memory.grow{-}succeed}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.grow}) &\hookrightarrow& \mathit{z}[\mathsf{mem}[0] = \mathit{mi}] ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~{|{\mathit{z}.\mathsf{mem}}{[0]}.\mathsf{data}|} / (64 \cdot \mathrm{Ki})) &\quad + \mbox{if}~\mathrm{grow}_{\mathit{memory}}({\mathit{z}.\mathsf{mem}}{[0]},\, \mathit{n}) = \mathit{mi} \\ {[\textsc{\scriptsize E{-}memory.grow{-}fail}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.grow}) &\hookrightarrow& \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~-1) & \\ \end{array} $$ @@ -4117,47 +4103,41 @@ $$ \end{array} $$ +\vspace{1ex} + $$ \begin{array}{@{}lcl@{}l@{}} -\mathrm{alloc}_{\mathit{import}}(\mathit{m},\, \epsilon,\, \epsilon) &=& \mathit{m} & \\ -\mathrm{alloc}_{\mathit{import}}(\mathit{m},\, \mathit{import}~{{\mathit{import}'}^\ast},\, \mathit{externval}~{{\mathit{externval}'}^\ast}) &=& \mathit{m}_{\mathit{res}} &\quad - \mbox{if}~\mathit{import} = \mathsf{import}~\mathit{name}~{\mathit{name}'}~\mathit{externtype} \\ - &&&&\quad {\land}~\mathit{externtype} = \mathsf{func}~\mathit{functype} \\ - &&&&\quad {\land}~\mathit{externval} = \mathsf{func}~\mathit{fa} \\ - &&&&\quad {\land}~\mathit{m}_{\mathit{new}} = \mathit{m}[\mathsf{func} = ..\mathit{fa}] \\ - &&&&\quad {\land}~\mathit{m}_{\mathit{res}} = \mathrm{alloc}_{\mathit{import}}(\mathit{m}_{\mathit{new}},\, {{\mathit{import}'}^\ast},\, {{\mathit{externval}'}^\ast}) \\ -\mathrm{alloc}_{\mathit{import}}(\mathit{m},\, \mathit{import}~{{\mathit{import}'}^\ast},\, \mathit{externval}~{{\mathit{externval}'}^\ast}) &=& \mathit{m}_{\mathit{res}} &\quad - \mbox{if}~\mathit{import} = \mathsf{import}~\mathit{name}~{\mathit{name}'}~\mathit{externtype} \\ - &&&&\quad {\land}~\mathit{externtype} = \mathsf{global}~\mathit{globaltype} \\ - &&&&\quad {\land}~\mathit{externval} = \mathsf{global}~\mathit{ga} \\ - &&&&\quad {\land}~\mathit{m}_{\mathit{new}} = \mathit{m}[\mathsf{global} = ..\mathit{ga}] \\ - &&&&\quad {\land}~\mathit{m}_{\mathit{res}} = \mathrm{alloc}_{\mathit{import}}(\mathit{m}_{\mathit{new}},\, {{\mathit{import}'}^\ast},\, {{\mathit{externval}'}^\ast}) \\ -\mathrm{alloc}_{\mathit{import}}(\mathit{m},\, \mathit{import}~{{\mathit{import}'}^\ast},\, \mathit{externval}~{{\mathit{externval}'}^\ast}) &=& \mathit{m}_{\mathit{res}} &\quad - \mbox{if}~\mathit{import} = \mathsf{import}~\mathit{name}~{\mathit{name}'}~\mathit{externtype} \\ - &&&&\quad {\land}~\mathit{externtype} = \mathsf{table}~\mathit{tabletype} \\ - &&&&\quad {\land}~\mathit{externval} = \mathsf{table}~\mathit{ta} \\ - &&&&\quad {\land}~\mathit{m}_{\mathit{new}} = \mathit{m}[\mathsf{table} = ..\mathit{ta}] \\ - &&&&\quad {\land}~\mathit{m}_{\mathit{res}} = \mathrm{alloc}_{\mathit{import}}(\mathit{m}_{\mathit{new}},\, {{\mathit{import}'}^\ast},\, {{\mathit{externval}'}^\ast}) \\ -\mathrm{alloc}_{\mathit{import}}(\mathit{m},\, \mathit{import}~{{\mathit{import}'}^\ast},\, \mathit{externval}~{{\mathit{externval}'}^\ast}) &=& \mathit{m}_{\mathit{res}} &\quad - \mbox{if}~\mathit{import} = \mathsf{import}~\mathit{name}~{\mathit{name}'}~\mathit{externtype} \\ - &&&&\quad {\land}~\mathit{externtype} = \mathsf{mem}~\mathit{memtype} \\ - &&&&\quad {\land}~\mathit{externval} = \mathsf{mem}~\mathit{ma} \\ - &&&&\quad {\land}~\mathit{m}_{\mathit{new}} = \mathit{m}[\mathsf{mem} = ..\mathit{ma}] \\ - &&&&\quad {\land}~\mathit{m}_{\mathit{res}} = \mathrm{alloc}_{\mathit{import}}(\mathit{m}_{\mathit{new}},\, {{\mathit{import}'}^\ast},\, {{\mathit{externval}'}^\ast}) \\ +\mathrm{funcs}(\epsilon) &=& \epsilon & \\ +\mathrm{funcs}((\mathsf{func}~\mathit{fa})~{{\mathit{externval}'}^\ast}) &=& \mathit{fa}~\mathrm{funcs}({{\mathit{externval}'}^\ast}) & \\ +\mathrm{funcs}(\mathit{externval}~{{\mathit{externval}'}^\ast}) &=& \mathrm{funcs}({{\mathit{externval}'}^\ast}) &\quad + \mbox{otherwise} \\ \end{array} $$ -\vspace{1ex} +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{globals}(\epsilon) &=& \epsilon & \\ +\mathrm{globals}((\mathsf{global}~\mathit{ga})~{{\mathit{externval}'}^\ast}) &=& \mathit{ga}~\mathrm{globals}({{\mathit{externval}'}^\ast}) & \\ +\mathrm{globals}(\mathit{externval}~{{\mathit{externval}'}^\ast}) &=& \mathrm{globals}({{\mathit{externval}'}^\ast}) &\quad + \mbox{otherwise} \\ +\end{array} +$$ $$ \begin{array}{@{}lcl@{}l@{}} -\mathrm{alloc}_{\mathit{func}}((\mathit{s} ; \mathit{f}),\, \epsilon) &=& (\mathit{s},\, \epsilon) & \\ -\mathrm{alloc}_{\mathit{func}}((\mathit{s} ; \mathit{f}),\, \mathit{func}~{{\mathit{func}'}^\ast}) &=& (\mathit{s}_{\mathit{res}},\, \mathit{fa}~{{\mathit{fa}'}^\ast}) &\quad - \mbox{if}~\mathit{fi} = \{ \begin{array}[t]{@{}l@{}} -\mathsf{module}~\mathit{f}.\mathsf{module},\; \mathsf{code}~\mathit{func} \}\end{array} \\ - &&&&\quad {\land}~\mathit{fa} = {|(\mathit{s} ; \mathit{f}).\mathsf{func}|} \\ - &&&&\quad {\land}~\mathit{s}_{\mathit{new}} = \mathit{s}[\mathsf{func} = ..\mathit{fi}] \\ - &&&&\quad {\land}~(\mathit{s}_{\mathit{res}},\, {{\mathit{fa}'}^\ast}) = \mathrm{alloc}_{\mathit{func}}((\mathit{s}_{\mathit{new}} ; \mathit{f}),\, {{\mathit{func}'}^\ast}) \\ +\mathrm{tables}(\epsilon) &=& \epsilon & \\ +\mathrm{tables}((\mathsf{table}~\mathit{ta})~{{\mathit{externval}'}^\ast}) &=& \mathit{ta}~\mathrm{tables}({{\mathit{externval}'}^\ast}) & \\ +\mathrm{tables}(\mathit{externval}~{{\mathit{externval}'}^\ast}) &=& \mathrm{tables}({{\mathit{externval}'}^\ast}) &\quad + \mbox{otherwise} \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{mems}(\epsilon) &=& \epsilon & \\ +\mathrm{mems}((\mathsf{mem}~\mathit{ma})~{{\mathit{externval}'}^\ast}) &=& \mathit{ma}~\mathrm{mems}({{\mathit{externval}'}^\ast}) & \\ +\mathrm{mems}(\mathit{externval}~{{\mathit{externval}'}^\ast}) &=& \mathrm{mems}({{\mathit{externval}'}^\ast}) &\quad + \mbox{otherwise} \\ \end{array} $$ @@ -4165,15 +4145,14 @@ $$ $$ \begin{array}{@{}lcl@{}l@{}} -\mathrm{alloc}_{\mathit{global}}((\mathit{s} ; \mathit{f}),\, \epsilon) &=& (\mathit{s},\, \epsilon) & \\ -\mathrm{alloc}_{\mathit{global}}((\mathit{s} ; \mathit{f}),\, \mathit{global}~{{\mathit{global}'}^\ast}) &=& (\mathit{s}_{\mathit{res}},\, \mathit{ga}~{{\mathit{ga}'}^\ast}) &\quad - \mbox{if}~\mathit{global} = \mathsf{global}~\mathit{globaltype}~{\mathit{instr}^\ast} \\ - &&&&\quad {\land}~\mathit{s} ; \mathit{f} ; {\mathit{instr}^\ast} \hookrightarrow \mathit{val} \\ - &&&&\quad {\land}~\mathit{gi} = \{ \begin{array}[t]{@{}l@{}} -\mathsf{type}~\mathit{globaltype},\; \mathsf{value}~\mathit{val} \}\end{array} \\ - &&&&\quad {\land}~\mathit{ga} = {|(\mathit{s} ; \mathit{f}).\mathsf{global}|} \\ - &&&&\quad {\land}~\mathit{s}_{\mathit{new}} = \mathit{s}[\mathsf{global} = ..\mathit{gi}] \\ - &&&&\quad {\land}~(\mathit{s}_{\mathit{res}},\, {{\mathit{ga}'}^\ast}) = \mathrm{alloc}_{\mathit{global}}((\mathit{s}_{\mathit{new}} ; \mathit{f}),\, {{\mathit{global}'}^\ast}) \\ +\mathrm{instexport}({\mathit{fa}^\ast},\, {\mathit{ga}^\ast},\, {\mathit{ta}^\ast},\, {\mathit{ma}^\ast},\, \mathsf{export}~\mathit{name}~(\mathsf{func}~\mathit{x})) &=& \{ \begin{array}[t]{@{}l@{}} +\mathsf{name}~\mathit{name},\; \mathsf{value}~(\mathsf{func}~{\mathit{fa}^\ast}[\mathit{x}]) \}\end{array} & \\ +\mathrm{instexport}({\mathit{fa}^\ast},\, {\mathit{ga}^\ast},\, {\mathit{ta}^\ast},\, {\mathit{ma}^\ast},\, \mathsf{export}~\mathit{name}~(\mathsf{global}~\mathit{x})) &=& \{ \begin{array}[t]{@{}l@{}} +\mathsf{name}~\mathit{name},\; \mathsf{value}~(\mathsf{global}~{\mathit{ga}^\ast}[\mathit{x}]) \}\end{array} & \\ +\mathrm{instexport}({\mathit{fa}^\ast},\, {\mathit{ga}^\ast},\, {\mathit{ta}^\ast},\, {\mathit{ma}^\ast},\, \mathsf{export}~\mathit{name}~(\mathsf{table}~\mathit{x})) &=& \{ \begin{array}[t]{@{}l@{}} +\mathsf{name}~\mathit{name},\; \mathsf{value}~(\mathsf{table}~{\mathit{ta}^\ast}[\mathit{x}]) \}\end{array} & \\ +\mathrm{instexport}({\mathit{fa}^\ast},\, {\mathit{ga}^\ast},\, {\mathit{ta}^\ast},\, {\mathit{ma}^\ast},\, \mathsf{export}~\mathit{name}~(\mathsf{mem}~\mathit{x})) &=& \{ \begin{array}[t]{@{}l@{}} +\mathsf{name}~\mathit{name},\; \mathsf{value}~(\mathsf{mem}~{\mathit{ma}^\ast}[\mathit{x}]) \}\end{array} & \\ \end{array} $$ @@ -4181,104 +4160,103 @@ $$ $$ \begin{array}{@{}lcl@{}l@{}} -\mathrm{alloc}_{\mathit{table}}((\mathit{s} ; \mathit{f}),\, \epsilon) &=& (\mathit{s},\, \epsilon) & \\ -\mathrm{alloc}_{\mathit{table}}((\mathit{s} ; \mathit{f}),\, \mathit{table}~{{\mathit{table}'}^\ast}) &=& (\mathit{s}_{\mathit{res}},\, \mathit{ta}~{{\mathit{ta}'}^\ast}) &\quad - \mbox{if}~\mathit{table} = \mathsf{table}~\mathit{tabletype} \\ - &&&&\quad {\land}~\mathit{tabletype} = [\mathit{i} .. {\mathit{j}^?}]~\mathit{reftype} \\ - &&&&\quad {\land}~\mathit{ti} = \{ \begin{array}[t]{@{}l@{}} -\mathsf{type}~\mathit{tabletype},\; \mathsf{elem}~{(\mathsf{ref.null}~\mathit{reftype})^{\mathit{i}}} \}\end{array} \\ - &&&&\quad {\land}~\mathit{ta} = {|(\mathit{s} ; \mathit{f}).\mathsf{table}|} \\ - &&&&\quad {\land}~\mathit{s}_{\mathit{new}} = \mathit{s}[\mathsf{table} = ..\mathit{ti}] \\ - &&&&\quad {\land}~(\mathit{s}_{\mathit{res}},\, {{\mathit{ta}'}^\ast}) = \mathrm{alloc}_{\mathit{table}}((\mathit{s}_{\mathit{new}} ; \mathit{f}),\, {{\mathit{table}'}^\ast}) \\ +\mathrm{allocfunc}(\mathit{s},\, \mathit{m},\, \mathit{func}) &=& (\mathit{s}[\mathsf{func} = ..\mathit{fi}],\, {|\mathit{s}.\mathsf{func}|}) &\quad + \mbox{if}~\mathit{fi} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{module}~\mathit{m},\; \mathsf{code}~\mathit{func} \}\end{array} \\ \end{array} $$ -\vspace{1ex} +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{allocfuncs}(\mathit{s},\, \mathit{m},\, \epsilon) &=& (\mathit{s},\, \epsilon) & \\ +\mathrm{allocfuncs}(\mathit{s},\, \mathit{m},\, \mathit{func}~{{\mathit{func}'}^\ast}) &=& (\mathit{s}_{2},\, \mathit{fa}~{{\mathit{fa}'}^\ast}) &\quad + \mbox{if}~(\mathit{s}_{1},\, \mathit{fa}) = \mathrm{allocfunc}(\mathit{s},\, \mathit{m},\, \mathit{func}) \\ + &&&\quad {\land}~(\mathit{s}_{2},\, {{\mathit{fa}'}^\ast}) = \mathrm{allocfuncs}(\mathit{s}_{1},\, \mathit{m},\, {{\mathit{func}'}^\ast}) \\ +\end{array} +$$ $$ \begin{array}{@{}lcl@{}l@{}} -\mathrm{alloc}_{\mathit{mem}}((\mathit{s} ; \mathit{f}),\, \epsilon) &=& (\mathit{s},\, \epsilon) & \\ -\mathrm{alloc}_{\mathit{mem}}((\mathit{s} ; \mathit{f}),\, \mathit{mem}~{{\mathit{mem}'}^\ast}) &=& (\mathit{s}_{\mathit{res}},\, \mathit{ma}~{{\mathit{ma}'}^\ast}) &\quad - \mbox{if}~\mathit{mem} = \mathsf{memory}~\mathit{memtype} \\ - &&&&\quad {\land}~\mathit{memtype} = [\mathit{i} .. {\mathit{j}^?}]~\mathsf{i{\scriptstyle8}} \\ - &&&&\quad {\land}~\mathit{mi} = \{ \begin{array}[t]{@{}l@{}} -\mathsf{type}~\mathit{memtype},\; \mathsf{data}~{0^{\mathit{i} \cdot 64 \cdot \mathrm{Ki}}} \}\end{array} \\ - &&&&\quad {\land}~\mathit{ma} = {|(\mathit{s} ; \mathit{f}).\mathsf{mem}|} \\ - &&&&\quad {\land}~\mathit{s}_{\mathit{new}} = \mathit{s}[\mathsf{mem} = ..\mathit{mi}] \\ - &&&&\quad {\land}~(\mathit{s}_{\mathit{res}},\, {{\mathit{ma}'}^\ast}) = \mathrm{alloc}_{\mathit{mem}}((\mathit{s}_{\mathit{new}} ; \mathit{f}),\, {{\mathit{mem}'}^\ast}) \\ +\mathrm{allocglobal}(\mathit{s},\, \mathit{globaltype},\, \mathit{val}) &=& (\mathit{s}[\mathsf{global} = ..\mathit{gi}],\, {|\mathit{s}.\mathsf{global}|}) &\quad + \mbox{if}~\mathit{gi} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{type}~\mathit{globaltype},\; \mathsf{value}~\mathit{val} \}\end{array} \\ \end{array} $$ -\vspace{1ex} +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{allocglobals}(\mathit{s},\, \epsilon,\, \epsilon) &=& (\mathit{s},\, \epsilon) & \\ +\mathrm{allocglobals}(\mathit{s},\, \mathit{globaltype}~{{\mathit{globaltype}'}^\ast},\, \mathit{val}~{{\mathit{val}'}^\ast}) &=& (\mathit{s}_{2},\, \mathit{ga}~{{\mathit{ga}'}^\ast}) &\quad + \mbox{if}~(\mathit{s}_{1},\, \mathit{ga}) = \mathrm{allocglobal}(\mathit{s},\, \mathit{globaltype},\, \mathit{val}) \\ + &&&\quad {\land}~(\mathit{s}_{2},\, {{\mathit{ga}'}^\ast}) = \mathrm{allocglobals}(\mathit{s}_{1},\, {{\mathit{globaltype}'}^\ast},\, {{\mathit{val}'}^\ast}) \\ +\end{array} +$$ $$ \begin{array}{@{}lcl@{}l@{}} -\mathrm{alloc}_{\mathit{elem}}((\mathit{s} ; \mathit{f}),\, \epsilon) &=& (\mathit{s},\, \epsilon) & \\ -\mathrm{alloc}_{\mathit{elem}}((\mathit{s} ; \mathit{f}),\, \mathit{elem}~{{\mathit{elem}'}^\ast}) &=& (\mathit{s}_{\mathit{res}},\, \mathit{ea}~{{\mathit{ea}'}^\ast}) &\quad - \mbox{if}~\mathit{elem} = \mathsf{elem}~\mathit{reftype}~{({\mathit{instr}^\ast})^\ast}~{\mathit{elemmode}^?} \\ - &&&&\quad {\land}~(\mathit{s} ; \mathit{f} ; {\mathit{instr}^\ast} \hookrightarrow \mathit{ref})^\ast \\ - &&&&\quad {\land}~\mathit{ei} = \{ \begin{array}[t]{@{}l@{}} -\mathsf{type}~\mathit{reftype},\; \mathsf{elem}~{\mathit{ref}^\ast} \}\end{array} \\ - &&&&\quad {\land}~\mathit{ea} = {|(\mathit{s} ; \mathit{f}).\mathsf{elem}|} \\ - &&&&\quad {\land}~\mathit{s}_{\mathit{new}} = \mathit{s}[\mathsf{elem} = ..\mathit{ei}] \\ - &&&&\quad {\land}~(\mathit{s}_{\mathit{res}},\, {{\mathit{ea}'}^\ast}) = \mathrm{alloc}_{\mathit{elem}}((\mathit{s}_{\mathit{new}} ; \mathit{f}),\, {{\mathit{elem}'}^\ast}) \\ +\mathrm{alloctable}(\mathit{s},\, [\mathit{i} .. \mathit{j}]~\mathit{rt}) &=& (\mathit{s}[\mathsf{table} = ..\mathit{ti}],\, {|\mathit{s}.\mathsf{table}|}) &\quad + \mbox{if}~\mathit{ti} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{type}~([\mathit{i} .. \mathit{j}]~\mathit{rt}),\; \mathsf{elem}~{(\mathsf{ref.null}~\mathit{rt})^{\mathit{i}}} \}\end{array} \\ \end{array} $$ -\vspace{1ex} +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{alloctables}(\mathit{s},\, \epsilon) &=& (\mathit{s},\, \epsilon) & \\ +\mathrm{alloctables}(\mathit{s},\, \mathit{tabletype}~{{\mathit{tabletype}'}^\ast}) &=& (\mathit{s}_{2},\, \mathit{ta}~{{\mathit{ta}'}^\ast}) &\quad + \mbox{if}~(\mathit{s}_{1},\, \mathit{ta}) = \mathrm{alloctable}(\mathit{s},\, \mathit{tabletype}) \\ + &&&\quad {\land}~(\mathit{s}_{2},\, {{\mathit{ta}'}^\ast}) = \mathrm{alloctables}(\mathit{s}_{1},\, {{\mathit{tabletype}'}^\ast}) \\ +\end{array} +$$ $$ \begin{array}{@{}lcl@{}l@{}} -\mathrm{alloc}_{\mathit{data}}((\mathit{s} ; \mathit{f}),\, \epsilon) &=& (\mathit{s},\, \epsilon) & \\ -\mathrm{alloc}_{\mathit{data}}((\mathit{s} ; \mathit{f}),\, \mathit{data}~{{\mathit{data}'}^\ast}) &=& (\mathit{s}_{\mathit{res}},\, \mathit{da}~{{\mathit{da}'}^\ast}) &\quad - \mbox{if}~\mathit{data} = \mathsf{data}~{\mathit{byte}^\ast}~{\mathit{datamode}^?} \\ - &&&&\quad {\land}~\mathit{di} = \{ \begin{array}[t]{@{}l@{}} -\mathsf{data}~{\mathit{byte}^\ast} \}\end{array} \\ - &&&&\quad {\land}~\mathit{da} = {|(\mathit{s} ; \mathit{f}).\mathsf{data}|} \\ - &&&&\quad {\land}~\mathit{s}_{\mathit{new}} = \mathit{s}[\mathsf{data} = ..\mathit{di}] \\ - &&&&\quad {\land}~(\mathit{s}_{\mathit{res}},\, {{\mathit{da}'}^\ast}) = \mathrm{alloc}_{\mathit{data}}((\mathit{s}_{\mathit{new}} ; \mathit{f}),\, {{\mathit{data}'}^\ast}) \\ +\mathrm{allocmem}(\mathit{s},\, [\mathit{i} .. \mathit{j}]~\mathsf{i{\scriptstyle8}}) &=& (\mathit{s}[\mathsf{mem} = ..\mathit{mi}],\, {|\mathit{s}.\mathsf{mem}|}) &\quad + \mbox{if}~\mathit{mi} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{type}~([\mathit{i} .. \mathit{j}]~\mathsf{i{\scriptstyle8}}),\; \mathsf{data}~{0^{\mathit{i} \cdot 64 \cdot \mathrm{Ki}}} \}\end{array} \\ \end{array} $$ -\vspace{1ex} +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{allocmems}(\mathit{s},\, \epsilon) &=& (\mathit{s},\, \epsilon) & \\ +\mathrm{allocmems}(\mathit{s},\, \mathit{memtype}~{{\mathit{memtype}'}^\ast}) &=& (\mathit{s}_{2},\, \mathit{ma}~{{\mathit{ma}'}^\ast}) &\quad + \mbox{if}~(\mathit{s}_{1},\, \mathit{ma}) = \mathrm{allocmem}(\mathit{s},\, \mathit{memtype}) \\ + &&&\quad {\land}~(\mathit{s}_{2},\, {{\mathit{ma}'}^\ast}) = \mathrm{allocmems}(\mathit{s}_{1},\, {{\mathit{memtype}'}^\ast}) \\ +\end{array} +$$ $$ \begin{array}{@{}lcl@{}l@{}} -\mathrm{replace}_{\mathit{moduleinst}}(\mathit{s},\, \epsilon,\, \mathit{m}) &=& \mathit{s} & \\ -\mathrm{replace}_{\mathit{moduleinst}}(\mathit{s},\, \mathit{fa}~{{\mathit{fa}'}^\ast},\, \mathit{m}) &=& \mathit{s}_{\mathit{res}} &\quad - \mbox{if}~\mathit{s}_{\mathit{new}} = \mathit{s}[\mathsf{func}[\mathit{fa}].\mathsf{module} = \mathit{m}] \\ - &&&&\quad {\land}~\mathit{s}_{\mathit{res}} = \mathrm{replace}_{\mathit{moduleinst}}(\mathit{s}_{\mathit{new}},\, {{\mathit{fa}'}^\ast},\, \mathit{m}) \\ +\mathrm{allocelem}(\mathit{s},\, \mathit{rt},\, {\mathit{ref}^\ast}) &=& (\mathit{s}[\mathsf{elem} = ..\mathit{ei}],\, {|\mathit{s}.\mathsf{elem}|}) &\quad + \mbox{if}~\mathit{ei} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{type}~\mathit{rt},\; \mathsf{elem}~{\mathit{ref}^\ast} \}\end{array} \\ \end{array} $$ -\vspace{1ex} +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{allocelems}(\mathit{s},\, \epsilon,\, \epsilon) &=& (\mathit{s},\, \epsilon) & \\ +\mathrm{allocelems}(\mathit{s},\, \mathit{rt}~{{\mathit{rt}'}^\ast},\, {\mathit{ref}^\ast}~{{{\mathit{ref}'}^\ast}^\ast}) &=& (\mathit{s}_{2},\, \mathit{ea}~{{\mathit{ea}'}^\ast}) &\quad + \mbox{if}~(\mathit{s}_{1},\, \mathit{ea}) = \mathrm{allocelem}(\mathit{s},\, \mathit{rt},\, {\mathit{ref}^\ast}) \\ + &&&\quad {\land}~(\mathit{s}_{2},\, {{\mathit{ea}'}^\ast}) = \mathrm{allocelems}(\mathit{s}_{2},\, {{\mathit{rt}'}^\ast},\, {{{\mathit{ref}'}^\ast}^\ast}) \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{allocdata}(\mathit{s},\, {\mathit{byte}^\ast}) &=& (\mathit{s}[\mathsf{data} = ..\mathit{di}],\, {|\mathit{s}.\mathsf{data}|}) &\quad + \mbox{if}~\mathit{di} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{data}~{\mathit{byte}^\ast} \}\end{array} \\ +\end{array} +$$ $$ \begin{array}{@{}lcl@{}l@{}} -\mathrm{alloc}_{\mathit{export}}(\mathit{m},\, \mathit{export}) &=& \mathit{xi} &\quad - \mbox{if}~\mathit{export} = \mathsf{export}~\mathit{name}~\mathit{externuse} \\ - &&&&\quad {\land}~\mathit{externuse} = \mathsf{func}~\mathit{x} \\ - &&&&\quad {\land}~\mathit{externval} = \mathsf{func}~\mathit{m}.\mathsf{func}[\mathit{x}] \\ - &&&&\quad {\land}~\mathit{xi} = \{ \begin{array}[t]{@{}l@{}} -\mathsf{name}~\mathit{name},\; \mathsf{value}~\mathit{externval} \}\end{array} \\ -\mathrm{alloc}_{\mathit{export}}(\mathit{m},\, \mathit{export}) &=& \mathit{xi} &\quad - \mbox{if}~\mathit{export} = \mathsf{export}~\mathit{name}~\mathit{externuse} \\ - &&&&\quad {\land}~\mathit{externuse} = \mathsf{global}~\mathit{x} \\ - &&&&\quad {\land}~\mathit{externval} = \mathsf{global}~\mathit{m}.\mathsf{global}[\mathit{x}] \\ - &&&&\quad {\land}~\mathit{xi} = \{ \begin{array}[t]{@{}l@{}} -\mathsf{name}~\mathit{name},\; \mathsf{value}~\mathit{externval} \}\end{array} \\ -\mathrm{alloc}_{\mathit{export}}(\mathit{m},\, \mathit{export}) &=& \mathit{xi} &\quad - \mbox{if}~\mathit{export} = \mathsf{export}~\mathit{name}~\mathit{externuse} \\ - &&&&\quad {\land}~\mathit{externuse} = \mathsf{table}~\mathit{x} \\ - &&&&\quad {\land}~\mathit{externval} = \mathsf{table}~\mathit{m}.\mathsf{table}[\mathit{x}] \\ - &&&&\quad {\land}~\mathit{xi} = \{ \begin{array}[t]{@{}l@{}} -\mathsf{name}~\mathit{name},\; \mathsf{value}~\mathit{externval} \}\end{array} \\ -\mathrm{alloc}_{\mathit{export}}(\mathit{m},\, \mathit{export}) &=& \mathit{xi} &\quad - \mbox{if}~\mathit{export} = \mathsf{export}~\mathit{name}~\mathit{externuse} \\ - &&&&\quad {\land}~\mathit{externuse} = \mathsf{mem}~\mathit{x} \\ - &&&&\quad {\land}~\mathit{externval} = \mathsf{mem}~\mathit{m}.\mathsf{mem}[\mathit{x}] \\ - &&&&\quad {\land}~\mathit{xi} = \{ \begin{array}[t]{@{}l@{}} -\mathsf{name}~\mathit{name},\; \mathsf{value}~\mathit{externval} \}\end{array} \\ +\mathrm{allocdatas}(\mathit{s},\, \epsilon) &=& (\mathit{s},\, \epsilon) & \\ +\mathrm{allocdatas}(\mathit{s},\, {\mathit{byte}^\ast}~{{{\mathit{byte}'}^\ast}^\ast}) &=& (\mathit{s}_{2},\, \mathit{da}~{{\mathit{da}'}^\ast}) &\quad + \mbox{if}~(\mathit{s}_{1},\, \mathit{da}) = \mathrm{allocdata}(\mathit{s},\, {\mathit{byte}^\ast}) \\ + &&&\quad {\land}~(\mathit{s}_{2},\, {{\mathit{da}'}^\ast}) = \mathrm{allocdatas}(\mathit{s}_{1},\, {{{\mathit{byte}'}^\ast}^\ast}) \\ \end{array} $$ @@ -4286,24 +4264,33 @@ $$ $$ \begin{array}{@{}lcl@{}l@{}} -\mathrm{alloc}_{\mathit{module}}(\mathit{s},\, \mathit{module},\, {\mathit{externval}^\ast}) &=& (\mathit{s}_{\mathit{res}},\, \mathit{m}_{\mathit{res}}) &\quad - \mbox{if}~\mathit{module} = \mathsf{module}~{\mathit{import}^\ast}~{\mathit{func}^\ast}~{\mathit{global}^\ast}~{\mathit{table}^\ast}~{\mathit{mem}^\ast}~{\mathit{elem}^\ast}~{\mathit{data}^\ast}~{\mathit{start}^?}~{\mathit{export}^\ast} \\ - &&&&\quad {\land}~\mathit{m}_{\mathit{init}} = \{ \begin{array}[t]{@{}l@{}} -\mathsf{func}~\epsilon,\; \mathsf{global}~\epsilon,\; \mathsf{table}~\epsilon,\; \mathsf{mem}~\epsilon,\; \mathsf{elem}~\epsilon,\; \mathsf{data}~\epsilon,\; \mathsf{export}~\epsilon \}\end{array} \\ - &&&&\quad {\land}~\mathit{m}_{\mathit{im}} = \mathrm{alloc}_{\mathit{import}}(\mathit{m}_{\mathit{init}},\, {\mathit{import}^\ast},\, {\mathit{externval}^\ast}) \\ - &&&&\quad {\land}~\mathit{f} = \{ \begin{array}[t]{@{}l@{}} -\mathsf{local}~\epsilon,\; \mathsf{module}~\mathit{m}_{\mathit{im}} \}\end{array} \\ - &&&&\quad {\land}~(\mathit{s}_{\mathit{func}},\, {\mathit{fa}^\ast}) = \mathrm{alloc}_{\mathit{func}}((\mathit{s} ; \mathit{f}),\, {\mathit{func}^\ast}) \\ - &&&&\quad {\land}~(\mathit{s}_{\mathit{global}},\, {\mathit{ga}^\ast}) = \mathrm{alloc}_{\mathit{global}}((\mathit{s}_{\mathit{func}} ; \mathit{f}),\, {\mathit{global}^\ast}) \\ - &&&&\quad {\land}~(\mathit{s}_{\mathit{table}},\, {\mathit{ta}^\ast}) = \mathrm{alloc}_{\mathit{table}}((\mathit{s}_{\mathit{global}} ; \mathit{f}),\, {\mathit{table}^\ast}) \\ - &&&&\quad {\land}~(\mathit{s}_{\mathit{mem}},\, {\mathit{ma}^\ast}) = \mathrm{alloc}_{\mathit{mem}}((\mathit{s}_{\mathit{table}} ; \mathit{f}),\, {\mathit{mem}^\ast}) \\ - &&&&\quad {\land}~(\mathit{s}_{\mathit{elem}},\, {\mathit{ea}^\ast}) = \mathrm{alloc}_{\mathit{elem}}((\mathit{s}_{\mathit{mem}} ; \mathit{f}),\, {\mathit{elem}^\ast}) \\ - &&&&\quad {\land}~(\mathit{s}_{\mathit{data}},\, {\mathit{da}^\ast}) = \mathrm{alloc}_{\mathit{data}}((\mathit{s}_{\mathit{elem}} ; \mathit{f}),\, {\mathit{data}^\ast}) \\ - &&&&\quad {\land}~\mathit{m}_{\mathit{ex}} = \mathit{m}_{\mathit{im}} \oplus \{ \begin{array}[t]{@{}l@{}} -\mathsf{func}~{\mathit{fa}^\ast},\; \mathsf{global}~{\mathit{ga}^\ast},\; \mathsf{table}~{\mathit{ta}^\ast},\; \mathsf{mem}~{\mathit{ma}^\ast},\; \mathsf{elem}~{\mathit{ea}^\ast},\; \mathsf{data}~{\mathit{da}^\ast},\; \mathsf{export}~\epsilon \}\end{array} \\ - &&&&\quad {\land}~{\mathit{xi}^\ast} = {\mathrm{alloc}_{\mathit{export}}(\mathit{m}_{\mathit{ex}},\, \mathit{export})^\ast} \\ - &&&&\quad {\land}~\mathit{m}_{\mathit{res}} = \mathit{m}_{\mathit{ex}}[\mathsf{export} = {\mathit{xi}^\ast}] \\ - &&&&\quad {\land}~\mathit{s}_{\mathit{res}} = \mathrm{replace}_{\mathit{moduleinst}}(\mathit{s}_{\mathit{data}},\, {\mathit{fa}^\ast},\, \mathit{m}_{\mathit{res}}) \\ +\mathrm{allocmodule}(\mathit{s},\, \mathit{module},\, {\mathit{externval}^\ast},\, {\mathit{val}^\ast},\, {({\mathit{ref}^\ast})^\ast}) &=& (\mathit{s}_{6},\, \mathit{m}) &\quad + \mbox{if}~\mathit{module} = \mathsf{module}~{\mathit{import}^\ast}~{\mathit{func}^{\mathit{n}_{\mathit{func}}}}~{(\mathsf{global}~\mathit{globaltype}~\mathit{expr}_{1})^{\mathit{n}_{\mathit{global}}}}~{(\mathsf{table}~\mathit{tabletype})^{\mathit{n}_{\mathit{table}}}}~{(\mathsf{memory}~\mathit{memtype})^{\mathit{n}_{\mathit{mem}}}}~{(\mathsf{elem}~\mathit{rt}~{\mathit{expr}_{2}^\ast}~{\mathit{elemmode}^?})^{\mathit{n}_{\mathit{elem}}}}~{(\mathsf{data}~{\mathit{byte}^\ast}~{\mathit{datamode}^?})^{\mathit{n}_{\mathit{data}}}}~{\mathit{start}^?}~{\mathit{export}^\ast} \\ + &&&\quad {\land}~{\mathit{fa}_{\mathit{ex}}^\ast} = \mathrm{funcs}({\mathit{externval}^\ast}) \\ + &&&\quad {\land}~{\mathit{ga}_{\mathit{ex}}^\ast} = \mathrm{globals}({\mathit{externval}^\ast}) \\ + &&&\quad {\land}~{\mathit{ta}_{\mathit{ex}}^\ast} = \mathrm{tables}({\mathit{externval}^\ast}) \\ + &&&\quad {\land}~{\mathit{ma}_{\mathit{ex}}^\ast} = \mathrm{mems}({\mathit{externval}^\ast}) \\ + &&&\quad {\land}~{\mathit{fa}^\ast} = {{|\mathit{s}.\mathsf{func}|} + \mathit{i}^{\mathit{i} < \mathit{n}_{\mathit{func}}}} \\ + &&&\quad {\land}~{\mathit{ga}^\ast} = {{|\mathit{s}.\mathsf{global}|} + \mathit{i}^{\mathit{i} < \mathit{n}_{\mathit{global}}}} \\ + &&&\quad {\land}~{\mathit{ta}^\ast} = {{|\mathit{s}.\mathsf{table}|} + \mathit{i}^{\mathit{i} < \mathit{n}_{\mathit{table}}}} \\ + &&&\quad {\land}~{\mathit{ma}^\ast} = {{|\mathit{s}.\mathsf{mem}|} + \mathit{i}^{\mathit{i} < \mathit{n}_{\mathit{mem}}}} \\ + &&&\quad {\land}~{\mathit{ea}^\ast} = {{|\mathit{s}.\mathsf{elem}|} + \mathit{i}^{\mathit{i} < \mathit{n}_{\mathit{elem}}}} \\ + &&&\quad {\land}~{\mathit{da}^\ast} = {{|\mathit{s}.\mathsf{data}|} + \mathit{i}^{\mathit{i} < \mathit{n}_{\mathit{data}}}} \\ + &&&\quad {\land}~{\mathit{xi}^\ast} = {\mathrm{instexport}({\mathit{fa}_{\mathit{ex}}^\ast}~{\mathit{fa}^\ast},\, {\mathit{ga}_{\mathit{ex}}^\ast}~{\mathit{ga}^\ast},\, {\mathit{ta}_{\mathit{ex}}^\ast}~{\mathit{ta}^\ast},\, {\mathit{ma}_{\mathit{ex}}^\ast}~{\mathit{ma}^\ast},\, \mathit{export})^\ast} \\ + &&&\quad {\land}~\mathit{m} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{func}~{\mathit{fa}_{\mathit{ex}}^\ast}~{\mathit{fa}^\ast},\; \\ + \mathsf{global}~{\mathit{ga}_{\mathit{ex}}^\ast}~{\mathit{ga}^\ast},\; \\ + \mathsf{table}~{\mathit{ta}_{\mathit{ex}}^\ast}~{\mathit{ta}^\ast},\; \\ + \mathsf{mem}~{\mathit{ma}_{\mathit{ex}}^\ast}~{\mathit{ma}^\ast},\; \\ + \mathsf{elem}~{\mathit{ea}^\ast},\; \\ + \mathsf{data}~{\mathit{da}^\ast},\; \\ + \mathsf{export}~{\mathit{xi}^\ast} \}\end{array} \\ + &&&\quad {\land}~(\mathit{s}_{1},\, {\mathit{fa}^\ast}) = \mathrm{allocfuncs}(\mathit{s},\, \mathit{m},\, {\mathit{func}^{\mathit{n}_{\mathit{func}}}}) \\ + &&&\quad {\land}~(\mathit{s}_{2},\, {\mathit{ga}^\ast}) = \mathrm{allocglobals}(\mathit{s}_{1},\, {\mathit{globaltype}^{\mathit{n}_{\mathit{global}}}},\, {\mathit{val}^\ast}) \\ + &&&\quad {\land}~(\mathit{s}_{3},\, {\mathit{ta}^\ast}) = \mathrm{alloctables}(\mathit{s}_{2},\, {\mathit{tabletype}^{\mathit{n}_{\mathit{table}}}}) \\ + &&&\quad {\land}~(\mathit{s}_{4},\, {\mathit{ma}^\ast}) = \mathrm{allocmems}(\mathit{s}_{3},\, {\mathit{memtype}^{\mathit{n}_{\mathit{mem}}}}) \\ + &&&\quad {\land}~(\mathit{s}_{5},\, {\mathit{ea}^\ast}) = \mathrm{allocelems}(\mathit{s}_{4},\, {\mathit{rt}^{\mathit{n}_{\mathit{elem}}}},\, {({\mathit{ref}^\ast})^\ast}) \\ + &&&\quad {\land}~(\mathit{s}_{6},\, {\mathit{da}^\ast}) = \mathrm{allocdatas}(\mathit{s}_{5},\, {({\mathit{byte}^\ast})^{\mathit{n}_{\mathit{data}}}}) \\ \end{array} $$ @@ -4311,21 +4298,18 @@ $$ $$ \begin{array}{@{}lcl@{}l@{}} -\mathrm{run}_{\mathit{elem}}((\mathit{s} ; \mathit{f}),\, \epsilon,\, \mathit{i}) &=& \mathit{s} ; \mathit{f} & \\ -\mathrm{run}_{\mathit{elem}}((\mathit{s} ; \mathit{f}),\, \mathit{elem}~{{\mathit{elem}'}^\ast},\, \mathit{i}) &=& \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} &\quad - \mbox{if}~\mathit{elem} = \mathsf{elem}~\mathit{reftype}~{\mathit{expr}^\ast} \\ - &&&&\quad {\land}~\mathrm{run}_{\mathit{elem}}((\mathit{s} ; \mathit{f}),\, {{\mathit{elem}'}^\ast},\, \mathit{i} + 1) = \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} \\ -\mathrm{run}_{\mathit{elem}}((\mathit{s} ; \mathit{f}),\, \mathit{elem}~{{\mathit{elem}'}^\ast},\, \mathit{i}) &=& \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} &\quad - \mbox{if}~\mathit{elem} = \mathsf{elem}~\mathit{reftype}~{\mathit{expr}^\ast}~\mathit{elemmode} \\ - &&&&\quad {\land}~\mathit{n} = {|{\mathit{expr}^\ast}|} \\ - &&&&\quad {\land}~\mathit{elemmode} = \mathsf{table}~\mathit{x}~{\mathit{instr}^\ast} \\ - &&&&\quad {\land}~\mathit{s} ; \mathit{f} ; {\mathit{instr}^\ast}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~0)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.init}~\mathit{x}~\mathit{i})~(\mathsf{elem.drop}~\mathit{i}) \hookrightarrow \mathit{s}_{\mathit{new}} ; \mathit{f}_{\mathit{new}} ; \epsilon \\ - &&&&\quad {\land}~\mathrm{run}_{\mathit{elem}}((\mathit{s}_{\mathit{new}} ; \mathit{f}_{\mathit{new}}),\, {{\mathit{elem}'}^\ast},\, \mathit{i} + 1) = \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} \\ -\mathrm{run}_{\mathit{elem}}((\mathit{s} ; \mathit{f}),\, \mathit{elem}~{{\mathit{elem}'}^\ast},\, \mathit{i}) &=& \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} &\quad - \mbox{if}~\mathit{elem} = \mathsf{elem}~\mathit{reftype}~{\mathit{expr}^\ast}~\mathit{elemmode} \\ - &&&&\quad {\land}~\mathit{elemmode} = \mathsf{declare} \\ - &&&&\quad {\land}~\mathit{s} ; \mathit{f} ; (\mathsf{elem.drop}~\mathit{i}) \hookrightarrow \mathit{s}_{\mathit{new}} ; \mathit{f}_{\mathit{new}} ; \epsilon \\ - &&&&\quad {\land}~\mathrm{run}_{\mathit{elem}}((\mathit{s}_{\mathit{new}} ; \mathit{f}_{\mathit{new}}),\, {{\mathit{elem}'}^\ast},\, \mathit{i} + 1) = \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} \\ +\mathrm{runelem}(\mathsf{elem}~\mathit{reftype}~{\mathit{expr}^\ast},\, \mathit{i}) &=& \epsilon & \\ +\mathrm{runelem}(\mathsf{elem}~\mathit{reftype}~{\mathit{expr}^\ast}~(\mathsf{declare}),\, \mathit{i}) &=& (\mathsf{elem.drop}~\mathit{i}) & \\ +\mathrm{runelem}(\mathsf{elem}~\mathit{reftype}~{\mathit{expr}^\ast}~(\mathsf{table}~\mathit{x}~{\mathit{instr}^\ast}),\, \mathit{i}) &=& {\mathit{instr}^\ast}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~0)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.init}~\mathit{x}~\mathit{i})~(\mathsf{elem.drop}~\mathit{i}) &\quad + \mbox{if}~\mathit{n} = {|{\mathit{expr}^\ast}|} \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{rundata}(\mathsf{data}~{\mathit{byte}^\ast},\, \mathit{i}) &=& \epsilon & \\ +\mathrm{rundata}(\mathsf{data}~{\mathit{byte}^\ast}~(\mathsf{memory}~0~{\mathit{instr}^\ast}),\, \mathit{i}) &=& {\mathit{instr}^\ast}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~0)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.init}~\mathit{i})~(\mathsf{data.drop}~\mathit{i}) &\quad + \mbox{if}~\mathit{n} = {|{\mathit{byte}^\ast}|} \\ \end{array} $$ @@ -4333,16 +4317,8 @@ $$ $$ \begin{array}{@{}lcl@{}l@{}} -\mathrm{run}_{\mathit{data}}((\mathit{s} ; \mathit{f}),\, \epsilon,\, \mathit{i}) &=& \mathit{s} ; \mathit{f} & \\ -\mathrm{run}_{\mathit{data}}((\mathit{s} ; \mathit{f}),\, \mathit{data}~{{\mathit{data}'}^\ast},\, \mathit{i}) &=& \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} &\quad - \mbox{if}~\mathit{data} = \mathsf{data}~{\mathit{byte}^\ast} \\ - &&&&\quad {\land}~\mathrm{run}_{\mathit{data}}((\mathit{s} ; \mathit{f}),\, {{\mathit{data}'}^\ast},\, \mathit{i} + 1) = \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} \\ -\mathrm{run}_{\mathit{data}}((\mathit{s} ; \mathit{f}),\, \mathit{data}~{{\mathit{data}'}^\ast},\, \mathit{i}) &=& \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} &\quad - \mbox{if}~\mathit{data} = \mathsf{data}~{\mathit{byte}^\ast}~\mathit{datamode} \\ - &&&&\quad {\land}~\mathit{n} = {|{\mathit{byte}^\ast}|} \\ - &&&&\quad {\land}~\mathit{datamode} = \mathsf{memory}~0~{\mathit{instr}^\ast} \\ - &&&&\quad {\land}~\mathit{s} ; \mathit{f} ; {\mathit{instr}^\ast}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~0)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.init}~\mathit{i})~(\mathsf{data.drop}~\mathit{i}) \hookrightarrow \mathit{s}_{\mathit{new}} ; \mathit{f}_{\mathit{new}} ; \epsilon \\ - &&&&\quad {\land}~\mathrm{run}_{\mathit{data}}((\mathit{s}_{\mathit{new}} ; \mathit{f}_{\mathit{new}}),\, {{\mathit{data}'}^\ast},\, \mathit{i} + 1) = \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} \\ +\mathrm{concat}_{\mathit{instr}}(\epsilon) &=& \epsilon & \\ +\mathrm{concat}_{\mathit{instr}}({\mathit{instr}^\ast}~{{{\mathit{instr}'}^\ast}^\ast}) &=& {\mathit{instr}^\ast}~\mathrm{concat}_{\mathit{instr}}({{{\mathit{instr}'}^\ast}^\ast}) & \\ \end{array} $$ @@ -4350,22 +4326,30 @@ $$ $$ \begin{array}{@{}lcl@{}l@{}} -\mathrm{instantiation}(\mathit{s},\, \mathit{module},\, {\mathit{externval}^\ast}) &=& (\mathit{s}_{\mathit{res}},\, \mathit{m}) &\quad - \mbox{if}~\mathit{module} = \mathsf{module}~{\mathit{import}^\ast}~{\mathit{func}^\ast}~{\mathit{global}^\ast}~{\mathit{table}^\ast}~{\mathit{mem}^\ast}~{\mathit{elem}^\ast}~{\mathit{data}^\ast}~{\mathit{export}^\ast} \\ - &&&&\quad {\land}~(\mathit{s}_{\mathit{alloc}},\, \mathit{m}) = \mathrm{alloc}_{\mathit{module}}(\mathit{s},\, \mathit{module},\, {\mathit{externval}^\ast}) \\ - &&&&\quad {\land}~\mathit{f} = \{ \begin{array}[t]{@{}l@{}} -\mathsf{local}~\epsilon,\; \mathsf{module}~\mathit{m} \}\end{array} \\ - &&&&\quad {\land}~\mathrm{run}_{\mathit{elem}}((\mathit{s}_{\mathit{alloc}} ; \mathit{f}),\, {\mathit{elem}^\ast},\, 0) = \mathit{s}_{\mathit{elem}} ; \mathit{f}_{\mathit{elem}} \\ - &&&&\quad {\land}~\mathrm{run}_{\mathit{data}}((\mathit{s}_{\mathit{elem}} ; \mathit{f}_{\mathit{elem}}),\, {\mathit{data}^\ast},\, 0) = \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} \\ -\mathrm{instantiation}(\mathit{s},\, \mathit{module},\, {\mathit{externval}^\ast}) &=& (\mathit{s}_{\mathit{res}},\, \mathit{m}) &\quad - \mbox{if}~\mathit{module} = \mathsf{module}~{\mathit{import}^\ast}~{\mathit{func}^\ast}~{\mathit{global}^\ast}~{\mathit{table}^\ast}~{\mathit{mem}^\ast}~{\mathit{elem}^\ast}~{\mathit{data}^\ast}~\mathit{start}~{\mathit{export}^\ast} \\ - &&&&\quad {\land}~(\mathit{s}_{\mathit{alloc}},\, \mathit{m}) = \mathrm{alloc}_{\mathit{module}}(\mathit{s},\, \mathit{module},\, {\mathit{externval}^\ast}) \\ - &&&&\quad {\land}~\mathit{f} = \{ \begin{array}[t]{@{}l@{}} +\mathrm{instantiation}(\mathit{s},\, \mathit{module},\, {\mathit{externval}^\ast}) &=& {\mathit{s}'} ; \mathit{f} ; {\mathit{instr}_{\mathit{elem}}^\ast}~{\mathit{instr}_{\mathit{data}}^\ast}~{(\mathsf{call}~\mathit{x})^?} &\quad + \mbox{if}~\mathit{module} = \mathsf{module}~{\mathit{import}^\ast}~{\mathit{func}^\ast}~{\mathit{global}^\ast}~{\mathit{table}^\ast}~{\mathit{mem}^\ast}~{\mathit{elem}^\ast}~{\mathit{data}^\ast}~{\mathit{start}^?}~{\mathit{export}^\ast} \\ + &&&\quad {\land}~\mathit{m}_{\mathit{init}} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{func}~\mathrm{funcs}({\mathit{externval}^\ast}),\; \\ + \mathsf{global}~\mathrm{globals}({\mathit{externval}^\ast}),\; \\ + \mathsf{table}~\epsilon,\; \\ + \mathsf{mem}~\epsilon,\; \\ + \mathsf{elem}~\epsilon,\; \\ + \mathsf{data}~\epsilon,\; \\ + \mathsf{export}~\epsilon \}\end{array} \\ + &&&\quad {\land}~\mathit{f}_{\mathit{init}} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{local}~\epsilon,\; \mathsf{module}~\mathit{m}_{\mathit{init}} \}\end{array} \\ + &&&\quad {\land}~(\mathit{global} = \mathsf{global}~\mathit{globaltype}~{\mathit{instr}_{1}^\ast})^\ast \\ + &&&\quad {\land}~(\mathit{s} ; \mathit{f}_{\mathit{init}} ; {\mathit{instr}_{1}^\ast} \hookrightarrow \mathit{val})^\ast \\ + &&&\quad {\land}~(\mathit{elem} = \mathsf{elem}~\mathit{reftype}~{({\mathit{instr}_{2}^\ast})^\ast}~{\mathit{elemmode}^?})^\ast \\ + &&&\quad {\land}~{(\mathit{s} ; \mathit{f}_{\mathit{init}} ; {\mathit{instr}_{2}^\ast} \hookrightarrow \mathit{ref})^\ast}^\ast \\ + &&&\quad {\land}~({\mathit{s}'},\, \mathit{m}) = \mathrm{allocmodule}(\mathit{s},\, \mathit{module},\, {\mathit{externval}^\ast},\, {\mathit{val}^\ast},\, {({\mathit{ref}^\ast})^\ast}) \\ + &&&\quad {\land}~\mathit{f} = \{ \begin{array}[t]{@{}l@{}} \mathsf{local}~\epsilon,\; \mathsf{module}~\mathit{m} \}\end{array} \\ - &&&&\quad {\land}~\mathrm{run}_{\mathit{elem}}((\mathit{s}_{\mathit{alloc}} ; \mathit{f}),\, {\mathit{elem}^\ast},\, 0) = \mathit{s}_{\mathit{elem}} ; \mathit{f}_{\mathit{elem}} \\ - &&&&\quad {\land}~\mathrm{run}_{\mathit{data}}((\mathit{s}_{\mathit{elem}} ; \mathit{f}_{\mathit{elem}}),\, {\mathit{data}^\ast},\, 0) = \mathit{s}_{\mathit{data}} ; \mathit{f}_{\mathit{data}} \\ - &&&&\quad {\land}~\mathit{start} = \mathsf{start}~\mathit{x} \\ - &&&&\quad {\land}~\mathit{s}_{\mathit{data}} ; \mathit{f}_{\mathit{data}} ; (\mathsf{call}~\mathit{x}) \hookrightarrow \mathit{s}_{\mathit{res}} ; \mathit{f}_{\mathit{res}} ; \epsilon \\ + &&&\quad {\land}~\mathit{n}_{\mathit{elem}} = {|{\mathit{elem}^\ast}|} \\ + &&&\quad {\land}~{\mathit{instr}_{\mathit{elem}}^\ast} = \mathrm{concat}_{\mathit{instr}}({\mathrm{runelem}({\mathit{elem}^\ast}[\mathit{i}],\, \mathit{i})^{\mathit{i} < \mathit{n}_{\mathit{elem}}}}) \\ + &&&\quad {\land}~\mathit{n}_{\mathit{data}} = {|{\mathit{data}^\ast}|} \\ + &&&\quad {\land}~{\mathit{instr}_{\mathit{data}}^\ast} = \mathrm{concat}_{\mathit{instr}}({\mathrm{rundata}({\mathit{data}^\ast}[\mathit{j}],\, \mathit{j})^{\mathit{j} < \mathit{n}_{\mathit{data}}}}) \\ + &&&\quad {\land}~{\mathit{start}^?} = {(\mathsf{start}~\mathit{x})^?} \\ \end{array} $$ @@ -4373,16 +4357,19 @@ $$ $$ \begin{array}{@{}lcl@{}l@{}} -\mathrm{invocation}(\mathit{s},\, \mathit{fa},\, {\mathit{val}^\ast}) &=& ({\mathit{s}'},\, {{\mathit{val}'}^\ast}) &\quad +\mathrm{invocation}(\mathit{s},\, \mathit{fa},\, {\mathit{val}^{\mathit{n}}}) &=& \mathit{s} ; \mathit{f} ; {\mathit{val}^{\mathit{n}}}~(\mathsf{call}~\mathit{fa}) &\quad \mbox{if}~\mathit{m} = \{ \begin{array}[t]{@{}l@{}} -\mathsf{func}~\epsilon,\; \mathsf{global}~\epsilon,\; \mathsf{table}~\epsilon,\; \mathsf{mem}~\epsilon,\; \mathsf{elem}~\epsilon,\; \mathsf{data}~\epsilon,\; \mathsf{export}~\epsilon \}\end{array} \\ - &&&&\quad {\land}~\mathit{f} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{func}~\epsilon,\; \\ + \mathsf{global}~\epsilon,\; \\ + \mathsf{table}~\epsilon,\; \\ + \mathsf{mem}~\epsilon,\; \\ + \mathsf{elem}~\epsilon,\; \\ + \mathsf{data}~\epsilon,\; \\ + \mathsf{export}~\epsilon \}\end{array} \\ + &&&\quad {\land}~\mathit{f} = \{ \begin{array}[t]{@{}l@{}} \mathsf{local}~\epsilon,\; \mathsf{module}~\mathit{m} \}\end{array} \\ - &&&&\quad {\land}~(\mathit{s} ; \mathit{f}).\mathsf{func}[\mathit{fa}].\mathsf{code} = \mathsf{func}~\mathit{functype}~{\mathit{valtype}^\ast}~\mathit{expr} \\ - &&&&\quad {\land}~\mathit{functype} = {\mathit{valtype}^\ast} \rightarrow {{\mathit{valtype}'}^\ast} \\ - &&&&\quad {\land}~{|{\mathit{val}^\ast}|} = {|{\mathit{valtype}^\ast}|} \\ - &&&&\quad {\land}~{|{{\mathit{val}'}^\ast}|} = {|{{\mathit{valtype}'}^\ast}|} \\ - &&&&\quad {\land}~\mathit{s} ; \mathit{f} ; {\mathit{val}^\ast}~(\mathsf{call}~\mathit{fa}) \hookrightarrow {\mathit{s}'} ; {\mathit{f}'} ; {{\mathit{val}'}^\ast} \\ + &&&\quad {\land}~(\mathit{s} ; \mathit{f}).\mathsf{func}[\mathit{fa}].\mathsf{code} = \mathsf{func}~\mathit{functype}~{\mathit{valtype}^\ast}~\mathit{expr} \\ + &&&\quad {\land}~\mathit{functype} = {\mathit{valtype}_{\mathit{param}}^{\mathit{n}}} \rightarrow {\mathit{valtype}_{\mathit{res}}^{\mathit{k}}} \\ \end{array} $$ diff --git a/spectec/test-latex/TEST.md b/spectec/test-latex/TEST.md index d9848c8a48..590adcd858 100644 --- a/spectec/test-latex/TEST.md +++ b/spectec/test-latex/TEST.md @@ -250,38 +250,47 @@ warning: rule `Tabletype_sub` was never spliced warning: rule `Valtype_sub/refl` was never spliced warning: rule `Valtype_sub/bot` was never spliced warning: definition `Ki` was never spliced -warning: definition `alloc_data` was never spliced -warning: definition `alloc_elem` was never spliced -warning: definition `alloc_export` was never spliced -warning: definition `alloc_func` was never spliced -warning: definition `alloc_global` was never spliced -warning: definition `alloc_import` was never spliced -warning: definition `alloc_mem` was never spliced -warning: definition `alloc_module` was never spliced -warning: definition `alloc_table` was never spliced +warning: definition `allocdata` was never spliced +warning: definition `allocdatas` was never spliced +warning: definition `allocelem` was never spliced +warning: definition `allocelems` was never spliced +warning: definition `allocfunc` was never spliced +warning: definition `allocfuncs` was never spliced +warning: definition `allocglobal` was never spliced +warning: definition `allocglobals` was never spliced +warning: definition `allocmem` was never spliced +warning: definition `allocmems` was never spliced +warning: definition `allocmodule` was never spliced +warning: definition `alloctable` was never spliced +warning: definition `alloctables` was never spliced warning: definition `binop` was never spliced warning: definition `bytes_` was never spliced +warning: definition `concat_instr` was never spliced warning: definition `cvtop` was never spliced warning: definition `data` was never spliced warning: definition `datainst` was never spliced warning: definition `elem` was never spliced warning: definition `eleminst` was never spliced warning: definition `ext` was never spliced +warning: definition `funcs` was never spliced warning: definition `global` was never spliced warning: definition `globalinst` was never spliced +warning: definition `globals` was never spliced warning: definition `grow_memory` was never spliced warning: definition `grow_table` was never spliced warning: definition `instantiation` was never spliced +warning: definition `instexport` was never spliced warning: definition `invocation` was never spliced warning: definition `local` was never spliced warning: definition `mem` was never spliced warning: definition `meminst` was never spliced +warning: definition `mems` was never spliced warning: definition `min` was never spliced warning: definition `relop` was never spliced -warning: definition `replace_moduleinst` was never spliced -warning: definition `run_data` was never spliced -warning: definition `run_elem` was never spliced +warning: definition `rundata` was never spliced +warning: definition `runelem` was never spliced warning: definition `tableinst` was never spliced +warning: definition `tables` was never spliced warning: definition `testop` was never spliced warning: definition `unop` was never spliced warning: definition `with_data` was never spliced diff --git a/spectec/test-middlend/TEST.md b/spectec/test-middlend/TEST.md index e60ed580bb..68c9ad17d0 100644 --- a/spectec/test-middlend/TEST.md +++ b/spectec/test-middlend/TEST.md @@ -84,8 +84,8 @@ syntax fn = ;; 1-syntax.watsup:56.1-57.11 syntax resulttype = valtype* -;; 1-syntax.watsup:59.1-60.17 -syntax limits = `[%..%?]`(u32, u32?) +;; 1-syntax.watsup:59.1-60.16 +syntax limits = `[%..%]`(u32, u32) ;; 1-syntax.watsup:61.1-62.15 syntax globaltype = `MUT%?%`(()?, valtype) @@ -378,7 +378,7 @@ syntax context = {FUNC functype*, GLOBAL globaltype*, TABLE tabletype*, MEM memt relation Limits_ok: `|-%:%`(limits, nat) ;; 3-typing.watsup:22.1-24.24 rule _ {k : nat, n_1 : n, n_2 : n}: - `|-%:%`(`[%..%?]`(n_1, ?(n_2)), k) + `|-%:%`(`[%..%]`(n_1, n_2), k) -- if ((n_1 <= n_2) /\ (n_2 <= k)) ;; 3-typing.watsup:15.1-15.64 @@ -450,7 +450,7 @@ relation Resulttype_sub: `|-%*<:%*`(valtype*, valtype*) relation Limits_sub: `|-%<:%`(limits, limits) ;; 3-typing.watsup:83.1-86.21 rule _ {n_11 : n, n_12 : n, n_21 : n, n_22 : n}: - `|-%<:%`(`[%..%?]`(n_11, ?(n_12)), `[%..%?]`(n_21, ?(n_22))) + `|-%<:%`(`[%..%]`(n_11, n_12), `[%..%]`(n_21, n_22)) -- if (n_11 >= n_21) -- if (n_12 <= n_22) @@ -1051,10 +1051,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:180.1-187.5 +;; 4-runtime.watsup:183.1-190.5 rec { -;; 4-runtime.watsup:180.1-187.5 +;; 4-runtime.watsup:183.1-190.5 syntax admininstr = | UNREACHABLE | NOP @@ -1221,26 +1221,28 @@ def with_data : (state, dataidx, byte*) -> state ;; 4-runtime.watsup:165.1-165.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:167.1-167.49 +;; 4-runtime.watsup:167.1-167.63 def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:169.1-172.57 - def {i : nat, i' : nat, j? : nat?, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' - -- if (ti = {TYPE `%%`(`[%..%?]`(i, j?{j}), reftype), ELEM r'*{r'}}) + ;; 4-runtime.watsup:170.1-174.36 + def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, rt : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM r'*{r'}}) -- if (i' = (|r'*{r'}| + n)) - -- if (ti' = {TYPE `%%`(`[%..%?]`(i', j?{j}), reftype), ELEM r'*{r'} :: r^n{}}) + -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), rt), ELEM r'*{r'} :: r^n{}}) + -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) -;; 4-runtime.watsup:168.1-168.41 +;; 4-runtime.watsup:168.1-168.55 def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:173.1-176.66 - def {b* : byte*, i : nat, i' : nat, j? : nat?, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' - -- if (mi = {TYPE `%I8`(`[%..%?]`(i, j?{j})), DATA b*{b}}) + ;; 4-runtime.watsup:175.1-179.34 + def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) - -- if (mi' = {TYPE `%I8`(`[%..%?]`(i', j?{j})), DATA b*{b} :: 0^((n * 64) * $Ki){}}) + -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: 0^((n * 64) * $Ki){}}) + -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) -;; 4-runtime.watsup:189.1-192.21 +;; 4-runtime.watsup:192.1-195.21 rec { -;; 4-runtime.watsup:189.1-192.21 +;; 4-runtime.watsup:192.1-195.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -1469,135 +1471,135 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:214.1-216.39 + ;; 6-reduction.watsup:212.1-214.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:218.1-221.14 + ;; 6-reduction.watsup:216.1-219.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:223.1-227.15 + ;; 6-reduction.watsup:221.1-225.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) (val <: admininstr) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) (val <: admininstr) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:230.1-232.73 + ;; 6-reduction.watsup:228.1-230.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:234.1-237.14 + ;; 6-reduction.watsup:232.1-235.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:239.1-244.15 + ;; 6-reduction.watsup:237.1-242.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:246.1-250.15 + ;; 6-reduction.watsup:244.1-248.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:253.1-255.72 + ;; 6-reduction.watsup:251.1-253.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:257.1-260.14 + ;; 6-reduction.watsup:255.1-258.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:262.1-266.15 + ;; 6-reduction.watsup:260.1-264.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) ($elem(z, y).ELEM_eleminst[i] <: admininstr) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:273.1-275.53 + ;; 6-reduction.watsup:271.1-273.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + ($size(nt <: valtype) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:277.1-279.71 + ;; 6-reduction.watsup:275.1-277.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- if ($bytes_($size(nt <: valtype), c) = $mem(z, 0).DATA_meminst[(i + n_O) : ($size(nt <: valtype) / 8)]) - ;; 6-reduction.watsup:281.1-283.45 + ;; 6-reduction.watsup:279.1-281.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:285.1-287.55 + ;; 6-reduction.watsup:283.1-285.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, $size(nt <: valtype), sx, c))]) -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:307.1-309.44 + ;; 6-reduction.watsup:305.1-307.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:322.1-324.37 + ;; 6-reduction.watsup:318.1-320.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:326.1-329.14 + ;; 6-reduction.watsup:322.1-325.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:331.1-335.15 + ;; 6-reduction.watsup:327.1-331.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) (val <: admininstr) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) (val <: admininstr) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:338.1-340.69 + ;; 6-reduction.watsup:334.1-336.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:342.1-345.14 + ;; 6-reduction.watsup:338.1-341.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:347.1-352.15 + ;; 6-reduction.watsup:343.1-348.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:354.1-358.15 + ;; 6-reduction.watsup:350.1-354.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:361.1-363.70 + ;; 6-reduction.watsup:357.1-359.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:365.1-368.14 + ;; 6-reduction.watsup:361.1-364.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:370.1-374.15 + ;; 6-reduction.watsup:366.1-370.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise @@ -1632,327 +1634,313 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (ref <: admininstr) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-208.36 - rule table.grow-succeed {n : n, ref : ref, ti : tableinst, ti' : tableinst, x : idx, z : state}: - `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti'), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($table(z, x) = ti) - -- if ($grow_table(ti, n, ref) = ti') - -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) + ;; 6-reduction.watsup:204.1-206.47 + rule table.grow-succeed {n : n, ref : ref, ti : tableinst, x : idx, z : state}: + `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($grow_table($table(z, x), n, ref) = ti) - ;; 6-reduction.watsup:210.1-211.64 + ;; 6-reduction.watsup:208.1-209.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:269.1-270.59 + ;; 6-reduction.watsup:267.1-268.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:290.1-292.53 + ;; 6-reduction.watsup:288.1-290.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + ($size(nt <: valtype) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:294.1-296.35 + ;; 6-reduction.watsup:292.1-294.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), ($size(nt <: valtype) / 8), b*{b}), [])) -- if (b*{b} = $bytes_($size(nt <: valtype), c)) - ;; 6-reduction.watsup:298.1-300.45 + ;; 6-reduction.watsup:296.1-298.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:302.1-304.50 + ;; 6-reduction.watsup:300.1-302.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if (b*{b} = $bytes_(n, $wrap_(($size(nt <: valtype), n), c))) - ;; 6-reduction.watsup:312.1-316.34 - rule memory.grow-succeed {mi : meminst, mi' : meminst, n : n, z : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_meminst(z, 0, mi'), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - -- if ($mem(z, 0) = mi) - -- if ($grow_memory(mi, n) = mi') - -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) + ;; 6-reduction.watsup:310.1-312.41 + rule memory.grow-succeed {mi : meminst, n : n, z : state}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_meminst(z, 0, mi), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($grow_memory($mem(z, 0), n) = mi) - ;; 6-reduction.watsup:318.1-319.59 + ;; 6-reduction.watsup:314.1-315.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:377.1-378.59 + ;; 6-reduction.watsup:373.1-374.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) -;; 7-module.watsup:3.1-3.64 +;; 7-module.watsup:4.1-4.35 rec { -;; 7-module.watsup:3.1-3.64 -def alloc_import : (moduleinst, import*, externval*) -> moduleinst - ;; 7-module.watsup:5.1-5.43 - def {m : moduleinst} alloc_import(m, [], []) = m - ;; 7-module.watsup:7.1-12.60 - def {externtype : externtype, externval : externval, externval'* : externval*, fa : funcaddr, functype : functype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = FUNC_externtype(functype)) - -- if (externval = FUNC_externval(fa)) - -- if (m_new = m[FUNC_moduleinst =.. [fa]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) - ;; 7-module.watsup:14.1-19.60 - def {externtype : externtype, externval : externval, externval'* : externval*, ga : globaladdr, globaltype : globaltype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = GLOBAL_externtype(globaltype)) - -- if (externval = GLOBAL_externval(ga)) - -- if (m_new = m[GLOBAL_moduleinst =.. [ga]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) - ;; 7-module.watsup:21.1-26.60 - def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name, ta : tableaddr, tabletype : tabletype} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = TABLE_externtype(tabletype)) - -- if (externval = TABLE_externval(ta)) - -- if (m_new = m[TABLE_moduleinst =.. [ta]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) - ;; 7-module.watsup:28.1-33.60 - def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, ma : memaddr, memtype : memtype, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = MEM_externtype(memtype)) - -- if (externval = MEM_externval(ma)) - -- if (m_new = m[MEM_moduleinst =.. [ma]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) +;; 7-module.watsup:4.1-4.35 +def funcs : externval* -> funcaddr* + ;; 7-module.watsup:5.1-5.30 + def funcs([]) = [] + ;; 7-module.watsup:6.1-6.59 + def {externval'* : externval*, fa : funcaddr} funcs([FUNC_externval(fa)] :: externval'*{externval'}) = [fa] :: $funcs(externval'*{externval'}) + ;; 7-module.watsup:7.1-8.15 + def {externval : externval, externval'* : externval*} funcs([externval] :: externval'*{externval'}) = $funcs(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:36.1-36.51 +;; 7-module.watsup:10.1-10.39 rec { -;; 7-module.watsup:36.1-36.51 -def alloc_func : (state, func*) -> (store, funcaddr*) - ;; 7-module.watsup:38.1-38.48 - def {f : frame, s : store} alloc_func(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:40.1-44.56 - def {f : frame, fa : funcaddr, fa'* : funcaddr*, fi : funcinst, func : func, func'* : func*, s : store, s_new : store, s_res : store} alloc_func(`%;%`(s, f), [func] :: func'*{func'}) = (s_res, [fa] :: fa'*{fa'}) - -- if (fi = {MODULE f.MODULE_frame, CODE func}) - -- if (fa = |$funcinst(`%;%`(s, f))|) - -- if (s_new = s[FUNC_store =.. [fi]]) - -- if ((s_res, fa'*{fa'}) = $alloc_func(`%;%`(s_new, f), func'*{func'})) +;; 7-module.watsup:10.1-10.39 +def globals : externval* -> globaladdr* + ;; 7-module.watsup:11.1-11.32 + def globals([]) = [] + ;; 7-module.watsup:12.1-12.65 + def {externval'* : externval*, ga : globaladdr} globals([GLOBAL_externval(ga)] :: externval'*{externval'}) = [ga] :: $globals(externval'*{externval'}) + ;; 7-module.watsup:13.1-14.15 + def {externval : externval, externval'* : externval*} globals([externval] :: externval'*{externval'}) = $globals(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:47.1-47.57 +;; 7-module.watsup:16.1-16.37 rec { -;; 7-module.watsup:47.1-47.57 -def alloc_global : (state, global*) -> (store, globaladdr*) - ;; 7-module.watsup:49.1-49.50 - def {f : frame, s : store} alloc_global(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:51.1-57.60 - def {f : frame, ga : globaladdr, ga'* : globaladdr*, gi : globalinst, global : global, global'* : global*, globaltype : globaltype, instr* : instr*, s : store, s_new : store, s_res : store, val : val} alloc_global(`%;%`(s, f), [global] :: global'*{global'}) = (s_res, [ga] :: ga'*{ga'}) - -- if (global = GLOBAL(globaltype, instr*{instr})) - -- Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), (instr <: admininstr)*{instr}), [(val <: admininstr)]) - -- if (gi = {TYPE globaltype, VALUE val}) - -- if (ga = |$globalinst(`%;%`(s, f))|) - -- if (s_new = s[GLOBAL_store =.. [gi]]) - -- if ((s_res, ga'*{ga'}) = $alloc_global(`%;%`(s_new, f), global'*{global'})) +;; 7-module.watsup:16.1-16.37 +def tables : externval* -> tableaddr* + ;; 7-module.watsup:17.1-17.31 + def tables([]) = [] + ;; 7-module.watsup:18.1-18.62 + def {externval'* : externval*, ta : tableaddr} tables([TABLE_externval(ta)] :: externval'*{externval'}) = [ta] :: $tables(externval'*{externval'}) + ;; 7-module.watsup:19.1-20.15 + def {externval : externval, externval'* : externval*} tables([externval] :: externval'*{externval'}) = $tables(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:60.1-60.54 +;; 7-module.watsup:22.1-22.33 rec { -;; 7-module.watsup:60.1-60.54 -def alloc_table : (state, table*) -> (store, tableaddr*) - ;; 7-module.watsup:62.1-62.49 - def {f : frame, s : store} alloc_table(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:64.1-70.58 - def {f : frame, i : nat, j? : nat?, reftype : reftype, s : store, s_new : store, s_res : store, ta : tableaddr, ta'* : tableaddr*, table : table, table'* : table*, tabletype : tabletype, ti : tableinst} alloc_table(`%;%`(s, f), [table] :: table'*{table'}) = (s_res, [ta] :: ta'*{ta'}) - -- if (table = TABLE(tabletype)) - -- if (tabletype = `%%`(`[%..%?]`(i, j?{j}), reftype)) - -- if (ti = {TYPE tabletype, ELEM REF.NULL_ref(reftype)^i{}}) - -- if (ta = |$tableinst(`%;%`(s, f))|) - -- if (s_new = s[TABLE_store =.. [ti]]) - -- if ((s_res, ta'*{ta'}) = $alloc_table(`%;%`(s_new, f), table'*{table'})) +;; 7-module.watsup:22.1-22.33 +def mems : externval* -> memaddr* + ;; 7-module.watsup:23.1-23.29 + def mems([]) = [] + ;; 7-module.watsup:24.1-24.56 + def {externval'* : externval*, ma : memaddr} mems([MEM_externval(ma)] :: externval'*{externval'}) = [ma] :: $mems(externval'*{externval'}) + ;; 7-module.watsup:25.1-26.15 + def {externval : externval, externval'* : externval*} mems([externval] :: externval'*{externval'}) = $mems(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:73.1-73.48 +;; 7-module.watsup:29.1-29.83 +def instexport : (funcaddr*, globaladdr*, tableaddr*, memaddr*, export) -> exportinst + ;; 7-module.watsup:30.1-30.95 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, FUNC_externuse(x))) = {NAME name, VALUE FUNC_externval(fa*{fa}[x])} + ;; 7-module.watsup:31.1-31.99 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, GLOBAL_externuse(x))) = {NAME name, VALUE GLOBAL_externval(ga*{ga}[x])} + ;; 7-module.watsup:32.1-32.97 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, TABLE_externuse(x))) = {NAME name, VALUE TABLE_externval(ta*{ta}[x])} + ;; 7-module.watsup:33.1-33.93 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, MEM_externuse(x))) = {NAME name, VALUE MEM_externval(ma*{ma}[x])} + +;; 7-module.watsup:36.1-36.60 +def allocfunc : (store, moduleinst, func) -> (store, funcaddr) + ;; 7-module.watsup:37.1-38.37 + def {fi : funcinst, func : func, m : moduleinst, s : store} allocfunc(s, m, func) = (s[FUNC_store =.. [fi]], |s.FUNC_store|) + -- if (fi = {MODULE m, CODE func}) + +;; 7-module.watsup:40.1-40.63 rec { -;; 7-module.watsup:73.1-73.48 -def alloc_mem : (state, mem*) -> (store, memaddr*) - ;; 7-module.watsup:75.1-75.47 - def {f : frame, s : store} alloc_mem(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:77.1-83.54 - def {f : frame, i : nat, j? : nat?, ma : memaddr, ma'* : memaddr*, mem : mem, mem'* : mem*, memtype : memtype, mi : meminst, s : store, s_new : store, s_res : store} alloc_mem(`%;%`(s, f), [mem] :: mem'*{mem'}) = (s_res, [ma] :: ma'*{ma'}) - -- if (mem = MEMORY(memtype)) - -- if (memtype = `%I8`(`[%..%?]`(i, j?{j}))) - -- if (mi = {TYPE memtype, DATA 0^((i * 64) * $Ki){}}) - -- if (ma = |$meminst(`%;%`(s, f))|) - -- if (s_new = s[MEM_store =.. [mi]]) - -- if ((s_res, ma'*{ma'}) = $alloc_mem(`%;%`(s_new, f), mem'*{mem'})) +;; 7-module.watsup:40.1-40.63 +def allocfuncs : (store, moduleinst, func*) -> (store, funcaddr*) + ;; 7-module.watsup:41.1-41.46 + def {m : moduleinst, s : store} allocfuncs(s, m, []) = (s, []) + ;; 7-module.watsup:42.1-44.50 + def {fa : funcaddr, fa'* : funcaddr*, func : func, func'* : func*, m : moduleinst, s : store, s_1 : store, s_2 : store} allocfuncs(s, m, [func] :: func'*{func'}) = (s_2, [fa] :: fa'*{fa'}) + -- if ((s_1, fa) = $allocfunc(s, m, func)) + -- if ((s_2, fa'*{fa'}) = $allocfuncs(s_1, m, func'*{func'})) } -;; 7-module.watsup:86.1-86.51 +;; 7-module.watsup:46.1-46.63 +def allocglobal : (store, globaltype, val) -> (store, globaladdr) + ;; 7-module.watsup:47.1-48.44 + def {gi : globalinst, globaltype : globaltype, s : store, val : val} allocglobal(s, globaltype, val) = (s[GLOBAL_store =.. [gi]], |s.GLOBAL_store|) + -- if (gi = {TYPE globaltype, VALUE val}) + +;; 7-module.watsup:50.1-50.67 rec { -;; 7-module.watsup:86.1-86.51 -def alloc_elem : (state, elem*) -> (store, elemaddr*) - ;; 7-module.watsup:88.1-88.48 - def {f : frame, s : store} alloc_elem(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:90.1-96.56 - def {ea : elemaddr, ea'* : elemaddr*, ei : eleminst, elem : elem, elem'* : elem*, elemmode? : elemmode?, f : frame, instr** : instr**, ref* : ref*, reftype : reftype, s : store, s_new : store, s_res : store} alloc_elem(`%;%`(s, f), [elem] :: elem'*{elem'}) = (s_res, [ea] :: ea'*{ea'}) - -- if (elem = `ELEM%%*%?`(reftype, instr*{instr}*{instr}, elemmode?{elemmode})) - -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), (instr <: admininstr)*{instr}), [(ref <: admininstr)]))*{instr ref} - -- if (ei = {TYPE reftype, ELEM ref*{ref}}) - -- if (ea = |$eleminst(`%;%`(s, f))|) - -- if (s_new = s[ELEM_store =.. [ei]]) - -- if ((s_res, ea'*{ea'}) = $alloc_elem(`%;%`(s_new, f), elem'*{elem'})) +;; 7-module.watsup:50.1-50.67 +def allocglobals : (store, globaltype*, val*) -> (store, globaladdr*) + ;; 7-module.watsup:51.1-51.54 + def {s : store} allocglobals(s, [], []) = (s, []) + ;; 7-module.watsup:52.1-54.62 + def {ga : globaladdr, ga'* : globaladdr*, globaltype : globaltype, globaltype'* : globaltype*, s : store, s_1 : store, s_2 : store, val : val, val'* : val*} allocglobals(s, [globaltype] :: globaltype'*{globaltype'}, [val] :: val'*{val'}) = (s_2, [ga] :: ga'*{ga'}) + -- if ((s_1, ga) = $allocglobal(s, globaltype, val)) + -- if ((s_2, ga'*{ga'}) = $allocglobals(s_1, globaltype'*{globaltype'}, val'*{val'})) } -;; 7-module.watsup:99.1-99.51 +;; 7-module.watsup:56.1-56.55 +def alloctable : (store, tabletype) -> (store, tableaddr) + ;; 7-module.watsup:57.1-58.59 + def {i : nat, j : nat, rt : reftype, s : store, ti : tableinst} alloctable(s, `%%`(`[%..%]`(i, j), rt)) = (s[TABLE_store =.. [ti]], |s.TABLE_store|) + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM REF.NULL_ref(rt)^i{}}) + +;; 7-module.watsup:60.1-60.58 rec { -;; 7-module.watsup:99.1-99.51 -def alloc_data : (state, data*) -> (store, dataaddr*) - ;; 7-module.watsup:101.1-101.48 - def {f : frame, s : store} alloc_data(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:103.1-108.56 - def {byte* : byte*, da : dataaddr, da'* : dataaddr*, data : data, data'* : data*, datamode? : datamode?, di : datainst, f : frame, s : store, s_new : store, s_res : store} alloc_data(`%;%`(s, f), [data] :: data'*{data'}) = (s_res, [da] :: da'*{da'}) - -- if (data = `DATA%*%?`(byte*{byte}, datamode?{datamode})) - -- if (di = {DATA byte*{byte}}) - -- if (da = |$datainst(`%;%`(s, f))|) - -- if (s_new = s[DATA_store =.. [di]]) - -- if ((s_res, da'*{da'}) = $alloc_data(`%;%`(s_new, f), data'*{data'})) +;; 7-module.watsup:60.1-60.58 +def alloctables : (store, tabletype*) -> (store, tableaddr*) + ;; 7-module.watsup:61.1-61.44 + def {s : store} alloctables(s, []) = (s, []) + ;; 7-module.watsup:62.1-64.53 + def {s : store, s_1 : store, s_2 : store, ta : tableaddr, ta'* : tableaddr*, tabletype : tabletype, tabletype'* : tabletype*} alloctables(s, [tabletype] :: tabletype'*{tabletype'}) = (s_2, [ta] :: ta'*{ta'}) + -- if ((s_1, ta) = $alloctable(s, tabletype)) + -- if ((s_2, ta'*{ta'}) = $alloctables(s_1, tabletype'*{tabletype'})) } -;; 7-module.watsup:111.1-111.62 +;; 7-module.watsup:66.1-66.49 +def allocmem : (store, memtype) -> (store, memaddr) + ;; 7-module.watsup:67.1-68.62 + def {i : nat, j : nat, mi : meminst, s : store} allocmem(s, `%I8`(`[%..%]`(i, j))) = (s[MEM_store =.. [mi]], |s.MEM_store|) + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA 0^((i * 64) * $Ki){}}) + +;; 7-module.watsup:70.1-70.52 rec { -;; 7-module.watsup:111.1-111.62 -def replace_moduleinst : (store, funcaddr*, moduleinst) -> store - ;; 7-module.watsup:113.1-113.43 - def {m : moduleinst, s : store} replace_moduleinst(s, [], m) = s - ;; 7-module.watsup:115.1-117.52 - def {fa : funcaddr, fa'* : funcaddr*, m : moduleinst, s : store, s_new : store, s_res : store} replace_moduleinst(s, [fa] :: fa'*{fa'}, m) = s_res - -- if (s_new = s[FUNC_store[fa].MODULE_funcinst = m]) - -- if (s_res = $replace_moduleinst(s_new, fa'*{fa'}, m)) +;; 7-module.watsup:70.1-70.52 +def allocmems : (store, memtype*) -> (store, memaddr*) + ;; 7-module.watsup:71.1-71.42 + def {s : store} allocmems(s, []) = (s, []) + ;; 7-module.watsup:72.1-74.49 + def {ma : memaddr, ma'* : memaddr*, memtype : memtype, memtype'* : memtype*, s : store, s_1 : store, s_2 : store} allocmems(s, [memtype] :: memtype'*{memtype'}) = (s_2, [ma] :: ma'*{ma'}) + -- if ((s_1, ma) = $allocmem(s, memtype)) + -- if ((s_2, ma'*{ma'}) = $allocmems(s_1, memtype'*{memtype'})) } -;; 7-module.watsup:120.1-120.51 -def alloc_export : (moduleinst, export) -> exportinst - ;; 7-module.watsup:122.1-126.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = FUNC_externuse(x)) - -- if (externval = FUNC_externval(m.FUNC_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - ;; 7-module.watsup:128.1-132.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = GLOBAL_externuse(x)) - -- if (externval = GLOBAL_externval(m.GLOBAL_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - ;; 7-module.watsup:134.1-138.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = TABLE_externuse(x)) - -- if (externval = TABLE_externval(m.TABLE_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - ;; 7-module.watsup:140.1-144.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = MEM_externuse(x)) - -- if (externval = MEM_externval(m.MEM_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - -;; 7-module.watsup:147.1-147.67 -def alloc_module : (store, module, externval*) -> (store, moduleinst) - ;; 7-module.watsup:149.1-163.56 - def {da* : dataaddr*, data* : data*, ea* : elemaddr*, elem* : elem*, export* : export*, externval* : externval*, f : frame, fa* : funcaddr*, func* : func*, ga* : globaladdr*, global* : global*, import* : import*, m_ex : moduleinst, m_im : moduleinst, m_init : moduleinst, m_res : moduleinst, ma* : memaddr*, mem* : mem*, module : module, s : store, s_data : store, s_elem : store, s_func : store, s_global : store, s_mem : store, s_res : store, s_table : store, start? : start?, ta* : tableaddr*, table* : table*, xi* : exportinst*} alloc_module(s, module, externval*{externval}) = (s_res, m_res) - -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) - -- if (m_init = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) - -- if (m_im = $alloc_import(m_init, import*{import}, externval*{externval})) - -- if (f = {LOCAL [], MODULE m_im}) - -- if ((s_func, fa*{fa}) = $alloc_func(`%;%`(s, f), func*{func})) - -- if ((s_global, ga*{ga}) = $alloc_global(`%;%`(s_func, f), global*{global})) - -- if ((s_table, ta*{ta}) = $alloc_table(`%;%`(s_global, f), table*{table})) - -- if ((s_mem, ma*{ma}) = $alloc_mem(`%;%`(s_table, f), mem*{mem})) - -- if ((s_elem, ea*{ea}) = $alloc_elem(`%;%`(s_mem, f), elem*{elem})) - -- if ((s_data, da*{da}) = $alloc_data(`%;%`(s_elem, f), data*{data})) - -- if (m_ex = m_im ++ {FUNC fa*{fa}, GLOBAL ga*{ga}, TABLE ta*{ta}, MEM ma*{ma}, ELEM ea*{ea}, DATA da*{da}, EXPORT []}) - -- if (xi*{xi} = $alloc_export(m_ex, export)*{export}) - -- if (m_res = m_ex[EXPORT_moduleinst = xi*{xi}]) - -- if (s_res = $replace_moduleinst(s_data, fa*{fa}, m_res)) - -;; 7-module.watsup:166.1-166.41 +;; 7-module.watsup:76.1-76.57 +def allocelem : (store, reftype, ref*) -> (store, elemaddr) + ;; 7-module.watsup:77.1-78.36 + def {ei : eleminst, ref* : ref*, rt : reftype, s : store} allocelem(s, rt, ref*{ref}) = (s[ELEM_store =.. [ei]], |s.ELEM_store|) + -- if (ei = {TYPE rt, ELEM ref*{ref}}) + +;; 7-module.watsup:80.1-80.63 rec { -;; 7-module.watsup:166.1-166.41 -def run_elem : (state, elem*, idx) -> state - ;; 7-module.watsup:168.1-168.41 - def {f : frame, i : nat, s : store} run_elem(`%;%`(s, f), [], i) = `%;%`(s, f) - ;; 7-module.watsup:170.1-172.59 - def {elem : elem, elem'* : elem*, expr* : expr*, f : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) - -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?())) - -- if ($run_elem(`%;%`(s, f), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:174.1-179.67 - def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, reftype : reftype, s : store, s_new : store, s_res : store, x : idx} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) - -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) - -- if (n = |expr*{expr}|) - -- if (elemmode = TABLE_elemmode(x, instr*{instr})) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), (instr <: admininstr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, i) ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) - -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:181.1-185.67 - def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_new : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) - -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) - -- if (elemmode = DECLARE_elemmode) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), [ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) - -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) +;; 7-module.watsup:80.1-80.63 +def allocelems : (store, reftype*, ref**) -> (store, elemaddr*) + ;; 7-module.watsup:81.1-81.52 + def {s : store} allocelems(s, [], []) = (s, []) + ;; 7-module.watsup:82.1-84.53 + def {ea : elemaddr, ea'* : elemaddr*, ref* : ref*, ref'** : ref**, rt : reftype, rt'* : reftype*, s : store, s_1 : store, s_2 : store} allocelems(s, [rt] :: rt'*{rt'}, [ref]*{ref} :: ref'*{ref'}*{ref'}) = (s_2, [ea] :: ea'*{ea'}) + -- if ((s_1, ea) = $allocelem(s, rt, ref*{ref})) + -- if ((s_2, ea'*{ea'}) = $allocelems(s_2, rt'*{rt'}, ref'*{ref'}*{ref'})) } -;; 7-module.watsup:188.1-188.41 +;; 7-module.watsup:86.1-86.49 +def allocdata : (store, byte*) -> (store, dataaddr) + ;; 7-module.watsup:87.1-88.28 + def {byte* : byte*, di : datainst, s : store} allocdata(s, byte*{byte}) = (s[DATA_store =.. [di]], |s.DATA_store|) + -- if (di = {DATA byte*{byte}}) + +;; 7-module.watsup:90.1-90.52 rec { -;; 7-module.watsup:188.1-188.41 -def run_data : (state, data*, idx) -> state - ;; 7-module.watsup:190.1-190.41 - def {f : frame, i : nat, s : store} run_data(`%;%`(s, f), [], i) = `%;%`(s, f) - ;; 7-module.watsup:192.1-194.59 - def {byte* : byte*, data : data, data'* : data*, f : frame, f_res : frame, i : nat, s : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) - -- if (data = `DATA%*%?`(byte*{byte}, ?())) - -- if ($run_data(`%;%`(s, f), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:196.1-201.67 - def {byte* : byte*, data : data, data'* : data*, datamode : datamode, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, s : store, s_new : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) - -- if (data = `DATA%*%?`(byte*{byte}, ?(datamode))) +;; 7-module.watsup:90.1-90.52 +def allocdatas : (store, byte**) -> (store, dataaddr*) + ;; 7-module.watsup:91.1-91.43 + def {s : store} allocdatas(s, []) = (s, []) + ;; 7-module.watsup:92.1-94.48 + def {byte* : byte*, byte'** : byte**, da : dataaddr, da'* : dataaddr*, s : store, s_1 : store, s_2 : store} allocdatas(s, [byte]*{byte} :: byte'*{byte'}*{byte'}) = (s_2, [da] :: da'*{da'}) + -- if ((s_1, da) = $allocdata(s, byte*{byte})) + -- if ((s_2, da'*{da'}) = $allocdatas(s_1, byte'*{byte'}*{byte'})) +} + +;; 7-module.watsup:97.1-97.81 +def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) + ;; 7-module.watsup:98.1-135.54 + def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i : nat, import* : import*, m : moduleinst, ma* : memaddr*, ma_ex* : memaddr*, memtype^n_mem : memtype^n_mem, module : module, n_data : n, n_elem : n, n_func : n, n_global : n, n_mem : n, n_table : n, ref** : ref**, rt^n_elem : reftype^n_elem, s : store, s_1 : store, s_2 : store, s_3 : store, s_4 : store, s_5 : store, s_6 : store, start? : start?, ta* : tableaddr*, ta_ex* : tableaddr*, tabletype^n_table : tabletype^n_table, val* : val*, xi* : exportinst*} allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref}) = (s_6, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func^n_func{func}, GLOBAL(globaltype, expr_1)^n_global{expr_1 globaltype}, TABLE(tabletype)^n_table{tabletype}, MEMORY(memtype)^n_mem{memtype}, `ELEM%%*%?`(rt, expr_2*{expr_2}, elemmode?{elemmode})^n_elem{elemmode expr_2 rt}, `DATA%*%?`(byte*{byte}, datamode?{datamode})^n_data{byte datamode}, start?{start}, export*{export})) + -- if (fa_ex*{fa_ex} = $funcs(externval*{externval})) + -- if (ga_ex*{ga_ex} = $globals(externval*{externval})) + -- if (ta_ex*{ta_ex} = $tables(externval*{externval})) + -- if (ma_ex*{ma_ex} = $mems(externval*{externval})) + -- if (fa*{fa} = (|s.FUNC_store| + i)^(i instr* + ;; 7-module.watsup:139.1-139.46 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?()), i) = [] + ;; 7-module.watsup:140.1-140.62 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(DECLARE_elemmode)), i) = [ELEM.DROP_instr(i)] + ;; 7-module.watsup:141.1-143.20 + def {expr* : expr*, i : nat, instr* : instr*, n : n, reftype : reftype, x : idx} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(TABLE_elemmode(x, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) TABLE.INIT_instr(x, i) ELEM.DROP_instr(i)] + -- if (n = |expr*{expr}|) + +;; 7-module.watsup:145.1-145.33 +def rundata : (data, idx) -> instr* + ;; 7-module.watsup:146.1-146.38 + def {byte* : byte*, i : nat} rundata(`DATA%*%?`(byte*{byte}, ?()), i) = [] + ;; 7-module.watsup:147.1-149.20 + def {byte* : byte*, i : nat, instr* : instr*, n : n} rundata(`DATA%*%?`(byte*{byte}, ?(MEMORY_datamode(0, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) MEMORY.INIT_instr(i) DATA.DROP_instr(i)] -- if (n = |byte*{byte}|) - -- if (datamode = MEMORY_datamode(0, instr*{instr})) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), (instr <: admininstr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(i) DATA.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) - -- if ($run_data(`%;%`(s_new, f_new), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) + +;; 7-module.watsup:152.1-152.36 +rec { + +;; 7-module.watsup:152.1-152.36 +def concat_instr : instr** -> instr* + ;; 7-module.watsup:153.1-153.37 + def concat_instr([]) = [] + ;; 7-module.watsup:154.1-154.68 + def {instr* : instr*, instr'** : instr**} concat_instr([instr]*{instr} :: instr'*{instr'}*{instr'}) = instr*{instr} :: $concat_instr(instr'*{instr'}*{instr'}) } -;; 7-module.watsup:206.1-206.68 -def instantiation : (store, module, externval*) -> (store, moduleinst) - ;; 7-module.watsup:208.1-213.61 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) - -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(), export*{export})) - -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) - -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) - -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:215.1-222.62 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) - -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(start), export*{export})) - -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) +;; 7-module.watsup:157.1-157.55 +def instantiation : (store, module, externval*) -> config + ;; 7-module.watsup:158.1-180.28 + def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i : nat, import* : import*, instr_1** : instr**, instr_2*** : instr***, instr_data* : instr*, instr_elem* : instr*, j : nat, m : moduleinst, m_init : moduleinst, mem* : mem*, module : module, n_data : n, n_elem : n, ref** : ref**, reftype* : reftype*, s : store, s' : store, start? : start?, table* : table*, val* : val*, x? : idx?} instantiation(s, module, externval*{externval}) = `%;%*`(`%;%`(s', f), (instr_elem <: admininstr)*{instr_elem} :: (instr_data <: admininstr)*{instr_data} :: CALL_admininstr(x)?{x}) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) + -- if (m_init = {FUNC $funcs(externval*{externval}), GLOBAL $globals(externval*{externval}), TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f_init = {LOCAL [], MODULE m_init}) + -- (if (global = GLOBAL(globaltype, instr_1*{instr_1})))*{global globaltype instr_1} + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), (instr_1 <: admininstr)*{instr_1}), [(val <: admininstr)]))*{instr_1 val} + -- (if (elem = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})))*{elem elemmode instr_2 reftype} + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), (instr_2 <: admininstr)*{instr_2}), [(ref <: admininstr)]))*{instr_2 ref}*{instr_2 ref} + -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) - -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_data, f_data)) - -- if (start = START(x)) - -- Step: `%~>%`(`%;%*`(`%;%`(s_data, f_data), [CALL_admininstr(x)]), `%;%*`(`%;%`(s_res, f_res), [])) - -;; 7-module.watsup:227.1-227.55 -def invocation : (store, funcaddr, val*) -> (store, val*) - ;; 7-module.watsup:229.1-236.55 - def {expr : expr, f : frame, f' : frame, fa : funcaddr, functype : functype, m : moduleinst, s : store, s' : store, val* : val*, val'* : val*, valtype* : valtype*, valtype'* : valtype*} invocation(s, fa, val*{val}) = (s', val'*{val'}) + -- if (n_elem = |elem*{elem}|) + -- if (instr_elem*{instr_elem} = $concat_instr($runelem(elem*{elem}[i], i)^(i config + ;; 7-module.watsup:184.1-196.52 + def {expr : expr, f : frame, fa : funcaddr, functype : functype, k : nat, m : moduleinst, n : n, s : store, val^n : val^n, valtype* : valtype*, valtype_param^n : valtype^n, valtype_res^k : valtype^k} invocation(s, fa, val^n{val}) = `%;%*`(`%;%`(s, f), (val <: admininstr)^n{val} :: [CALL_ADDR_admininstr(fa)]) -- if (m = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) -- if (f = {LOCAL [], MODULE m}) -- if ($funcinst(`%;%`(s, f))[fa].CODE_funcinst = `FUNC%%*%`(functype, valtype*{valtype}, expr)) - -- if (functype = `%->%`(valtype*{valtype}, valtype'*{valtype'})) - -- if (|val*{val}| = |valtype*{valtype}|) - -- if (|val'*{val'}| = |valtype'*{valtype'}|) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), (val <: admininstr)*{val} :: [CALL_ADDR_admininstr(fa)]), `%;%*`(`%;%`(s', f'), (val' <: admininstr)*{val'})) + -- if (functype = `%->%`(valtype_param^n{valtype_param}, valtype_res^k{valtype_res})) == IL Validation... == Running pass sub @@ -2065,8 +2053,8 @@ def valtype_fn : fn -> valtype ;; 1-syntax.watsup:56.1-57.11 syntax resulttype = valtype* -;; 1-syntax.watsup:59.1-60.17 -syntax limits = `[%..%?]`(u32, u32?) +;; 1-syntax.watsup:59.1-60.16 +syntax limits = `[%..%]`(u32, u32) ;; 1-syntax.watsup:61.1-62.15 syntax globaltype = `MUT%?%`(()?, valtype) @@ -2359,7 +2347,7 @@ syntax context = {FUNC functype*, GLOBAL globaltype*, TABLE tabletype*, MEM memt relation Limits_ok: `|-%:%`(limits, nat) ;; 3-typing.watsup:22.1-24.24 rule _ {k : nat, n_1 : n, n_2 : n}: - `|-%:%`(`[%..%?]`(n_1, ?(n_2)), k) + `|-%:%`(`[%..%]`(n_1, n_2), k) -- if ((n_1 <= n_2) /\ (n_2 <= k)) ;; 3-typing.watsup:15.1-15.64 @@ -2431,7 +2419,7 @@ relation Resulttype_sub: `|-%*<:%*`(valtype*, valtype*) relation Limits_sub: `|-%<:%`(limits, limits) ;; 3-typing.watsup:83.1-86.21 rule _ {n_11 : n, n_12 : n, n_21 : n, n_22 : n}: - `|-%<:%`(`[%..%?]`(n_11, ?(n_12)), `[%..%?]`(n_21, ?(n_22))) + `|-%<:%`(`[%..%]`(n_11, n_12), `[%..%]`(n_21, n_22)) -- if (n_11 >= n_21) -- if (n_12 <= n_22) @@ -3032,10 +3020,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:180.1-187.5 +;; 4-runtime.watsup:183.1-190.5 rec { -;; 4-runtime.watsup:180.1-187.5 +;; 4-runtime.watsup:183.1-190.5 syntax admininstr = | UNREACHABLE | NOP @@ -3259,26 +3247,28 @@ def with_data : (state, dataidx, byte*) -> state ;; 4-runtime.watsup:165.1-165.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:167.1-167.49 +;; 4-runtime.watsup:167.1-167.63 def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:169.1-172.57 - def {i : nat, i' : nat, j? : nat?, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' - -- if (ti = {TYPE `%%`(`[%..%?]`(i, j?{j}), reftype), ELEM r'*{r'}}) + ;; 4-runtime.watsup:170.1-174.36 + def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, rt : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM r'*{r'}}) -- if (i' = (|r'*{r'}| + n)) - -- if (ti' = {TYPE `%%`(`[%..%?]`(i', j?{j}), reftype), ELEM r'*{r'} :: r^n{}}) + -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), rt), ELEM r'*{r'} :: r^n{}}) + -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) -;; 4-runtime.watsup:168.1-168.41 +;; 4-runtime.watsup:168.1-168.55 def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:173.1-176.66 - def {b* : byte*, i : nat, i' : nat, j? : nat?, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' - -- if (mi = {TYPE `%I8`(`[%..%?]`(i, j?{j})), DATA b*{b}}) + ;; 4-runtime.watsup:175.1-179.34 + def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) - -- if (mi' = {TYPE `%I8`(`[%..%?]`(i', j?{j})), DATA b*{b} :: 0^((n * 64) * $Ki){}}) + -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: 0^((n * 64) * $Ki){}}) + -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) -;; 4-runtime.watsup:189.1-192.21 +;; 4-runtime.watsup:192.1-195.21 rec { -;; 4-runtime.watsup:189.1-192.21 +;; 4-runtime.watsup:192.1-195.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -3507,135 +3497,135 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:214.1-216.39 + ;; 6-reduction.watsup:212.1-214.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:218.1-221.14 + ;; 6-reduction.watsup:216.1-219.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:223.1-227.15 + ;; 6-reduction.watsup:221.1-225.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:230.1-232.73 + ;; 6-reduction.watsup:228.1-230.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:234.1-237.14 + ;; 6-reduction.watsup:232.1-235.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:239.1-244.15 + ;; 6-reduction.watsup:237.1-242.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:246.1-250.15 + ;; 6-reduction.watsup:244.1-248.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:253.1-255.72 + ;; 6-reduction.watsup:251.1-253.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:257.1-260.14 + ;; 6-reduction.watsup:255.1-258.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:262.1-266.15 + ;; 6-reduction.watsup:260.1-264.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y).ELEM_eleminst[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:273.1-275.53 + ;; 6-reduction.watsup:271.1-273.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + ($size($valtype_numtype(nt)) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:277.1-279.71 + ;; 6-reduction.watsup:275.1-277.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- if ($bytes_($size($valtype_numtype(nt)), c) = $mem(z, 0).DATA_meminst[(i + n_O) : ($size($valtype_numtype(nt)) / 8)]) - ;; 6-reduction.watsup:281.1-283.45 + ;; 6-reduction.watsup:279.1-281.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:285.1-287.55 + ;; 6-reduction.watsup:283.1-285.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, $size($valtype_numtype(nt)), sx, c))]) -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:307.1-309.44 + ;; 6-reduction.watsup:305.1-307.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:322.1-324.37 + ;; 6-reduction.watsup:318.1-320.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:326.1-329.14 + ;; 6-reduction.watsup:322.1-325.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:331.1-335.15 + ;; 6-reduction.watsup:327.1-331.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:338.1-340.69 + ;; 6-reduction.watsup:334.1-336.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:342.1-345.14 + ;; 6-reduction.watsup:338.1-341.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:347.1-352.15 + ;; 6-reduction.watsup:343.1-348.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:354.1-358.15 + ;; 6-reduction.watsup:350.1-354.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:361.1-363.70 + ;; 6-reduction.watsup:357.1-359.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:365.1-368.14 + ;; 6-reduction.watsup:361.1-364.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:370.1-374.15 + ;; 6-reduction.watsup:366.1-370.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise @@ -3670,327 +3660,313 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-208.36 - rule table.grow-succeed {n : n, ref : ref, ti : tableinst, ti' : tableinst, x : idx, z : state}: - `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti'), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($table(z, x) = ti) - -- if ($grow_table(ti, n, ref) = ti') - -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) + ;; 6-reduction.watsup:204.1-206.47 + rule table.grow-succeed {n : n, ref : ref, ti : tableinst, x : idx, z : state}: + `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($grow_table($table(z, x), n, ref) = ti) - ;; 6-reduction.watsup:210.1-211.64 + ;; 6-reduction.watsup:208.1-209.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:269.1-270.59 + ;; 6-reduction.watsup:267.1-268.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:290.1-292.53 + ;; 6-reduction.watsup:288.1-290.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + ($size($valtype_numtype(nt)) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:294.1-296.35 + ;; 6-reduction.watsup:292.1-294.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), ($size($valtype_numtype(nt)) / 8), b*{b}), [])) -- if (b*{b} = $bytes_($size($valtype_numtype(nt)), c)) - ;; 6-reduction.watsup:298.1-300.45 + ;; 6-reduction.watsup:296.1-298.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:302.1-304.50 + ;; 6-reduction.watsup:300.1-302.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if (b*{b} = $bytes_(n, $wrap_(($size($valtype_numtype(nt)), n), c))) - ;; 6-reduction.watsup:312.1-316.34 - rule memory.grow-succeed {mi : meminst, mi' : meminst, n : n, z : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_meminst(z, 0, mi'), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - -- if ($mem(z, 0) = mi) - -- if ($grow_memory(mi, n) = mi') - -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) + ;; 6-reduction.watsup:310.1-312.41 + rule memory.grow-succeed {mi : meminst, n : n, z : state}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_meminst(z, 0, mi), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($grow_memory($mem(z, 0), n) = mi) - ;; 6-reduction.watsup:318.1-319.59 + ;; 6-reduction.watsup:314.1-315.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:377.1-378.59 + ;; 6-reduction.watsup:373.1-374.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) -;; 7-module.watsup:3.1-3.64 +;; 7-module.watsup:4.1-4.35 rec { -;; 7-module.watsup:3.1-3.64 -def alloc_import : (moduleinst, import*, externval*) -> moduleinst - ;; 7-module.watsup:5.1-5.43 - def {m : moduleinst} alloc_import(m, [], []) = m - ;; 7-module.watsup:7.1-12.60 - def {externtype : externtype, externval : externval, externval'* : externval*, fa : funcaddr, functype : functype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = FUNC_externtype(functype)) - -- if (externval = FUNC_externval(fa)) - -- if (m_new = m[FUNC_moduleinst =.. [fa]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) - ;; 7-module.watsup:14.1-19.60 - def {externtype : externtype, externval : externval, externval'* : externval*, ga : globaladdr, globaltype : globaltype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = GLOBAL_externtype(globaltype)) - -- if (externval = GLOBAL_externval(ga)) - -- if (m_new = m[GLOBAL_moduleinst =.. [ga]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) - ;; 7-module.watsup:21.1-26.60 - def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name, ta : tableaddr, tabletype : tabletype} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = TABLE_externtype(tabletype)) - -- if (externval = TABLE_externval(ta)) - -- if (m_new = m[TABLE_moduleinst =.. [ta]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) - ;; 7-module.watsup:28.1-33.60 - def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, ma : memaddr, memtype : memtype, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = MEM_externtype(memtype)) - -- if (externval = MEM_externval(ma)) - -- if (m_new = m[MEM_moduleinst =.. [ma]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) +;; 7-module.watsup:4.1-4.35 +def funcs : externval* -> funcaddr* + ;; 7-module.watsup:5.1-5.30 + def funcs([]) = [] + ;; 7-module.watsup:6.1-6.59 + def {externval'* : externval*, fa : funcaddr} funcs([FUNC_externval(fa)] :: externval'*{externval'}) = [fa] :: $funcs(externval'*{externval'}) + ;; 7-module.watsup:7.1-8.15 + def {externval : externval, externval'* : externval*} funcs([externval] :: externval'*{externval'}) = $funcs(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:36.1-36.51 +;; 7-module.watsup:10.1-10.39 rec { -;; 7-module.watsup:36.1-36.51 -def alloc_func : (state, func*) -> (store, funcaddr*) - ;; 7-module.watsup:38.1-38.48 - def {f : frame, s : store} alloc_func(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:40.1-44.56 - def {f : frame, fa : funcaddr, fa'* : funcaddr*, fi : funcinst, func : func, func'* : func*, s : store, s_new : store, s_res : store} alloc_func(`%;%`(s, f), [func] :: func'*{func'}) = (s_res, [fa] :: fa'*{fa'}) - -- if (fi = {MODULE f.MODULE_frame, CODE func}) - -- if (fa = |$funcinst(`%;%`(s, f))|) - -- if (s_new = s[FUNC_store =.. [fi]]) - -- if ((s_res, fa'*{fa'}) = $alloc_func(`%;%`(s_new, f), func'*{func'})) +;; 7-module.watsup:10.1-10.39 +def globals : externval* -> globaladdr* + ;; 7-module.watsup:11.1-11.32 + def globals([]) = [] + ;; 7-module.watsup:12.1-12.65 + def {externval'* : externval*, ga : globaladdr} globals([GLOBAL_externval(ga)] :: externval'*{externval'}) = [ga] :: $globals(externval'*{externval'}) + ;; 7-module.watsup:13.1-14.15 + def {externval : externval, externval'* : externval*} globals([externval] :: externval'*{externval'}) = $globals(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:47.1-47.57 +;; 7-module.watsup:16.1-16.37 rec { -;; 7-module.watsup:47.1-47.57 -def alloc_global : (state, global*) -> (store, globaladdr*) - ;; 7-module.watsup:49.1-49.50 - def {f : frame, s : store} alloc_global(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:51.1-57.60 - def {f : frame, ga : globaladdr, ga'* : globaladdr*, gi : globalinst, global : global, global'* : global*, globaltype : globaltype, instr* : instr*, s : store, s_new : store, s_res : store, val : val} alloc_global(`%;%`(s, f), [global] :: global'*{global'}) = (s_res, [ga] :: ga'*{ga'}) - -- if (global = GLOBAL(globaltype, instr*{instr})) - -- Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr}), [$admininstr_val(val)]) - -- if (gi = {TYPE globaltype, VALUE val}) - -- if (ga = |$globalinst(`%;%`(s, f))|) - -- if (s_new = s[GLOBAL_store =.. [gi]]) - -- if ((s_res, ga'*{ga'}) = $alloc_global(`%;%`(s_new, f), global'*{global'})) +;; 7-module.watsup:16.1-16.37 +def tables : externval* -> tableaddr* + ;; 7-module.watsup:17.1-17.31 + def tables([]) = [] + ;; 7-module.watsup:18.1-18.62 + def {externval'* : externval*, ta : tableaddr} tables([TABLE_externval(ta)] :: externval'*{externval'}) = [ta] :: $tables(externval'*{externval'}) + ;; 7-module.watsup:19.1-20.15 + def {externval : externval, externval'* : externval*} tables([externval] :: externval'*{externval'}) = $tables(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:60.1-60.54 +;; 7-module.watsup:22.1-22.33 rec { -;; 7-module.watsup:60.1-60.54 -def alloc_table : (state, table*) -> (store, tableaddr*) - ;; 7-module.watsup:62.1-62.49 - def {f : frame, s : store} alloc_table(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:64.1-70.58 - def {f : frame, i : nat, j? : nat?, reftype : reftype, s : store, s_new : store, s_res : store, ta : tableaddr, ta'* : tableaddr*, table : table, table'* : table*, tabletype : tabletype, ti : tableinst} alloc_table(`%;%`(s, f), [table] :: table'*{table'}) = (s_res, [ta] :: ta'*{ta'}) - -- if (table = TABLE(tabletype)) - -- if (tabletype = `%%`(`[%..%?]`(i, j?{j}), reftype)) - -- if (ti = {TYPE tabletype, ELEM REF.NULL_ref(reftype)^i{}}) - -- if (ta = |$tableinst(`%;%`(s, f))|) - -- if (s_new = s[TABLE_store =.. [ti]]) - -- if ((s_res, ta'*{ta'}) = $alloc_table(`%;%`(s_new, f), table'*{table'})) +;; 7-module.watsup:22.1-22.33 +def mems : externval* -> memaddr* + ;; 7-module.watsup:23.1-23.29 + def mems([]) = [] + ;; 7-module.watsup:24.1-24.56 + def {externval'* : externval*, ma : memaddr} mems([MEM_externval(ma)] :: externval'*{externval'}) = [ma] :: $mems(externval'*{externval'}) + ;; 7-module.watsup:25.1-26.15 + def {externval : externval, externval'* : externval*} mems([externval] :: externval'*{externval'}) = $mems(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:73.1-73.48 +;; 7-module.watsup:29.1-29.83 +def instexport : (funcaddr*, globaladdr*, tableaddr*, memaddr*, export) -> exportinst + ;; 7-module.watsup:30.1-30.95 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, FUNC_externuse(x))) = {NAME name, VALUE FUNC_externval(fa*{fa}[x])} + ;; 7-module.watsup:31.1-31.99 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, GLOBAL_externuse(x))) = {NAME name, VALUE GLOBAL_externval(ga*{ga}[x])} + ;; 7-module.watsup:32.1-32.97 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, TABLE_externuse(x))) = {NAME name, VALUE TABLE_externval(ta*{ta}[x])} + ;; 7-module.watsup:33.1-33.93 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, MEM_externuse(x))) = {NAME name, VALUE MEM_externval(ma*{ma}[x])} + +;; 7-module.watsup:36.1-36.60 +def allocfunc : (store, moduleinst, func) -> (store, funcaddr) + ;; 7-module.watsup:37.1-38.37 + def {fi : funcinst, func : func, m : moduleinst, s : store} allocfunc(s, m, func) = (s[FUNC_store =.. [fi]], |s.FUNC_store|) + -- if (fi = {MODULE m, CODE func}) + +;; 7-module.watsup:40.1-40.63 rec { -;; 7-module.watsup:73.1-73.48 -def alloc_mem : (state, mem*) -> (store, memaddr*) - ;; 7-module.watsup:75.1-75.47 - def {f : frame, s : store} alloc_mem(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:77.1-83.54 - def {f : frame, i : nat, j? : nat?, ma : memaddr, ma'* : memaddr*, mem : mem, mem'* : mem*, memtype : memtype, mi : meminst, s : store, s_new : store, s_res : store} alloc_mem(`%;%`(s, f), [mem] :: mem'*{mem'}) = (s_res, [ma] :: ma'*{ma'}) - -- if (mem = MEMORY(memtype)) - -- if (memtype = `%I8`(`[%..%?]`(i, j?{j}))) - -- if (mi = {TYPE memtype, DATA 0^((i * 64) * $Ki){}}) - -- if (ma = |$meminst(`%;%`(s, f))|) - -- if (s_new = s[MEM_store =.. [mi]]) - -- if ((s_res, ma'*{ma'}) = $alloc_mem(`%;%`(s_new, f), mem'*{mem'})) +;; 7-module.watsup:40.1-40.63 +def allocfuncs : (store, moduleinst, func*) -> (store, funcaddr*) + ;; 7-module.watsup:41.1-41.46 + def {m : moduleinst, s : store} allocfuncs(s, m, []) = (s, []) + ;; 7-module.watsup:42.1-44.50 + def {fa : funcaddr, fa'* : funcaddr*, func : func, func'* : func*, m : moduleinst, s : store, s_1 : store, s_2 : store} allocfuncs(s, m, [func] :: func'*{func'}) = (s_2, [fa] :: fa'*{fa'}) + -- if ((s_1, fa) = $allocfunc(s, m, func)) + -- if ((s_2, fa'*{fa'}) = $allocfuncs(s_1, m, func'*{func'})) } -;; 7-module.watsup:86.1-86.51 +;; 7-module.watsup:46.1-46.63 +def allocglobal : (store, globaltype, val) -> (store, globaladdr) + ;; 7-module.watsup:47.1-48.44 + def {gi : globalinst, globaltype : globaltype, s : store, val : val} allocglobal(s, globaltype, val) = (s[GLOBAL_store =.. [gi]], |s.GLOBAL_store|) + -- if (gi = {TYPE globaltype, VALUE val}) + +;; 7-module.watsup:50.1-50.67 rec { -;; 7-module.watsup:86.1-86.51 -def alloc_elem : (state, elem*) -> (store, elemaddr*) - ;; 7-module.watsup:88.1-88.48 - def {f : frame, s : store} alloc_elem(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:90.1-96.56 - def {ea : elemaddr, ea'* : elemaddr*, ei : eleminst, elem : elem, elem'* : elem*, elemmode? : elemmode?, f : frame, instr** : instr**, ref* : ref*, reftype : reftype, s : store, s_new : store, s_res : store} alloc_elem(`%;%`(s, f), [elem] :: elem'*{elem'}) = (s_res, [ea] :: ea'*{ea'}) - -- if (elem = `ELEM%%*%?`(reftype, instr*{instr}*{instr}, elemmode?{elemmode})) - -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr}), [$admininstr_ref(ref)]))*{instr ref} - -- if (ei = {TYPE reftype, ELEM ref*{ref}}) - -- if (ea = |$eleminst(`%;%`(s, f))|) - -- if (s_new = s[ELEM_store =.. [ei]]) - -- if ((s_res, ea'*{ea'}) = $alloc_elem(`%;%`(s_new, f), elem'*{elem'})) +;; 7-module.watsup:50.1-50.67 +def allocglobals : (store, globaltype*, val*) -> (store, globaladdr*) + ;; 7-module.watsup:51.1-51.54 + def {s : store} allocglobals(s, [], []) = (s, []) + ;; 7-module.watsup:52.1-54.62 + def {ga : globaladdr, ga'* : globaladdr*, globaltype : globaltype, globaltype'* : globaltype*, s : store, s_1 : store, s_2 : store, val : val, val'* : val*} allocglobals(s, [globaltype] :: globaltype'*{globaltype'}, [val] :: val'*{val'}) = (s_2, [ga] :: ga'*{ga'}) + -- if ((s_1, ga) = $allocglobal(s, globaltype, val)) + -- if ((s_2, ga'*{ga'}) = $allocglobals(s_1, globaltype'*{globaltype'}, val'*{val'})) } -;; 7-module.watsup:99.1-99.51 +;; 7-module.watsup:56.1-56.55 +def alloctable : (store, tabletype) -> (store, tableaddr) + ;; 7-module.watsup:57.1-58.59 + def {i : nat, j : nat, rt : reftype, s : store, ti : tableinst} alloctable(s, `%%`(`[%..%]`(i, j), rt)) = (s[TABLE_store =.. [ti]], |s.TABLE_store|) + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM REF.NULL_ref(rt)^i{}}) + +;; 7-module.watsup:60.1-60.58 rec { -;; 7-module.watsup:99.1-99.51 -def alloc_data : (state, data*) -> (store, dataaddr*) - ;; 7-module.watsup:101.1-101.48 - def {f : frame, s : store} alloc_data(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:103.1-108.56 - def {byte* : byte*, da : dataaddr, da'* : dataaddr*, data : data, data'* : data*, datamode? : datamode?, di : datainst, f : frame, s : store, s_new : store, s_res : store} alloc_data(`%;%`(s, f), [data] :: data'*{data'}) = (s_res, [da] :: da'*{da'}) - -- if (data = `DATA%*%?`(byte*{byte}, datamode?{datamode})) - -- if (di = {DATA byte*{byte}}) - -- if (da = |$datainst(`%;%`(s, f))|) - -- if (s_new = s[DATA_store =.. [di]]) - -- if ((s_res, da'*{da'}) = $alloc_data(`%;%`(s_new, f), data'*{data'})) +;; 7-module.watsup:60.1-60.58 +def alloctables : (store, tabletype*) -> (store, tableaddr*) + ;; 7-module.watsup:61.1-61.44 + def {s : store} alloctables(s, []) = (s, []) + ;; 7-module.watsup:62.1-64.53 + def {s : store, s_1 : store, s_2 : store, ta : tableaddr, ta'* : tableaddr*, tabletype : tabletype, tabletype'* : tabletype*} alloctables(s, [tabletype] :: tabletype'*{tabletype'}) = (s_2, [ta] :: ta'*{ta'}) + -- if ((s_1, ta) = $alloctable(s, tabletype)) + -- if ((s_2, ta'*{ta'}) = $alloctables(s_1, tabletype'*{tabletype'})) } -;; 7-module.watsup:111.1-111.62 +;; 7-module.watsup:66.1-66.49 +def allocmem : (store, memtype) -> (store, memaddr) + ;; 7-module.watsup:67.1-68.62 + def {i : nat, j : nat, mi : meminst, s : store} allocmem(s, `%I8`(`[%..%]`(i, j))) = (s[MEM_store =.. [mi]], |s.MEM_store|) + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA 0^((i * 64) * $Ki){}}) + +;; 7-module.watsup:70.1-70.52 rec { -;; 7-module.watsup:111.1-111.62 -def replace_moduleinst : (store, funcaddr*, moduleinst) -> store - ;; 7-module.watsup:113.1-113.43 - def {m : moduleinst, s : store} replace_moduleinst(s, [], m) = s - ;; 7-module.watsup:115.1-117.52 - def {fa : funcaddr, fa'* : funcaddr*, m : moduleinst, s : store, s_new : store, s_res : store} replace_moduleinst(s, [fa] :: fa'*{fa'}, m) = s_res - -- if (s_new = s[FUNC_store[fa].MODULE_funcinst = m]) - -- if (s_res = $replace_moduleinst(s_new, fa'*{fa'}, m)) +;; 7-module.watsup:70.1-70.52 +def allocmems : (store, memtype*) -> (store, memaddr*) + ;; 7-module.watsup:71.1-71.42 + def {s : store} allocmems(s, []) = (s, []) + ;; 7-module.watsup:72.1-74.49 + def {ma : memaddr, ma'* : memaddr*, memtype : memtype, memtype'* : memtype*, s : store, s_1 : store, s_2 : store} allocmems(s, [memtype] :: memtype'*{memtype'}) = (s_2, [ma] :: ma'*{ma'}) + -- if ((s_1, ma) = $allocmem(s, memtype)) + -- if ((s_2, ma'*{ma'}) = $allocmems(s_1, memtype'*{memtype'})) } -;; 7-module.watsup:120.1-120.51 -def alloc_export : (moduleinst, export) -> exportinst - ;; 7-module.watsup:122.1-126.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = FUNC_externuse(x)) - -- if (externval = FUNC_externval(m.FUNC_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - ;; 7-module.watsup:128.1-132.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = GLOBAL_externuse(x)) - -- if (externval = GLOBAL_externval(m.GLOBAL_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - ;; 7-module.watsup:134.1-138.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = TABLE_externuse(x)) - -- if (externval = TABLE_externval(m.TABLE_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - ;; 7-module.watsup:140.1-144.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = MEM_externuse(x)) - -- if (externval = MEM_externval(m.MEM_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - -;; 7-module.watsup:147.1-147.67 -def alloc_module : (store, module, externval*) -> (store, moduleinst) - ;; 7-module.watsup:149.1-163.56 - def {da* : dataaddr*, data* : data*, ea* : elemaddr*, elem* : elem*, export* : export*, externval* : externval*, f : frame, fa* : funcaddr*, func* : func*, ga* : globaladdr*, global* : global*, import* : import*, m_ex : moduleinst, m_im : moduleinst, m_init : moduleinst, m_res : moduleinst, ma* : memaddr*, mem* : mem*, module : module, s : store, s_data : store, s_elem : store, s_func : store, s_global : store, s_mem : store, s_res : store, s_table : store, start? : start?, ta* : tableaddr*, table* : table*, xi* : exportinst*} alloc_module(s, module, externval*{externval}) = (s_res, m_res) - -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) - -- if (m_init = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) - -- if (m_im = $alloc_import(m_init, import*{import}, externval*{externval})) - -- if (f = {LOCAL [], MODULE m_im}) - -- if ((s_func, fa*{fa}) = $alloc_func(`%;%`(s, f), func*{func})) - -- if ((s_global, ga*{ga}) = $alloc_global(`%;%`(s_func, f), global*{global})) - -- if ((s_table, ta*{ta}) = $alloc_table(`%;%`(s_global, f), table*{table})) - -- if ((s_mem, ma*{ma}) = $alloc_mem(`%;%`(s_table, f), mem*{mem})) - -- if ((s_elem, ea*{ea}) = $alloc_elem(`%;%`(s_mem, f), elem*{elem})) - -- if ((s_data, da*{da}) = $alloc_data(`%;%`(s_elem, f), data*{data})) - -- if (m_ex = m_im ++ {FUNC fa*{fa}, GLOBAL ga*{ga}, TABLE ta*{ta}, MEM ma*{ma}, ELEM ea*{ea}, DATA da*{da}, EXPORT []}) - -- if (xi*{xi} = $alloc_export(m_ex, export)*{export}) - -- if (m_res = m_ex[EXPORT_moduleinst = xi*{xi}]) - -- if (s_res = $replace_moduleinst(s_data, fa*{fa}, m_res)) - -;; 7-module.watsup:166.1-166.41 +;; 7-module.watsup:76.1-76.57 +def allocelem : (store, reftype, ref*) -> (store, elemaddr) + ;; 7-module.watsup:77.1-78.36 + def {ei : eleminst, ref* : ref*, rt : reftype, s : store} allocelem(s, rt, ref*{ref}) = (s[ELEM_store =.. [ei]], |s.ELEM_store|) + -- if (ei = {TYPE rt, ELEM ref*{ref}}) + +;; 7-module.watsup:80.1-80.63 rec { -;; 7-module.watsup:166.1-166.41 -def run_elem : (state, elem*, idx) -> state - ;; 7-module.watsup:168.1-168.41 - def {f : frame, i : nat, s : store} run_elem(`%;%`(s, f), [], i) = `%;%`(s, f) - ;; 7-module.watsup:170.1-172.59 - def {elem : elem, elem'* : elem*, expr* : expr*, f : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) - -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?())) - -- if ($run_elem(`%;%`(s, f), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:174.1-179.67 - def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, reftype : reftype, s : store, s_new : store, s_res : store, x : idx} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) - -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) - -- if (n = |expr*{expr}|) - -- if (elemmode = TABLE_elemmode(x, instr*{instr})) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, i) ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) - -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:181.1-185.67 - def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_new : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) - -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) - -- if (elemmode = DECLARE_elemmode) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), [ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) - -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) +;; 7-module.watsup:80.1-80.63 +def allocelems : (store, reftype*, ref**) -> (store, elemaddr*) + ;; 7-module.watsup:81.1-81.52 + def {s : store} allocelems(s, [], []) = (s, []) + ;; 7-module.watsup:82.1-84.53 + def {ea : elemaddr, ea'* : elemaddr*, ref* : ref*, ref'** : ref**, rt : reftype, rt'* : reftype*, s : store, s_1 : store, s_2 : store} allocelems(s, [rt] :: rt'*{rt'}, [ref]*{ref} :: ref'*{ref'}*{ref'}) = (s_2, [ea] :: ea'*{ea'}) + -- if ((s_1, ea) = $allocelem(s, rt, ref*{ref})) + -- if ((s_2, ea'*{ea'}) = $allocelems(s_2, rt'*{rt'}, ref'*{ref'}*{ref'})) } -;; 7-module.watsup:188.1-188.41 +;; 7-module.watsup:86.1-86.49 +def allocdata : (store, byte*) -> (store, dataaddr) + ;; 7-module.watsup:87.1-88.28 + def {byte* : byte*, di : datainst, s : store} allocdata(s, byte*{byte}) = (s[DATA_store =.. [di]], |s.DATA_store|) + -- if (di = {DATA byte*{byte}}) + +;; 7-module.watsup:90.1-90.52 rec { -;; 7-module.watsup:188.1-188.41 -def run_data : (state, data*, idx) -> state - ;; 7-module.watsup:190.1-190.41 - def {f : frame, i : nat, s : store} run_data(`%;%`(s, f), [], i) = `%;%`(s, f) - ;; 7-module.watsup:192.1-194.59 - def {byte* : byte*, data : data, data'* : data*, f : frame, f_res : frame, i : nat, s : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) - -- if (data = `DATA%*%?`(byte*{byte}, ?())) - -- if ($run_data(`%;%`(s, f), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:196.1-201.67 - def {byte* : byte*, data : data, data'* : data*, datamode : datamode, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, s : store, s_new : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) - -- if (data = `DATA%*%?`(byte*{byte}, ?(datamode))) +;; 7-module.watsup:90.1-90.52 +def allocdatas : (store, byte**) -> (store, dataaddr*) + ;; 7-module.watsup:91.1-91.43 + def {s : store} allocdatas(s, []) = (s, []) + ;; 7-module.watsup:92.1-94.48 + def {byte* : byte*, byte'** : byte**, da : dataaddr, da'* : dataaddr*, s : store, s_1 : store, s_2 : store} allocdatas(s, [byte]*{byte} :: byte'*{byte'}*{byte'}) = (s_2, [da] :: da'*{da'}) + -- if ((s_1, da) = $allocdata(s, byte*{byte})) + -- if ((s_2, da'*{da'}) = $allocdatas(s_1, byte'*{byte'}*{byte'})) +} + +;; 7-module.watsup:97.1-97.81 +def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) + ;; 7-module.watsup:98.1-135.54 + def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i : nat, import* : import*, m : moduleinst, ma* : memaddr*, ma_ex* : memaddr*, memtype^n_mem : memtype^n_mem, module : module, n_data : n, n_elem : n, n_func : n, n_global : n, n_mem : n, n_table : n, ref** : ref**, rt^n_elem : reftype^n_elem, s : store, s_1 : store, s_2 : store, s_3 : store, s_4 : store, s_5 : store, s_6 : store, start? : start?, ta* : tableaddr*, ta_ex* : tableaddr*, tabletype^n_table : tabletype^n_table, val* : val*, xi* : exportinst*} allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref}) = (s_6, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func^n_func{func}, GLOBAL(globaltype, expr_1)^n_global{expr_1 globaltype}, TABLE(tabletype)^n_table{tabletype}, MEMORY(memtype)^n_mem{memtype}, `ELEM%%*%?`(rt, expr_2*{expr_2}, elemmode?{elemmode})^n_elem{elemmode expr_2 rt}, `DATA%*%?`(byte*{byte}, datamode?{datamode})^n_data{byte datamode}, start?{start}, export*{export})) + -- if (fa_ex*{fa_ex} = $funcs(externval*{externval})) + -- if (ga_ex*{ga_ex} = $globals(externval*{externval})) + -- if (ta_ex*{ta_ex} = $tables(externval*{externval})) + -- if (ma_ex*{ma_ex} = $mems(externval*{externval})) + -- if (fa*{fa} = (|s.FUNC_store| + i)^(i instr* + ;; 7-module.watsup:139.1-139.46 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?()), i) = [] + ;; 7-module.watsup:140.1-140.62 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(DECLARE_elemmode)), i) = [ELEM.DROP_instr(i)] + ;; 7-module.watsup:141.1-143.20 + def {expr* : expr*, i : nat, instr* : instr*, n : n, reftype : reftype, x : idx} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(TABLE_elemmode(x, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) TABLE.INIT_instr(x, i) ELEM.DROP_instr(i)] + -- if (n = |expr*{expr}|) + +;; 7-module.watsup:145.1-145.33 +def rundata : (data, idx) -> instr* + ;; 7-module.watsup:146.1-146.38 + def {byte* : byte*, i : nat} rundata(`DATA%*%?`(byte*{byte}, ?()), i) = [] + ;; 7-module.watsup:147.1-149.20 + def {byte* : byte*, i : nat, instr* : instr*, n : n} rundata(`DATA%*%?`(byte*{byte}, ?(MEMORY_datamode(0, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) MEMORY.INIT_instr(i) DATA.DROP_instr(i)] -- if (n = |byte*{byte}|) - -- if (datamode = MEMORY_datamode(0, instr*{instr})) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(i) DATA.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) - -- if ($run_data(`%;%`(s_new, f_new), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) + +;; 7-module.watsup:152.1-152.36 +rec { + +;; 7-module.watsup:152.1-152.36 +def concat_instr : instr** -> instr* + ;; 7-module.watsup:153.1-153.37 + def concat_instr([]) = [] + ;; 7-module.watsup:154.1-154.68 + def {instr* : instr*, instr'** : instr**} concat_instr([instr]*{instr} :: instr'*{instr'}*{instr'}) = instr*{instr} :: $concat_instr(instr'*{instr'}*{instr'}) } -;; 7-module.watsup:206.1-206.68 -def instantiation : (store, module, externval*) -> (store, moduleinst) - ;; 7-module.watsup:208.1-213.61 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) - -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(), export*{export})) - -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) - -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) - -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:215.1-222.62 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) - -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(start), export*{export})) - -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) +;; 7-module.watsup:157.1-157.55 +def instantiation : (store, module, externval*) -> config + ;; 7-module.watsup:158.1-180.28 + def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i : nat, import* : import*, instr_1** : instr**, instr_2*** : instr***, instr_data* : instr*, instr_elem* : instr*, j : nat, m : moduleinst, m_init : moduleinst, mem* : mem*, module : module, n_data : n, n_elem : n, ref** : ref**, reftype* : reftype*, s : store, s' : store, start? : start?, table* : table*, val* : val*, x? : idx?} instantiation(s, module, externval*{externval}) = `%;%*`(`%;%`(s', f), $admininstr_instr(instr_elem)*{instr_elem} :: $admininstr_instr(instr_data)*{instr_data} :: CALL_admininstr(x)?{x}) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) + -- if (m_init = {FUNC $funcs(externval*{externval}), GLOBAL $globals(externval*{externval}), TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f_init = {LOCAL [], MODULE m_init}) + -- (if (global = GLOBAL(globaltype, instr_1*{instr_1})))*{global globaltype instr_1} + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_1)*{instr_1}), [$admininstr_val(val)]))*{instr_1 val} + -- (if (elem = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})))*{elem elemmode instr_2 reftype} + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_2)*{instr_2}), [$admininstr_ref(ref)]))*{instr_2 ref}*{instr_2 ref} + -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) - -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_data, f_data)) - -- if (start = START(x)) - -- Step: `%~>%`(`%;%*`(`%;%`(s_data, f_data), [CALL_admininstr(x)]), `%;%*`(`%;%`(s_res, f_res), [])) - -;; 7-module.watsup:227.1-227.55 -def invocation : (store, funcaddr, val*) -> (store, val*) - ;; 7-module.watsup:229.1-236.55 - def {expr : expr, f : frame, f' : frame, fa : funcaddr, functype : functype, m : moduleinst, s : store, s' : store, val* : val*, val'* : val*, valtype* : valtype*, valtype'* : valtype*} invocation(s, fa, val*{val}) = (s', val'*{val'}) + -- if (n_elem = |elem*{elem}|) + -- if (instr_elem*{instr_elem} = $concat_instr($runelem(elem*{elem}[i], i)^(i config + ;; 7-module.watsup:184.1-196.52 + def {expr : expr, f : frame, fa : funcaddr, functype : functype, k : nat, m : moduleinst, n : n, s : store, val^n : val^n, valtype* : valtype*, valtype_param^n : valtype^n, valtype_res^k : valtype^k} invocation(s, fa, val^n{val}) = `%;%*`(`%;%`(s, f), $admininstr_val(val)^n{val} :: [CALL_ADDR_admininstr(fa)]) -- if (m = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) -- if (f = {LOCAL [], MODULE m}) -- if ($funcinst(`%;%`(s, f))[fa].CODE_funcinst = `FUNC%%*%`(functype, valtype*{valtype}, expr)) - -- if (functype = `%->%`(valtype*{valtype}, valtype'*{valtype'})) - -- if (|val*{val}| = |valtype*{valtype}|) - -- if (|val'*{val'}| = |valtype'*{valtype'}|) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_val(val)*{val} :: [CALL_ADDR_admininstr(fa)]), `%;%*`(`%;%`(s', f'), $admininstr_val(val')*{val'})) + -- if (functype = `%->%`(valtype_param^n{valtype_param}, valtype_res^k{valtype_res})) == IL Validation... == Running pass totalize @@ -4103,8 +4079,8 @@ def valtype_fn : fn -> valtype ;; 1-syntax.watsup:56.1-57.11 syntax resulttype = valtype* -;; 1-syntax.watsup:59.1-60.17 -syntax limits = `[%..%?]`(u32, u32?) +;; 1-syntax.watsup:59.1-60.16 +syntax limits = `[%..%]`(u32, u32) ;; 1-syntax.watsup:61.1-62.15 syntax globaltype = `MUT%?%`(()?, valtype) @@ -4398,7 +4374,7 @@ syntax context = {FUNC functype*, GLOBAL globaltype*, TABLE tabletype*, MEM memt relation Limits_ok: `|-%:%`(limits, nat) ;; 3-typing.watsup:22.1-24.24 rule _ {k : nat, n_1 : n, n_2 : n}: - `|-%:%`(`[%..%?]`(n_1, ?(n_2)), k) + `|-%:%`(`[%..%]`(n_1, n_2), k) -- if ((n_1 <= n_2) /\ (n_2 <= k)) ;; 3-typing.watsup:15.1-15.64 @@ -4470,7 +4446,7 @@ relation Resulttype_sub: `|-%*<:%*`(valtype*, valtype*) relation Limits_sub: `|-%<:%`(limits, limits) ;; 3-typing.watsup:83.1-86.21 rule _ {n_11 : n, n_12 : n, n_21 : n, n_22 : n}: - `|-%<:%`(`[%..%?]`(n_11, ?(n_12)), `[%..%?]`(n_21, ?(n_22))) + `|-%<:%`(`[%..%]`(n_11, n_12), `[%..%]`(n_21, n_22)) -- if (n_11 >= n_21) -- if (n_12 <= n_22) @@ -5072,10 +5048,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:180.1-187.5 +;; 4-runtime.watsup:183.1-190.5 rec { -;; 4-runtime.watsup:180.1-187.5 +;; 4-runtime.watsup:183.1-190.5 syntax admininstr = | UNREACHABLE | NOP @@ -5299,26 +5275,30 @@ def with_data : (state, dataidx, byte*) -> state ;; 4-runtime.watsup:165.1-165.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:167.1-167.49 -def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:169.1-172.57 - def {i : nat, i' : nat, j? : nat?, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' - -- if (ti = {TYPE `%%`(`[%..%?]`(i, j?{j}), reftype), ELEM r'*{r'}}) +;; 4-runtime.watsup:167.1-167.63 +def grow_table : (tableinst, nat, ref) -> tableinst? + ;; 4-runtime.watsup:170.1-174.36 + def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, rt : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ?(ti') + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM r'*{r'}}) -- if (i' = (|r'*{r'}| + n)) - -- if (ti' = {TYPE `%%`(`[%..%?]`(i', j?{j}), reftype), ELEM r'*{r'} :: r^n{}}) + -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), rt), ELEM r'*{r'} :: r^n{}}) + -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) + def {x : (tableinst, nat, ref)} grow_table(x) = ?() -;; 4-runtime.watsup:168.1-168.41 -def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:173.1-176.66 - def {b* : byte*, i : nat, i' : nat, j? : nat?, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' - -- if (mi = {TYPE `%I8`(`[%..%?]`(i, j?{j})), DATA b*{b}}) +;; 4-runtime.watsup:168.1-168.55 +def grow_memory : (meminst, nat) -> meminst? + ;; 4-runtime.watsup:175.1-179.34 + def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = ?(mi') + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) - -- if (mi' = {TYPE `%I8`(`[%..%?]`(i', j?{j})), DATA b*{b} :: 0^((n * 64) * $Ki){}}) + -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: 0^((n * 64) * $Ki){}}) + -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) + def {x : (meminst, nat)} grow_memory(x) = ?() -;; 4-runtime.watsup:189.1-192.21 +;; 4-runtime.watsup:192.1-195.21 rec { -;; 4-runtime.watsup:189.1-192.21 +;; 4-runtime.watsup:192.1-195.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -5547,135 +5527,135 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:214.1-216.39 + ;; 6-reduction.watsup:212.1-214.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:218.1-221.14 + ;; 6-reduction.watsup:216.1-219.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:223.1-227.15 + ;; 6-reduction.watsup:221.1-225.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:230.1-232.73 + ;; 6-reduction.watsup:228.1-230.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:234.1-237.14 + ;; 6-reduction.watsup:232.1-235.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:239.1-244.15 + ;; 6-reduction.watsup:237.1-242.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:246.1-250.15 + ;; 6-reduction.watsup:244.1-248.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:253.1-255.72 + ;; 6-reduction.watsup:251.1-253.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:257.1-260.14 + ;; 6-reduction.watsup:255.1-258.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:262.1-266.15 + ;; 6-reduction.watsup:260.1-264.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y).ELEM_eleminst[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:273.1-275.53 + ;; 6-reduction.watsup:271.1-273.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (!($size($valtype_numtype(nt))) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:277.1-279.71 + ;; 6-reduction.watsup:275.1-277.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- if ($bytes_(!($size($valtype_numtype(nt))), c) = $mem(z, 0).DATA_meminst[(i + n_O) : (!($size($valtype_numtype(nt))) / 8)]) - ;; 6-reduction.watsup:281.1-283.45 + ;; 6-reduction.watsup:279.1-281.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:285.1-287.55 + ;; 6-reduction.watsup:283.1-285.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, !($size($valtype_numtype(nt))), sx, c))]) -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:307.1-309.44 + ;; 6-reduction.watsup:305.1-307.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:322.1-324.37 + ;; 6-reduction.watsup:318.1-320.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:326.1-329.14 + ;; 6-reduction.watsup:322.1-325.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:331.1-335.15 + ;; 6-reduction.watsup:327.1-331.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:338.1-340.69 + ;; 6-reduction.watsup:334.1-336.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:342.1-345.14 + ;; 6-reduction.watsup:338.1-341.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:347.1-352.15 + ;; 6-reduction.watsup:343.1-348.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:354.1-358.15 + ;; 6-reduction.watsup:350.1-354.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:361.1-363.70 + ;; 6-reduction.watsup:357.1-359.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:365.1-368.14 + ;; 6-reduction.watsup:361.1-364.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:370.1-374.15 + ;; 6-reduction.watsup:366.1-370.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise @@ -5710,327 +5690,313 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-208.36 - rule table.grow-succeed {n : n, ref : ref, ti : tableinst, ti' : tableinst, x : idx, z : state}: - `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti'), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($table(z, x) = ti) - -- if ($grow_table(ti, n, ref) = ti') - -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) + ;; 6-reduction.watsup:204.1-206.47 + rule table.grow-succeed {n : n, ref : ref, ti : tableinst, x : idx, z : state}: + `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if (!($grow_table($table(z, x), n, ref)) = ti) - ;; 6-reduction.watsup:210.1-211.64 + ;; 6-reduction.watsup:208.1-209.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:269.1-270.59 + ;; 6-reduction.watsup:267.1-268.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:290.1-292.53 + ;; 6-reduction.watsup:288.1-290.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (!($size($valtype_numtype(nt))) / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:294.1-296.35 + ;; 6-reduction.watsup:292.1-294.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (!($size($valtype_numtype(nt))) / 8), b*{b}), [])) -- if (b*{b} = $bytes_(!($size($valtype_numtype(nt))), c)) - ;; 6-reduction.watsup:298.1-300.45 + ;; 6-reduction.watsup:296.1-298.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:302.1-304.50 + ;; 6-reduction.watsup:300.1-302.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if (b*{b} = $bytes_(n, $wrap_((!($size($valtype_numtype(nt))), n), c))) - ;; 6-reduction.watsup:312.1-316.34 - rule memory.grow-succeed {mi : meminst, mi' : meminst, n : n, z : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_meminst(z, 0, mi'), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - -- if ($mem(z, 0) = mi) - -- if ($grow_memory(mi, n) = mi') - -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) + ;; 6-reduction.watsup:310.1-312.41 + rule memory.grow-succeed {mi : meminst, n : n, z : state}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_meminst(z, 0, mi), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if (!($grow_memory($mem(z, 0), n)) = mi) - ;; 6-reduction.watsup:318.1-319.59 + ;; 6-reduction.watsup:314.1-315.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:377.1-378.59 + ;; 6-reduction.watsup:373.1-374.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) -;; 7-module.watsup:3.1-3.64 +;; 7-module.watsup:4.1-4.35 rec { -;; 7-module.watsup:3.1-3.64 -def alloc_import : (moduleinst, import*, externval*) -> moduleinst - ;; 7-module.watsup:5.1-5.43 - def {m : moduleinst} alloc_import(m, [], []) = m - ;; 7-module.watsup:7.1-12.60 - def {externtype : externtype, externval : externval, externval'* : externval*, fa : funcaddr, functype : functype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = FUNC_externtype(functype)) - -- if (externval = FUNC_externval(fa)) - -- if (m_new = m[FUNC_moduleinst =.. [fa]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) - ;; 7-module.watsup:14.1-19.60 - def {externtype : externtype, externval : externval, externval'* : externval*, ga : globaladdr, globaltype : globaltype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = GLOBAL_externtype(globaltype)) - -- if (externval = GLOBAL_externval(ga)) - -- if (m_new = m[GLOBAL_moduleinst =.. [ga]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) - ;; 7-module.watsup:21.1-26.60 - def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name, ta : tableaddr, tabletype : tabletype} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = TABLE_externtype(tabletype)) - -- if (externval = TABLE_externval(ta)) - -- if (m_new = m[TABLE_moduleinst =.. [ta]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) - ;; 7-module.watsup:28.1-33.60 - def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, ma : memaddr, memtype : memtype, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = MEM_externtype(memtype)) - -- if (externval = MEM_externval(ma)) - -- if (m_new = m[MEM_moduleinst =.. [ma]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) +;; 7-module.watsup:4.1-4.35 +def funcs : externval* -> funcaddr* + ;; 7-module.watsup:5.1-5.30 + def funcs([]) = [] + ;; 7-module.watsup:6.1-6.59 + def {externval'* : externval*, fa : funcaddr} funcs([FUNC_externval(fa)] :: externval'*{externval'}) = [fa] :: $funcs(externval'*{externval'}) + ;; 7-module.watsup:7.1-8.15 + def {externval : externval, externval'* : externval*} funcs([externval] :: externval'*{externval'}) = $funcs(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:36.1-36.51 +;; 7-module.watsup:10.1-10.39 rec { -;; 7-module.watsup:36.1-36.51 -def alloc_func : (state, func*) -> (store, funcaddr*) - ;; 7-module.watsup:38.1-38.48 - def {f : frame, s : store} alloc_func(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:40.1-44.56 - def {f : frame, fa : funcaddr, fa'* : funcaddr*, fi : funcinst, func : func, func'* : func*, s : store, s_new : store, s_res : store} alloc_func(`%;%`(s, f), [func] :: func'*{func'}) = (s_res, [fa] :: fa'*{fa'}) - -- if (fi = {MODULE f.MODULE_frame, CODE func}) - -- if (fa = |$funcinst(`%;%`(s, f))|) - -- if (s_new = s[FUNC_store =.. [fi]]) - -- if ((s_res, fa'*{fa'}) = $alloc_func(`%;%`(s_new, f), func'*{func'})) +;; 7-module.watsup:10.1-10.39 +def globals : externval* -> globaladdr* + ;; 7-module.watsup:11.1-11.32 + def globals([]) = [] + ;; 7-module.watsup:12.1-12.65 + def {externval'* : externval*, ga : globaladdr} globals([GLOBAL_externval(ga)] :: externval'*{externval'}) = [ga] :: $globals(externval'*{externval'}) + ;; 7-module.watsup:13.1-14.15 + def {externval : externval, externval'* : externval*} globals([externval] :: externval'*{externval'}) = $globals(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:47.1-47.57 +;; 7-module.watsup:16.1-16.37 rec { -;; 7-module.watsup:47.1-47.57 -def alloc_global : (state, global*) -> (store, globaladdr*) - ;; 7-module.watsup:49.1-49.50 - def {f : frame, s : store} alloc_global(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:51.1-57.60 - def {f : frame, ga : globaladdr, ga'* : globaladdr*, gi : globalinst, global : global, global'* : global*, globaltype : globaltype, instr* : instr*, s : store, s_new : store, s_res : store, val : val} alloc_global(`%;%`(s, f), [global] :: global'*{global'}) = (s_res, [ga] :: ga'*{ga'}) - -- if (global = GLOBAL(globaltype, instr*{instr})) - -- Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr}), [$admininstr_val(val)]) - -- if (gi = {TYPE globaltype, VALUE val}) - -- if (ga = |$globalinst(`%;%`(s, f))|) - -- if (s_new = s[GLOBAL_store =.. [gi]]) - -- if ((s_res, ga'*{ga'}) = $alloc_global(`%;%`(s_new, f), global'*{global'})) +;; 7-module.watsup:16.1-16.37 +def tables : externval* -> tableaddr* + ;; 7-module.watsup:17.1-17.31 + def tables([]) = [] + ;; 7-module.watsup:18.1-18.62 + def {externval'* : externval*, ta : tableaddr} tables([TABLE_externval(ta)] :: externval'*{externval'}) = [ta] :: $tables(externval'*{externval'}) + ;; 7-module.watsup:19.1-20.15 + def {externval : externval, externval'* : externval*} tables([externval] :: externval'*{externval'}) = $tables(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:60.1-60.54 +;; 7-module.watsup:22.1-22.33 rec { -;; 7-module.watsup:60.1-60.54 -def alloc_table : (state, table*) -> (store, tableaddr*) - ;; 7-module.watsup:62.1-62.49 - def {f : frame, s : store} alloc_table(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:64.1-70.58 - def {f : frame, i : nat, j? : nat?, reftype : reftype, s : store, s_new : store, s_res : store, ta : tableaddr, ta'* : tableaddr*, table : table, table'* : table*, tabletype : tabletype, ti : tableinst} alloc_table(`%;%`(s, f), [table] :: table'*{table'}) = (s_res, [ta] :: ta'*{ta'}) - -- if (table = TABLE(tabletype)) - -- if (tabletype = `%%`(`[%..%?]`(i, j?{j}), reftype)) - -- if (ti = {TYPE tabletype, ELEM REF.NULL_ref(reftype)^i{}}) - -- if (ta = |$tableinst(`%;%`(s, f))|) - -- if (s_new = s[TABLE_store =.. [ti]]) - -- if ((s_res, ta'*{ta'}) = $alloc_table(`%;%`(s_new, f), table'*{table'})) +;; 7-module.watsup:22.1-22.33 +def mems : externval* -> memaddr* + ;; 7-module.watsup:23.1-23.29 + def mems([]) = [] + ;; 7-module.watsup:24.1-24.56 + def {externval'* : externval*, ma : memaddr} mems([MEM_externval(ma)] :: externval'*{externval'}) = [ma] :: $mems(externval'*{externval'}) + ;; 7-module.watsup:25.1-26.15 + def {externval : externval, externval'* : externval*} mems([externval] :: externval'*{externval'}) = $mems(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:73.1-73.48 +;; 7-module.watsup:29.1-29.83 +def instexport : (funcaddr*, globaladdr*, tableaddr*, memaddr*, export) -> exportinst + ;; 7-module.watsup:30.1-30.95 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, FUNC_externuse(x))) = {NAME name, VALUE FUNC_externval(fa*{fa}[x])} + ;; 7-module.watsup:31.1-31.99 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, GLOBAL_externuse(x))) = {NAME name, VALUE GLOBAL_externval(ga*{ga}[x])} + ;; 7-module.watsup:32.1-32.97 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, TABLE_externuse(x))) = {NAME name, VALUE TABLE_externval(ta*{ta}[x])} + ;; 7-module.watsup:33.1-33.93 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, MEM_externuse(x))) = {NAME name, VALUE MEM_externval(ma*{ma}[x])} + +;; 7-module.watsup:36.1-36.60 +def allocfunc : (store, moduleinst, func) -> (store, funcaddr) + ;; 7-module.watsup:37.1-38.37 + def {fi : funcinst, func : func, m : moduleinst, s : store} allocfunc(s, m, func) = (s[FUNC_store =.. [fi]], |s.FUNC_store|) + -- if (fi = {MODULE m, CODE func}) + +;; 7-module.watsup:40.1-40.63 rec { -;; 7-module.watsup:73.1-73.48 -def alloc_mem : (state, mem*) -> (store, memaddr*) - ;; 7-module.watsup:75.1-75.47 - def {f : frame, s : store} alloc_mem(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:77.1-83.54 - def {f : frame, i : nat, j? : nat?, ma : memaddr, ma'* : memaddr*, mem : mem, mem'* : mem*, memtype : memtype, mi : meminst, s : store, s_new : store, s_res : store} alloc_mem(`%;%`(s, f), [mem] :: mem'*{mem'}) = (s_res, [ma] :: ma'*{ma'}) - -- if (mem = MEMORY(memtype)) - -- if (memtype = `%I8`(`[%..%?]`(i, j?{j}))) - -- if (mi = {TYPE memtype, DATA 0^((i * 64) * $Ki){}}) - -- if (ma = |$meminst(`%;%`(s, f))|) - -- if (s_new = s[MEM_store =.. [mi]]) - -- if ((s_res, ma'*{ma'}) = $alloc_mem(`%;%`(s_new, f), mem'*{mem'})) +;; 7-module.watsup:40.1-40.63 +def allocfuncs : (store, moduleinst, func*) -> (store, funcaddr*) + ;; 7-module.watsup:41.1-41.46 + def {m : moduleinst, s : store} allocfuncs(s, m, []) = (s, []) + ;; 7-module.watsup:42.1-44.50 + def {fa : funcaddr, fa'* : funcaddr*, func : func, func'* : func*, m : moduleinst, s : store, s_1 : store, s_2 : store} allocfuncs(s, m, [func] :: func'*{func'}) = (s_2, [fa] :: fa'*{fa'}) + -- if ((s_1, fa) = $allocfunc(s, m, func)) + -- if ((s_2, fa'*{fa'}) = $allocfuncs(s_1, m, func'*{func'})) } -;; 7-module.watsup:86.1-86.51 +;; 7-module.watsup:46.1-46.63 +def allocglobal : (store, globaltype, val) -> (store, globaladdr) + ;; 7-module.watsup:47.1-48.44 + def {gi : globalinst, globaltype : globaltype, s : store, val : val} allocglobal(s, globaltype, val) = (s[GLOBAL_store =.. [gi]], |s.GLOBAL_store|) + -- if (gi = {TYPE globaltype, VALUE val}) + +;; 7-module.watsup:50.1-50.67 rec { -;; 7-module.watsup:86.1-86.51 -def alloc_elem : (state, elem*) -> (store, elemaddr*) - ;; 7-module.watsup:88.1-88.48 - def {f : frame, s : store} alloc_elem(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:90.1-96.56 - def {ea : elemaddr, ea'* : elemaddr*, ei : eleminst, elem : elem, elem'* : elem*, elemmode? : elemmode?, f : frame, instr** : instr**, ref* : ref*, reftype : reftype, s : store, s_new : store, s_res : store} alloc_elem(`%;%`(s, f), [elem] :: elem'*{elem'}) = (s_res, [ea] :: ea'*{ea'}) - -- if (elem = `ELEM%%*%?`(reftype, instr*{instr}*{instr}, elemmode?{elemmode})) - -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr}), [$admininstr_ref(ref)]))*{instr ref} - -- if (ei = {TYPE reftype, ELEM ref*{ref}}) - -- if (ea = |$eleminst(`%;%`(s, f))|) - -- if (s_new = s[ELEM_store =.. [ei]]) - -- if ((s_res, ea'*{ea'}) = $alloc_elem(`%;%`(s_new, f), elem'*{elem'})) +;; 7-module.watsup:50.1-50.67 +def allocglobals : (store, globaltype*, val*) -> (store, globaladdr*) + ;; 7-module.watsup:51.1-51.54 + def {s : store} allocglobals(s, [], []) = (s, []) + ;; 7-module.watsup:52.1-54.62 + def {ga : globaladdr, ga'* : globaladdr*, globaltype : globaltype, globaltype'* : globaltype*, s : store, s_1 : store, s_2 : store, val : val, val'* : val*} allocglobals(s, [globaltype] :: globaltype'*{globaltype'}, [val] :: val'*{val'}) = (s_2, [ga] :: ga'*{ga'}) + -- if ((s_1, ga) = $allocglobal(s, globaltype, val)) + -- if ((s_2, ga'*{ga'}) = $allocglobals(s_1, globaltype'*{globaltype'}, val'*{val'})) } -;; 7-module.watsup:99.1-99.51 +;; 7-module.watsup:56.1-56.55 +def alloctable : (store, tabletype) -> (store, tableaddr) + ;; 7-module.watsup:57.1-58.59 + def {i : nat, j : nat, rt : reftype, s : store, ti : tableinst} alloctable(s, `%%`(`[%..%]`(i, j), rt)) = (s[TABLE_store =.. [ti]], |s.TABLE_store|) + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM REF.NULL_ref(rt)^i{}}) + +;; 7-module.watsup:60.1-60.58 rec { -;; 7-module.watsup:99.1-99.51 -def alloc_data : (state, data*) -> (store, dataaddr*) - ;; 7-module.watsup:101.1-101.48 - def {f : frame, s : store} alloc_data(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:103.1-108.56 - def {byte* : byte*, da : dataaddr, da'* : dataaddr*, data : data, data'* : data*, datamode? : datamode?, di : datainst, f : frame, s : store, s_new : store, s_res : store} alloc_data(`%;%`(s, f), [data] :: data'*{data'}) = (s_res, [da] :: da'*{da'}) - -- if (data = `DATA%*%?`(byte*{byte}, datamode?{datamode})) - -- if (di = {DATA byte*{byte}}) - -- if (da = |$datainst(`%;%`(s, f))|) - -- if (s_new = s[DATA_store =.. [di]]) - -- if ((s_res, da'*{da'}) = $alloc_data(`%;%`(s_new, f), data'*{data'})) +;; 7-module.watsup:60.1-60.58 +def alloctables : (store, tabletype*) -> (store, tableaddr*) + ;; 7-module.watsup:61.1-61.44 + def {s : store} alloctables(s, []) = (s, []) + ;; 7-module.watsup:62.1-64.53 + def {s : store, s_1 : store, s_2 : store, ta : tableaddr, ta'* : tableaddr*, tabletype : tabletype, tabletype'* : tabletype*} alloctables(s, [tabletype] :: tabletype'*{tabletype'}) = (s_2, [ta] :: ta'*{ta'}) + -- if ((s_1, ta) = $alloctable(s, tabletype)) + -- if ((s_2, ta'*{ta'}) = $alloctables(s_1, tabletype'*{tabletype'})) } -;; 7-module.watsup:111.1-111.62 +;; 7-module.watsup:66.1-66.49 +def allocmem : (store, memtype) -> (store, memaddr) + ;; 7-module.watsup:67.1-68.62 + def {i : nat, j : nat, mi : meminst, s : store} allocmem(s, `%I8`(`[%..%]`(i, j))) = (s[MEM_store =.. [mi]], |s.MEM_store|) + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA 0^((i * 64) * $Ki){}}) + +;; 7-module.watsup:70.1-70.52 rec { -;; 7-module.watsup:111.1-111.62 -def replace_moduleinst : (store, funcaddr*, moduleinst) -> store - ;; 7-module.watsup:113.1-113.43 - def {m : moduleinst, s : store} replace_moduleinst(s, [], m) = s - ;; 7-module.watsup:115.1-117.52 - def {fa : funcaddr, fa'* : funcaddr*, m : moduleinst, s : store, s_new : store, s_res : store} replace_moduleinst(s, [fa] :: fa'*{fa'}, m) = s_res - -- if (s_new = s[FUNC_store[fa].MODULE_funcinst = m]) - -- if (s_res = $replace_moduleinst(s_new, fa'*{fa'}, m)) +;; 7-module.watsup:70.1-70.52 +def allocmems : (store, memtype*) -> (store, memaddr*) + ;; 7-module.watsup:71.1-71.42 + def {s : store} allocmems(s, []) = (s, []) + ;; 7-module.watsup:72.1-74.49 + def {ma : memaddr, ma'* : memaddr*, memtype : memtype, memtype'* : memtype*, s : store, s_1 : store, s_2 : store} allocmems(s, [memtype] :: memtype'*{memtype'}) = (s_2, [ma] :: ma'*{ma'}) + -- if ((s_1, ma) = $allocmem(s, memtype)) + -- if ((s_2, ma'*{ma'}) = $allocmems(s_1, memtype'*{memtype'})) } -;; 7-module.watsup:120.1-120.51 -def alloc_export : (moduleinst, export) -> exportinst - ;; 7-module.watsup:122.1-126.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = FUNC_externuse(x)) - -- if (externval = FUNC_externval(m.FUNC_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - ;; 7-module.watsup:128.1-132.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = GLOBAL_externuse(x)) - -- if (externval = GLOBAL_externval(m.GLOBAL_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - ;; 7-module.watsup:134.1-138.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = TABLE_externuse(x)) - -- if (externval = TABLE_externval(m.TABLE_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - ;; 7-module.watsup:140.1-144.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = MEM_externuse(x)) - -- if (externval = MEM_externval(m.MEM_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - -;; 7-module.watsup:147.1-147.67 -def alloc_module : (store, module, externval*) -> (store, moduleinst) - ;; 7-module.watsup:149.1-163.56 - def {da* : dataaddr*, data* : data*, ea* : elemaddr*, elem* : elem*, export* : export*, externval* : externval*, f : frame, fa* : funcaddr*, func* : func*, ga* : globaladdr*, global* : global*, import* : import*, m_ex : moduleinst, m_im : moduleinst, m_init : moduleinst, m_res : moduleinst, ma* : memaddr*, mem* : mem*, module : module, s : store, s_data : store, s_elem : store, s_func : store, s_global : store, s_mem : store, s_res : store, s_table : store, start? : start?, ta* : tableaddr*, table* : table*, xi* : exportinst*} alloc_module(s, module, externval*{externval}) = (s_res, m_res) - -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) - -- if (m_init = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) - -- if (m_im = $alloc_import(m_init, import*{import}, externval*{externval})) - -- if (f = {LOCAL [], MODULE m_im}) - -- if ((s_func, fa*{fa}) = $alloc_func(`%;%`(s, f), func*{func})) - -- if ((s_global, ga*{ga}) = $alloc_global(`%;%`(s_func, f), global*{global})) - -- if ((s_table, ta*{ta}) = $alloc_table(`%;%`(s_global, f), table*{table})) - -- if ((s_mem, ma*{ma}) = $alloc_mem(`%;%`(s_table, f), mem*{mem})) - -- if ((s_elem, ea*{ea}) = $alloc_elem(`%;%`(s_mem, f), elem*{elem})) - -- if ((s_data, da*{da}) = $alloc_data(`%;%`(s_elem, f), data*{data})) - -- if (m_ex = m_im ++ {FUNC fa*{fa}, GLOBAL ga*{ga}, TABLE ta*{ta}, MEM ma*{ma}, ELEM ea*{ea}, DATA da*{da}, EXPORT []}) - -- if (xi*{xi} = $alloc_export(m_ex, export)*{export}) - -- if (m_res = m_ex[EXPORT_moduleinst = xi*{xi}]) - -- if (s_res = $replace_moduleinst(s_data, fa*{fa}, m_res)) - -;; 7-module.watsup:166.1-166.41 +;; 7-module.watsup:76.1-76.57 +def allocelem : (store, reftype, ref*) -> (store, elemaddr) + ;; 7-module.watsup:77.1-78.36 + def {ei : eleminst, ref* : ref*, rt : reftype, s : store} allocelem(s, rt, ref*{ref}) = (s[ELEM_store =.. [ei]], |s.ELEM_store|) + -- if (ei = {TYPE rt, ELEM ref*{ref}}) + +;; 7-module.watsup:80.1-80.63 rec { -;; 7-module.watsup:166.1-166.41 -def run_elem : (state, elem*, idx) -> state - ;; 7-module.watsup:168.1-168.41 - def {f : frame, i : nat, s : store} run_elem(`%;%`(s, f), [], i) = `%;%`(s, f) - ;; 7-module.watsup:170.1-172.59 - def {elem : elem, elem'* : elem*, expr* : expr*, f : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) - -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?())) - -- if ($run_elem(`%;%`(s, f), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:174.1-179.67 - def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, reftype : reftype, s : store, s_new : store, s_res : store, x : idx} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) - -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) - -- if (n = |expr*{expr}|) - -- if (elemmode = TABLE_elemmode(x, instr*{instr})) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, i) ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) - -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:181.1-185.67 - def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_new : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) - -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) - -- if (elemmode = DECLARE_elemmode) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), [ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) - -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) +;; 7-module.watsup:80.1-80.63 +def allocelems : (store, reftype*, ref**) -> (store, elemaddr*) + ;; 7-module.watsup:81.1-81.52 + def {s : store} allocelems(s, [], []) = (s, []) + ;; 7-module.watsup:82.1-84.53 + def {ea : elemaddr, ea'* : elemaddr*, ref* : ref*, ref'** : ref**, rt : reftype, rt'* : reftype*, s : store, s_1 : store, s_2 : store} allocelems(s, [rt] :: rt'*{rt'}, [ref]*{ref} :: ref'*{ref'}*{ref'}) = (s_2, [ea] :: ea'*{ea'}) + -- if ((s_1, ea) = $allocelem(s, rt, ref*{ref})) + -- if ((s_2, ea'*{ea'}) = $allocelems(s_2, rt'*{rt'}, ref'*{ref'}*{ref'})) } -;; 7-module.watsup:188.1-188.41 +;; 7-module.watsup:86.1-86.49 +def allocdata : (store, byte*) -> (store, dataaddr) + ;; 7-module.watsup:87.1-88.28 + def {byte* : byte*, di : datainst, s : store} allocdata(s, byte*{byte}) = (s[DATA_store =.. [di]], |s.DATA_store|) + -- if (di = {DATA byte*{byte}}) + +;; 7-module.watsup:90.1-90.52 rec { -;; 7-module.watsup:188.1-188.41 -def run_data : (state, data*, idx) -> state - ;; 7-module.watsup:190.1-190.41 - def {f : frame, i : nat, s : store} run_data(`%;%`(s, f), [], i) = `%;%`(s, f) - ;; 7-module.watsup:192.1-194.59 - def {byte* : byte*, data : data, data'* : data*, f : frame, f_res : frame, i : nat, s : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) - -- if (data = `DATA%*%?`(byte*{byte}, ?())) - -- if ($run_data(`%;%`(s, f), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:196.1-201.67 - def {byte* : byte*, data : data, data'* : data*, datamode : datamode, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, s : store, s_new : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) - -- if (data = `DATA%*%?`(byte*{byte}, ?(datamode))) +;; 7-module.watsup:90.1-90.52 +def allocdatas : (store, byte**) -> (store, dataaddr*) + ;; 7-module.watsup:91.1-91.43 + def {s : store} allocdatas(s, []) = (s, []) + ;; 7-module.watsup:92.1-94.48 + def {byte* : byte*, byte'** : byte**, da : dataaddr, da'* : dataaddr*, s : store, s_1 : store, s_2 : store} allocdatas(s, [byte]*{byte} :: byte'*{byte'}*{byte'}) = (s_2, [da] :: da'*{da'}) + -- if ((s_1, da) = $allocdata(s, byte*{byte})) + -- if ((s_2, da'*{da'}) = $allocdatas(s_1, byte'*{byte'}*{byte'})) +} + +;; 7-module.watsup:97.1-97.81 +def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) + ;; 7-module.watsup:98.1-135.54 + def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i : nat, import* : import*, m : moduleinst, ma* : memaddr*, ma_ex* : memaddr*, memtype^n_mem : memtype^n_mem, module : module, n_data : n, n_elem : n, n_func : n, n_global : n, n_mem : n, n_table : n, ref** : ref**, rt^n_elem : reftype^n_elem, s : store, s_1 : store, s_2 : store, s_3 : store, s_4 : store, s_5 : store, s_6 : store, start? : start?, ta* : tableaddr*, ta_ex* : tableaddr*, tabletype^n_table : tabletype^n_table, val* : val*, xi* : exportinst*} allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref}) = (s_6, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func^n_func{func}, GLOBAL(globaltype, expr_1)^n_global{expr_1 globaltype}, TABLE(tabletype)^n_table{tabletype}, MEMORY(memtype)^n_mem{memtype}, `ELEM%%*%?`(rt, expr_2*{expr_2}, elemmode?{elemmode})^n_elem{elemmode expr_2 rt}, `DATA%*%?`(byte*{byte}, datamode?{datamode})^n_data{byte datamode}, start?{start}, export*{export})) + -- if (fa_ex*{fa_ex} = $funcs(externval*{externval})) + -- if (ga_ex*{ga_ex} = $globals(externval*{externval})) + -- if (ta_ex*{ta_ex} = $tables(externval*{externval})) + -- if (ma_ex*{ma_ex} = $mems(externval*{externval})) + -- if (fa*{fa} = (|s.FUNC_store| + i)^(i instr* + ;; 7-module.watsup:139.1-139.46 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?()), i) = [] + ;; 7-module.watsup:140.1-140.62 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(DECLARE_elemmode)), i) = [ELEM.DROP_instr(i)] + ;; 7-module.watsup:141.1-143.20 + def {expr* : expr*, i : nat, instr* : instr*, n : n, reftype : reftype, x : idx} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(TABLE_elemmode(x, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) TABLE.INIT_instr(x, i) ELEM.DROP_instr(i)] + -- if (n = |expr*{expr}|) + +;; 7-module.watsup:145.1-145.33 +def rundata : (data, idx) -> instr* + ;; 7-module.watsup:146.1-146.38 + def {byte* : byte*, i : nat} rundata(`DATA%*%?`(byte*{byte}, ?()), i) = [] + ;; 7-module.watsup:147.1-149.20 + def {byte* : byte*, i : nat, instr* : instr*, n : n} rundata(`DATA%*%?`(byte*{byte}, ?(MEMORY_datamode(0, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) MEMORY.INIT_instr(i) DATA.DROP_instr(i)] -- if (n = |byte*{byte}|) - -- if (datamode = MEMORY_datamode(0, instr*{instr})) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(i) DATA.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) - -- if ($run_data(`%;%`(s_new, f_new), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) + +;; 7-module.watsup:152.1-152.36 +rec { + +;; 7-module.watsup:152.1-152.36 +def concat_instr : instr** -> instr* + ;; 7-module.watsup:153.1-153.37 + def concat_instr([]) = [] + ;; 7-module.watsup:154.1-154.68 + def {instr* : instr*, instr'** : instr**} concat_instr([instr]*{instr} :: instr'*{instr'}*{instr'}) = instr*{instr} :: $concat_instr(instr'*{instr'}*{instr'}) } -;; 7-module.watsup:206.1-206.68 -def instantiation : (store, module, externval*) -> (store, moduleinst) - ;; 7-module.watsup:208.1-213.61 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) - -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(), export*{export})) - -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) - -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) - -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:215.1-222.62 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) - -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(start), export*{export})) - -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) +;; 7-module.watsup:157.1-157.55 +def instantiation : (store, module, externval*) -> config + ;; 7-module.watsup:158.1-180.28 + def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i : nat, import* : import*, instr_1** : instr**, instr_2*** : instr***, instr_data* : instr*, instr_elem* : instr*, j : nat, m : moduleinst, m_init : moduleinst, mem* : mem*, module : module, n_data : n, n_elem : n, ref** : ref**, reftype* : reftype*, s : store, s' : store, start? : start?, table* : table*, val* : val*, x? : idx?} instantiation(s, module, externval*{externval}) = `%;%*`(`%;%`(s', f), $admininstr_instr(instr_elem)*{instr_elem} :: $admininstr_instr(instr_data)*{instr_data} :: CALL_admininstr(x)?{x}) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) + -- if (m_init = {FUNC $funcs(externval*{externval}), GLOBAL $globals(externval*{externval}), TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f_init = {LOCAL [], MODULE m_init}) + -- (if (global = GLOBAL(globaltype, instr_1*{instr_1})))*{global globaltype instr_1} + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_1)*{instr_1}), [$admininstr_val(val)]))*{instr_1 val} + -- (if (elem = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})))*{elem elemmode instr_2 reftype} + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_2)*{instr_2}), [$admininstr_ref(ref)]))*{instr_2 ref}*{instr_2 ref} + -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) - -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_data, f_data)) - -- if (start = START(x)) - -- Step: `%~>%`(`%;%*`(`%;%`(s_data, f_data), [CALL_admininstr(x)]), `%;%*`(`%;%`(s_res, f_res), [])) - -;; 7-module.watsup:227.1-227.55 -def invocation : (store, funcaddr, val*) -> (store, val*) - ;; 7-module.watsup:229.1-236.55 - def {expr : expr, f : frame, f' : frame, fa : funcaddr, functype : functype, m : moduleinst, s : store, s' : store, val* : val*, val'* : val*, valtype* : valtype*, valtype'* : valtype*} invocation(s, fa, val*{val}) = (s', val'*{val'}) + -- if (n_elem = |elem*{elem}|) + -- if (instr_elem*{instr_elem} = $concat_instr($runelem(elem*{elem}[i], i)^(i config + ;; 7-module.watsup:184.1-196.52 + def {expr : expr, f : frame, fa : funcaddr, functype : functype, k : nat, m : moduleinst, n : n, s : store, val^n : val^n, valtype* : valtype*, valtype_param^n : valtype^n, valtype_res^k : valtype^k} invocation(s, fa, val^n{val}) = `%;%*`(`%;%`(s, f), $admininstr_val(val)^n{val} :: [CALL_ADDR_admininstr(fa)]) -- if (m = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) -- if (f = {LOCAL [], MODULE m}) -- if ($funcinst(`%;%`(s, f))[fa].CODE_funcinst = `FUNC%%*%`(functype, valtype*{valtype}, expr)) - -- if (functype = `%->%`(valtype*{valtype}, valtype'*{valtype'})) - -- if (|val*{val}| = |valtype*{valtype}|) - -- if (|val'*{val'}| = |valtype'*{valtype'}|) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_val(val)*{val} :: [CALL_ADDR_admininstr(fa)]), `%;%*`(`%;%`(s', f'), $admininstr_val(val')*{val'})) + -- if (functype = `%->%`(valtype_param^n{valtype_param}, valtype_res^k{valtype_res})) == IL Validation... == Running pass the-elimination @@ -6143,8 +6109,8 @@ def valtype_fn : fn -> valtype ;; 1-syntax.watsup:56.1-57.11 syntax resulttype = valtype* -;; 1-syntax.watsup:59.1-60.17 -syntax limits = `[%..%?]`(u32, u32?) +;; 1-syntax.watsup:59.1-60.16 +syntax limits = `[%..%]`(u32, u32) ;; 1-syntax.watsup:61.1-62.15 syntax globaltype = `MUT%?%`(()?, valtype) @@ -6438,7 +6404,7 @@ syntax context = {FUNC functype*, GLOBAL globaltype*, TABLE tabletype*, MEM memt relation Limits_ok: `|-%:%`(limits, nat) ;; 3-typing.watsup:22.1-24.24 rule _ {k : nat, n_1 : n, n_2 : n}: - `|-%:%`(`[%..%?]`(n_1, ?(n_2)), k) + `|-%:%`(`[%..%]`(n_1, n_2), k) -- if ((n_1 <= n_2) /\ (n_2 <= k)) ;; 3-typing.watsup:15.1-15.64 @@ -6510,7 +6476,7 @@ relation Resulttype_sub: `|-%*<:%*`(valtype*, valtype*) relation Limits_sub: `|-%<:%`(limits, limits) ;; 3-typing.watsup:83.1-86.21 rule _ {n_11 : n, n_12 : n, n_21 : n, n_22 : n}: - `|-%<:%`(`[%..%?]`(n_11, ?(n_12)), `[%..%?]`(n_21, ?(n_22))) + `|-%<:%`(`[%..%]`(n_11, n_12), `[%..%]`(n_21, n_22)) -- if (n_11 >= n_21) -- if (n_12 <= n_22) @@ -7121,10 +7087,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:180.1-187.5 +;; 4-runtime.watsup:183.1-190.5 rec { -;; 4-runtime.watsup:180.1-187.5 +;; 4-runtime.watsup:183.1-190.5 syntax admininstr = | UNREACHABLE | NOP @@ -7348,26 +7314,30 @@ def with_data : (state, dataidx, byte*) -> state ;; 4-runtime.watsup:165.1-165.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:167.1-167.49 -def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:169.1-172.57 - def {i : nat, i' : nat, j? : nat?, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' - -- if (ti = {TYPE `%%`(`[%..%?]`(i, j?{j}), reftype), ELEM r'*{r'}}) +;; 4-runtime.watsup:167.1-167.63 +def grow_table : (tableinst, nat, ref) -> tableinst? + ;; 4-runtime.watsup:170.1-174.36 + def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, rt : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ?(ti') + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM r'*{r'}}) -- if (i' = (|r'*{r'}| + n)) - -- if (ti' = {TYPE `%%`(`[%..%?]`(i', j?{j}), reftype), ELEM r'*{r'} :: r^n{}}) + -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), rt), ELEM r'*{r'} :: r^n{}}) + -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) + def {x : (tableinst, nat, ref)} grow_table(x) = ?() -;; 4-runtime.watsup:168.1-168.41 -def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:173.1-176.66 - def {b* : byte*, i : nat, i' : nat, j? : nat?, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' - -- if (mi = {TYPE `%I8`(`[%..%?]`(i, j?{j})), DATA b*{b}}) +;; 4-runtime.watsup:168.1-168.55 +def grow_memory : (meminst, nat) -> meminst? + ;; 4-runtime.watsup:175.1-179.34 + def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = ?(mi') + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) - -- if (mi' = {TYPE `%I8`(`[%..%?]`(i', j?{j})), DATA b*{b} :: 0^((n * 64) * $Ki){}}) + -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: 0^((n * 64) * $Ki){}}) + -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) + def {x : (meminst, nat)} grow_memory(x) = ?() -;; 4-runtime.watsup:189.1-192.21 +;; 4-runtime.watsup:192.1-195.21 rec { -;; 4-runtime.watsup:189.1-192.21 +;; 4-runtime.watsup:192.1-195.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -7598,139 +7568,139 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:214.1-216.39 + ;; 6-reduction.watsup:212.1-214.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:218.1-221.14 + ;; 6-reduction.watsup:216.1-219.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:223.1-227.15 + ;; 6-reduction.watsup:221.1-225.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:230.1-232.73 + ;; 6-reduction.watsup:228.1-230.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:234.1-237.14 + ;; 6-reduction.watsup:232.1-235.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:239.1-244.15 + ;; 6-reduction.watsup:237.1-242.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:246.1-250.15 + ;; 6-reduction.watsup:244.1-248.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:253.1-255.72 + ;; 6-reduction.watsup:251.1-253.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:257.1-260.14 + ;; 6-reduction.watsup:255.1-258.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:262.1-266.15 + ;; 6-reduction.watsup:260.1-264.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y).ELEM_eleminst[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:273.1-275.53 + ;; 6-reduction.watsup:271.1-273.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:277.1-279.71 + ;; 6-reduction.watsup:275.1-277.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($size($valtype_numtype(nt)) = ?(o1)) -- if ($bytes_(o0, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (o1 / 8)]) - ;; 6-reduction.watsup:281.1-283.45 + ;; 6-reduction.watsup:279.1-281.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:285.1-287.55 + ;; 6-reduction.watsup:283.1-285.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, o0, sx, c))]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:307.1-309.44 + ;; 6-reduction.watsup:305.1-307.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:322.1-324.37 + ;; 6-reduction.watsup:318.1-320.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:326.1-329.14 + ;; 6-reduction.watsup:322.1-325.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:331.1-335.15 + ;; 6-reduction.watsup:327.1-331.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:338.1-340.69 + ;; 6-reduction.watsup:334.1-336.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:342.1-345.14 + ;; 6-reduction.watsup:338.1-341.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:347.1-352.15 + ;; 6-reduction.watsup:343.1-348.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:354.1-358.15 + ;; 6-reduction.watsup:350.1-354.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:361.1-363.70 + ;; 6-reduction.watsup:357.1-359.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:365.1-368.14 + ;; 6-reduction.watsup:361.1-364.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:370.1-374.15 + ;; 6-reduction.watsup:366.1-370.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise @@ -7765,331 +7735,319 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-208.36 - rule table.grow-succeed {n : n, ref : ref, ti : tableinst, ti' : tableinst, x : idx, z : state}: - `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti'), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($table(z, x) = ti) - -- if ($grow_table(ti, n, ref) = ti') - -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) + ;; 6-reduction.watsup:204.1-206.47 + rule table.grow-succeed {n : n, ref : ref, ti : tableinst, x : idx, z : state, o0 : tableinst}: + `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($grow_table($table(z, x), n, ref) = ?(o0)) + -- if (o0 = ti) - ;; 6-reduction.watsup:210.1-211.64 + ;; 6-reduction.watsup:208.1-209.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:269.1-270.59 + ;; 6-reduction.watsup:267.1-268.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:290.1-292.53 + ;; 6-reduction.watsup:288.1-290.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:294.1-296.35 + ;; 6-reduction.watsup:292.1-294.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (o0 / 8), b*{b}), [])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($size($valtype_numtype(nt)) = ?(o1)) -- if (b*{b} = $bytes_(o1, c)) - ;; 6-reduction.watsup:298.1-300.45 + ;; 6-reduction.watsup:296.1-298.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:302.1-304.50 + ;; 6-reduction.watsup:300.1-302.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (b*{b} = $bytes_(n, $wrap_((o0, n), c))) - ;; 6-reduction.watsup:312.1-316.34 - rule memory.grow-succeed {mi : meminst, mi' : meminst, n : n, z : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_meminst(z, 0, mi'), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - -- if ($mem(z, 0) = mi) - -- if ($grow_memory(mi, n) = mi') - -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) + ;; 6-reduction.watsup:310.1-312.41 + rule memory.grow-succeed {mi : meminst, n : n, z : state, o0 : meminst}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_meminst(z, 0, mi), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($grow_memory($mem(z, 0), n) = ?(o0)) + -- if (o0 = mi) - ;; 6-reduction.watsup:318.1-319.59 + ;; 6-reduction.watsup:314.1-315.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:377.1-378.59 + ;; 6-reduction.watsup:373.1-374.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) -;; 7-module.watsup:3.1-3.64 +;; 7-module.watsup:4.1-4.35 rec { -;; 7-module.watsup:3.1-3.64 -def alloc_import : (moduleinst, import*, externval*) -> moduleinst - ;; 7-module.watsup:5.1-5.43 - def {m : moduleinst} alloc_import(m, [], []) = m - ;; 7-module.watsup:7.1-12.60 - def {externtype : externtype, externval : externval, externval'* : externval*, fa : funcaddr, functype : functype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = FUNC_externtype(functype)) - -- if (externval = FUNC_externval(fa)) - -- if (m_new = m[FUNC_moduleinst =.. [fa]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) - ;; 7-module.watsup:14.1-19.60 - def {externtype : externtype, externval : externval, externval'* : externval*, ga : globaladdr, globaltype : globaltype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = GLOBAL_externtype(globaltype)) - -- if (externval = GLOBAL_externval(ga)) - -- if (m_new = m[GLOBAL_moduleinst =.. [ga]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) - ;; 7-module.watsup:21.1-26.60 - def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name, ta : tableaddr, tabletype : tabletype} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = TABLE_externtype(tabletype)) - -- if (externval = TABLE_externval(ta)) - -- if (m_new = m[TABLE_moduleinst =.. [ta]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) - ;; 7-module.watsup:28.1-33.60 - def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, ma : memaddr, memtype : memtype, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = MEM_externtype(memtype)) - -- if (externval = MEM_externval(ma)) - -- if (m_new = m[MEM_moduleinst =.. [ma]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) +;; 7-module.watsup:4.1-4.35 +def funcs : externval* -> funcaddr* + ;; 7-module.watsup:5.1-5.30 + def funcs([]) = [] + ;; 7-module.watsup:6.1-6.59 + def {externval'* : externval*, fa : funcaddr} funcs([FUNC_externval(fa)] :: externval'*{externval'}) = [fa] :: $funcs(externval'*{externval'}) + ;; 7-module.watsup:7.1-8.15 + def {externval : externval, externval'* : externval*} funcs([externval] :: externval'*{externval'}) = $funcs(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:36.1-36.51 +;; 7-module.watsup:10.1-10.39 rec { -;; 7-module.watsup:36.1-36.51 -def alloc_func : (state, func*) -> (store, funcaddr*) - ;; 7-module.watsup:38.1-38.48 - def {f : frame, s : store} alloc_func(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:40.1-44.56 - def {f : frame, fa : funcaddr, fa'* : funcaddr*, fi : funcinst, func : func, func'* : func*, s : store, s_new : store, s_res : store} alloc_func(`%;%`(s, f), [func] :: func'*{func'}) = (s_res, [fa] :: fa'*{fa'}) - -- if (fi = {MODULE f.MODULE_frame, CODE func}) - -- if (fa = |$funcinst(`%;%`(s, f))|) - -- if (s_new = s[FUNC_store =.. [fi]]) - -- if ((s_res, fa'*{fa'}) = $alloc_func(`%;%`(s_new, f), func'*{func'})) +;; 7-module.watsup:10.1-10.39 +def globals : externval* -> globaladdr* + ;; 7-module.watsup:11.1-11.32 + def globals([]) = [] + ;; 7-module.watsup:12.1-12.65 + def {externval'* : externval*, ga : globaladdr} globals([GLOBAL_externval(ga)] :: externval'*{externval'}) = [ga] :: $globals(externval'*{externval'}) + ;; 7-module.watsup:13.1-14.15 + def {externval : externval, externval'* : externval*} globals([externval] :: externval'*{externval'}) = $globals(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:47.1-47.57 +;; 7-module.watsup:16.1-16.37 rec { -;; 7-module.watsup:47.1-47.57 -def alloc_global : (state, global*) -> (store, globaladdr*) - ;; 7-module.watsup:49.1-49.50 - def {f : frame, s : store} alloc_global(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:51.1-57.60 - def {f : frame, ga : globaladdr, ga'* : globaladdr*, gi : globalinst, global : global, global'* : global*, globaltype : globaltype, instr* : instr*, s : store, s_new : store, s_res : store, val : val} alloc_global(`%;%`(s, f), [global] :: global'*{global'}) = (s_res, [ga] :: ga'*{ga'}) - -- if (global = GLOBAL(globaltype, instr*{instr})) - -- Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr}), [$admininstr_val(val)]) - -- if (gi = {TYPE globaltype, VALUE val}) - -- if (ga = |$globalinst(`%;%`(s, f))|) - -- if (s_new = s[GLOBAL_store =.. [gi]]) - -- if ((s_res, ga'*{ga'}) = $alloc_global(`%;%`(s_new, f), global'*{global'})) +;; 7-module.watsup:16.1-16.37 +def tables : externval* -> tableaddr* + ;; 7-module.watsup:17.1-17.31 + def tables([]) = [] + ;; 7-module.watsup:18.1-18.62 + def {externval'* : externval*, ta : tableaddr} tables([TABLE_externval(ta)] :: externval'*{externval'}) = [ta] :: $tables(externval'*{externval'}) + ;; 7-module.watsup:19.1-20.15 + def {externval : externval, externval'* : externval*} tables([externval] :: externval'*{externval'}) = $tables(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:60.1-60.54 +;; 7-module.watsup:22.1-22.33 rec { -;; 7-module.watsup:60.1-60.54 -def alloc_table : (state, table*) -> (store, tableaddr*) - ;; 7-module.watsup:62.1-62.49 - def {f : frame, s : store} alloc_table(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:64.1-70.58 - def {f : frame, i : nat, j? : nat?, reftype : reftype, s : store, s_new : store, s_res : store, ta : tableaddr, ta'* : tableaddr*, table : table, table'* : table*, tabletype : tabletype, ti : tableinst} alloc_table(`%;%`(s, f), [table] :: table'*{table'}) = (s_res, [ta] :: ta'*{ta'}) - -- if (table = TABLE(tabletype)) - -- if (tabletype = `%%`(`[%..%?]`(i, j?{j}), reftype)) - -- if (ti = {TYPE tabletype, ELEM REF.NULL_ref(reftype)^i{}}) - -- if (ta = |$tableinst(`%;%`(s, f))|) - -- if (s_new = s[TABLE_store =.. [ti]]) - -- if ((s_res, ta'*{ta'}) = $alloc_table(`%;%`(s_new, f), table'*{table'})) +;; 7-module.watsup:22.1-22.33 +def mems : externval* -> memaddr* + ;; 7-module.watsup:23.1-23.29 + def mems([]) = [] + ;; 7-module.watsup:24.1-24.56 + def {externval'* : externval*, ma : memaddr} mems([MEM_externval(ma)] :: externval'*{externval'}) = [ma] :: $mems(externval'*{externval'}) + ;; 7-module.watsup:25.1-26.15 + def {externval : externval, externval'* : externval*} mems([externval] :: externval'*{externval'}) = $mems(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:73.1-73.48 +;; 7-module.watsup:29.1-29.83 +def instexport : (funcaddr*, globaladdr*, tableaddr*, memaddr*, export) -> exportinst + ;; 7-module.watsup:30.1-30.95 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, FUNC_externuse(x))) = {NAME name, VALUE FUNC_externval(fa*{fa}[x])} + ;; 7-module.watsup:31.1-31.99 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, GLOBAL_externuse(x))) = {NAME name, VALUE GLOBAL_externval(ga*{ga}[x])} + ;; 7-module.watsup:32.1-32.97 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, TABLE_externuse(x))) = {NAME name, VALUE TABLE_externval(ta*{ta}[x])} + ;; 7-module.watsup:33.1-33.93 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, MEM_externuse(x))) = {NAME name, VALUE MEM_externval(ma*{ma}[x])} + +;; 7-module.watsup:36.1-36.60 +def allocfunc : (store, moduleinst, func) -> (store, funcaddr) + ;; 7-module.watsup:37.1-38.37 + def {fi : funcinst, func : func, m : moduleinst, s : store} allocfunc(s, m, func) = (s[FUNC_store =.. [fi]], |s.FUNC_store|) + -- if (fi = {MODULE m, CODE func}) + +;; 7-module.watsup:40.1-40.63 rec { -;; 7-module.watsup:73.1-73.48 -def alloc_mem : (state, mem*) -> (store, memaddr*) - ;; 7-module.watsup:75.1-75.47 - def {f : frame, s : store} alloc_mem(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:77.1-83.54 - def {f : frame, i : nat, j? : nat?, ma : memaddr, ma'* : memaddr*, mem : mem, mem'* : mem*, memtype : memtype, mi : meminst, s : store, s_new : store, s_res : store} alloc_mem(`%;%`(s, f), [mem] :: mem'*{mem'}) = (s_res, [ma] :: ma'*{ma'}) - -- if (mem = MEMORY(memtype)) - -- if (memtype = `%I8`(`[%..%?]`(i, j?{j}))) - -- if (mi = {TYPE memtype, DATA 0^((i * 64) * $Ki){}}) - -- if (ma = |$meminst(`%;%`(s, f))|) - -- if (s_new = s[MEM_store =.. [mi]]) - -- if ((s_res, ma'*{ma'}) = $alloc_mem(`%;%`(s_new, f), mem'*{mem'})) +;; 7-module.watsup:40.1-40.63 +def allocfuncs : (store, moduleinst, func*) -> (store, funcaddr*) + ;; 7-module.watsup:41.1-41.46 + def {m : moduleinst, s : store} allocfuncs(s, m, []) = (s, []) + ;; 7-module.watsup:42.1-44.50 + def {fa : funcaddr, fa'* : funcaddr*, func : func, func'* : func*, m : moduleinst, s : store, s_1 : store, s_2 : store} allocfuncs(s, m, [func] :: func'*{func'}) = (s_2, [fa] :: fa'*{fa'}) + -- if ((s_1, fa) = $allocfunc(s, m, func)) + -- if ((s_2, fa'*{fa'}) = $allocfuncs(s_1, m, func'*{func'})) } -;; 7-module.watsup:86.1-86.51 +;; 7-module.watsup:46.1-46.63 +def allocglobal : (store, globaltype, val) -> (store, globaladdr) + ;; 7-module.watsup:47.1-48.44 + def {gi : globalinst, globaltype : globaltype, s : store, val : val} allocglobal(s, globaltype, val) = (s[GLOBAL_store =.. [gi]], |s.GLOBAL_store|) + -- if (gi = {TYPE globaltype, VALUE val}) + +;; 7-module.watsup:50.1-50.67 rec { -;; 7-module.watsup:86.1-86.51 -def alloc_elem : (state, elem*) -> (store, elemaddr*) - ;; 7-module.watsup:88.1-88.48 - def {f : frame, s : store} alloc_elem(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:90.1-96.56 - def {ea : elemaddr, ea'* : elemaddr*, ei : eleminst, elem : elem, elem'* : elem*, elemmode? : elemmode?, f : frame, instr** : instr**, ref* : ref*, reftype : reftype, s : store, s_new : store, s_res : store} alloc_elem(`%;%`(s, f), [elem] :: elem'*{elem'}) = (s_res, [ea] :: ea'*{ea'}) - -- if (elem = `ELEM%%*%?`(reftype, instr*{instr}*{instr}, elemmode?{elemmode})) - -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr}), [$admininstr_ref(ref)]))*{instr ref} - -- if (ei = {TYPE reftype, ELEM ref*{ref}}) - -- if (ea = |$eleminst(`%;%`(s, f))|) - -- if (s_new = s[ELEM_store =.. [ei]]) - -- if ((s_res, ea'*{ea'}) = $alloc_elem(`%;%`(s_new, f), elem'*{elem'})) +;; 7-module.watsup:50.1-50.67 +def allocglobals : (store, globaltype*, val*) -> (store, globaladdr*) + ;; 7-module.watsup:51.1-51.54 + def {s : store} allocglobals(s, [], []) = (s, []) + ;; 7-module.watsup:52.1-54.62 + def {ga : globaladdr, ga'* : globaladdr*, globaltype : globaltype, globaltype'* : globaltype*, s : store, s_1 : store, s_2 : store, val : val, val'* : val*} allocglobals(s, [globaltype] :: globaltype'*{globaltype'}, [val] :: val'*{val'}) = (s_2, [ga] :: ga'*{ga'}) + -- if ((s_1, ga) = $allocglobal(s, globaltype, val)) + -- if ((s_2, ga'*{ga'}) = $allocglobals(s_1, globaltype'*{globaltype'}, val'*{val'})) } -;; 7-module.watsup:99.1-99.51 +;; 7-module.watsup:56.1-56.55 +def alloctable : (store, tabletype) -> (store, tableaddr) + ;; 7-module.watsup:57.1-58.59 + def {i : nat, j : nat, rt : reftype, s : store, ti : tableinst} alloctable(s, `%%`(`[%..%]`(i, j), rt)) = (s[TABLE_store =.. [ti]], |s.TABLE_store|) + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM REF.NULL_ref(rt)^i{}}) + +;; 7-module.watsup:60.1-60.58 rec { -;; 7-module.watsup:99.1-99.51 -def alloc_data : (state, data*) -> (store, dataaddr*) - ;; 7-module.watsup:101.1-101.48 - def {f : frame, s : store} alloc_data(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:103.1-108.56 - def {byte* : byte*, da : dataaddr, da'* : dataaddr*, data : data, data'* : data*, datamode? : datamode?, di : datainst, f : frame, s : store, s_new : store, s_res : store} alloc_data(`%;%`(s, f), [data] :: data'*{data'}) = (s_res, [da] :: da'*{da'}) - -- if (data = `DATA%*%?`(byte*{byte}, datamode?{datamode})) - -- if (di = {DATA byte*{byte}}) - -- if (da = |$datainst(`%;%`(s, f))|) - -- if (s_new = s[DATA_store =.. [di]]) - -- if ((s_res, da'*{da'}) = $alloc_data(`%;%`(s_new, f), data'*{data'})) +;; 7-module.watsup:60.1-60.58 +def alloctables : (store, tabletype*) -> (store, tableaddr*) + ;; 7-module.watsup:61.1-61.44 + def {s : store} alloctables(s, []) = (s, []) + ;; 7-module.watsup:62.1-64.53 + def {s : store, s_1 : store, s_2 : store, ta : tableaddr, ta'* : tableaddr*, tabletype : tabletype, tabletype'* : tabletype*} alloctables(s, [tabletype] :: tabletype'*{tabletype'}) = (s_2, [ta] :: ta'*{ta'}) + -- if ((s_1, ta) = $alloctable(s, tabletype)) + -- if ((s_2, ta'*{ta'}) = $alloctables(s_1, tabletype'*{tabletype'})) } -;; 7-module.watsup:111.1-111.62 +;; 7-module.watsup:66.1-66.49 +def allocmem : (store, memtype) -> (store, memaddr) + ;; 7-module.watsup:67.1-68.62 + def {i : nat, j : nat, mi : meminst, s : store} allocmem(s, `%I8`(`[%..%]`(i, j))) = (s[MEM_store =.. [mi]], |s.MEM_store|) + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA 0^((i * 64) * $Ki){}}) + +;; 7-module.watsup:70.1-70.52 rec { -;; 7-module.watsup:111.1-111.62 -def replace_moduleinst : (store, funcaddr*, moduleinst) -> store - ;; 7-module.watsup:113.1-113.43 - def {m : moduleinst, s : store} replace_moduleinst(s, [], m) = s - ;; 7-module.watsup:115.1-117.52 - def {fa : funcaddr, fa'* : funcaddr*, m : moduleinst, s : store, s_new : store, s_res : store} replace_moduleinst(s, [fa] :: fa'*{fa'}, m) = s_res - -- if (s_new = s[FUNC_store[fa].MODULE_funcinst = m]) - -- if (s_res = $replace_moduleinst(s_new, fa'*{fa'}, m)) +;; 7-module.watsup:70.1-70.52 +def allocmems : (store, memtype*) -> (store, memaddr*) + ;; 7-module.watsup:71.1-71.42 + def {s : store} allocmems(s, []) = (s, []) + ;; 7-module.watsup:72.1-74.49 + def {ma : memaddr, ma'* : memaddr*, memtype : memtype, memtype'* : memtype*, s : store, s_1 : store, s_2 : store} allocmems(s, [memtype] :: memtype'*{memtype'}) = (s_2, [ma] :: ma'*{ma'}) + -- if ((s_1, ma) = $allocmem(s, memtype)) + -- if ((s_2, ma'*{ma'}) = $allocmems(s_1, memtype'*{memtype'})) } -;; 7-module.watsup:120.1-120.51 -def alloc_export : (moduleinst, export) -> exportinst - ;; 7-module.watsup:122.1-126.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = FUNC_externuse(x)) - -- if (externval = FUNC_externval(m.FUNC_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - ;; 7-module.watsup:128.1-132.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = GLOBAL_externuse(x)) - -- if (externval = GLOBAL_externval(m.GLOBAL_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - ;; 7-module.watsup:134.1-138.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = TABLE_externuse(x)) - -- if (externval = TABLE_externval(m.TABLE_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - ;; 7-module.watsup:140.1-144.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = MEM_externuse(x)) - -- if (externval = MEM_externval(m.MEM_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - -;; 7-module.watsup:147.1-147.67 -def alloc_module : (store, module, externval*) -> (store, moduleinst) - ;; 7-module.watsup:149.1-163.56 - def {da* : dataaddr*, data* : data*, ea* : elemaddr*, elem* : elem*, export* : export*, externval* : externval*, f : frame, fa* : funcaddr*, func* : func*, ga* : globaladdr*, global* : global*, import* : import*, m_ex : moduleinst, m_im : moduleinst, m_init : moduleinst, m_res : moduleinst, ma* : memaddr*, mem* : mem*, module : module, s : store, s_data : store, s_elem : store, s_func : store, s_global : store, s_mem : store, s_res : store, s_table : store, start? : start?, ta* : tableaddr*, table* : table*, xi* : exportinst*} alloc_module(s, module, externval*{externval}) = (s_res, m_res) - -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) - -- if (m_init = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) - -- if (m_im = $alloc_import(m_init, import*{import}, externval*{externval})) - -- if (f = {LOCAL [], MODULE m_im}) - -- if ((s_func, fa*{fa}) = $alloc_func(`%;%`(s, f), func*{func})) - -- if ((s_global, ga*{ga}) = $alloc_global(`%;%`(s_func, f), global*{global})) - -- if ((s_table, ta*{ta}) = $alloc_table(`%;%`(s_global, f), table*{table})) - -- if ((s_mem, ma*{ma}) = $alloc_mem(`%;%`(s_table, f), mem*{mem})) - -- if ((s_elem, ea*{ea}) = $alloc_elem(`%;%`(s_mem, f), elem*{elem})) - -- if ((s_data, da*{da}) = $alloc_data(`%;%`(s_elem, f), data*{data})) - -- if (m_ex = m_im ++ {FUNC fa*{fa}, GLOBAL ga*{ga}, TABLE ta*{ta}, MEM ma*{ma}, ELEM ea*{ea}, DATA da*{da}, EXPORT []}) - -- if (xi*{xi} = $alloc_export(m_ex, export)*{export}) - -- if (m_res = m_ex[EXPORT_moduleinst = xi*{xi}]) - -- if (s_res = $replace_moduleinst(s_data, fa*{fa}, m_res)) - -;; 7-module.watsup:166.1-166.41 +;; 7-module.watsup:76.1-76.57 +def allocelem : (store, reftype, ref*) -> (store, elemaddr) + ;; 7-module.watsup:77.1-78.36 + def {ei : eleminst, ref* : ref*, rt : reftype, s : store} allocelem(s, rt, ref*{ref}) = (s[ELEM_store =.. [ei]], |s.ELEM_store|) + -- if (ei = {TYPE rt, ELEM ref*{ref}}) + +;; 7-module.watsup:80.1-80.63 rec { -;; 7-module.watsup:166.1-166.41 -def run_elem : (state, elem*, idx) -> state - ;; 7-module.watsup:168.1-168.41 - def {f : frame, i : nat, s : store} run_elem(`%;%`(s, f), [], i) = `%;%`(s, f) - ;; 7-module.watsup:170.1-172.59 - def {elem : elem, elem'* : elem*, expr* : expr*, f : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) - -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?())) - -- if ($run_elem(`%;%`(s, f), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:174.1-179.67 - def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, reftype : reftype, s : store, s_new : store, s_res : store, x : idx} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) - -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) - -- if (n = |expr*{expr}|) - -- if (elemmode = TABLE_elemmode(x, instr*{instr})) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, i) ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) - -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:181.1-185.67 - def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_new : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) - -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) - -- if (elemmode = DECLARE_elemmode) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), [ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) - -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) +;; 7-module.watsup:80.1-80.63 +def allocelems : (store, reftype*, ref**) -> (store, elemaddr*) + ;; 7-module.watsup:81.1-81.52 + def {s : store} allocelems(s, [], []) = (s, []) + ;; 7-module.watsup:82.1-84.53 + def {ea : elemaddr, ea'* : elemaddr*, ref* : ref*, ref'** : ref**, rt : reftype, rt'* : reftype*, s : store, s_1 : store, s_2 : store} allocelems(s, [rt] :: rt'*{rt'}, [ref]*{ref} :: ref'*{ref'}*{ref'}) = (s_2, [ea] :: ea'*{ea'}) + -- if ((s_1, ea) = $allocelem(s, rt, ref*{ref})) + -- if ((s_2, ea'*{ea'}) = $allocelems(s_2, rt'*{rt'}, ref'*{ref'}*{ref'})) } -;; 7-module.watsup:188.1-188.41 +;; 7-module.watsup:86.1-86.49 +def allocdata : (store, byte*) -> (store, dataaddr) + ;; 7-module.watsup:87.1-88.28 + def {byte* : byte*, di : datainst, s : store} allocdata(s, byte*{byte}) = (s[DATA_store =.. [di]], |s.DATA_store|) + -- if (di = {DATA byte*{byte}}) + +;; 7-module.watsup:90.1-90.52 rec { -;; 7-module.watsup:188.1-188.41 -def run_data : (state, data*, idx) -> state - ;; 7-module.watsup:190.1-190.41 - def {f : frame, i : nat, s : store} run_data(`%;%`(s, f), [], i) = `%;%`(s, f) - ;; 7-module.watsup:192.1-194.59 - def {byte* : byte*, data : data, data'* : data*, f : frame, f_res : frame, i : nat, s : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) - -- if (data = `DATA%*%?`(byte*{byte}, ?())) - -- if ($run_data(`%;%`(s, f), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:196.1-201.67 - def {byte* : byte*, data : data, data'* : data*, datamode : datamode, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, s : store, s_new : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) - -- if (data = `DATA%*%?`(byte*{byte}, ?(datamode))) +;; 7-module.watsup:90.1-90.52 +def allocdatas : (store, byte**) -> (store, dataaddr*) + ;; 7-module.watsup:91.1-91.43 + def {s : store} allocdatas(s, []) = (s, []) + ;; 7-module.watsup:92.1-94.48 + def {byte* : byte*, byte'** : byte**, da : dataaddr, da'* : dataaddr*, s : store, s_1 : store, s_2 : store} allocdatas(s, [byte]*{byte} :: byte'*{byte'}*{byte'}) = (s_2, [da] :: da'*{da'}) + -- if ((s_1, da) = $allocdata(s, byte*{byte})) + -- if ((s_2, da'*{da'}) = $allocdatas(s_1, byte'*{byte'}*{byte'})) +} + +;; 7-module.watsup:97.1-97.81 +def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) + ;; 7-module.watsup:98.1-135.54 + def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i : nat, import* : import*, m : moduleinst, ma* : memaddr*, ma_ex* : memaddr*, memtype^n_mem : memtype^n_mem, module : module, n_data : n, n_elem : n, n_func : n, n_global : n, n_mem : n, n_table : n, ref** : ref**, rt^n_elem : reftype^n_elem, s : store, s_1 : store, s_2 : store, s_3 : store, s_4 : store, s_5 : store, s_6 : store, start? : start?, ta* : tableaddr*, ta_ex* : tableaddr*, tabletype^n_table : tabletype^n_table, val* : val*, xi* : exportinst*} allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref}) = (s_6, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func^n_func{func}, GLOBAL(globaltype, expr_1)^n_global{expr_1 globaltype}, TABLE(tabletype)^n_table{tabletype}, MEMORY(memtype)^n_mem{memtype}, `ELEM%%*%?`(rt, expr_2*{expr_2}, elemmode?{elemmode})^n_elem{elemmode expr_2 rt}, `DATA%*%?`(byte*{byte}, datamode?{datamode})^n_data{byte datamode}, start?{start}, export*{export})) + -- if (fa_ex*{fa_ex} = $funcs(externval*{externval})) + -- if (ga_ex*{ga_ex} = $globals(externval*{externval})) + -- if (ta_ex*{ta_ex} = $tables(externval*{externval})) + -- if (ma_ex*{ma_ex} = $mems(externval*{externval})) + -- if (fa*{fa} = (|s.FUNC_store| + i)^(i instr* + ;; 7-module.watsup:139.1-139.46 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?()), i) = [] + ;; 7-module.watsup:140.1-140.62 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(DECLARE_elemmode)), i) = [ELEM.DROP_instr(i)] + ;; 7-module.watsup:141.1-143.20 + def {expr* : expr*, i : nat, instr* : instr*, n : n, reftype : reftype, x : idx} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(TABLE_elemmode(x, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) TABLE.INIT_instr(x, i) ELEM.DROP_instr(i)] + -- if (n = |expr*{expr}|) + +;; 7-module.watsup:145.1-145.33 +def rundata : (data, idx) -> instr* + ;; 7-module.watsup:146.1-146.38 + def {byte* : byte*, i : nat} rundata(`DATA%*%?`(byte*{byte}, ?()), i) = [] + ;; 7-module.watsup:147.1-149.20 + def {byte* : byte*, i : nat, instr* : instr*, n : n} rundata(`DATA%*%?`(byte*{byte}, ?(MEMORY_datamode(0, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) MEMORY.INIT_instr(i) DATA.DROP_instr(i)] -- if (n = |byte*{byte}|) - -- if (datamode = MEMORY_datamode(0, instr*{instr})) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(i) DATA.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) - -- if ($run_data(`%;%`(s_new, f_new), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) + +;; 7-module.watsup:152.1-152.36 +rec { + +;; 7-module.watsup:152.1-152.36 +def concat_instr : instr** -> instr* + ;; 7-module.watsup:153.1-153.37 + def concat_instr([]) = [] + ;; 7-module.watsup:154.1-154.68 + def {instr* : instr*, instr'** : instr**} concat_instr([instr]*{instr} :: instr'*{instr'}*{instr'}) = instr*{instr} :: $concat_instr(instr'*{instr'}*{instr'}) } -;; 7-module.watsup:206.1-206.68 -def instantiation : (store, module, externval*) -> (store, moduleinst) - ;; 7-module.watsup:208.1-213.61 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) - -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(), export*{export})) - -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) - -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) - -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:215.1-222.62 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) - -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(start), export*{export})) - -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) +;; 7-module.watsup:157.1-157.55 +def instantiation : (store, module, externval*) -> config + ;; 7-module.watsup:158.1-180.28 + def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i : nat, import* : import*, instr_1** : instr**, instr_2*** : instr***, instr_data* : instr*, instr_elem* : instr*, j : nat, m : moduleinst, m_init : moduleinst, mem* : mem*, module : module, n_data : n, n_elem : n, ref** : ref**, reftype* : reftype*, s : store, s' : store, start? : start?, table* : table*, val* : val*, x? : idx?} instantiation(s, module, externval*{externval}) = `%;%*`(`%;%`(s', f), $admininstr_instr(instr_elem)*{instr_elem} :: $admininstr_instr(instr_data)*{instr_data} :: CALL_admininstr(x)?{x}) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) + -- if (m_init = {FUNC $funcs(externval*{externval}), GLOBAL $globals(externval*{externval}), TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f_init = {LOCAL [], MODULE m_init}) + -- (if (global = GLOBAL(globaltype, instr_1*{instr_1})))*{global globaltype instr_1} + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_1)*{instr_1}), [$admininstr_val(val)]))*{instr_1 val} + -- (if (elem = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})))*{elem elemmode instr_2 reftype} + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_2)*{instr_2}), [$admininstr_ref(ref)]))*{instr_2 ref}*{instr_2 ref} + -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) - -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_data, f_data)) - -- if (start = START(x)) - -- Step: `%~>%`(`%;%*`(`%;%`(s_data, f_data), [CALL_admininstr(x)]), `%;%*`(`%;%`(s_res, f_res), [])) - -;; 7-module.watsup:227.1-227.55 -def invocation : (store, funcaddr, val*) -> (store, val*) - ;; 7-module.watsup:229.1-236.55 - def {expr : expr, f : frame, f' : frame, fa : funcaddr, functype : functype, m : moduleinst, s : store, s' : store, val* : val*, val'* : val*, valtype* : valtype*, valtype'* : valtype*} invocation(s, fa, val*{val}) = (s', val'*{val'}) + -- if (n_elem = |elem*{elem}|) + -- if (instr_elem*{instr_elem} = $concat_instr($runelem(elem*{elem}[i], i)^(i config + ;; 7-module.watsup:184.1-196.52 + def {expr : expr, f : frame, fa : funcaddr, functype : functype, k : nat, m : moduleinst, n : n, s : store, val^n : val^n, valtype* : valtype*, valtype_param^n : valtype^n, valtype_res^k : valtype^k} invocation(s, fa, val^n{val}) = `%;%*`(`%;%`(s, f), $admininstr_val(val)^n{val} :: [CALL_ADDR_admininstr(fa)]) -- if (m = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) -- if (f = {LOCAL [], MODULE m}) -- if ($funcinst(`%;%`(s, f))[fa].CODE_funcinst = `FUNC%%*%`(functype, valtype*{valtype}, expr)) - -- if (functype = `%->%`(valtype*{valtype}, valtype'*{valtype'})) - -- if (|val*{val}| = |valtype*{valtype}|) - -- if (|val'*{val'}| = |valtype'*{valtype'}|) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_val(val)*{val} :: [CALL_ADDR_admininstr(fa)]), `%;%*`(`%;%`(s', f'), $admininstr_val(val')*{val'})) + -- if (functype = `%->%`(valtype_param^n{valtype_param}, valtype_res^k{valtype_res})) == IL Validation... == Running pass wildcards @@ -8202,8 +8160,8 @@ def valtype_fn : fn -> valtype ;; 1-syntax.watsup:56.1-57.11 syntax resulttype = valtype* -;; 1-syntax.watsup:59.1-60.17 -syntax limits = `[%..%?]`(u32, u32?) +;; 1-syntax.watsup:59.1-60.16 +syntax limits = `[%..%]`(u32, u32) ;; 1-syntax.watsup:61.1-62.15 syntax globaltype = `MUT%?%`(()?, valtype) @@ -8497,7 +8455,7 @@ syntax context = {FUNC functype*, GLOBAL globaltype*, TABLE tabletype*, MEM memt relation Limits_ok: `|-%:%`(limits, nat) ;; 3-typing.watsup:22.1-24.24 rule _ {k : nat, n_1 : n, n_2 : n}: - `|-%:%`(`[%..%?]`(n_1, ?(n_2)), k) + `|-%:%`(`[%..%]`(n_1, n_2), k) -- if ((n_1 <= n_2) /\ (n_2 <= k)) ;; 3-typing.watsup:15.1-15.64 @@ -8569,7 +8527,7 @@ relation Resulttype_sub: `|-%*<:%*`(valtype*, valtype*) relation Limits_sub: `|-%<:%`(limits, limits) ;; 3-typing.watsup:83.1-86.21 rule _ {n_11 : n, n_12 : n, n_21 : n, n_22 : n}: - `|-%<:%`(`[%..%?]`(n_11, ?(n_12)), `[%..%?]`(n_21, ?(n_22))) + `|-%<:%`(`[%..%]`(n_11, n_12), `[%..%]`(n_21, n_22)) -- if (n_11 >= n_21) -- if (n_12 <= n_22) @@ -9180,10 +9138,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:180.1-187.5 +;; 4-runtime.watsup:183.1-190.5 rec { -;; 4-runtime.watsup:180.1-187.5 +;; 4-runtime.watsup:183.1-190.5 syntax admininstr = | UNREACHABLE | NOP @@ -9407,26 +9365,30 @@ def with_data : (state, dataidx, byte*) -> state ;; 4-runtime.watsup:165.1-165.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:167.1-167.49 -def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:169.1-172.57 - def {i : nat, i' : nat, j? : nat?, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' - -- if (ti = {TYPE `%%`(`[%..%?]`(i, j?{j}), reftype), ELEM r'*{r'}}) +;; 4-runtime.watsup:167.1-167.63 +def grow_table : (tableinst, nat, ref) -> tableinst? + ;; 4-runtime.watsup:170.1-174.36 + def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, rt : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ?(ti') + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM r'*{r'}}) -- if (i' = (|r'*{r'}| + n)) - -- if (ti' = {TYPE `%%`(`[%..%?]`(i', j?{j}), reftype), ELEM r'*{r'} :: r^n{}}) + -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), rt), ELEM r'*{r'} :: r^n{}}) + -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) + def {x : (tableinst, nat, ref)} grow_table(x) = ?() -;; 4-runtime.watsup:168.1-168.41 -def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:173.1-176.66 - def {b* : byte*, i : nat, i' : nat, j? : nat?, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' - -- if (mi = {TYPE `%I8`(`[%..%?]`(i, j?{j})), DATA b*{b}}) +;; 4-runtime.watsup:168.1-168.55 +def grow_memory : (meminst, nat) -> meminst? + ;; 4-runtime.watsup:175.1-179.34 + def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = ?(mi') + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) - -- if (mi' = {TYPE `%I8`(`[%..%?]`(i', j?{j})), DATA b*{b} :: 0^((n * 64) * $Ki){}}) + -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: 0^((n * 64) * $Ki){}}) + -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) + def {x : (meminst, nat)} grow_memory(x) = ?() -;; 4-runtime.watsup:189.1-192.21 +;; 4-runtime.watsup:192.1-195.21 rec { -;; 4-runtime.watsup:189.1-192.21 +;; 4-runtime.watsup:192.1-195.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -9657,139 +9619,139 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:214.1-216.39 + ;; 6-reduction.watsup:212.1-214.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:218.1-221.14 + ;; 6-reduction.watsup:216.1-219.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:223.1-227.15 + ;; 6-reduction.watsup:221.1-225.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:230.1-232.73 + ;; 6-reduction.watsup:228.1-230.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:234.1-237.14 + ;; 6-reduction.watsup:232.1-235.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:239.1-244.15 + ;; 6-reduction.watsup:237.1-242.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:246.1-250.15 + ;; 6-reduction.watsup:244.1-248.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:253.1-255.72 + ;; 6-reduction.watsup:251.1-253.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:257.1-260.14 + ;; 6-reduction.watsup:255.1-258.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:262.1-266.15 + ;; 6-reduction.watsup:260.1-264.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y).ELEM_eleminst[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:273.1-275.53 + ;; 6-reduction.watsup:271.1-273.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:277.1-279.71 + ;; 6-reduction.watsup:275.1-277.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($size($valtype_numtype(nt)) = ?(o1)) -- if ($bytes_(o0, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (o1 / 8)]) - ;; 6-reduction.watsup:281.1-283.45 + ;; 6-reduction.watsup:279.1-281.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:285.1-287.55 + ;; 6-reduction.watsup:283.1-285.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, o0, sx, c))]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:307.1-309.44 + ;; 6-reduction.watsup:305.1-307.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:322.1-324.37 + ;; 6-reduction.watsup:318.1-320.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:326.1-329.14 + ;; 6-reduction.watsup:322.1-325.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:331.1-335.15 + ;; 6-reduction.watsup:327.1-331.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:338.1-340.69 + ;; 6-reduction.watsup:334.1-336.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:342.1-345.14 + ;; 6-reduction.watsup:338.1-341.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:347.1-352.15 + ;; 6-reduction.watsup:343.1-348.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:354.1-358.15 + ;; 6-reduction.watsup:350.1-354.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:361.1-363.70 + ;; 6-reduction.watsup:357.1-359.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:365.1-368.14 + ;; 6-reduction.watsup:361.1-364.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:370.1-374.15 + ;; 6-reduction.watsup:366.1-370.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise @@ -9824,331 +9786,319 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-208.36 - rule table.grow-succeed {n : n, ref : ref, ti : tableinst, ti' : tableinst, x : idx, z : state}: - `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti'), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($table(z, x) = ti) - -- if ($grow_table(ti, n, ref) = ti') - -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) + ;; 6-reduction.watsup:204.1-206.47 + rule table.grow-succeed {n : n, ref : ref, ti : tableinst, x : idx, z : state, o0 : tableinst}: + `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($grow_table($table(z, x), n, ref) = ?(o0)) + -- if (o0 = ti) - ;; 6-reduction.watsup:210.1-211.64 + ;; 6-reduction.watsup:208.1-209.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:269.1-270.59 + ;; 6-reduction.watsup:267.1-268.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:290.1-292.53 + ;; 6-reduction.watsup:288.1-290.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:294.1-296.35 + ;; 6-reduction.watsup:292.1-294.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (o0 / 8), b*{b}), [])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($size($valtype_numtype(nt)) = ?(o1)) -- if (b*{b} = $bytes_(o1, c)) - ;; 6-reduction.watsup:298.1-300.45 + ;; 6-reduction.watsup:296.1-298.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:302.1-304.50 + ;; 6-reduction.watsup:300.1-302.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (b*{b} = $bytes_(n, $wrap_((o0, n), c))) - ;; 6-reduction.watsup:312.1-316.34 - rule memory.grow-succeed {mi : meminst, mi' : meminst, n : n, z : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_meminst(z, 0, mi'), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - -- if ($mem(z, 0) = mi) - -- if ($grow_memory(mi, n) = mi') - -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) + ;; 6-reduction.watsup:310.1-312.41 + rule memory.grow-succeed {mi : meminst, n : n, z : state, o0 : meminst}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_meminst(z, 0, mi), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($grow_memory($mem(z, 0), n) = ?(o0)) + -- if (o0 = mi) - ;; 6-reduction.watsup:318.1-319.59 + ;; 6-reduction.watsup:314.1-315.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:377.1-378.59 + ;; 6-reduction.watsup:373.1-374.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) -;; 7-module.watsup:3.1-3.64 +;; 7-module.watsup:4.1-4.35 rec { -;; 7-module.watsup:3.1-3.64 -def alloc_import : (moduleinst, import*, externval*) -> moduleinst - ;; 7-module.watsup:5.1-5.43 - def {m : moduleinst} alloc_import(m, [], []) = m - ;; 7-module.watsup:7.1-12.60 - def {externtype : externtype, externval : externval, externval'* : externval*, fa : funcaddr, functype : functype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = FUNC_externtype(functype)) - -- if (externval = FUNC_externval(fa)) - -- if (m_new = m[FUNC_moduleinst =.. [fa]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) - ;; 7-module.watsup:14.1-19.60 - def {externtype : externtype, externval : externval, externval'* : externval*, ga : globaladdr, globaltype : globaltype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = GLOBAL_externtype(globaltype)) - -- if (externval = GLOBAL_externval(ga)) - -- if (m_new = m[GLOBAL_moduleinst =.. [ga]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) - ;; 7-module.watsup:21.1-26.60 - def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name, ta : tableaddr, tabletype : tabletype} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = TABLE_externtype(tabletype)) - -- if (externval = TABLE_externval(ta)) - -- if (m_new = m[TABLE_moduleinst =.. [ta]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) - ;; 7-module.watsup:28.1-33.60 - def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, ma : memaddr, memtype : memtype, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = MEM_externtype(memtype)) - -- if (externval = MEM_externval(ma)) - -- if (m_new = m[MEM_moduleinst =.. [ma]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) +;; 7-module.watsup:4.1-4.35 +def funcs : externval* -> funcaddr* + ;; 7-module.watsup:5.1-5.30 + def funcs([]) = [] + ;; 7-module.watsup:6.1-6.59 + def {externval'* : externval*, fa : funcaddr} funcs([FUNC_externval(fa)] :: externval'*{externval'}) = [fa] :: $funcs(externval'*{externval'}) + ;; 7-module.watsup:7.1-8.15 + def {externval : externval, externval'* : externval*} funcs([externval] :: externval'*{externval'}) = $funcs(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:36.1-36.51 +;; 7-module.watsup:10.1-10.39 rec { -;; 7-module.watsup:36.1-36.51 -def alloc_func : (state, func*) -> (store, funcaddr*) - ;; 7-module.watsup:38.1-38.48 - def {f : frame, s : store} alloc_func(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:40.1-44.56 - def {f : frame, fa : funcaddr, fa'* : funcaddr*, fi : funcinst, func : func, func'* : func*, s : store, s_new : store, s_res : store} alloc_func(`%;%`(s, f), [func] :: func'*{func'}) = (s_res, [fa] :: fa'*{fa'}) - -- if (fi = {MODULE f.MODULE_frame, CODE func}) - -- if (fa = |$funcinst(`%;%`(s, f))|) - -- if (s_new = s[FUNC_store =.. [fi]]) - -- if ((s_res, fa'*{fa'}) = $alloc_func(`%;%`(s_new, f), func'*{func'})) +;; 7-module.watsup:10.1-10.39 +def globals : externval* -> globaladdr* + ;; 7-module.watsup:11.1-11.32 + def globals([]) = [] + ;; 7-module.watsup:12.1-12.65 + def {externval'* : externval*, ga : globaladdr} globals([GLOBAL_externval(ga)] :: externval'*{externval'}) = [ga] :: $globals(externval'*{externval'}) + ;; 7-module.watsup:13.1-14.15 + def {externval : externval, externval'* : externval*} globals([externval] :: externval'*{externval'}) = $globals(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:47.1-47.57 +;; 7-module.watsup:16.1-16.37 rec { -;; 7-module.watsup:47.1-47.57 -def alloc_global : (state, global*) -> (store, globaladdr*) - ;; 7-module.watsup:49.1-49.50 - def {f : frame, s : store} alloc_global(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:51.1-57.60 - def {f : frame, ga : globaladdr, ga'* : globaladdr*, gi : globalinst, global : global, global'* : global*, globaltype : globaltype, instr* : instr*, s : store, s_new : store, s_res : store, val : val} alloc_global(`%;%`(s, f), [global] :: global'*{global'}) = (s_res, [ga] :: ga'*{ga'}) - -- if (global = GLOBAL(globaltype, instr*{instr})) - -- Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr}), [$admininstr_val(val)]) - -- if (gi = {TYPE globaltype, VALUE val}) - -- if (ga = |$globalinst(`%;%`(s, f))|) - -- if (s_new = s[GLOBAL_store =.. [gi]]) - -- if ((s_res, ga'*{ga'}) = $alloc_global(`%;%`(s_new, f), global'*{global'})) +;; 7-module.watsup:16.1-16.37 +def tables : externval* -> tableaddr* + ;; 7-module.watsup:17.1-17.31 + def tables([]) = [] + ;; 7-module.watsup:18.1-18.62 + def {externval'* : externval*, ta : tableaddr} tables([TABLE_externval(ta)] :: externval'*{externval'}) = [ta] :: $tables(externval'*{externval'}) + ;; 7-module.watsup:19.1-20.15 + def {externval : externval, externval'* : externval*} tables([externval] :: externval'*{externval'}) = $tables(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:60.1-60.54 +;; 7-module.watsup:22.1-22.33 rec { -;; 7-module.watsup:60.1-60.54 -def alloc_table : (state, table*) -> (store, tableaddr*) - ;; 7-module.watsup:62.1-62.49 - def {f : frame, s : store} alloc_table(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:64.1-70.58 - def {f : frame, i : nat, j? : nat?, reftype : reftype, s : store, s_new : store, s_res : store, ta : tableaddr, ta'* : tableaddr*, table : table, table'* : table*, tabletype : tabletype, ti : tableinst} alloc_table(`%;%`(s, f), [table] :: table'*{table'}) = (s_res, [ta] :: ta'*{ta'}) - -- if (table = TABLE(tabletype)) - -- if (tabletype = `%%`(`[%..%?]`(i, j?{j}), reftype)) - -- if (ti = {TYPE tabletype, ELEM REF.NULL_ref(reftype)^i{}}) - -- if (ta = |$tableinst(`%;%`(s, f))|) - -- if (s_new = s[TABLE_store =.. [ti]]) - -- if ((s_res, ta'*{ta'}) = $alloc_table(`%;%`(s_new, f), table'*{table'})) +;; 7-module.watsup:22.1-22.33 +def mems : externval* -> memaddr* + ;; 7-module.watsup:23.1-23.29 + def mems([]) = [] + ;; 7-module.watsup:24.1-24.56 + def {externval'* : externval*, ma : memaddr} mems([MEM_externval(ma)] :: externval'*{externval'}) = [ma] :: $mems(externval'*{externval'}) + ;; 7-module.watsup:25.1-26.15 + def {externval : externval, externval'* : externval*} mems([externval] :: externval'*{externval'}) = $mems(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:73.1-73.48 +;; 7-module.watsup:29.1-29.83 +def instexport : (funcaddr*, globaladdr*, tableaddr*, memaddr*, export) -> exportinst + ;; 7-module.watsup:30.1-30.95 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, FUNC_externuse(x))) = {NAME name, VALUE FUNC_externval(fa*{fa}[x])} + ;; 7-module.watsup:31.1-31.99 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, GLOBAL_externuse(x))) = {NAME name, VALUE GLOBAL_externval(ga*{ga}[x])} + ;; 7-module.watsup:32.1-32.97 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, TABLE_externuse(x))) = {NAME name, VALUE TABLE_externval(ta*{ta}[x])} + ;; 7-module.watsup:33.1-33.93 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, MEM_externuse(x))) = {NAME name, VALUE MEM_externval(ma*{ma}[x])} + +;; 7-module.watsup:36.1-36.60 +def allocfunc : (store, moduleinst, func) -> (store, funcaddr) + ;; 7-module.watsup:37.1-38.37 + def {fi : funcinst, func : func, m : moduleinst, s : store} allocfunc(s, m, func) = (s[FUNC_store =.. [fi]], |s.FUNC_store|) + -- if (fi = {MODULE m, CODE func}) + +;; 7-module.watsup:40.1-40.63 rec { -;; 7-module.watsup:73.1-73.48 -def alloc_mem : (state, mem*) -> (store, memaddr*) - ;; 7-module.watsup:75.1-75.47 - def {f : frame, s : store} alloc_mem(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:77.1-83.54 - def {f : frame, i : nat, j? : nat?, ma : memaddr, ma'* : memaddr*, mem : mem, mem'* : mem*, memtype : memtype, mi : meminst, s : store, s_new : store, s_res : store} alloc_mem(`%;%`(s, f), [mem] :: mem'*{mem'}) = (s_res, [ma] :: ma'*{ma'}) - -- if (mem = MEMORY(memtype)) - -- if (memtype = `%I8`(`[%..%?]`(i, j?{j}))) - -- if (mi = {TYPE memtype, DATA 0^((i * 64) * $Ki){}}) - -- if (ma = |$meminst(`%;%`(s, f))|) - -- if (s_new = s[MEM_store =.. [mi]]) - -- if ((s_res, ma'*{ma'}) = $alloc_mem(`%;%`(s_new, f), mem'*{mem'})) +;; 7-module.watsup:40.1-40.63 +def allocfuncs : (store, moduleinst, func*) -> (store, funcaddr*) + ;; 7-module.watsup:41.1-41.46 + def {m : moduleinst, s : store} allocfuncs(s, m, []) = (s, []) + ;; 7-module.watsup:42.1-44.50 + def {fa : funcaddr, fa'* : funcaddr*, func : func, func'* : func*, m : moduleinst, s : store, s_1 : store, s_2 : store} allocfuncs(s, m, [func] :: func'*{func'}) = (s_2, [fa] :: fa'*{fa'}) + -- if ((s_1, fa) = $allocfunc(s, m, func)) + -- if ((s_2, fa'*{fa'}) = $allocfuncs(s_1, m, func'*{func'})) } -;; 7-module.watsup:86.1-86.51 +;; 7-module.watsup:46.1-46.63 +def allocglobal : (store, globaltype, val) -> (store, globaladdr) + ;; 7-module.watsup:47.1-48.44 + def {gi : globalinst, globaltype : globaltype, s : store, val : val} allocglobal(s, globaltype, val) = (s[GLOBAL_store =.. [gi]], |s.GLOBAL_store|) + -- if (gi = {TYPE globaltype, VALUE val}) + +;; 7-module.watsup:50.1-50.67 rec { -;; 7-module.watsup:86.1-86.51 -def alloc_elem : (state, elem*) -> (store, elemaddr*) - ;; 7-module.watsup:88.1-88.48 - def {f : frame, s : store} alloc_elem(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:90.1-96.56 - def {ea : elemaddr, ea'* : elemaddr*, ei : eleminst, elem : elem, elem'* : elem*, elemmode? : elemmode?, f : frame, instr** : instr**, ref* : ref*, reftype : reftype, s : store, s_new : store, s_res : store} alloc_elem(`%;%`(s, f), [elem] :: elem'*{elem'}) = (s_res, [ea] :: ea'*{ea'}) - -- if (elem = `ELEM%%*%?`(reftype, instr*{instr}*{instr}, elemmode?{elemmode})) - -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr}), [$admininstr_ref(ref)]))*{instr ref} - -- if (ei = {TYPE reftype, ELEM ref*{ref}}) - -- if (ea = |$eleminst(`%;%`(s, f))|) - -- if (s_new = s[ELEM_store =.. [ei]]) - -- if ((s_res, ea'*{ea'}) = $alloc_elem(`%;%`(s_new, f), elem'*{elem'})) +;; 7-module.watsup:50.1-50.67 +def allocglobals : (store, globaltype*, val*) -> (store, globaladdr*) + ;; 7-module.watsup:51.1-51.54 + def {s : store} allocglobals(s, [], []) = (s, []) + ;; 7-module.watsup:52.1-54.62 + def {ga : globaladdr, ga'* : globaladdr*, globaltype : globaltype, globaltype'* : globaltype*, s : store, s_1 : store, s_2 : store, val : val, val'* : val*} allocglobals(s, [globaltype] :: globaltype'*{globaltype'}, [val] :: val'*{val'}) = (s_2, [ga] :: ga'*{ga'}) + -- if ((s_1, ga) = $allocglobal(s, globaltype, val)) + -- if ((s_2, ga'*{ga'}) = $allocglobals(s_1, globaltype'*{globaltype'}, val'*{val'})) } -;; 7-module.watsup:99.1-99.51 +;; 7-module.watsup:56.1-56.55 +def alloctable : (store, tabletype) -> (store, tableaddr) + ;; 7-module.watsup:57.1-58.59 + def {i : nat, j : nat, rt : reftype, s : store, ti : tableinst} alloctable(s, `%%`(`[%..%]`(i, j), rt)) = (s[TABLE_store =.. [ti]], |s.TABLE_store|) + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM REF.NULL_ref(rt)^i{}}) + +;; 7-module.watsup:60.1-60.58 rec { -;; 7-module.watsup:99.1-99.51 -def alloc_data : (state, data*) -> (store, dataaddr*) - ;; 7-module.watsup:101.1-101.48 - def {f : frame, s : store} alloc_data(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:103.1-108.56 - def {byte* : byte*, da : dataaddr, da'* : dataaddr*, data : data, data'* : data*, datamode? : datamode?, di : datainst, f : frame, s : store, s_new : store, s_res : store} alloc_data(`%;%`(s, f), [data] :: data'*{data'}) = (s_res, [da] :: da'*{da'}) - -- if (data = `DATA%*%?`(byte*{byte}, datamode?{datamode})) - -- if (di = {DATA byte*{byte}}) - -- if (da = |$datainst(`%;%`(s, f))|) - -- if (s_new = s[DATA_store =.. [di]]) - -- if ((s_res, da'*{da'}) = $alloc_data(`%;%`(s_new, f), data'*{data'})) +;; 7-module.watsup:60.1-60.58 +def alloctables : (store, tabletype*) -> (store, tableaddr*) + ;; 7-module.watsup:61.1-61.44 + def {s : store} alloctables(s, []) = (s, []) + ;; 7-module.watsup:62.1-64.53 + def {s : store, s_1 : store, s_2 : store, ta : tableaddr, ta'* : tableaddr*, tabletype : tabletype, tabletype'* : tabletype*} alloctables(s, [tabletype] :: tabletype'*{tabletype'}) = (s_2, [ta] :: ta'*{ta'}) + -- if ((s_1, ta) = $alloctable(s, tabletype)) + -- if ((s_2, ta'*{ta'}) = $alloctables(s_1, tabletype'*{tabletype'})) } -;; 7-module.watsup:111.1-111.62 +;; 7-module.watsup:66.1-66.49 +def allocmem : (store, memtype) -> (store, memaddr) + ;; 7-module.watsup:67.1-68.62 + def {i : nat, j : nat, mi : meminst, s : store} allocmem(s, `%I8`(`[%..%]`(i, j))) = (s[MEM_store =.. [mi]], |s.MEM_store|) + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA 0^((i * 64) * $Ki){}}) + +;; 7-module.watsup:70.1-70.52 rec { -;; 7-module.watsup:111.1-111.62 -def replace_moduleinst : (store, funcaddr*, moduleinst) -> store - ;; 7-module.watsup:113.1-113.43 - def {m : moduleinst, s : store} replace_moduleinst(s, [], m) = s - ;; 7-module.watsup:115.1-117.52 - def {fa : funcaddr, fa'* : funcaddr*, m : moduleinst, s : store, s_new : store, s_res : store} replace_moduleinst(s, [fa] :: fa'*{fa'}, m) = s_res - -- if (s_new = s[FUNC_store[fa].MODULE_funcinst = m]) - -- if (s_res = $replace_moduleinst(s_new, fa'*{fa'}, m)) +;; 7-module.watsup:70.1-70.52 +def allocmems : (store, memtype*) -> (store, memaddr*) + ;; 7-module.watsup:71.1-71.42 + def {s : store} allocmems(s, []) = (s, []) + ;; 7-module.watsup:72.1-74.49 + def {ma : memaddr, ma'* : memaddr*, memtype : memtype, memtype'* : memtype*, s : store, s_1 : store, s_2 : store} allocmems(s, [memtype] :: memtype'*{memtype'}) = (s_2, [ma] :: ma'*{ma'}) + -- if ((s_1, ma) = $allocmem(s, memtype)) + -- if ((s_2, ma'*{ma'}) = $allocmems(s_1, memtype'*{memtype'})) } -;; 7-module.watsup:120.1-120.51 -def alloc_export : (moduleinst, export) -> exportinst - ;; 7-module.watsup:122.1-126.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = FUNC_externuse(x)) - -- if (externval = FUNC_externval(m.FUNC_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - ;; 7-module.watsup:128.1-132.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = GLOBAL_externuse(x)) - -- if (externval = GLOBAL_externval(m.GLOBAL_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - ;; 7-module.watsup:134.1-138.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = TABLE_externuse(x)) - -- if (externval = TABLE_externval(m.TABLE_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - ;; 7-module.watsup:140.1-144.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = MEM_externuse(x)) - -- if (externval = MEM_externval(m.MEM_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - -;; 7-module.watsup:147.1-147.67 -def alloc_module : (store, module, externval*) -> (store, moduleinst) - ;; 7-module.watsup:149.1-163.56 - def {da* : dataaddr*, data* : data*, ea* : elemaddr*, elem* : elem*, export* : export*, externval* : externval*, f : frame, fa* : funcaddr*, func* : func*, ga* : globaladdr*, global* : global*, import* : import*, m_ex : moduleinst, m_im : moduleinst, m_init : moduleinst, m_res : moduleinst, ma* : memaddr*, mem* : mem*, module : module, s : store, s_data : store, s_elem : store, s_func : store, s_global : store, s_mem : store, s_res : store, s_table : store, start? : start?, ta* : tableaddr*, table* : table*, xi* : exportinst*} alloc_module(s, module, externval*{externval}) = (s_res, m_res) - -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) - -- if (m_init = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) - -- if (m_im = $alloc_import(m_init, import*{import}, externval*{externval})) - -- if (f = {LOCAL [], MODULE m_im}) - -- if ((s_func, fa*{fa}) = $alloc_func(`%;%`(s, f), func*{func})) - -- if ((s_global, ga*{ga}) = $alloc_global(`%;%`(s_func, f), global*{global})) - -- if ((s_table, ta*{ta}) = $alloc_table(`%;%`(s_global, f), table*{table})) - -- if ((s_mem, ma*{ma}) = $alloc_mem(`%;%`(s_table, f), mem*{mem})) - -- if ((s_elem, ea*{ea}) = $alloc_elem(`%;%`(s_mem, f), elem*{elem})) - -- if ((s_data, da*{da}) = $alloc_data(`%;%`(s_elem, f), data*{data})) - -- if (m_ex = m_im ++ {FUNC fa*{fa}, GLOBAL ga*{ga}, TABLE ta*{ta}, MEM ma*{ma}, ELEM ea*{ea}, DATA da*{da}, EXPORT []}) - -- if (xi*{xi} = $alloc_export(m_ex, export)*{export}) - -- if (m_res = m_ex[EXPORT_moduleinst = xi*{xi}]) - -- if (s_res = $replace_moduleinst(s_data, fa*{fa}, m_res)) - -;; 7-module.watsup:166.1-166.41 +;; 7-module.watsup:76.1-76.57 +def allocelem : (store, reftype, ref*) -> (store, elemaddr) + ;; 7-module.watsup:77.1-78.36 + def {ei : eleminst, ref* : ref*, rt : reftype, s : store} allocelem(s, rt, ref*{ref}) = (s[ELEM_store =.. [ei]], |s.ELEM_store|) + -- if (ei = {TYPE rt, ELEM ref*{ref}}) + +;; 7-module.watsup:80.1-80.63 rec { -;; 7-module.watsup:166.1-166.41 -def run_elem : (state, elem*, idx) -> state - ;; 7-module.watsup:168.1-168.41 - def {f : frame, i : nat, s : store} run_elem(`%;%`(s, f), [], i) = `%;%`(s, f) - ;; 7-module.watsup:170.1-172.59 - def {elem : elem, elem'* : elem*, expr* : expr*, f : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) - -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?())) - -- if ($run_elem(`%;%`(s, f), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:174.1-179.67 - def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, reftype : reftype, s : store, s_new : store, s_res : store, x : idx} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) - -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) - -- if (n = |expr*{expr}|) - -- if (elemmode = TABLE_elemmode(x, instr*{instr})) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, i) ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) - -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:181.1-185.67 - def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_new : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) - -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) - -- if (elemmode = DECLARE_elemmode) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), [ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) - -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) +;; 7-module.watsup:80.1-80.63 +def allocelems : (store, reftype*, ref**) -> (store, elemaddr*) + ;; 7-module.watsup:81.1-81.52 + def {s : store} allocelems(s, [], []) = (s, []) + ;; 7-module.watsup:82.1-84.53 + def {ea : elemaddr, ea'* : elemaddr*, ref* : ref*, ref'** : ref**, rt : reftype, rt'* : reftype*, s : store, s_1 : store, s_2 : store} allocelems(s, [rt] :: rt'*{rt'}, [ref]*{ref} :: ref'*{ref'}*{ref'}) = (s_2, [ea] :: ea'*{ea'}) + -- if ((s_1, ea) = $allocelem(s, rt, ref*{ref})) + -- if ((s_2, ea'*{ea'}) = $allocelems(s_2, rt'*{rt'}, ref'*{ref'}*{ref'})) } -;; 7-module.watsup:188.1-188.41 +;; 7-module.watsup:86.1-86.49 +def allocdata : (store, byte*) -> (store, dataaddr) + ;; 7-module.watsup:87.1-88.28 + def {byte* : byte*, di : datainst, s : store} allocdata(s, byte*{byte}) = (s[DATA_store =.. [di]], |s.DATA_store|) + -- if (di = {DATA byte*{byte}}) + +;; 7-module.watsup:90.1-90.52 rec { -;; 7-module.watsup:188.1-188.41 -def run_data : (state, data*, idx) -> state - ;; 7-module.watsup:190.1-190.41 - def {f : frame, i : nat, s : store} run_data(`%;%`(s, f), [], i) = `%;%`(s, f) - ;; 7-module.watsup:192.1-194.59 - def {byte* : byte*, data : data, data'* : data*, f : frame, f_res : frame, i : nat, s : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) - -- if (data = `DATA%*%?`(byte*{byte}, ?())) - -- if ($run_data(`%;%`(s, f), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:196.1-201.67 - def {byte* : byte*, data : data, data'* : data*, datamode : datamode, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, s : store, s_new : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) - -- if (data = `DATA%*%?`(byte*{byte}, ?(datamode))) +;; 7-module.watsup:90.1-90.52 +def allocdatas : (store, byte**) -> (store, dataaddr*) + ;; 7-module.watsup:91.1-91.43 + def {s : store} allocdatas(s, []) = (s, []) + ;; 7-module.watsup:92.1-94.48 + def {byte* : byte*, byte'** : byte**, da : dataaddr, da'* : dataaddr*, s : store, s_1 : store, s_2 : store} allocdatas(s, [byte]*{byte} :: byte'*{byte'}*{byte'}) = (s_2, [da] :: da'*{da'}) + -- if ((s_1, da) = $allocdata(s, byte*{byte})) + -- if ((s_2, da'*{da'}) = $allocdatas(s_1, byte'*{byte'}*{byte'})) +} + +;; 7-module.watsup:97.1-97.81 +def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) + ;; 7-module.watsup:98.1-135.54 + def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i : nat, import* : import*, m : moduleinst, ma* : memaddr*, ma_ex* : memaddr*, memtype^n_mem : memtype^n_mem, module : module, n_data : n, n_elem : n, n_func : n, n_global : n, n_mem : n, n_table : n, ref** : ref**, rt^n_elem : reftype^n_elem, s : store, s_1 : store, s_2 : store, s_3 : store, s_4 : store, s_5 : store, s_6 : store, start? : start?, ta* : tableaddr*, ta_ex* : tableaddr*, tabletype^n_table : tabletype^n_table, val* : val*, xi* : exportinst*} allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref}) = (s_6, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func^n_func{func}, GLOBAL(globaltype, expr_1)^n_global{expr_1 globaltype}, TABLE(tabletype)^n_table{tabletype}, MEMORY(memtype)^n_mem{memtype}, `ELEM%%*%?`(rt, expr_2*{expr_2}, elemmode?{elemmode})^n_elem{elemmode expr_2 rt}, `DATA%*%?`(byte*{byte}, datamode?{datamode})^n_data{byte datamode}, start?{start}, export*{export})) + -- if (fa_ex*{fa_ex} = $funcs(externval*{externval})) + -- if (ga_ex*{ga_ex} = $globals(externval*{externval})) + -- if (ta_ex*{ta_ex} = $tables(externval*{externval})) + -- if (ma_ex*{ma_ex} = $mems(externval*{externval})) + -- if (fa*{fa} = (|s.FUNC_store| + i)^(i instr* + ;; 7-module.watsup:139.1-139.46 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?()), i) = [] + ;; 7-module.watsup:140.1-140.62 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(DECLARE_elemmode)), i) = [ELEM.DROP_instr(i)] + ;; 7-module.watsup:141.1-143.20 + def {expr* : expr*, i : nat, instr* : instr*, n : n, reftype : reftype, x : idx} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(TABLE_elemmode(x, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) TABLE.INIT_instr(x, i) ELEM.DROP_instr(i)] + -- if (n = |expr*{expr}|) + +;; 7-module.watsup:145.1-145.33 +def rundata : (data, idx) -> instr* + ;; 7-module.watsup:146.1-146.38 + def {byte* : byte*, i : nat} rundata(`DATA%*%?`(byte*{byte}, ?()), i) = [] + ;; 7-module.watsup:147.1-149.20 + def {byte* : byte*, i : nat, instr* : instr*, n : n} rundata(`DATA%*%?`(byte*{byte}, ?(MEMORY_datamode(0, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) MEMORY.INIT_instr(i) DATA.DROP_instr(i)] -- if (n = |byte*{byte}|) - -- if (datamode = MEMORY_datamode(0, instr*{instr})) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(i) DATA.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) - -- if ($run_data(`%;%`(s_new, f_new), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) + +;; 7-module.watsup:152.1-152.36 +rec { + +;; 7-module.watsup:152.1-152.36 +def concat_instr : instr** -> instr* + ;; 7-module.watsup:153.1-153.37 + def concat_instr([]) = [] + ;; 7-module.watsup:154.1-154.68 + def {instr* : instr*, instr'** : instr**} concat_instr([instr]*{instr} :: instr'*{instr'}*{instr'}) = instr*{instr} :: $concat_instr(instr'*{instr'}*{instr'}) } -;; 7-module.watsup:206.1-206.68 -def instantiation : (store, module, externval*) -> (store, moduleinst) - ;; 7-module.watsup:208.1-213.61 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) - -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(), export*{export})) - -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) - -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) - -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:215.1-222.62 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) - -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(start), export*{export})) - -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) +;; 7-module.watsup:157.1-157.55 +def instantiation : (store, module, externval*) -> config + ;; 7-module.watsup:158.1-180.28 + def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i : nat, import* : import*, instr_1** : instr**, instr_2*** : instr***, instr_data* : instr*, instr_elem* : instr*, j : nat, m : moduleinst, m_init : moduleinst, mem* : mem*, module : module, n_data : n, n_elem : n, ref** : ref**, reftype* : reftype*, s : store, s' : store, start? : start?, table* : table*, val* : val*, x? : idx?} instantiation(s, module, externval*{externval}) = `%;%*`(`%;%`(s', f), $admininstr_instr(instr_elem)*{instr_elem} :: $admininstr_instr(instr_data)*{instr_data} :: CALL_admininstr(x)?{x}) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) + -- if (m_init = {FUNC $funcs(externval*{externval}), GLOBAL $globals(externval*{externval}), TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f_init = {LOCAL [], MODULE m_init}) + -- (if (global = GLOBAL(globaltype, instr_1*{instr_1})))*{global globaltype instr_1} + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_1)*{instr_1}), [$admininstr_val(val)]))*{instr_1 val} + -- (if (elem = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})))*{elem elemmode instr_2 reftype} + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_2)*{instr_2}), [$admininstr_ref(ref)]))*{instr_2 ref}*{instr_2 ref} + -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) - -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_data, f_data)) - -- if (start = START(x)) - -- Step: `%~>%`(`%;%*`(`%;%`(s_data, f_data), [CALL_admininstr(x)]), `%;%*`(`%;%`(s_res, f_res), [])) - -;; 7-module.watsup:227.1-227.55 -def invocation : (store, funcaddr, val*) -> (store, val*) - ;; 7-module.watsup:229.1-236.55 - def {expr : expr, f : frame, f' : frame, fa : funcaddr, functype : functype, m : moduleinst, s : store, s' : store, val* : val*, val'* : val*, valtype* : valtype*, valtype'* : valtype*} invocation(s, fa, val*{val}) = (s', val'*{val'}) + -- if (n_elem = |elem*{elem}|) + -- if (instr_elem*{instr_elem} = $concat_instr($runelem(elem*{elem}[i], i)^(i config + ;; 7-module.watsup:184.1-196.52 + def {expr : expr, f : frame, fa : funcaddr, functype : functype, k : nat, m : moduleinst, n : n, s : store, val^n : val^n, valtype* : valtype*, valtype_param^n : valtype^n, valtype_res^k : valtype^k} invocation(s, fa, val^n{val}) = `%;%*`(`%;%`(s, f), $admininstr_val(val)^n{val} :: [CALL_ADDR_admininstr(fa)]) -- if (m = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) -- if (f = {LOCAL [], MODULE m}) -- if ($funcinst(`%;%`(s, f))[fa].CODE_funcinst = `FUNC%%*%`(functype, valtype*{valtype}, expr)) - -- if (functype = `%->%`(valtype*{valtype}, valtype'*{valtype'})) - -- if (|val*{val}| = |valtype*{valtype}|) - -- if (|val'*{val'}| = |valtype'*{valtype'}|) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_val(val)*{val} :: [CALL_ADDR_admininstr(fa)]), `%;%*`(`%;%`(s', f'), $admininstr_val(val')*{val'})) + -- if (functype = `%->%`(valtype_param^n{valtype_param}, valtype_res^k{valtype_res})) == IL Validation... == Running pass sideconditions @@ -10261,8 +10211,8 @@ def valtype_fn : fn -> valtype ;; 1-syntax.watsup:56.1-57.11 syntax resulttype = valtype* -;; 1-syntax.watsup:59.1-60.17 -syntax limits = `[%..%?]`(u32, u32?) +;; 1-syntax.watsup:59.1-60.16 +syntax limits = `[%..%]`(u32, u32) ;; 1-syntax.watsup:61.1-62.15 syntax globaltype = `MUT%?%`(()?, valtype) @@ -10556,7 +10506,7 @@ syntax context = {FUNC functype*, GLOBAL globaltype*, TABLE tabletype*, MEM memt relation Limits_ok: `|-%:%`(limits, nat) ;; 3-typing.watsup:22.1-24.24 rule _ {k : nat, n_1 : n, n_2 : n}: - `|-%:%`(`[%..%?]`(n_1, ?(n_2)), k) + `|-%:%`(`[%..%]`(n_1, n_2), k) -- if ((n_1 <= n_2) /\ (n_2 <= k)) ;; 3-typing.watsup:15.1-15.64 @@ -10629,7 +10579,7 @@ relation Resulttype_sub: `|-%*<:%*`(valtype*, valtype*) relation Limits_sub: `|-%<:%`(limits, limits) ;; 3-typing.watsup:83.1-86.21 rule _ {n_11 : n, n_12 : n, n_21 : n, n_22 : n}: - `|-%<:%`(`[%..%?]`(n_11, ?(n_12)), `[%..%?]`(n_21, ?(n_22))) + `|-%<:%`(`[%..%]`(n_11, n_12), `[%..%]`(n_21, n_22)) -- if (n_11 >= n_21) -- if (n_12 <= n_22) @@ -11287,10 +11237,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:180.1-187.5 +;; 4-runtime.watsup:183.1-190.5 rec { -;; 4-runtime.watsup:180.1-187.5 +;; 4-runtime.watsup:183.1-190.5 syntax admininstr = | UNREACHABLE | NOP @@ -11514,26 +11464,30 @@ def with_data : (state, dataidx, byte*) -> state ;; 4-runtime.watsup:165.1-165.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:167.1-167.49 -def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:169.1-172.57 - def {i : nat, i' : nat, j? : nat?, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' - -- if (ti = {TYPE `%%`(`[%..%?]`(i, j?{j}), reftype), ELEM r'*{r'}}) +;; 4-runtime.watsup:167.1-167.63 +def grow_table : (tableinst, nat, ref) -> tableinst? + ;; 4-runtime.watsup:170.1-174.36 + def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, rt : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ?(ti') + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM r'*{r'}}) -- if (i' = (|r'*{r'}| + n)) - -- if (ti' = {TYPE `%%`(`[%..%?]`(i', j?{j}), reftype), ELEM r'*{r'} :: r^n{}}) + -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), rt), ELEM r'*{r'} :: r^n{}}) + -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) + def {x : (tableinst, nat, ref)} grow_table(x) = ?() -;; 4-runtime.watsup:168.1-168.41 -def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:173.1-176.66 - def {b* : byte*, i : nat, i' : nat, j? : nat?, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' - -- if (mi = {TYPE `%I8`(`[%..%?]`(i, j?{j})), DATA b*{b}}) +;; 4-runtime.watsup:168.1-168.55 +def grow_memory : (meminst, nat) -> meminst? + ;; 4-runtime.watsup:175.1-179.34 + def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = ?(mi') + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) - -- if (mi' = {TYPE `%I8`(`[%..%?]`(i', j?{j})), DATA b*{b} :: 0^((n * 64) * $Ki){}}) + -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: 0^((n * 64) * $Ki){}}) + -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) + def {x : (meminst, nat)} grow_memory(x) = ?() -;; 4-runtime.watsup:189.1-192.21 +;; 4-runtime.watsup:192.1-195.21 rec { -;; 4-runtime.watsup:189.1-192.21 +;; 4-runtime.watsup:192.1-195.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -11770,140 +11724,140 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) -- if (|$table(z, x).ELEM_tableinst| = n) - ;; 6-reduction.watsup:214.1-216.39 + ;; 6-reduction.watsup:212.1-214.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:218.1-221.14 + ;; 6-reduction.watsup:216.1-219.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:223.1-227.15 + ;; 6-reduction.watsup:221.1-225.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:230.1-232.73 + ;; 6-reduction.watsup:228.1-230.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:234.1-237.14 + ;; 6-reduction.watsup:232.1-235.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:239.1-244.15 + ;; 6-reduction.watsup:237.1-242.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:246.1-250.15 + ;; 6-reduction.watsup:244.1-248.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:253.1-255.72 + ;; 6-reduction.watsup:251.1-253.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:257.1-260.14 + ;; 6-reduction.watsup:255.1-258.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:262.1-266.15 + ;; 6-reduction.watsup:260.1-264.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y).ELEM_eleminst[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- if (i < |$elem(z, y).ELEM_eleminst|) -- otherwise - ;; 6-reduction.watsup:273.1-275.53 + ;; 6-reduction.watsup:271.1-273.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:277.1-279.71 + ;; 6-reduction.watsup:275.1-277.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($size($valtype_numtype(nt)) = ?(o1)) -- if ($bytes_(o0, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (o1 / 8)]) - ;; 6-reduction.watsup:281.1-283.45 + ;; 6-reduction.watsup:279.1-281.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:285.1-287.55 + ;; 6-reduction.watsup:283.1-285.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, o0, sx, c))]) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)]) - ;; 6-reduction.watsup:307.1-309.44 + ;; 6-reduction.watsup:305.1-307.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) -- if (((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:322.1-324.37 + ;; 6-reduction.watsup:318.1-320.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:326.1-329.14 + ;; 6-reduction.watsup:322.1-325.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:331.1-335.15 + ;; 6-reduction.watsup:327.1-331.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:338.1-340.69 + ;; 6-reduction.watsup:334.1-336.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:342.1-345.14 + ;; 6-reduction.watsup:338.1-341.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:347.1-352.15 + ;; 6-reduction.watsup:343.1-348.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:354.1-358.15 + ;; 6-reduction.watsup:350.1-354.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:361.1-363.70 + ;; 6-reduction.watsup:357.1-359.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:365.1-368.14 + ;; 6-reduction.watsup:361.1-364.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:370.1-374.15 + ;; 6-reduction.watsup:366.1-370.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- if (i < |$data(z, x).DATA_datainst|) @@ -11939,331 +11893,319 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-208.36 - rule table.grow-succeed {n : n, ref : ref, ti : tableinst, ti' : tableinst, x : idx, z : state}: - `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti'), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- if ($table(z, x) = ti) - -- if ($grow_table(ti, n, ref) = ti') - -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) + ;; 6-reduction.watsup:204.1-206.47 + rule table.grow-succeed {n : n, ref : ref, ti : tableinst, x : idx, z : state, o0 : tableinst}: + `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- if ($grow_table($table(z, x), n, ref) = ?(o0)) + -- if (o0 = ti) - ;; 6-reduction.watsup:210.1-211.64 + ;; 6-reduction.watsup:208.1-209.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:269.1-270.59 + ;; 6-reduction.watsup:267.1-268.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:290.1-292.53 + ;; 6-reduction.watsup:288.1-290.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:294.1-296.35 + ;; 6-reduction.watsup:292.1-294.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (o0 / 8), b*{b}), [])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if ($size($valtype_numtype(nt)) = ?(o1)) -- if (b*{b} = $bytes_(o1, c)) - ;; 6-reduction.watsup:298.1-300.45 + ;; 6-reduction.watsup:296.1-298.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:302.1-304.50 + ;; 6-reduction.watsup:300.1-302.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- if ($size($valtype_numtype(nt)) = ?(o0)) -- if (b*{b} = $bytes_(n, $wrap_((o0, n), c))) - ;; 6-reduction.watsup:312.1-316.34 - rule memory.grow-succeed {mi : meminst, mi' : meminst, n : n, z : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_meminst(z, 0, mi'), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - -- if ($mem(z, 0) = mi) - -- if ($grow_memory(mi, n) = mi') - -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) + ;; 6-reduction.watsup:310.1-312.41 + rule memory.grow-succeed {mi : meminst, n : n, z : state, o0 : meminst}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_meminst(z, 0, mi), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- if ($grow_memory($mem(z, 0), n) = ?(o0)) + -- if (o0 = mi) - ;; 6-reduction.watsup:318.1-319.59 + ;; 6-reduction.watsup:314.1-315.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:377.1-378.59 + ;; 6-reduction.watsup:373.1-374.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) -;; 7-module.watsup:3.1-3.64 +;; 7-module.watsup:4.1-4.35 rec { -;; 7-module.watsup:3.1-3.64 -def alloc_import : (moduleinst, import*, externval*) -> moduleinst - ;; 7-module.watsup:5.1-5.43 - def {m : moduleinst} alloc_import(m, [], []) = m - ;; 7-module.watsup:7.1-12.60 - def {externtype : externtype, externval : externval, externval'* : externval*, fa : funcaddr, functype : functype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = FUNC_externtype(functype)) - -- if (externval = FUNC_externval(fa)) - -- if (m_new = m[FUNC_moduleinst =.. [fa]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) - ;; 7-module.watsup:14.1-19.60 - def {externtype : externtype, externval : externval, externval'* : externval*, ga : globaladdr, globaltype : globaltype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = GLOBAL_externtype(globaltype)) - -- if (externval = GLOBAL_externval(ga)) - -- if (m_new = m[GLOBAL_moduleinst =.. [ga]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) - ;; 7-module.watsup:21.1-26.60 - def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name, ta : tableaddr, tabletype : tabletype} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = TABLE_externtype(tabletype)) - -- if (externval = TABLE_externval(ta)) - -- if (m_new = m[TABLE_moduleinst =.. [ta]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) - ;; 7-module.watsup:28.1-33.60 - def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, ma : memaddr, memtype : memtype, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = MEM_externtype(memtype)) - -- if (externval = MEM_externval(ma)) - -- if (m_new = m[MEM_moduleinst =.. [ma]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) +;; 7-module.watsup:4.1-4.35 +def funcs : externval* -> funcaddr* + ;; 7-module.watsup:5.1-5.30 + def funcs([]) = [] + ;; 7-module.watsup:6.1-6.59 + def {externval'* : externval*, fa : funcaddr} funcs([FUNC_externval(fa)] :: externval'*{externval'}) = [fa] :: $funcs(externval'*{externval'}) + ;; 7-module.watsup:7.1-8.15 + def {externval : externval, externval'* : externval*} funcs([externval] :: externval'*{externval'}) = $funcs(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:36.1-36.51 +;; 7-module.watsup:10.1-10.39 rec { -;; 7-module.watsup:36.1-36.51 -def alloc_func : (state, func*) -> (store, funcaddr*) - ;; 7-module.watsup:38.1-38.48 - def {f : frame, s : store} alloc_func(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:40.1-44.56 - def {f : frame, fa : funcaddr, fa'* : funcaddr*, fi : funcinst, func : func, func'* : func*, s : store, s_new : store, s_res : store} alloc_func(`%;%`(s, f), [func] :: func'*{func'}) = (s_res, [fa] :: fa'*{fa'}) - -- if (fi = {MODULE f.MODULE_frame, CODE func}) - -- if (fa = |$funcinst(`%;%`(s, f))|) - -- if (s_new = s[FUNC_store =.. [fi]]) - -- if ((s_res, fa'*{fa'}) = $alloc_func(`%;%`(s_new, f), func'*{func'})) +;; 7-module.watsup:10.1-10.39 +def globals : externval* -> globaladdr* + ;; 7-module.watsup:11.1-11.32 + def globals([]) = [] + ;; 7-module.watsup:12.1-12.65 + def {externval'* : externval*, ga : globaladdr} globals([GLOBAL_externval(ga)] :: externval'*{externval'}) = [ga] :: $globals(externval'*{externval'}) + ;; 7-module.watsup:13.1-14.15 + def {externval : externval, externval'* : externval*} globals([externval] :: externval'*{externval'}) = $globals(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:47.1-47.57 +;; 7-module.watsup:16.1-16.37 rec { -;; 7-module.watsup:47.1-47.57 -def alloc_global : (state, global*) -> (store, globaladdr*) - ;; 7-module.watsup:49.1-49.50 - def {f : frame, s : store} alloc_global(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:51.1-57.60 - def {f : frame, ga : globaladdr, ga'* : globaladdr*, gi : globalinst, global : global, global'* : global*, globaltype : globaltype, instr* : instr*, s : store, s_new : store, s_res : store, val : val} alloc_global(`%;%`(s, f), [global] :: global'*{global'}) = (s_res, [ga] :: ga'*{ga'}) - -- if (global = GLOBAL(globaltype, instr*{instr})) - -- Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr}), [$admininstr_val(val)]) - -- if (gi = {TYPE globaltype, VALUE val}) - -- if (ga = |$globalinst(`%;%`(s, f))|) - -- if (s_new = s[GLOBAL_store =.. [gi]]) - -- if ((s_res, ga'*{ga'}) = $alloc_global(`%;%`(s_new, f), global'*{global'})) +;; 7-module.watsup:16.1-16.37 +def tables : externval* -> tableaddr* + ;; 7-module.watsup:17.1-17.31 + def tables([]) = [] + ;; 7-module.watsup:18.1-18.62 + def {externval'* : externval*, ta : tableaddr} tables([TABLE_externval(ta)] :: externval'*{externval'}) = [ta] :: $tables(externval'*{externval'}) + ;; 7-module.watsup:19.1-20.15 + def {externval : externval, externval'* : externval*} tables([externval] :: externval'*{externval'}) = $tables(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:60.1-60.54 +;; 7-module.watsup:22.1-22.33 rec { -;; 7-module.watsup:60.1-60.54 -def alloc_table : (state, table*) -> (store, tableaddr*) - ;; 7-module.watsup:62.1-62.49 - def {f : frame, s : store} alloc_table(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:64.1-70.58 - def {f : frame, i : nat, j? : nat?, reftype : reftype, s : store, s_new : store, s_res : store, ta : tableaddr, ta'* : tableaddr*, table : table, table'* : table*, tabletype : tabletype, ti : tableinst} alloc_table(`%;%`(s, f), [table] :: table'*{table'}) = (s_res, [ta] :: ta'*{ta'}) - -- if (table = TABLE(tabletype)) - -- if (tabletype = `%%`(`[%..%?]`(i, j?{j}), reftype)) - -- if (ti = {TYPE tabletype, ELEM REF.NULL_ref(reftype)^i{}}) - -- if (ta = |$tableinst(`%;%`(s, f))|) - -- if (s_new = s[TABLE_store =.. [ti]]) - -- if ((s_res, ta'*{ta'}) = $alloc_table(`%;%`(s_new, f), table'*{table'})) +;; 7-module.watsup:22.1-22.33 +def mems : externval* -> memaddr* + ;; 7-module.watsup:23.1-23.29 + def mems([]) = [] + ;; 7-module.watsup:24.1-24.56 + def {externval'* : externval*, ma : memaddr} mems([MEM_externval(ma)] :: externval'*{externval'}) = [ma] :: $mems(externval'*{externval'}) + ;; 7-module.watsup:25.1-26.15 + def {externval : externval, externval'* : externval*} mems([externval] :: externval'*{externval'}) = $mems(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:73.1-73.48 +;; 7-module.watsup:29.1-29.83 +def instexport : (funcaddr*, globaladdr*, tableaddr*, memaddr*, export) -> exportinst + ;; 7-module.watsup:30.1-30.95 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, FUNC_externuse(x))) = {NAME name, VALUE FUNC_externval(fa*{fa}[x])} + ;; 7-module.watsup:31.1-31.99 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, GLOBAL_externuse(x))) = {NAME name, VALUE GLOBAL_externval(ga*{ga}[x])} + ;; 7-module.watsup:32.1-32.97 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, TABLE_externuse(x))) = {NAME name, VALUE TABLE_externval(ta*{ta}[x])} + ;; 7-module.watsup:33.1-33.93 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, MEM_externuse(x))) = {NAME name, VALUE MEM_externval(ma*{ma}[x])} + +;; 7-module.watsup:36.1-36.60 +def allocfunc : (store, moduleinst, func) -> (store, funcaddr) + ;; 7-module.watsup:37.1-38.37 + def {fi : funcinst, func : func, m : moduleinst, s : store} allocfunc(s, m, func) = (s[FUNC_store =.. [fi]], |s.FUNC_store|) + -- if (fi = {MODULE m, CODE func}) + +;; 7-module.watsup:40.1-40.63 rec { -;; 7-module.watsup:73.1-73.48 -def alloc_mem : (state, mem*) -> (store, memaddr*) - ;; 7-module.watsup:75.1-75.47 - def {f : frame, s : store} alloc_mem(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:77.1-83.54 - def {f : frame, i : nat, j? : nat?, ma : memaddr, ma'* : memaddr*, mem : mem, mem'* : mem*, memtype : memtype, mi : meminst, s : store, s_new : store, s_res : store} alloc_mem(`%;%`(s, f), [mem] :: mem'*{mem'}) = (s_res, [ma] :: ma'*{ma'}) - -- if (mem = MEMORY(memtype)) - -- if (memtype = `%I8`(`[%..%?]`(i, j?{j}))) - -- if (mi = {TYPE memtype, DATA 0^((i * 64) * $Ki){}}) - -- if (ma = |$meminst(`%;%`(s, f))|) - -- if (s_new = s[MEM_store =.. [mi]]) - -- if ((s_res, ma'*{ma'}) = $alloc_mem(`%;%`(s_new, f), mem'*{mem'})) +;; 7-module.watsup:40.1-40.63 +def allocfuncs : (store, moduleinst, func*) -> (store, funcaddr*) + ;; 7-module.watsup:41.1-41.46 + def {m : moduleinst, s : store} allocfuncs(s, m, []) = (s, []) + ;; 7-module.watsup:42.1-44.50 + def {fa : funcaddr, fa'* : funcaddr*, func : func, func'* : func*, m : moduleinst, s : store, s_1 : store, s_2 : store} allocfuncs(s, m, [func] :: func'*{func'}) = (s_2, [fa] :: fa'*{fa'}) + -- if ((s_1, fa) = $allocfunc(s, m, func)) + -- if ((s_2, fa'*{fa'}) = $allocfuncs(s_1, m, func'*{func'})) } -;; 7-module.watsup:86.1-86.51 +;; 7-module.watsup:46.1-46.63 +def allocglobal : (store, globaltype, val) -> (store, globaladdr) + ;; 7-module.watsup:47.1-48.44 + def {gi : globalinst, globaltype : globaltype, s : store, val : val} allocglobal(s, globaltype, val) = (s[GLOBAL_store =.. [gi]], |s.GLOBAL_store|) + -- if (gi = {TYPE globaltype, VALUE val}) + +;; 7-module.watsup:50.1-50.67 rec { -;; 7-module.watsup:86.1-86.51 -def alloc_elem : (state, elem*) -> (store, elemaddr*) - ;; 7-module.watsup:88.1-88.48 - def {f : frame, s : store} alloc_elem(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:90.1-96.56 - def {ea : elemaddr, ea'* : elemaddr*, ei : eleminst, elem : elem, elem'* : elem*, elemmode? : elemmode?, f : frame, instr** : instr**, ref* : ref*, reftype : reftype, s : store, s_new : store, s_res : store} alloc_elem(`%;%`(s, f), [elem] :: elem'*{elem'}) = (s_res, [ea] :: ea'*{ea'}) - -- if (elem = `ELEM%%*%?`(reftype, instr*{instr}*{instr}, elemmode?{elemmode})) - -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr}), [$admininstr_ref(ref)]))*{instr ref} - -- if (ei = {TYPE reftype, ELEM ref*{ref}}) - -- if (ea = |$eleminst(`%;%`(s, f))|) - -- if (s_new = s[ELEM_store =.. [ei]]) - -- if ((s_res, ea'*{ea'}) = $alloc_elem(`%;%`(s_new, f), elem'*{elem'})) +;; 7-module.watsup:50.1-50.67 +def allocglobals : (store, globaltype*, val*) -> (store, globaladdr*) + ;; 7-module.watsup:51.1-51.54 + def {s : store} allocglobals(s, [], []) = (s, []) + ;; 7-module.watsup:52.1-54.62 + def {ga : globaladdr, ga'* : globaladdr*, globaltype : globaltype, globaltype'* : globaltype*, s : store, s_1 : store, s_2 : store, val : val, val'* : val*} allocglobals(s, [globaltype] :: globaltype'*{globaltype'}, [val] :: val'*{val'}) = (s_2, [ga] :: ga'*{ga'}) + -- if ((s_1, ga) = $allocglobal(s, globaltype, val)) + -- if ((s_2, ga'*{ga'}) = $allocglobals(s_1, globaltype'*{globaltype'}, val'*{val'})) } -;; 7-module.watsup:99.1-99.51 +;; 7-module.watsup:56.1-56.55 +def alloctable : (store, tabletype) -> (store, tableaddr) + ;; 7-module.watsup:57.1-58.59 + def {i : nat, j : nat, rt : reftype, s : store, ti : tableinst} alloctable(s, `%%`(`[%..%]`(i, j), rt)) = (s[TABLE_store =.. [ti]], |s.TABLE_store|) + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM REF.NULL_ref(rt)^i{}}) + +;; 7-module.watsup:60.1-60.58 rec { -;; 7-module.watsup:99.1-99.51 -def alloc_data : (state, data*) -> (store, dataaddr*) - ;; 7-module.watsup:101.1-101.48 - def {f : frame, s : store} alloc_data(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:103.1-108.56 - def {byte* : byte*, da : dataaddr, da'* : dataaddr*, data : data, data'* : data*, datamode? : datamode?, di : datainst, f : frame, s : store, s_new : store, s_res : store} alloc_data(`%;%`(s, f), [data] :: data'*{data'}) = (s_res, [da] :: da'*{da'}) - -- if (data = `DATA%*%?`(byte*{byte}, datamode?{datamode})) - -- if (di = {DATA byte*{byte}}) - -- if (da = |$datainst(`%;%`(s, f))|) - -- if (s_new = s[DATA_store =.. [di]]) - -- if ((s_res, da'*{da'}) = $alloc_data(`%;%`(s_new, f), data'*{data'})) +;; 7-module.watsup:60.1-60.58 +def alloctables : (store, tabletype*) -> (store, tableaddr*) + ;; 7-module.watsup:61.1-61.44 + def {s : store} alloctables(s, []) = (s, []) + ;; 7-module.watsup:62.1-64.53 + def {s : store, s_1 : store, s_2 : store, ta : tableaddr, ta'* : tableaddr*, tabletype : tabletype, tabletype'* : tabletype*} alloctables(s, [tabletype] :: tabletype'*{tabletype'}) = (s_2, [ta] :: ta'*{ta'}) + -- if ((s_1, ta) = $alloctable(s, tabletype)) + -- if ((s_2, ta'*{ta'}) = $alloctables(s_1, tabletype'*{tabletype'})) } -;; 7-module.watsup:111.1-111.62 +;; 7-module.watsup:66.1-66.49 +def allocmem : (store, memtype) -> (store, memaddr) + ;; 7-module.watsup:67.1-68.62 + def {i : nat, j : nat, mi : meminst, s : store} allocmem(s, `%I8`(`[%..%]`(i, j))) = (s[MEM_store =.. [mi]], |s.MEM_store|) + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA 0^((i * 64) * $Ki){}}) + +;; 7-module.watsup:70.1-70.52 rec { -;; 7-module.watsup:111.1-111.62 -def replace_moduleinst : (store, funcaddr*, moduleinst) -> store - ;; 7-module.watsup:113.1-113.43 - def {m : moduleinst, s : store} replace_moduleinst(s, [], m) = s - ;; 7-module.watsup:115.1-117.52 - def {fa : funcaddr, fa'* : funcaddr*, m : moduleinst, s : store, s_new : store, s_res : store} replace_moduleinst(s, [fa] :: fa'*{fa'}, m) = s_res - -- if (s_new = s[FUNC_store[fa].MODULE_funcinst = m]) - -- if (s_res = $replace_moduleinst(s_new, fa'*{fa'}, m)) +;; 7-module.watsup:70.1-70.52 +def allocmems : (store, memtype*) -> (store, memaddr*) + ;; 7-module.watsup:71.1-71.42 + def {s : store} allocmems(s, []) = (s, []) + ;; 7-module.watsup:72.1-74.49 + def {ma : memaddr, ma'* : memaddr*, memtype : memtype, memtype'* : memtype*, s : store, s_1 : store, s_2 : store} allocmems(s, [memtype] :: memtype'*{memtype'}) = (s_2, [ma] :: ma'*{ma'}) + -- if ((s_1, ma) = $allocmem(s, memtype)) + -- if ((s_2, ma'*{ma'}) = $allocmems(s_1, memtype'*{memtype'})) } -;; 7-module.watsup:120.1-120.51 -def alloc_export : (moduleinst, export) -> exportinst - ;; 7-module.watsup:122.1-126.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = FUNC_externuse(x)) - -- if (externval = FUNC_externval(m.FUNC_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - ;; 7-module.watsup:128.1-132.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = GLOBAL_externuse(x)) - -- if (externval = GLOBAL_externval(m.GLOBAL_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - ;; 7-module.watsup:134.1-138.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = TABLE_externuse(x)) - -- if (externval = TABLE_externval(m.TABLE_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - ;; 7-module.watsup:140.1-144.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = MEM_externuse(x)) - -- if (externval = MEM_externval(m.MEM_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - -;; 7-module.watsup:147.1-147.67 -def alloc_module : (store, module, externval*) -> (store, moduleinst) - ;; 7-module.watsup:149.1-163.56 - def {da* : dataaddr*, data* : data*, ea* : elemaddr*, elem* : elem*, export* : export*, externval* : externval*, f : frame, fa* : funcaddr*, func* : func*, ga* : globaladdr*, global* : global*, import* : import*, m_ex : moduleinst, m_im : moduleinst, m_init : moduleinst, m_res : moduleinst, ma* : memaddr*, mem* : mem*, module : module, s : store, s_data : store, s_elem : store, s_func : store, s_global : store, s_mem : store, s_res : store, s_table : store, start? : start?, ta* : tableaddr*, table* : table*, xi* : exportinst*} alloc_module(s, module, externval*{externval}) = (s_res, m_res) - -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) - -- if (m_init = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) - -- if (m_im = $alloc_import(m_init, import*{import}, externval*{externval})) - -- if (f = {LOCAL [], MODULE m_im}) - -- if ((s_func, fa*{fa}) = $alloc_func(`%;%`(s, f), func*{func})) - -- if ((s_global, ga*{ga}) = $alloc_global(`%;%`(s_func, f), global*{global})) - -- if ((s_table, ta*{ta}) = $alloc_table(`%;%`(s_global, f), table*{table})) - -- if ((s_mem, ma*{ma}) = $alloc_mem(`%;%`(s_table, f), mem*{mem})) - -- if ((s_elem, ea*{ea}) = $alloc_elem(`%;%`(s_mem, f), elem*{elem})) - -- if ((s_data, da*{da}) = $alloc_data(`%;%`(s_elem, f), data*{data})) - -- if (m_ex = m_im ++ {FUNC fa*{fa}, GLOBAL ga*{ga}, TABLE ta*{ta}, MEM ma*{ma}, ELEM ea*{ea}, DATA da*{da}, EXPORT []}) - -- if (xi*{xi} = $alloc_export(m_ex, export)*{export}) - -- if (m_res = m_ex[EXPORT_moduleinst = xi*{xi}]) - -- if (s_res = $replace_moduleinst(s_data, fa*{fa}, m_res)) - -;; 7-module.watsup:166.1-166.41 +;; 7-module.watsup:76.1-76.57 +def allocelem : (store, reftype, ref*) -> (store, elemaddr) + ;; 7-module.watsup:77.1-78.36 + def {ei : eleminst, ref* : ref*, rt : reftype, s : store} allocelem(s, rt, ref*{ref}) = (s[ELEM_store =.. [ei]], |s.ELEM_store|) + -- if (ei = {TYPE rt, ELEM ref*{ref}}) + +;; 7-module.watsup:80.1-80.63 rec { -;; 7-module.watsup:166.1-166.41 -def run_elem : (state, elem*, idx) -> state - ;; 7-module.watsup:168.1-168.41 - def {f : frame, i : nat, s : store} run_elem(`%;%`(s, f), [], i) = `%;%`(s, f) - ;; 7-module.watsup:170.1-172.59 - def {elem : elem, elem'* : elem*, expr* : expr*, f : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) - -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?())) - -- if ($run_elem(`%;%`(s, f), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:174.1-179.67 - def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, reftype : reftype, s : store, s_new : store, s_res : store, x : idx} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) - -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) - -- if (n = |expr*{expr}|) - -- if (elemmode = TABLE_elemmode(x, instr*{instr})) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, i) ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) - -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:181.1-185.67 - def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_new : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) - -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) - -- if (elemmode = DECLARE_elemmode) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), [ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) - -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) +;; 7-module.watsup:80.1-80.63 +def allocelems : (store, reftype*, ref**) -> (store, elemaddr*) + ;; 7-module.watsup:81.1-81.52 + def {s : store} allocelems(s, [], []) = (s, []) + ;; 7-module.watsup:82.1-84.53 + def {ea : elemaddr, ea'* : elemaddr*, ref* : ref*, ref'** : ref**, rt : reftype, rt'* : reftype*, s : store, s_1 : store, s_2 : store} allocelems(s, [rt] :: rt'*{rt'}, [ref]*{ref} :: ref'*{ref'}*{ref'}) = (s_2, [ea] :: ea'*{ea'}) + -- if ((s_1, ea) = $allocelem(s, rt, ref*{ref})) + -- if ((s_2, ea'*{ea'}) = $allocelems(s_2, rt'*{rt'}, ref'*{ref'}*{ref'})) } -;; 7-module.watsup:188.1-188.41 +;; 7-module.watsup:86.1-86.49 +def allocdata : (store, byte*) -> (store, dataaddr) + ;; 7-module.watsup:87.1-88.28 + def {byte* : byte*, di : datainst, s : store} allocdata(s, byte*{byte}) = (s[DATA_store =.. [di]], |s.DATA_store|) + -- if (di = {DATA byte*{byte}}) + +;; 7-module.watsup:90.1-90.52 rec { -;; 7-module.watsup:188.1-188.41 -def run_data : (state, data*, idx) -> state - ;; 7-module.watsup:190.1-190.41 - def {f : frame, i : nat, s : store} run_data(`%;%`(s, f), [], i) = `%;%`(s, f) - ;; 7-module.watsup:192.1-194.59 - def {byte* : byte*, data : data, data'* : data*, f : frame, f_res : frame, i : nat, s : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) - -- if (data = `DATA%*%?`(byte*{byte}, ?())) - -- if ($run_data(`%;%`(s, f), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:196.1-201.67 - def {byte* : byte*, data : data, data'* : data*, datamode : datamode, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, s : store, s_new : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) - -- if (data = `DATA%*%?`(byte*{byte}, ?(datamode))) +;; 7-module.watsup:90.1-90.52 +def allocdatas : (store, byte**) -> (store, dataaddr*) + ;; 7-module.watsup:91.1-91.43 + def {s : store} allocdatas(s, []) = (s, []) + ;; 7-module.watsup:92.1-94.48 + def {byte* : byte*, byte'** : byte**, da : dataaddr, da'* : dataaddr*, s : store, s_1 : store, s_2 : store} allocdatas(s, [byte]*{byte} :: byte'*{byte'}*{byte'}) = (s_2, [da] :: da'*{da'}) + -- if ((s_1, da) = $allocdata(s, byte*{byte})) + -- if ((s_2, da'*{da'}) = $allocdatas(s_1, byte'*{byte'}*{byte'})) +} + +;; 7-module.watsup:97.1-97.81 +def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) + ;; 7-module.watsup:98.1-135.54 + def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i : nat, import* : import*, m : moduleinst, ma* : memaddr*, ma_ex* : memaddr*, memtype^n_mem : memtype^n_mem, module : module, n_data : n, n_elem : n, n_func : n, n_global : n, n_mem : n, n_table : n, ref** : ref**, rt^n_elem : reftype^n_elem, s : store, s_1 : store, s_2 : store, s_3 : store, s_4 : store, s_5 : store, s_6 : store, start? : start?, ta* : tableaddr*, ta_ex* : tableaddr*, tabletype^n_table : tabletype^n_table, val* : val*, xi* : exportinst*} allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref}) = (s_6, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func^n_func{func}, GLOBAL(globaltype, expr_1)^n_global{expr_1 globaltype}, TABLE(tabletype)^n_table{tabletype}, MEMORY(memtype)^n_mem{memtype}, `ELEM%%*%?`(rt, expr_2*{expr_2}, elemmode?{elemmode})^n_elem{elemmode expr_2 rt}, `DATA%*%?`(byte*{byte}, datamode?{datamode})^n_data{byte datamode}, start?{start}, export*{export})) + -- if (fa_ex*{fa_ex} = $funcs(externval*{externval})) + -- if (ga_ex*{ga_ex} = $globals(externval*{externval})) + -- if (ta_ex*{ta_ex} = $tables(externval*{externval})) + -- if (ma_ex*{ma_ex} = $mems(externval*{externval})) + -- if (fa*{fa} = (|s.FUNC_store| + i)^(i instr* + ;; 7-module.watsup:139.1-139.46 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?()), i) = [] + ;; 7-module.watsup:140.1-140.62 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(DECLARE_elemmode)), i) = [ELEM.DROP_instr(i)] + ;; 7-module.watsup:141.1-143.20 + def {expr* : expr*, i : nat, instr* : instr*, n : n, reftype : reftype, x : idx} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(TABLE_elemmode(x, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) TABLE.INIT_instr(x, i) ELEM.DROP_instr(i)] + -- if (n = |expr*{expr}|) + +;; 7-module.watsup:145.1-145.33 +def rundata : (data, idx) -> instr* + ;; 7-module.watsup:146.1-146.38 + def {byte* : byte*, i : nat} rundata(`DATA%*%?`(byte*{byte}, ?()), i) = [] + ;; 7-module.watsup:147.1-149.20 + def {byte* : byte*, i : nat, instr* : instr*, n : n} rundata(`DATA%*%?`(byte*{byte}, ?(MEMORY_datamode(0, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) MEMORY.INIT_instr(i) DATA.DROP_instr(i)] -- if (n = |byte*{byte}|) - -- if (datamode = MEMORY_datamode(0, instr*{instr})) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(i) DATA.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) - -- if ($run_data(`%;%`(s_new, f_new), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) + +;; 7-module.watsup:152.1-152.36 +rec { + +;; 7-module.watsup:152.1-152.36 +def concat_instr : instr** -> instr* + ;; 7-module.watsup:153.1-153.37 + def concat_instr([]) = [] + ;; 7-module.watsup:154.1-154.68 + def {instr* : instr*, instr'** : instr**} concat_instr([instr]*{instr} :: instr'*{instr'}*{instr'}) = instr*{instr} :: $concat_instr(instr'*{instr'}*{instr'}) } -;; 7-module.watsup:206.1-206.68 -def instantiation : (store, module, externval*) -> (store, moduleinst) - ;; 7-module.watsup:208.1-213.61 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) - -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(), export*{export})) - -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) - -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) - -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:215.1-222.62 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) - -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(start), export*{export})) - -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) +;; 7-module.watsup:157.1-157.55 +def instantiation : (store, module, externval*) -> config + ;; 7-module.watsup:158.1-180.28 + def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i : nat, import* : import*, instr_1** : instr**, instr_2*** : instr***, instr_data* : instr*, instr_elem* : instr*, j : nat, m : moduleinst, m_init : moduleinst, mem* : mem*, module : module, n_data : n, n_elem : n, ref** : ref**, reftype* : reftype*, s : store, s' : store, start? : start?, table* : table*, val* : val*, x? : idx?} instantiation(s, module, externval*{externval}) = `%;%*`(`%;%`(s', f), $admininstr_instr(instr_elem)*{instr_elem} :: $admininstr_instr(instr_data)*{instr_data} :: CALL_admininstr(x)?{x}) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) + -- if (m_init = {FUNC $funcs(externval*{externval}), GLOBAL $globals(externval*{externval}), TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f_init = {LOCAL [], MODULE m_init}) + -- (if (global = GLOBAL(globaltype, instr_1*{instr_1})))*{global globaltype instr_1} + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_1)*{instr_1}), [$admininstr_val(val)]))*{instr_1 val} + -- (if (elem = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})))*{elem elemmode instr_2 reftype} + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_2)*{instr_2}), [$admininstr_ref(ref)]))*{instr_2 ref}*{instr_2 ref} + -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) - -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_data, f_data)) - -- if (start = START(x)) - -- Step: `%~>%`(`%;%*`(`%;%`(s_data, f_data), [CALL_admininstr(x)]), `%;%*`(`%;%`(s_res, f_res), [])) - -;; 7-module.watsup:227.1-227.55 -def invocation : (store, funcaddr, val*) -> (store, val*) - ;; 7-module.watsup:229.1-236.55 - def {expr : expr, f : frame, f' : frame, fa : funcaddr, functype : functype, m : moduleinst, s : store, s' : store, val* : val*, val'* : val*, valtype* : valtype*, valtype'* : valtype*} invocation(s, fa, val*{val}) = (s', val'*{val'}) + -- if (n_elem = |elem*{elem}|) + -- if (instr_elem*{instr_elem} = $concat_instr($runelem(elem*{elem}[i], i)^(i config + ;; 7-module.watsup:184.1-196.52 + def {expr : expr, f : frame, fa : funcaddr, functype : functype, k : nat, m : moduleinst, n : n, s : store, val^n : val^n, valtype* : valtype*, valtype_param^n : valtype^n, valtype_res^k : valtype^k} invocation(s, fa, val^n{val}) = `%;%*`(`%;%`(s, f), $admininstr_val(val)^n{val} :: [CALL_ADDR_admininstr(fa)]) -- if (m = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) -- if (f = {LOCAL [], MODULE m}) -- if ($funcinst(`%;%`(s, f))[fa].CODE_funcinst = `FUNC%%*%`(functype, valtype*{valtype}, expr)) - -- if (functype = `%->%`(valtype*{valtype}, valtype'*{valtype'})) - -- if (|val*{val}| = |valtype*{valtype}|) - -- if (|val'*{val'}| = |valtype'*{valtype'}|) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_val(val)*{val} :: [CALL_ADDR_admininstr(fa)]), `%;%*`(`%;%`(s', f'), $admininstr_val(val')*{val'})) + -- if (functype = `%->%`(valtype_param^n{valtype_param}, valtype_res^k{valtype_res})) == IL Validation... == Running pass animate @@ -12379,8 +12321,8 @@ def valtype_fn : fn -> valtype ;; 1-syntax.watsup:56.1-57.11 syntax resulttype = valtype* -;; 1-syntax.watsup:59.1-60.17 -syntax limits = `[%..%?]`(u32, u32?) +;; 1-syntax.watsup:59.1-60.16 +syntax limits = `[%..%]`(u32, u32) ;; 1-syntax.watsup:61.1-62.15 syntax globaltype = `MUT%?%`(()?, valtype) @@ -12674,7 +12616,7 @@ syntax context = {FUNC functype*, GLOBAL globaltype*, TABLE tabletype*, MEM memt relation Limits_ok: `|-%:%`(limits, nat) ;; 3-typing.watsup:22.1-24.24 rule _ {k : nat, n_1 : n, n_2 : n}: - `|-%:%`(`[%..%?]`(n_1, ?(n_2)), k) + `|-%:%`(`[%..%]`(n_1, n_2), k) -- if ((n_1 <= n_2) /\ (n_2 <= k)) ;; 3-typing.watsup:15.1-15.64 @@ -12747,7 +12689,7 @@ relation Resulttype_sub: `|-%*<:%*`(valtype*, valtype*) relation Limits_sub: `|-%<:%`(limits, limits) ;; 3-typing.watsup:83.1-86.21 rule _ {n_11 : n, n_12 : n, n_21 : n, n_22 : n}: - `|-%<:%`(`[%..%?]`(n_11, ?(n_12)), `[%..%?]`(n_21, ?(n_22))) + `|-%<:%`(`[%..%]`(n_11, n_12), `[%..%]`(n_21, n_22)) -- if (n_11 >= n_21) -- if (n_12 <= n_22) @@ -13405,10 +13347,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:180.1-187.5 +;; 4-runtime.watsup:183.1-190.5 rec { -;; 4-runtime.watsup:180.1-187.5 +;; 4-runtime.watsup:183.1-190.5 syntax admininstr = | UNREACHABLE | NOP @@ -13632,26 +13574,30 @@ def with_data : (state, dataidx, byte*) -> state ;; 4-runtime.watsup:165.1-165.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:167.1-167.49 -def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:169.1-172.57 - def {i : nat, i' : nat, j? : nat?, n : n, r : ref, r'* : ref*, reftype : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' - -- if (ti = {TYPE `%%`(`[%..%?]`(i, j?{j}), reftype), ELEM r'*{r'}}) +;; 4-runtime.watsup:167.1-167.63 +def grow_table : (tableinst, nat, ref) -> tableinst? + ;; 4-runtime.watsup:170.1-174.36 + def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, rt : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ?(ti') + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM r'*{r'}}) -- if (i' = (|r'*{r'}| + n)) - -- if (ti' = {TYPE `%%`(`[%..%?]`(i', j?{j}), reftype), ELEM r'*{r'} :: r^n{}}) + -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), rt), ELEM r'*{r'} :: r^n{}}) + -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) + def {x : (tableinst, nat, ref)} grow_table(x) = ?() -;; 4-runtime.watsup:168.1-168.41 -def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:173.1-176.66 - def {b* : byte*, i : nat, i' : nat, j? : nat?, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' - -- if (mi = {TYPE `%I8`(`[%..%?]`(i, j?{j})), DATA b*{b}}) +;; 4-runtime.watsup:168.1-168.55 +def grow_memory : (meminst, nat) -> meminst? + ;; 4-runtime.watsup:175.1-179.34 + def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = ?(mi') + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) - -- if (mi' = {TYPE `%I8`(`[%..%?]`(i', j?{j})), DATA b*{b} :: 0^((n * 64) * $Ki){}}) + -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: 0^((n * 64) * $Ki){}}) + -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) + def {x : (meminst, nat)} grow_memory(x) = ?() -;; 4-runtime.watsup:189.1-192.21 +;; 4-runtime.watsup:192.1-195.21 rec { -;; 4-runtime.watsup:189.1-192.21 +;; 4-runtime.watsup:192.1-195.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -13888,140 +13834,140 @@ relation Step_read: `%~>%*`(config, admininstr*) `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) -- where n = |$table(z, x).ELEM_tableinst| - ;; 6-reduction.watsup:214.1-216.39 + ;; 6-reduction.watsup:212.1-214.39 rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) -- if ((i + n) > |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:218.1-221.14 + ;; 6-reduction.watsup:216.1-219.14 rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:223.1-227.15 + ;; 6-reduction.watsup:221.1-225.15 rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) -- otherwise - ;; 6-reduction.watsup:230.1-232.73 + ;; 6-reduction.watsup:228.1-230.73 rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$table(z, y).ELEM_tableinst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:234.1-237.14 + ;; 6-reduction.watsup:232.1-235.14 rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:239.1-244.15 + ;; 6-reduction.watsup:237.1-242.15 rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:246.1-250.15 + ;; 6-reduction.watsup:244.1-248.15 rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) -- otherwise - ;; 6-reduction.watsup:253.1-255.72 + ;; 6-reduction.watsup:251.1-253.72 rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) -- if (((i + n) > |$elem(z, y).ELEM_eleminst|) \/ ((j + n) > |$table(z, x).ELEM_tableinst|)) - ;; 6-reduction.watsup:257.1-260.14 + ;; 6-reduction.watsup:255.1-258.14 rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:262.1-266.15 + ;; 6-reduction.watsup:260.1-264.15 rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) $admininstr_ref($elem(z, y).ELEM_eleminst[i]) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) -- otherwise -- if (i < |$elem(z, y).ELEM_eleminst|) - ;; 6-reduction.watsup:273.1-275.53 + ;; 6-reduction.watsup:271.1-273.53 rule load-num-trap {i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [TRAP_admininstr]) -- where ?(o0) = $size($valtype_numtype(nt)) -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:277.1-279.71 + ;; 6-reduction.watsup:275.1-277.71 rule load-num-val {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?(), n_A, n_O)]), [CONST_admininstr(nt, c)]) -- where ?(o0) = $size($valtype_numtype(nt)) -- where ?(o1) = $size($valtype_numtype(nt)) -- where $bytes_(o0, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (o1 / 8)] - ;; 6-reduction.watsup:281.1-283.45 + ;; 6-reduction.watsup:279.1-281.45 rule load-pack-trap {i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [TRAP_admininstr]) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:285.1-287.55 + ;; 6-reduction.watsup:283.1-285.55 rule load-pack-val {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, sx : sx, z : state, o0 : nat}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) LOAD_admininstr(nt, ?((n, sx)), n_A, n_O)]), [CONST_admininstr(nt, $ext(n, o0, sx, c))]) -- where ?(o0) = $size($valtype_numtype(nt)) -- where $bytes_(n, c) = $mem(z, 0).DATA_meminst[(i + n_O) : (n / 8)] - ;; 6-reduction.watsup:307.1-309.44 + ;; 6-reduction.watsup:305.1-307.44 rule memory.size {n : n, z : state}: `%~>%*`(`%;%*`(z, [MEMORY.SIZE_admininstr]), [CONST_admininstr(I32_numtype, n)]) -- where ((n * 64) * $Ki) = |$mem(z, 0).DATA_meminst| - ;; 6-reduction.watsup:322.1-324.37 + ;; 6-reduction.watsup:318.1-320.37 rule memory.fill-trap {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [TRAP_admininstr]) -- if ((i + n) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:326.1-329.14 + ;; 6-reduction.watsup:322.1-325.14 rule memory.fill-zero {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:331.1-335.15 + ;; 6-reduction.watsup:327.1-331.15 rule memory.fill-succ {i : nat, n : n, val : val, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_val(val) CONST_admininstr(I32_numtype, n) MEMORY.FILL_admininstr]), [CONST_admininstr(I32_numtype, i) $admininstr_val(val) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (i + 1)) $admininstr_val(val) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.FILL_admininstr]) -- otherwise - ;; 6-reduction.watsup:338.1-340.69 + ;; 6-reduction.watsup:334.1-336.69 rule memory.copy-trap {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [TRAP_admininstr]) -- if (((i + n) > |$mem(z, 0).DATA_meminst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:342.1-345.14 + ;; 6-reduction.watsup:338.1-341.14 rule memory.copy-zero {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:347.1-352.15 + ;; 6-reduction.watsup:343.1-348.15 rule memory.copy-le {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise -- if (j <= i) - ;; 6-reduction.watsup:354.1-358.15 + ;; 6-reduction.watsup:350.1-354.15 rule memory.copy-gt {i : nat, j : nat, n : n, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.COPY_admininstr]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) LOAD_admininstr(I32_numtype, ?((8, U_sx)), 0, 0) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.COPY_admininstr]) -- otherwise - ;; 6-reduction.watsup:361.1-363.70 + ;; 6-reduction.watsup:357.1-359.70 rule memory.init-trap {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [TRAP_admininstr]) -- if (((i + n) > |$data(z, x).DATA_datainst|) \/ ((j + n) > |$mem(z, 0).DATA_meminst|)) - ;; 6-reduction.watsup:365.1-368.14 + ;; 6-reduction.watsup:361.1-364.14 rule memory.init-zero {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), []) -- otherwise -- if (n = 0) - ;; 6-reduction.watsup:370.1-374.15 + ;; 6-reduction.watsup:366.1-370.15 rule memory.init-succ {i : nat, j : nat, n : n, x : idx, z : state}: `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(x)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, $data(z, x).DATA_datainst[i]) STORE_admininstr(I32_numtype, ?(8), 0, 0) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) MEMORY.INIT_admininstr(x)]) -- otherwise @@ -14057,331 +14003,319 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) $admininstr_ref(ref) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) -- if (i < |$table(z, x).ELEM_tableinst|) - ;; 6-reduction.watsup:204.1-208.36 - rule table.grow-succeed {n : n, ref : ref, ti : tableinst, ti' : tableinst, x : idx, z : state}: - `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti'), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) - -- where ti = $table(z, x) - -- where ti' = $grow_table(ti, n, ref) - -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) + ;; 6-reduction.watsup:204.1-206.47 + rule table.grow-succeed {n : n, ref : ref, ti : tableinst, x : idx, z : state, o0 : tableinst}: + `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableinst(z, x, ti), [CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)])) + -- where ?(o0) = $grow_table($table(z, x), n, ref) + -- where ti = o0 - ;; 6-reduction.watsup:210.1-211.64 + ;; 6-reduction.watsup:208.1-209.64 rule table.grow-fail {n : n, ref : ref, x : idx, z : state}: `%~>%`(`%;%*`(z, [$admininstr_ref(ref) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:269.1-270.59 + ;; 6-reduction.watsup:267.1-268.59 rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - ;; 6-reduction.watsup:290.1-292.53 + ;; 6-reduction.watsup:288.1-290.53 rule store-num-trap {c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- where ?(o0) = $size($valtype_numtype(nt)) -- if (((i + n_O) + (o0 / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:294.1-296.35 + ;; 6-reduction.watsup:292.1-294.35 rule store-num-val {b* : byte*, c : c_numtype, i : nat, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat, o1 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (o0 / 8), b*{b}), [])) -- where ?(o0) = $size($valtype_numtype(nt)) -- where ?(o1) = $size($valtype_numtype(nt)) -- where b*{b} = $bytes_(o1, c) - ;; 6-reduction.watsup:298.1-300.45 + ;; 6-reduction.watsup:296.1-298.45 rule store-pack-trap {c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`(z, [TRAP_admininstr])) -- if (((i + n_O) + (n / 8)) > |$mem(z, 0).DATA_meminst|) - ;; 6-reduction.watsup:302.1-304.50 + ;; 6-reduction.watsup:300.1-302.50 rule store-pack-val {b* : byte*, c : c_numtype, i : nat, n : n, n_A : n, n_O : n, nt : numtype, z : state, o0 : nat}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CONST_admininstr(nt, c) STORE_admininstr(nt, ?(n), n_A, n_O)]), `%;%*`($with_mem(z, 0, (i + n_O), (n / 8), b*{b}), [])) -- where ?(o0) = $size($valtype_numtype(nt)) -- where b*{b} = $bytes_(n, $wrap_((o0, n), c)) - ;; 6-reduction.watsup:312.1-316.34 - rule memory.grow-succeed {mi : meminst, mi' : meminst, n : n, z : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_meminst(z, 0, mi'), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) - -- where mi = $mem(z, 0) - -- where mi' = $grow_memory(mi, n) - -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) + ;; 6-reduction.watsup:310.1-312.41 + rule memory.grow-succeed {mi : meminst, n : n, z : state, o0 : meminst}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`($with_meminst(z, 0, mi), [CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))])) + -- where ?(o0) = $grow_memory($mem(z, 0), n) + -- where mi = o0 - ;; 6-reduction.watsup:318.1-319.59 + ;; 6-reduction.watsup:314.1-315.59 rule memory.grow-fail {n : n, z : state}: `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) MEMORY.GROW_admininstr]), `%;%*`(z, [CONST_admininstr(I32_numtype, - 1)])) - ;; 6-reduction.watsup:377.1-378.59 + ;; 6-reduction.watsup:373.1-374.59 rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) -;; 7-module.watsup:3.1-3.64 +;; 7-module.watsup:4.1-4.35 rec { -;; 7-module.watsup:3.1-3.64 -def alloc_import : (moduleinst, import*, externval*) -> moduleinst - ;; 7-module.watsup:5.1-5.43 - def {m : moduleinst} alloc_import(m, [], []) = m - ;; 7-module.watsup:7.1-12.60 - def {externtype : externtype, externval : externval, externval'* : externval*, fa : funcaddr, functype : functype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = FUNC_externtype(functype)) - -- if (externval = FUNC_externval(fa)) - -- if (m_new = m[FUNC_moduleinst =.. [fa]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) - ;; 7-module.watsup:14.1-19.60 - def {externtype : externtype, externval : externval, externval'* : externval*, ga : globaladdr, globaltype : globaltype, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = GLOBAL_externtype(globaltype)) - -- if (externval = GLOBAL_externval(ga)) - -- if (m_new = m[GLOBAL_moduleinst =.. [ga]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) - ;; 7-module.watsup:21.1-26.60 - def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, name : name, name' : name, ta : tableaddr, tabletype : tabletype} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = TABLE_externtype(tabletype)) - -- if (externval = TABLE_externval(ta)) - -- if (m_new = m[TABLE_moduleinst =.. [ta]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) - ;; 7-module.watsup:28.1-33.60 - def {externtype : externtype, externval : externval, externval'* : externval*, import : import, import'* : import*, m : moduleinst, m_new : moduleinst, m_res : moduleinst, ma : memaddr, memtype : memtype, name : name, name' : name} alloc_import(m, [import] :: import'*{import'}, [externval] :: externval'*{externval'}) = m_res - -- if (import = IMPORT(name, name', externtype)) - -- if (externtype = MEM_externtype(memtype)) - -- if (externval = MEM_externval(ma)) - -- if (m_new = m[MEM_moduleinst =.. [ma]]) - -- if (m_res = $alloc_import(m_new, import'*{import'}, externval'*{externval'})) +;; 7-module.watsup:4.1-4.35 +def funcs : externval* -> funcaddr* + ;; 7-module.watsup:5.1-5.30 + def funcs([]) = [] + ;; 7-module.watsup:6.1-6.59 + def {externval'* : externval*, fa : funcaddr} funcs([FUNC_externval(fa)] :: externval'*{externval'}) = [fa] :: $funcs(externval'*{externval'}) + ;; 7-module.watsup:7.1-8.15 + def {externval : externval, externval'* : externval*} funcs([externval] :: externval'*{externval'}) = $funcs(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:36.1-36.51 +;; 7-module.watsup:10.1-10.39 rec { -;; 7-module.watsup:36.1-36.51 -def alloc_func : (state, func*) -> (store, funcaddr*) - ;; 7-module.watsup:38.1-38.48 - def {f : frame, s : store} alloc_func(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:40.1-44.56 - def {f : frame, fa : funcaddr, fa'* : funcaddr*, fi : funcinst, func : func, func'* : func*, s : store, s_new : store, s_res : store} alloc_func(`%;%`(s, f), [func] :: func'*{func'}) = (s_res, [fa] :: fa'*{fa'}) - -- if (fi = {MODULE f.MODULE_frame, CODE func}) - -- if (fa = |$funcinst(`%;%`(s, f))|) - -- if (s_new = s[FUNC_store =.. [fi]]) - -- if ((s_res, fa'*{fa'}) = $alloc_func(`%;%`(s_new, f), func'*{func'})) +;; 7-module.watsup:10.1-10.39 +def globals : externval* -> globaladdr* + ;; 7-module.watsup:11.1-11.32 + def globals([]) = [] + ;; 7-module.watsup:12.1-12.65 + def {externval'* : externval*, ga : globaladdr} globals([GLOBAL_externval(ga)] :: externval'*{externval'}) = [ga] :: $globals(externval'*{externval'}) + ;; 7-module.watsup:13.1-14.15 + def {externval : externval, externval'* : externval*} globals([externval] :: externval'*{externval'}) = $globals(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:47.1-47.57 +;; 7-module.watsup:16.1-16.37 rec { -;; 7-module.watsup:47.1-47.57 -def alloc_global : (state, global*) -> (store, globaladdr*) - ;; 7-module.watsup:49.1-49.50 - def {f : frame, s : store} alloc_global(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:51.1-57.60 - def {f : frame, ga : globaladdr, ga'* : globaladdr*, gi : globalinst, global : global, global'* : global*, globaltype : globaltype, instr* : instr*, s : store, s_new : store, s_res : store, val : val} alloc_global(`%;%`(s, f), [global] :: global'*{global'}) = (s_res, [ga] :: ga'*{ga'}) - -- if (global = GLOBAL(globaltype, instr*{instr})) - -- Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr}), [$admininstr_val(val)]) - -- if (gi = {TYPE globaltype, VALUE val}) - -- if (ga = |$globalinst(`%;%`(s, f))|) - -- if (s_new = s[GLOBAL_store =.. [gi]]) - -- if ((s_res, ga'*{ga'}) = $alloc_global(`%;%`(s_new, f), global'*{global'})) +;; 7-module.watsup:16.1-16.37 +def tables : externval* -> tableaddr* + ;; 7-module.watsup:17.1-17.31 + def tables([]) = [] + ;; 7-module.watsup:18.1-18.62 + def {externval'* : externval*, ta : tableaddr} tables([TABLE_externval(ta)] :: externval'*{externval'}) = [ta] :: $tables(externval'*{externval'}) + ;; 7-module.watsup:19.1-20.15 + def {externval : externval, externval'* : externval*} tables([externval] :: externval'*{externval'}) = $tables(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:60.1-60.54 +;; 7-module.watsup:22.1-22.33 rec { -;; 7-module.watsup:60.1-60.54 -def alloc_table : (state, table*) -> (store, tableaddr*) - ;; 7-module.watsup:62.1-62.49 - def {f : frame, s : store} alloc_table(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:64.1-70.58 - def {f : frame, i : nat, j? : nat?, reftype : reftype, s : store, s_new : store, s_res : store, ta : tableaddr, ta'* : tableaddr*, table : table, table'* : table*, tabletype : tabletype, ti : tableinst} alloc_table(`%;%`(s, f), [table] :: table'*{table'}) = (s_res, [ta] :: ta'*{ta'}) - -- if (table = TABLE(tabletype)) - -- if (tabletype = `%%`(`[%..%?]`(i, j?{j}), reftype)) - -- if (ti = {TYPE tabletype, ELEM REF.NULL_ref(reftype)^i{}}) - -- if (ta = |$tableinst(`%;%`(s, f))|) - -- if (s_new = s[TABLE_store =.. [ti]]) - -- if ((s_res, ta'*{ta'}) = $alloc_table(`%;%`(s_new, f), table'*{table'})) +;; 7-module.watsup:22.1-22.33 +def mems : externval* -> memaddr* + ;; 7-module.watsup:23.1-23.29 + def mems([]) = [] + ;; 7-module.watsup:24.1-24.56 + def {externval'* : externval*, ma : memaddr} mems([MEM_externval(ma)] :: externval'*{externval'}) = [ma] :: $mems(externval'*{externval'}) + ;; 7-module.watsup:25.1-26.15 + def {externval : externval, externval'* : externval*} mems([externval] :: externval'*{externval'}) = $mems(externval'*{externval'}) + -- otherwise } -;; 7-module.watsup:73.1-73.48 +;; 7-module.watsup:29.1-29.83 +def instexport : (funcaddr*, globaladdr*, tableaddr*, memaddr*, export) -> exportinst + ;; 7-module.watsup:30.1-30.95 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, FUNC_externuse(x))) = {NAME name, VALUE FUNC_externval(fa*{fa}[x])} + ;; 7-module.watsup:31.1-31.99 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, GLOBAL_externuse(x))) = {NAME name, VALUE GLOBAL_externval(ga*{ga}[x])} + ;; 7-module.watsup:32.1-32.97 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, TABLE_externuse(x))) = {NAME name, VALUE TABLE_externval(ta*{ta}[x])} + ;; 7-module.watsup:33.1-33.93 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, MEM_externuse(x))) = {NAME name, VALUE MEM_externval(ma*{ma}[x])} + +;; 7-module.watsup:36.1-36.60 +def allocfunc : (store, moduleinst, func) -> (store, funcaddr) + ;; 7-module.watsup:37.1-38.37 + def {fi : funcinst, func : func, m : moduleinst, s : store} allocfunc(s, m, func) = (s[FUNC_store =.. [fi]], |s.FUNC_store|) + -- if (fi = {MODULE m, CODE func}) + +;; 7-module.watsup:40.1-40.63 rec { -;; 7-module.watsup:73.1-73.48 -def alloc_mem : (state, mem*) -> (store, memaddr*) - ;; 7-module.watsup:75.1-75.47 - def {f : frame, s : store} alloc_mem(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:77.1-83.54 - def {f : frame, i : nat, j? : nat?, ma : memaddr, ma'* : memaddr*, mem : mem, mem'* : mem*, memtype : memtype, mi : meminst, s : store, s_new : store, s_res : store} alloc_mem(`%;%`(s, f), [mem] :: mem'*{mem'}) = (s_res, [ma] :: ma'*{ma'}) - -- if (mem = MEMORY(memtype)) - -- if (memtype = `%I8`(`[%..%?]`(i, j?{j}))) - -- if (mi = {TYPE memtype, DATA 0^((i * 64) * $Ki){}}) - -- if (ma = |$meminst(`%;%`(s, f))|) - -- if (s_new = s[MEM_store =.. [mi]]) - -- if ((s_res, ma'*{ma'}) = $alloc_mem(`%;%`(s_new, f), mem'*{mem'})) +;; 7-module.watsup:40.1-40.63 +def allocfuncs : (store, moduleinst, func*) -> (store, funcaddr*) + ;; 7-module.watsup:41.1-41.46 + def {m : moduleinst, s : store} allocfuncs(s, m, []) = (s, []) + ;; 7-module.watsup:42.1-44.50 + def {fa : funcaddr, fa'* : funcaddr*, func : func, func'* : func*, m : moduleinst, s : store, s_1 : store, s_2 : store} allocfuncs(s, m, [func] :: func'*{func'}) = (s_2, [fa] :: fa'*{fa'}) + -- if ((s_1, fa) = $allocfunc(s, m, func)) + -- if ((s_2, fa'*{fa'}) = $allocfuncs(s_1, m, func'*{func'})) } -;; 7-module.watsup:86.1-86.51 +;; 7-module.watsup:46.1-46.63 +def allocglobal : (store, globaltype, val) -> (store, globaladdr) + ;; 7-module.watsup:47.1-48.44 + def {gi : globalinst, globaltype : globaltype, s : store, val : val} allocglobal(s, globaltype, val) = (s[GLOBAL_store =.. [gi]], |s.GLOBAL_store|) + -- if (gi = {TYPE globaltype, VALUE val}) + +;; 7-module.watsup:50.1-50.67 rec { -;; 7-module.watsup:86.1-86.51 -def alloc_elem : (state, elem*) -> (store, elemaddr*) - ;; 7-module.watsup:88.1-88.48 - def {f : frame, s : store} alloc_elem(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:90.1-96.56 - def {ea : elemaddr, ea'* : elemaddr*, ei : eleminst, elem : elem, elem'* : elem*, elemmode? : elemmode?, f : frame, instr** : instr**, ref* : ref*, reftype : reftype, s : store, s_new : store, s_res : store} alloc_elem(`%;%`(s, f), [elem] :: elem'*{elem'}) = (s_res, [ea] :: ea'*{ea'}) - -- if (elem = `ELEM%%*%?`(reftype, instr*{instr}*{instr}, elemmode?{elemmode})) - -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr}), [$admininstr_ref(ref)]))*{instr ref} - -- if (ei = {TYPE reftype, ELEM ref*{ref}}) - -- if (ea = |$eleminst(`%;%`(s, f))|) - -- if (s_new = s[ELEM_store =.. [ei]]) - -- if ((s_res, ea'*{ea'}) = $alloc_elem(`%;%`(s_new, f), elem'*{elem'})) +;; 7-module.watsup:50.1-50.67 +def allocglobals : (store, globaltype*, val*) -> (store, globaladdr*) + ;; 7-module.watsup:51.1-51.54 + def {s : store} allocglobals(s, [], []) = (s, []) + ;; 7-module.watsup:52.1-54.62 + def {ga : globaladdr, ga'* : globaladdr*, globaltype : globaltype, globaltype'* : globaltype*, s : store, s_1 : store, s_2 : store, val : val, val'* : val*} allocglobals(s, [globaltype] :: globaltype'*{globaltype'}, [val] :: val'*{val'}) = (s_2, [ga] :: ga'*{ga'}) + -- if ((s_1, ga) = $allocglobal(s, globaltype, val)) + -- if ((s_2, ga'*{ga'}) = $allocglobals(s_1, globaltype'*{globaltype'}, val'*{val'})) } -;; 7-module.watsup:99.1-99.51 +;; 7-module.watsup:56.1-56.55 +def alloctable : (store, tabletype) -> (store, tableaddr) + ;; 7-module.watsup:57.1-58.59 + def {i : nat, j : nat, rt : reftype, s : store, ti : tableinst} alloctable(s, `%%`(`[%..%]`(i, j), rt)) = (s[TABLE_store =.. [ti]], |s.TABLE_store|) + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM REF.NULL_ref(rt)^i{}}) + +;; 7-module.watsup:60.1-60.58 rec { -;; 7-module.watsup:99.1-99.51 -def alloc_data : (state, data*) -> (store, dataaddr*) - ;; 7-module.watsup:101.1-101.48 - def {f : frame, s : store} alloc_data(`%;%`(s, f), []) = (s, []) - ;; 7-module.watsup:103.1-108.56 - def {byte* : byte*, da : dataaddr, da'* : dataaddr*, data : data, data'* : data*, datamode? : datamode?, di : datainst, f : frame, s : store, s_new : store, s_res : store} alloc_data(`%;%`(s, f), [data] :: data'*{data'}) = (s_res, [da] :: da'*{da'}) - -- if (data = `DATA%*%?`(byte*{byte}, datamode?{datamode})) - -- if (di = {DATA byte*{byte}}) - -- if (da = |$datainst(`%;%`(s, f))|) - -- if (s_new = s[DATA_store =.. [di]]) - -- if ((s_res, da'*{da'}) = $alloc_data(`%;%`(s_new, f), data'*{data'})) +;; 7-module.watsup:60.1-60.58 +def alloctables : (store, tabletype*) -> (store, tableaddr*) + ;; 7-module.watsup:61.1-61.44 + def {s : store} alloctables(s, []) = (s, []) + ;; 7-module.watsup:62.1-64.53 + def {s : store, s_1 : store, s_2 : store, ta : tableaddr, ta'* : tableaddr*, tabletype : tabletype, tabletype'* : tabletype*} alloctables(s, [tabletype] :: tabletype'*{tabletype'}) = (s_2, [ta] :: ta'*{ta'}) + -- if ((s_1, ta) = $alloctable(s, tabletype)) + -- if ((s_2, ta'*{ta'}) = $alloctables(s_1, tabletype'*{tabletype'})) } -;; 7-module.watsup:111.1-111.62 +;; 7-module.watsup:66.1-66.49 +def allocmem : (store, memtype) -> (store, memaddr) + ;; 7-module.watsup:67.1-68.62 + def {i : nat, j : nat, mi : meminst, s : store} allocmem(s, `%I8`(`[%..%]`(i, j))) = (s[MEM_store =.. [mi]], |s.MEM_store|) + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA 0^((i * 64) * $Ki){}}) + +;; 7-module.watsup:70.1-70.52 rec { -;; 7-module.watsup:111.1-111.62 -def replace_moduleinst : (store, funcaddr*, moduleinst) -> store - ;; 7-module.watsup:113.1-113.43 - def {m : moduleinst, s : store} replace_moduleinst(s, [], m) = s - ;; 7-module.watsup:115.1-117.52 - def {fa : funcaddr, fa'* : funcaddr*, m : moduleinst, s : store, s_new : store, s_res : store} replace_moduleinst(s, [fa] :: fa'*{fa'}, m) = s_res - -- if (s_new = s[FUNC_store[fa].MODULE_funcinst = m]) - -- if (s_res = $replace_moduleinst(s_new, fa'*{fa'}, m)) +;; 7-module.watsup:70.1-70.52 +def allocmems : (store, memtype*) -> (store, memaddr*) + ;; 7-module.watsup:71.1-71.42 + def {s : store} allocmems(s, []) = (s, []) + ;; 7-module.watsup:72.1-74.49 + def {ma : memaddr, ma'* : memaddr*, memtype : memtype, memtype'* : memtype*, s : store, s_1 : store, s_2 : store} allocmems(s, [memtype] :: memtype'*{memtype'}) = (s_2, [ma] :: ma'*{ma'}) + -- if ((s_1, ma) = $allocmem(s, memtype)) + -- if ((s_2, ma'*{ma'}) = $allocmems(s_1, memtype'*{memtype'})) } -;; 7-module.watsup:120.1-120.51 -def alloc_export : (moduleinst, export) -> exportinst - ;; 7-module.watsup:122.1-126.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = FUNC_externuse(x)) - -- if (externval = FUNC_externval(m.FUNC_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - ;; 7-module.watsup:128.1-132.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = GLOBAL_externuse(x)) - -- if (externval = GLOBAL_externval(m.GLOBAL_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - ;; 7-module.watsup:134.1-138.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = TABLE_externuse(x)) - -- if (externval = TABLE_externval(m.TABLE_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - ;; 7-module.watsup:140.1-144.44 - def {export : export, externuse : externuse, externval : externval, m : moduleinst, name : name, x : idx, xi : exportinst} alloc_export(m, export) = xi - -- if (export = EXPORT(name, externuse)) - -- if (externuse = MEM_externuse(x)) - -- if (externval = MEM_externval(m.MEM_moduleinst[x])) - -- if (xi = {NAME name, VALUE externval}) - -;; 7-module.watsup:147.1-147.67 -def alloc_module : (store, module, externval*) -> (store, moduleinst) - ;; 7-module.watsup:149.1-163.56 - def {da* : dataaddr*, data* : data*, ea* : elemaddr*, elem* : elem*, export* : export*, externval* : externval*, f : frame, fa* : funcaddr*, func* : func*, ga* : globaladdr*, global* : global*, import* : import*, m_ex : moduleinst, m_im : moduleinst, m_init : moduleinst, m_res : moduleinst, ma* : memaddr*, mem* : mem*, module : module, s : store, s_data : store, s_elem : store, s_func : store, s_global : store, s_mem : store, s_res : store, s_table : store, start? : start?, ta* : tableaddr*, table* : table*, xi* : exportinst*} alloc_module(s, module, externval*{externval}) = (s_res, m_res) - -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) - -- if (m_init = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) - -- if (m_im = $alloc_import(m_init, import*{import}, externval*{externval})) - -- if (f = {LOCAL [], MODULE m_im}) - -- if ((s_func, fa*{fa}) = $alloc_func(`%;%`(s, f), func*{func})) - -- if ((s_global, ga*{ga}) = $alloc_global(`%;%`(s_func, f), global*{global})) - -- if ((s_table, ta*{ta}) = $alloc_table(`%;%`(s_global, f), table*{table})) - -- if ((s_mem, ma*{ma}) = $alloc_mem(`%;%`(s_table, f), mem*{mem})) - -- if ((s_elem, ea*{ea}) = $alloc_elem(`%;%`(s_mem, f), elem*{elem})) - -- if ((s_data, da*{da}) = $alloc_data(`%;%`(s_elem, f), data*{data})) - -- if (m_ex = m_im ++ {FUNC fa*{fa}, GLOBAL ga*{ga}, TABLE ta*{ta}, MEM ma*{ma}, ELEM ea*{ea}, DATA da*{da}, EXPORT []}) - -- if (xi*{xi} = $alloc_export(m_ex, export)*{export}) - -- if (m_res = m_ex[EXPORT_moduleinst = xi*{xi}]) - -- if (s_res = $replace_moduleinst(s_data, fa*{fa}, m_res)) - -;; 7-module.watsup:166.1-166.41 +;; 7-module.watsup:76.1-76.57 +def allocelem : (store, reftype, ref*) -> (store, elemaddr) + ;; 7-module.watsup:77.1-78.36 + def {ei : eleminst, ref* : ref*, rt : reftype, s : store} allocelem(s, rt, ref*{ref}) = (s[ELEM_store =.. [ei]], |s.ELEM_store|) + -- if (ei = {TYPE rt, ELEM ref*{ref}}) + +;; 7-module.watsup:80.1-80.63 rec { -;; 7-module.watsup:166.1-166.41 -def run_elem : (state, elem*, idx) -> state - ;; 7-module.watsup:168.1-168.41 - def {f : frame, i : nat, s : store} run_elem(`%;%`(s, f), [], i) = `%;%`(s, f) - ;; 7-module.watsup:170.1-172.59 - def {elem : elem, elem'* : elem*, expr* : expr*, f : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) - -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?())) - -- if ($run_elem(`%;%`(s, f), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:174.1-179.67 - def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, reftype : reftype, s : store, s_new : store, s_res : store, x : idx} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) - -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) - -- if (n = |expr*{expr}|) - -- if (elemmode = TABLE_elemmode(x, instr*{instr})) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, i) ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) - -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:181.1-185.67 - def {elem : elem, elem'* : elem*, elemmode : elemmode, expr* : expr*, f : frame, f_new : frame, f_res : frame, i : nat, reftype : reftype, s : store, s_new : store, s_res : store} run_elem(`%;%`(s, f), [elem] :: elem'*{elem'}, i) = `%;%`(s_res, f_res) - -- if (elem = `ELEM%%*%?`(reftype, expr*{expr}, ?(elemmode))) - -- if (elemmode = DECLARE_elemmode) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), [ELEM.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) - -- if ($run_elem(`%;%`(s_new, f_new), elem'*{elem'}, (i + 1)) = `%;%`(s_res, f_res)) +;; 7-module.watsup:80.1-80.63 +def allocelems : (store, reftype*, ref**) -> (store, elemaddr*) + ;; 7-module.watsup:81.1-81.52 + def {s : store} allocelems(s, [], []) = (s, []) + ;; 7-module.watsup:82.1-84.53 + def {ea : elemaddr, ea'* : elemaddr*, ref* : ref*, ref'** : ref**, rt : reftype, rt'* : reftype*, s : store, s_1 : store, s_2 : store} allocelems(s, [rt] :: rt'*{rt'}, [ref]*{ref} :: ref'*{ref'}*{ref'}) = (s_2, [ea] :: ea'*{ea'}) + -- if ((s_1, ea) = $allocelem(s, rt, ref*{ref})) + -- if ((s_2, ea'*{ea'}) = $allocelems(s_2, rt'*{rt'}, ref'*{ref'}*{ref'})) } -;; 7-module.watsup:188.1-188.41 +;; 7-module.watsup:86.1-86.49 +def allocdata : (store, byte*) -> (store, dataaddr) + ;; 7-module.watsup:87.1-88.28 + def {byte* : byte*, di : datainst, s : store} allocdata(s, byte*{byte}) = (s[DATA_store =.. [di]], |s.DATA_store|) + -- if (di = {DATA byte*{byte}}) + +;; 7-module.watsup:90.1-90.52 rec { -;; 7-module.watsup:188.1-188.41 -def run_data : (state, data*, idx) -> state - ;; 7-module.watsup:190.1-190.41 - def {f : frame, i : nat, s : store} run_data(`%;%`(s, f), [], i) = `%;%`(s, f) - ;; 7-module.watsup:192.1-194.59 - def {byte* : byte*, data : data, data'* : data*, f : frame, f_res : frame, i : nat, s : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) - -- if (data = `DATA%*%?`(byte*{byte}, ?())) - -- if ($run_data(`%;%`(s, f), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:196.1-201.67 - def {byte* : byte*, data : data, data'* : data*, datamode : datamode, f : frame, f_new : frame, f_res : frame, i : nat, instr* : instr*, n : n, s : store, s_new : store, s_res : store} run_data(`%;%`(s, f), [data] :: data'*{data'}, i) = `%;%`(s_res, f_res) - -- if (data = `DATA%*%?`(byte*{byte}, ?(datamode))) +;; 7-module.watsup:90.1-90.52 +def allocdatas : (store, byte**) -> (store, dataaddr*) + ;; 7-module.watsup:91.1-91.43 + def {s : store} allocdatas(s, []) = (s, []) + ;; 7-module.watsup:92.1-94.48 + def {byte* : byte*, byte'** : byte**, da : dataaddr, da'* : dataaddr*, s : store, s_1 : store, s_2 : store} allocdatas(s, [byte]*{byte} :: byte'*{byte'}*{byte'}) = (s_2, [da] :: da'*{da'}) + -- if ((s_1, da) = $allocdata(s, byte*{byte})) + -- if ((s_2, da'*{da'}) = $allocdatas(s_1, byte'*{byte'}*{byte'})) +} + +;; 7-module.watsup:97.1-97.81 +def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) + ;; 7-module.watsup:98.1-135.54 + def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i : nat, import* : import*, m : moduleinst, ma* : memaddr*, ma_ex* : memaddr*, memtype^n_mem : memtype^n_mem, module : module, n_data : n, n_elem : n, n_func : n, n_global : n, n_mem : n, n_table : n, ref** : ref**, rt^n_elem : reftype^n_elem, s : store, s_1 : store, s_2 : store, s_3 : store, s_4 : store, s_5 : store, s_6 : store, start? : start?, ta* : tableaddr*, ta_ex* : tableaddr*, tabletype^n_table : tabletype^n_table, val* : val*, xi* : exportinst*} allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref}) = (s_6, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func^n_func{func}, GLOBAL(globaltype, expr_1)^n_global{expr_1 globaltype}, TABLE(tabletype)^n_table{tabletype}, MEMORY(memtype)^n_mem{memtype}, `ELEM%%*%?`(rt, expr_2*{expr_2}, elemmode?{elemmode})^n_elem{elemmode expr_2 rt}, `DATA%*%?`(byte*{byte}, datamode?{datamode})^n_data{byte datamode}, start?{start}, export*{export})) + -- if (fa_ex*{fa_ex} = $funcs(externval*{externval})) + -- if (ga_ex*{ga_ex} = $globals(externval*{externval})) + -- if (ta_ex*{ta_ex} = $tables(externval*{externval})) + -- if (ma_ex*{ma_ex} = $mems(externval*{externval})) + -- if (fa*{fa} = (|s.FUNC_store| + i)^(i instr* + ;; 7-module.watsup:139.1-139.46 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?()), i) = [] + ;; 7-module.watsup:140.1-140.62 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(DECLARE_elemmode)), i) = [ELEM.DROP_instr(i)] + ;; 7-module.watsup:141.1-143.20 + def {expr* : expr*, i : nat, instr* : instr*, n : n, reftype : reftype, x : idx} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(TABLE_elemmode(x, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) TABLE.INIT_instr(x, i) ELEM.DROP_instr(i)] + -- if (n = |expr*{expr}|) + +;; 7-module.watsup:145.1-145.33 +def rundata : (data, idx) -> instr* + ;; 7-module.watsup:146.1-146.38 + def {byte* : byte*, i : nat} rundata(`DATA%*%?`(byte*{byte}, ?()), i) = [] + ;; 7-module.watsup:147.1-149.20 + def {byte* : byte*, i : nat, instr* : instr*, n : n} rundata(`DATA%*%?`(byte*{byte}, ?(MEMORY_datamode(0, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) MEMORY.INIT_instr(i) DATA.DROP_instr(i)] -- if (n = |byte*{byte}|) - -- if (datamode = MEMORY_datamode(0, instr*{instr})) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_instr(instr)*{instr} :: [CONST_admininstr(I32_numtype, 0) CONST_admininstr(I32_numtype, n) MEMORY.INIT_admininstr(i) DATA.DROP_admininstr(i)]), `%;%*`(`%;%`(s_new, f_new), [])) - -- if ($run_data(`%;%`(s_new, f_new), data'*{data'}, (i + 1)) = `%;%`(s_res, f_res)) + +;; 7-module.watsup:152.1-152.36 +rec { + +;; 7-module.watsup:152.1-152.36 +def concat_instr : instr** -> instr* + ;; 7-module.watsup:153.1-153.37 + def concat_instr([]) = [] + ;; 7-module.watsup:154.1-154.68 + def {instr* : instr*, instr'** : instr**} concat_instr([instr]*{instr} :: instr'*{instr'}*{instr'}) = instr*{instr} :: $concat_instr(instr'*{instr'}*{instr'}) } -;; 7-module.watsup:206.1-206.68 -def instantiation : (store, module, externval*) -> (store, moduleinst) - ;; 7-module.watsup:208.1-213.61 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_elem : store, s_res : store, table* : table*} instantiation(s, module, externval*{externval}) = (s_res, m) - -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(), export*{export})) - -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) - -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) - -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_res, f_res)) - ;; 7-module.watsup:215.1-222.62 - def {data* : data*, elem* : elem*, export* : export*, externval* : externval*, f : frame, f_data : frame, f_elem : frame, f_res : frame, func* : func*, global* : global*, import* : import*, m : moduleinst, mem* : mem*, module : module, s : store, s_alloc : store, s_data : store, s_elem : store, s_res : store, start : start, table* : table*, x : idx} instantiation(s, module, externval*{externval}) = (s_res, m) - -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, ?(start), export*{export})) - -- if ((s_alloc, m) = $alloc_module(s, module, externval*{externval})) +;; 7-module.watsup:157.1-157.55 +def instantiation : (store, module, externval*) -> config + ;; 7-module.watsup:158.1-180.28 + def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i : nat, import* : import*, instr_1** : instr**, instr_2*** : instr***, instr_data* : instr*, instr_elem* : instr*, j : nat, m : moduleinst, m_init : moduleinst, mem* : mem*, module : module, n_data : n, n_elem : n, ref** : ref**, reftype* : reftype*, s : store, s' : store, start? : start?, table* : table*, val* : val*, x? : idx?} instantiation(s, module, externval*{externval}) = `%;%*`(`%;%`(s', f), $admininstr_instr(instr_elem)*{instr_elem} :: $admininstr_instr(instr_data)*{instr_data} :: CALL_admininstr(x)?{x}) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) + -- if (m_init = {FUNC $funcs(externval*{externval}), GLOBAL $globals(externval*{externval}), TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f_init = {LOCAL [], MODULE m_init}) + -- (if (global = GLOBAL(globaltype, instr_1*{instr_1})))*{global globaltype instr_1} + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_1)*{instr_1}), [$admininstr_val(val)]))*{instr_1 val} + -- (if (elem = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})))*{elem elemmode instr_2 reftype} + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_2)*{instr_2}), [$admininstr_ref(ref)]))*{instr_2 ref}*{instr_2 ref} + -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) -- if (f = {LOCAL [], MODULE m}) - -- if ($run_elem(`%;%`(s_alloc, f), elem*{elem}, 0) = `%;%`(s_elem, f_elem)) - -- if ($run_data(`%;%`(s_elem, f_elem), data*{data}, 0) = `%;%`(s_data, f_data)) - -- if (start = START(x)) - -- Step: `%~>%`(`%;%*`(`%;%`(s_data, f_data), [CALL_admininstr(x)]), `%;%*`(`%;%`(s_res, f_res), [])) - -;; 7-module.watsup:227.1-227.55 -def invocation : (store, funcaddr, val*) -> (store, val*) - ;; 7-module.watsup:229.1-236.55 - def {expr : expr, f : frame, f' : frame, fa : funcaddr, functype : functype, m : moduleinst, s : store, s' : store, val* : val*, val'* : val*, valtype* : valtype*, valtype'* : valtype*} invocation(s, fa, val*{val}) = (s', val'*{val'}) + -- if (n_elem = |elem*{elem}|) + -- if (instr_elem*{instr_elem} = $concat_instr($runelem(elem*{elem}[i], i)^(i config + ;; 7-module.watsup:184.1-196.52 + def {expr : expr, f : frame, fa : funcaddr, functype : functype, k : nat, m : moduleinst, n : n, s : store, val^n : val^n, valtype* : valtype*, valtype_param^n : valtype^n, valtype_res^k : valtype^k} invocation(s, fa, val^n{val}) = `%;%*`(`%;%`(s, f), $admininstr_val(val)^n{val} :: [CALL_ADDR_admininstr(fa)]) -- if (m = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) -- if (f = {LOCAL [], MODULE m}) -- if ($funcinst(`%;%`(s, f))[fa].CODE_funcinst = `FUNC%%*%`(functype, valtype*{valtype}, expr)) - -- if (functype = `%->%`(valtype*{valtype}, valtype'*{valtype'})) - -- if (|val*{val}| = |valtype*{valtype}|) - -- if (|val'*{val'}| = |valtype'*{valtype'}|) - -- Step: `%~>%`(`%;%*`(`%;%`(s, f), $admininstr_val(val)*{val} :: [CALL_ADDR_admininstr(fa)]), `%;%*`(`%;%`(s', f'), $admininstr_val(val')*{val'})) + -- if (functype = `%->%`(valtype_param^n{valtype_param}, valtype_res^k{valtype_res})) == IL Validation... == Complete. diff --git a/spectec/test-prose/TEST.md b/spectec/test-prose/TEST.md index 92ef363de5..8aac5556a3 100644 --- a/spectec/test-prose/TEST.md +++ b/spectec/test-prose/TEST.md @@ -370,7 +370,7 @@ table.grow 3. Assert: Due to validation, a value is on the top of the stack. 4. Pop YetE ((ref <: admininstr)) from the stack. 5. If YetC (), then: - a. YetI: Perform $with_tableinst(z, x, ti'). + a. YetI: Perform $with_tableinst(z, x, ti). b. Push YetE (CONST_admininstr(I32_numtype, |$table(z, x).ELEM_tableinst|)) to the stack. 6. If YetC (), then: a. YetI: Perform z. @@ -399,7 +399,7 @@ memory.grow 1. Assert: Due to validation, a value of value type i32 is on the top of the stack. 2. Pop YetE (CONST_admininstr(I32_numtype, n)) from the stack. 3. If YetC (), then: - a. YetI: Perform $with_meminst(z, 0, mi'). + a. YetI: Perform $with_meminst(z, 0, mi). b. Push YetE (CONST_admininstr(I32_numtype, (|$mem(z, 0).DATA_meminst| / (64 * $Ki)))) to the stack. 4. If YetC (), then: a. YetI: Perform z. From 65e6777f8d341fc6f37bb12c3a344e11fe3da2b7 Mon Sep 17 00:00:00 2001 From: Wonho Date: Fri, 14 Jul 2023 16:06:13 +0900 Subject: [PATCH 35/49] Minor change --- spectec/spec/7-module.watsup | 4 ++-- spectec/test-frontend/TEST.md | 8 ++++---- spectec/test-middlend/TEST.md | 28 ++++++++++++++-------------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/spectec/spec/7-module.watsup b/spectec/spec/7-module.watsup index 6cdfcd5879..7798871280 100644 --- a/spectec/spec/7-module.watsup +++ b/spectec/spec/7-module.watsup @@ -167,9 +167,9 @@ def $instantiation(s, module, externval*) = s'; f; instr_elem* instr_data* (CALL EXPORT epsilon } -- if f_init = { LOCAL epsilon, MODULE m_init } - -- (if global = GLOBAL globaltype instr_1*)* + -- if global* = (GLOBAL globaltype instr_1*)* -- (Step_read : s; f_init; instr_1* ~> val)* - -- (if elem = ELEM reftype (instr_2*)* elemmode?)* + -- if elem* = (ELEM reftype (instr_2*)* elemmode?)* -- (Step_read : s; f_init; instr_2* ~> ref)** -- if (s', m) = $allocmodule(s, module, externval*, val*, (ref*)*) -- if f = { LOCAL epsilon, MODULE m } diff --git a/spectec/test-frontend/TEST.md b/spectec/test-frontend/TEST.md index 8f7feef6ce..441613731c 100644 --- a/spectec/test-frontend/TEST.md +++ b/spectec/test-frontend/TEST.md @@ -1922,9 +1922,9 @@ def instantiation : (store, module, externval*) -> config -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) -- if (m_init = {FUNC $funcs(externval*{externval}), GLOBAL $globals(externval*{externval}), TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) -- if (f_init = {LOCAL [], MODULE m_init}) - -- (if (global = GLOBAL(globaltype, instr_1*{instr_1})))*{global globaltype instr_1} + -- if (global*{global} = GLOBAL(globaltype, instr_1*{instr_1})*{globaltype instr_1}) -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), (instr_1 <: admininstr)*{instr_1}), [(val <: admininstr)]))*{instr_1 val} - -- (if (elem = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})))*{elem elemmode instr_2 reftype} + -- if (elem*{elem} = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})*{elemmode instr_2 reftype}) -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), (instr_2 <: admininstr)*{instr_2}), [(ref <: admininstr)]))*{instr_2 ref}*{instr_2 ref} -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) -- if (f = {LOCAL [], MODULE m}) @@ -4338,9 +4338,9 @@ $$ \mathsf{export}~\epsilon \}\end{array} \\ &&&\quad {\land}~\mathit{f}_{\mathit{init}} = \{ \begin{array}[t]{@{}l@{}} \mathsf{local}~\epsilon,\; \mathsf{module}~\mathit{m}_{\mathit{init}} \}\end{array} \\ - &&&\quad {\land}~(\mathit{global} = \mathsf{global}~\mathit{globaltype}~{\mathit{instr}_{1}^\ast})^\ast \\ + &&&\quad {\land}~{\mathit{global}^\ast} = {(\mathsf{global}~\mathit{globaltype}~{\mathit{instr}_{1}^\ast})^\ast} \\ &&&\quad {\land}~(\mathit{s} ; \mathit{f}_{\mathit{init}} ; {\mathit{instr}_{1}^\ast} \hookrightarrow \mathit{val})^\ast \\ - &&&\quad {\land}~(\mathit{elem} = \mathsf{elem}~\mathit{reftype}~{({\mathit{instr}_{2}^\ast})^\ast}~{\mathit{elemmode}^?})^\ast \\ + &&&\quad {\land}~{\mathit{elem}^\ast} = {(\mathsf{elem}~\mathit{reftype}~{({\mathit{instr}_{2}^\ast})^\ast}~{\mathit{elemmode}^?})^\ast} \\ &&&\quad {\land}~{(\mathit{s} ; \mathit{f}_{\mathit{init}} ; {\mathit{instr}_{2}^\ast} \hookrightarrow \mathit{ref})^\ast}^\ast \\ &&&\quad {\land}~({\mathit{s}'},\, \mathit{m}) = \mathrm{allocmodule}(\mathit{s},\, \mathit{module},\, {\mathit{externval}^\ast},\, {\mathit{val}^\ast},\, {({\mathit{ref}^\ast})^\ast}) \\ &&&\quad {\land}~\mathit{f} = \{ \begin{array}[t]{@{}l@{}} diff --git a/spectec/test-middlend/TEST.md b/spectec/test-middlend/TEST.md index 68c9ad17d0..020e0faf02 100644 --- a/spectec/test-middlend/TEST.md +++ b/spectec/test-middlend/TEST.md @@ -1921,9 +1921,9 @@ def instantiation : (store, module, externval*) -> config -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) -- if (m_init = {FUNC $funcs(externval*{externval}), GLOBAL $globals(externval*{externval}), TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) -- if (f_init = {LOCAL [], MODULE m_init}) - -- (if (global = GLOBAL(globaltype, instr_1*{instr_1})))*{global globaltype instr_1} + -- if (global*{global} = GLOBAL(globaltype, instr_1*{instr_1})*{globaltype instr_1}) -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), (instr_1 <: admininstr)*{instr_1}), [(val <: admininstr)]))*{instr_1 val} - -- (if (elem = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})))*{elem elemmode instr_2 reftype} + -- if (elem*{elem} = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})*{elemmode instr_2 reftype}) -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), (instr_2 <: admininstr)*{instr_2}), [(ref <: admininstr)]))*{instr_2 ref}*{instr_2 ref} -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) -- if (f = {LOCAL [], MODULE m}) @@ -3947,9 +3947,9 @@ def instantiation : (store, module, externval*) -> config -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) -- if (m_init = {FUNC $funcs(externval*{externval}), GLOBAL $globals(externval*{externval}), TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) -- if (f_init = {LOCAL [], MODULE m_init}) - -- (if (global = GLOBAL(globaltype, instr_1*{instr_1})))*{global globaltype instr_1} + -- if (global*{global} = GLOBAL(globaltype, instr_1*{instr_1})*{globaltype instr_1}) -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_1)*{instr_1}), [$admininstr_val(val)]))*{instr_1 val} - -- (if (elem = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})))*{elem elemmode instr_2 reftype} + -- if (elem*{elem} = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})*{elemmode instr_2 reftype}) -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_2)*{instr_2}), [$admininstr_ref(ref)]))*{instr_2 ref}*{instr_2 ref} -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) -- if (f = {LOCAL [], MODULE m}) @@ -5977,9 +5977,9 @@ def instantiation : (store, module, externval*) -> config -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) -- if (m_init = {FUNC $funcs(externval*{externval}), GLOBAL $globals(externval*{externval}), TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) -- if (f_init = {LOCAL [], MODULE m_init}) - -- (if (global = GLOBAL(globaltype, instr_1*{instr_1})))*{global globaltype instr_1} + -- if (global*{global} = GLOBAL(globaltype, instr_1*{instr_1})*{globaltype instr_1}) -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_1)*{instr_1}), [$admininstr_val(val)]))*{instr_1 val} - -- (if (elem = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})))*{elem elemmode instr_2 reftype} + -- if (elem*{elem} = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})*{elemmode instr_2 reftype}) -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_2)*{instr_2}), [$admininstr_ref(ref)]))*{instr_2 ref}*{instr_2 ref} -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) -- if (f = {LOCAL [], MODULE m}) @@ -8028,9 +8028,9 @@ def instantiation : (store, module, externval*) -> config -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) -- if (m_init = {FUNC $funcs(externval*{externval}), GLOBAL $globals(externval*{externval}), TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) -- if (f_init = {LOCAL [], MODULE m_init}) - -- (if (global = GLOBAL(globaltype, instr_1*{instr_1})))*{global globaltype instr_1} + -- if (global*{global} = GLOBAL(globaltype, instr_1*{instr_1})*{globaltype instr_1}) -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_1)*{instr_1}), [$admininstr_val(val)]))*{instr_1 val} - -- (if (elem = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})))*{elem elemmode instr_2 reftype} + -- if (elem*{elem} = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})*{elemmode instr_2 reftype}) -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_2)*{instr_2}), [$admininstr_ref(ref)]))*{instr_2 ref}*{instr_2 ref} -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) -- if (f = {LOCAL [], MODULE m}) @@ -10079,9 +10079,9 @@ def instantiation : (store, module, externval*) -> config -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) -- if (m_init = {FUNC $funcs(externval*{externval}), GLOBAL $globals(externval*{externval}), TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) -- if (f_init = {LOCAL [], MODULE m_init}) - -- (if (global = GLOBAL(globaltype, instr_1*{instr_1})))*{global globaltype instr_1} + -- if (global*{global} = GLOBAL(globaltype, instr_1*{instr_1})*{globaltype instr_1}) -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_1)*{instr_1}), [$admininstr_val(val)]))*{instr_1 val} - -- (if (elem = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})))*{elem elemmode instr_2 reftype} + -- if (elem*{elem} = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})*{elemmode instr_2 reftype}) -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_2)*{instr_2}), [$admininstr_ref(ref)]))*{instr_2 ref}*{instr_2 ref} -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) -- if (f = {LOCAL [], MODULE m}) @@ -12186,9 +12186,9 @@ def instantiation : (store, module, externval*) -> config -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) -- if (m_init = {FUNC $funcs(externval*{externval}), GLOBAL $globals(externval*{externval}), TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) -- if (f_init = {LOCAL [], MODULE m_init}) - -- (if (global = GLOBAL(globaltype, instr_1*{instr_1})))*{global globaltype instr_1} + -- if (global*{global} = GLOBAL(globaltype, instr_1*{instr_1})*{globaltype instr_1}) -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_1)*{instr_1}), [$admininstr_val(val)]))*{instr_1 val} - -- (if (elem = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})))*{elem elemmode instr_2 reftype} + -- if (elem*{elem} = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})*{elemmode instr_2 reftype}) -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_2)*{instr_2}), [$admininstr_ref(ref)]))*{instr_2 ref}*{instr_2 ref} -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) -- if (f = {LOCAL [], MODULE m}) @@ -14296,9 +14296,9 @@ def instantiation : (store, module, externval*) -> config -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) -- if (m_init = {FUNC $funcs(externval*{externval}), GLOBAL $globals(externval*{externval}), TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) -- if (f_init = {LOCAL [], MODULE m_init}) - -- (if (global = GLOBAL(globaltype, instr_1*{instr_1})))*{global globaltype instr_1} + -- if (global*{global} = GLOBAL(globaltype, instr_1*{instr_1})*{globaltype instr_1}) -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_1)*{instr_1}), [$admininstr_val(val)]))*{instr_1 val} - -- (if (elem = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})))*{elem elemmode instr_2 reftype} + -- if (elem*{elem} = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})*{elemmode instr_2 reftype}) -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_2)*{instr_2}), [$admininstr_ref(ref)]))*{instr_2 ref}*{instr_2 ref} -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) -- if (f = {LOCAL [], MODULE m}) From edb1fbfa1c28039a4674e9d39ffb58b57c8e7691 Mon Sep 17 00:00:00 2001 From: Wonho Date: Wed, 19 Jul 2023 14:08:49 +0900 Subject: [PATCH 36/49] Merge two render_condition functions --- spectec/src/backend-latex/render.ml | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/spectec/src/backend-latex/render.ml b/spectec/src/backend-latex/render.ml index 80e1097be3..f431b1b748 100644 --- a/spectec/src/backend-latex/render.ml +++ b/spectec/src/backend-latex/render.ml @@ -684,25 +684,16 @@ let render_ruledef env d = render_rule_deco env " \\, " id1 id2 "" | _ -> failwith "render_ruledef" -let render_red_conditions env = function +let render_condition env tabs = function | [] -> " & " | [Elem {it = ElsePr; _}] -> " &\\quad\n " ^ word "otherwise" | (Elem {it = ElsePr; _})::prems -> " &\\quad\n " ^ word "otherwise, if" ^ "~" ^ - concat_map_nl " \\\\\n &&&&\\quad {\\land}~" "" (render_prem env) prems + concat_map_nl (" \\\\\n " ^ tabs ^ "\\quad {\\land}~") "" (render_prem env) prems | prems -> " &\\quad\n " ^ word "if" ^ "~" ^ - concat_map_nl " \\\\\n &&&&\\quad {\\land}~" "" (render_prem env) prems + concat_map_nl (" \\\\\n " ^ tabs ^ "\\quad {\\land}~") "" (render_prem env) prems -let render_func_conditions env = function - | [] -> " & " - | [Elem {it = ElsePr; _}] -> " &\\quad\n " ^ word "otherwise" - | (Elem {it = ElsePr; _})::prems -> - " &\\quad\n " ^ word "otherwise, if" ^ "~" ^ - concat_map_nl " \\\\\n &&&\\quad {\\land}~" "" (render_prem env) prems - | prems -> - " &\\quad\n " ^ word "if" ^ "~" ^ - concat_map_nl " \\\\\n &&&\\quad {\\land}~" "" (render_prem env) prems let render_reddef env d = match d.it with @@ -714,14 +705,14 @@ let render_reddef env d = in render_rule_deco env "" id1 id2 " \\quad " ^ "& " ^ render_exp env e1 ^ " &" ^ render_atom env SqArrow ^ "& " ^ - render_exp env e2 ^ render_red_conditions env prems + render_exp env e2 ^ render_condition env "&&&&" prems | _ -> failwith "render_reddef" let render_funcdef env d = match d.it with | DefD (id1, e1, e2, prems) -> render_exp env (CallE (id1, e1) $ d.at) ^ " &=& " ^ - render_exp env e2 ^ render_func_conditions env prems + render_exp env e2 ^ render_condition env "&&&" prems | _ -> failwith "render_funcdef" let rec render_sep_defs ?(sep = " \\\\\n") ?(br = " \\\\[0.8ex]\n") f = function From 8bb5fe0165670a49285e6638789978752f6737d0 Mon Sep 17 00:00:00 2001 From: Wonho Date: Thu, 20 Jul 2023 14:25:39 +0900 Subject: [PATCH 37/49] Merge ListN --- spectec/src/backend-latex/render.ml | 7 +++++-- spectec/src/el/ast.ml | 2 +- spectec/src/el/eq.ml | 4 +++- spectec/src/el/free.ml | 4 +++- spectec/src/el/print.ml | 4 +++- spectec/src/frontend/elab.ml | 6 +----- spectec/src/frontend/multiplicity.ml | 15 +++++++++------ spectec/src/frontend/parser.mly | 8 ++++++-- spectec/src/il/ast.ml | 3 +-- spectec/src/il/eq.ml | 6 +++--- spectec/src/il/free.ml | 6 +++--- spectec/src/il/print.ml | 4 ++-- spectec/src/il/validation.ml | 9 +++------ spectec/src/middlend/sideconditions.ml | 6 +++--- spectec/src/middlend/sub.ml | 3 +-- spectec/src/middlend/totalize.ml | 3 +-- spectec/src/middlend/unthe.ml | 4 +--- spectec/src/middlend/wild.ml | 4 +--- spectec/test-frontend/TEST.md | 16 ++++++++-------- 19 files changed, 58 insertions(+), 56 deletions(-) diff --git a/spectec/src/backend-latex/render.ml b/spectec/src/backend-latex/render.ml index f431b1b748..f1ee53327f 100644 --- a/spectec/src/backend-latex/render.ml +++ b/spectec/src/backend-latex/render.ml @@ -327,7 +327,7 @@ exception Arity_mismatch let rec expand_iter args iter = match iter with | Opt | List | List1 -> iter - | ListN e -> ListN (expand_exp args e) + | ListN (e, opt) -> ListN (expand_exp args e, opt) and expand_exp args e = expand_exp' args e.it $ e.at and expand_exp' args e' = @@ -441,7 +441,10 @@ and render_iter env = function | Opt -> "^?" | List -> "^\\ast" | List1 -> "^{+}" - | ListN {it = ParenE (e, _); _} | ListN e -> "^{" ^ render_exp env e ^ "}" + | ListN ({it = ParenE (e, _); _}, None) | ListN (e, None) -> + "^{" ^ render_exp env e ^ "}" + | ListN (e, Some id) -> + "^(" ^ id.it ^ "<" ^ render_exp env e ^ ")" (* Types *) diff --git a/spectec/src/el/ast.ml b/spectec/src/el/ast.ml index e2c082c30a..eca3a9ebab 100644 --- a/spectec/src/el/ast.ml +++ b/spectec/src/el/ast.ml @@ -44,7 +44,7 @@ type iter = | Opt (* `?` *) | List (* `*` *) | List1 (* `+` *) - | ListN of exp (* `^` exp *) + | ListN of exp * id option (* `^` exp *) (* Types *) diff --git a/spectec/src/el/eq.ml b/spectec/src/el/eq.ml index f5cf97f0d0..e8a42e6e28 100644 --- a/spectec/src/el/eq.ml +++ b/spectec/src/el/eq.ml @@ -20,7 +20,9 @@ let eq_nl_list eq_x xs1 xs2 = eq_list (eq_nl_elem eq_x) xs1 xs2 let rec eq_iter iter1 iter2 = iter1 = iter2 || match iter1, iter2 with - | ListN e1, ListN e2 -> eq_exp e1 e2 + | ListN (e1, None), ListN (e2, None) -> eq_exp e1 e2 + | ListN (e1, Some id1), ListN (e2, Some id2) -> + eq_exp e1 e2 && id1.it = id2.it | _, _ -> false diff --git a/spectec/src/el/free.ml b/spectec/src/el/free.ml index 8ca0e1ff15..4da3742ff1 100644 --- a/spectec/src/el/free.ml +++ b/spectec/src/el/free.ml @@ -37,7 +37,9 @@ let free_defid id = {empty with defid = Set.singleton id.it} let rec free_iter iter = match iter with | Opt | List | List1 -> empty - | ListN e -> free_exp e + | ListN (e, None) -> free_exp e + | ListN (e, Some (id)) -> + union (free_exp e) (free_varid id) (* Types *) diff --git a/spectec/src/el/print.ml b/spectec/src/el/print.ml index 6a4f6683e6..e5f92a73b9 100644 --- a/spectec/src/el/print.ml +++ b/spectec/src/el/print.ml @@ -70,7 +70,9 @@ let rec string_of_iter iter = | Opt -> "?" | List -> "*" | List1 -> "+" - | ListN e -> "^" ^ string_of_exp e + | ListN (e, None) -> "^" ^ string_of_exp e + | ListN (e, Some (id)) -> + "^(" ^ id.it ^ "<" ^ string_of_exp e ^ ")" (* Types *) diff --git a/spectec/src/frontend/elab.ml b/spectec/src/frontend/elab.ml index cca9840a23..e5666fc7c7 100644 --- a/spectec/src/frontend/elab.ml +++ b/spectec/src/frontend/elab.ml @@ -336,11 +336,7 @@ let rec elab_iter env iter : Il.iter = | Opt -> Il.Opt | List -> Il.List | List1 -> Il.List1 - | ListN e -> - match e.it with - | ParenE ({ it = CmpE ({ it = VarE id; _ }, LtOp, e); _}, _) -> - Il.IndexedListN (id, elab_exp env e (NatT $ e.at)) - | _ -> Il.ListN (elab_exp env e (NatT $ e.at)) + | ListN (e, opt) -> Il.ListN (elab_exp env e (NatT $ e.at), opt) (* Types *) diff --git a/spectec/src/frontend/multiplicity.ml b/spectec/src/frontend/multiplicity.ml index aebc8adc50..47ee4032ef 100644 --- a/spectec/src/frontend/multiplicity.ml +++ b/spectec/src/frontend/multiplicity.ml @@ -68,7 +68,9 @@ let iter_nl_list f xs = List.iter (function Nl -> () | Elem x -> f x) xs let rec check_iter env ctx iter = match iter with | Opt | List | List1 -> () - | ListN e -> check_exp env ctx e + | ListN (e, opt) -> + Option.iter (fun id -> check_id env ctx id) opt; + check_exp env ctx e and check_exp env ctx e = match e.it with @@ -161,12 +163,13 @@ let union = Env.union (fun _ ctx1 ctx2 -> assert (ctx1 = ctx2); Some ctx1) let rec annot_iter env iter : Il.Ast.iter * occur = match iter with | Opt | List | List1 -> iter, Env.empty - | ListN e -> + | ListN (e, None) -> let e', occur = annot_exp env e in - ListN e', occur - | IndexedListN (id, e) -> - let e', occur = annot_exp env e in - IndexedListN (id, e'), occur + ListN (e', None), occur + | ListN (e, Some id) -> + let e', occur1 = annot_exp env e in + let occur2 = Env.singleton id.it (Env.find id.it env) in + ListN (e', Some id), union occur1 occur2 and annot_exp env e : Il.Ast.exp * occur = let it, occur = diff --git a/spectec/src/frontend/parser.mly b/spectec/src/frontend/parser.mly index 236a80586e..854bb36911 100644 --- a/spectec/src/frontend/parser.mly +++ b/spectec/src/frontend/parser.mly @@ -135,12 +135,16 @@ check_atom : (* Iteration *) - iter : | QUEST { Opt } | PLUS { List1 } | STAR { List } - | UP arith_prim { ListN $2 } + | UP arith_prim + { match $2.it with + | ParenE ({ it = CmpE({ it = VarE id; _ }, LtOp, e); _}, false) -> + ListN (e, Some id) + | _ -> ListN ($2, None) + } (* Types *) diff --git a/spectec/src/il/ast.ml b/spectec/src/il/ast.ml index f97a0ebdcd..73b58558de 100644 --- a/spectec/src/il/ast.ml +++ b/spectec/src/il/ast.ml @@ -41,8 +41,7 @@ type iter = | Opt (* `?` *) | List (* `*` *) | List1 (* `+` *) - | ListN of exp (* `^` exp *) - | IndexedListN of id * exp (* `^` exp *) + | ListN of exp * id option (* `^` exp *) (* Types *) diff --git a/spectec/src/il/eq.ml b/spectec/src/il/eq.ml index 177ce77a69..6dc8952718 100644 --- a/spectec/src/il/eq.ml +++ b/spectec/src/il/eq.ml @@ -24,9 +24,9 @@ let eq_id i1 i2 = let rec eq_iter iter1 iter2 = iter1 = iter2 || match iter1, iter2 with - | ListN e1, ListN e2 -> eq_exp e1 e2 - | IndexedListN (id1, e1), IndexedListN (id2, e2) -> - id1.it = id2.it && eq_exp e1 e2 + | ListN (e1, None), ListN (e2, None) -> eq_exp e1 e2 + | ListN (e1, Some id1), ListN (e2, Some id2) -> + eq_exp e1 e2 && id1.it = id2.it | _, _ -> false diff --git a/spectec/src/il/free.ml b/spectec/src/il/free.ml index 22d5e6d7ab..6ed62def48 100644 --- a/spectec/src/il/free.ml +++ b/spectec/src/il/free.ml @@ -55,9 +55,9 @@ let free_defid id = {empty with defid = Set.singleton id.it} let rec free_iter iter = match iter with | Opt | List | List1 -> empty - | ListN e -> free_exp e - | IndexedListN (id, e) -> - union (free_varid id) (free_exp e) + | ListN (e, None) -> free_exp e + | ListN (e, Some id) -> + union (free_exp e) (free_varid id) (* Types *) diff --git a/spectec/src/il/print.ml b/spectec/src/il/print.ml index 268ae5e578..a2fb91d5f7 100644 --- a/spectec/src/il/print.ml +++ b/spectec/src/il/print.ml @@ -76,8 +76,8 @@ let rec string_of_iter iter = | Opt -> "?" | List -> "*" | List1 -> "+" - | ListN e -> "^" ^ string_of_exp e - | IndexedListN (id, e) -> + | ListN (e, None) -> "^" ^ string_of_exp e + | ListN (e, Some id) -> "^(" ^ id.it ^ "<" ^ string_of_exp e ^ ")" and string_of_typ t = diff --git a/spectec/src/il/validation.ml b/spectec/src/il/validation.ml index f6a3fb1280..c4b7238c44 100644 --- a/spectec/src/il/validation.ml +++ b/spectec/src/il/validation.ml @@ -100,7 +100,7 @@ let as_iter_typ iter phrase env dir t at : typ = let as_list_typ phrase env dir t at : typ = match expand' env t.it with - | IterT (t1, (List | List1 | ListN _ | IndexedListN _)) -> t1 + | IterT (t1, (List | List1 | ListN _)) -> t1 | _ -> as_error at phrase dir t "(_)*" let as_tup_typ phrase env dir t at : typ list = @@ -241,8 +241,7 @@ let valid_list valid_x_y env xs ys at = let rec valid_iter env iter = match iter with | Opt | List | List1 -> () - | IndexedListN (_, e) - | ListN e -> valid_exp env e (NatT $ e.at) + | ListN (e, _) -> valid_exp env e (NatT $ e.at) (* Types *) @@ -260,8 +259,7 @@ and valid_typ env t = List.iter (valid_typ env) ts | IterT (t1, iter) -> match iter with - | IndexedListN (_, e) - | ListN e -> error e.at "definite iterator not allowed in type" + | ListN (e, _) -> error e.at "definite iterator not allowed in type" | _ -> valid_typ env t1; valid_iter env iter and valid_deftyp env dt = @@ -318,7 +316,6 @@ and infer_exp env e : typ = | IterE (e1, iter) -> let iter' = match fst iter with - | IndexedListN _ | ListN _ -> List | iter' -> iter' in diff --git a/spectec/src/middlend/sideconditions.ml b/spectec/src/middlend/sideconditions.ml index 13a416f586..ff1aa2d02b 100644 --- a/spectec/src/middlend/sideconditions.ml +++ b/spectec/src/middlend/sideconditions.ml @@ -22,7 +22,7 @@ module Env = Map.Make(String) (* Smart constructor for LenE that optimizes |x^n| into n *) let lenE e = match e.it with -| IterE (_, ((ListN ne | IndexedListN (_, ne)), _)) -> ne +| IterE (_, (ListN (ne, _), _)) -> ne | _ -> LenE e $$ no_region % (NatT $ no_region) let is_null e = CmpE (EqOp, e, OptE None $$ no_region % e.note) $$ no_region % (BoolT $ e.at) @@ -39,7 +39,7 @@ let iter_side_conditions env ((iter, vs) : iterexp) : premise list = | _, [] -> [] | Opt, (e::es) -> List.map (fun e' -> iffE (is_null e) (is_null e')) es | (List|List1), (e::es) -> List.map (same_len e) es - | (ListN ne | IndexedListN (_, ne)), es -> List.map (has_len ne) es + | ListN (ne, _), es -> List.map (has_len ne) es (* Expr traversal *) let rec t_exp env e : premise list = @@ -87,7 +87,7 @@ let rec t_exp env e : premise list = and t_iterexp env (iter, _) = t_iter env iter and t_iter env = function - | IndexedListN (_, e) | ListN e -> t_exp env e + | ListN (e, _) -> t_exp env e | _ -> [] and t_path env path = match path.it with diff --git a/spectec/src/middlend/sub.ml b/spectec/src/middlend/sub.ml index 0b4ea008d3..c93f87052a 100644 --- a/spectec/src/middlend/sub.ml +++ b/spectec/src/middlend/sub.ml @@ -119,8 +119,7 @@ and t_exp' env = function | SubE (e, t1, t2) -> SubE (e, t1, t2) and t_iter env = function - | ListN e -> ListN (t_exp env e) - | IndexedListN (id, e) -> IndexedListN (id, t_exp env e) + | ListN (e, id) -> ListN (t_exp env e, id) | i -> i and t_iterexp env (iter, vs) = (t_iter env iter, vs) diff --git a/spectec/src/middlend/totalize.ml b/spectec/src/middlend/totalize.ml index c8cbc3bbaf..a6ad571bce 100644 --- a/spectec/src/middlend/totalize.ml +++ b/spectec/src/middlend/totalize.ml @@ -78,8 +78,7 @@ and t_exp' env = function | SubE (e, t1, t2) -> SubE (e, t1, t2) and t_iter env = function - | ListN e -> ListN (t_exp env e) - | IndexedListN (id, e) -> IndexedListN (id, t_exp env e) + | ListN (e, id) -> ListN (t_exp env e, id) | i -> i and t_iterexp env (iter, vs) = (t_iter env iter, vs) diff --git a/spectec/src/middlend/unthe.ml b/spectec/src/middlend/unthe.ml index ba3f595ebb..9ae131429c 100644 --- a/spectec/src/middlend/unthe.ml +++ b/spectec/src/middlend/unthe.ml @@ -156,9 +156,7 @@ and t_iterexp n (iter, vs) = unary t_iter n iter (fun iter' -> (iter', vs)) and t_iter n iter = match iter with - | ListN e -> unary t_exp n e (fun e' -> ListN e') - | IndexedListN (id, e) -> - unary t_exp n e (fun e' -> IndexedListN (id, e')) + | ListN (e, id) -> unary t_exp n e (fun e' -> ListN (e', id)) | _ -> [], iter and t_path n = phrase t_path' n diff --git a/spectec/src/middlend/wild.ml b/spectec/src/middlend/wild.ml index 97bc050415..dcfad4899c 100644 --- a/spectec/src/middlend/wild.ml +++ b/spectec/src/middlend/wild.ml @@ -180,9 +180,7 @@ and t_iterexp env (iter, vs) = unary t_iter env iter (fun iter' -> (iter', vs)) and t_iter env iter = match iter with - | ListN e -> unary t_exp env e (fun e' -> ListN e') - | IndexedListN (id, e) -> - unary t_exp env e (fun e' -> IndexedListN (id, e')) + | ListN (e, id) -> unary t_exp env e (fun e' -> ListN (e', id)) | _ -> [], iter and t_path env = phrase t_path' env diff --git a/spectec/test-frontend/TEST.md b/spectec/test-frontend/TEST.md index 441613731c..453a08f72e 100644 --- a/spectec/test-frontend/TEST.md +++ b/spectec/test-frontend/TEST.md @@ -4270,12 +4270,12 @@ $$ &&&\quad {\land}~{\mathit{ga}_{\mathit{ex}}^\ast} = \mathrm{globals}({\mathit{externval}^\ast}) \\ &&&\quad {\land}~{\mathit{ta}_{\mathit{ex}}^\ast} = \mathrm{tables}({\mathit{externval}^\ast}) \\ &&&\quad {\land}~{\mathit{ma}_{\mathit{ex}}^\ast} = \mathrm{mems}({\mathit{externval}^\ast}) \\ - &&&\quad {\land}~{\mathit{fa}^\ast} = {{|\mathit{s}.\mathsf{func}|} + \mathit{i}^{\mathit{i} < \mathit{n}_{\mathit{func}}}} \\ - &&&\quad {\land}~{\mathit{ga}^\ast} = {{|\mathit{s}.\mathsf{global}|} + \mathit{i}^{\mathit{i} < \mathit{n}_{\mathit{global}}}} \\ - &&&\quad {\land}~{\mathit{ta}^\ast} = {{|\mathit{s}.\mathsf{table}|} + \mathit{i}^{\mathit{i} < \mathit{n}_{\mathit{table}}}} \\ - &&&\quad {\land}~{\mathit{ma}^\ast} = {{|\mathit{s}.\mathsf{mem}|} + \mathit{i}^{\mathit{i} < \mathit{n}_{\mathit{mem}}}} \\ - &&&\quad {\land}~{\mathit{ea}^\ast} = {{|\mathit{s}.\mathsf{elem}|} + \mathit{i}^{\mathit{i} < \mathit{n}_{\mathit{elem}}}} \\ - &&&\quad {\land}~{\mathit{da}^\ast} = {{|\mathit{s}.\mathsf{data}|} + \mathit{i}^{\mathit{i} < \mathit{n}_{\mathit{data}}}} \\ + &&&\quad {\land}~{\mathit{fa}^\ast} = {{|\mathit{s}.\mathsf{func}|} + \mathit{i}^(i<\mathit{n}_{\mathit{func}})} \\ + &&&\quad {\land}~{\mathit{ga}^\ast} = {{|\mathit{s}.\mathsf{global}|} + \mathit{i}^(i<\mathit{n}_{\mathit{global}})} \\ + &&&\quad {\land}~{\mathit{ta}^\ast} = {{|\mathit{s}.\mathsf{table}|} + \mathit{i}^(i<\mathit{n}_{\mathit{table}})} \\ + &&&\quad {\land}~{\mathit{ma}^\ast} = {{|\mathit{s}.\mathsf{mem}|} + \mathit{i}^(i<\mathit{n}_{\mathit{mem}})} \\ + &&&\quad {\land}~{\mathit{ea}^\ast} = {{|\mathit{s}.\mathsf{elem}|} + \mathit{i}^(i<\mathit{n}_{\mathit{elem}})} \\ + &&&\quad {\land}~{\mathit{da}^\ast} = {{|\mathit{s}.\mathsf{data}|} + \mathit{i}^(i<\mathit{n}_{\mathit{data}})} \\ &&&\quad {\land}~{\mathit{xi}^\ast} = {\mathrm{instexport}({\mathit{fa}_{\mathit{ex}}^\ast}~{\mathit{fa}^\ast},\, {\mathit{ga}_{\mathit{ex}}^\ast}~{\mathit{ga}^\ast},\, {\mathit{ta}_{\mathit{ex}}^\ast}~{\mathit{ta}^\ast},\, {\mathit{ma}_{\mathit{ex}}^\ast}~{\mathit{ma}^\ast},\, \mathit{export})^\ast} \\ &&&\quad {\land}~\mathit{m} = \{ \begin{array}[t]{@{}l@{}} \mathsf{func}~{\mathit{fa}_{\mathit{ex}}^\ast}~{\mathit{fa}^\ast},\; \\ @@ -4346,9 +4346,9 @@ $$ &&&\quad {\land}~\mathit{f} = \{ \begin{array}[t]{@{}l@{}} \mathsf{local}~\epsilon,\; \mathsf{module}~\mathit{m} \}\end{array} \\ &&&\quad {\land}~\mathit{n}_{\mathit{elem}} = {|{\mathit{elem}^\ast}|} \\ - &&&\quad {\land}~{\mathit{instr}_{\mathit{elem}}^\ast} = \mathrm{concat}_{\mathit{instr}}({\mathrm{runelem}({\mathit{elem}^\ast}[\mathit{i}],\, \mathit{i})^{\mathit{i} < \mathit{n}_{\mathit{elem}}}}) \\ + &&&\quad {\land}~{\mathit{instr}_{\mathit{elem}}^\ast} = \mathrm{concat}_{\mathit{instr}}({\mathrm{runelem}({\mathit{elem}^\ast}[\mathit{i}],\, \mathit{i})^(i<\mathit{n}_{\mathit{elem}})}) \\ &&&\quad {\land}~\mathit{n}_{\mathit{data}} = {|{\mathit{data}^\ast}|} \\ - &&&\quad {\land}~{\mathit{instr}_{\mathit{data}}^\ast} = \mathrm{concat}_{\mathit{instr}}({\mathrm{rundata}({\mathit{data}^\ast}[\mathit{j}],\, \mathit{j})^{\mathit{j} < \mathit{n}_{\mathit{data}}}}) \\ + &&&\quad {\land}~{\mathit{instr}_{\mathit{data}}^\ast} = \mathrm{concat}_{\mathit{instr}}({\mathrm{rundata}({\mathit{data}^\ast}[\mathit{j}],\, \mathit{j})^(j<\mathit{n}_{\mathit{data}})}) \\ &&&\quad {\land}~{\mathit{start}^?} = {(\mathsf{start}~\mathit{x})^?} \\ \end{array} $$ From 6872abefd4f585464e71efa93e659351f5572cb1 Mon Sep 17 00:00:00 2001 From: Wonho Date: Fri, 21 Jul 2023 16:06:15 +0900 Subject: [PATCH 38/49] Fix bug in iter with index --- spectec/spec/7-module.watsup | 12 +-- spectec/src/el/free.ml | 4 +- spectec/src/frontend/multiplicity.ml | 17 ++-- spectec/src/il/free.ml | 4 +- spectec/test-frontend/TEST.md | 32 +++--- spectec/test-middlend/TEST.md | 140 +++++++++++++-------------- 6 files changed, 103 insertions(+), 106 deletions(-) diff --git a/spectec/spec/7-module.watsup b/spectec/spec/7-module.watsup index 7798871280..72e8027d6a 100644 --- a/spectec/spec/7-module.watsup +++ b/spectec/spec/7-module.watsup @@ -111,12 +111,12 @@ def $allocmodule(s, module, externval*, val*, (ref*)*) = (s_6, m) -- if ga_ex* = $globals(externval*) -- if ta_ex* = $tables(externval*) -- if ma_ex* = $mems(externval*) - -- if fa* = $(|s.FUNC|+i)^(i empty - | ListN (e, None) -> free_exp e - | ListN (e, Some (id)) -> - union (free_exp e) (free_varid id) + | ListN (e, _) -> free_exp e (* Types *) diff --git a/spectec/src/frontend/multiplicity.ml b/spectec/src/frontend/multiplicity.ml index 47ee4032ef..e3e9519c26 100644 --- a/spectec/src/frontend/multiplicity.ml +++ b/spectec/src/frontend/multiplicity.ml @@ -68,8 +68,7 @@ let iter_nl_list f xs = List.iter (function Nl -> () | Elem x -> f x) xs let rec check_iter env ctx iter = match iter with | Opt | List | List1 -> () - | ListN (e, opt) -> - Option.iter (fun id -> check_id env ctx id) opt; + | ListN (e, _) -> check_exp env ctx e and check_exp env ctx e = @@ -163,13 +162,9 @@ let union = Env.union (fun _ ctx1 ctx2 -> assert (ctx1 = ctx2); Some ctx1) let rec annot_iter env iter : Il.Ast.iter * occur = match iter with | Opt | List | List1 -> iter, Env.empty - | ListN (e, None) -> + | ListN (e, opt) -> let e', occur = annot_exp env e in - ListN (e', None), occur - | ListN (e, Some id) -> - let e', occur1 = annot_exp env e in - let occur2 = Env.singleton id.it (Env.find id.it env) in - ListN (e', Some id), union occur1 occur2 + ListN (e', opt), occur and annot_exp env e : Il.Ast.exp * occur = let it, occur = @@ -290,6 +285,12 @@ and annot_iterexp env occur1 (iter, ids) at : Il.Ast.iterexp * occur = ) occur1 in let ids' = List.map (fun (x, _) -> x $ at) (Env.bindings occur1') in + + (match iter' with + | ListN (_, Some id) -> + assert (List.length ids' = 1 && id.it = (List.hd ids').it) + | _ -> ()); + (iter', ids'), union occur1' occur2 diff --git a/spectec/src/il/free.ml b/spectec/src/il/free.ml index 6ed62def48..5bc554d498 100644 --- a/spectec/src/il/free.ml +++ b/spectec/src/il/free.ml @@ -55,9 +55,7 @@ let free_defid id = {empty with defid = Set.singleton id.it} let rec free_iter iter = match iter with | Opt | List | List1 -> empty - | ListN (e, None) -> free_exp e - | ListN (e, Some id) -> - union (free_exp e) (free_varid id) + | ListN (e, _) -> free_exp e (* Types *) diff --git a/spectec/test-frontend/TEST.md b/spectec/test-frontend/TEST.md index 453a08f72e..c713d88e61 100644 --- a/spectec/test-frontend/TEST.md +++ b/spectec/test-frontend/TEST.md @@ -1865,18 +1865,18 @@ def allocdatas : (store, byte**) -> (store, dataaddr*) ;; 7-module.watsup:97.1-97.81 def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) ;; 7-module.watsup:98.1-135.54 - def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i : nat, import* : import*, m : moduleinst, ma* : memaddr*, ma_ex* : memaddr*, memtype^n_mem : memtype^n_mem, module : module, n_data : n, n_elem : n, n_func : n, n_global : n, n_mem : n, n_table : n, ref** : ref**, rt^n_elem : reftype^n_elem, s : store, s_1 : store, s_2 : store, s_3 : store, s_4 : store, s_5 : store, s_6 : store, start? : start?, ta* : tableaddr*, ta_ex* : tableaddr*, tabletype^n_table : tabletype^n_table, val* : val*, xi* : exportinst*} allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref}) = (s_6, m) + def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i_data^(i_data instr* ;; 7-module.watsup:157.1-157.55 def instantiation : (store, module, externval*) -> config ;; 7-module.watsup:158.1-180.28 - def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i : nat, import* : import*, instr_1** : instr**, instr_2*** : instr***, instr_data* : instr*, instr_elem* : instr*, j : nat, m : moduleinst, m_init : moduleinst, mem* : mem*, module : module, n_data : n, n_elem : n, ref** : ref**, reftype* : reftype*, s : store, s' : store, start? : start?, table* : table*, val* : val*, x? : idx?} instantiation(s, module, externval*{externval}) = `%;%*`(`%;%`(s', f), (instr_elem <: admininstr)*{instr_elem} :: (instr_data <: admininstr)*{instr_data} :: CALL_admininstr(x)?{x}) + def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i^(i config -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) -- if (f = {LOCAL [], MODULE m}) -- if (n_elem = |elem*{elem}|) - -- if (instr_elem*{instr_elem} = $concat_instr($runelem(elem*{elem}[i], i)^(i (store, dataaddr*) ;; 7-module.watsup:97.1-97.81 def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) ;; 7-module.watsup:98.1-135.54 - def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i : nat, import* : import*, m : moduleinst, ma* : memaddr*, ma_ex* : memaddr*, memtype^n_mem : memtype^n_mem, module : module, n_data : n, n_elem : n, n_func : n, n_global : n, n_mem : n, n_table : n, ref** : ref**, rt^n_elem : reftype^n_elem, s : store, s_1 : store, s_2 : store, s_3 : store, s_4 : store, s_5 : store, s_6 : store, start? : start?, ta* : tableaddr*, ta_ex* : tableaddr*, tabletype^n_table : tabletype^n_table, val* : val*, xi* : exportinst*} allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref}) = (s_6, m) + def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i_data^(i_data instr* ;; 7-module.watsup:157.1-157.55 def instantiation : (store, module, externval*) -> config ;; 7-module.watsup:158.1-180.28 - def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i : nat, import* : import*, instr_1** : instr**, instr_2*** : instr***, instr_data* : instr*, instr_elem* : instr*, j : nat, m : moduleinst, m_init : moduleinst, mem* : mem*, module : module, n_data : n, n_elem : n, ref** : ref**, reftype* : reftype*, s : store, s' : store, start? : start?, table* : table*, val* : val*, x? : idx?} instantiation(s, module, externval*{externval}) = `%;%*`(`%;%`(s', f), (instr_elem <: admininstr)*{instr_elem} :: (instr_data <: admininstr)*{instr_data} :: CALL_admininstr(x)?{x}) + def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i^(i config -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) -- if (f = {LOCAL [], MODULE m}) -- if (n_elem = |elem*{elem}|) - -- if (instr_elem*{instr_elem} = $concat_instr($runelem(elem*{elem}[i], i)^(i (store, dataaddr*) ;; 7-module.watsup:97.1-97.81 def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) ;; 7-module.watsup:98.1-135.54 - def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i : nat, import* : import*, m : moduleinst, ma* : memaddr*, ma_ex* : memaddr*, memtype^n_mem : memtype^n_mem, module : module, n_data : n, n_elem : n, n_func : n, n_global : n, n_mem : n, n_table : n, ref** : ref**, rt^n_elem : reftype^n_elem, s : store, s_1 : store, s_2 : store, s_3 : store, s_4 : store, s_5 : store, s_6 : store, start? : start?, ta* : tableaddr*, ta_ex* : tableaddr*, tabletype^n_table : tabletype^n_table, val* : val*, xi* : exportinst*} allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref}) = (s_6, m) + def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i_data^(i_data instr* ;; 7-module.watsup:157.1-157.55 def instantiation : (store, module, externval*) -> config ;; 7-module.watsup:158.1-180.28 - def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i : nat, import* : import*, instr_1** : instr**, instr_2*** : instr***, instr_data* : instr*, instr_elem* : instr*, j : nat, m : moduleinst, m_init : moduleinst, mem* : mem*, module : module, n_data : n, n_elem : n, ref** : ref**, reftype* : reftype*, s : store, s' : store, start? : start?, table* : table*, val* : val*, x? : idx?} instantiation(s, module, externval*{externval}) = `%;%*`(`%;%`(s', f), $admininstr_instr(instr_elem)*{instr_elem} :: $admininstr_instr(instr_data)*{instr_data} :: CALL_admininstr(x)?{x}) + def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i^(i config -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) -- if (f = {LOCAL [], MODULE m}) -- if (n_elem = |elem*{elem}|) - -- if (instr_elem*{instr_elem} = $concat_instr($runelem(elem*{elem}[i], i)^(i (store, dataaddr*) ;; 7-module.watsup:97.1-97.81 def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) ;; 7-module.watsup:98.1-135.54 - def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i : nat, import* : import*, m : moduleinst, ma* : memaddr*, ma_ex* : memaddr*, memtype^n_mem : memtype^n_mem, module : module, n_data : n, n_elem : n, n_func : n, n_global : n, n_mem : n, n_table : n, ref** : ref**, rt^n_elem : reftype^n_elem, s : store, s_1 : store, s_2 : store, s_3 : store, s_4 : store, s_5 : store, s_6 : store, start? : start?, ta* : tableaddr*, ta_ex* : tableaddr*, tabletype^n_table : tabletype^n_table, val* : val*, xi* : exportinst*} allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref}) = (s_6, m) + def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i_data^(i_data instr* ;; 7-module.watsup:157.1-157.55 def instantiation : (store, module, externval*) -> config ;; 7-module.watsup:158.1-180.28 - def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i : nat, import* : import*, instr_1** : instr**, instr_2*** : instr***, instr_data* : instr*, instr_elem* : instr*, j : nat, m : moduleinst, m_init : moduleinst, mem* : mem*, module : module, n_data : n, n_elem : n, ref** : ref**, reftype* : reftype*, s : store, s' : store, start? : start?, table* : table*, val* : val*, x? : idx?} instantiation(s, module, externval*{externval}) = `%;%*`(`%;%`(s', f), $admininstr_instr(instr_elem)*{instr_elem} :: $admininstr_instr(instr_data)*{instr_data} :: CALL_admininstr(x)?{x}) + def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i^(i config -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) -- if (f = {LOCAL [], MODULE m}) -- if (n_elem = |elem*{elem}|) - -- if (instr_elem*{instr_elem} = $concat_instr($runelem(elem*{elem}[i], i)^(i (store, dataaddr*) ;; 7-module.watsup:97.1-97.81 def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) ;; 7-module.watsup:98.1-135.54 - def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i : nat, import* : import*, m : moduleinst, ma* : memaddr*, ma_ex* : memaddr*, memtype^n_mem : memtype^n_mem, module : module, n_data : n, n_elem : n, n_func : n, n_global : n, n_mem : n, n_table : n, ref** : ref**, rt^n_elem : reftype^n_elem, s : store, s_1 : store, s_2 : store, s_3 : store, s_4 : store, s_5 : store, s_6 : store, start? : start?, ta* : tableaddr*, ta_ex* : tableaddr*, tabletype^n_table : tabletype^n_table, val* : val*, xi* : exportinst*} allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref}) = (s_6, m) + def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i_data^(i_data instr* ;; 7-module.watsup:157.1-157.55 def instantiation : (store, module, externval*) -> config ;; 7-module.watsup:158.1-180.28 - def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i : nat, import* : import*, instr_1** : instr**, instr_2*** : instr***, instr_data* : instr*, instr_elem* : instr*, j : nat, m : moduleinst, m_init : moduleinst, mem* : mem*, module : module, n_data : n, n_elem : n, ref** : ref**, reftype* : reftype*, s : store, s' : store, start? : start?, table* : table*, val* : val*, x? : idx?} instantiation(s, module, externval*{externval}) = `%;%*`(`%;%`(s', f), $admininstr_instr(instr_elem)*{instr_elem} :: $admininstr_instr(instr_data)*{instr_data} :: CALL_admininstr(x)?{x}) + def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i^(i config -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) -- if (f = {LOCAL [], MODULE m}) -- if (n_elem = |elem*{elem}|) - -- if (instr_elem*{instr_elem} = $concat_instr($runelem(elem*{elem}[i], i)^(i (store, dataaddr*) ;; 7-module.watsup:97.1-97.81 def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) ;; 7-module.watsup:98.1-135.54 - def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i : nat, import* : import*, m : moduleinst, ma* : memaddr*, ma_ex* : memaddr*, memtype^n_mem : memtype^n_mem, module : module, n_data : n, n_elem : n, n_func : n, n_global : n, n_mem : n, n_table : n, ref** : ref**, rt^n_elem : reftype^n_elem, s : store, s_1 : store, s_2 : store, s_3 : store, s_4 : store, s_5 : store, s_6 : store, start? : start?, ta* : tableaddr*, ta_ex* : tableaddr*, tabletype^n_table : tabletype^n_table, val* : val*, xi* : exportinst*} allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref}) = (s_6, m) + def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i_data^(i_data instr* ;; 7-module.watsup:157.1-157.55 def instantiation : (store, module, externval*) -> config ;; 7-module.watsup:158.1-180.28 - def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i : nat, import* : import*, instr_1** : instr**, instr_2*** : instr***, instr_data* : instr*, instr_elem* : instr*, j : nat, m : moduleinst, m_init : moduleinst, mem* : mem*, module : module, n_data : n, n_elem : n, ref** : ref**, reftype* : reftype*, s : store, s' : store, start? : start?, table* : table*, val* : val*, x? : idx?} instantiation(s, module, externval*{externval}) = `%;%*`(`%;%`(s', f), $admininstr_instr(instr_elem)*{instr_elem} :: $admininstr_instr(instr_data)*{instr_data} :: CALL_admininstr(x)?{x}) + def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i^(i config -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) -- if (f = {LOCAL [], MODULE m}) -- if (n_elem = |elem*{elem}|) - -- if (instr_elem*{instr_elem} = $concat_instr($runelem(elem*{elem}[i], i)^(i (store, dataaddr*) ;; 7-module.watsup:97.1-97.81 def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) ;; 7-module.watsup:98.1-135.54 - def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i : nat, import* : import*, m : moduleinst, ma* : memaddr*, ma_ex* : memaddr*, memtype^n_mem : memtype^n_mem, module : module, n_data : n, n_elem : n, n_func : n, n_global : n, n_mem : n, n_table : n, ref** : ref**, rt^n_elem : reftype^n_elem, s : store, s_1 : store, s_2 : store, s_3 : store, s_4 : store, s_5 : store, s_6 : store, start? : start?, ta* : tableaddr*, ta_ex* : tableaddr*, tabletype^n_table : tabletype^n_table, val* : val*, xi* : exportinst*} allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref}) = (s_6, m) + def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i_data^(i_data instr* ;; 7-module.watsup:157.1-157.55 def instantiation : (store, module, externval*) -> config ;; 7-module.watsup:158.1-180.28 - def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i : nat, import* : import*, instr_1** : instr**, instr_2*** : instr***, instr_data* : instr*, instr_elem* : instr*, j : nat, m : moduleinst, m_init : moduleinst, mem* : mem*, module : module, n_data : n, n_elem : n, ref** : ref**, reftype* : reftype*, s : store, s' : store, start? : start?, table* : table*, val* : val*, x? : idx?} instantiation(s, module, externval*{externval}) = `%;%*`(`%;%`(s', f), $admininstr_instr(instr_elem)*{instr_elem} :: $admininstr_instr(instr_data)*{instr_data} :: CALL_admininstr(x)?{x}) + def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i^(i config -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) -- if (f = {LOCAL [], MODULE m}) -- if (n_elem = |elem*{elem}|) - -- if (instr_elem*{instr_elem} = $concat_instr($runelem(elem*{elem}[i], i)^(i (store, dataaddr*) ;; 7-module.watsup:97.1-97.81 def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) ;; 7-module.watsup:98.1-135.54 - def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i : nat, import* : import*, m : moduleinst, ma* : memaddr*, ma_ex* : memaddr*, memtype^n_mem : memtype^n_mem, module : module, n_data : n, n_elem : n, n_func : n, n_global : n, n_mem : n, n_table : n, ref** : ref**, rt^n_elem : reftype^n_elem, s : store, s_1 : store, s_2 : store, s_3 : store, s_4 : store, s_5 : store, s_6 : store, start? : start?, ta* : tableaddr*, ta_ex* : tableaddr*, tabletype^n_table : tabletype^n_table, val* : val*, xi* : exportinst*} allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref}) = (s_6, m) + def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i_data^(i_data instr* ;; 7-module.watsup:157.1-157.55 def instantiation : (store, module, externval*) -> config ;; 7-module.watsup:158.1-180.28 - def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i : nat, import* : import*, instr_1** : instr**, instr_2*** : instr***, instr_data* : instr*, instr_elem* : instr*, j : nat, m : moduleinst, m_init : moduleinst, mem* : mem*, module : module, n_data : n, n_elem : n, ref** : ref**, reftype* : reftype*, s : store, s' : store, start? : start?, table* : table*, val* : val*, x? : idx?} instantiation(s, module, externval*{externval}) = `%;%*`(`%;%`(s', f), $admininstr_instr(instr_elem)*{instr_elem} :: $admininstr_instr(instr_data)*{instr_data} :: CALL_admininstr(x)?{x}) + def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i^(i config -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) -- if (f = {LOCAL [], MODULE m}) -- if (n_elem = |elem*{elem}|) - -- if (instr_elem*{instr_elem} = $concat_instr($runelem(elem*{elem}[i], i)^(i Date: Mon, 24 Jul 2023 13:19:01 +0900 Subject: [PATCH 39/49] Minor changes --- spectec/src/backend-latex/render.ml | 12 ++++++------ spectec/src/el/eq.ml | 2 +- spectec/src/el/print.ml | 3 +-- spectec/src/frontend/elab.ml | 2 +- spectec/src/frontend/multiplicity.ml | 4 ++-- spectec/src/frontend/parser.mly | 2 +- spectec/src/il/eq.ml | 2 +- spectec/src/il/validation.ml | 6 +----- spectec/src/middlend/sub.ml | 2 +- spectec/src/middlend/totalize.ml | 2 +- spectec/src/middlend/unthe.ml | 2 +- spectec/src/middlend/wild.ml | 2 +- 12 files changed, 18 insertions(+), 23 deletions(-) diff --git a/spectec/src/backend-latex/render.ml b/spectec/src/backend-latex/render.ml index f1ee53327f..29fd1840f2 100644 --- a/spectec/src/backend-latex/render.ml +++ b/spectec/src/backend-latex/render.ml @@ -327,7 +327,7 @@ exception Arity_mismatch let rec expand_iter args iter = match iter with | Opt | List | List1 -> iter - | ListN (e, opt) -> ListN (expand_exp args e, opt) + | ListN (e, id_opt) -> ListN (expand_exp args e, id_opt) and expand_exp args e = expand_exp' args e.it $ e.at and expand_exp' args e' = @@ -442,9 +442,9 @@ and render_iter env = function | List -> "^\\ast" | List1 -> "^{+}" | ListN ({it = ParenE (e, _); _}, None) | ListN (e, None) -> - "^{" ^ render_exp env e ^ "}" + "^{" ^ render_exp env e ^ "}" | ListN (e, Some id) -> - "^(" ^ id.it ^ "<" ^ render_exp env e ^ ")" + "^(" ^ id.it ^ "<" ^ render_exp env e ^ ")" (* Types *) @@ -687,7 +687,7 @@ let render_ruledef env d = render_rule_deco env " \\, " id1 id2 "" | _ -> failwith "render_ruledef" -let render_condition env tabs = function +let render_conditions env tabs = function | [] -> " & " | [Elem {it = ElsePr; _}] -> " &\\quad\n " ^ word "otherwise" | (Elem {it = ElsePr; _})::prems -> @@ -708,14 +708,14 @@ let render_reddef env d = in render_rule_deco env "" id1 id2 " \\quad " ^ "& " ^ render_exp env e1 ^ " &" ^ render_atom env SqArrow ^ "& " ^ - render_exp env e2 ^ render_condition env "&&&&" prems + render_exp env e2 ^ render_conditions env "&&&&" prems | _ -> failwith "render_reddef" let render_funcdef env d = match d.it with | DefD (id1, e1, e2, prems) -> render_exp env (CallE (id1, e1) $ d.at) ^ " &=& " ^ - render_exp env e2 ^ render_condition env "&&&" prems + render_exp env e2 ^ render_conditions env "&&&" prems | _ -> failwith "render_funcdef" let rec render_sep_defs ?(sep = " \\\\\n") ?(br = " \\\\[0.8ex]\n") f = function diff --git a/spectec/src/el/eq.ml b/spectec/src/el/eq.ml index e8a42e6e28..5d57318b09 100644 --- a/spectec/src/el/eq.ml +++ b/spectec/src/el/eq.ml @@ -22,7 +22,7 @@ let rec eq_iter iter1 iter2 = match iter1, iter2 with | ListN (e1, None), ListN (e2, None) -> eq_exp e1 e2 | ListN (e1, Some id1), ListN (e2, Some id2) -> - eq_exp e1 e2 && id1.it = id2.it + eq_exp e1 e2 && id1.it = id2.it | _, _ -> false diff --git a/spectec/src/el/print.ml b/spectec/src/el/print.ml index e5f92a73b9..4e0342fd37 100644 --- a/spectec/src/el/print.ml +++ b/spectec/src/el/print.ml @@ -71,8 +71,7 @@ let rec string_of_iter iter = | List -> "*" | List1 -> "+" | ListN (e, None) -> "^" ^ string_of_exp e - | ListN (e, Some (id)) -> - "^(" ^ id.it ^ "<" ^ string_of_exp e ^ ")" + | ListN (e, Some (id)) -> "^(" ^ id.it ^ "<" ^ string_of_exp e ^ ")" (* Types *) diff --git a/spectec/src/frontend/elab.ml b/spectec/src/frontend/elab.ml index e5666fc7c7..6418653a38 100644 --- a/spectec/src/frontend/elab.ml +++ b/spectec/src/frontend/elab.ml @@ -336,7 +336,7 @@ let rec elab_iter env iter : Il.iter = | Opt -> Il.Opt | List -> Il.List | List1 -> Il.List1 - | ListN (e, opt) -> Il.ListN (elab_exp env e (NatT $ e.at), opt) + | ListN (e, id_opt) -> Il.ListN (elab_exp env e (NatT $ e.at), id_opt) (* Types *) diff --git a/spectec/src/frontend/multiplicity.ml b/spectec/src/frontend/multiplicity.ml index e3e9519c26..64c618607b 100644 --- a/spectec/src/frontend/multiplicity.ml +++ b/spectec/src/frontend/multiplicity.ml @@ -162,9 +162,9 @@ let union = Env.union (fun _ ctx1 ctx2 -> assert (ctx1 = ctx2); Some ctx1) let rec annot_iter env iter : Il.Ast.iter * occur = match iter with | Opt | List | List1 -> iter, Env.empty - | ListN (e, opt) -> + | ListN (e, id_opt) -> let e', occur = annot_exp env e in - ListN (e', opt), occur + ListN (e', id_opt), occur and annot_exp env e : Il.Ast.exp * occur = let it, occur = diff --git a/spectec/src/frontend/parser.mly b/spectec/src/frontend/parser.mly index 854bb36911..596243a7a2 100644 --- a/spectec/src/frontend/parser.mly +++ b/spectec/src/frontend/parser.mly @@ -142,7 +142,7 @@ iter : | UP arith_prim { match $2.it with | ParenE ({ it = CmpE({ it = VarE id; _ }, LtOp, e); _}, false) -> - ListN (e, Some id) + ListN (e, Some id) | _ -> ListN ($2, None) } diff --git a/spectec/src/il/eq.ml b/spectec/src/il/eq.ml index 6dc8952718..47bdae7f62 100644 --- a/spectec/src/il/eq.ml +++ b/spectec/src/il/eq.ml @@ -26,7 +26,7 @@ let rec eq_iter iter1 iter2 = match iter1, iter2 with | ListN (e1, None), ListN (e2, None) -> eq_exp e1 e2 | ListN (e1, Some id1), ListN (e2, Some id2) -> - eq_exp e1 e2 && id1.it = id2.it + eq_exp e1 e2 && id1.it = id2.it | _, _ -> false diff --git a/spectec/src/il/validation.ml b/spectec/src/il/validation.ml index c4b7238c44..97e2e9c1d6 100644 --- a/spectec/src/il/validation.ml +++ b/spectec/src/il/validation.ml @@ -314,11 +314,7 @@ and infer_exp env e : typ = | CallE (id, _) -> snd (find "function" env.defs id) | MixE _ -> error e.at "cannot infer type of mixin notation" | IterE (e1, iter) -> - let iter' = - match fst iter with - | ListN _ -> List - | iter' -> iter' - in + let iter' = match fst iter with ListN _ -> List | iter' -> iter' in IterT (infer_exp env e1, iter') $ e.at | OptE _ -> error e.at "cannot infer type of option" | TheE e1 -> as_iter_typ Opt "option" env Check (infer_exp env e1) e1.at diff --git a/spectec/src/middlend/sub.ml b/spectec/src/middlend/sub.ml index c93f87052a..a2c4d82655 100644 --- a/spectec/src/middlend/sub.ml +++ b/spectec/src/middlend/sub.ml @@ -119,7 +119,7 @@ and t_exp' env = function | SubE (e, t1, t2) -> SubE (e, t1, t2) and t_iter env = function - | ListN (e, id) -> ListN (t_exp env e, id) + | ListN (e, id_opt) -> ListN (t_exp env e, id_opt) | i -> i and t_iterexp env (iter, vs) = (t_iter env iter, vs) diff --git a/spectec/src/middlend/totalize.ml b/spectec/src/middlend/totalize.ml index a6ad571bce..4c8c98e787 100644 --- a/spectec/src/middlend/totalize.ml +++ b/spectec/src/middlend/totalize.ml @@ -78,7 +78,7 @@ and t_exp' env = function | SubE (e, t1, t2) -> SubE (e, t1, t2) and t_iter env = function - | ListN (e, id) -> ListN (t_exp env e, id) + | ListN (e, id_opt) -> ListN (t_exp env e, id_opt) | i -> i and t_iterexp env (iter, vs) = (t_iter env iter, vs) diff --git a/spectec/src/middlend/unthe.ml b/spectec/src/middlend/unthe.ml index 9ae131429c..3ed9ef98b3 100644 --- a/spectec/src/middlend/unthe.ml +++ b/spectec/src/middlend/unthe.ml @@ -156,7 +156,7 @@ and t_iterexp n (iter, vs) = unary t_iter n iter (fun iter' -> (iter', vs)) and t_iter n iter = match iter with - | ListN (e, id) -> unary t_exp n e (fun e' -> ListN (e', id)) + | ListN (e, id_opt) -> unary t_exp n e (fun e' -> ListN (e', id_opt)) | _ -> [], iter and t_path n = phrase t_path' n diff --git a/spectec/src/middlend/wild.ml b/spectec/src/middlend/wild.ml index dcfad4899c..f2b395555f 100644 --- a/spectec/src/middlend/wild.ml +++ b/spectec/src/middlend/wild.ml @@ -180,7 +180,7 @@ and t_iterexp env (iter, vs) = unary t_iter env iter (fun iter' -> (iter', vs)) and t_iter env iter = match iter with - | ListN (e, id) -> unary t_exp env e (fun e' -> ListN (e', id)) + | ListN (e, id_opt) -> unary t_exp env e (fun e' -> ListN (e', id_opt)) | _ -> [], iter and t_path env = phrase t_path' env From d764e973c40c42e49aeee51ba35d807352b50313 Mon Sep 17 00:00:00 2001 From: Wonho Date: Mon, 24 Jul 2023 13:22:24 +0900 Subject: [PATCH 40/49] Minor change --- spectec/src/frontend/parser.mly | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spectec/src/frontend/parser.mly b/spectec/src/frontend/parser.mly index 596243a7a2..6b9660526b 100644 --- a/spectec/src/frontend/parser.mly +++ b/spectec/src/frontend/parser.mly @@ -141,7 +141,7 @@ iter : | STAR { List } | UP arith_prim { match $2.it with - | ParenE ({ it = CmpE({ it = VarE id; _ }, LtOp, e); _}, false) -> + | ParenE ({it = CmpE({it = VarE id; _}, LtOp, e); _}, false) -> ListN (e, Some id) | _ -> ListN ($2, None) } From 5c9aed2b0ce2275b4153afb746366f0b59b15dc8 Mon Sep 17 00:00:00 2001 From: Wonho Date: Mon, 24 Jul 2023 15:55:18 +0900 Subject: [PATCH 41/49] Check iter with index --- spectec/src/el/free.ml | 3 ++- spectec/src/frontend/multiplicity.ml | 11 ++++++++--- spectec/src/il/free.ml | 2 +- spectec/src/il/validation.ml | 10 +++++++++- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/spectec/src/el/free.ml b/spectec/src/el/free.ml index 00f741fa4a..bb5d3e0af0 100644 --- a/spectec/src/el/free.ml +++ b/spectec/src/el/free.ml @@ -18,6 +18,7 @@ let union sets1 sets2 = defid = Set.union sets1.defid sets2.defid; } +let free_opt free_x xo = Option.(value (map free_x xo) ~default:empty) let free_list free_x xs = List.(fold_left union empty (map free_x xs)) let free_nl_elem free_x = function Nl -> empty | Elem x -> free_x x @@ -37,7 +38,7 @@ let free_defid id = {empty with defid = Set.singleton id.it} let rec free_iter iter = match iter with | Opt | List | List1 -> empty - | ListN (e, _) -> free_exp e + | ListN (e, id_opt) -> union (free_exp e) (free_opt free_varid id_opt) (* Types *) diff --git a/spectec/src/frontend/multiplicity.ml b/spectec/src/frontend/multiplicity.ml index 64c618607b..dedb6f587d 100644 --- a/spectec/src/frontend/multiplicity.ml +++ b/spectec/src/frontend/multiplicity.ml @@ -68,7 +68,8 @@ let iter_nl_list f xs = List.iter (function Nl -> () | Elem x -> f x) xs let rec check_iter env ctx iter = match iter with | Opt | List | List1 -> () - | ListN (e, _) -> + | ListN (e, opt) -> + Option.iter (fun id -> check_id env (iter::ctx) id) opt; check_exp env ctx e and check_exp env ctx e = @@ -162,9 +163,13 @@ let union = Env.union (fun _ ctx1 ctx2 -> assert (ctx1 = ctx2); Some ctx1) let rec annot_iter env iter : Il.Ast.iter * occur = match iter with | Opt | List | List1 -> iter, Env.empty - | ListN (e, id_opt) -> + | ListN (e, None) -> let e', occur = annot_exp env e in - ListN (e', id_opt), occur + ListN (e', None), occur + | ListN (e, Some id) -> + let e', occur1 = annot_exp env e in + let occur2 = Env.singleton id.it [] in + ListN (e', Some id), union occur1 occur2 and annot_exp env e : Il.Ast.exp * occur = let it, occur = diff --git a/spectec/src/il/free.ml b/spectec/src/il/free.ml index 5bc554d498..f27b533e48 100644 --- a/spectec/src/il/free.ml +++ b/spectec/src/il/free.ml @@ -55,7 +55,7 @@ let free_defid id = {empty with defid = Set.singleton id.it} let rec free_iter iter = match iter with | Opt | List | List1 -> empty - | ListN (e, _) -> free_exp e + | ListN (e, id_opt) -> union (free_exp e) (free_opt free_varid id_opt) (* Types *) diff --git a/spectec/src/il/validation.ml b/spectec/src/il/validation.ml index 97e2e9c1d6..af6d3a8d19 100644 --- a/spectec/src/il/validation.ml +++ b/spectec/src/il/validation.ml @@ -241,7 +241,15 @@ let valid_list valid_x_y env xs ys at = let rec valid_iter env iter = match iter with | Opt | List | List1 -> () - | ListN (e, _) -> valid_exp env e (NatT $ e.at) + | ListN (e, None) -> valid_exp env e (NatT $ e.at) + | ListN (e, Some id) -> + valid_exp env e (NatT $ e.at); + let t', dim = find "variable" env.vars id in + equiv_typ env t' (NatT $ e.at) e.at; + if dim <> [iter] then + error e.at ("use of iterated variable `" ^ + id.it ^ String.concat "" (List.map string_of_iter dim) ^ + "` outside suitable iteraton context") (* Types *) From ba5b056b60dd485e3a48b6bdaf8662435bef3bfb Mon Sep 17 00:00:00 2001 From: Wonho Date: Wed, 26 Jul 2023 15:04:37 +0900 Subject: [PATCH 42/49] Minor changes --- spectec/src/el/print.ml | 2 +- spectec/src/frontend/multiplicity.ml | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/spectec/src/el/print.ml b/spectec/src/el/print.ml index 4e0342fd37..67373fe75c 100644 --- a/spectec/src/el/print.ml +++ b/spectec/src/el/print.ml @@ -71,7 +71,7 @@ let rec string_of_iter iter = | List -> "*" | List1 -> "+" | ListN (e, None) -> "^" ^ string_of_exp e - | ListN (e, Some (id)) -> "^(" ^ id.it ^ "<" ^ string_of_exp e ^ ")" + | ListN (e, Some id) -> "^(" ^ id.it ^ "<" ^ string_of_exp e ^ ")" (* Types *) diff --git a/spectec/src/frontend/multiplicity.ml b/spectec/src/frontend/multiplicity.ml index dedb6f587d..c1cb45ed78 100644 --- a/spectec/src/frontend/multiplicity.ml +++ b/spectec/src/frontend/multiplicity.ml @@ -68,9 +68,9 @@ let iter_nl_list f xs = List.iter (function Nl -> () | Elem x -> f x) xs let rec check_iter env ctx iter = match iter with | Opt | List | List1 -> () - | ListN (e, opt) -> - Option.iter (fun id -> check_id env (iter::ctx) id) opt; - check_exp env ctx e + | ListN (e, id_opt) -> + Option.iter (fun id -> check_id env (iter::ctx) id) id_opt; + check_exp env ctx e and check_exp env ctx e = match e.it with @@ -163,13 +163,11 @@ let union = Env.union (fun _ ctx1 ctx2 -> assert (ctx1 = ctx2); Some ctx1) let rec annot_iter env iter : Il.Ast.iter * occur = match iter with | Opt | List | List1 -> iter, Env.empty - | ListN (e, None) -> - let e', occur = annot_exp env e in - ListN (e', None), occur - | ListN (e, Some id) -> + | ListN (e, id_opt) -> let e', occur1 = annot_exp env e in - let occur2 = Env.singleton id.it [] in - ListN (e', Some id), union occur1 occur2 + let occur2 = + match id_opt with None -> Env.empty | Some id -> Env.singleton id.it [] in + ListN (e', id_opt), union occur1 occur2 and annot_exp env e : Il.Ast.exp * occur = let it, occur = From 31213dd1877e1ed18a5d08f54c452960e9431539 Mon Sep 17 00:00:00 2001 From: Wonho Date: Wed, 26 Jul 2023 15:27:24 +0900 Subject: [PATCH 43/49] Strip index variable in iter --- spectec/src/frontend/multiplicity.ml | 17 +++++++++++++---- spectec/src/il/validation.ml | 15 ++++++--------- spectec/test-frontend/TEST.md | 4 ++-- spectec/test-middlend/TEST.md | 28 ++++++++++++++-------------- 4 files changed, 35 insertions(+), 29 deletions(-) diff --git a/spectec/src/frontend/multiplicity.ml b/spectec/src/frontend/multiplicity.ml index c1cb45ed78..0bdf4578d8 100644 --- a/spectec/src/frontend/multiplicity.ml +++ b/spectec/src/frontend/multiplicity.ml @@ -65,11 +65,15 @@ let check_id env ctx id = let iter_nl_list f xs = List.iter (function Nl -> () | Elem x -> f x) xs +let strip_index = function + | ListN (e, Some _) -> ListN (e, None) + | iter -> iter + let rec check_iter env ctx iter = match iter with | Opt | List | List1 -> () | ListN (e, id_opt) -> - Option.iter (fun id -> check_id env (iter::ctx) id) id_opt; + Option.iter (fun id -> check_id env (strip_index iter::ctx) id) id_opt; check_exp env ctx e and check_exp env ctx e = @@ -110,7 +114,7 @@ and check_exp env ctx e = | StrE efs -> iter_nl_list (fun ef -> check_exp env ctx (snd ef)) efs | IterE (e1, iter) -> check_iter env ctx iter; - check_exp env (iter::ctx) e1 + check_exp env (strip_index iter::ctx) e1 and check_path env ctx p = match p.it with @@ -132,7 +136,7 @@ let rec check_prem env ctx prem = | ElsePr -> () | IterPr (prem', iter) -> check_iter env ctx iter; - check_prem env (iter::ctx) prem' + check_prem env (strip_index iter::ctx) prem' let check_def d : env = match d.it with @@ -160,6 +164,10 @@ type occur = Il.Ast.iter list Env.t let union = Env.union (fun _ ctx1 ctx2 -> assert (ctx1 = ctx2); Some ctx1) +let strip_index = function + | ListN (e, Some _) -> ListN (e, None) + | iter -> iter + let rec annot_iter env iter : Il.Ast.iter * occur = match iter with | Opt | List | List1 -> iter, Env.empty @@ -284,7 +292,8 @@ and annot_iterexp env occur1 (iter, ids) at : Il.Ast.iterexp * occur = Env.filter_map (fun _ iters -> match iters with | [] -> None - | iter1::iters' -> assert (Il.Eq.eq_iter iter iter1); Some iters' + | iter1::iters' -> + assert (Il.Eq.eq_iter (strip_index iter) iter1); Some iters' ) occur1 in let ids' = List.map (fun (x, _) -> x $ at) (Env.bindings occur1') in diff --git a/spectec/src/il/validation.ml b/spectec/src/il/validation.ml index af6d3a8d19..ea3041767a 100644 --- a/spectec/src/il/validation.ml +++ b/spectec/src/il/validation.ml @@ -241,15 +241,7 @@ let valid_list valid_x_y env xs ys at = let rec valid_iter env iter = match iter with | Opt | List | List1 -> () - | ListN (e, None) -> valid_exp env e (NatT $ e.at) - | ListN (e, Some id) -> - valid_exp env e (NatT $ e.at); - let t', dim = find "variable" env.vars id in - equiv_typ env t' (NatT $ e.at) e.at; - if dim <> [iter] then - error e.at ("use of iterated variable `" ^ - id.it ^ String.concat "" (List.map string_of_iter dim) ^ - "` outside suitable iteraton context") + | ListN (e, _) -> valid_exp env e (NatT $ e.at) (* Types *) @@ -478,6 +470,11 @@ and valid_path env p t : typ = t' and valid_iterexp env (iter, ids) : env = + let iter = + match iter with + | ListN (e, Some _) -> ListN (e, None) + | iter -> iter + in valid_iter env iter; List.fold_left (fun env id -> match find "variable" env.vars id with diff --git a/spectec/test-frontend/TEST.md b/spectec/test-frontend/TEST.md index c713d88e61..790c6a48e9 100644 --- a/spectec/test-frontend/TEST.md +++ b/spectec/test-frontend/TEST.md @@ -1865,7 +1865,7 @@ def allocdatas : (store, byte**) -> (store, dataaddr*) ;; 7-module.watsup:97.1-97.81 def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) ;; 7-module.watsup:98.1-135.54 - def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i_data^(i_data instr* ;; 7-module.watsup:157.1-157.55 def instantiation : (store, module, externval*) -> config ;; 7-module.watsup:158.1-180.28 - def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i^(i (store, dataaddr*) ;; 7-module.watsup:97.1-97.81 def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) ;; 7-module.watsup:98.1-135.54 - def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i_data^(i_data instr* ;; 7-module.watsup:157.1-157.55 def instantiation : (store, module, externval*) -> config ;; 7-module.watsup:158.1-180.28 - def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i^(i (store, dataaddr*) ;; 7-module.watsup:97.1-97.81 def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) ;; 7-module.watsup:98.1-135.54 - def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i_data^(i_data instr* ;; 7-module.watsup:157.1-157.55 def instantiation : (store, module, externval*) -> config ;; 7-module.watsup:158.1-180.28 - def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i^(i (store, dataaddr*) ;; 7-module.watsup:97.1-97.81 def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) ;; 7-module.watsup:98.1-135.54 - def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i_data^(i_data instr* ;; 7-module.watsup:157.1-157.55 def instantiation : (store, module, externval*) -> config ;; 7-module.watsup:158.1-180.28 - def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i^(i (store, dataaddr*) ;; 7-module.watsup:97.1-97.81 def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) ;; 7-module.watsup:98.1-135.54 - def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i_data^(i_data instr* ;; 7-module.watsup:157.1-157.55 def instantiation : (store, module, externval*) -> config ;; 7-module.watsup:158.1-180.28 - def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i^(i (store, dataaddr*) ;; 7-module.watsup:97.1-97.81 def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) ;; 7-module.watsup:98.1-135.54 - def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i_data^(i_data instr* ;; 7-module.watsup:157.1-157.55 def instantiation : (store, module, externval*) -> config ;; 7-module.watsup:158.1-180.28 - def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i^(i (store, dataaddr*) ;; 7-module.watsup:97.1-97.81 def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) ;; 7-module.watsup:98.1-135.54 - def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i_data^(i_data instr* ;; 7-module.watsup:157.1-157.55 def instantiation : (store, module, externval*) -> config ;; 7-module.watsup:158.1-180.28 - def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i^(i (store, dataaddr*) ;; 7-module.watsup:97.1-97.81 def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) ;; 7-module.watsup:98.1-135.54 - def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i_data^(i_data instr* ;; 7-module.watsup:157.1-157.55 def instantiation : (store, module, externval*) -> config ;; 7-module.watsup:158.1-180.28 - def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i^(i Date: Wed, 26 Jul 2023 15:55:32 +0900 Subject: [PATCH 44/49] Add type check for index variable --- spectec/src/frontend/elab.ml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spectec/src/frontend/elab.ml b/spectec/src/frontend/elab.ml index 6418653a38..deb43a91de 100644 --- a/spectec/src/frontend/elab.ml +++ b/spectec/src/frontend/elab.ml @@ -336,7 +336,12 @@ let rec elab_iter env iter : Il.iter = | Opt -> Il.Opt | List -> Il.List | List1 -> Il.List1 - | ListN (e, id_opt) -> Il.ListN (elab_exp env e (NatT $ e.at), id_opt) + | ListN (e, id_opt) -> + Option.iter (fun id -> + let t = find "variable" env.vars (prefix_id id) in + if (t.it <> NatT) then error_typ e.at "iteration index" (NatT $ e.at) + ) id_opt; + Il.ListN (elab_exp env e (NatT $ e.at), id_opt) (* Types *) From 384016dc7295eb1820d909976d6b01bc7e4cf702 Mon Sep 17 00:00:00 2001 From: Wonho Date: Wed, 26 Jul 2023 15:57:20 +0900 Subject: [PATCH 45/49] Remove wrong assertion --- spectec/src/frontend/multiplicity.ml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/spectec/src/frontend/multiplicity.ml b/spectec/src/frontend/multiplicity.ml index 0bdf4578d8..67de10d78a 100644 --- a/spectec/src/frontend/multiplicity.ml +++ b/spectec/src/frontend/multiplicity.ml @@ -298,11 +298,6 @@ and annot_iterexp env occur1 (iter, ids) at : Il.Ast.iterexp * occur = in let ids' = List.map (fun (x, _) -> x $ at) (Env.bindings occur1') in - (match iter' with - | ListN (_, Some id) -> - assert (List.length ids' = 1 && id.it = (List.hd ids').it) - | _ -> ()); - (iter', ids'), union occur1' occur2 From fd8ec1f1ee3fa5f322d2e8102a57011989e71b79 Mon Sep 17 00:00:00 2001 From: ShinWonho <50018375+ShinWonho@users.noreply.github.com> Date: Wed, 26 Jul 2023 17:04:47 +0900 Subject: [PATCH 46/49] Update spectec/src/frontend/elab.ml Co-authored-by: Andreas Rossberg --- spectec/src/frontend/elab.ml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spectec/src/frontend/elab.ml b/spectec/src/frontend/elab.ml index deb43a91de..e8ebdef00d 100644 --- a/spectec/src/frontend/elab.ml +++ b/spectec/src/frontend/elab.ml @@ -339,7 +339,8 @@ let rec elab_iter env iter : Il.iter = | ListN (e, id_opt) -> Option.iter (fun id -> let t = find "variable" env.vars (prefix_id id) in - if (t.it <> NatT) then error_typ e.at "iteration index" (NatT $ e.at) + if not (equiv_typ env t (NatT $ id.at)) then + error_typ e.at "iteration index" (NatT $ id.at) ) id_opt; Il.ListN (elab_exp env e (NatT $ e.at), id_opt) From 97e95c33abb4495084550463296b9d12b56a9248 Mon Sep 17 00:00:00 2001 From: Wonho Date: Wed, 26 Jul 2023 17:09:53 +0900 Subject: [PATCH 47/49] Add validation for iter with index --- spectec/src/frontend/multiplicity.ml | 1 - spectec/src/il/validation.ml | 12 ++++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/spectec/src/frontend/multiplicity.ml b/spectec/src/frontend/multiplicity.ml index 67de10d78a..6fb9dae19f 100644 --- a/spectec/src/frontend/multiplicity.ml +++ b/spectec/src/frontend/multiplicity.ml @@ -297,7 +297,6 @@ and annot_iterexp env occur1 (iter, ids) at : Il.Ast.iterexp * occur = ) occur1 in let ids' = List.map (fun (x, _) -> x $ at) (Env.bindings occur1') in - (iter', ids'), union occur1' occur2 diff --git a/spectec/src/il/validation.ml b/spectec/src/il/validation.ml index ea3041767a..ee69b3417c 100644 --- a/spectec/src/il/validation.ml +++ b/spectec/src/il/validation.ml @@ -241,7 +241,15 @@ let valid_list valid_x_y env xs ys at = let rec valid_iter env iter = match iter with | Opt | List | List1 -> () - | ListN (e, _) -> valid_exp env e (NatT $ e.at) + | ListN (e, None) -> valid_exp env e (NatT $ e.at) + | ListN (e, Some id) -> + valid_exp env e (NatT $ e.at); + let t', dim = find "variable" env.vars id in + equiv_typ env t' (NatT $ e.at) e.at; + if dim <> [ListN (e, None)] then + error e.at ("use of iterated variable `" ^ + id.it ^ String.concat "" (List.map string_of_iter dim) ^ + "` outside suitable iteraton context") (* Types *) @@ -470,12 +478,12 @@ and valid_path env p t : typ = t' and valid_iterexp env (iter, ids) : env = + valid_iter env iter; let iter = match iter with | ListN (e, Some _) -> ListN (e, None) | iter -> iter in - valid_iter env iter; List.fold_left (fun env id -> match find "variable" env.vars id with | t, iter1::iters From 0e45beff1c929a1154a318913802f73b4e8c5af9 Mon Sep 17 00:00:00 2001 From: ShinWonho <50018375+ShinWonho@users.noreply.github.com> Date: Wed, 26 Jul 2023 19:13:24 +0900 Subject: [PATCH 48/49] Update spectec/src/il/validation.ml Co-authored-by: Andreas Rossberg --- spectec/src/il/validation.ml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spectec/src/il/validation.ml b/spectec/src/il/validation.ml index ee69b3417c..deb9a07bc3 100644 --- a/spectec/src/il/validation.ml +++ b/spectec/src/il/validation.ml @@ -246,7 +246,9 @@ let rec valid_iter env iter = valid_exp env e (NatT $ e.at); let t', dim = find "variable" env.vars id in equiv_typ env t' (NatT $ e.at) e.at; - if dim <> [ListN (e, None)] then + match dim with + | [ListN (e', None)] when Eq.eq_exp e e' -> () + | _ -> error e.at ("use of iterated variable `" ^ id.it ^ String.concat "" (List.map string_of_iter dim) ^ "` outside suitable iteraton context") From 199efd171cd6082310224aa0f49dd7692817588e Mon Sep 17 00:00:00 2001 From: Wonho Date: Wed, 26 Jul 2023 19:15:11 +0900 Subject: [PATCH 49/49] Minor change --- spectec/src/il/validation.ml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spectec/src/il/validation.ml b/spectec/src/il/validation.ml index deb9a07bc3..b151d7c2e9 100644 --- a/spectec/src/il/validation.ml +++ b/spectec/src/il/validation.ml @@ -481,7 +481,7 @@ and valid_path env p t : typ = and valid_iterexp env (iter, ids) : env = valid_iter env iter; - let iter = + let iter' = match iter with | ListN (e, Some _) -> ListN (e, None) | iter -> iter @@ -489,14 +489,14 @@ and valid_iterexp env (iter, ids) : env = List.fold_left (fun env id -> match find "variable" env.vars id with | t, iter1::iters - when Eq.eq_iter (snd (Lib.List.split_last (iter1::iters))) iter -> + when Eq.eq_iter (snd (Lib.List.split_last (iter1::iters))) iter' -> {env with vars = Env.add id.it (t, fst (Lib.List.split_last (iter1::iters))) env.vars} | _, iters -> error id.at ("iteration variable `" ^ id.it ^ "` has incompatible dimension `" ^ id.it ^ String.concat "" (List.map string_of_iter iters) ^ - "` in iteration `_" ^ string_of_iter iter ^ "`") + "` in iteration `_" ^ string_of_iter iter' ^ "`") ) env ids