Ver código fonte

reshape: array of size (i/o array of longint)
]

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

felixf 7 anos atrás
pai
commit
9b7c916ea9
3 arquivos alterados com 8 adições e 3 exclusões
  1. 2 2
      source/FoxArrayBase.Mod
  2. 5 0
      source/FoxGlobal.Mod
  3. 1 1
      source/FoxSemanticChecker.Mod

+ 2 - 2
source/FoxArrayBase.Mod

@@ -10039,7 +10039,7 @@ TYPE
 *)
 
 
-	PROCEDURE DoReshape*( VAR dest: ADDRESS;  src: ADDRESS; CONST shape: ARRAY [ * ] OF LONGINT );
+	PROCEDURE DoReshape*( VAR dest: ADDRESS;  src: ADDRESS; CONST shape: ARRAY [ * ] OF SIZE );
 	VAR i, Size: SIZE;  ptr, data: ANY;  new: ADDRESS;
 
 		oldSize, newSize: SIZE;  oldDim, newDim: SIZE;
@@ -10723,7 +10723,7 @@ TYPE
 		CONST src: ARRAY [?] OF basetype
 		CONST shape: ARRAY [*] OF LONGINT
 	*)
-	PROCEDURE Reshape*(CONST left: ARRAY [?]; CONST right: ARRAY [*] OF LONGINT): ARRAY [?];
+	PROCEDURE Reshape*(CONST left: ARRAY [?]; CONST right: ARRAY [*] OF SIZE): ARRAY [?];
 	BEGIN
 		DoReshape(SYSTEM.VAL(ADDRESS,RESULT), SYSTEM.VAL(ADDRESS,left), right);
 		RETURN RESULT

+ 5 - 0
source/FoxGlobal.Mod

@@ -1617,6 +1617,11 @@ TYPE
 			WHILE toSize >= fromSize DO
 				toSize := toSize DIV 2; INC(distance);
 			END;
+		ELSIF (from IS SyntaxTree.SizeType) & (to IS SyntaxTree.FloatType) THEN
+			distance := 1;
+			WHILE toSize >= fromSize DO
+				toSize := toSize DIV 2; INC(distance);
+			END;
 		ELSIF (from IS SyntaxTree.RangeType) & (to IS SyntaxTree.RangeType) THEN
 			distance := 0;
 		ELSIF (from IS SyntaxTree.BooleanType) & (to IS SyntaxTree.BooleanType) THEN

+ 1 - 1
source/FoxSemanticChecker.Mod

@@ -6120,7 +6120,7 @@ TYPE
 						END;
 
 						parameterType := SyntaxTree.NewMathArrayType(Basic.invalidPosition,currentScope,SyntaxTree.Open);
-						parameterType(SyntaxTree.MathArrayType).SetArrayBase(system.longintType);
+						parameterType(SyntaxTree.MathArrayType).SetArrayBase(system.sizeType);
 						IF ~CompatibleTo(system,type1,parameterType) THEN
 							Error(parameter1.position,"parameter incompatible to math array of longint");
 							result := SyntaxTree.invalidExpression;