Sfoglia il codice sorgente

performance optimisation: do not type guard when
- a constant symbol (const parameter) is encountered or
- a record type is encountered (cannot change its type)



git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@8339 8c9fc860-2736-0410-a75d-ab315db34111

felixf 6 anni fa
parent
commit
a2e60c884d
1 ha cambiato i file con 5 aggiunte e 1 eliminazioni
  1. 5 1
      source/FoxSemanticChecker.Mod

+ 5 - 1
source/FoxSemanticChecker.Mod

@@ -3738,7 +3738,11 @@ TYPE
 
 			IF (left = NIL) OR (left IS SyntaxTree.SelfDesignator) OR (left IS SyntaxTree.DereferenceDesignator) & (left(SyntaxTree.DereferenceDesignator).left IS SyntaxTree.SelfDesignator) THEN
 				IF GetGuard(symbol,guardType) THEN
-					result := NewTypeGuardDesignator(position,result(SyntaxTree.SymbolDesignator),guardType, result);
+					IF (symbol.type.resolved IS SyntaxTree.RecordType) OR ~assignable THEN (* type guard is tested and type cannot be changed *)
+						result.SetType(guardType);
+					ELSE
+						result := NewTypeGuardDesignator(position,result(SyntaxTree.SymbolDesignator),guardType, result);
+					END;
 				END;
 			END;