From d85354f39d267e1840edeebf1e6e81b90985d3a8 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Tue, 29 Apr 2025 21:52:24 -0700 Subject: Drop a false start for adding clazz fields. GLB does not widen primitives in memory. Missing float-cmp-copy --- .../test/java/com/seaofnodes/simple/Chapter16Test.java | 4 ++-- .../test/java/com/seaofnodes/simple/Chapter17Test.java | 8 ++++---- .../test/java/com/seaofnodes/simple/Chapter22Test.java | 2 +- chapter22/src/test/java/com/seaofnodes/simple/Eval2.java | 3 +-- .../src/test/java/com/seaofnodes/simple/TypeTest.java | 16 ++++++++-------- .../com/seaofnodes/simple/fuzzer/ScriptGenerator.java | 2 +- 6 files changed, 17 insertions(+), 18 deletions(-) (limited to 'chapter22/src/test/java/com') diff --git a/chapter22/src/test/java/com/seaofnodes/simple/Chapter16Test.java b/chapter22/src/test/java/com/seaofnodes/simple/Chapter16Test.java index 930624e5..58bb4148 100644 --- a/chapter22/src/test/java/com/seaofnodes/simple/Chapter16Test.java +++ b/chapter22/src/test/java/com/seaofnodes/simple/Chapter16Test.java @@ -128,7 +128,7 @@ p.x++; return p; """); try { code.parse().opto().typeCheck(); fail(); } - catch( Exception e ) { assertEquals("Cannot modify final field 'x'",e.getMessage()); } + catch( Exception e ) { assertEquals("Cannot reassign final 'x'",e.getMessage()); } } @Test @@ -140,7 +140,7 @@ p.x++; return p; """); try { code.parse().opto().typeCheck(); fail(); } - catch( Exception e ) { assertEquals("Cannot modify final field 'x'",e.getMessage()); } + catch( Exception e ) { assertEquals("Cannot reassign final 'x'",e.getMessage()); } } @Test diff --git a/chapter22/src/test/java/com/seaofnodes/simple/Chapter17Test.java b/chapter22/src/test/java/com/seaofnodes/simple/Chapter17Test.java index 78515083..bdeb645c 100644 --- a/chapter22/src/test/java/com/seaofnodes/simple/Chapter17Test.java +++ b/chapter22/src/test/java/com/seaofnodes/simple/Chapter17Test.java @@ -172,13 +172,13 @@ return s.x; @Test public void testVar6() { CodeGen code = new CodeGen("struct S{int x;}; S s=new S; s.x++; return s.x; // Error initializer so x is immutable "); try { code.parse().opto().typeCheck(); fail(); } - catch( Exception e ) { assertEquals("Cannot modify final field 'x'",e.getMessage()); } + catch( Exception e ) { assertEquals("Cannot reassign final 'x'",e.getMessage()); } } @Test public void testVar7() { CodeGen code = new CodeGen("struct S{int x;}; S s=new S{x=3;}; s.x++; return s.x; // Error initializer so x is immutable "); try { code.parse().opto().typeCheck(); fail(); } - catch( Exception e ) { assertEquals("Cannot modify final field 'x'",e.getMessage()); } + catch( Exception e ) { assertEquals("Cannot reassign final 'x'",e.getMessage()); } } @Test public void testVar8() { @@ -198,7 +198,7 @@ return s.x; @Test public void testVar10() { CodeGen code = new CodeGen("struct S{int x;}; val s=new S; s.x++; return s.x; // Error, has val so x is immutable "); try { code.parse().opto().typeCheck(); fail(); } - catch( Exception e ) { assertEquals("Cannot modify final field 'x'",e.getMessage()); } + catch( Exception e ) { assertEquals("Cannot reassign final 'x'",e.getMessage()); } } @Test public void testVar11() { @@ -216,7 +216,7 @@ val xfoo = foo; // Throw away mutability xfoo.bar.x++; // Error, cannot mutate through xfoo """); try { code.parse().opto().typeCheck(); fail(); } - catch( Exception e ) { assertEquals("Cannot modify final field 'x'",e.getMessage()); } + catch( Exception e ) { assertEquals("Cannot reassign final 'x'",e.getMessage()); } } @Test public void testVar12() { diff --git a/chapter22/src/test/java/com/seaofnodes/simple/Chapter22Test.java b/chapter22/src/test/java/com/seaofnodes/simple/Chapter22Test.java index dccf00bc..6bec499e 100644 --- a/chapter22/src/test/java/com/seaofnodes/simple/Chapter22Test.java +++ b/chapter22/src/test/java/com/seaofnodes/simple/Chapter22Test.java @@ -28,7 +28,7 @@ public class Chapter22Test { assertEquals(stop, code._stop.toString()); } - @Test + @Test @Ignore public void testCoRecur() { String src = """ struct A { B? b; C? c; i64 ax; val az = x*2; }; diff --git a/chapter22/src/test/java/com/seaofnodes/simple/Eval2.java b/chapter22/src/test/java/com/seaofnodes/simple/Eval2.java index 38da6898..ecea97dd 100644 --- a/chapter22/src/test/java/com/seaofnodes/simple/Eval2.java +++ b/chapter22/src/test/java/com/seaofnodes/simple/Eval2.java @@ -407,8 +407,7 @@ public abstract class Eval2 { // Since never can close the type cycle, without cyclic types, have // to handle FRefs even here if( tmp.isFRef() ) - //tmp = tmp.makeFrom(((TypeMemPtr)Parser.TYPES.get(tmp._obj._name))._obj); - throw Utils.TODO(); + tmp = tmp.makeFrom(((TypeMemPtr)Parser.TYPES.get(tmp._obj._name))._obj); Object[] xs = (Object[])x; // Array of fields if( tmp._obj.isAry() ) { diff --git a/chapter22/src/test/java/com/seaofnodes/simple/TypeTest.java b/chapter22/src/test/java/com/seaofnodes/simple/TypeTest.java index d94f5b5a..660f984a 100644 --- a/chapter22/src/test/java/com/seaofnodes/simple/TypeTest.java +++ b/chapter22/src/test/java/com/seaofnodes/simple/TypeTest.java @@ -20,9 +20,9 @@ public class TypeTest { TypeStruct s2 = TypeStruct.make("s2", new Field[]{ Field.make("a", TypeInteger.BOT,-3, false), Field.make("b", TypeInteger.BOT,-4, false) }); - Assert.assertEquals(s1.makeRO(), s1.glb()); + Assert.assertEquals(s1.makeRO(), s1.glb(false)); Assert.assertNotEquals(s1, s1.dual()); - Assert.assertEquals(s1.makeRO(), s1.dual().glb()); + Assert.assertEquals(s1.makeRO(), s1.dual().glb(false)); TypeMem m1 = TypeMem.make(1,TypeNil.NIL); TypeMem m2 = TypeMem.make(2,TypeInteger.U16); @@ -38,9 +38,9 @@ public class TypeTest { Assert.assertEquals(TypeMem.make(0,Type.BOTTOM), m1.meet(m3)); Assert.assertEquals(TypeMem .BOT, m3.meet(m4)); - Assert.assertEquals(TypeMem.make(1,Type.BOTTOM), m1.glb()); + Assert.assertEquals(TypeMem.make(1,Type.BOTTOM), m1.glb(false)); Assert.assertEquals(TypeMem.make(1,Type.XNIL), m1.dual()); - Assert.assertEquals(m4.dual(), m4.glb().dual()); + Assert.assertEquals(m4.dual(), m4.glb(false).dual()); TypeMemPtr ptr1 = TypeMemPtr.make(s1); Assert.assertEquals(s1, ptr1._obj); @@ -55,13 +55,13 @@ public class TypeTest { Assert.assertEquals(s2, ptr2nil._obj); Assert.assertNotEquals(ptr1, ptr2); - Assert.assertNotEquals(ptr1, ptr1.glb()); - Assert.assertEquals(ptr1nil.makeRO(), ptr1.glb()); + Assert.assertNotEquals(ptr1, ptr1.glb(false)); + Assert.assertEquals(ptr1nil.makeRO(), ptr1.glb(false)); Assert.assertEquals(ptr1, ptr1.dual().dual()); - Assert.assertEquals(ptr1.glb().makeRO(), ptr1.dual().glb()); + Assert.assertEquals(ptr1.glb(false).makeRO(), ptr1.dual().glb(false)); Assert.assertEquals(TypeMemPtr.makeNullable(TypeStruct.BOT), ptr1.meet(ptr2nil)); - Assert.assertEquals(ptr1.glb(), ptr1.meet(TypeNil.NIL).makeRO()); + Assert.assertEquals(ptr1.glb(false), ptr1.meet(TypeNil.NIL).makeRO()); TypeMemPtr TOP = TypeMemPtr.TOP; TypeMemPtr BOT = TypeMemPtr.makeNullable(TypeStruct.BOT); diff --git a/chapter22/src/test/java/com/seaofnodes/simple/fuzzer/ScriptGenerator.java b/chapter22/src/test/java/com/seaofnodes/simple/fuzzer/ScriptGenerator.java index c9f7d801..4f86d0be 100644 --- a/chapter22/src/test/java/com/seaofnodes/simple/fuzzer/ScriptGenerator.java +++ b/chapter22/src/test/java/com/seaofnodes/simple/fuzzer/ScriptGenerator.java @@ -97,7 +97,7 @@ public class ScriptGenerator { private static final List INTTYPES = new ArrayList<>(); static { - for( var e : Parser.PRIMS.entrySet() ) { + for( var e : Parser.TYPES.entrySet() ) { if( e.getValue() instanceof TypeInteger ) { INTTYPES.add(new TypeInt(e.getKey())); } -- cgit v1.2.3