Explorar o código

Patched a bug with recursive imports in Runtime.

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@6497 8c9fc860-2736-0410-a75d-ab315db34111
felixf %!s(int64=9) %!d(string=hai) anos
pai
achega
9fdbb7c67b
Modificáronse 2 ficheiros con 30 adicións e 30 borrados
  1. 29 29
      source/FoxGenericObjectFile.Mod
  2. 1 1
      source/FoxIntermediateBackend.Mod

+ 29 - 29
source/FoxGenericObjectFile.Mod

@@ -586,37 +586,37 @@ TYPE ObjectFileFormat* = OBJECT (Formats.ObjectFileFormat)
 	BEGIN
 	BEGIN
 		NEW(sectionList);
 		NEW(sectionList);
 		IF context.arg.GetString(dest) THEN
 		IF context.arg.GetString(dest) THEN
-		(*writer := Basic.GetWriter(Basic.GetDebugWriter(fileName));*)
-		WHILE context.arg.GetString(fileName) DO
-			file := Files.Old(fileName);
-			IF file # NIL THEN
-				NEW(reader,file,0);
-				ReadHeader(reader, binary, poolMap);
-				WHILE reader.Peek () # 0X DO
-					ObjectFile.InitSection(section);
-					ObjectFile.ReadSection (reader, section, binary, poolMap);
-					NEW(bs, SHORTINT(section.type) ,section.priority,section.unit,name, FALSE, FALSE);
-					bs.os := section;
-					NEW(is, SHORTINT(bs.os.type), SHORTINT(bs.os.priority), bs.os.identifier.name,NIL, FALSE);
-					is.SetResolved(bs);
-					sectionList.AddSection(is);
-					
-					
-					reader.SkipWhitespace;
+			(*writer := Basic.GetWriter(Basic.GetDebugWriter(fileName));*)
+			WHILE context.arg.GetString(fileName) DO
+				file := Files.Old(fileName);
+				IF file # NIL THEN
+					NEW(reader,file,0);
+					ReadHeader(reader, binary, poolMap);
+					WHILE reader.Peek () # 0X DO
+						ObjectFile.InitSection(section);
+						ObjectFile.ReadSection (reader, section, binary, poolMap);
+						NEW(bs, SHORTINT(section.type) ,section.priority,section.unit,name, FALSE, FALSE);
+						bs.os := section;
+						NEW(is, SHORTINT(bs.os.type), SHORTINT(bs.os.priority), bs.os.identifier.name,NIL, FALSE);
+						is.SetResolved(bs);
+						sectionList.AddSection(is);		
+						reader.SkipWhitespace;
+					END;
+				ELSE
+					context.error.String("file not found "); context.error.String(fileName); context.error.Ln; 
+					RETURN;
 				END;
 				END;
-			ELSE
-				context.error.String("file not found "); context.error.String(fileName); context.error.Ln
 			END;
 			END;
-		END;
-		file := Files.New(dest);
-		Files.OpenWriter(writer, file, 0);
-		WriteHeader(writer, TRUE, sectionList, poolMapDummy, NIL);
-		FOR i := 0 TO sectionList.Length()-1 DO
-			is := sectionList.GetSection(i)(IntermediateCode.Section);
-			ObjectFile.WriteSection(writer, is.resolved.os, TRUE, poolMapDummy); (* binary *)
-		END;
-		writer.Update;
-		Files.Register(file);
+			file := Files.New(dest);
+			Files.OpenWriter(writer, file, 0);
+			WriteHeader(writer, TRUE, sectionList, poolMapDummy, NIL);
+			FOR i := 0 TO sectionList.Length()-1 DO
+				is := sectionList.GetSection(i)(IntermediateCode.Section);
+				ObjectFile.WriteSection(writer, is.resolved.os, TRUE, poolMapDummy); (* binary *)
+			END;
+			writer.Update;
+			Files.Register(file);
+			context.out.String("Created library "); context.out.String(dest); context.out.Ln;
 		END;
 		END;
 	END MakeLibrary;
 	END MakeLibrary;
 	
 	

+ 1 - 1
source/FoxIntermediateBackend.Mod

@@ -2764,7 +2764,7 @@ TYPE
 
 
 
 
 				IF import = NIL THEN
 				IF import = NIL THEN
-					import := SyntaxTree.NewImport(-1,SyntaxTree.NewIdentifier(moduleName),SyntaxTree.NewIdentifier(moduleName),TRUE);
+					import := SyntaxTree.NewImport(-1,SyntaxTree.NewIdentifier(moduleName),SyntaxTree.NewIdentifier(moduleName),FALSE);
 
 
 					import.SetContext(SyntaxTree.NewIdentifier("A2"));
 					import.SetContext(SyntaxTree.NewIdentifier("A2"));
 					IF ~checker.AddImport(moduleScope.ownerModule,import) THEN
 					IF ~checker.AddImport(moduleScope.ownerModule,import) THEN