2
0
Эх сурвалжийг харах

Patched fingerprinting issues

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@7030 8c9fc860-2736-0410-a75d-ab315db34111
felixf 8 жил өмнө
parent
commit
1f5cb8d25b

+ 2 - 2
source/Fox.Tool

@@ -13,13 +13,13 @@ Compiler.Compile --noInterfaceCheck
 
 	BitSets.Mod ObjectFile.Mod GenericLinker.Mod StaticLinker.Mod
 	FoxBasic.Mod  FoxProgTools.Mod  FoxScanner.Mod FoxCSharpScanner.Mod FoxSyntaxTree.Mod FoxGlobal.Mod
-	FoxFormats.Mod FoxPrintout.Mod
+	FoxFormats.Mod 	FoxFingerPrinter.Mod FoxPrintout.Mod
 	FoxParser.Mod FoxCSharpParser.Mod  FoxSemanticChecker.Mod
 	FoxBackend.Mod FoxSections.Mod 
 	FoxFrontend.Mod 
 	FoxCompiler.Mod 
 	FoxOberonFrontend.Mod FoxCSharpFrontend.Mod
-	FoxFingerPrinter.Mod  FoxInterfaceComparison.Mod FoxTextualSymbolFile.Mod FoxBinarySymbolFile.Mod
+  	FoxInterfaceComparison.Mod FoxTextualSymbolFile.Mod FoxBinarySymbolFile.Mod
 	FoxBinaryCode.Mod FoxIntermediateCode.Mod FoxIntermediateBackend.Mod FoxCodeGenerators.Mod
 	FoxBinaryObjectFile.Mod FoxGenericObjectFile.Mod
 	FoxAMD64InstructionSet.Mod FoxAMD64Assembler.Mod FoxAMDBackend.Mod

+ 1 - 1
source/FoxBinaryObjectFile.Mod

@@ -2242,7 +2242,7 @@ TYPE
 
 		IF Trace THEN module.Dump(D.Log);D.Ln; D.Update; END;
 
-		NEW(fingerprinter,module.system);
+		NEW(fingerprinter);
 		(* module.module.name,moduleName);*)
 		Global.ModuleFileName(module.module.name,module.module.context,moduleName);
 		NEW(crc32);

+ 20 - 17
source/FoxFingerPrinter.Mod

@@ -133,14 +133,13 @@ TYPE
 	VAR
 		fp-: LONGINT; (* temporary fingerprint for values etc. *)
 		fingerprint: FingerPrint;
-		system-: Global.System;
 		deep: BOOLEAN; (* public / private field of FP needed ? *)
 		traceLevel: LONGINT;
 
 		level: LONGINT;
 
-		PROCEDURE & InitFingerPrinter*(system: Global.System);
-		BEGIN fp:= 0; SELF.system := system; deep := FALSE; traceLevel := 0;
+		PROCEDURE & InitFingerPrinter*();
+		BEGIN fp:= 0; deep := FALSE; traceLevel := 0;
 		END InitFingerPrinter;
 		(** types *)
 
@@ -449,23 +448,27 @@ TYPE
 					D.Str("TypeName  ");
 					D.Str0(x.scope.ownerModule.name);
 				END;
-				FPName(fp,x.scope.ownerModule.name);
 				typeDeclaration := x.typeDeclaration;
