diff --git a/src/engine/BinParser.v3 b/src/engine/BinParser.v3 index 0164ef00..79e8f5b3 100644 --- a/src/engine/BinParser.v3 +++ b/src/engine/BinParser.v3 @@ -861,38 +861,44 @@ class WasmParser(extensions: Extension.set, limits: Limits, module: Module, return readByte("deftype code", BpConstants.renderDefTypeCode); // XXX: LEB not allowed here } def readDefSingleType(pt: int, code: byte, supertypes: Array) { - if (extensions.GC && code == BpDefTypeCode.SUB.code) { - var count = readU32_i("supertype count", limits.max_supertypes); - supertypes = Array.new(count); - for (i < count) { - var pt = decoder.pos; - var index = readU32_i("type index", u32.view(module.heaptypes.length)); - supertypes[i] = toHeapType(pt, index); - } - pt = decoder.pos; - code = readDefTypeCode(); + var final = 1; + if (extensions.GC) { + if (code == BpDefTypeCode.SUB.code) final = 0; + else if (code == BpDefTypeCode.SUB_FINAL.code) final = 1; + else final = 2; + if (final != 2) { + var count = readU32_i("supertype count", limits.max_supertypes); + supertypes = Array.new(count); + for (i < count) { + var pt = decoder.pos; + var index = readU32_i("type index", u32.view(module.heaptypes.length)); + supertypes[i] = toHeapType(pt, index); + } + pt = decoder.pos; + code = readDefTypeCode(); - if (subtype_list == null) subtype_list = Vector.new(); - subtype_list.put(pt, module.heaptypes.length); + if (subtype_list == null) subtype_list = Vector.new(); + subtype_list.put(pt, module.heaptypes.length); + } } match (code) { - BpDefTypeCode.Function.code => return readDefFuncType(supertypes); - BpDefTypeCode.Struct.code => if (extensions.GC) return readDefStructType(supertypes); - BpDefTypeCode.Array.code => if (extensions.GC) return readDefArrayType(supertypes); + BpDefTypeCode.Function.code => return readDefFuncType(final != 0, supertypes); + BpDefTypeCode.Struct.code => if (extensions.GC) return readDefStructType(final != 0, supertypes); + BpDefTypeCode.Array.code => if (extensions.GC) return readDefArrayType(final != 0, supertypes); } err.rel(decoder, pt).InvalidTypeDeclCode(code); } - def readDefFuncType(supertypes: Array) { + def readDefFuncType(final: bool, supertypes: Array) { var ptypes = readValueTypes("param count", limits.max_num_func_params); if (!err.ok()) return; var rtypes = readValueTypes("result count", limits.max_num_func_results); if (!err.ok()) return; - var decl = SigDecl.new(supertypes, ptypes, rtypes); + var decl = SigDecl.new(final, supertypes, ptypes, rtypes); module.addDecl(decl); decl.recgrp_index = decl.heaptype_index - max_fw_index; } - def readDefStructType(supertypes: Array) { + def readDefStructType(final: bool, supertypes: Array) { var count = readU32_i("field count", limits.max_num_struct_fields); if (!err.ok()) return; var field_types = Array.new(count); @@ -900,14 +906,14 @@ class WasmParser(extensions: Extension.set, limits: Limits, module: Module, field_types[j] = readStorageType(); } if (!err.ok()) return; - var decl = StructDecl.new(supertypes, field_types); + var decl = StructDecl.new(final, supertypes, field_types); module.addDecl(decl); decl.recgrp_index = decl.heaptype_index - max_fw_index; } - def readDefArrayType(supertypes: Array) { + def readDefArrayType(final: bool, supertypes: Array) { var elem_type = readStorageType(); if (!err.ok()) return; - var decl = ArrayDecl.new(supertypes, [elem_type]); + var decl = ArrayDecl.new(final, supertypes, [elem_type]); module.addDecl(decl); decl.recgrp_index = decl.heaptype_index - max_fw_index; } diff --git a/src/engine/Canon.v3 b/src/engine/Canon.v3 index 2f7b201e..f4bba6ee 100644 --- a/src/engine/Canon.v3 +++ b/src/engine/Canon.v3 @@ -15,7 +15,7 @@ component Canon { return SigDecl.!(globalCache.doOne(s)); } def sigPR(params: Array, results: Array) -> SigDecl { - return sig(SigDecl.new(ValueTypes.NO_HEAPTYPES, params, results)); + return sig(SigDecl.new(true, ValueTypes.NO_HEAPTYPES, params, results)); } } @@ -133,16 +133,16 @@ class RecGroup(length: int) { decls[cursor++] = d; hash = hash * 33 + hashHeapTypeDecl(d); } - def addStruct(supertypes: Array, fields: Array) -> this { - var d = decls[cursor++] = StructDecl.new(supertypes, fields); + def addStruct(final: bool, supertypes: Array, fields: Array) -> this { + var d = decls[cursor++] = StructDecl.new(final, supertypes, fields); hash = hash * 33 + hashStructDecl(d); } - def addArray(supertypes: Array, elems: Array) -> this { - var d = decls[cursor++] = ArrayDecl.new(supertypes, elems); + def addArray(final: bool, supertypes: Array, elems: Array) -> this { + var d = decls[cursor++] = ArrayDecl.new(final, supertypes, elems); hash = hash * 33 + hashArrayDecl(d); } - def addSig(supertypes: Array, params: Array, results: Array) -> this { - var d = decls[cursor++] = SigDecl.new(supertypes, params, results); + def addSig(final: bool, supertypes: Array, params: Array, results: Array) -> this { + var d = decls[cursor++] = SigDecl.new(final, supertypes, params, results); hash = hash * 33 + hashSigDecl(d); } @@ -182,17 +182,17 @@ class RecGroup(length: int) { match (d) { x: StructDecl => { if (isOpen || hasOpenStorageType(x.field_types)) { - d = StructDecl.new(ns, Arrays.dup(x.field_types)); + d = StructDecl.new(x.final, ns, Arrays.dup(x.field_types)); } } x: ArrayDecl => { if (isOpen || hasOpenStorageType(x.elem_types)) { - d = ArrayDecl.new(ns, Arrays.dup(x.elem_types)); + d = ArrayDecl.new(x.final, ns, Arrays.dup(x.elem_types)); } } x: SigDecl => { if (isOpen || hasOpenValueType(x.params) || hasOpenValueType(x.results)) { - d = SigDecl.new(ns, Arrays.dup(x.params), Arrays.dup(x.results)); + d = SigDecl.new(x.final, ns, Arrays.dup(x.params), Arrays.dup(x.results)); } } } diff --git a/src/engine/Opcodes.v3 b/src/engine/Opcodes.v3 index c88778dc..9cd24ced 100644 --- a/src/engine/Opcodes.v3 +++ b/src/engine/Opcodes.v3 @@ -795,7 +795,7 @@ class InstrTracer { } else if (pl == 0 && rl == 1) { pr.1[0].render(out); } else { - SigDecl.new(null, pr.0, pr.1).render(out); + SigDecl.new(true, null, pr.0, pr.1).render(out); } } LABEL => out.put1("depth=%d", parser.readLabel()); diff --git a/src/engine/SigCache.v3 b/src/engine/SigCache.v3 index 61355217..0bc1f9f8 100644 --- a/src/engine/SigCache.v3 +++ b/src/engine/SigCache.v3 @@ -135,7 +135,7 @@ component SigCache { def is_v = S(arr_is, arr_v); private def S(params: Array, results: Array) -> SigDecl { - var sig = SigDecl.new(ValueTypes.NO_HEAPTYPES, params, results); + var sig = SigDecl.new(true, ValueTypes.NO_HEAPTYPES, params, results); Canon.globalCache.insert(sig); return sig; } diff --git a/src/engine/Type.v3 b/src/engine/Type.v3 index 51b85b71..ae758001 100644 --- a/src/engine/Type.v3 +++ b/src/engine/Type.v3 @@ -81,6 +81,9 @@ component ValueTypes { def NONE = Array.new(0); def NO_HEAPTYPES = Array.new(0); + // Helper utility for a final signature type with no supertypes. + def newSig = SigDecl.new(true, NO_HEAPTYPES, _, _); + // Render a value type, careful not to recurse into any type in {seen}. def render(vt: ValueType, seen: List, buf: StringBuilder) -> StringBuilder { var s: string; @@ -389,7 +392,7 @@ component TypeRelation { } // Heap type declarations. -class HeapTypeDecl(supertypes: Array) extends Decl { +class HeapTypeDecl(final: bool, supertypes: Array) extends Decl { var hash = 0; var heaptype_index = -1; var canon_id = -1; @@ -420,7 +423,7 @@ class StructDecl extends HeapTypeDecl { def field_types: Array; def defaultable = allHaveDefaultValues(field_types); - new(supertypes: Array, field_types) super(supertypes) {} + new(final: bool, supertypes: Array, field_types) super(final, supertypes) {} def render(buf: StringBuilder) -> StringBuilder { return putUid(buf.put1("struct #%d", heaptype_index)); @@ -432,7 +435,7 @@ class ArrayDecl extends HeapTypeDecl { def elem_types: Array; def defaultable = allHaveDefaultValues(elem_types); - new(supertypes: Array, elem_types) super(supertypes) {} + new(final: bool, supertypes: Array, elem_types) super(final, supertypes) {} def render(buf: StringBuilder) -> StringBuilder { return putUid(buf.put1("array #%d", heaptype_index)); @@ -444,12 +447,12 @@ class SigDecl extends HeapTypeDecl { def params: Array; def results: Array; - new(supertypes: Array, params, results) super(supertypes) {} + new(final: bool, supertypes: Array, params, results) super(final, supertypes) {} def bindLeft(count: int) -> SigDecl { var p = params, np = Array.new(p.length - count); for (i < np.length) np[i] = p[i + count]; - return SigDecl.new(ValueTypes.NO_HEAPTYPES, np, results); // TODO: bindLeft of SigDecl.supertypes + return SigDecl.new(final, ValueTypes.NO_HEAPTYPES, np, results); // TODO: bindLeft of SigDecl.supertypes } def isAssignableSig(that: SigDecl) -> bool { if (that == null) return false; @@ -478,7 +481,7 @@ class SigDecl extends HeapTypeDecl { return putUid(buf); } def dup() -> SigDecl { - var ns = SigDecl.new(supertypes, params, results); + var ns = SigDecl.new(final, supertypes, params, results); ns.canon_id = this.canon_id; return ns; } diff --git a/src/jawa/JawaClass.v3 b/src/jawa/JawaClass.v3 index a6757971..3552eddb 100644 --- a/src/jawa/JawaClass.v3 +++ b/src/jawa/JawaClass.v3 @@ -26,7 +26,7 @@ enum JawaFieldAttr(code: u16) { ENUM (0x2000) } -def newSig = SigDecl.new(ValueTypes.NO_HEAPTYPES, _, _); +def newSig = ValueTypes.newSig; // Method representation: attributes, signatures, and method declarations. class JawaMethod(name: JawaString, attrs: JawaMethodAttr.set, sig: JawaMethodSig, var impl: Function) { diff --git a/src/jawa/JawaGcRuntime.v3 b/src/jawa/JawaGcRuntime.v3 index 10ae0b04..f0ecd43e 100644 --- a/src/jawa/JawaGcRuntime.v3 +++ b/src/jawa/JawaGcRuntime.v3 @@ -3,7 +3,7 @@ // Implementation of the Jawa runtime using the GC extension to Wasm. def OUT = Trace.OUT; -def newSig = SigDecl.new(ValueTypes.NO_HEAPTYPES, _, _); +def newSig = ValueTypes.newSig; class JawaGcRuntime extends JawaRuntime { def arrayReps = HashMap.new(JawaRefType.hashI32, JawaArrayType.==); @@ -40,7 +40,7 @@ class JawaGcRuntime extends JawaRuntime { var pair = newStructs(at, 1, parent.vtable.length), objStruct = pair.1, metaStruct = pair.0; - var array = ArrayDecl.new(ValueTypes.NO_HEAPTYPES, Array.new(1)); + var array = ArrayDecl.new(true, ValueTypes.NO_HEAPTYPES, Array.new(1)); comodule.addDecl(array); arrayReps[at] = gcrep = JawaGcRuntimeArrayRep.new(metaStruct, objStruct, array); @@ -201,7 +201,7 @@ class JawaGcRuntime extends JawaRuntime { return gcrep; } def newStruct(t: JawaRefType, field_types: Array) -> StructDecl { - var objStruct = StructDecl.new(ValueTypes.NO_HEAPTYPES, field_types); // TODO: supertypes + var objStruct = StructDecl.new(true, ValueTypes.NO_HEAPTYPES, field_types); // TODO: supertypes comodule.addDecl(objStruct); if (t != null) reftypes.set(objStruct.heaptype_index, t); return objStruct; diff --git a/src/jawa/JawaHostRuntime.v3 b/src/jawa/JawaHostRuntime.v3 index 66dc45c2..349d6948 100644 --- a/src/jawa/JawaHostRuntime.v3 +++ b/src/jawa/JawaHostRuntime.v3 @@ -1,7 +1,7 @@ // Copyright 2020 Ben L. Titzer. All rights reserved. // See LICENSE for details of Apache 2.0 license. -def newSig = SigDecl.new(ValueTypes.NO_HEAPTYPES, _, _); +def newSig = ValueTypes.newSig; // Implementation of the Jawa runtime using only the host language, Virgil. class JawaHostRuntime extends JawaRuntime { diff --git a/src/jawa/JawaSysFuncs.v3 b/src/jawa/JawaSysFuncs.v3 index f991976e..f5d7453b 100644 --- a/src/jawa/JawaSysFuncs.v3 +++ b/src/jawa/JawaSysFuncs.v3 @@ -3,7 +3,7 @@ // All the system functions supported by Jawa in the "SYSTEM" bytecode. enum JawaSysFunc(sig: SigDecl, eval: Array -> HostResult) { - puts(SigDecl.new(ValueTypes.NO_HEAPTYPES, [ValueType.Host(JawaTypes.STRING)], SigCache.arr_v), eval_puts), + puts(SigDecl.new(true, ValueTypes.NO_HEAPTYPES, [ValueType.Host(JawaTypes.STRING)], SigCache.arr_v), eval_puts), puti(SigCache.i_v, eval_puti), millis(SigCache.v_i, eval_millis), micros(SigCache.v_i, eval_micros), @@ -11,7 +11,7 @@ enum JawaSysFunc(sig: SigDecl, eval: Array -> HostResult) { exp(SigCache.d_d, eval_exp), log(SigCache.d_d, eval_log), sqrt(SigCache.d_d, eval_sqrt), - idhash(SigDecl.new(ValueTypes.NO_HEAPTYPES, [ValueType.Host(JawaTypes.OBJECT)], SigCache.arr_i), eval_idhash) + idhash(SigDecl.new(true, ValueTypes.NO_HEAPTYPES, [ValueType.Host(JawaTypes.OBJECT)], SigCache.arr_i), eval_idhash) } // System functions that can be imported by code. diff --git a/src/modules/wasi/WspOneModule.v3 b/src/modules/wasi/WspOneModule.v3 index 2abbf0b0..6e7ffe96 100644 --- a/src/modules/wasi/WspOneModule.v3 +++ b/src/modules/wasi/WspOneModule.v3 @@ -12,7 +12,7 @@ private enum PreopenType(code: byte) { // Registered functions in the "wasi_snapshot_preview1" module. def funcMap = Strings.newMap<(SigDecl, (WspOneModule, Array) -> HostResult)>(), X = init(); def init() { - def i_ = ValueType.I32, l_ = ValueType.I64, s = SigDecl.new(ValueTypes.NO_HEAPTYPES, _, _); + def i_ = ValueType.I32, l_ = ValueType.I64, s = SigDecl.new(true, ValueTypes.NO_HEAPTYPES, _, _); def S: SigCache; for (t in [ ("args_get", S.ii_i, WspOneModule.args_get), diff --git a/src/modules/wizeng/WizengModule.v3 b/src/modules/wizeng/WizengModule.v3 index 0ec6b29b..70d4da41 100644 --- a/src/modules/wizeng/WizengModule.v3 +++ b/src/modules/wizeng/WizengModule.v3 @@ -49,7 +49,7 @@ class WizengModule extends HostModule("wizeng") { var sig_index = 0; // TODO: get correct sig index? var func = new_funcref(sig, sig_index, _); - var imported_sig = SigDecl.new([], SigCache.arr_ii, [rtype]); + var imported_sig = SigDecl.new(true, [], SigCache.arr_ii, [rtype]); result[j] = HostFunctionN.new("new_funcref", imported_sig, func); } } diff --git a/test/unittest/CanonTest.v3 b/test/unittest/CanonTest.v3 index df77a680..e41a266b 100644 --- a/test/unittest/CanonTest.v3 +++ b/test/unittest/CanonTest.v3 @@ -13,9 +13,9 @@ def X = [ () ]; -def newSig = SigDecl.new(ValueTypes.NO_HEAPTYPES, _, _); -def newStruct = StructDecl.new(ValueTypes.NO_HEAPTYPES, _); -def newArray = ArrayDecl.new(ValueTypes.NO_HEAPTYPES, _); +def newSig = SigDecl.new(true, ValueTypes.NO_HEAPTYPES, _, _); +def newStruct = StructDecl.new(true, ValueTypes.NO_HEAPTYPES, _); +def newArray = ArrayDecl.new(true, ValueTypes.NO_HEAPTYPES, _); class CanonTester(t: Tester) { def assertSigId(sig: SigDecl) { diff --git a/test/unittest/CodeValidatorTest.v3 b/test/unittest/CodeValidatorTest.v3 index e0852287..89bf7dbb 100644 --- a/test/unittest/CodeValidatorTest.v3 +++ b/test/unittest/CodeValidatorTest.v3 @@ -100,7 +100,7 @@ def X = [ () ]; -def newSig = SigDecl.new(ValueTypes.NO_HEAPTYPES, _, _); +def newSig = ValueTypes.newSig; class CodeValidatorTester(t: Tester) extends ModuleBuilder { def err = ErrorGen.new("CodeValidatorTest.v3"); @@ -1522,7 +1522,7 @@ def test_call_ref0(t: CodeValidatorTester) { t.sig(sig); t.TypeError(code1, 1); - t.sig(SigDecl.new(null, [ref_v_v], SigCache.arr_v)); + t.sig(newSig([ref_v_v], SigCache.arr_v)); var code2: Array = [Opcode.LOCAL_GET.code, 0, Opcode.CALL_REF.code, heapIndexByte(sig)]; if (sig == sig_v_v) t.valid(code2); else t.TypeError(code2, 3); @@ -1676,7 +1676,7 @@ def test_struct_newdef(t: CodeValidatorTester) { def test_struct_get(t: CodeValidatorTester) { t.setExtensions(Extension.GC); - var st = StructDecl.new(ValueTypes.NO_HEAPTYPES, [unpackedT(ValueType.I32, true), unpackedT(ValueType.F32, true)]); + var st = StructDecl.new(true, ValueTypes.NO_HEAPTYPES, [unpackedT(ValueType.I32, true), unpackedT(ValueType.F32, true)]); t.module.addDecl(st); t.sig0([ValueTypes.RefStruct(false, st)], SigCache.arr_i); diff --git a/test/unittest/ExeTest.v3 b/test/unittest/ExeTest.v3 index df94eb44..891479e3 100644 --- a/test/unittest/ExeTest.v3 +++ b/test/unittest/ExeTest.v3 @@ -1034,7 +1034,7 @@ component TestTiers { def NO_IMPORTS = Array.new(0); -def newSig = SigDecl.new(ValueTypes.NO_HEAPTYPES, _, _); +def newSig = ValueTypes.newSig; class ExeTester(t: Tester, tiering: ExecutionStrategy) extends ModuleBuilder { var max_call_depth = 100u; @@ -1301,7 +1301,7 @@ def test_block1(i: ExeTester) { def test_block2(i: ExeTester) { i.extensions |= Extension.GC; - i.sig(SigDecl.new(ValueTypes.NO_HEAPTYPES, SigCache.arr_g, SigCache.arr_g)); + i.sig(newSig(SigCache.arr_g, SigCache.arr_g)); i.code([Opcode.BLOCK.code, BpTypeCode.REF_NULL.code, BpTypeCode.FUNCREF.code, Opcode.LOCAL_GET.code, 0, Opcode.END.code]); @@ -2010,7 +2010,7 @@ def test_locals4(i: ExeTester) { def test_locals5(i: ExeTester) { var sig_v_i = i.addSig(SigCache.v_i); var ft = ValueType.Ref(true, HeapType.Func(sig_v_i)); - i.sig(SigDecl.new(ValueTypes.NO_HEAPTYPES, SigCache.arr_g, SigCache.arr_g)); + i.sig(newSig(SigCache.arr_g, SigCache.arr_g)); var l = i.addLocals(1, ft); i.code([ Opcode.LOCAL_GET.code, byte.!(l) @@ -2705,7 +2705,7 @@ def uvu(a: u32, b: Value, c: u32) -> Array { } def test_table_fill(i: ExeTester) { - i.sig(SigDecl.new(ValueTypes.NO_HEAPTYPES, [ValueType.I32, ValueTypes.FUNCREF, ValueType.I32], SigCache.arr_v)); + i.sig(newSig([ValueType.I32, ValueTypes.FUNCREF, ValueType.I32], SigCache.arr_v)); i.addTable(6, 0, []); i.code([ Opcode.LOCAL_GET.code, 0, @@ -3304,7 +3304,7 @@ def test_abstype_default(t: ExeTester) { var module = Module.new(null); var abs = AbsTypeDecl.new(true, c.0 == ValueTypes.EXTERNREF, []); var at = ValueType.Abstract(abs); - var sig = SigDecl.new(ValueTypes.NO_HEAPTYPES, SigCache.arr_v, [at]); + var sig = newSig(SigCache.arr_v, [at]); module.addDecl(abs); module.addImport("foo", "bar", [], abs); module.addDecl(sig); diff --git a/test/unittest/HeapTypeTest.v3 b/test/unittest/HeapTypeTest.v3 index 3a7f4dc7..634f5c0a 100644 --- a/test/unittest/HeapTypeTest.v3 +++ b/test/unittest/HeapTypeTest.v3 @@ -27,9 +27,12 @@ def Z = [ ]; def NO_SUPERS = ValueTypes.NO_HEAPTYPES; -def newSig = SigDecl.new(NO_SUPERS, _, _); -def newStruct = StructDecl.new(NO_SUPERS, _); -def newArray = ArrayDecl.new(NO_SUPERS, _); +def newSig = ValueTypes.newSig; +def newStruct = StructDecl.new(true, NO_SUPERS, _); +def newArray = ArrayDecl.new(true, NO_SUPERS, _); +def finalSig = SigDecl.new(true, _, _, _); +def finalStruct = StructDecl.new(true, _, _); +def finalArray = ArrayDecl.new(true, _, _); class HeapTypeTester(t: Tester) { def test_id_cached(a: Array) { @@ -175,7 +178,7 @@ def test_canon_struct_super1(t: HeapTypeTester) { var s0 = newStruct([]); var s1 = newStruct([]); - var s2 = StructDecl.new([HeapType.Struct(s1)], [StorageType(ValueType.Ref(true, HeapType.Struct(s1)), Packedness.UNPACKED, true)]); + var s2 = finalStruct([HeapType.Struct(s1)], [StorageType(ValueType.Ref(true, HeapType.Struct(s1)), Packedness.UNPACKED, true)]); t.t.asserteq(HeapType.Struct(s1), s2.supertypes[0]); t.put_group(heaptypes, [s0]); @@ -199,9 +202,9 @@ def test_canon_struct_super2(t: HeapTypeTester) { var s0 = newStruct([StorageType(ValueType.I32, Packedness.UNPACKED, true)]); var st = StorageType(ValueType.Ref(true, HeapType.Struct(s0)), Packedness.UNPACKED, true); - var s1 = StructDecl.new([HeapType.Struct(s0)], [st]); + var s1 = finalStruct([HeapType.Struct(s0)], [st]); var s2 = newStruct([StorageType(ValueType.F32, Packedness.UNPACKED, true)]); - var s3 = StructDecl.new([HeapType.Struct(s2)], [st]); + var s3 = finalStruct([HeapType.Struct(s2)], [st]); t.put_group(heaptypes, [s0, s1]); cache.doGroup(heaptypes, 0, 2); @@ -272,15 +275,15 @@ def test_valid_suptype0(t: HeapTypeTester) { var no_fields = Array.new(0); var mut_int_field = StorageType(ValueType.I32, Packedness.UNPACKED, true); - var s0 = StructDecl.new(NO_SUPERS, no_fields); - t.test_supertype_checking(true, StructDecl.new([HeapType.Struct(s0)], no_fields)); - t.test_supertype_checking(true, StructDecl.new([HeapType.Struct(s0)], [mut_int_field])); + var s0 = newStruct(no_fields); + t.test_supertype_checking(true, finalStruct([HeapType.Struct(s0)], no_fields)); + t.test_supertype_checking(true, finalStruct([HeapType.Struct(s0)], [mut_int_field])); - var a0 = ArrayDecl.new(NO_SUPERS, [mut_int_field]); - t.test_supertype_checking(true, ArrayDecl.new([HeapType.Array(a0)], [mut_int_field])); + var a0 = finalArray(NO_SUPERS, [mut_int_field]); + t.test_supertype_checking(true, finalArray([HeapType.Array(a0)], [mut_int_field])); var f0 = SigCache.v_v; - t.test_supertype_checking(true, SigDecl.new([HeapType.Func(f0)], SigCache.arr_v, SigCache.arr_v)); + t.test_supertype_checking(true, finalSig([HeapType.Func(f0)], SigCache.arr_v, SigCache.arr_v)); } def test_valid_suptype1(t: HeapTypeTester) { @@ -289,41 +292,41 @@ def test_valid_suptype1(t: HeapTypeTester) { var imm_funcref_field = StorageType(ValueTypes.FUNCREF, Packedness.UNPACKED, false); var imm_nullref_field = StorageType(ValueTypes.NULLREF, Packedness.UNPACKED, false); - var s0 = StructDecl.new(NO_SUPERS, [imm_anyref_field]); - t.test_supertype_checking(true, StructDecl.new([HeapType.Struct(s0)], [imm_anyref_field])); - t.test_supertype_checking(true, StructDecl.new([HeapType.Struct(s0)], [imm_nullref_field])); - t.test_supertype_checking(false, StructDecl.new([HeapType.Struct(s0)], [imm_funcref_field])); + var s0 = newStruct([imm_anyref_field]); + t.test_supertype_checking(true, finalStruct([HeapType.Struct(s0)], [imm_anyref_field])); + t.test_supertype_checking(true, finalStruct([HeapType.Struct(s0)], [imm_nullref_field])); + t.test_supertype_checking(false, finalStruct([HeapType.Struct(s0)], [imm_funcref_field])); - var a0 = ArrayDecl.new(NO_SUPERS, [imm_anyref_field]); - t.test_supertype_checking(true, ArrayDecl.new([HeapType.Array(a0)], [imm_anyref_field])); + var a0 = finalArray(NO_SUPERS, [imm_anyref_field]); + t.test_supertype_checking(true, finalArray([HeapType.Array(a0)], [imm_anyref_field])); - var f0 = SigDecl.new(NO_SUPERS, SigCache.arr_v, [ValueTypes.ANYREF]); - t.test_supertype_checking(true, SigDecl.new([HeapType.Func(f0)], SigCache.arr_v, [ValueTypes.ANYREF])); // covariant ret - t.test_supertype_checking(true, SigDecl.new([HeapType.Func(f0)], SigCache.arr_v, [ValueTypes.NULLREF])); // covariant ret - t.test_supertype_checking(false, SigDecl.new([HeapType.Func(f0)], SigCache.arr_v, [ValueTypes.FUNCREF])); // covariant ret + var f0 = finalSig(NO_SUPERS, SigCache.arr_v, [ValueTypes.ANYREF]); + t.test_supertype_checking(true, finalSig([HeapType.Func(f0)], SigCache.arr_v, [ValueTypes.ANYREF])); // covariant ret + t.test_supertype_checking(true, finalSig([HeapType.Func(f0)], SigCache.arr_v, [ValueTypes.NULLREF])); // covariant ret + t.test_supertype_checking(false, finalSig([HeapType.Func(f0)], SigCache.arr_v, [ValueTypes.FUNCREF])); // covariant ret - var f1 = SigDecl.new(NO_SUPERS, [ValueTypes.NULLREF], SigCache.arr_v); - t.test_supertype_checking(true, SigDecl.new([HeapType.Func(f1)], [ValueTypes.NULLREF], SigCache.arr_v)); // contra-variant param - t.test_supertype_checking(true, SigDecl.new([HeapType.Func(f1)], [ValueTypes.ANYREF], SigCache.arr_v)); // contra-variant param - t.test_supertype_checking(false, SigDecl.new([HeapType.Func(f1)], [ValueTypes.FUNCREF], SigCache.arr_v)); // contra-variant param + var f1 = finalSig(NO_SUPERS, [ValueTypes.NULLREF], SigCache.arr_v); + t.test_supertype_checking(true, finalSig([HeapType.Func(f1)], [ValueTypes.NULLREF], SigCache.arr_v)); // contra-variant param + t.test_supertype_checking(true, finalSig([HeapType.Func(f1)], [ValueTypes.ANYREF], SigCache.arr_v)); // contra-variant param + t.test_supertype_checking(false, finalSig([HeapType.Func(f1)], [ValueTypes.FUNCREF], SigCache.arr_v)); // contra-variant param } def test_invalid_suptype0(t: HeapTypeTester) { var no_fields = Array.new(0); var mut_int_field = StorageType(ValueType.I32, Packedness.UNPACKED, true); - var s0 = StructDecl.new(NO_SUPERS, no_fields); - var a0 = ArrayDecl.new(NO_SUPERS, [mut_int_field]); + var s0 = newStruct(no_fields); + var a0 = finalArray(NO_SUPERS, [mut_int_field]); var f0 = SigCache.v_v; - t.test_supertype_checking(false, StructDecl.new([HeapType.Array(a0)], no_fields)); // kind mismatch - t.test_supertype_checking(false, StructDecl.new([HeapType.Func(f0)], no_fields)); // kind mismatch + t.test_supertype_checking(false, finalStruct([HeapType.Array(a0)], no_fields)); // kind mismatch + t.test_supertype_checking(false, finalStruct([HeapType.Func(f0)], no_fields)); // kind mismatch - t.test_supertype_checking(false, ArrayDecl.new([HeapType.Struct(s0)], [mut_int_field])); // kind mismatch - t.test_supertype_checking(false, ArrayDecl.new([HeapType.Func(f0)], [mut_int_field])); // kind mismatch + t.test_supertype_checking(false, finalArray([HeapType.Struct(s0)], [mut_int_field])); // kind mismatch + t.test_supertype_checking(false, finalArray([HeapType.Func(f0)], [mut_int_field])); // kind mismatch - t.test_supertype_checking(false, SigDecl.new([HeapType.Struct(s0)], SigCache.arr_v, SigCache.arr_i)); // kind mismatch - t.test_supertype_checking(false, SigDecl.new([HeapType.Array(a0)], SigCache.arr_v, SigCache.arr_i)); // kind mismatch + t.test_supertype_checking(false, finalSig([HeapType.Struct(s0)], SigCache.arr_v, SigCache.arr_i)); // kind mismatch + t.test_supertype_checking(false, finalSig([HeapType.Array(a0)], SigCache.arr_v, SigCache.arr_i)); // kind mismatch } def test_invalid_suptype1(t: HeapTypeTester) { @@ -331,16 +334,16 @@ def test_invalid_suptype1(t: HeapTypeTester) { var mut_int_field = StorageType(ValueType.I32, Packedness.UNPACKED, true); var imm_int_field = StorageType(ValueType.I32, Packedness.UNPACKED, false); - var s0 = StructDecl.new(NO_SUPERS, [mut_int_field]); - t.test_supertype_checking(false, StructDecl.new([HeapType.Struct(s0)], no_fields)); // no fields - t.test_supertype_checking(false, StructDecl.new([HeapType.Struct(s0)], [imm_int_field])); // make mut field imm + var s0 = newStruct([mut_int_field]); + t.test_supertype_checking(false, finalStruct([HeapType.Struct(s0)], no_fields)); // no fields + t.test_supertype_checking(false, finalStruct([HeapType.Struct(s0)], [imm_int_field])); // make mut field imm - var a0 = ArrayDecl.new(NO_SUPERS, [mut_int_field]); - t.test_supertype_checking(false, ArrayDecl.new([HeapType.Array(a0)], [imm_int_field])); // make mut field imm + var a0 = finalArray(NO_SUPERS, [mut_int_field]); + t.test_supertype_checking(false, finalArray([HeapType.Array(a0)], [imm_int_field])); // make mut field imm var f0 = SigCache.v_v; - t.test_supertype_checking(false, SigDecl.new([HeapType.Func(f0)], SigCache.arr_v, SigCache.arr_i)); // arity mismatch - t.test_supertype_checking(false, SigDecl.new([HeapType.Func(f0)], SigCache.arr_i, SigCache.arr_v)); // arity mismatch + t.test_supertype_checking(false, finalSig([HeapType.Func(f0)], SigCache.arr_v, SigCache.arr_i)); // arity mismatch + t.test_supertype_checking(false, finalSig([HeapType.Func(f0)], SigCache.arr_i, SigCache.arr_v)); // arity mismatch } def test_invalid_suptype2(t: HeapTypeTester) { @@ -349,22 +352,22 @@ def test_invalid_suptype2(t: HeapTypeTester) { var mut_anyref_field = StorageType(ValueTypes.ANYREF, Packedness.UNPACKED, true); var mut_funcref_field = StorageType(ValueTypes.FUNCREF, Packedness.UNPACKED, true); - var s0 = StructDecl.new(NO_SUPERS, [mut_anyref_field]); - t.test_supertype_checking(true, StructDecl.new([HeapType.Struct(s0)], [mut_anyref_field])); // ok - t.test_supertype_checking(false, StructDecl.new([HeapType.Struct(s0)], [mut_int_field])); // field type mismatch - t.test_supertype_checking(false, StructDecl.new([HeapType.Struct(s0)], [mut_funcref_field])); // field type mismatch - - var a0 = ArrayDecl.new(NO_SUPERS, [mut_anyref_field]); - t.test_supertype_checking(true, ArrayDecl.new([HeapType.Array(a0)], [mut_anyref_field])); // ok - t.test_supertype_checking(false, ArrayDecl.new([HeapType.Array(a0)], [mut_int_field])); // elem type mismatch - t.test_supertype_checking(false, ArrayDecl.new([HeapType.Array(a0)], [mut_funcref_field])); // elem type mismatch - - var f0 = SigDecl.new(NO_SUPERS, [ValueTypes.ANYREF], [ValueTypes.FUNCREF]); - t.test_supertype_checking(true, SigDecl.new([HeapType.Func(f0)], [ValueTypes.ANYREF], [ValueTypes.FUNCREF])); // ok - t.test_supertype_checking(false, SigDecl.new([HeapType.Func(f0)], [ValueType.I32], [ValueTypes.FUNCREF])); // param type - t.test_supertype_checking(false, SigDecl.new([HeapType.Func(f0)], [ValueTypes.FUNCREF], [ValueTypes.FUNCREF])); // param type - t.test_supertype_checking(false, SigDecl.new([HeapType.Func(f0)], [ValueTypes.ANYREF], [ValueType.I32])); // result type - t.test_supertype_checking(false, SigDecl.new([HeapType.Func(f0)], [ValueTypes.ANYREF], [ValueTypes.ANYREF])); // result type + var s0 = newStruct([mut_anyref_field]); + t.test_supertype_checking(true, finalStruct([HeapType.Struct(s0)], [mut_anyref_field])); // ok + t.test_supertype_checking(false, finalStruct([HeapType.Struct(s0)], [mut_int_field])); // field type mismatch + t.test_supertype_checking(false, finalStruct([HeapType.Struct(s0)], [mut_funcref_field])); // field type mismatch + + var a0 = finalArray(NO_SUPERS, [mut_anyref_field]); + t.test_supertype_checking(true, finalArray([HeapType.Array(a0)], [mut_anyref_field])); // ok + t.test_supertype_checking(false, finalArray([HeapType.Array(a0)], [mut_int_field])); // elem type mismatch + t.test_supertype_checking(false, finalArray([HeapType.Array(a0)], [mut_funcref_field])); // elem type mismatch + + var f0 = finalSig(NO_SUPERS, [ValueTypes.ANYREF], [ValueTypes.FUNCREF]); + t.test_supertype_checking(true, finalSig([HeapType.Func(f0)], [ValueTypes.ANYREF], [ValueTypes.FUNCREF])); // ok + t.test_supertype_checking(false, finalSig([HeapType.Func(f0)], [ValueType.I32], [ValueTypes.FUNCREF])); // param type + t.test_supertype_checking(false, finalSig([HeapType.Func(f0)], [ValueTypes.FUNCREF], [ValueTypes.FUNCREF])); // param type + t.test_supertype_checking(false, finalSig([HeapType.Func(f0)], [ValueTypes.ANYREF], [ValueType.I32])); // result type + t.test_supertype_checking(false, finalSig([HeapType.Func(f0)], [ValueTypes.ANYREF], [ValueTypes.ANYREF])); // result type } def test_invalid_suptype3(t: HeapTypeTester) { @@ -373,13 +376,13 @@ def test_invalid_suptype3(t: HeapTypeTester) { var imm_anyref_field = StorageType(ValueTypes.ANYREF, Packedness.UNPACKED, false); var imm_funcref_field = StorageType(ValueTypes.FUNCREF, Packedness.UNPACKED, false); - var s0 = StructDecl.new(NO_SUPERS, [imm_funcref_field]); - t.test_supertype_checking(false, StructDecl.new([HeapType.Struct(s0)], [imm_int_field])); // field type mismatch - t.test_supertype_checking(false, StructDecl.new([HeapType.Struct(s0)], [imm_anyref_field])); // field type mismatch + var s0 = newStruct([imm_funcref_field]); + t.test_supertype_checking(false, finalStruct([HeapType.Struct(s0)], [imm_int_field])); // field type mismatch + t.test_supertype_checking(false, finalStruct([HeapType.Struct(s0)], [imm_anyref_field])); // field type mismatch - var a0 = ArrayDecl.new(NO_SUPERS, [imm_funcref_field]); - t.test_supertype_checking(false, ArrayDecl.new([HeapType.Array(a0)], [imm_int_field])); // elem type mismatch - t.test_supertype_checking(false, ArrayDecl.new([HeapType.Array(a0)], [imm_anyref_field])); // elem type mismatch + var a0 = finalArray(NO_SUPERS, [imm_funcref_field]); + t.test_supertype_checking(false, finalArray([HeapType.Array(a0)], [imm_int_field])); // elem type mismatch + t.test_supertype_checking(false, finalArray([HeapType.Array(a0)], [imm_anyref_field])); // elem type mismatch } def dupHeapTypeDecl(decl: HeapTypeDecl) -> HeapTypeDecl { diff --git a/test/unittest/InstantiatorTest.v3 b/test/unittest/InstantiatorTest.v3 index 9048e341..52967452 100644 --- a/test/unittest/InstantiatorTest.v3 +++ b/test/unittest/InstantiatorTest.v3 @@ -22,7 +22,7 @@ def X = [ () ]; -def newSig = SigDecl.new(ValueTypes.NO_HEAPTYPES, _, _); +def newSig = ValueTypes.newSig; class InstantiatorTester(t: Tester) extends ModuleBuilder { def assert_fail(bindings: Array) { diff --git a/test/unittest/JawaDeclTest.v3 b/test/unittest/JawaDeclTest.v3 index ab786ed3..10f2f368 100644 --- a/test/unittest/JawaDeclTest.v3 +++ b/test/unittest/JawaDeclTest.v3 @@ -20,7 +20,7 @@ def X = [ () ]; -def newSig = SigDecl.new(ValueTypes.NO_HEAPTYPES, _, _); +def newSig = ValueTypes.newSig; def test_fw_class1(t: JawaTester) { var jlo = t.importJawaLangObject(); diff --git a/test/unittest/JawaErrorTest.v3 b/test/unittest/JawaErrorTest.v3 index c5136edb..051d138a 100644 --- a/test/unittest/JawaErrorTest.v3 +++ b/test/unittest/JawaErrorTest.v3 @@ -13,7 +13,7 @@ def X = [ () ]; -def newSig = SigDecl.new(ValueTypes.NO_HEAPTYPES, _, _); +def newSig = ValueTypes.newSig; def RETURN_TYPES = Arrays.prepend(JawaTypeRef.Void, Arrays.map(JawaTypes.PRIMITIVES, JawaTypeRef.Prim)); diff --git a/test/unittest/JawaExeTest.v3 b/test/unittest/JawaExeTest.v3 index 5056e738..d6e976b1 100644 --- a/test/unittest/JawaExeTest.v3 +++ b/test/unittest/JawaExeTest.v3 @@ -72,7 +72,7 @@ def X = [ ]; -def newSig = SigDecl.new(ValueTypes.NO_HEAPTYPES, _, _); +def newSig = ValueTypes.newSig; class ArgCatcher { var args: Array; diff --git a/test/unittest/JawaTest.v3 b/test/unittest/JawaTest.v3 index 860cea4b..7d09566e 100644 --- a/test/unittest/JawaTest.v3 +++ b/test/unittest/JawaTest.v3 @@ -45,7 +45,7 @@ def X = [ def NO_METHOD_ATTRS: JawaMethodAttr.set; def NO_CLASS_ATTRS: JawaClassAttr.set; -def newSig = SigDecl.new(ValueTypes.NO_HEAPTYPES, _, _); +def newSig = ValueTypes.newSig; def strhash(s: string) -> int { return int.view(JawaStrings.of(s).hashCode()); diff --git a/test/unittest/JawaTester.v3 b/test/unittest/JawaTester.v3 index 05041231..bce0d791 100644 --- a/test/unittest/JawaTester.v3 +++ b/test/unittest/JawaTester.v3 @@ -17,7 +17,7 @@ component JawaTests { } } -def newSig = SigDecl.new(ValueTypes.NO_HEAPTYPES, _, _); +def newSig = ValueTypes.newSig; class JawaTester extends ModuleBuilder { def NO_CLASS_ATTRS: JawaClassAttr.set; diff --git a/test/unittest/ModuleBuilder.v3 b/test/unittest/ModuleBuilder.v3 index ccd68f13..73bb24c6 100644 --- a/test/unittest/ModuleBuilder.v3 +++ b/test/unittest/ModuleBuilder.v3 @@ -31,7 +31,7 @@ class ModuleBuilder { module.functions[func_index] = func = nf; } def sig0(params: Array, results: Array) -> this { - sig(SigDecl.new(ValueTypes.NO_HEAPTYPES, params, results)); + sig(SigDecl.new(true, ValueTypes.NO_HEAPTYPES, params, results)); } def addSig(sig: SigDecl) -> SigDecl { if (u32.view(sig.heaptype_index) >= module.heaptypes.length || module.heaptypes[sig.heaptype_index] != sig) { @@ -48,25 +48,25 @@ class ModuleBuilder { return func; } def newSig(params: Array, results: Array) -> SigDecl { - var sig = SigDecl.new(ValueTypes.NO_HEAPTYPES, params, results); + var sig = SigDecl.new(true, ValueTypes.NO_HEAPTYPES, params, results); sig = SigDecl.!(cache.doOne(sig)); module.addDecl(sig); return sig; } def newStruct(field_types: Array) -> StructDecl { - var decl = StructDecl.new(ValueTypes.NO_HEAPTYPES, field_types); + var decl = StructDecl.new(true, ValueTypes.NO_HEAPTYPES, field_types); decl = StructDecl.!(cache.doOne(decl)); module.addDecl(decl); return decl; } def newStructP(supertypes: Array, field_types: Array) -> StructDecl { - var decl = StructDecl.new(Arrays.map(supertypes, HeapType.Struct), field_types); + var decl = StructDecl.new(true, Arrays.map(supertypes, HeapType.Struct), field_types); decl = StructDecl.!(cache.doOne(decl)); module.addDecl(decl); return decl; } def newArray(elem_types: Array) -> ArrayDecl { - var decl = ArrayDecl.new(ValueTypes.NO_HEAPTYPES, elem_types); + var decl = ArrayDecl.new(true, ValueTypes.NO_HEAPTYPES, elem_types); decl = ArrayDecl.!(cache.doOne(decl)); module.addDecl(decl); return decl; diff --git a/test/unittest/ValueTypeTest.v3 b/test/unittest/ValueTypeTest.v3 index 83e81c5f..e18bd5c4 100644 --- a/test/unittest/ValueTypeTest.v3 +++ b/test/unittest/ValueTypeTest.v3 @@ -46,9 +46,12 @@ def X = [ ]; def NO_SUPERS = ValueTypes.NO_HEAPTYPES; -def newSig = SigDecl.new(NO_SUPERS, _, _); -def newStruct = StructDecl.new(NO_SUPERS, _); -def newArray = ArrayDecl.new(NO_SUPERS, _); +def newSig = SigDecl.new(true, NO_SUPERS, _, _); +def newStruct = StructDecl.new(true, NO_SUPERS, _); +def newArray = ArrayDecl.new(true, NO_SUPERS, _); +def finalSig = SigDecl.new(true, _, _, _); +def finalStruct = StructDecl.new(true, _, _); +def finalArray = ArrayDecl.new(true, _, _); def VtRefT = ValueType.Ref(false, _); def VtRefN = ValueType.Ref(true, _); @@ -56,15 +59,15 @@ class ValueTypeTester(t: Tester) { var cache: HeapTypeCache; def newCanonSig(params: Array, results: Array) -> SigDecl { - var sig = SigDecl.new(NO_SUPERS, params, results); + var sig = newSig(params, results); return SigDecl.!(canon().doOne(sig)); } def newCanonStruct(field_types: Array) -> StructDecl { - var st = StructDecl.new(NO_SUPERS, field_types); + var st = newStruct(field_types); return StructDecl.!(canon().doOne(st)); } def newCanonArray(elem_types: Array) -> ArrayDecl { - var at = ArrayDecl.new(NO_SUPERS, elem_types); + var at = newArray(elem_types); return ArrayDecl.!(canon().doOne(at)); } def canon() -> HeapTypeCache { @@ -375,16 +378,16 @@ def check_super_chain(t: ValueTypeTester, newDecl: (Array, P) -> def test_super_chainS(t: ValueTypeTester) { var no_fields = Array.new(0); - check_super_chain(t, StructDecl.new, HeapType.Struct, no_fields); + check_super_chain(t, finalStruct, HeapType.Struct, no_fields); } def test_super_chainA(t: ValueTypeTester) { var no_fields = Array.new(0); - check_super_chain(t, ArrayDecl.new, HeapType.Array, no_fields); + check_super_chain(t, finalArray, HeapType.Array, no_fields); } def newSigDecl2(supertypes: Array, pr: (Array, Array)) -> SigDecl { - return SigDecl.new(supertypes, pr.0, pr.1); // just unpacks tuple to two args + return finalSig(supertypes, pr.0, pr.1); // just unpacks tuple to two args } def test_super_chainF(t: ValueTypeTester) { @@ -394,11 +397,11 @@ def test_super_chainF(t: ValueTypeTester) { def check_func_variance(t: ValueTypeTester, a: ValueType, b: ValueType) { { // return variance - var sig_b = SigDecl.new(NO_SUPERS, SigCache.arr_v, [b]); + var sig_b = newSig(SigCache.arr_v, [b]); var f_b = VtRefN(HeapType.Func(sig_b)); if (ValueTypes.isAssignable(a, b)) { - var sig_a = SigDecl.new([HeapType.Func(sig_b)], SigCache.arr_v, [a]); + var sig_a = finalSig([HeapType.Func(sig_b)], SigCache.arr_v, [a]); t.assert_subtype(VtRefT(HeapType.Func(sig_a)), f_b); t.assert_subtype(VtRefN(HeapType.Func(sig_a)), f_b); } @@ -407,11 +410,11 @@ def check_func_variance(t: ValueTypeTester, a: ValueType, b: ValueType) { t.assert_unrelated(f_a, f_b); } { // param variance - var sig_a = SigDecl.new(NO_SUPERS, [a], SigCache.arr_v); + var sig_a = newSig([a], SigCache.arr_v); var f_a = VtRefN(HeapType.Func(sig_a)); if (ValueTypes.isAssignable(a, b)) { - var sig_b = SigDecl.new([HeapType.Func(sig_a)], [b], SigCache.arr_v); + var sig_b = finalSig([HeapType.Func(sig_a)], [b], SigCache.arr_v); t.assert_subtype(VtRefT(HeapType.Func(sig_b)), f_a); t.assert_subtype(VtRefN(HeapType.Func(sig_b)), f_a); } @@ -461,7 +464,7 @@ def test_func_var2(t: ValueTypeTester) { def test_rec_func1(t: ValueTypeTester) { var m = Module.new("ValueTypeTest.v3"); for (p in PRIMS) { - var sig1 = SigDecl.new(NO_SUPERS, [p], [VtRefT(HeapType.FwRef(0))]); + var sig1 = newSig([p], [VtRefT(HeapType.FwRef(0))]); m.addDecl(sig1); t.canon().doGroup(m.heaptypes, 0, 1); sig1 = SigDecl.!(m.heaptypes[0]); @@ -469,7 +472,7 @@ def test_rec_func1(t: ValueTypeTester) { t.assert_equal(VtRefT(HeapType.Func(sig1)), VtRefT(HeapType.Func(sig1))); t.assert_subtype(VtRefT(HeapType.Func(sig1)), VtRefN(HeapType.Func(sig1))); - var sig2 = SigDecl.new(NO_SUPERS, [p], [VtRefT(HeapType.FwRef(0))]); + var sig2 = newSig([p], [VtRefT(HeapType.FwRef(0))]); m.addDecl(sig2); t.canon().doGroup(m.heaptypes, 1, 1); sig2 = SigDecl.!(m.heaptypes[1]); @@ -481,12 +484,12 @@ def test_rec_func1(t: ValueTypeTester) { def test_rec_func2(t: ValueTypeTester) { var m = Module.new("ValueTypeTest.v3"); for (p in PRIMS) { - var sig1 = SigDecl.new(NO_SUPERS, [VtRefT(HeapType.FwRef(0))], [p]); + var sig1 = newSig([VtRefT(HeapType.FwRef(0))], [p]); m.addDecl(sig1); t.canon().doGroup(m.heaptypes, 0, 1); sig1 = SigDecl.!(m.heaptypes[0]); - var sig2 = SigDecl.new(NO_SUPERS, [p], [VtRefT(HeapType.FwRef(0))]); + var sig2 = newSig([p], [VtRefT(HeapType.FwRef(0))]); m.addDecl(sig2); t.canon().doGroup(m.heaptypes, 1, 1); sig2 = SigDecl.!(m.heaptypes[1]); @@ -537,11 +540,11 @@ def test_array1(t: ValueTypeTester) { def test_array_sub1(t: ValueTypeTester) { for (mut in [false, true]) { - var ra = ArrayDecl.new(NO_SUPERS, [unpackedT(ValueTypes.ANYREF, mut)]); + var ra = finalArray(NO_SUPERS, [unpackedT(ValueTypes.ANYREF, mut)]); ra.heaptype_index = 5; var fa = if(mut, - ArrayDecl.new(NO_SUPERS, [unpackedT(ValueTypes.FUNCREF, mut)]), - ArrayDecl.new([HeapType.Array(ra)], [unpackedT(ValueTypes.FUNCREF, mut)])); + finalArray(NO_SUPERS, [unpackedT(ValueTypes.FUNCREF, mut)]), + finalArray([HeapType.Array(ra)], [unpackedT(ValueTypes.FUNCREF, mut)])); fa.heaptype_index = 6; for (nullable in [false, true]) { var rat = ValueType.Ref(nullable, HeapType.Array(ra)); @@ -576,10 +579,10 @@ def test_struct1(t: ValueTypeTester) { def test_struct_sub1(t: ValueTypeTester) { for (mut in [true, false]) { - var ra = StructDecl.new(NO_SUPERS, [unpackedT(ValueTypes.ANYREF, mut)]); + var ra = finalStruct(NO_SUPERS, [unpackedT(ValueTypes.ANYREF, mut)]); var fa = if(mut, - StructDecl.new(NO_SUPERS, [unpackedT(ValueTypes.FUNCREF, mut)]), - StructDecl.new([HeapType.Struct(ra)], [unpackedT(ValueTypes.FUNCREF, mut)])); + finalStruct(NO_SUPERS, [unpackedT(ValueTypes.FUNCREF, mut)]), + finalStruct([HeapType.Struct(ra)], [unpackedT(ValueTypes.FUNCREF, mut)])); for (nullable in [true, false]) { var rat = ValueType.Ref(nullable, HeapType.Struct(ra)); var fat = ValueType.Ref(nullable, HeapType.Struct(fa)); @@ -595,8 +598,8 @@ def test_struct_sub2(t: ValueTypeTester) { for (mut in [false, true]) { for (ti in TERMS) { for (tj in PRIMS) { - var a = StructDecl.new(NO_SUPERS, [unpackedT(ti, mut)]); - var b = StructDecl.new([HeapType.Struct(a)], [unpackedT(ti, mut), unpackedT(tj, mut)]); + var a = finalStruct(NO_SUPERS, [unpackedT(ti, mut)]); + var b = finalStruct([HeapType.Struct(a)], [unpackedT(ti, mut), unpackedT(tj, mut)]); var sa = VtRefT(HeapType.Struct(a)); var sb = VtRefT(HeapType.Struct(b)); t.assert_subtype(sb, sa);