agwat.pas 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. {
  2. Copyright (c) 1998-2010 by the Free Pascal team
  3. This unit implements the WebAssembly text assembler
  4. The text is in S-expression format and should be consumable
  5. By either Binaryen or Wabt
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. }
  19. unit agwat;
  20. interface
  21. uses
  22. cclasses,systems, cgutils,
  23. globtype,globals,
  24. symconst,symbase,symdef,symsym, symtype,symcpu,
  25. aasmbase,aasmtai,aasmdata,aasmcpu,
  26. assemble
  27. ,cutils
  28. ,cpubase
  29. ,fmodule
  30. ,verbose, itcpuwasm;
  31. type
  32. TWatInstrWriter = class;
  33. {# This is a derived class which is used to write
  34. Binaryen-styled assembler.
  35. }
  36. { TWatAssembler }
  37. { TWabtTextAssembler }
  38. TWabtTextAssembler=class(texternalassembler)
  39. protected
  40. procedure WriteInstruction(hp: tai);
  41. procedure WriteProcDef(pd: tprocdef);
  42. procedure WriteProcParams(pd: tprocdef);
  43. procedure WriteProcResult(pd: tprocdef);
  44. procedure WriteSymtableProcdefs(st: TSymtable);
  45. procedure WriteTempAlloc(p:TAsmList);
  46. procedure WriteExports(p: TAsmList);
  47. public
  48. constructor CreateWithWriter(info: pasminfo; wr: TExternalAssemblerOutputFile; freewriter, smart: boolean); override;
  49. procedure WriteTree(p:TAsmList);override;
  50. procedure WriteAsmList;override;
  51. end;
  52. {# This is the base class for writing instructions.
  53. The WriteInstruction() method must be overridden
  54. to write a single instruction to the assembler
  55. file.
  56. }
  57. { TBinaryenInstrWriter }
  58. { TWatInstrWriter }
  59. TWatInstrWriter = class
  60. constructor create(_owner: TWabtTextAssembler);
  61. procedure WriteInstruction(hp : tai); virtual;
  62. protected
  63. owner: TWabtTextAssembler;
  64. end;
  65. implementation
  66. type
  67. t64bitarray = array[0..7] of byte;
  68. t32bitarray = array[0..3] of byte;
  69. const
  70. line_length = 70;
  71. {****************************************************************************}
  72. { Support routines }
  73. {****************************************************************************}
  74. function fixline(s:string):string;
  75. {
  76. return s with all leading and ending spaces and tabs removed
  77. }
  78. var
  79. i,j,k : integer;
  80. begin
  81. i:=length(s);
  82. while (i>0) and (s[i] in [#9,' ']) do
  83. dec(i);
  84. j:=1;
  85. while (j<i) and (s[j] in [#9,' ']) do
  86. inc(j);
  87. for k:=j to i do
  88. if s[k] in [#0..#31,#127..#255] then
  89. s[k]:='.';
  90. fixline:=Copy(s,j,i-j+1);
  91. end;
  92. function GetWasmName(const st: TSymStr): ansistring;
  93. begin
  94. Result := '$'+st;
  95. Replace(Result, '(','');
  96. Replace(Result, ')','');
  97. end;
  98. function getreferencestring(var ref : treference) : ansistring;
  99. begin
  100. if (ref.arrayreftype<>art_none) or
  101. (ref.index<>NR_NO) then
  102. internalerror(2010122809);
  103. if assigned(ref.symbol) then
  104. begin
  105. // global symbol or field -> full type and name
  106. // ref.base can be <> NR_NO in case an instance field is loaded.
  107. // This register is not part of this instruction, it will have
  108. // been placed on the stack by the previous one.
  109. if (ref.offset<>0) then
  110. internalerror(2010122811);
  111. result:=GetWasmName(ref.symbol.name);
  112. end
  113. else
  114. begin
  115. // local symbol -> stack slot, stored in offset
  116. if ref.base<>NR_STACK_POINTER_REG then
  117. internalerror(2010122810);
  118. result:=tostr(ref.offset);
  119. end;
  120. end;
  121. function constsingle(s: single): ansistring;
  122. begin
  123. result:='0fx'+hexstr(longint(t32bitarray(s)),8);
  124. end;
  125. function constdouble(d: double): ansistring;
  126. begin
  127. // force interpretation as double (since we write it out as an
  128. // integer, we never have to swap the endianess). We have to
  129. // include the sign separately because of the way Java parses
  130. // hex numbers (0x8000000000000000 is not a valid long)
  131. result:=hexstr(abs(int64(t64bitarray(d))),16);
  132. if int64(t64bitarray(d))<0 then
  133. result:='-'+result;
  134. result:='0dx'+result;
  135. end;
  136. function getopstr(const o:toper) : ansistring;
  137. var
  138. d: double;
  139. s: single;
  140. begin
  141. case o.typ of
  142. top_reg:
  143. // should have been translated into a memory location by the
  144. // register allocator)
  145. if (cs_no_regalloc in current_settings.globalswitches) then
  146. getopstr:=std_regname(o.reg)
  147. else
  148. internalerror(2010122803);
  149. top_const:
  150. str(o.val,result);
  151. top_ref:
  152. getopstr:=getreferencestring(o.ref^);
  153. top_single:
  154. begin
  155. result:=constsingle(o.sval);
  156. end;
  157. top_double:
  158. begin
  159. result:=constdouble(o.dval);
  160. end;
  161. {top_string:
  162. begin
  163. result:=constastr(o.pcval,o.pcvallen);
  164. end;
  165. top_wstring:
  166. begin
  167. result:=constwstr(o.pwstrval^.data,getlengthwidestring(o.pwstrval));
  168. end}
  169. else
  170. internalerror(2010122802);
  171. end;
  172. end;
  173. { TWabtTextAssembler }
  174. procedure TWabtTextAssembler.WriteInstruction(hp: tai);
  175. var
  176. cpu : taicpu;
  177. i : integer;
  178. const
  179. ExplicitOffset = [a_i32_load, a_i32_store];
  180. begin
  181. //writer.AsmWriteLn('instr');
  182. //writeln('>',taicpu(hp).opcode);
  183. cpu := taicpu(hp);
  184. writer.AsmWrite(#9);
  185. writer.AsmWrite(wasm_op2str[cpu.opcode] );
  186. if (cpu.opcode = a_if) then
  187. writer.AsmWrite(' (result i32)'); //todo: this is a hardcode, but shouldn't
  188. cpu := taicpu(hp);
  189. if cpu.ops<>0 then
  190. begin
  191. for i:=0 to cpu.ops-1 do
  192. begin
  193. writer.AsmWrite(#9);
  194. if (cpu.oper[i]^.typ = top_ref) and
  195. (cpu.opcode in ExplicitOffset) then begin
  196. writer.AsmWrite('offset=');
  197. writer.AsmWrite(tostr(cpu.oper[i]^.ref^.offset));
  198. writer.AsmWrite(' ;;');
  199. writer.AsmWrite('alignment=');
  200. writer.AsmWrite(tostr(cpu.oper[i]^.ref^.alignment));
  201. end else
  202. writer.AsmWrite(getopstr(cpu.oper[i]^));
  203. end;
  204. end;
  205. writer.AsmLn;
  206. end;
  207. procedure TWabtTextAssembler.WriteProcDef(pd: tprocdef);
  208. var
  209. i : integer;
  210. begin
  211. if not assigned(tcpuprocdef(pd).exprasmlist) and
  212. not(po_abstractmethod in pd.procoptions) and
  213. (not is_javainterface(pd.struct) or
  214. (pd.proctypeoption in [potype_unitinit,potype_unitfinalize])) then
  215. begin
  216. //writeln('mordoy ne vyshel! ',pd.procsym.RealName );
  217. exit;
  218. end;
  219. writer.AsmWrite('(func ');
  220. writer.AsmWrite( GetWasmName( pd.procsym.RealName ));
  221. //writer.AsmWriteln(MethodDefinition(pd));
  222. {if jvmtypeneedssignature(pd) then
  223. begin
  224. writer.AsmWrite('.signature "');
  225. writer.AsmWrite(tcpuprocdef(pd).jvmmangledbasename(true));
  226. writer.AsmWriteln('"');
  227. end;}
  228. writer.AsmLn;
  229. WriteProcParams(tcpuprocdef(pd));
  230. WriteProcResult(tcpuprocdef(pd));
  231. WriteTempAlloc(tcpuprocdef(pd).exprasmlist);
  232. WriteTree(tcpuprocdef(pd).exprasmlist);
  233. writer.AsmWriteln(')');
  234. writer.AsmLn;
  235. end;
  236. procedure TWabtTextAssembler.WriteProcParams(pd: tprocdef);
  237. var
  238. i : integer;
  239. prm : tcpuparavarsym;
  240. begin
  241. if not Assigned(pd) or
  242. not Assigned(pd.paras) or
  243. (pd.paras.Count=0) then
  244. exit;
  245. for i:=0 to pd.paras.Count-1 do
  246. begin
  247. prm := tcpuparavarsym(pd.paras[i]);
  248. writer.AsmWrite(#9'(param'#9);
  249. case prm.getsize of
  250. 1..4: writer.AsmWrite('i32');
  251. 8: writer.AsmWrite('i64');
  252. end;
  253. writer.AsmWrite(')');
  254. writer.AsmLn;
  255. end;
  256. end;
  257. procedure TWabtTextAssembler.WriteProcResult(pd: tprocdef);
  258. begin
  259. if not assigned(pd) or
  260. not Assigned(pd.returndef) or
  261. (pd.returndef.size = 0)
  262. then exit;
  263. writer.AsmWrite(#9'(result'#9);
  264. case pd.returndef.size of
  265. 1..4: writer.AsmWrite('i32');
  266. 8: writer.AsmWrite('i64');
  267. end;
  268. writer.AsmWrite(')');
  269. writer.AsmLn;
  270. end;
  271. procedure TWabtTextAssembler.WriteTree(p: TAsmList);
  272. var
  273. ch : char;
  274. hp : tai;
  275. hp1 : tailineinfo;
  276. s : ansistring;
  277. i,pos : longint;
  278. InlineLevel : longint;
  279. do_line : boolean;
  280. begin
  281. if not assigned(p) then
  282. exit;
  283. InlineLevel:=0;
  284. { lineinfo is only needed for al_procedures (PFV) }
  285. do_line:=(cs_asm_source in current_settings.globalswitches);
  286. hp:=tai(p.first);
  287. while assigned(hp) do
  288. begin
  289. prefetch(pointer(hp.next)^);
  290. if not(hp.typ in SkipLineInfo) then
  291. begin
  292. hp1 := hp as tailineinfo;
  293. current_filepos:=hp1.fileinfo;
  294. { no line info for inlined code }
  295. if do_line and (inlinelevel=0) then
  296. begin
  297. { load infile }
  298. if lastfileinfo.fileindex<>hp1.fileinfo.fileindex then
  299. begin
  300. infile:=current_module.sourcefiles.get_file(hp1.fileinfo.fileindex);
  301. if assigned(infile) then
  302. begin
  303. { open only if needed !! }
  304. if (cs_asm_source in current_settings.globalswitches) then
  305. infile.open;
  306. end;
  307. { avoid unnecessary reopens of the same file !! }
  308. lastfileinfo.fileindex:=hp1.fileinfo.fileindex;
  309. { be sure to change line !! }
  310. lastfileinfo.line:=-1;
  311. end;
  312. { write source }
  313. if (cs_asm_source in current_settings.globalswitches) and
  314. assigned(infile) then
  315. begin
  316. if (infile<>lastinfile) then
  317. begin
  318. writer.AsmWriteLn(asminfo^.comment+'['+infile.name+']');
  319. if assigned(lastinfile) then
  320. lastinfile.close;
  321. end;
  322. if (hp1.fileinfo.line<>lastfileinfo.line) and
  323. ((hp1.fileinfo.line<infile.maxlinebuf) or (InlineLevel>0)) then
  324. begin
  325. if (hp1.fileinfo.line<>0) and
  326. ((infile.linebuf^[hp1.fileinfo.line]>=0) or (InlineLevel>0)) then
  327. writer.AsmWriteLn(asminfo^.comment+'['+tostr(hp1.fileinfo.line)+'] '+
  328. fixline(infile.GetLineStr(hp1.fileinfo.line)));
  329. { set it to a negative value !
  330. to make that is has been read already !! PM }
  331. if (infile.linebuf^[hp1.fileinfo.line]>=0) then
  332. infile.linebuf^[hp1.fileinfo.line]:=-infile.linebuf^[hp1.fileinfo.line]-1;
  333. end;
  334. end;
  335. lastfileinfo:=hp1.fileinfo;
  336. lastinfile:=infile;
  337. end;
  338. end;
  339. case hp.typ of
  340. ait_comment :
  341. Begin
  342. writer.AsmWrite(asminfo^.comment);
  343. writer.AsmWritePChar(tai_comment(hp).str);
  344. writer.AsmLn;
  345. End;
  346. ait_regalloc :
  347. begin
  348. if (cs_asm_regalloc in current_settings.globalswitches) then
  349. begin
  350. writer.AsmWrite(#9+asminfo^.comment+'Register ');
  351. repeat
  352. writer.AsmWrite(std_regname(Tai_regalloc(hp).reg));
  353. if (hp.next=nil) or
  354. (tai(hp.next).typ<>ait_regalloc) or
  355. (tai_regalloc(hp.next).ratype<>tai_regalloc(hp).ratype) then
  356. break;
  357. hp:=tai(hp.next);
  358. writer.AsmWrite(',');
  359. until false;
  360. writer.AsmWrite(' ');
  361. writer.AsmWriteLn(regallocstr[tai_regalloc(hp).ratype]);
  362. end;
  363. end;
  364. ait_tempalloc :
  365. begin
  366. if (cs_asm_tempalloc in current_settings.globalswitches) then
  367. begin
  368. {$ifdef EXTDEBUG}
  369. if assigned(tai_tempalloc(hp).problem) then
  370. writer.AsmWriteLn(asminfo^.comment+'Temp '+tostr(tai_tempalloc(hp).temppos)+','+
  371. tostr(tai_tempalloc(hp).tempsize)+' '+tai_tempalloc(hp).problem^)
  372. else
  373. {$endif EXTDEBUG}
  374. end;
  375. end;
  376. ait_align :
  377. begin
  378. end;
  379. ait_section :
  380. begin
  381. end;
  382. ait_datablock :
  383. begin
  384. // internalerror(2010122701);
  385. end;
  386. ait_const:
  387. begin
  388. writer.AsmWriteln('constant');
  389. // internalerror(2010122702);
  390. end;
  391. ait_realconst :
  392. begin
  393. internalerror(2010122703);
  394. end;
  395. ait_string :
  396. begin
  397. pos:=0;
  398. for i:=1 to tai_string(hp).len do
  399. begin
  400. if pos=0 then
  401. begin
  402. writer.AsmWrite(#9'strconst: '#9'"');
  403. pos:=20;
  404. end;
  405. ch:=tai_string(hp).str[i-1];
  406. case ch of
  407. #0, {This can't be done by range, because a bug in FPC}
  408. #1..#31,
  409. #128..#255 : s:='\'+tostr(ord(ch) shr 6)+tostr((ord(ch) and 63) shr 3)+tostr(ord(ch) and 7);
  410. '"' : s:='\"';
  411. '\' : s:='\\';
  412. else
  413. s:=ch;
  414. end;
  415. writer.AsmWrite(s);
  416. inc(pos,length(s));
  417. if (pos>line_length) or (i=tai_string(hp).len) then
  418. begin
  419. writer.AsmWriteLn('"');
  420. pos:=0;
  421. end;
  422. end;
  423. end;
  424. ait_label :
  425. begin
  426. if (tai_label(hp).labsym.is_used) then
  427. begin
  428. writer.AsmWrite(tai_label(hp).labsym.name);
  429. writer.AsmWriteLn(':');
  430. end;
  431. end;
  432. ait_symbol :
  433. begin
  434. if (tai_symbol(hp).sym.typ = AT_FUNCTION) then
  435. begin
  436. end
  437. else
  438. begin
  439. writer.AsmWrite('data symbol: ');
  440. writer.AsmWriteln(tai_symbol(hp).sym.name);
  441. // internalerror(2010122706);
  442. end;
  443. end;
  444. ait_symbol_end :
  445. begin
  446. end;
  447. ait_instruction :
  448. begin
  449. WriteInstruction(hp);
  450. end;
  451. ait_force_line,
  452. ait_function_name : ;
  453. ait_cutobject :
  454. begin
  455. end;
  456. ait_marker :
  457. if tai_marker(hp).kind=mark_NoLineInfoStart then
  458. inc(InlineLevel)
  459. else if tai_marker(hp).kind=mark_NoLineInfoEnd then
  460. dec(InlineLevel);
  461. ait_directive :
  462. begin
  463. { the CPU directive is probably not supported by the JVM assembler,
  464. so it's commented out }
  465. //todo:
  466. writer.AsmWrite(asminfo^.comment);
  467. if tai_directive(hp).directive=asd_cpu then
  468. writer.AsmWrite(asminfo^.comment);
  469. writer.AsmWrite('.'+directivestr[tai_directive(hp).directive]+' ');
  470. if tai_directive(hp).name<>'' then
  471. writer.AsmWrite(tai_directive(hp).name);
  472. writer.AsmLn;
  473. end;
  474. else
  475. internalerror(2010122707);
  476. end;
  477. hp:=tai(hp.next);
  478. end;
  479. end;
  480. procedure TWabtTextAssembler.WriteAsmList;
  481. var
  482. hal : tasmlisttype;
  483. begin
  484. if current_module.is_unit then begin
  485. writer.AsmWriteLn('(module)');
  486. exit;
  487. end;
  488. writer.MarkEmpty;
  489. writer.AsmWriteLn('(module ');
  490. { print all global variables }
  491. //WriteSymtableVarSyms(current_module.globalsymtable);
  492. //WriteSymtableVarSyms(current_module.localsymtable);
  493. //writer.AsmLn;
  494. { print all global procedures/functions }
  495. WriteSymtableProcdefs(current_module.globalsymtable);
  496. WriteSymtableProcdefs(current_module.localsymtable);
  497. WriteExports(current_asmdata.asmlists[al_exports]);
  498. //WriteSymtableStructDefs(current_module.globalsymtable);
  499. //WriteSymtableStructDefs(current_module.localsymtable);
  500. //writer.decorator.LinePrefix := '';
  501. writer.AsmWriteLn(')');
  502. writer.AsmLn;
  503. end;
  504. constructor TWabtTextAssembler.CreateWithWriter(info: pasminfo;
  505. wr: TExternalAssemblerOutputFile; freewriter, smart: boolean);
  506. begin
  507. inherited CreateWithWriter(info, wr, freewriter, smart);
  508. end;
  509. procedure TWabtTextAssembler.WriteSymtableProcdefs(st: TSymtable);
  510. var
  511. i : longint;
  512. def : tdef;
  513. begin
  514. if not assigned(st) then
  515. exit;
  516. for i:=0 to st.DefList.Count-1 do
  517. begin
  518. def:=tdef(st.DefList[i]);
  519. case def.typ of
  520. procdef :
  521. begin
  522. { methods are also in the static/globalsymtable of the unit
  523. -> make sure they are only written for the objectdefs that
  524. own them }
  525. if (not(st.symtabletype in [staticsymtable,globalsymtable]) or
  526. (def.owner=st)) and
  527. not(df_generic in def.defoptions) then
  528. begin
  529. WriteProcDef(tprocdef(def));
  530. if assigned(tprocdef(def).localst) then
  531. WriteSymtableProcdefs(tprocdef(def).localst);
  532. end;
  533. end;
  534. else
  535. ;
  536. end;
  537. end;
  538. end;
  539. procedure TWabtTextAssembler.WriteTempAlloc(p: TAsmList);
  540. var
  541. hp: tai;
  542. tmp: array of tai_tempalloc;
  543. mx : integer;
  544. i : integer;
  545. begin
  546. if not assigned(p) then
  547. exit;
  548. mx := -1;
  549. hp:=tai(p.first);
  550. while assigned(hp) do
  551. begin
  552. //prefetch(pointer(hp.next)^);
  553. if (hp.typ = ait_tempalloc) and
  554. tai_tempalloc(hp).allocation and
  555. (tai_tempalloc(hp).temppos >= mx) then
  556. mx := tai_tempalloc(hp).temppos+1;
  557. hp:=tai(hp.next);
  558. end;
  559. if (mx <= 0) then exit; // no temp allocations used
  560. SetLength(tmp, mx);
  561. hp:=tai(p.first);
  562. while assigned(hp) do
  563. begin
  564. //prefetch(pointer(hp.next)^);
  565. if (hp.typ = ait_tempalloc) and
  566. (tai_tempalloc(hp).allocation) and
  567. (tmp[ tai_tempalloc(hp).temppos ] = nil) then
  568. begin
  569. tmp[ tai_tempalloc(hp).temppos ] := tai_tempalloc(hp);
  570. dec(mx);
  571. if mx = 0 then break;
  572. end;
  573. hp:=tai(hp.next);
  574. end;
  575. for i:=0 to length(tmp)-1 do
  576. begin
  577. if tmp[i] = nil then continue;
  578. writer.AsmWrite(#9'(local'#9);
  579. if tmp[i].tempsize<=4 then writer.AsmWrite('i32')
  580. else if tmp[i].tempsize = 8 then writer.AsmWrite('i64');
  581. writer.AsmWrite(')');
  582. writer.AsmWrite(#9+asminfo^.comment+'Temp '+tostr(tmp[i].temppos)+','+
  583. tostr(tmp[i].tempsize)+' '+tempallocstr[tmp[i].allocation]);
  584. writer.AsmLn;
  585. end;
  586. end;
  587. procedure TWabtTextAssembler.WriteExports(p: TAsmList);
  588. var
  589. hp: tai;
  590. x: tai_impexp;
  591. begin
  592. if not Assigned(p) then Exit;
  593. hp:=tai(p.First);
  594. while Assigned(hp) do begin
  595. case hp.typ of
  596. ait_importexport:
  597. begin
  598. x:=tai_impexp(hp);
  599. writer.AsmWrite('(export "');
  600. writer.AsmWrite(x.extname);
  601. writer.AsmWrite('" (');
  602. case x.symstype of
  603. ie_Func: writer.AsmWrite('func');
  604. end;
  605. writer.AsmWrite(' ');
  606. writer.AsmWrite(GetWasmName(x.intname));
  607. writer.AsmWrite('))');
  608. writer.AsmLn;
  609. end;
  610. end;
  611. hp := tai_impexp(hp.Next);
  612. end;
  613. end;
  614. { TWatInstrWriter }
  615. constructor TWatInstrWriter.create(_owner: TWabtTextAssembler);
  616. begin
  617. inherited create;
  618. owner := _owner;
  619. end;
  620. procedure TWatInstrWriter.WriteInstruction(hp: tai);
  621. begin
  622. end;
  623. const
  624. as_wasm_wabt_info : tasminfo =
  625. (
  626. id : as_wasm_wabt;
  627. idtxt : 'Wabt';
  628. asmbin : 'wat2wasm';
  629. asmcmd : '$ASM $EXTRAOPT';
  630. supported_targets : [system_wasm_wasm32];
  631. flags : [];
  632. labelprefix : 'L';
  633. comment : ';; ';
  634. dollarsign : '$';
  635. );
  636. initialization
  637. RegisterAssembler(as_wasm_wabt_info, TWabtTextAssembler);
  638. end.