ogwasm.pas 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. {
  2. Copyright (c) 2021 by Nikolay Nikolov
  3. Contains the WebAssembly binary module format reader and writer
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit ogwasm;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. { common }
  22. globtype,
  23. { target }
  24. systems,
  25. { assembler }
  26. aasmbase,assemble,
  27. { WebAssembly module format definitions }
  28. wasmbase,
  29. { output }
  30. ogbase,
  31. owbase;
  32. type
  33. { TWasmObjData }
  34. TWasmObjData = class(TObjData)
  35. public
  36. function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;override;
  37. procedure writeReloc(Data:TRelocDataInt;len:aword;p:TObjSymbol;Reloctype:TObjRelocationType);override;
  38. end;
  39. { TWasmObjOutput }
  40. TWasmObjOutput = class(tObjOutput)
  41. protected
  42. function writeData(Data:TObjData):boolean;override;
  43. public
  44. constructor create(AWriter:TObjectWriter);override;
  45. end;
  46. { TWasmAssembler }
  47. TWasmAssembler = class(tinternalassembler)
  48. constructor create(info: pasminfo; smart:boolean);override;
  49. end;
  50. implementation
  51. {****************************************************************************
  52. TWasmObjData
  53. ****************************************************************************}
  54. function TWasmObjData.sectionname(atype: TAsmSectiontype;
  55. const aname: string; aorder: TAsmSectionOrder): string;
  56. begin
  57. result:='todosectionname';
  58. end;
  59. procedure TWasmObjData.writeReloc(Data: TRelocDataInt; len: aword;
  60. p: TObjSymbol; Reloctype: TObjRelocationType);
  61. begin
  62. end;
  63. {****************************************************************************
  64. TWasmObjOutput
  65. ****************************************************************************}
  66. function TWasmObjOutput.writeData(Data:TObjData):boolean;
  67. begin
  68. result:=false;
  69. end;
  70. constructor TWasmObjOutput.create(AWriter: TObjectWriter);
  71. begin
  72. inherited;
  73. cobjdata:=TWasmObjData;
  74. end;
  75. {****************************************************************************
  76. TWasmAssembler
  77. ****************************************************************************}
  78. constructor TWasmAssembler.Create(info: pasminfo; smart:boolean);
  79. begin
  80. inherited;
  81. CObjOutput:=TWasmObjOutput;
  82. end;
  83. {*****************************************************************************
  84. Initialize
  85. *****************************************************************************}
  86. {$ifdef wasm32}
  87. const
  88. as_wasm32_wasm_info : tasminfo =
  89. (
  90. id : as_wasm32_wasm;
  91. idtxt : 'OMF';
  92. asmbin : '';
  93. asmcmd : '';
  94. supported_targets : [system_wasm32_embedded,system_wasm32_wasi];
  95. flags : [af_outputbinary,af_smartlink_sections];
  96. labelprefix : '..@';
  97. labelmaxlen : -1;
  98. comment : '; ';
  99. dollarsign: '$';
  100. );
  101. {$endif wasm32}
  102. initialization
  103. {$ifdef wasm32}
  104. RegisterAssembler(as_wasm32_wasm_info,TWasmAssembler);
  105. {$endif wasm32}
  106. end.