Browse Source

- removed TWasmObjData.AddFuncType, instead call directly [F]FuncTypes.AddOrGetFuncType

Nikolay Nikolov 1 year ago
parent
commit
0be3fe9ab4
2 changed files with 5 additions and 10 deletions
  1. 3 8
      compiler/ogwasm.pas
  2. 2 2
      compiler/wasm32/aasmcpu.pas

+ 3 - 8
compiler/ogwasm.pas

@@ -124,7 +124,6 @@ interface
         function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;override;
         function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;override;
         procedure writeReloc(Data:TRelocDataInt;len:aword;p:TObjSymbol;Reloctype:TObjRelocationType);override;
         procedure writeReloc(Data:TRelocDataInt;len:aword;p:TObjSymbol;Reloctype:TObjRelocationType);override;
         function AddOrCreateObjSymbolExtraData(const symname:TSymStr): TWasmObjSymbolExtraData;
         function AddOrCreateObjSymbolExtraData(const symname:TSymStr): TWasmObjSymbolExtraData;
-        function AddFuncType(wft: TWasmFuncType): integer;
         function globalref(asmsym:TAsmSymbol):TObjSymbol;
         function globalref(asmsym:TAsmSymbol):TObjSymbol;
         function ExceptionTagRef(asmsym:TAsmSymbol):TObjSymbol;
         function ExceptionTagRef(asmsym:TAsmSymbol):TObjSymbol;
         procedure DeclareGlobalType(gt: tai_globaltype);
         procedure DeclareGlobalType(gt: tai_globaltype);
@@ -135,6 +134,7 @@ interface
         procedure DeclareImportName(ain: tai_import_name);
         procedure DeclareImportName(ain: tai_import_name);
         procedure DeclareLocal(al: tai_local);
         procedure DeclareLocal(al: tai_local);
         procedure symbolpairdefine(akind: TSymbolPairKind;const asym, avalue: string);override;
         procedure symbolpairdefine(akind: TSymbolPairKind;const asym, avalue: string);override;
+        property FuncTypes: TWasmFuncTypeTable read FFuncTypes;
       end;
       end;
 
 
       { TWasmObjOutput }
       { TWasmObjOutput }
@@ -783,11 +783,6 @@ implementation
           result:=TWasmObjSymbolExtraData.Create(FObjSymbolsExtraDataList,symname);
           result:=TWasmObjSymbolExtraData.Create(FObjSymbolsExtraDataList,symname);
       end;
       end;
 
 
-    function TWasmObjData.AddFuncType(wft: TWasmFuncType): integer;
-      begin
-        Result:=FFuncTypes.AddOrGetFuncType(wft);
-      end;
-
     function TWasmObjData.globalref(asmsym: TAsmSymbol): TObjSymbol;
     function TWasmObjData.globalref(asmsym: TAsmSymbol): TObjSymbol;
       begin
       begin
         if assigned(asmsym) then
         if assigned(asmsym) then
@@ -835,7 +830,7 @@ implementation
         ObjSymExtraData: TWasmObjSymbolExtraData;
         ObjSymExtraData: TWasmObjSymbolExtraData;
       begin
       begin
         FLastFuncName:=ft.funcname;
         FLastFuncName:=ft.funcname;
-        i:=AddFuncType(ft.functype);
+        i:=FFuncTypes.AddOrGetFuncType(ft.functype);
         ObjSymExtraData:=AddOrCreateObjSymbolExtraData(ft.funcname);
         ObjSymExtraData:=AddOrCreateObjSymbolExtraData(ft.funcname);
         ObjSymExtraData.TypeIdx:=i;
         ObjSymExtraData.TypeIdx:=i;
       end;
       end;
@@ -848,7 +843,7 @@ implementation
       begin
       begin
         ObjSymExtraData:=AddOrCreateObjSymbolExtraData(tt.tagname);
         ObjSymExtraData:=AddOrCreateObjSymbolExtraData(tt.tagname);
         ft:=TWasmFuncType.Create([],tt.params);
         ft:=TWasmFuncType.Create([],tt.params);
-        i:=AddFuncType(ft);
+        i:=FFuncTypes.AddOrGetFuncType(ft);
         ft.free;
         ft.free;
         ObjSymExtraData.ExceptionTagTypeIdx:=i;
         ObjSymExtraData.ExceptionTagTypeIdx:=i;
       end;
       end;

+ 2 - 2
compiler/wasm32/aasmcpu.pas

@@ -1677,7 +1677,7 @@ uses
                 case typ of
                 case typ of
                   top_functype:
                   top_functype:
                     begin
                     begin
-                      TWasmObjData(objdata).AddFuncType(functype);
+                      TWasmObjData(objdata).FuncTypes.AddOrGetFuncType(functype);
                       result:=6+
                       result:=6+
                         UlebSize(0);
                         UlebSize(0);
                     end;
                     end;
@@ -2658,7 +2658,7 @@ uses
                   top_functype:
                   top_functype:
                     begin
                     begin
                       WriteByte($11);
                       WriteByte($11);
-                      objdata.writeReloc(TWasmObjData(objdata).AddFuncType(functype),5,nil,RELOC_TYPE_INDEX_LEB);
+                      objdata.writeReloc(TWasmObjData(objdata).FuncTypes.AddOrGetFuncType(functype),5,nil,RELOC_TYPE_INDEX_LEB);
                       WriteUleb(0);
                       WriteUleb(0);
                     end;
                     end;
                   else
                   else