Prechádzať zdrojové kódy

Activated Option "AliasOnlyExported" such that only aliases appear in object files that are required to link or load object files
Procedures that are implicitly required at runtime need to be exported, too.


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

felixf 7 rokov pred
rodič
commit
252996767c

+ 1 - 1
source/FoxGenericObjectFile.Mod

@@ -13,7 +13,7 @@ CONST
 
 
 	(* optimizations *)
 	(* optimizations *)
 	PatchFixups = TRUE; (* patch all fixups that can be processed during object file generation *)
 	PatchFixups = TRUE; (* patch all fixups that can be processed during object file generation *)
-	AliasOnlyExported = FALSE;  (* create an alias only for exported sections *)
+	AliasOnlyExported = TRUE;  (* create an alias only for exported sections *)
 	DetailedStatistics = FALSE;
 	DetailedStatistics = FALSE;
 
 
 VAR
 VAR

+ 1 - 1
source/FoxIntermediateBackend.Mod

@@ -14704,7 +14704,7 @@ TYPE
 
 
 	PROCEDURE IsExported(symbol: SyntaxTree.Symbol): BOOLEAN;
 	PROCEDURE IsExported(symbol: SyntaxTree.Symbol): BOOLEAN;
 	BEGIN
 	BEGIN
-		RETURN (symbol # NIL) & (symbol.access * SyntaxTree.Public # {})
+		RETURN (symbol # NIL) & symbol.NeedsSection();
 	END IsExported;
 	END IsExported;
 
 
 
 

+ 23 - 0
source/FoxSyntaxTree.Mod

@@ -3154,6 +3154,16 @@ TYPE
 		PROCEDURE NeedsTrace* (): BOOLEAN;
 		PROCEDURE NeedsTrace* (): BOOLEAN;
 		BEGIN RETURN FALSE;
 		BEGIN RETURN FALSE;
 		END NeedsTrace;
 		END NeedsTrace;
+		
+		(* If a symbol needs to be vieible in the object file
+			A symbol needs to be visible in an object file when it is require during linking
+			This is the case for exported symbols but also for methods in a method table, for instance.
+		*)
+		PROCEDURE NeedsSection*(): BOOLEAN;
+		BEGIN
+			RETURN access * Public # {};
+		END NeedsSection;
+
 
 
 	END Symbol;
 	END Symbol;
 
 
@@ -3193,6 +3203,12 @@ TYPE
 		VAR position: LONGINT;
 		VAR position: LONGINT;
 		BEGIN position := SELF.position.start; v.VisitTypeDeclaration(SELF)
 		BEGIN position := SELF.position.start; v.VisitTypeDeclaration(SELF)
 		END Accept;
 		END Accept;
+		
+		(* type declarations should be generally included in object files *)
+		PROCEDURE NeedsSection*(): BOOLEAN;
+		BEGIN
+			RETURN TRUE;
+		END NeedsSection;
 
 
 	END TypeDeclaration;
 	END TypeDeclaration;
 
 
@@ -3474,10 +3490,17 @@ TYPE
 		BEGIN SELF.methodNumber := methodNumber
 		BEGIN SELF.methodNumber := methodNumber
 		END SetMethodNumber;
 		END SetMethodNumber;
 
 
+		PROCEDURE NeedsSection(): BOOLEAN;
+		BEGIN
+			RETURN (access * Public # {}) OR (methodNumber >= 0);
+		END NeedsSection;
+
 		PROCEDURE Accept*(v: Visitor);
 		PROCEDURE Accept*(v: Visitor);
 		VAR position: LONGINT;
 		VAR position: LONGINT;
 		BEGIN position := SELF.position.start; v.VisitProcedure(SELF)
 		BEGIN position := SELF.position.start; v.VisitProcedure(SELF)
 		END Accept;
 		END Accept;
+		
+
 
 
 	END Procedure;
 	END Procedure;
 
 

+ 2 - 2
source/Win32.Objects.Mod

@@ -1302,7 +1302,7 @@ END TimerFrequency;
 VAR GetProcedureName*: PROCEDURE (pc: ADDRESS; VAR n: ARRAY OF CHAR; VAR spc: ADDRESS);
 VAR GetProcedureName*: PROCEDURE (pc: ADDRESS; VAR n: ARRAY OF CHAR; VAR spc: ADDRESS);
 
 
 
 
-PROCEDURE LeaveA2;
+PROCEDURE LeaveA2*;
 VAR cur: Process; ebp,n: ADDRESS;
 VAR cur: Process; ebp,n: ADDRESS;
 BEGIN
 BEGIN
 	IF clock = NIL THEN RETURN END;
 	IF clock = NIL THEN RETURN END;
@@ -1315,7 +1315,7 @@ BEGIN
 	END;
 	END;
 END LeaveA2;
 END LeaveA2;
 
 
-PROCEDURE ReenterA2;
+PROCEDURE ReenterA2*;
 VAR cur: Process;
 VAR cur: Process;
 BEGIN
 BEGIN
 	IF clock = NIL THEN RETURN END;
 	IF clock = NIL THEN RETURN END;