Преглед изворни кода

* combined TWasmObjSymbol.ImportIndex and .FuncIndex into just .FuncIndex,
because there's no point in having them separate, and the name ImportIndex
is misleading, as there are multiple import indices (they are separate for
functions, globals, tables, memories, etc.)

Nikolay Nikolov пре 3 година
родитељ
комит
e85aff2b96
1 измењених фајлова са 5 додато и 18 уклоњено
  1. 5 18
      compiler/ogwasm.pas

+ 5 - 18
compiler/ogwasm.pas

@@ -44,14 +44,12 @@ interface
       { TWasmObjSymbol }
       { TWasmObjSymbol }
 
 
       TWasmObjSymbol = class(TObjSymbol)
       TWasmObjSymbol = class(TObjSymbol)
-        ImportIndex: Integer;
         FuncIndex: Integer;
         FuncIndex: Integer;
         SymbolIndex: Integer;
         SymbolIndex: Integer;
         GlobalIndex: Integer;
         GlobalIndex: Integer;
         AliasOf: string;
         AliasOf: string;
         ExtraData: TWasmObjSymbolExtraData;
         ExtraData: TWasmObjSymbolExtraData;
         constructor create(AList:TFPHashObjectList;const AName:string);override;
         constructor create(AList:TFPHashObjectList;const AName:string);override;
-        function ImportOrFuncIndex: Integer;
         function IsAlias: Boolean;
         function IsAlias: Boolean;
       end;
       end;
 
 
@@ -326,7 +324,6 @@ implementation
     constructor TWasmObjSymbol.create(AList: TFPHashObjectList; const AName: string);
     constructor TWasmObjSymbol.create(AList: TFPHashObjectList; const AName: string);
       begin
       begin
         inherited create(AList,AName);
         inherited create(AList,AName);
-        ImportIndex:=-1;
         FuncIndex:=-1;
         FuncIndex:=-1;
         SymbolIndex:=-1;
         SymbolIndex:=-1;
         GlobalIndex:=-1;
         GlobalIndex:=-1;
@@ -334,16 +331,6 @@ implementation
         ExtraData:=nil;
         ExtraData:=nil;
       end;
       end;
 
 
-    function TWasmObjSymbol.ImportOrFuncIndex: Integer;
-      begin
-        if ImportIndex<>-1 then
-          result:=ImportIndex
-        else if FuncIndex<>-1 then
-          result:=FuncIndex
-        else
-          internalerror(2021092601);
-      end;
-
     function TWasmObjSymbol.IsAlias: Boolean;
     function TWasmObjSymbol.IsAlias: Boolean;
       begin
       begin
         result:=AliasOf<>'';
         result:=AliasOf<>'';
@@ -992,7 +979,7 @@ implementation
                       if not assigned(objrel.symbol) then
                       if not assigned(objrel.symbol) then
                         internalerror(2021092509);
                         internalerror(2021092509);
                       objsec.Data.seek(objrel.DataOffset);
                       objsec.Data.seek(objrel.DataOffset);
-                      WriteUleb5(objsec.Data,TWasmObjSymbol(objrel.symbol).ImportOrFuncIndex);
+                      WriteUleb5(objsec.Data,TWasmObjSymbol(objrel.symbol).FuncIndex);
                     end;
                     end;
                   RELOC_MEMORY_ADDR_OR_TABLE_INDEX_SLEB:
                   RELOC_MEMORY_ADDR_OR_TABLE_INDEX_SLEB:
                     begin
                     begin
@@ -1279,7 +1266,7 @@ implementation
             objsym:=TWasmObjSymbol(Data.ObjSymbolList[i]);
             objsym:=TWasmObjSymbol(Data.ObjSymbolList[i]);
             if IsExternalFunction(objsym) then
             if IsExternalFunction(objsym) then
               begin
               begin
-                objsym.ImportIndex:=NextImportFunctionIndex;
+                objsym.FuncIndex:=NextImportFunctionIndex;
                 Inc(NextImportFunctionIndex);
                 Inc(NextImportFunctionIndex);
                 objsym.ExtraData:=TWasmObjSymbolExtraData(FData.FObjSymbolsExtraDataList.Find(objsym.Name));
                 objsym.ExtraData:=TWasmObjSymbolExtraData(FData.FObjSymbolsExtraDataList.Find(objsym.Name));
                 if objsym.ExtraData.ImportModule<>'' then
                 if objsym.ExtraData.ImportModule<>'' then
@@ -1376,7 +1363,7 @@ implementation
                   begin
                   begin
                     WriteName(FWasmSections[wsiExport],TWasmObjSymbolExtraData(FData.FObjSymbolsExtraDataList.Find(objsym.Name)).ExportName);
                     WriteName(FWasmSections[wsiExport],TWasmObjSymbolExtraData(FData.FObjSymbolsExtraDataList.Find(objsym.Name)).ExportName);
                     WriteByte(FWasmSections[wsiExport],0);  { func }
                     WriteByte(FWasmSections[wsiExport],0);  { func }
-                    WriteUleb(FWasmSections[wsiExport],objsym.ImportOrFuncIndex);
+                    WriteUleb(FWasmSections[wsiExport],objsym.FuncIndex);
                   end;
                   end;
               end;
               end;
           end;
           end;
@@ -1406,13 +1393,13 @@ implementation
                 if objsym.ExtraData.ImportModule<>'' then
                 if objsym.ExtraData.ImportModule<>'' then
                   begin
                   begin
                     WriteUleb(FWasmSymbolTable,WASM_SYM_UNDEFINED or WASM_SYM_EXPLICIT_NAME);
                     WriteUleb(FWasmSymbolTable,WASM_SYM_UNDEFINED or WASM_SYM_EXPLICIT_NAME);
-                    WriteUleb(FWasmSymbolTable,objsym.ImportIndex);
+                    WriteUleb(FWasmSymbolTable,objsym.FuncIndex);
                     WriteName(FWasmSymbolTable,objsym.Name);
                     WriteName(FWasmSymbolTable,objsym.Name);
                   end
                   end
                 else
                 else
                   begin
                   begin
                     WriteUleb(FWasmSymbolTable,WASM_SYM_UNDEFINED);
                     WriteUleb(FWasmSymbolTable,WASM_SYM_UNDEFINED);
-                    WriteUleb(FWasmSymbolTable,objsym.ImportIndex);
+                    WriteUleb(FWasmSymbolTable,objsym.FuncIndex);
                   end;
                   end;
               end
               end
             else if objsym.typ=AT_FUNCTION then
             else if objsym.typ=AT_FUNCTION then