Quellcode durchsuchen

pastojs: fixed storing procedurre scope references

git-svn-id: trunk@40493 -
Mattias Gaertner vor 6 Jahren
Ursprung
Commit
8080b53489

+ 7 - 4
packages/fcl-passrc/src/pasuseanalyzer.pas

@@ -390,9 +390,7 @@ begin
   aModule:=El.GetModule;
   if aModule=El then exit;
   if aModule=nil then
-    Result:='NilModule.'+Result
-  else
-    Result:=aModule.Name+'.'+Result;
+    Result:='NilModule.'+Result;
 end;
 
 function dbgs(a: TPAIdentifierAccess): string;
@@ -2335,6 +2333,7 @@ var
   UsedModule, aModule: TPasModule;
   UsesClause: TPasUsesClause;
   Use: TPasUsesUnit;
+  PosEl: TPasElement;
 begin
   {$IFDEF VerbosePasAnalyzer}
   writeln('TPasAnalyzer.EmitSectionHints ',GetElModName(Section));
@@ -2350,8 +2349,12 @@ begin
       UsedModule:=TPasModule(Use.Module);
       if CompareText(UsedModule.Name,'system')=0 then continue;
       if not PAElementExists(UsedModule) then
+        begin
+        PosEl:=Use.Expr;
+        if PosEl=nil then PosEl:=Use;
         EmitMessage(20170311191725,mtHint,nPAUnitNotUsed,sPAUnitNotUsed,
-          [UsedModule.Name,aModule.Name],Use.Expr);
+          [UsedModule.Name,aModule.Name],PosEl);
+        end;
       end;
     end;
 

+ 6 - 3
packages/pastojs/src/pas2jscompiler.pp

@@ -1322,7 +1322,7 @@ begin
       Log.DebugLogWriteLn(PasModule.GetDeclaration(true));
     end;
 
-    if IsUnitReadFromPCU then
+    if Assigned(PCUSupport) and not PCUSupport.HasReader then
       UseAnalyzer.Options:=UseAnalyzer.Options+[paoImplReferences];
 
     {$IFDEF VerboseUnitQueue}
@@ -1476,7 +1476,7 @@ begin
   //writeln('TPas2jsCompilerFile.CreateJS START ',UnitFilename,' JS=',GetObjName(FJSModule));
   try
     // show hints only for units that are actually converted
-    if Not (Assigned(PCUSupport) and Not PCUSupport.HasReader) then
+    if (PCUSupport=nil) or not PCUSupport.HasReader then
       begin
       //writeln('TPas2jsCompilerFile.CreateJS ',UnitFilename);
       UseAnalyzer.EmitModuleHints(PasModule);
@@ -1870,13 +1870,14 @@ function TPas2jsCompiler.MarkNeedBuilding(aFile: TPas2jsCompilerFile;
       begin
         if not aFile.NeedBuild then
           Mark(nUnitNeedsCompileDueToUsedUnit,
-                                   [aFile.GetModuleName,UsedFile.GetModuleName]);
+                                  [aFile.GetModuleName,UsedFile.GetModuleName]);
       end;
     end;
   end;
 
 begin
   Result:=false;
+  //writeln('TPas2jsCompiler.MarkNeedBuilding ',aFile.UnitFilename);
   // check each file only once
   if Checked.FindItem(aFile)<>nil then
     exit(aFile.NeedBuild);
@@ -1892,7 +1893,9 @@ begin
   end;
 
   // check dependencies
+  //writeln('TPas2jsCompiler.MarkNeedBuilding CheckUsesClause ',aFile.UnitFilename,' MainUses');
   CheckUsesClause(aFile.GetPasMainUsesClause);
+  //writeln('TPas2jsCompiler.MarkNeedBuilding CheckUsesClause ',aFile.UnitFilename,' ImplUses');
   CheckUsesClause(aFile.GetPasImplUsesClause);
 
   if (not aFile.NeedBuild) and (not aFile.IsForeign) then

+ 3 - 4
packages/pastojs/tests/tcprecompile.pas

@@ -94,7 +94,6 @@ procedure TCustomTestCLI_Precompile.CheckPrecompile(MainFile,
 var
   JSFilename, OrigSrc, NewSrc, s: String;
   JSFile: TCLIFile;
-  i: Integer;
 begin
   try
     AddDir(UnitOutputDir);
@@ -116,8 +115,8 @@ begin
     JSFile:=FindFile(JSFilename);
     OrigSrc:=JSFile.Source;
     // compile, using .pcu files
-    for i:=0 to FileCount-1 do
-      writeln('AAA1 TCustomTestCLI_Precompile.CheckPrecompile ',i,' ',Files[i].Filename);
+    //for i:=0 to FileCount-1 do
+    //  writeln('AAA1 TCustomTestCLI_Precompile.CheckPrecompile ',i,' ',Files[i].Filename);
 
     {$IFDEF VerbosePCUFiler}
     writeln('TTestCLI_Precompile.CheckPrecompile compile using pcu files==================');
@@ -289,7 +288,7 @@ begin
    'end;']);
   AddUnit('src/unit2.pp',
   ['uses unit1;',
-  'procedure Do2(j: integer);'],
+   'procedure Do2(j: integer);'],
   ['procedure Do2(j: integer);',
    'begin',
    '  unit1.i:=j;',