Forráskód Böngészése

Improved return type of BitSet.GetBits

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@8524 8c9fc860-2736-0410-a75d-ab315db34111
negelef 6 éve
szülő
commit
6cafa4b647

+ 2 - 2
source/BitSets.Mod

@@ -83,8 +83,8 @@ TYPE BitSet* = OBJECT
 		SYSTEM.MOVE(ADDRESS OF values[0], adr, bytes);
 	END SetBytes;
 
-	PROCEDURE GetBits* (startPos: SIZE; bits: LONGINT): LONGINT;
-	VAR value: LONGINT; adr: ADDRESS;
+	PROCEDURE GetBits* (startPos: SIZE; bits: LONGINT): WORD;
+	VAR value: WORD; adr: ADDRESS;
 	BEGIN
 		ASSERT (startPos >= 0); ASSERT (startPos+bits <= size);
 		IF (bits = 8) & (startPos MOD 8 =0) THEN

+ 1 - 1
source/FoxARMInstructionSet.Mod

@@ -2866,7 +2866,7 @@ CONST
 		Disasm = OBJECT (Disassembler.Disassembler)
 
 			PROCEDURE DisassembleInstruction(bitSet: BitSets.BitSet; VAR adr: LONGINT; maxInstructionSize: LONGINT; w:Streams.Writer);
-			VAR instruction: Instruction; value: LONGINT; mnemonic: LONGINT;
+			VAR instruction: Instruction; value: WORD; mnemonic: LONGINT;
 			BEGIN
 				(* maxInstructionSize can be ignored here *)
 				value := bitSet.GetBits(adr*8,32);

+ 4 - 4
source/FoxBinaryCode.Mod

@@ -437,7 +437,7 @@ TYPE
 		END GetByte;
 
 		PROCEDURE GetWord*(pc: Unit): LONGINT;
-		VAR c1,c2: LONGINT;
+		VAR c1,c2: WORD;
 		BEGIN
 			c1 := os.bits.GetBits(pc*os.unit,8);
 			c2 := os.bits.GetBits(pc*os.unit+8,8);
@@ -449,7 +449,7 @@ TYPE
 		END GetWord;
 
 		PROCEDURE GetDWord*(pc: Unit): LONGINT;
-		VAR c1,c2,c3,c4: LONGINT;
+		VAR c1,c2,c3,c4: WORD;
 		BEGIN
 			c1 := os.bits.GetBits(pc*os.unit+0*Byte,Byte);
 			c2 := os.bits.GetBits(pc*os.unit+1*Byte,Byte);
@@ -494,7 +494,7 @@ TYPE
 			RETURN ConvertToLongreal(x)
 		END GetLongreal;
 
-		PROCEDURE GetBits*(pc: Unit; size: Bits): LONGINT;
+		PROCEDURE GetBits*(pc: Unit; size: Bits): WORD;
 		BEGIN
 			RETURN os.bits.GetBits(pc*os.unit,size)
 		END GetBits;
@@ -557,7 +557,7 @@ TYPE
 
 
 			PROCEDURE DumpUnit(at: LONGINT);
-			VAR val: LONGINT; a: ARRAY 9 OF CHAR; bits: LONGINT;
+			VAR val: WORD; a: ARRAY 9 OF CHAR; bits: LONGINT;
 			BEGIN
 				val := GetBits(at,os.unit);
 				bits := os.unit;

+ 2 - 2
source/FoxDisassembler.Mod

@@ -77,7 +77,7 @@ TYPE
 		END DisassembleInstruction;
 
 		PROCEDURE DisassembleBlock(from, to: LONGINT);
-		VAR adr, prevadr, max, digit,value: LONGINT; string: ARRAY 256 OF CHAR;
+		VAR adr, prevadr, max, digit: LONGINT; value: WORD; string: ARRAY 256 OF CHAR;
 		BEGIN
 			IF code = NIL THEN RETURN END;
 			adr := from;
@@ -102,7 +102,7 @@ TYPE
 		END DisassembleBlock;
 
 		PROCEDURE DataBlock(from, to: LONGINT);
-		VAR adr,width,max,value: LONGINT;
+		VAR adr,width,max: LONGINT; value: WORD;
 		BEGIN
 			IF data = NIL THEN RETURN END;
 			adr := from;

+ 1 - 1
source/FoxFingerprinter.Mod

@@ -1117,7 +1117,7 @@ TYPE
 		*)
 		PROCEDURE VisitProcedure*(x: SyntaxTree.Procedure);
 		VAR fp: Basic.Fingerprint; access: SET; fingerprint: SyntaxTree.Fingerprint; deep: BOOLEAN; code: SyntaxTree.Code; i: LONGINT;
