Răsfoiți Sursa

Decided to allow for type test / type guard constant folding (with consequences for testing / guarding NIL objects of same type)

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@6859 8c9fc860-2736-0410-a75d-ab315db34111
felixf 9 ani în urmă
părinte
comite
df21889098
2 a modificat fișierele cu 5 adăugiri și 5 ștergeri
  1. 1 1
      source/FoxSemanticChecker.Mod
  2. 4 4
      source/Oberon.Execution.Test

+ 1 - 1
source/FoxSemanticChecker.Mod

@@ -2999,7 +2999,7 @@ TYPE
 					END;
 				ELSIF IsUnsafePointer(left.type) THEN
 					Error(binaryExpression.position,Diagnostics.Invalid,"forbidden type test on unsafe pointer");
-				ELSIF (leftType.SameType(right(SyntaxTree.SymbolDesignator).symbol(SyntaxTree.TypeDeclaration).declaredType.resolved)) & ~(leftType IS SyntaxTree.PointerType) THEN
+				ELSIF (leftType.SameType(right(SyntaxTree.SymbolDesignator).symbol(SyntaxTree.TypeDeclaration).declaredType.resolved)) THEN
 					NewBool(TRUE)
 				ELSIF right(SyntaxTree.SymbolDesignator).symbol(SyntaxTree.TypeDeclaration).declaredType.resolved IS SyntaxTree.AnyType THEN
 					NewBool(TRUE);

+ 4 - 4
source/Oberon.Execution.Test

@@ -2143,7 +2143,7 @@ negative: unsatisfied type guard on pointer to record
 	BEGIN NEW (p0); p1 := p0(P1);
 	END Test.
 
-negative: type guard on nil pointer to same record
+positive: type guard on nil pointer to same record
 
 	MODULE Test;
 	TYPE R = RECORD END; P = POINTER TO R;
@@ -2210,7 +2210,7 @@ negative: unsatisfied type guard on object
 	BEGIN NEW (o0); o1 := o0(O1);
 	END Test.
 
-negative: type guard on same nil object
+positive: type guard on same nil object
 
 	MODULE Test;
 	TYPE O = OBJECT END O;
@@ -2416,7 +2416,7 @@ positive: unsatisfied type test on returned pointer to record
 	BEGIN ASSERT (~(Function () IS P1)); ASSERT (~(Function ()^ IS R1));
 	END Test.
 
-negative: type test on nil pointer to same record
+positive: type test on nil pointer to same record
 
 	MODULE Test;
 	TYPE R = RECORD END; P = POINTER TO R;
@@ -2495,7 +2495,7 @@ positive: unsatisfied type test on returned object
 	BEGIN ASSERT (~(Function () IS O1));
 	END Test.
 
-negative: type test on same nil object
+positive: type test on same nil object
 
 	MODULE Test;
 	TYPE O = OBJECT END O;