ncgrtti.pas 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Routines for the code generation of RTTI data structures
  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 ncgrtti;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. cclasses,
  22. aasmbase,
  23. symbase,symconst,symtype,symdef;
  24. type
  25. { TRTTIWriter }
  26. TRTTIWriter=class
  27. private
  28. function fields_count(st:tsymtable;rt:trttitype):longint;
  29. procedure fields_write_rtti(st:tsymtable;rt:trttitype);
  30. procedure fields_write_rtti_data(st:tsymtable;rt:trttitype);
  31. procedure write_rtti_extrasyms(def:Tdef;rt:Trttitype;mainrtti:Tasmsymbol);
  32. procedure published_write_rtti(st:tsymtable;rt:trttitype);
  33. function published_properties_count(st:tsymtable):longint;
  34. procedure published_properties_write_rtti_data(propnamelist:TFPHashObjectList;st:tsymtable);
  35. procedure collect_propnamelist(propnamelist:TFPHashObjectList;objdef:tobjectdef);
  36. procedure write_rtti_name(def:tdef);
  37. procedure write_rtti_data(def:tdef;rt:trttitype);
  38. procedure write_child_rtti_data(def:tdef;rt:trttitype);
  39. function ref_rtti(def:tdef;rt:trttitype):tasmsymbol;
  40. public
  41. procedure write_rtti(def:tdef;rt:trttitype);
  42. function get_rtti_label(def:tdef;rt:trttitype):tasmsymbol;
  43. function get_rtti_label_ord2str(def:tdef;rt:trttitype):tasmsymbol;
  44. function get_rtti_label_str2ord(def:tdef;rt:trttitype):tasmsymbol;
  45. end;
  46. var
  47. RTTIWriter : TRTTIWriter;
  48. implementation
  49. uses
  50. cutils,
  51. globals,globtype,verbose,
  52. fmodule,
  53. symsym,
  54. aasmtai,aasmdata
  55. ;
  56. const
  57. rttidefstate : array[trttitype] of tdefstate = (ds_rtti_table_written,ds_init_table_written);
  58. type
  59. TPropNameListItem = class(TFPHashObject)
  60. propindex : longint;
  61. propowner : TSymtable;
  62. end;
  63. {***************************************************************************
  64. TRTTIWriter
  65. ***************************************************************************}
  66. procedure TRTTIWriter.write_rtti_name(def:tdef);
  67. var
  68. hs : string;
  69. begin
  70. { name }
  71. if assigned(def.typesym) then
  72. begin
  73. hs:=ttypesym(def.typesym).realname;
  74. current_asmdata.asmlists[al_rtti].concat(Tai_string.Create(chr(length(hs))+hs));
  75. end
  76. else
  77. current_asmdata.asmlists[al_rtti].concat(Tai_string.Create(#0));
  78. end;
  79. function TRTTIWriter.fields_count(st:tsymtable;rt:trttitype):longint;
  80. var
  81. i : longint;
  82. sym : tsym;
  83. begin
  84. result:=0;
  85. for i:=0 to st.SymList.Count-1 do
  86. begin
  87. sym:=tsym(st.SymList[i]);
  88. if (rt=fullrtti) or
  89. (
  90. (tsym(sym).typ=fieldvarsym) and
  91. tfieldvarsym(sym).vardef.needs_inittable
  92. ) then
  93. inc(result);
  94. end;
  95. end;
  96. procedure TRTTIWriter.fields_write_rtti_data(st:tsymtable;rt:trttitype);
  97. var
  98. i : longint;
  99. sym : tsym;
  100. begin
  101. for i:=0 to st.SymList.Count-1 do
  102. begin
  103. sym:=tsym(st.SymList[i]);
  104. if (rt=fullrtti) or
  105. (
  106. (tsym(sym).typ=fieldvarsym) and
  107. tfieldvarsym(sym).vardef.needs_inittable
  108. ) then
  109. begin
  110. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_sym(ref_rtti(tfieldvarsym(sym).vardef,rt)));
  111. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_32bit(tfieldvarsym(sym).fieldoffset));
  112. end;
  113. end;
  114. end;
  115. procedure TRTTIWriter.fields_write_rtti(st:tsymtable;rt:trttitype);
  116. var
  117. i : longint;
  118. sym : tsym;
  119. begin
  120. for i:=0 to st.SymList.Count-1 do
  121. begin
  122. sym:=tsym(st.SymList[i]);
  123. if (rt=fullrtti) or
  124. (
  125. (tsym(sym).typ=fieldvarsym) and
  126. tfieldvarsym(sym).vardef.needs_inittable
  127. ) then
  128. write_rtti(tfieldvarsym(sym).vardef,rt);
  129. end;
  130. end;
  131. procedure TRTTIWriter.published_write_rtti(st:tsymtable;rt:trttitype);
  132. var
  133. i : longint;
  134. sym : tsym;
  135. begin
  136. for i:=0 to st.SymList.Count-1 do
  137. begin
  138. sym:=tsym(st.SymList[i]);
  139. if (sp_published in tsym(sym).symoptions) then
  140. begin
  141. case tsym(sym).typ of
  142. propertysym:
  143. write_rtti(tpropertysym(sym).propdef,rt);
  144. fieldvarsym:
  145. write_rtti(tfieldvarsym(sym).vardef,rt);
  146. end;
  147. end;
  148. end;
  149. end;
  150. function TRTTIWriter.published_properties_count(st:tsymtable):longint;
  151. var
  152. i : longint;
  153. sym : tsym;
  154. begin
  155. result:=0;
  156. for i:=0 to st.SymList.Count-1 do
  157. begin
  158. sym:=tsym(st.SymList[i]);
  159. if (tsym(sym).typ=propertysym) and
  160. (sp_published in tsym(sym).symoptions) then
  161. inc(result);
  162. end;
  163. end;
  164. procedure TRTTIWriter.collect_propnamelist(propnamelist:TFPHashObjectList;objdef:tobjectdef);
  165. var
  166. i : longint;
  167. sym : tsym;
  168. pn : tpropnamelistitem;
  169. begin
  170. if assigned(objdef.childof) then
  171. collect_propnamelist(propnamelist,objdef.childof);
  172. for i:=0 to objdef.symtable.SymList.Count-1 do
  173. begin
  174. sym:=tsym(objdef.symtable.SymList[i]);
  175. if (tsym(sym).typ=propertysym) and
  176. (sp_published in tsym(sym).symoptions) then
  177. begin
  178. pn:=TPropNameListItem(propnamelist.Find(tsym(sym).name));
  179. if not assigned(pn) then
  180. begin
  181. pn:=tpropnamelistitem.create(propnamelist,tsym(sym).name);
  182. pn.propindex:=propnamelist.count-1;
  183. pn.propowner:=tsym(sym).owner;
  184. end;
  185. end;
  186. end;
  187. end;
  188. procedure TRTTIWriter.published_properties_write_rtti_data(propnamelist:TFPHashObjectList;st:tsymtable);
  189. var
  190. i : longint;
  191. sym : tsym;
  192. proctypesinfo : byte;
  193. propnameitem : tpropnamelistitem;
  194. procedure writeaccessproc(pap:tpropaccesslisttypes; shiftvalue : byte; unsetvalue: byte);
  195. var
  196. typvalue : byte;
  197. hp : ppropaccesslistitem;
  198. address : longint;
  199. def : tdef;
  200. hpropsym : tpropertysym;
  201. propaccesslist : tpropaccesslist;
  202. begin
  203. hpropsym:=tpropertysym(sym);
  204. repeat
  205. propaccesslist:=hpropsym.propaccesslist[pap];
  206. if not propaccesslist.empty then
  207. break;
  208. hpropsym:=hpropsym.overridenpropsym;
  209. until not assigned(hpropsym);
  210. if not(assigned(propaccesslist) and assigned(propaccesslist.firstsym)) then
  211. begin
  212. current_asmdata.asmlists[al_rtti].concat(Tai_const.create(aitconst_ptr,unsetvalue));
  213. typvalue:=3;
  214. end
  215. else if propaccesslist.firstsym^.sym.typ=fieldvarsym then
  216. begin
  217. address:=0;
  218. hp:=propaccesslist.firstsym;
  219. def:=nil;
  220. while assigned(hp) do
  221. begin
  222. case hp^.sltype of
  223. sl_load :
  224. begin
  225. def:=tfieldvarsym(hp^.sym).vardef;
  226. inc(address,tfieldvarsym(hp^.sym).fieldoffset);
  227. end;
  228. sl_subscript :
  229. begin
  230. if not(assigned(def) and (def.typ=recorddef)) then
  231. internalerror(200402171);
  232. inc(address,tfieldvarsym(hp^.sym).fieldoffset);
  233. def:=tfieldvarsym(hp^.sym).vardef;
  234. end;
  235. sl_vec :
  236. begin
  237. if not(assigned(def) and (def.typ=arraydef)) then
  238. internalerror(200402172);
  239. def:=tarraydef(def).elementdef;
  240. inc(address,def.size*hp^.value);
  241. end;
  242. end;
  243. hp:=hp^.next;
  244. end;
  245. current_asmdata.asmlists[al_rtti].concat(Tai_const.create(aitconst_ptr,address));
  246. typvalue:=0;
  247. end
  248. else
  249. begin
  250. { When there was an error then procdef is not assigned }
  251. if not assigned(propaccesslist.procdef) then
  252. exit;
  253. if not(po_virtualmethod in tprocdef(propaccesslist.procdef).procoptions) then
  254. begin
  255. current_asmdata.asmlists[al_rtti].concat(Tai_const.createname(tprocdef(propaccesslist.procdef).mangledname,0));
  256. typvalue:=1;
  257. end
  258. else
  259. begin
  260. { virtual method, write vmt offset }
  261. current_asmdata.asmlists[al_rtti].concat(Tai_const.create(aitconst_ptr,
  262. tprocdef(propaccesslist.procdef)._class.vmtmethodoffset(tprocdef(propaccesslist.procdef).extnumber)));
  263. typvalue:=2;
  264. end;
  265. end;
  266. proctypesinfo:=proctypesinfo or (typvalue shl shiftvalue);
  267. end;
  268. begin
  269. for i:=0 to st.SymList.Count-1 do
  270. begin
  271. sym:=tsym(st.SymList[i]);
  272. if (sym.typ=propertysym) and
  273. (sp_published in sym.symoptions) then
  274. begin
  275. if ppo_indexed in tpropertysym(sym).propoptions then
  276. proctypesinfo:=$40
  277. else
  278. proctypesinfo:=0;
  279. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_sym(ref_rtti(tpropertysym(sym).propdef,fullrtti)));
  280. writeaccessproc(palt_read,0,0);
  281. writeaccessproc(palt_write,2,0);
  282. { is it stored ? }
  283. if not(ppo_stored in tpropertysym(sym).propoptions) then
  284. begin
  285. { no, so put a constant zero }
  286. current_asmdata.asmlists[al_rtti].concat(Tai_const.create(aitconst_ptr,0));
  287. proctypesinfo:=proctypesinfo or (3 shl 4);
  288. end
  289. else
  290. writeaccessproc(palt_stored,4,1); { maybe; if no procedure put a constant 1 (=true) }
  291. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_32bit(tpropertysym(sym).index));
  292. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_32bit(tpropertysym(sym).default));
  293. propnameitem:=TPropNameListItem(propnamelist.Find(tpropertysym(sym).name));
  294. if not assigned(propnameitem) then
  295. internalerror(200512201);
  296. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_16bit(propnameitem.propindex));
  297. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(proctypesinfo));
  298. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(length(tpropertysym(sym).realname)));
  299. current_asmdata.asmlists[al_rtti].concat(Tai_string.Create(tpropertysym(sym).realname));
  300. {$ifdef cpurequiresproperalignment}
  301. current_asmdata.asmlists[al_rtti].concat(cai_align.Create(sizeof(TConstPtrUInt)));
  302. {$endif cpurequiresproperalignment}
  303. end;
  304. end;
  305. end;
  306. procedure TRTTIWriter.write_rtti_data(def:tdef;rt:trttitype);
  307. procedure unknown_rtti(def:tstoreddef);
  308. begin
  309. current_asmdata.asmlists[al_rtti].concat(tai_const.create_8bit(tkUnknown));
  310. write_rtti_name(def);
  311. end;
  312. procedure variantdef_rtti(def:tvariantdef);
  313. begin
  314. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(tkVariant));
  315. end;
  316. procedure stringdef_rtti(def:tstringdef);
  317. begin
  318. case def.stringtype of
  319. st_ansistring:
  320. begin
  321. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(tkAString));
  322. write_rtti_name(def);
  323. end;
  324. st_widestring:
  325. begin
  326. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(tkWString));
  327. write_rtti_name(def);
  328. end;
  329. st_longstring:
  330. begin
  331. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(tkLString));
  332. write_rtti_name(def);
  333. end;
  334. st_shortstring:
  335. begin
  336. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(tkSString));
  337. write_rtti_name(def);
  338. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(def.len));
  339. {$ifdef cpurequiresproperalignment}
  340. current_asmdata.asmlists[al_rtti].concat(cai_align.Create(sizeof(TConstPtrUInt)));
  341. {$endif cpurequiresproperalignment}
  342. end;
  343. end;
  344. end;
  345. procedure enumdef_rtti(def:tenumdef);
  346. var
  347. hp : tenumsym;
  348. begin
  349. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(tkEnumeration));
  350. write_rtti_name(def);
  351. {$ifdef cpurequiresproperalignment}
  352. current_asmdata.asmlists[al_rtti].concat(Cai_align.Create(sizeof(TConstPtrUInt)));
  353. {$endif cpurequiresproperalignment}
  354. case longint(def.size) of
  355. 1 :
  356. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(otUByte));
  357. 2 :
  358. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(otUWord));
  359. 4 :
  360. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(otULong));
  361. end;
  362. {$ifdef cpurequiresproperalignment}
  363. current_asmdata.asmlists[al_rtti].concat(Cai_align.Create(sizeof(TConstPtrUInt)));
  364. {$endif cpurequiresproperalignment}
  365. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_32bit(def.min));
  366. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_32bit(def.max));
  367. if assigned(def.basedef) then
  368. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_sym(ref_rtti(def.basedef,rt)))
  369. else
  370. current_asmdata.asmlists[al_rtti].concat(Tai_const.create_sym(nil));
  371. hp:=tenumsym(def.firstenum);
  372. while assigned(hp) do
  373. begin
  374. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(length(hp.realname)));
  375. current_asmdata.asmlists[al_rtti].concat(Tai_string.Create(hp.realname));
  376. hp:=hp.nextenum;
  377. end;
  378. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(0));
  379. end;
  380. procedure orddef_rtti(def:torddef);
  381. procedure dointeger;
  382. const
  383. trans : array[tordtype] of byte =
  384. (otUByte{otNone},
  385. otUByte,otUWord,otULong,otUByte{otNone},
  386. otSByte,otSWord,otSLong,otUByte{otNone},
  387. otUByte,otUWord,otULong,otUByte,
  388. otUByte,otUWord,otUByte);
  389. begin
  390. write_rtti_name(def);
  391. {$ifdef cpurequiresproperalignment}
  392. current_asmdata.asmlists[al_rtti].concat(cai_align.Create(sizeof(TConstPtrUInt)));
  393. {$endif cpurequiresproperalignment}
  394. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(byte(trans[def.ordtype])));
  395. {$ifdef cpurequiresproperalignment}
  396. current_asmdata.asmlists[al_rtti].concat(cai_align.Create(sizeof(TConstPtrUInt)));
  397. {$endif cpurequiresproperalignment}
  398. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_32bit(longint(def.low)));
  399. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_32bit(longint(def.high)));
  400. end;
  401. begin
  402. case def.ordtype of
  403. s64bit :
  404. begin
  405. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(tkInt64));
  406. write_rtti_name(def);
  407. {$ifdef cpurequiresproperalignment}
  408. current_asmdata.asmlists[al_rtti].concat(cai_align.Create(sizeof(TConstPtrUInt)));
  409. {$endif cpurequiresproperalignment}
  410. { low }
  411. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_64bit(int64($80000000) shl 32));
  412. { high }
  413. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_64bit((int64($7fffffff) shl 32) or int64($ffffffff)));
  414. end;
  415. u64bit :
  416. begin
  417. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(tkQWord));
  418. write_rtti_name(def);
  419. {$ifdef cpurequiresproperalignment}
  420. current_asmdata.asmlists[al_rtti].concat(cai_align.Create(sizeof(TConstPtrUInt)));
  421. {$endif cpurequiresproperalignment}
  422. { low }
  423. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_64bit(0));
  424. { high }
  425. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_64bit(int64((int64($ffffffff) shl 32) or int64($ffffffff))));
  426. end;
  427. bool8bit:
  428. begin
  429. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(tkBool));
  430. dointeger;
  431. end;
  432. uchar:
  433. begin
  434. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(tkChar));
  435. dointeger;
  436. end;
  437. uwidechar:
  438. begin
  439. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(tkWChar));
  440. dointeger;
  441. end;
  442. else
  443. begin
  444. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(tkInteger));
  445. dointeger;
  446. end;
  447. end;
  448. end;
  449. procedure floatdef_rtti(def:tfloatdef);
  450. const
  451. {tfloattype = (s32real,s64real,s80real,s64bit,s128bit);}
  452. translate : array[tfloattype] of byte =
  453. (ftSingle,ftDouble,ftExtended,ftComp,ftCurr,ftFloat128);
  454. begin
  455. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(tkFloat));
  456. write_rtti_name(def);
  457. {$ifdef cpurequiresproperalignment}
  458. current_asmdata.asmlists[al_rtti].concat(cai_align.Create(sizeof(TConstPtrUInt)));
  459. {$endif cpurequiresproperalignment}
  460. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(translate[def.floattype]));
  461. end;
  462. procedure setdef_rtti(def:tsetdef);
  463. begin
  464. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(tkSet));
  465. write_rtti_name(def);
  466. {$ifdef cpurequiresproperalignment}
  467. current_asmdata.asmlists[al_rtti].concat(cai_align.Create(sizeof(TConstPtrUInt)));
  468. {$endif cpurequiresproperalignment}
  469. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(otULong));
  470. {$ifdef cpurequiresproperalignment}
  471. current_asmdata.asmlists[al_rtti].concat(cai_align.Create(sizeof(TConstPtrUInt)));
  472. {$endif cpurequiresproperalignment}
  473. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_sym(ref_rtti(def.elementdef,rt)));
  474. end;
  475. procedure arraydef_rtti(def:tarraydef);
  476. begin
  477. if ado_IsDynamicArray in def.arrayoptions then
  478. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(tkdynarray))
  479. else
  480. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(tkarray));
  481. write_rtti_name(def);
  482. {$ifdef cpurequiresproperalignment}
  483. current_asmdata.asmlists[al_rtti].concat(cai_align.Create(sizeof(TConstPtrUInt)));
  484. {$endif cpurequiresproperalignment}
  485. { size of elements }
  486. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_aint(def.elesize));
  487. if not(ado_IsDynamicArray in def.arrayoptions) then
  488. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_aint(def.elecount));
  489. { element type }
  490. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_sym(ref_rtti(def.elementdef,rt)));
  491. { variant type }
  492. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_32bit(tstoreddef(def.elementdef).getvardef));
  493. end;
  494. procedure recorddef_rtti(def:trecorddef);
  495. var
  496. fieldcnt : longint;
  497. begin
  498. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(tkrecord));
  499. write_rtti_name(def);
  500. {$ifdef cpurequiresproperalignment}
  501. current_asmdata.asmlists[al_rtti].concat(cai_align.Create(sizeof(TConstPtrUInt)));
  502. {$endif cpurequiresproperalignment}
  503. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_32bit(def.size));
  504. fieldcnt:=fields_count(def.symtable,rt);
  505. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_32bit(fieldcnt));
  506. fields_write_rtti_data(def.symtable,rt);
  507. end;
  508. procedure procvardef_rtti(def:tprocvardef);
  509. procedure write_para(parasym:tparavarsym);
  510. var
  511. paraspec : byte;
  512. begin
  513. { only store user visible parameters }
  514. if not(vo_is_hidden_para in parasym.varoptions) then
  515. begin
  516. case parasym.varspez of
  517. vs_value: paraspec := 0;
  518. vs_const: paraspec := pfConst;
  519. vs_var : paraspec := pfVar;
  520. vs_out : paraspec := pfOut;
  521. end;
  522. { write flags for current parameter }
  523. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(paraspec));
  524. { write name of current parameter }
  525. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(length(parasym.realname)));
  526. current_asmdata.asmlists[al_rtti].concat(Tai_string.Create(parasym.realname));
  527. { write name of type of current parameter }
  528. write_rtti_name(parasym.vardef);
  529. end;
  530. end;
  531. var
  532. methodkind : byte;
  533. i : integer;
  534. begin
  535. if po_methodpointer in def.procoptions then
  536. begin
  537. { write method id and name }
  538. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(tkmethod));
  539. write_rtti_name(def);
  540. {$ifdef cpurequiresproperalignment}
  541. current_asmdata.asmlists[al_rtti].concat(cai_align.Create(sizeof(TConstPtrUInt)));
  542. {$endif cpurequiresproperalignment}
  543. { write kind of method (can only be function or procedure)}
  544. if def.returndef = voidtype then
  545. methodkind := mkProcedure
  546. else
  547. methodkind := mkFunction;
  548. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(methodkind));
  549. { write parameter info. The parameters must be written in reverse order
  550. if this method uses right to left parameter pushing! }
  551. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(def.maxparacount));
  552. if def.proccalloption in pushleftright_pocalls then
  553. begin
  554. for i:=0 to def.paras.count-1 do
  555. write_para(tparavarsym(def.paras[i]));
  556. end
  557. else
  558. begin
  559. for i:=def.paras.count-1 downto 0 do
  560. write_para(tparavarsym(def.paras[i]));
  561. end;
  562. { write name of result type }
  563. write_rtti_name(def.returndef);
  564. end
  565. else
  566. begin
  567. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(tkprocvar));
  568. write_rtti_name(def);
  569. end;
  570. end;
  571. procedure objectdef_rtti(def:tobjectdef);
  572. procedure objectdef_rtti_class_init(def:tobjectdef);
  573. begin
  574. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_32bit(def.size));
  575. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_32bit(fields_count(def.symtable,rt)));
  576. fields_write_rtti_data(def.symtable,rt);
  577. end;
  578. procedure objectdef_rtti_interface_init(def:tobjectdef);
  579. begin
  580. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_32bit(def.size));
  581. end;
  582. procedure objectdef_rtti_class_full(def:tobjectdef);
  583. var
  584. propnamelist : TFPHashObjectList;
  585. begin
  586. { Collect unique property names with nameindex }
  587. propnamelist:=TFPHashObjectList.Create;
  588. collect_propnamelist(propnamelist,def);
  589. if (oo_has_vmt in def.objectoptions) then
  590. current_asmdata.asmlists[al_rtti].concat(Tai_const.Createname(def.vmt_mangledname,0))
  591. else
  592. current_asmdata.asmlists[al_rtti].concat(Tai_const.create_sym(nil));
  593. { write parent typeinfo }
  594. if assigned(def.childof) and
  595. (oo_can_have_published in def.childof.objectoptions) then
  596. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_sym(ref_rtti(def.childof,fullrtti)))
  597. else
  598. current_asmdata.asmlists[al_rtti].concat(Tai_const.create_sym(nil));
  599. { total number of unique properties }
  600. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_16bit(propnamelist.count));
  601. { write unit name }
  602. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(length(current_module.realmodulename^)));
  603. current_asmdata.asmlists[al_rtti].concat(Tai_string.Create(current_module.realmodulename^));
  604. {$ifdef cpurequiresproperalignment}
  605. current_asmdata.asmlists[al_rtti].concat(cai_align.Create(sizeof(TConstPtrUInt)));
  606. {$endif cpurequiresproperalignment}
  607. { write published properties for this object }
  608. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_16bit(published_properties_count(def.symtable)));
  609. {$ifdef cpurequiresproperalignment}
  610. current_asmdata.asmlists[al_rtti].concat(cai_align.Create(sizeof(TConstPtrUInt)));
  611. {$endif cpurequiresproperalignment}
  612. published_properties_write_rtti_data(propnamelist,def.symtable);
  613. propnamelist.free;
  614. end;
  615. procedure objectdef_rtti_interface_full(def:tobjectdef);
  616. var
  617. i : longint;
  618. propnamelist : TFPHashObjectList;
  619. begin
  620. { Collect unique property names with nameindex }
  621. propnamelist:=TFPHashObjectList.Create;
  622. collect_propnamelist(propnamelist,def);
  623. { write parent typeinfo }
  624. if assigned(def.childof) then
  625. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_sym(ref_rtti(def.childof,fullrtti)))
  626. else
  627. current_asmdata.asmlists[al_rtti].concat(Tai_const.create_sym(nil));
  628. { interface: write flags, iid and iidstr }
  629. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_32bit(
  630. { ugly, but working }
  631. {$ifdef USE_PACKSET1}
  632. byte([
  633. {$else USE_PACKSET1}
  634. longint([
  635. {$endif USE_PACKSET1}
  636. TCompilerIntfFlag(ord(ifHasGuid)*ord(assigned(def.iidguid))),
  637. TCompilerIntfFlag(ord(ifHasStrGUID)*ord(assigned(def.iidstr)))
  638. ])
  639. {
  640. ifDispInterface,
  641. ifDispatch, }
  642. ));
  643. {$ifdef cpurequiresproperalignment}
  644. current_asmdata.asmlists[al_rtti].concat(cai_align.Create(sizeof(TConstPtrUInt)));
  645. {$endif cpurequiresproperalignment}
  646. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_32bit(longint(def.iidguid^.D1)));
  647. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_16bit(def.iidguid^.D2));
  648. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_16bit(def.iidguid^.D3));
  649. for i:=Low(def.iidguid^.D4) to High(def.iidguid^.D4) do
  650. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(def.iidguid^.D4[i]));
  651. { write unit name }
  652. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(length(current_module.realmodulename^)));
  653. current_asmdata.asmlists[al_rtti].concat(Tai_string.Create(current_module.realmodulename^));
  654. {$ifdef cpurequiresproperalignment}
  655. current_asmdata.asmlists[al_rtti].concat(cai_align.Create(sizeof(TConstPtrUInt)));
  656. {$endif cpurequiresproperalignment}
  657. { write iidstr }
  658. if assigned(def.iidstr) then
  659. begin
  660. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(length(def.iidstr^)));
  661. current_asmdata.asmlists[al_rtti].concat(Tai_string.Create(def.iidstr^));
  662. end
  663. else
  664. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(0));
  665. {$ifdef cpurequiresproperalignment}
  666. current_asmdata.asmlists[al_rtti].concat(cai_align.Create(sizeof(TConstPtrUInt)));
  667. {$endif cpurequiresproperalignment}
  668. { write published properties for this object }
  669. published_properties_write_rtti_data(propnamelist,def.symtable);
  670. propnamelist.free;
  671. end;
  672. begin
  673. case def.objecttype of
  674. odt_class:
  675. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(tkclass));
  676. odt_object:
  677. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(tkobject));
  678. odt_interfacecom:
  679. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(tkinterface));
  680. odt_interfacecorba:
  681. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(tkinterfaceCorba));
  682. else
  683. internalerror(200611034);
  684. end;
  685. { generate the name }
  686. current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(length(def.objrealname^)));
  687. current_asmdata.asmlists[al_rtti].concat(Tai_string.Create(def.objrealname^));
  688. {$ifdef cpurequiresproperalignment}
  689. current_asmdata.asmlists[al_rtti].concat(cai_align.Create(sizeof(TConstPtrUInt)));
  690. {$endif cpurequiresproperalignment}
  691. case rt of
  692. initrtti :
  693. begin
  694. if def.objecttype in [odt_class,odt_object] then
  695. objectdef_rtti_class_init(def)
  696. else
  697. objectdef_rtti_interface_init(def);
  698. end;
  699. fullrtti :
  700. begin
  701. if def.objecttype in [odt_class,odt_object] then
  702. objectdef_rtti_class_full(def)
  703. else
  704. objectdef_rtti_interface_full(def);
  705. end;
  706. end;
  707. end;
  708. begin
  709. case def.typ of
  710. variantdef :
  711. variantdef_rtti(tvariantdef(def));
  712. stringdef :
  713. stringdef_rtti(tstringdef(def));
  714. enumdef :
  715. enumdef_rtti(tenumdef(def));
  716. orddef :
  717. orddef_rtti(torddef(def));
  718. floatdef :
  719. floatdef_rtti(tfloatdef(def));
  720. setdef :
  721. setdef_rtti(tsetdef(def));
  722. procvardef :
  723. procvardef_rtti(tprocvardef(def));
  724. arraydef :
  725. begin
  726. if ado_IsBitPacked in tarraydef(def).arrayoptions then
  727. unknown_rtti(tstoreddef(def))
  728. else
  729. arraydef_rtti(tarraydef(def));
  730. end;
  731. recorddef :
  732. begin
  733. if trecorddef(def).is_packed then
  734. unknown_rtti(tstoreddef(def))
  735. else
  736. recorddef_rtti(trecorddef(def));
  737. end;
  738. objectdef :
  739. objectdef_rtti(tobjectdef(def));
  740. else
  741. unknown_rtti(tstoreddef(def));
  742. end;
  743. end;
  744. procedure TRTTIWriter.write_rtti_extrasyms(def:Tdef;rt:Trttitype;mainrtti:Tasmsymbol);
  745. procedure enumdef_rtti_ord2stringindex(def:Tenumdef);
  746. var rttilab:Tasmsymbol;
  747. t:Tenumsym;
  748. syms:^Tenumsym;
  749. offsets:^longint;
  750. sym_count,sym_alloc:longint;
  751. h,i,p,o,st:longint;
  752. mode:(lookup,search); {Modify with care, ordinal value of enum is written.}
  753. r:single; {Must be real type because of integer overflow risk.}
  754. begin
  755. {Random access needed, put in array.}
  756. getmem(syms,64*sizeof(Tenumsym));
  757. getmem(offsets,64*sizeof(longint));
  758. sym_count:=0;
  759. sym_alloc:=64;
  760. st:=0;
  761. t:=Tenumsym(def.firstenum);
  762. while assigned(t) do
  763. begin
  764. if sym_count>=sym_alloc then
  765. begin
  766. reallocmem(syms,2*sym_alloc*sizeof(Tenumsym));
  767. reallocmem(offsets,2*sym_alloc*sizeof(longint));
  768. sym_alloc:=sym_alloc*2;
  769. end;
  770. syms[sym_count]:=t;
  771. offsets[sym_count]:=st;
  772. inc(sym_count);
  773. st:=st+length(t.realname)+1;
  774. t:=t.nextenum;
  775. end;
  776. {Sort the syms by enum value}
  777. if sym_count>=2 then
  778. begin
  779. p:=1;
  780. while 2*p<sym_count do
  781. p:=2*p;
  782. while p<>0 do
  783. begin
  784. for h:=p to sym_count-1 do
  785. begin
  786. i:=h;
  787. t:=syms[i];
  788. o:=offsets[i];
  789. repeat
  790. if syms[i-p].value<=t.value then
  791. break;
  792. syms[i]:=syms[i-p];
  793. offsets[i]:=offsets[i-p];
  794. dec(i,p);
  795. until i<p;
  796. syms[i]:=t;
  797. offsets[i]:=o;
  798. end;
  799. p:=p shr 1;
  800. end;
  801. end;
  802. {Decide wether a lookup array is size efficient.}
  803. mode:=lookup;
  804. if sym_count>0 then
  805. begin
  806. i:=1;
  807. r:=0;
  808. h:=syms[0].value; {Next expected enum value is min.}
  809. while i<sym_count do
  810. begin
  811. {Calculate size of hole between values. Avoid integer overflows.}
  812. r:=r+(single(syms[i].value)-single(h))-1;
  813. h:=syms[i].value;
  814. inc(i);
  815. end;
  816. if r>sym_count then
  817. mode:=search; {Don't waste more than 50% space.}
  818. end;
  819. {Calculate start of string table.}
  820. st:=1;
  821. if assigned(def.typesym) then
  822. inc(st,length(def.typesym.realname)+1)
  823. else
  824. inc(st);
  825. {$ifdef cpurequiresproperalignment}
  826. align(st,sizeof(Tconstptruint));
  827. {$endif}
  828. inc(st);
  829. {$ifdef cpurequiresproperalignment}
  830. align(st,sizeof(Tconstptruint));
  831. {$endif}
  832. inc(st,8+sizeof(aint));
  833. { write rtti data }
  834. with current_asmdata do
  835. begin
  836. rttilab:=defineasmsymbol(Tstoreddef(def).rtti_mangledname(rt)+'_o2s',AB_GLOBAL,AT_DATA);
  837. maybe_new_object_file(asmlists[al_rtti]);
  838. new_section(asmlists[al_rtti],sec_rodata,rttilab.name,const_align(sizeof(aint)));
  839. asmlists[al_rtti].concat(Tai_symbol.create_global(rttilab,0));
  840. asmlists[al_rtti].concat(Tai_const.create_32bit(longint(mode)));
  841. if mode=lookup then
  842. begin
  843. o:=syms[0].value; {Start with min value.}
  844. for i:=0 to sym_count-1 do
  845. begin
  846. while o<syms[i].value do
  847. begin
  848. asmlists[al_rtti].concat(Tai_const.create_aint(0));
  849. inc(o);
  850. end;
  851. inc(o);
  852. asmlists[al_rtti].concat(Tai_const.create_sym_offset(mainrtti,st+offsets[i]));
  853. end;
  854. end
  855. else
  856. begin
  857. asmlists[al_rtti].concat(Tai_const.create_32bit(sym_count));
  858. for i:=0 to sym_count-1 do
  859. begin
  860. asmlists[al_rtti].concat(Tai_const.create_32bit(syms[i].value));
  861. asmlists[al_rtti].concat(Tai_const.create_sym_offset(mainrtti,st+offsets[i]));
  862. end;
  863. end;
  864. asmlists[al_rtti].concat(Tai_symbol_end.create(rttilab));
  865. end;
  866. dispose(syms);
  867. dispose(offsets);
  868. end;
  869. procedure enumdef_rtti_string2ordindex(def:Tenumdef);
  870. var rttilab:Tasmsymbol;
  871. t:Tenumsym;
  872. syms:^Tenumsym;
  873. offsets:^longint;
  874. sym_count,sym_alloc:longint;
  875. h,i,p,o,st:longint;
  876. begin
  877. {Random access needed, put in array.}
  878. getmem(syms,64*sizeof(Tenumsym));
  879. getmem(offsets,64*sizeof(longint));
  880. sym_count:=0;
  881. sym_alloc:=64;
  882. st:=0;
  883. t:=Tenumsym(def.firstenum);
  884. while assigned(t) do
  885. begin
  886. if sym_count>=sym_alloc then
  887. begin
  888. reallocmem(syms,2*sym_alloc*sizeof(Tenumsym));
  889. reallocmem(offsets,2*sym_alloc*sizeof(longint));
  890. sym_alloc:=sym_alloc*2;
  891. end;
  892. syms[sym_count]:=t;
  893. offsets[sym_count]:=st;
  894. inc(sym_count);
  895. st:=st+length(t.realname)+1;
  896. t:=t.nextenum;
  897. end;
  898. {Sort the syms by enum name}
  899. if sym_count>=2 then
  900. begin
  901. p:=1;
  902. while 2*p<sym_count do
  903. p:=2*p;
  904. while p<>0 do
  905. begin
  906. for h:=p to sym_count-1 do
  907. begin
  908. i:=h;
  909. t:=syms[i];
  910. o:=offsets[i];
  911. repeat
  912. if syms[i-p].name<=t.name then
  913. break;
  914. syms[i]:=syms[i-p];
  915. offsets[i]:=offsets[i-p];
  916. dec(i,p);
  917. until i<p;
  918. syms[i]:=t;
  919. offsets[i]:=o;
  920. end;
  921. p:=p shr 1;
  922. end;
  923. end;
  924. {Calculate start of string table.}
  925. st:=1;
  926. if assigned(def.typesym) then
  927. inc(st,length(def.typesym.realname)+1)
  928. else
  929. inc(st);
  930. {$ifdef cpurequiresproperalignment}
  931. align(st,sizeof(Tconstptruint));
  932. {$endif}
  933. inc(st);
  934. {$ifdef cpurequiresproperalignment}
  935. align(st,sizeof(Tconstptruint));
  936. {$endif}
  937. inc(st,8+sizeof(aint));
  938. { write rtti data }
  939. with current_asmdata do
  940. begin
  941. rttilab:=defineasmsymbol(Tstoreddef(def).rtti_mangledname(rt)+'_s2o',AB_GLOBAL,AT_DATA);
  942. maybe_new_object_file(asmlists[al_rtti]);
  943. new_section(asmlists[al_rtti],sec_rodata,rttilab.name,const_align(sizeof(aint)));
  944. asmlists[al_rtti].concat(Tai_symbol.create_global(rttilab,0));
  945. asmlists[al_rtti].concat(Tai_const.create_32bit(sym_count));
  946. for i:=0 to sym_count-1 do
  947. begin
  948. asmlists[al_rtti].concat(Tai_const.create_32bit(syms[i].value));
  949. asmlists[al_rtti].concat(Tai_const.create_sym_offset(mainrtti,st+offsets[i]));
  950. end;
  951. asmlists[al_rtti].concat(Tai_symbol_end.create(rttilab));
  952. end;
  953. dispose(syms);
  954. dispose(offsets);
  955. end;
  956. begin
  957. case def.typ of
  958. enumdef:
  959. if rt=fullrtti then
  960. begin
  961. enumdef_rtti_ord2stringindex(Tenumdef(def));
  962. enumdef_rtti_string2ordindex(Tenumdef(def));
  963. end;
  964. end;
  965. end;
  966. procedure TRTTIWriter.write_child_rtti_data(def:tdef;rt:trttitype);
  967. begin
  968. case def.typ of
  969. enumdef :
  970. if assigned(tenumdef(def).basedef) then
  971. write_rtti(tenumdef(def).basedef,rt);
  972. setdef :
  973. write_rtti(tsetdef(def).elementdef,rt);
  974. arraydef :
  975. write_rtti(tarraydef(def).elementdef,rt);
  976. recorddef :
  977. fields_write_rtti(trecorddef(def).symtable,rt);
  978. objectdef :
  979. begin
  980. if assigned(tobjectdef(def).childof) then
  981. write_rtti(tobjectdef(def).childof,rt);
  982. if rt=initrtti then
  983. fields_write_rtti(tobjectdef(def).symtable,rt)
  984. else
  985. published_write_rtti(tobjectdef(def).symtable,rt);
  986. end;
  987. end;
  988. end;
  989. function TRTTIWriter.ref_rtti(def:tdef;rt:trttitype):tasmsymbol;
  990. begin
  991. result:=current_asmdata.RefAsmSymbol(def.rtti_mangledname(rt));
  992. end;
  993. procedure TRTTIWriter.write_rtti(def:tdef;rt:trttitype);
  994. var
  995. rttilab : tasmsymbol;
  996. begin
  997. { only write rtti of definitions from the current module }
  998. if not findunitsymtable(def.owner).iscurrentunit then
  999. exit;
  1000. { prevent recursion }
  1001. if rttidefstate[rt] in def.defstates then
  1002. exit;
  1003. include(def.defstates,rttidefstate[rt]);
  1004. { write first all dependencies }
  1005. write_child_rtti_data(def,rt);
  1006. { write rtti data }
  1007. rttilab:=current_asmdata.DefineAsmSymbol(tstoreddef(def).rtti_mangledname(rt),AB_GLOBAL,AT_DATA);
  1008. maybe_new_object_file(current_asmdata.asmlists[al_rtti]);
  1009. new_section(current_asmdata.asmlists[al_rtti],sec_rodata,rttilab.name,const_align(sizeof(aint)));
  1010. current_asmdata.asmlists[al_rtti].concat(Tai_symbol.Create_global(rttilab,0));
  1011. write_rtti_data(def,rt);
  1012. current_asmdata.asmlists[al_rtti].concat(Tai_symbol_end.Create(rttilab));
  1013. write_rtti_extrasyms(def,rt,rttilab);
  1014. end;
  1015. function TRTTIWriter.get_rtti_label(def:tdef;rt:trttitype):tasmsymbol;
  1016. begin
  1017. result:=current_asmdata.RefAsmSymbol(def.rtti_mangledname(rt));
  1018. end;
  1019. function TRTTIWriter.get_rtti_label_ord2str(def:tdef;rt:trttitype):tasmsymbol;
  1020. begin
  1021. result:=current_asmdata.RefAsmSymbol(def.rtti_mangledname(rt)+'_o2s');
  1022. end;
  1023. function TRTTIWriter.get_rtti_label_str2ord(def:tdef;rt:trttitype):tasmsymbol;
  1024. begin
  1025. result:=current_asmdata.RefAsmSymbol(def.rtti_mangledname(rt)+'_s2o');
  1026. end;
  1027. end.