diff options
| author | Cliff Click <cliffc@acm.org> | 2026-12-04 14:34:59 -0800 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-12-04 14:34:59 -0800 |
| commit | 57f2a6b71e449f323fa944b2d3e34e7fadd54e6d (patch) | |
| tree | 5c2b62dd87817ba03e32dbdb567811d38694cfba /chapter33/src/test/java | |
| parent | b5786e4f67c166a11533660647196c15e04508cd (diff) | |
| download | Simple-57f2a6b71e449f323fa944b2d3e34e7fadd54e6d.tar.gz Simple-57f2a6b71e449f323fa944b2d3e34e7fadd54e6d.zip | |
Replace XInt with TypeSet while preserving existing set semantics
Migrate function targets, escape aliases/functions, RPC sets, struct caches, compiler consumers, and serialized types. Keep uniform defaults and the existing cofinite import remapping so this step does not alter parsing or escape policy. Clear lazy struct set caches before recycling TypeSets on reset. Remove XInt source.
Use C0DC for the new packed set layout and test rejection of C0D2 objects. Add packing and word-boundary coverage. Before migration, differential checks matched XInt for 10,000 finite/cofinite pairs and 11 million memberships.
Validation: make -k -j8 tests passes after rebuilding old-format caches (835 executions), including four lattice shards and native/separate-compilation tests. Warmed TypeSet intern hits allocate no storage. git diff --cached --check passes.
Diffstat (limited to 'chapter33/src/test/java')
8 files changed, 100 insertions, 74 deletions
diff --git a/chapter33/src/test/java/com/seaofnodes/simple/BulkMemPhiTest.java b/chapter33/src/test/java/com/seaofnodes/simple/BulkMemPhiTest.java index fd816c68..cf57865e 100644 --- a/chapter33/src/test/java/com/seaofnodes/simple/BulkMemPhiTest.java +++ b/chapter33/src/test/java/com/seaofnodes/simple/BulkMemPhiTest.java @@ -5,7 +5,7 @@ import com.seaofnodes.simple.node.*; import com.seaofnodes.simple.type.TypeInteger; import com.seaofnodes.simple.type.TypeMem; import com.seaofnodes.simple.type.Type; -import com.seaofnodes.simple.type.XInt; +import com.seaofnodes.simple.type.TypeSet; import org.junit.Test; import static org.junit.Assert.*; @@ -14,7 +14,7 @@ public class BulkMemPhiTest { CodeGen code = new CodeGen(""); code._phase = CodeGen.Phase.Lower; Node defaults = code.con(TypeMem.START); - Node method = code.con(TypeMem.make(55,Type.BOTTOM,false,false,false,XInt.make(4),XInt.EMPTY)); + Node method = code.con(TypeMem.make(55,Type.BOTTOM,false,false,false,TypeSet.of(4),TypeSet.EMPTY)); MemMergeNode fields = new MemMergeNode(null,defaults); fields.alias(55,method); fields.init(); @@ -30,7 +30,7 @@ public class BulkMemPhiTest { assertTrue("A new slice must not inherit an escape bound that excludes its method", precise.compute().isa(precise._type)); precise.peephole(); - assertTrue(XInt.bit(((TypeMem)precise._type)._escFs,4)); + assertTrue(((TypeMem)precise._type)._escFs.contains(4)); } // Reduced from Capitalize's Lower-phase failure. A precise MemMerge slot diff --git a/chapter33/src/test/java/com/seaofnodes/simple/CallEndTest.java b/chapter33/src/test/java/com/seaofnodes/simple/CallEndTest.java index bba3a2c8..7983141d 100644 --- a/chapter33/src/test/java/com/seaofnodes/simple/CallEndTest.java +++ b/chapter33/src/test/java/com/seaofnodes/simple/CallEndTest.java @@ -56,10 +56,10 @@ public class CallEndTest { ret._type = TypeTuple.make(Type.CONTROL,TypeMem.START,broad); TypeTuple unknownStop = stop.compute(); TypeMem unknownGlobal = global.compute(); - assertSame(XInt.FULL,((TypeMem)unknownStop.mem())._escFs); - assertSame(XInt.FULL,((TypeMem)unknownStop.mem())._escAs); - assertSame(XInt.FULL,unknownGlobal._escFs); - assertSame(XInt.FULL,unknownGlobal._escAs); + assertSame(TypeSet.FULL,((TypeMem)unknownStop.mem())._escFs); + assertSame(TypeSet.FULL,((TypeMem)unknownStop.mem())._escAs); + assertSame(TypeSet.FULL,unknownGlobal._escFs); + assertSame(TypeSet.FULL,unknownGlobal._escAs); for( Type precise : new Type[]{object,callback} ) { assertTrue(precise.isa(broad)); value._type = precise; diff --git a/chapter33/src/test/java/com/seaofnodes/simple/Chapter25Test.java b/chapter33/src/test/java/com/seaofnodes/simple/Chapter25Test.java index 85f273a1..103461f0 100644 --- a/chapter33/src/test/java/com/seaofnodes/simple/Chapter25Test.java +++ b/chapter33/src/test/java/com/seaofnodes/simple/Chapter25Test.java @@ -15,7 +15,7 @@ import com.seaofnodes.simple.node.LoopNode; import com.seaofnodes.simple.type.TypeInteger; import com.seaofnodes.simple.type.TypeMem; import com.seaofnodes.simple.type.TypeTuple; -import com.seaofnodes.simple.type.XInt; +import com.seaofnodes.simple.type.TypeSet; import com.seaofnodes.simple.util.Ary; import java.io.File; import java.io.FileWriter; @@ -76,7 +76,7 @@ public class Chapter25Test { for( long seed : new long[]{1,123,987654321} ) { CodeGen code = new CodeGen(src,seed,true).driver(CodeGen.Phase.Parse); FunNode visible = null; - int[] privateFidxs = XInt.EMPTY; + TypeSet privateFidxs = TypeSet.EMPTY; int checked = 0; for( FunNode fun : code._linker ) { if( fun==null || fun._name==null ) continue; @@ -85,16 +85,16 @@ public class Chapter25Test { checked++; } if( fun._name.equals("_hidden") || fun._name.equals("hiddenClassMethod") ) { - privateFidxs = XInt.make(privateFidxs,fun.sig().fidx()); + privateFidxs = privateFidxs.with(fun.sig().fidx()); checked++; } } assertEquals(3,checked); code.driver(CodeGen.Phase.TypeCheck); TypeMem outside = ((TypeTuple)code._start._type).mem(); - assertTrue(XInt.bit(outside._escFs,visible.sig().fidx())); - for( int fidx = XInt.next(privateFidxs,0); fidx>=0; fidx = XInt.next(privateFidxs,fidx) ) - assertFalse(XInt.bit(outside._escFs,fidx)); + assertTrue(outside._escFs.contains(visible.sig().fidx())); + for( int fidx = privateFidxs.next(0); fidx>=0; fidx = privateFidxs.next(fidx) ) + assertFalse(outside._escFs.contains(fidx)); assertTrue(visible.unknownCallers()); assertEquals(TypeInteger.U8,visible.parm(3)._type); assertEquals("0",Eval2.eval(code,0)); @@ -119,11 +119,11 @@ public class Chapter25Test { code.driver(CodeGen.Phase.TypeCheck); TypeMem outside = ((TypeTuple)code._start._type).mem(); // A public field can publish a privately named function. - assertTrue(XInt.bit(outside._escFs,published)); - assertFalse(XInt.bit(outside._escFs,unpublished)); - assertTrue(XInt.bit(outside._escAs,clz.field("visible")._alias)); - assertFalse(XInt.bit(outside._escAs,clz.field("_hidden")._alias)); - assertFalse(XInt.bit(outside._escAs,clz.field("_private")._alias)); + assertTrue(outside._escFs.contains(published)); + assertFalse(outside._escFs.contains(unpublished)); + assertTrue(outside._escAs.contains(clz.field("visible")._alias)); + assertFalse(outside._escAs.contains(clz.field("_hidden")._alias)); + assertFalse(outside._escAs.contains(clz.field("_private")._alias)); } @Test public void testImportedEscapeExclusions() throws IOException { @@ -150,8 +150,8 @@ public class Chapter25Test { int hidden=((com.seaofnodes.simple.type.TypeFunPtr)clz.field("_hidden_noInline")._t).fidx(); assertNotEquals(savedHidden,hidden); TypeMem outside=((TypeTuple)code._start._type).mem(); - assertTrue(XInt.isHigh(outside._escFs)); - assertFalse(XInt.bit(outside._escFs,hidden)); + assertTrue(!outside._escFs.isFinite()); + assertFalse(outside._escFs.contains(hidden)); assertEquals("42",Eval2.eval(code,41)); Files.delete(dir.resolve("Lib.o")); Files.delete(dir); diff --git a/chapter33/src/test/java/com/seaofnodes/simple/EscapeFlowTest.java b/chapter33/src/test/java/com/seaofnodes/simple/EscapeFlowTest.java index ee7406c6..84aa8a3f 100644 --- a/chapter33/src/test/java/com/seaofnodes/simple/EscapeFlowTest.java +++ b/chapter33/src/test/java/com/seaofnodes/simple/EscapeFlowTest.java @@ -18,7 +18,7 @@ public class EscapeFlowTest { int hidden=named(code,"_hidden_noInline").sig().fidx(); code.driver(CodeGen.Phase.TypeCheck); TypeMem outside=((TypeTuple)code._start._type).mem(); - assertFalse(XInt.bit(outside._escFs,hidden)); + assertFalse(outside._escFs.contains(hidden)); assertEquals("0",Eval2.eval(code,0)); assertEquals("4",Eval2.eval(code,4)); } @@ -33,7 +33,7 @@ public class EscapeFlowTest { FunNode callback=named(code,"_callback_noInline"); int fidx=callback.sig().fidx(); code.driver(CodeGen.Phase.TypeCheck); - assertTrue(XInt.bit(((TypeTuple)code._start._type).mem()._escFs,fidx)); + assertTrue(((TypeTuple)code._start._type).mem()._escFs.contains(fidx)); assertFalse(callback.isDead()); assertTrue(callback.unknownCallers()); } @@ -47,8 +47,8 @@ public class EscapeFlowTest { return wrap; """,seed,true).driver(CodeGen.Phase.TypeCheck); TypeMem outside = ((TypeTuple)code._start._type).mem(); - assertTrue(XInt.isHigh(outside._escFs)); - assertNotSame(XInt.FULL,outside._escFs); + assertTrue(!outside._escFs.isFinite()); + assertNotSame(TypeSet.FULL,outside._escFs); for( FunNode fun : code._linker ) if( fun!=null && fun._name!=null && fun._name.contains("_A.") ) assertFalse(fun._name,fun.unknownCallers()); @@ -72,7 +72,7 @@ public class EscapeFlowTest { ParmNode callback = apply.parm(3); assertTrue(callback.in(1) instanceof ProjNode); TypeFunPtr type = (TypeFunPtr)callback._type; - assertTrue(XInt.isHigh(type.fidxs())); + assertTrue(!type.fidxs().isFinite()); assertSame(TypeInteger.I32,apply.ret().expr()._type); // Only <clinit> and apply escape; forwarding #self must not expose _hidden. assertEquals("Stop[ return { apply_noInline}; return #2; ]",code.print()); @@ -86,7 +86,7 @@ public class EscapeFlowTest { """).driver(CodeGen.Phase.TypeCheck); FunNode callback = named(code,"_callback_noInline"); assertTrue(callback.unknownCallers()); - assertTrue(XInt.bit(((TypeTuple)code._start._type).mem()._escFs,callback.sig().fidx())); + assertTrue(((TypeTuple)code._start._type).mem()._escFs.contains(callback.sig().fidx())); } // Call remains CONTROL. Changing only the outside set must wake CallEnd @@ -100,17 +100,17 @@ public class EscapeFlowTest { CallNode call = new CallNode(null,ConstantNode.raw(Type.CONTROL), ConstantNode.raw(TypeMem.START),ConstantNode.raw(factory)).init(); CallEndNode end = new CallEndNode(call,TypeRPC.BOT); - int[] foreign = XInt.dual(XInt.make(7)); - code._start._type = TypeTuple.make(Type.CONTROL,TypeMem.START.makeFrom(foreign,XInt.EMPTY),TypeInteger.BOT); + TypeSet foreign = TypeSet.of(7).dual(); + code._start._type = TypeTuple.make(Type.CONTROL,TypeMem.START.makeFrom(foreign,TypeSet.EMPTY),TypeInteger.BOT); TypeTuple before = (TypeTuple)end.compute(); - assertFalse(XInt.bit(((TypeFunPtr)before.ret()).fidxs(),7)); + assertFalse(((TypeFunPtr)before.ret()).fidxs().contains(7)); boolean depends = false; for( int i = 0; i<code._start.nDeps(); i++ ) depends |= code._start.dep(i)==end; assertTrue(depends); - code._start._type = TypeTuple.make(Type.CONTROL,TypeMem.START.makeFrom(XInt.FULL,XInt.EMPTY),TypeInteger.BOT); + code._start._type = TypeTuple.make(Type.CONTROL,TypeMem.START.makeFrom(TypeSet.FULL,TypeSet.EMPTY),TypeInteger.BOT); TypeTuple after = (TypeTuple)end.compute(); assertTrue(before.isa(after)); - assertTrue(XInt.bit(((TypeFunPtr)after.ret()).fidxs(),7)); + assertTrue(((TypeFunPtr)after.ret()).fidxs().contains(7)); } // Ordinary arguments do not read Start, but a later opaque argument must @@ -126,22 +126,22 @@ public class EscapeFlowTest { SummaryNode observer = new SummaryNode(state,new int[0],ctrl,mem).init(); summary.exposed(observer); code._iter._work.clear(); - code._start.setType(TypeTuple.make(Type.CONTROL,TypeMem.START.makeFrom(XInt.make(XInt.make(7),8),XInt.EMPTY),TypeInteger.BOT)); + code._start.setType(TypeTuple.make(Type.CONTROL,TypeMem.START.makeFrom(TypeSet.of(7).with(8),TypeSet.EMPTY),TypeInteger.BOT)); assertFalse(code._iter._work.on(summary)); assertFalse(code._iter._work.on(observer)); arg.setType(TypeMemPtr.makeNullable(TypeStruct.forward("OpaqueSummary"))); assertTrue(code._iter._work.on(summary)); assertTrue(code._iter._work.on(observer)); - assertTrue(XInt.bit(((TypeTuple)summary.compute()).mem()._escFs,7)); - assertTrue(XInt.bit(summary.exposed(observer)._escFs,7)); + assertTrue(((TypeTuple)summary.compute()).mem()._escFs.contains(7)); + assertTrue(summary.exposed(observer)._escFs.contains(7)); code._iter._work.clear(); - code._start.setType(TypeTuple.make(Type.CONTROL,TypeMem.START.makeFrom(XInt.make(8),XInt.EMPTY),TypeInteger.BOT)); + code._start.setType(TypeTuple.make(Type.CONTROL,TypeMem.START.makeFrom(TypeSet.of(8),TypeSet.EMPTY),TypeInteger.BOT)); assertTrue(code._iter._work.on(summary)); assertTrue(code._iter._work.on(observer)); - assertTrue(XInt.bit(((TypeTuple)summary.compute()).mem()._escFs,8)); - assertTrue(XInt.bit(summary.exposed(observer)._escFs,8)); - assertFalse(XInt.bit(summary.exposed(observer)._escFs,7)); + assertTrue(((TypeTuple)summary.compute()).mem()._escFs.contains(8)); + assertTrue(summary.exposed(observer)._escFs.contains(8)); + assertFalse(summary.exposed(observer)._escFs.contains(7)); } // Public construction exposes the allocator; private-memory helpers @@ -152,17 +152,17 @@ public class EscapeFlowTest { return new Box(((arg<<32)>>32)).n; """).parse(); FunNode allocator = named(code,"Test.Box.<new>"); - int[] helpers = XInt.EMPTY; + TypeSet helpers = TypeSet.EMPTY; for( FunNode fun : code._linker ) if( fun!=null && fun.sig().ret() instanceof TypeMem ) - helpers = XInt.make(helpers,fun.sig().fidx()); - assertNotSame(XInt.EMPTY,helpers); + helpers = helpers.with(fun.sig().fidx()); + assertNotSame(TypeSet.EMPTY,helpers); code.driver(CodeGen.Phase.TypeCheck); TypeMem outside = ((TypeTuple)code._start._type).mem(); assertTrue(allocator.unknownCallers()); - assertTrue(XInt.bit(outside._escFs,allocator.sig().fidx())); - for( int fidx = XInt.next(helpers,0); fidx>=0; fidx = XInt.next(helpers,fidx) ) - assertFalse(XInt.bit(outside._escFs,fidx)); + assertTrue(outside._escFs.contains(allocator.sig().fidx())); + for( int fidx = helpers.next(0); fidx>=0; fidx = helpers.next(fidx) ) + assertFalse(outside._escFs.contains(fidx)); assertEquals("42",Eval2.eval(code,42)); } diff --git a/chapter33/src/test/java/com/seaofnodes/simple/SeparateCompilationTest.java b/chapter33/src/test/java/com/seaofnodes/simple/SeparateCompilationTest.java index cc4e552f..72e26a2e 100644 --- a/chapter33/src/test/java/com/seaofnodes/simple/SeparateCompilationTest.java +++ b/chapter33/src/test/java/com/seaofnodes/simple/SeparateCompilationTest.java @@ -36,7 +36,7 @@ public class SeparateCompilationTest { Path file=lib.resolve("Old.o"); ElfReader elf=ElfReader.load(file.toFile(),null); byte[] bytes=Files.readAllBytes(file); - bytes[elf._bais.size()+3]='E'; // Previous C0DE header, before format 2. + bytes[elf._bais.size()+3]='2'; // Previous format used packed XInt arrays. Files.write(file,bytes); try { ElfReader.load(file.toFile(),null).loadPublicTypes(new CodeGen("")); diff --git a/chapter33/src/test/java/com/seaofnodes/simple/TypeSetTest.java b/chapter33/src/test/java/com/seaofnodes/simple/TypeSetTest.java index 5f25a901..43e35fc3 100644 --- a/chapter33/src/test/java/com/seaofnodes/simple/TypeSetTest.java +++ b/chapter33/src/test/java/com/seaofnodes/simple/TypeSetTest.java @@ -2,6 +2,7 @@ package com.seaofnodes.simple; import com.seaofnodes.simple.type.Type; import com.seaofnodes.simple.type.TypeSet; +import com.seaofnodes.simple.util.BAOS; import java.util.ArrayList; import org.junit.Before; import org.junit.Test; @@ -10,6 +11,31 @@ import static org.junit.Assert.*; public class TypeSetTest { @Before public void resetTypes() { Type.reset(); } + @Test public void testPackedSetsAndUniformOperations() { + int[] ids = {0,1,30,31,32,63,64,95,127,1023}; + TypeSet finite = TypeSet.of(ids); + assertEquals(ids.length,finite.bitCount()); + int next = -1; + for( int id : ids ) { + next = finite.next(next); + assertEquals(id,next); + } + assertEquals(-1,finite.next(next)); + assertEquals(0,TypeSet.of(0).onlyBit()); + assertSame(TypeSet.FULL,finite.meet(finite.dual())); + assertSame(TypeSet.EMPTY,finite.join(finite.dual())); + assertSame(finite,finite.with(2048).without(2048)); + for( int defaults=0; defaults<4; defaults++ ) + for( int[] exceptions : new int[][]{new int[0],ids} ) { + TypeSet set = TypeSet.make((defaults&1)!=0,(defaults&2)!=0,exceptions); + BAOS out = new BAOS(); + set.packed(out); + BAOS in = new BAOS(out.toByteArray()); + assertSame(set,TypeSet.unpack(in)); + assertEquals(out.size(),in.size()); + } + } + @Test public void testTypeSetDiscoveryAndInterning() { int[] external = {0xAAAAAAAA,0xAAAAAAAA,2}; // Odd identities are external. int[] exceptions = {0,31,32,63,65}; diff --git a/chapter33/src/test/java/com/seaofnodes/simple/TypeTest.java b/chapter33/src/test/java/com/seaofnodes/simple/TypeTest.java index adcc1b3a..28b6b0fb 100644 --- a/chapter33/src/test/java/com/seaofnodes/simple/TypeTest.java +++ b/chapter33/src/test/java/com/seaofnodes/simple/TypeTest.java @@ -48,9 +48,9 @@ public class TypeTest { // Conversely, a singleton pointer can refer to mutable contents. Assert.assertTrue(TypeMemPtr.make((byte)2,varying,true).isConstant()); - TypeMem memory = TypeMem.make(2,cycle,true,true,true,XInt.EMPTY,XInt.EMPTY); + TypeMem memory = TypeMem.make(2,cycle,true,true,true,TypeSet.EMPTY,TypeSet.EMPTY); Assert.assertTrue(memory.isConstant()); - Assert.assertFalse(TypeMem.make(2,cycle,true,false,true,XInt.EMPTY,XInt.EMPTY).isConstant()); + Assert.assertFalse(TypeMem.make(2,cycle,true,false,true,TypeSet.EMPTY,TypeSet.EMPTY).isConstant()); // Repeated aggregate types are sharing, not recursion. Neither query // should require or leave behind a cyclic-traversal visit marker. TypeTuple tuple = TypeTuple.make(cycle,memory,cycle); @@ -80,23 +80,23 @@ public class TypeTest { } @Test public void testOpaqueExternalEscapes() { - TypeMem defaults = TypeMem.START.makeFrom(XInt.make(2),XInt.make(3)); - TypeMem prior = TypeMem.START.makeFrom(XInt.make(5),XInt.make(7)); + TypeMem defaults = TypeMem.START.makeFrom(TypeSet.of(2),TypeSet.of(3)); + TypeMem prior = TypeMem.START.makeFrom(TypeSet.of(5),TypeSet.of(7)); TypeMemPtr opaque = TypeMemPtr.makeNullable(TypeStruct.forward("OpaqueExternal")); TypeMem escaped = prior.escapesFrom(opaque,defaults); - assertSame(XInt.meet(prior._escFs,defaults._escFs),escaped._escFs); - assertSame(XInt.meet(prior._escAs,defaults._escAs),escaped._escAs); + assertSame(prior._escFs.meet(defaults._escFs),escaped._escFs); + assertSame(prior._escAs.meet(defaults._escAs),escaped._escAs); // Before type closure the same name might still resolve locally. - assertSame(XInt.FULL,prior.escapesFrom(opaque,TypeMem.BOT)._escFs); + assertSame(TypeSet.FULL,prior.escapesFrom(opaque,TypeMem.BOT)._escFs); for( Type unknown : new Type[]{Type.BOTTOM,TypeScalar.BOT,TypePtr.PTR, TypeMemPtr.make(TypeStruct.open("LocalStillOpen"))} ) { TypeMem broad = prior.escapesFrom(unknown,defaults); - assertSame(XInt.FULL,broad._escFs); - assertSame(XInt.FULL,broad._escAs); + assertSame(TypeSet.FULL,broad._escFs); + assertSame(TypeSet.FULL,broad._escAs); } // Concrete private callbacks must not be restricted to public names. TypeFunPtr callback = TypeFunPtr.make1((byte)2,true,TypeFunPtr.TEMPTY,TypeInteger.BOT,11); - assertSame(XInt.make(11),TypeMem.START.escapesFrom(callback,defaults)._escFs); + assertSame(TypeSet.of(11),TypeMem.START.escapesFrom(callback,defaults)._escFs); } // Aggregate finality is carried by its fields. Canonicalizing the unused @@ -107,18 +107,18 @@ public class TypeTest { Field.make("y",TypeInteger.ZERO,3,true)); for( Type t : new Type[]{Type.BOTTOM,Type.TOP,TypeStruct.BOT,TypeStruct.TOP,obj,obj.dual()} ) for( boolean one : new boolean[]{false,true} ) { - TypeMem mem = TypeMem.make(1,t,one,false,false,XInt.EMPTY,XInt.EMPTY); - assertSame(mem,TypeMem.make(1,t,one,false,true,XInt.EMPTY,XInt.EMPTY)); + TypeMem mem = TypeMem.make(1,t,one,false,false,TypeSet.EMPTY,TypeSet.EMPTY); + assertSame(mem,TypeMem.make(1,t,one,false,true,TypeSet.EMPTY,TypeSet.EMPTY)); assertSame(mem,mem.dual().dual()); - assertSame(mem.dual(),TypeMem.make(1,t.dual(),!one,true,true,XInt.FULL,XInt.FULL)); + assertSame(mem.dual(),TypeMem.make(1,t.dual(),!one,true,true,TypeSet.FULL,TypeSet.FULL)); } // Precise field slices still distinguish final and mutable storage. - Assert.assertNotEquals(TypeMem.make(2,TypeInteger.BOT,false,false,false,XInt.EMPTY,XInt.EMPTY), - TypeMem.make(2,TypeInteger.BOT,false,false,true ,XInt.EMPTY,XInt.EMPTY)); + Assert.assertNotEquals(TypeMem.make(2,TypeInteger.BOT,false,false,false,TypeSet.EMPTY,TypeSet.EMPTY), + TypeMem.make(2,TypeInteger.BOT,false,false,true ,TypeSet.EMPTY,TypeSet.EMPTY)); for( boolean one : new boolean[]{false,true} ) for( boolean fin : new boolean[]{false,true} ) { - TypeMem bulk = TypeMem.make(1,Type.TOP,one,false,false,XInt.EMPTY,XInt.EMPTY); - TypeMem slice = TypeMem.make(2,TypeInteger.BOT,false,false,fin,XInt.EMPTY,XInt.EMPTY); + TypeMem bulk = TypeMem.make(1,Type.TOP,one,false,false,TypeSet.EMPTY,TypeSet.EMPTY); + TypeMem slice = TypeMem.make(2,TypeInteger.BOT,false,false,fin,TypeSet.EMPTY,TypeSet.EMPTY); assertSame(slice,bulk.meet(slice)); check_symmetric(bulk,slice); check_symmetric(bulk.dual(),slice.dual()); @@ -134,8 +134,8 @@ public class TypeTest { for( Type broad : new Type[]{Type.BOTTOM,TypeScalar.BOT,TypePtr.PTR,TypePtr.NPTR} ) { Assert.assertTrue(precise.isa(broad)); TypeMem unknown = TypeMem.START.escapes(broad); - assertSame(XInt.FULL,unknown._escFs); - assertSame(XInt.FULL,unknown._escAs); + assertSame(TypeSet.FULL,unknown._escFs); + assertSame(TypeSet.FULL,unknown._escAs); Assert.assertTrue(TypeMem.START.escapes(precise).isa(unknown)); } for( Type empty : new Type[]{Type.TOP,TypeScalar.TOP,TypePtr.XPTR,TypePtr.XNPTR,TypeNil.NIL} ) @@ -143,14 +143,14 @@ public class TypeTest { } @Test public void testBoundedBits() { - int[] sparse = XInt.make(XInt.make(2),65); - for( int[] bits : new int[][]{XInt.EMPTY,XInt.FULL,sparse,XInt.dual(sparse)} ) + TypeSet sparse = TypeSet.of(2).with(65); + for( TypeSet bits : new TypeSet[]{TypeSet.EMPTY,TypeSet.FULL,sparse,sparse.dual()} ) for( int limit : new int[]{0,1,32,65,66,100} ) { - int next = XInt.next(bits,-1,limit); + int next = bits.nextKnown(-1,limit); for( int bit=0; bit<limit; bit++ ) - if( XInt.bit(bits,bit) ) { + if( bits.contains(bit) ) { Assert.assertEquals(bit,next); - next = XInt.next(bits,next,limit); + next = bits.nextKnown(next,limit); } Assert.assertEquals(-1,next); } @@ -218,12 +218,12 @@ public class TypeTest { Assert.assertNotEquals(m3, m4); Assert.assertEquals(TypeStruct.BOT, s1.meet(s2)); - TypeMem scalarMemBot = TypeMem.make(1,TypeScalar.BOT,false,false,false,XInt.FULL,XInt.FULL); - Assert.assertEquals(scalarMemBot, ((TypeMem)m1.meet(m2)).makeFrom( XInt.FULL, XInt.FULL)); + TypeMem scalarMemBot = TypeMem.make(1,TypeScalar.BOT,false,false,false,TypeSet.FULL,TypeSet.FULL); + Assert.assertEquals(scalarMemBot, ((TypeMem)m1.meet(m2)).makeFrom( TypeSet.FULL, TypeSet.FULL)); Assert.assertEquals(TypeMem.make(1,TypeScalar.BOT), m1.meet(m3)); - Assert.assertEquals(scalarMemBot, ((TypeMem)m3.meet(m4)).makeFrom( XInt.FULL, XInt.FULL)); + Assert.assertEquals(scalarMemBot, ((TypeMem)m3.meet(m4)).makeFrom( TypeSet.FULL, TypeSet.FULL)); - Assert.assertEquals(TypeMem.make(2,Type.XNIL,true,true,true, XInt.FULL, XInt.FULL), m1.dual()); + Assert.assertEquals(TypeMem.make(2,Type.XNIL,true,true,true, TypeSet.FULL, TypeSet.FULL), m1.dual()); TypeMemPtr ptr1 = TypeMemPtr.make(s1); Assert.assertEquals(s1, ptr1._obj); diff --git a/chapter33/src/test/java/com/seaofnodes/simple/type/PackedTypeTestSupport.java b/chapter33/src/test/java/com/seaofnodes/simple/type/PackedTypeTestSupport.java index c218e98b..39ea46b9 100644 --- a/chapter33/src/test/java/com/seaofnodes/simple/type/PackedTypeTestSupport.java +++ b/chapter33/src/test/java/com/seaofnodes/simple/type/PackedTypeTestSupport.java @@ -7,7 +7,7 @@ import static org.junit.Assert.*; public class PackedTypeTestSupport { public static void singleton(int id) { Type.TAGOFFS(); - TypeFunPtr fun=TypeFunPtr.make((byte)2,true,new Type[0],TypeInteger.BOT,XInt.make(id)); + TypeFunPtr fun=TypeFunPtr.make((byte)2,true,new Type[0],TypeInteger.BOT,TypeSet.of(id)); BAOS out=new BAOS(); fun.packed(out,new HashMap<>()); assertEquals(id<=254 ? 2 : 4,out.size()); |