-			size,value: LONGINT; name: ARRAY 256 OF CHAR;
+			size: LONGINT; value: WORD; name: ARRAY 256 OF CHAR;
 		BEGIN
 			IF x.scope IS SyntaxTree.RecordScope THEN (* method *)
 				FPrintMethod(fp,fp,x,NIL);

+ 1 - 1
source/FoxTRMInstructionSet.Mod

@@ -1071,7 +1071,7 @@ TYPE
 		Disasm = OBJECT (Disassembler.Disassembler)
 
 			PROCEDURE DisassembleInstruction(bitSet: BitSets.BitSet; VAR adr: LONGINT; maxInstructionSize: LONGINT; w:Streams.Writer);
-			VAR instruction: Instruction; value: LONGINT; mnemonic: LONGINT;
+			VAR instruction: Instruction; value: WORD; mnemonic: LONGINT;
 			BEGIN
 				(* maxInstructionSize can be ignored here *)
 				value := bitSet.GetBits(adr*36,decodeInstance.instructionW);    (*bitset treated as series of 36 bit slots, individual words left aligned.*)

+ 2 - 2
source/Linker.Mod

@@ -294,14 +294,14 @@ END WriteUnixBinaryFile;
 
 PROCEDURE WriteTRMFile (arrangement: Arrangement; writer: Files.Writer; bitsPerLine, lines:LONGINT);
 VAR i,j,size,end,nonZeroInLeadingNibble: LONGINT;
-	PROCEDURE GetBits(pos: LONGINT): LONGINT;
+	PROCEDURE GetBits(pos: LONGINT): WORD;
 	BEGIN
 		IF pos >= size THEN RETURN 0
 		ELSIF pos+4 > size THEN RETURN arrangement.bits.GetBits(pos,size-pos)
 		ELSE RETURN arrangement.bits.GetBits(pos,4)
 		END;
 	END GetBits;
-	PROCEDURE GetFirstNibble(pos: LONGINT): LONGINT;
+	PROCEDURE GetFirstNibble(pos: LONGINT): WORD;
 	BEGIN
 		RETURN arrangement.bits.GetBits(pos,nonZeroInLeadingNibble);
 	END GetFirstNibble;

+ 7 - 7
source/ObjectFile.Mod

@@ -352,7 +352,7 @@ VAR
 		dest.bits := NIL;
 	END InitSection;
 
-	PROCEDURE NibbleToCharacter* (value: LONGINT): CHAR;
+	PROCEDURE NibbleToCharacter* (value: WORD): CHAR;
 	BEGIN
 		IF value >= 10 THEN
 			RETURN CHR ((ORD ('A') - 10) + value);
@@ -470,14 +470,14 @@ VAR
 		END GetSegment;
 
 		PROCEDURE WriteSegment(offset,len: LONGINT); (* offset in bits *)
-		VAR bits: LONGINT;
+		VAR value: WORD;
 		BEGIN
 			ASSERT(len MOD 4 = 0); ASSERT(offset MOD 4 = 0);
 			len := len DIV 4;
 			writer.Int(len,1); writer.Char(Separator); writer.Int(offset DIV 4,1); writer.Char(Separator);
 			WHILE len > 0 DO
-				bits := section.bits.GetBits(offset, MIN(4, size-offset));
-				writer.Char(NibbleToCharacter(bits));
+				value := section.bits.GetBits(offset, MIN(4, size-offset));
+				writer.Char(NibbleToCharacter(value));
 				INC(offset, 4);
 				DEC(len);
 			END;
@@ -820,7 +820,7 @@ VAR
 		END GetSegment;
 
 		PROCEDURE WriteSegment(offset,len: LONGINT); (* offset in bits *)
-		VAR bits: LONGINT; pos: LONGINT;
+		VAR value: WORD; pos: LONGINT;
 		BEGIN
 			pos := writer.Pos();
 			ASSERT(len > 0);
@@ -828,10 +828,10 @@ VAR
 			len := len DIV ByteSize;
 			writer.RawNum(len); writer.RawNum(offset DIV ByteSize);
 			WHILE len > 0 DO
-				bits := section.bits.GetBits(offset, MIN(ByteSize, size-offset));
+				value := section.bits.GetBits(offset, MIN(ByteSize, size-offset));
 				INC(offset, ByteSize);
 				DEC(len);
-				writer.Char(CHR(bits));
+				writer.Char(CHR(value));
 			END;
 			INC(statSegments); INC(statSegmentsSize, writer.Pos()-pos);
 		END WriteSegment;