Selaa lähdekoodia

+ handle the call instruction in the wasm binary writer

Nikolay Nikolov 3 vuotta sitten
vanhempi
commit
3e2a9b6ceb
2 muutettua tiedostoa jossa 36 lisäystä ja 0 poistoa
  1. 3 0
      compiler/ogbase.pas
  2. 33 0
      compiler/wasm32/aasmcpu.pas

+ 3 - 0
compiler/ogbase.pas

@@ -112,6 +112,9 @@ interface
          RELOC_ABSOLUTE_HI8,
          RELOC_ABSOLUTE_HI8,
          RELOC_ABSOLUTE_LO8,
          RELOC_ABSOLUTE_LO8,
 {$endif z80}
 {$endif z80}
+{$ifdef WASM32}
+         RELOC_FUNCTION_INDEX_LEB,
+{$endif WASM32}
          { Relative relocation }
          { Relative relocation }
          RELOC_RELATIVE,
          RELOC_RELATIVE,
          { PECoff (Windows) RVA relocation }
          { PECoff (Windows) RVA relocation }

+ 33 - 0
compiler/wasm32/aasmcpu.pas

@@ -585,6 +585,22 @@ implementation
                     internalerror(2021092017);
                     internalerror(2021092017);
                 end;
                 end;
             end;
             end;
+          a_call:
+            begin
+              if ops<>1 then
+                internalerror(2021092021);
+              with oper[0]^ do
+                case typ of
+                  top_ref:
+                    begin
+                      if not assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) or (ref^.offset<>0) then
+                        internalerror(2021092023);
+                      result:=6;
+                    end;
+                  else
+                    internalerror(2021092022);
+                end;
+            end;
           else
           else
             Writeln('Warning! Not implemented opcode, pass1: ', opcode);
             Writeln('Warning! Not implemented opcode, pass1: ', opcode);
         end;
         end;
@@ -1037,6 +1053,23 @@ implementation
                     internalerror(2021092017);
                     internalerror(2021092017);
                 end;
                 end;
             end;
             end;
+          a_call:
+            begin
+              if ops<>1 then
+                internalerror(2021092021);
+              with oper[0]^ do
+                case typ of
+                  top_ref:
+                    begin
+                      if not assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) or (ref^.offset<>0) then
+                        internalerror(2021092023);
+                      WriteByte($10);
+                      objdata.writeReloc(0,5,ObjData.symbolref(ref^.symbol),RELOC_FUNCTION_INDEX_LEB);
+                    end;
+                  else
+                    internalerror(2021092022);
+                end;
+            end;
           else
           else
             Writeln('Warning! Not implemented opcode, pass2: ', opcode);
             Writeln('Warning! Not implemented opcode, pass2: ', opcode);
         end;
         end;