-				IF (typeDeclaration # NIL) & (typeDeclaration.declaredType.resolved # x) THEN
-					(* in record type: pointer to type declaration of a pointer *)
-					typeDeclaration := NIL
-				END;
-				IF (typeDeclaration # NIL) & (typeDeclaration.scope # NIL)THEN
-					FPName(fp,typeDeclaration.name);
-					IF Trace THEN
-						D.Str(".");
-						D.Str0(typeDeclaration.name);
+				IF(typeDeclaration # NIL) & (typeDeclaration.access * SyntaxTree.Public # {}) THEN 
+					FPName(fp,x.scope.ownerModule.name);
+					IF (typeDeclaration.declaredType.resolved # x) THEN
+						(* in record type: pointer to type declaration of a pointer *)
+						typeDeclaration := NIL
+					END;
+					IF (typeDeclaration # NIL) & (typeDeclaration.scope # NIL)THEN
+						FPName(fp,typeDeclaration.name);
+						IF Trace THEN
+							D.Str(".");
+							D.Str0(typeDeclaration.name);
+						END;
+					ELSIF (typeDeclaration # NIL) & (typeDeclaration.scope = NIL) THEN
+						D.Str("typedeclaration without scope: "); D.Str0(x.typeDeclaration.name); D.Int(x.typeDeclaration.position.start,5); D.Ln;
+						D.Update;
+					ELSE
+						FPNumber(fp,0);
 					END;
-				ELSIF (typeDeclaration # NIL) & (typeDeclaration.scope = NIL) THEN
-					D.Str("typedeclaration without scope: "); D.Str0(x.typeDeclaration.name); D.Int(x.typeDeclaration.position.start,5); D.Ln;
-					D.Update;
 				ELSE
-					FPNumber(fp,0);
+					FPNumber(fp, 0);
 				END;
 				IF Trace THEN
 					D.Str(", fp = "); D.Hex(fp,-8); D.Ln;

+ 1 - 1
source/FoxGenericObjectFile.Mod

@@ -313,7 +313,7 @@ TYPE ObjectFileFormat* = OBJECT (Formats.ObjectFileFormat)
 				RETURN FALSE;
 			END;
 
-			NEW (fingerPrinter, module.system);
+			NEW (fingerPrinter);
 			Files.OpenWriter (writer, file, 0);
 			IF ExportModule (module(Sections.Module)) THEN
 				writer.Update;

+ 4 - 1
source/FoxGlobal.Mod

@@ -38,6 +38,8 @@ CONST
 	StringRealtime* = "REALTIME";
 	StringDynamic* = "DYNAMIC";
 	
+	StringFingerprint*="FingerPrint";
+	
 	StringInstructionWidth*="InstructionWidth";
 	StringDataMemorySize*= "DataMemorySize";
 	StringCodeMemorySize*= "CodeMemorySize";
@@ -188,7 +190,7 @@ VAR
 	SelfParameterName-,ReturnParameterName-,SystemName-,systemName-,PointerReturnName-, ResultName-,
 	A2Name-,OberonName-,ArrayBaseName-,RecordBodyName-,ModuleBodyName-,
 	NameWinAPI-,NameC-,NameMovable-,NameUntraced-,NameDelegate-,NameInterrupt-, NamePcOffset-, NameNoPAF-,NameEntry-, NameExit-, NameFixed-,NameFictive-, NameAligned-,NameStackAligned-,
-	NameExclusive-,NameActive-,NamePriority-,NameSafe-,NameRealtime-, NameDynamic-, NameDataMemorySize-, NameCodeMemorySize-
+	NameExclusive-,NameActive-,NamePriority-,NameSafe-,NameRealtime-, NameDynamic-, NameFingerprint-, NameDataMemorySize-, NameCodeMemorySize-
 	, NameChannelWidth-, NameChannelDepth-, NameChannelModule-, NameVector-, NameFloatingPoint-, NameNoMul-,NameNonBlockingIO-, NameTRM-, NameTRMS-, NameEngine-, NameFinal-, NameAbstract-,
 	NameBackend-, NameRuntime-, NameFrequencyDivider-, NameRegister-,NameNoReturn-,NamePlain-,NameUnsafe-,NameDisposable-,NameUnchecked-,NameUncooperative-: SyntaxTree.Identifier;
 
@@ -1718,6 +1720,7 @@ TYPE
 		NameDisposable := SyntaxTree.NewIdentifier(StringDisposable);
 		NameUnchecked := SyntaxTree.NewIdentifier(StringUnchecked);
 		NameUncooperative := SyntaxTree.NewIdentifier(StringUncooperative);
+		NameFingerprint := SyntaxTree.NewIdentifier(StringFingerprint);
 
 		(* types *)
 		Boolean8 := SyntaxTree.NewBooleanType(8);

+ 1 - 1
source/FoxInterfaceComparison.Mod

@@ -148,7 +148,7 @@ CONST
 		Global.ModuleFileName(module.name,module.context,fname);
 		importedModule := symbolFileFormat.Import(fname,importCache);
 
-		NEW(fingerprinter,symbolFileFormat.system);
+		NEW(fingerprinter);
 		IF importedModule # NIL THEN
 			CompareScopes(module.moduleScope,importedModule.moduleScope);
 			IF importCache # NIL THEN SemanticChecker.RemoveModuleFromCache(importCache, importedModule) END;

+ 2 - 2
source/FoxIntermediateBackend.Mod

@@ -1356,7 +1356,7 @@ TYPE
 			NEW(registerUsageCount);
 			usedRegisters := NIL;
 			procedureResultDesignator := NIL;
-			NEW(fingerPrinter, system);
+			NEW(fingerPrinter);
 			NEW(temporaries);
 			currentIsInline := FALSE;
 			NeedDescriptor := FALSE;
@@ -11644,7 +11644,7 @@ TYPE
 			END Export;
 			
 		BEGIN
-			NEW(fingerPrinter, module.system);
+			NEW(fingerPrinter);
 			NEW(poolMap, 64);
 			(* this is the name pool private to the export table -- it is sorted and should not be mixed / used for other names in a module *)
 			namePool := Block("Heaps","SystemBlockDesc",".@NamePool",namePoolOffset); 

+ 1 - 1
source/FoxMinosObjectFile.Mod

@@ -547,7 +547,7 @@ TYPE
 	BEGIN
 		error := FALSE;
 		moduleScope := module.module.moduleScope;
-		NEW(fingerprinter,module.system);
+		NEW(fingerprinter);
 		MakeSectionOffsets(module,dataSize,codeSize,bodyOffset,code); (* --> all sections are now assembled as one piece in code *)
 		ObjectFile(bodyOffset);
 		w.Update;

+ 14 - 2
source/FoxPrintout.Mod

@@ -2,7 +2,7 @@ MODULE FoxPrintout; (** AUTHOR "fof & fn"; PURPOSE "Oberon Compiler Module Outpu
 (* (c) fof ETHZ 2009 *)
 
 IMPORT
-	Scanner := FoxScanner, SyntaxTree := FoxSyntaxTree, Global := FoxGlobal, Basic := FoxBasic, Streams, D:=Debugging, SYSTEM;
+	Scanner := FoxScanner, SyntaxTree := FoxSyntaxTree, Global := FoxGlobal, Basic := FoxBasic, FingerPrinter := FoxFingerPrinter, Streams, D:=Debugging, SYSTEM;
 
 CONST
 	(* print modes *)
@@ -18,6 +18,7 @@ TYPE
 		useCase: BOOLEAN; (* TRUE to enable case conversion in "Identifier" *)
 
 		alertCount, commentCount: LONGINT;
+		fingerPrinter:FingerPrinter.FingerPrinter;
 
 		PROCEDURE Small(CONST name: ARRAY OF CHAR; VAR result: ARRAY OF CHAR);
 		VAR ch: CHAR; i: LONGINT;
@@ -1193,7 +1194,7 @@ TYPE
 		END Access;
 
 		PROCEDURE VisitProcedure(x: SyntaxTree.Procedure);
-		VAR type: SyntaxTree.ProcedureType;  first: BOOLEAN;
+		VAR type: SyntaxTree.ProcedureType;  first: BOOLEAN; fp: SyntaxTree.FingerPrint;
 		BEGIN
 			IF Visible(x) THEN
 				Indent;
@@ -1218,6 +1219,17 @@ TYPE
 				IF (x.fixed) THEN Value(Global.NameFixed, x.alignment,first)
 				ELSIF (x.alignment >1) THEN Value(Global.NameAligned, x.alignment, first)
 				END;
+				IF type.callingConvention = SyntaxTree.WinAPICallingConvention THEN
+					Flag(Global.NameWinAPI,first)
+				ELSIF type.callingConvention = SyntaxTree.CCallingConvention THEN
+					Flag(Global.NameC,first)
+				END;
+
+				IF x.isInline & (mode = SymbolFile) THEN
+					IF fingerPrinter = NIL THEN NEW(fingerPrinter) END;
+					fp := fingerPrinter.SymbolFP(x);
+					Value(Global.NameFingerprint, fp.shallow, first) 
+				END;
 				FlagEnd(first);
 
 				IF x.isInline OR x.isOberonInline THEN w.String(" - ") END;

+ 7 - 0
source/FoxSemanticChecker.Mod

@@ -6820,6 +6820,7 @@ TYPE
 			value: LONGINT;
 			modifiers: SyntaxTree.Modifier; recentIsRealtime, recentIsBodyProcedure: BOOLEAN;
 			position: Position;
+			fp: SyntaxTree.FingerPrint;
 		BEGIN
 			IF Trace THEN D.Str("VisitProcedure "); D.Str0(procedure.name);  D.Ln;  END;
 			IF IsOberonInline(procedure) THEN
@@ -6872,6 +6873,12 @@ TYPE
 				IF HasFlag(modifiers,Global.NameFinal,position) THEN procedure.SetFinal(TRUE)
 				ELSIF HasFlag(modifiers,Global.NameAbstract,position) THEN procedure.SetAbstract(TRUE)
 				END;
+				IF HasValue(modifiers, Global.NameFingerprint, position, value) THEN 
+					SyntaxTree.InitFingerPrint(fp);
+					fp.shallow := value;
+					fp.shallowAvailable := TRUE;
+					procedure.SetFingerPrint(fp);
+				END;
 
 				CheckModifiers(modifiers, TRUE);
 				

+ 2 - 2
source/Release.Tool

@@ -668,11 +668,11 @@ PACKAGE Compiler ARCHIVE "Compiler.zip" SOURCE "CompilerSrc.zip" DESCRIPTION "Ac
 	Fox.Tool	
 	BitSets.Mod ObjectFile.Mod GenericLinker.Mod StaticLinker.Mod
 	FoxBasic.Mod  FoxProgTools.Mod  FoxScanner.Mod FoxCSharpScanner.Mod FoxSyntaxTree.Mod FoxGlobal.Mod
-	FoxActiveCells.Mod FoxHardware.Mod FoxFormats.Mod FoxPrintout.Mod
+	FoxActiveCells.Mod FoxHardware.Mod FoxFormats.Mod FoxFingerPrinter.Mod  FoxPrintout.Mod
 	FoxParser.Mod FoxCSharpParser.Mod  FoxSemanticChecker.Mod
 	FoxBackend.Mod FoxSections.Mod FoxFrontend.Mod
 	FoxCompiler.Mod  FoxOberonFrontend.Mod FoxCSharpFrontend.Mod
-	FoxFingerPrinter.Mod  FoxInterfaceComparison.Mod FoxTextualSymbolFile.Mod FoxBinarySymbolFile.Mod
+	FoxInterfaceComparison.Mod FoxTextualSymbolFile.Mod FoxBinarySymbolFile.Mod
 	FoxBinaryCode.Mod FoxIntermediateCode.Mod FoxIntermediateBackend.Mod FoxCodeGenerators.Mod
 	FoxBinaryObjectFile.Mod FoxGenericObjectFile.Mod
 	FoxAMD64InstructionSet.Mod FoxAMD64Assembler.Mod FoxAMDBackend.Mod