ソースを参照

changed the ENUM semantics. Common sense seems to be that enums increase subsequently without collision avoidance.

Example: 

MyEnum = ENUM
a = 10,  b  , c=41,  d = 10,  e
END;


MyEnum.e is now 11 (colliding with b, but the follow-up value of d = 10)

MyExtendedEnum = ENUM(MyEnum)
e
END;

MyExtendedEnum.e still is 42, in order to avoid collisions when inheriting, the max value + 1 is taken.



git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@7602 8c9fc860-2736-0410-a75d-ab315db34111
felixf 7 年 前
コミット
b348f5ed82
1 ファイル変更2 行追加1 行削除
  1. 2 1
      source/FoxSemanticChecker.Mod

+ 2 - 1
source/FoxSemanticChecker.Mod

@@ -426,6 +426,7 @@ TYPE
 			prevScope := currentScope;
 			currentScope := x;
 			e := x.firstConstant;
+			nextHighest := highest;
 			WHILE (e # NIL) DO
 				Register(e,x,FALSE);
 				IF SymbolNeedsResolution(e) THEN
@@ -433,7 +434,7 @@ TYPE
 						value := ConstantExpression(e.value);
 						value := NewConversion(e.position,value,x.ownerEnumeration,NIL);
 					ELSE
-						value := SyntaxTree.NewEnumerationValue(e.position,highest+1);
+						value := SyntaxTree.NewEnumerationValue(e.position,nextHighest+1);
 						value.SetType(x.ownerEnumeration);
 					END;
 					IF (value.resolved # NIL) & (value.resolved IS SyntaxTree.EnumerationValue) THEN