Sfoglia il codice sorgente

Handle NIL entries in deflist after commit 48986

git-svn-id: trunk@49230 -
pierre 4 anni fa
parent
commit
e6045673ee
4 ha cambiato i file con 36 aggiunte e 22 eliminazioni
  1. 3 0
      compiler/pgenutil.pas
  2. 3 0
      compiler/pmodules.pas
  3. 25 20
      compiler/wasm32/agllvmmc.pas
  4. 5 2
      compiler/wasm32/agwat.pas

+ 3 - 0
compiler/pgenutil.pas

@@ -813,6 +813,9 @@ uses
             st : TSymtable;
             i : longint;
           begin
+            { since commit 48986 deflist might have NIL entries }
+            if not assigned(def) then
+              exit;
             case def.typ of
               procdef:
                 tprocdef(def).forwarddef:=false;

+ 3 - 0
compiler/pmodules.pas

@@ -618,6 +618,9 @@ implementation
         for i:=current_module.localsymtable.deflist.count-1 downto 0 do
           begin
             def:=tdef(current_module.localsymtable.deflist[i]);
+            { since commit 48986 deflist might have NIL entries }
+            if not assigned(def) then
+              continue;
             { this also frees def, as the defs are owned by the symtable }
             if not def.is_registered and
                not(df_not_registered_no_free in def.defoptions) then

+ 25 - 20
compiler/wasm32/agllvmmc.pas

@@ -70,31 +70,36 @@ implementation
   procedure TLLVMMachineCodePlaygroundAssembler.WriteImports;
     var
       i    : integer;
+      def  : tdef;
       proc : tprocdef;
       list : TAsmList;
       cur_unit: tused_unit;
     begin
       for i:=0 to current_module.deflist.Count-1 do
-        if assigned(current_module.deflist[i]) and (tdef(current_module.deflist[i]).typ=procdef) then
-          begin
-            proc := tprocdef(current_module.deflist[i]);
-            if (po_external in proc.procoptions) and assigned(proc.import_dll) then
-              begin
-                //WriteProcDef(proc);
-                list:=TAsmList.Create;
-                thlcgwasm(hlcg).g_procdef(list,proc);
-                WriteTree(list);
-                list.free;
-                writer.AsmWrite(#9'.import_module'#9);
-                writer.AsmWrite(proc.mangledname);
-                writer.AsmWrite(', ');
-                writer.AsmWriteLn(proc.import_dll^);
-                writer.AsmWrite(#9'.import_name'#9);
-                writer.AsmWrite(proc.mangledname);
-                writer.AsmWrite(', ');
-                writer.AsmWriteLn(proc.import_name^);
-              end;
-          end;
+        begin
+          def:=tdef(current_module.deflist[i]);
+          { since commit 48986 deflist might have NIL entries }
+          if assigned(def) and (def.typ=procdef) then
+            begin
+              proc := tprocdef(def);
+              if (po_external in proc.procoptions) and assigned(proc.import_dll) then
+                begin
+                  //WriteProcDef(proc);
+                  list:=TAsmList.Create;
+                  thlcgwasm(hlcg).g_procdef(list,proc);
+                  WriteTree(list);
+                  list.free;
+                  writer.AsmWrite(#9'.import_module'#9);
+                  writer.AsmWrite(proc.mangledname);
+                  writer.AsmWrite(', ');
+                  writer.AsmWriteLn(proc.import_dll^);
+                  writer.AsmWrite(#9'.import_name'#9);
+                  writer.AsmWrite(proc.mangledname);
+                  writer.AsmWrite(', ');
+                  writer.AsmWriteLn(proc.import_name^);
+                end;
+            end;
+         end;
       list:=TAsmList.Create;
       cur_unit:=tused_unit(usedunits.First);
       while assigned(cur_unit) do

+ 5 - 2
compiler/wasm32/agwat.pas

@@ -957,14 +957,17 @@ implementation
     procedure TWabtTextAssembler.WriteImports;
       var
         i    : integer;
+        def  : tdef;
         proc : tprocdef;
         sym  : tsym;
         j    : integer;
         psym : tprocsym;
       begin
         for i:=0 to current_module.deflist.Count-1 do begin
-          if tdef(current_module.deflist[i]).typ = procdef then begin
-            proc := tprocdef(current_module.deflist[i]);
+          def:=tdef(current_module.deflist[i]);
+          { since commit 48986 deflist might have NIL entries }
+          if assigned(def) and (def.typ=procdef) then begin
+            proc := tprocdef(def);
             if (po_external in proc.procoptions) and assigned(proc.import_dll) then begin
               writer.AsmWrite(#9'(import "');
               writer.AsmWrite(proc.import_dll^);