Ver código fonte

Prepared Heaps.NewArray for POINTER TO ARRAY OF ARRAY X OF RecPtr

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@7195 8c9fc860-2736-0410-a75d-ab315db34111
felixf 8 anos atrás
pai
commit
57fbeae15d
1 arquivos alterados com 6 adições e 5 exclusões
  1. 6 5
      source/Heaps.Mod

+ 6 - 5
source/Heaps.Mod

@@ -1298,7 +1298,7 @@ END NewProtRec;
 
 
 (** NewArr - Implementation of NEW with an array containing pointers. *)
-PROCEDURE NewArr*(VAR p: ANY; elemTag: ADDRESS; numElems, numDims: SIZE; isRealtime: BOOLEAN);
+PROCEDURE NewArr*(VAR p: ANY; elemTag: ADDRESS;  numElems, numDims: SIZE; isRealtime: BOOLEAN);
 VAR arrayBlockAdr, dataBlockAdr: ADDRESS; 
 	elemSize, arrSize, blockSize, arrayBlockSize, fillSize, size, arrayDataOffset: SIZE;
 	firstElem: ADDRESS; 
@@ -1377,7 +1377,7 @@ UnsafeArrayDesc = RECORD (ArrayDataBlockDesc)
 END;
 
 (* replacement for overcomplicated code emission -- at the cost of a slightly increased runtime cost *)
-PROCEDURE NewArray*(CONST a: ARRAY OF SIZE;  elementSize: SIZE; tag: ADDRESS; VAR dest: ANY);
+PROCEDURE NewArray*(CONST a: ARRAY OF SIZE;  tag: ADDRESS; staticElements, elementSize: SIZE; VAR dest: ANY);
 VAR p: ANY; dim: SIZE;
 		
 		PROCEDURE GetSize(): SIZE;
@@ -1387,18 +1387,19 @@ VAR p: ANY; dim: SIZE;
 			FOR i := 0 TO dim-1 DO
 				size := size * a[i];
 			END;
-			RETURN size;
+			RETURN size*staticElements;
 		END GetSize;
 		
 		PROCEDURE SetSizes(dest: UnsafeArray);
 		VAR i: SIZE;
 		BEGIN
 			FOR i := 0 TO dim-1 DO
-				dest.len[i] := a[i];
+				dest.len[i] := a[dim-1-i];
 			END;
 		END SetSizes;
 
 	BEGIN
+		(* static elements is requred for this case : POINTER TO ARRAY OF ARRAY X OF RecordWithPointer *)
 		dim := LEN( a,0 );
 		IF tag = NIL THEN
 			NewSys(p, GetSize() * elementSize + dim * SIZEOF(ADDRESS) + 3 *SIZEOF(ADDRESS) + (dim DIV 2) * 2 * SIZEOF(ADDRESS), FALSE);
@@ -1620,7 +1621,7 @@ TraceHeap:
 *)
 
 Compiler.Compile -p=Win32G --traceModule=Trace  Heaps.Mod ~
-StaticLinker.Link --fileFormat=PE32 --fileName=A2P.exe --extension=GofW --displacement=401000H Runtime Trace Kernel32 Machine Heaps Modules Objects Kernel KernelLog Streams Commands FIles WinFS Clock Dates Reals Strings Diagnostics BitSets StringPool ObjectFile GenericLinker Reflection  GenericLoader  BootConsole ~
+StaticLinker.Link --fileFormat=PE32 --fileName=A2.exe --extension=GofW --displacement=401000H Runtime Trace Kernel32 Machine Heaps Modules Objects Kernel KernelLog Streams Commands FIles WinFS Clock Dates Reals Strings Diagnostics BitSets StringPool ObjectFile GenericLinker Reflection  GenericLoader  BootConsole ~
 FSTools.CloseFiles A2M.exe ~