psystem.pas 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Load the system unit, create required defs for systemunit
  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 psystem;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. symbase;
  22. procedure create_intern_symbols;
  23. procedure create_intern_types;
  24. procedure load_intern_types;
  25. procedure registernodes;
  26. procedure registertais;
  27. implementation
  28. uses
  29. globals,globtype,verbose,constexp,cpuinfo,
  30. systems,
  31. symconst,symtype,symsym,symdef,symtable,
  32. aasmtai,aasmdata,aasmcpu,
  33. ncgutil,ncgrtti,fmodule,
  34. node,nbas,nflw,nset,ncon,ncnv,nld,nmem,ncal,nmat,nadd,ninl,nopt
  35. ;
  36. procedure create_intern_symbols;
  37. {
  38. all intern procedures for the system unit
  39. }
  40. begin
  41. systemunit.insert(tsyssym.create('Concat',in_concat_x));
  42. systemunit.insert(tsyssym.create('Write',in_write_x));
  43. systemunit.insert(tsyssym.create('WriteLn',in_writeln_x));
  44. systemunit.insert(tsyssym.create('WriteStr',in_writestr_x));
  45. systemunit.insert(tsyssym.create('Assigned',in_assigned_x));
  46. systemunit.insert(tsyssym.create('Read',in_read_x));
  47. systemunit.insert(tsyssym.create('ReadLn',in_readln_x));
  48. systemunit.insert(tsyssym.create('ReadStr',in_readstr_x));
  49. systemunit.insert(tsyssym.create('Ofs',in_ofs_x));
  50. systemunit.insert(tsyssym.create('SizeOf',in_sizeof_x));
  51. systemunit.insert(tsyssym.create('BitSizeOf',in_bitsizeof_x));
  52. systemunit.insert(tsyssym.create('TypeOf',in_typeof_x));
  53. systemunit.insert(tsyssym.create('Low',in_low_x));
  54. systemunit.insert(tsyssym.create('High',in_high_x));
  55. systemunit.insert(tsyssym.create('Slice',in_slice_x));
  56. systemunit.insert(tsyssym.create('Seg',in_seg_x));
  57. systemunit.insert(tsyssym.create('Ord',in_ord_x));
  58. systemunit.insert(tsyssym.create('Pred',in_pred_x));
  59. systemunit.insert(tsyssym.create('Succ',in_succ_x));
  60. systemunit.insert(tsyssym.create('Exclude',in_exclude_x_y));
  61. systemunit.insert(tsyssym.create('Include',in_include_x_y));
  62. systemunit.insert(tsyssym.create('Pack',in_pack_x_y_z));
  63. systemunit.insert(tsyssym.create('Unpack',in_unpack_x_y_z));
  64. systemunit.insert(tsyssym.create('Break',in_break));
  65. systemunit.insert(tsyssym.create('Exit',in_exit));
  66. systemunit.insert(tsyssym.create('Continue',in_continue));
  67. systemunit.insert(tsyssym.create('Leave',in_leave)); {macpas only}
  68. systemunit.insert(tsyssym.create('Cycle',in_cycle)); {macpas only}
  69. systemunit.insert(tsyssym.create('Dec',in_dec_x));
  70. systemunit.insert(tsyssym.create('Inc',in_inc_x));
  71. systemunit.insert(tsyssym.create('Str',in_str_x_string));
  72. systemunit.insert(tsyssym.create('Assert',in_assert_x_y));
  73. systemunit.insert(tsyssym.create('Val',in_val_x));
  74. systemunit.insert(tsyssym.create('Addr',in_addr_x));
  75. systemunit.insert(tsyssym.create('TypeInfo',in_typeinfo_x));
  76. systemunit.insert(tsyssym.create('SetLength',in_setlength_x));
  77. systemunit.insert(tsyssym.create('Copy',in_copy_x));
  78. systemunit.insert(tsyssym.create('Initialize',in_initialize_x));
  79. systemunit.insert(tsyssym.create('Finalize',in_finalize_x));
  80. systemunit.insert(tsyssym.create('Length',in_length_x));
  81. systemunit.insert(tsyssym.create('New',in_new_x));
  82. systemunit.insert(tsyssym.create('Dispose',in_dispose_x));
  83. {$if defined(x86) or defined(arm) or defined(jvm)}
  84. systemunit.insert(tsyssym.create('Get_Frame',in_get_frame));
  85. {$endif defined(x86) or defined(arm) or defined(jvm)}
  86. systemunit.insert(tsyssym.create('Unaligned',in_unaligned_x));
  87. systemunit.insert(tsyssym.create('Aligned',in_aligned_x));
  88. systemunit.insert(tsyssym.create('ObjCSelector',in_objc_selector_x)); { objc only }
  89. systemunit.insert(tsyssym.create('ObjCEncode',in_objc_encode_x)); { objc only }
  90. systemunit.insert(tsyssym.create('Default',in_default_x));
  91. end;
  92. procedure set_default_int_types;
  93. begin
  94. {$ifdef cpu64bitaddr}
  95. uinttype:=u64inttype;
  96. sinttype:=s64inttype;
  97. ptruinttype:=u64inttype;
  98. ptrsinttype:=s64inttype;
  99. {$endif cpu64bitaddr}
  100. {$ifdef cpu32bitaddr}
  101. uinttype:=u32inttype;
  102. sinttype:=s32inttype;
  103. ptruinttype:=u32inttype;
  104. ptrsinttype:=s32inttype;
  105. {$endif cpu32bitaddr}
  106. {$ifdef cpu32bitalu}
  107. uinttype:=u32inttype;
  108. sinttype:=s32inttype;
  109. {$endif cpu32bitalu}
  110. {$ifdef cpu16bitaddr}
  111. ptruinttype:=u16inttype;
  112. ptrsinttype:=s16inttype;
  113. {$endif cpu16bitaddr}
  114. {$ifdef cpu16bitalu}
  115. uinttype:=u16inttype;
  116. sinttype:=s16inttype;
  117. {$endif cpu16bitalu}
  118. {$ifdef cpu8bitalu}
  119. uinttype:=u8inttype;
  120. sinttype:=s8inttype;
  121. {$endif cpu8bitalu}
  122. {$ifndef avr}
  123. osuinttype:=uinttype;
  124. ossinttype:=sinttype;
  125. {$else avr}
  126. osuinttype:=u16inttype;
  127. ossinttype:=s16inttype;
  128. {$endif avr}
  129. end;
  130. procedure create_intern_types;
  131. {
  132. all the types inserted into the system unit
  133. }
  134. function addtype(const s:string;def:tdef):ttypesym;
  135. begin
  136. result:=ttypesym.create(s,def);
  137. systemunit.insert(result);
  138. end;
  139. procedure addfield(recst:tabstractrecordsymtable;sym:tfieldvarsym);
  140. begin
  141. recst.insert(sym);
  142. recst.addfield(sym,vis_hidden);
  143. end;
  144. procedure create_fpu_types;
  145. begin
  146. if init_settings.fputype<>fpu_none then
  147. begin
  148. s32floattype:=tfloatdef.create(s32real);
  149. s64floattype:=tfloatdef.create(s64real);
  150. s80floattype:=tfloatdef.create(s80real);
  151. sc80floattype:=tfloatdef.create(sc80real);
  152. end else begin
  153. s32floattype:=nil;
  154. s64floattype:=nil;
  155. s80floattype:=nil;
  156. sc80floattype:=nil;
  157. end;
  158. end;
  159. var
  160. hrecst : trecordsymtable;
  161. begin
  162. symtablestack.push(systemunit);
  163. cundefinedtype:=tundefineddef.create;
  164. cformaltype:=tformaldef.create(false);
  165. ctypedformaltype:=tformaldef.create(true);
  166. voidtype:=torddef.create(uvoid,0,0);
  167. u8inttype:=torddef.create(u8bit,0,255);
  168. s8inttype:=torddef.create(s8bit,int64(-128),127);
  169. u16inttype:=torddef.create(u16bit,0,65535);
  170. s16inttype:=torddef.create(s16bit,int64(-32768),32767);
  171. u32inttype:=torddef.create(u32bit,0,high(longword));
  172. s32inttype:=torddef.create(s32bit,int64(low(longint)),int64(high(longint)));
  173. u64inttype:=torddef.create(u64bit,low(qword),high(qword));
  174. s64inttype:=torddef.create(s64bit,low(int64),high(int64));
  175. pasbool8type:=torddef.create(pasbool8,0,1);
  176. pasbool16type:=torddef.create(pasbool16,0,1);
  177. pasbool32type:=torddef.create(pasbool32,0,1);
  178. pasbool64type:=torddef.create(pasbool64,0,1);
  179. bool8type:=torddef.create(bool8bit,low(int64),high(int64));
  180. bool16type:=torddef.create(bool16bit,low(int64),high(int64));
  181. bool32type:=torddef.create(bool32bit,low(int64),high(int64));
  182. bool64type:=torddef.create(bool64bit,low(int64),high(int64));
  183. cansichartype:=torddef.create(uchar,0,255);
  184. cwidechartype:=torddef.create(uwidechar,0,65535);
  185. cshortstringtype:=tstringdef.createshort(255);
  186. { should we give a length to the default long and ansi string definition ?? }
  187. clongstringtype:=tstringdef.createlong(-1);
  188. cansistringtype:=tstringdef.createansi(0);
  189. if target_info.system in systems_windows then
  190. cwidestringtype:=tstringdef.createwide
  191. else
  192. cwidestringtype:=tstringdef.createunicode;
  193. cunicodestringtype:=tstringdef.createunicode;
  194. { length=0 for shortstring is open string (needed for readln(string) }
  195. openshortstringtype:=tstringdef.createshort(0);
  196. openchararraytype:=tarraydef.create(0,-1,s32inttype);
  197. tarraydef(openchararraytype).elementdef:=cansichartype;
  198. {$ifdef x86}
  199. create_fpu_types;
  200. {$ifndef FPC_SUPPORT_X87_TYPES_ON_WIN64}
  201. if target_info.system=system_x86_64_win64 then
  202. begin
  203. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  204. pbestrealtype:=@s64floattype;
  205. end
  206. else
  207. {$endif FPC_SUPPORT_X87_TYPES_ON_WIN64}
  208. s64currencytype:=tfloatdef.create(s64currency);
  209. {$endif x86}
  210. {$ifdef powerpc}
  211. create_fpu_types;
  212. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  213. {$endif powerpc}
  214. {$ifdef POWERPC64}
  215. create_fpu_types;
  216. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  217. {$endif POWERPC64}
  218. {$ifdef sparc}
  219. create_fpu_types;
  220. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  221. {$endif sparc}
  222. {$ifdef m68k}
  223. create_fpu_types;
  224. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  225. {$endif}
  226. {$ifdef arm}
  227. create_fpu_types;
  228. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  229. {$endif arm}
  230. {$ifdef avr}
  231. s32floattype:=tfloatdef.create(s32real);
  232. s64floattype:=tfloatdef.create(s64real);
  233. s80floattype:=tfloatdef.create(s80real);
  234. sc80floattype:=tfloatdef.create(sc80real);
  235. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  236. {$endif avr}
  237. {$ifdef mips}
  238. create_fpu_types;
  239. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  240. {$endif mips}
  241. {$ifdef jvm}
  242. create_fpu_types;
  243. s64currencytype:=torddef.create(scurrency,low(int64),high(int64));
  244. {$endif jvm}
  245. set_default_int_types;
  246. { some other definitions }
  247. voidpointertype:=tpointerdef.create(voidtype);
  248. charpointertype:=tpointerdef.create(cansichartype);
  249. widecharpointertype:=tpointerdef.create(cwidechartype);
  250. voidfarpointertype:=tpointerdef.createfar(voidtype);
  251. cfiletype:=tfiledef.createuntyped;
  252. cvarianttype:=tvariantdef.create(vt_normalvariant);
  253. colevarianttype:=tvariantdef.create(vt_olevariant);
  254. {$ifdef cpufpemu}
  255. { Normal types }
  256. (* we use the same types as without emulator, the only
  257. difference is that direct calls to the emulator are generated
  258. if (cs_fp_emulation in current_settings.moduleswitches) then
  259. begin
  260. addtype('Single',s32floattype);
  261. { extended size is the best real type for the target }
  262. addtype('Real',s32floattype);
  263. pbestrealtype:=@s32floattype;
  264. { extended size is the best real type for the target }
  265. addtype('Extended',pbestrealtype^);
  266. end
  267. else
  268. *)
  269. {$endif cpufpemu}
  270. if init_settings.fputype <> fpu_none then
  271. begin
  272. addtype('Single',s32floattype);
  273. addtype('Double',s64floattype);
  274. { extended size is the best real type for the target }
  275. addtype('Extended',pbestrealtype^);
  276. { CExtended corresponds to the C version of the Extended type
  277. (either "long double" or "double") }
  278. if target_info.system in systems_android then
  279. { Android has "long double"="double" even for x86 }
  280. addtype('CExtended',s64floattype)
  281. else
  282. if tfloatdef(pbestrealtype^).floattype=s80real then
  283. addtype('CExtended',sc80floattype)
  284. else
  285. addtype('CExtended',pbestrealtype^);
  286. end;
  287. {$ifdef x86}
  288. {$ifndef FPC_SUPPORT_X87_TYPES_ON_WIN64}
  289. if target_info.system<>system_x86_64_win64 then
  290. {$endif FPC_SUPPORT_X87_TYPES_ON_WIN64}
  291. addtype('Comp',tfloatdef.create(s64comp));
  292. {$endif x86}
  293. addtype('Currency',s64currencytype);
  294. addtype('Pointer',voidpointertype);
  295. {$ifdef x86}
  296. addtype('FarPointer',voidfarpointertype);
  297. {$endif x86}
  298. addtype('ShortString',cshortstringtype);
  299. {$ifdef support_longstring}
  300. addtype('LongString',clongstringtype);
  301. {$endif support_longstring}
  302. addtype('AnsiString',cansistringtype);
  303. addtype('WideString',cwidestringtype);
  304. addtype('UnicodeString',cunicodestringtype);
  305. addtype('OpenString',openshortstringtype);
  306. addtype('Boolean',pasbool8type);
  307. addtype('Boolean16',pasbool16type);
  308. addtype('Boolean32',pasbool32type);
  309. addtype('Boolean64',pasbool64type);
  310. addtype('ByteBool',bool8type);
  311. addtype('WordBool',bool16type);
  312. addtype('LongBool',bool32type);
  313. addtype('QWordBool',bool64type);
  314. addtype('Byte',u8inttype);
  315. addtype('ShortInt',s8inttype);
  316. addtype('Word',u16inttype);
  317. addtype('SmallInt',s16inttype);
  318. addtype('LongWord',u32inttype);
  319. addtype('LongInt',s32inttype);
  320. addtype('QWord',u64inttype);
  321. addtype('Int64',s64inttype);
  322. addtype('Char',cansichartype);
  323. addtype('WideChar',cwidechartype);
  324. addtype('Text',tfiledef.createtext);
  325. addtype('TypedFile',tfiledef.createtyped(voidtype));
  326. addtype('Variant',cvarianttype);
  327. addtype('OleVariant',colevarianttype);
  328. { Internal types }
  329. addtype('$undefined',cundefinedtype);
  330. addtype('$formal',cformaltype);
  331. addtype('$typedformal',ctypedformaltype);
  332. addtype('$void',voidtype);
  333. addtype('$byte',u8inttype);
  334. addtype('$shortint',s8inttype);
  335. addtype('$word',u16inttype);
  336. addtype('$smallint',s16inttype);
  337. addtype('$ulong',u32inttype);
  338. addtype('$longint',s32inttype);
  339. addtype('$qword',u64inttype);
  340. addtype('$int64',s64inttype);
  341. addtype('$char',cansichartype);
  342. addtype('$widechar',cwidechartype);
  343. addtype('$shortstring',cshortstringtype);
  344. addtype('$longstring',clongstringtype);
  345. addtype('$ansistring',cansistringtype);
  346. addtype('$widestring',cwidestringtype);
  347. addtype('$unicodestring',cunicodestringtype);
  348. addtype('$openshortstring',openshortstringtype);
  349. addtype('$boolean',pasbool8type);
  350. addtype('$boolean16',pasbool16type);
  351. addtype('$boolean32',pasbool32type);
  352. addtype('$boolean64',pasbool64type);
  353. addtype('$bytebool',bool8type);
  354. addtype('$wordbool',bool16type);
  355. addtype('$longbool',bool32type);
  356. addtype('$qwordbool',bool64type);
  357. addtype('$void_pointer',voidpointertype);
  358. addtype('$char_pointer',charpointertype);
  359. addtype('$widechar_pointer',widecharpointertype);
  360. addtype('$void_farpointer',voidfarpointertype);
  361. addtype('$openchararray',openchararraytype);
  362. addtype('$file',cfiletype);
  363. addtype('$variant',cvarianttype);
  364. addtype('$olevariant',colevarianttype);
  365. if init_settings.fputype<>fpu_none then
  366. begin
  367. addtype('$s32real',s32floattype);
  368. addtype('$s64real',s64floattype);
  369. addtype('$s80real',s80floattype);
  370. addtype('$sc80real',sc80floattype);
  371. end;
  372. addtype('$s64currency',s64currencytype);
  373. if not(target_info.system in systems_managed_vm) then
  374. begin
  375. { Add a type for virtual method tables }
  376. hrecst:=trecordsymtable.create('',current_settings.packrecords);
  377. vmttype:=trecorddef.create('',hrecst);
  378. pvmttype:=tpointerdef.create(vmttype);
  379. { can't use addtype for pvmt because the rtti of the pointed
  380. type is not available. The rtti for pvmt will be written implicitly
  381. by thev tblarray below }
  382. systemunit.insert(ttypesym.create('$pvmt',pvmttype));
  383. addfield(hrecst,tfieldvarsym.create('$length',vs_value,ptrsinttype,[]));
  384. addfield(hrecst,tfieldvarsym.create('$mlength',vs_value,ptrsinttype,[]));
  385. addfield(hrecst,tfieldvarsym.create('$parent',vs_value,pvmttype,[]));
  386. { it seems vmttype is used both for TP objects and Delphi classes,
  387. so the next entry could either be the first virtual method (vm1)
  388. (object) or the class name (class). We can't easily create separate
  389. vtable formats for both, as gdb is hard coded to search for
  390. __vtbl_ptr_type in all cases (JM) }
  391. addfield(hrecst,tfieldvarsym.create('$vm1_or_classname',vs_value,tpointerdef.create(cshortstringtype),[]));
  392. vmtarraytype:=tarraydef.create(0,0,s32inttype);
  393. tarraydef(vmtarraytype).elementdef:=voidpointertype;
  394. addfield(hrecst,tfieldvarsym.create('$__pfn',vs_value,vmtarraytype,[]));
  395. addtype('$__vtbl_ptr_type',vmttype);
  396. vmtarraytype:=tarraydef.create(0,1,s32inttype);
  397. tarraydef(vmtarraytype).elementdef:=pvmttype;
  398. addtype('$vtblarray',vmtarraytype);
  399. { Add a type for methodpointers }
  400. hrecst:=trecordsymtable.create('',1);
  401. addfield(hrecst,tfieldvarsym.create('$proc',vs_value,voidpointertype,[]));
  402. addfield(hrecst,tfieldvarsym.create('$self',vs_value,voidpointertype,[]));
  403. methodpointertype:=trecorddef.create('',hrecst);
  404. addtype('$methodpointer',methodpointertype);
  405. end;
  406. symtablestack.pop(systemunit);
  407. end;
  408. procedure load_intern_types;
  409. {
  410. Load all default definitions for consts from the system unit
  411. }
  412. procedure loadtype(const s:string;var def:tdef);
  413. var
  414. srsym : ttypesym;
  415. begin
  416. srsym:=search_system_type(s);
  417. def:=srsym.typedef;
  418. end;
  419. var
  420. oldcurrentmodule : tmodule;
  421. begin
  422. {$ifndef FPC_SUPPORT_X87_TYPES_ON_WIN64}
  423. if target_info.system=system_x86_64_win64 then
  424. pbestrealtype:=@s64floattype;
  425. {$endif FPC_SUPPORT_X87_TYPES_ON_WIN64}
  426. oldcurrentmodule:=current_module;
  427. set_current_module(nil);
  428. loadtype('byte',u8inttype);
  429. loadtype('shortint',s8inttype);
  430. loadtype('word',u16inttype);
  431. loadtype('smallint',s16inttype);
  432. loadtype('ulong',u32inttype);
  433. loadtype('longint',s32inttype);
  434. loadtype('qword',u64inttype);
  435. loadtype('int64',s64inttype);
  436. loadtype('undefined',cundefinedtype);
  437. loadtype('formal',cformaltype);
  438. loadtype('typedformal',ctypedformaltype);
  439. loadtype('void',voidtype);
  440. loadtype('char',cansichartype);
  441. loadtype('widechar',cwidechartype);
  442. loadtype('shortstring',cshortstringtype);
  443. loadtype('longstring',clongstringtype);
  444. loadtype('ansistring',cansistringtype);
  445. loadtype('widestring',cwidestringtype);
  446. loadtype('unicodestring',cunicodestringtype);
  447. loadtype('openshortstring',openshortstringtype);
  448. loadtype('openchararray',openchararraytype);
  449. if init_settings.fputype <> fpu_none then
  450. begin
  451. loadtype('s32real',s32floattype);
  452. loadtype('s64real',s64floattype);
  453. loadtype('s80real',s80floattype);
  454. loadtype('sc80real',sc80floattype);
  455. end;
  456. loadtype('s64currency',s64currencytype);
  457. loadtype('boolean',pasbool8type);
  458. loadtype('boolean16',pasbool16type);
  459. loadtype('boolean32',pasbool32type);
  460. loadtype('boolean64',pasbool64type);
  461. loadtype('bytebool',bool8type);
  462. loadtype('wordbool',bool16type);
  463. loadtype('longbool',bool32type);
  464. loadtype('qwordbool',bool64type);
  465. loadtype('void_pointer',voidpointertype);
  466. loadtype('char_pointer',charpointertype);
  467. loadtype('widechar_pointer',widecharpointertype);
  468. loadtype('void_farpointer',voidfarpointertype);
  469. loadtype('file',cfiletype);
  470. if not(target_info.system in systems_managed_vm) then
  471. begin
  472. loadtype('pvmt',pvmttype);
  473. loadtype('vtblarray',vmtarraytype);
  474. loadtype('__vtbl_ptr_type',vmttype);
  475. end;
  476. loadtype('variant',cvarianttype);
  477. loadtype('olevariant',colevarianttype);
  478. if not(target_info.system in systems_managed_vm) then
  479. loadtype('methodpointer',methodpointertype);
  480. loadtype('HRESULT',hresultdef);
  481. set_default_int_types;
  482. set_current_module(oldcurrentmodule);
  483. end;
  484. procedure registernodes;
  485. {
  486. Register all possible nodes in the nodeclass array that
  487. will be used for loading the nodes from a ppu
  488. }
  489. begin
  490. nodeclass[addn]:=caddnode;
  491. nodeclass[muln]:=caddnode;
  492. nodeclass[subn]:=caddnode;
  493. nodeclass[divn]:=cmoddivnode;
  494. nodeclass[symdifn]:=caddnode;
  495. nodeclass[modn]:=cmoddivnode;
  496. nodeclass[assignn]:=cassignmentnode;
  497. nodeclass[loadn]:=cloadnode;
  498. nodeclass[rangen]:=crangenode;
  499. nodeclass[ltn]:=caddnode;
  500. nodeclass[lten]:=caddnode;
  501. nodeclass[gtn]:=caddnode;
  502. nodeclass[gten]:=caddnode;
  503. nodeclass[equaln]:=caddnode;
  504. nodeclass[unequaln]:=caddnode;
  505. nodeclass[inn]:=cinnode;
  506. nodeclass[orn]:=caddnode;
  507. nodeclass[xorn]:=caddnode;
  508. nodeclass[shrn]:=cshlshrnode;
  509. nodeclass[shln]:=cshlshrnode;
  510. nodeclass[slashn]:=caddnode;
  511. nodeclass[andn]:=caddnode;
  512. nodeclass[subscriptn]:=csubscriptnode;
  513. nodeclass[derefn]:=cderefnode;
  514. nodeclass[addrn]:=caddrnode;
  515. nodeclass[ordconstn]:=cordconstnode;
  516. nodeclass[typeconvn]:=ctypeconvnode;
  517. nodeclass[calln]:=ccallnode;
  518. nodeclass[callparan]:=ccallparanode;
  519. nodeclass[realconstn]:=crealconstnode;
  520. nodeclass[unaryminusn]:=cunaryminusnode;
  521. nodeclass[unaryplusn]:=cunaryplusnode;
  522. nodeclass[asmn]:=casmnode;
  523. nodeclass[vecn]:=cvecnode;
  524. nodeclass[pointerconstn]:=cpointerconstnode;
  525. nodeclass[stringconstn]:=cstringconstnode;
  526. nodeclass[notn]:=cnotnode;
  527. nodeclass[inlinen]:=cinlinenode;
  528. nodeclass[niln]:=cnilnode;
  529. nodeclass[errorn]:=cerrornode;
  530. nodeclass[typen]:=ctypenode;
  531. nodeclass[setelementn]:=csetelementnode;
  532. nodeclass[setconstn]:=csetconstnode;
  533. nodeclass[blockn]:=cblocknode;
  534. nodeclass[statementn]:=cstatementnode;
  535. nodeclass[ifn]:=cifnode;
  536. nodeclass[breakn]:=cbreaknode;
  537. nodeclass[continuen]:=ccontinuenode;
  538. nodeclass[whilerepeatn]:=cwhilerepeatnode;
  539. nodeclass[forn]:=cfornode;
  540. nodeclass[exitn]:=cexitnode;
  541. nodeclass[withn]:=cwithnode;
  542. nodeclass[casen]:=ccasenode;
  543. nodeclass[labeln]:=clabelnode;
  544. nodeclass[goton]:=cgotonode;
  545. nodeclass[tryexceptn]:=ctryexceptnode;
  546. nodeclass[raisen]:=craisenode;
  547. nodeclass[tryfinallyn]:=ctryfinallynode;
  548. nodeclass[onn]:=connode;
  549. nodeclass[isn]:=cisnode;
  550. nodeclass[asn]:=casnode;
  551. nodeclass[starstarn]:=caddnode;
  552. nodeclass[arrayconstructorn]:=carrayconstructornode;
  553. nodeclass[arrayconstructorrangen]:=carrayconstructorrangenode;
  554. nodeclass[tempcreaten]:=ctempcreatenode;
  555. nodeclass[temprefn]:=ctemprefnode;
  556. nodeclass[tempdeleten]:=ctempdeletenode;
  557. nodeclass[addoptn]:=caddnode;
  558. nodeclass[nothingn]:=cnothingnode;
  559. nodeclass[loadvmtaddrn]:=cloadvmtaddrnode;
  560. nodeclass[guidconstn]:=cguidconstnode;
  561. nodeclass[rttin]:=crttinode;
  562. nodeclass[loadparentfpn]:=cloadparentfpnode;
  563. end;
  564. procedure registertais;
  565. {
  566. Register all possible tais in the taiclass array that
  567. will be used for loading the tais from a ppu
  568. }
  569. begin
  570. aiclass[ait_none]:=nil;
  571. aiclass[ait_align]:=tai_align;
  572. aiclass[ait_section]:=tai_section;
  573. aiclass[ait_comment]:=tai_comment;
  574. aiclass[ait_string]:=tai_string;
  575. aiclass[ait_instruction]:=taicpu;
  576. aiclass[ait_datablock]:=tai_datablock;
  577. aiclass[ait_symbol]:=tai_symbol;
  578. aiclass[ait_symbol_end]:=tai_symbol_end;
  579. aiclass[ait_directive]:=tai_directive;
  580. aiclass[ait_label]:=tai_label;
  581. aiclass[ait_const]:=tai_const;
  582. aiclass[ait_real_32bit]:=tai_real_32bit;
  583. aiclass[ait_real_64bit]:=tai_real_64bit;
  584. aiclass[ait_real_80bit]:=tai_real_80bit;
  585. aiclass[ait_comp_64bit]:=tai_comp_64bit;
  586. aiclass[ait_stab]:=tai_stab;
  587. aiclass[ait_force_line]:=tai_force_line;
  588. aiclass[ait_function_name]:=tai_function_name;
  589. aiclass[ait_ent]:=tai_ent;
  590. aiclass[ait_ent_end]:=tai_ent_end;
  591. {$ifdef alpha}
  592. { the follow is for the DEC Alpha }
  593. aiclass[ait_frame]:=tai_frame;
  594. {$endif alpha}
  595. {$ifdef m68k}
  596. { TODO: FIXME: tai_labeled_instruction doesn't exists}
  597. // aiclass[ait_labeled_instruction]:=tai_labeled_instruction;
  598. {$endif m68k}
  599. {$ifdef ia64}
  600. aiclass[ait_bundle]:=tai_bundle;
  601. aiclass[ait_stop]:=tai_stop;
  602. {$endif ia64}
  603. {$ifdef SPARC}
  604. // aiclass[ait_labeled_instruction]:=tai_labeled_instruction;
  605. {$endif SPARC}
  606. {$ifdef arm}
  607. aiclass[ait_thumb_func]:=tai_thumb_func;
  608. aiclass[ait_thumb_set]:=tai_thumb_set;
  609. {$endif arm}
  610. aiclass[ait_set]:=tai_set;
  611. aiclass[ait_weak]:=tai_weak;
  612. aiclass[ait_cutobject]:=tai_cutobject;
  613. aiclass[ait_regalloc]:=tai_regalloc;
  614. aiclass[ait_tempalloc]:=tai_tempalloc;
  615. aiclass[ait_marker]:=tai_marker;
  616. aiclass[ait_seh_directive]:=tai_seh_directive;
  617. {$ifdef JVM}
  618. aiclass[ait_jvar]:=tai_jvar;
  619. aiclass[ait_jcatch]:=tai_jcatch;
  620. {$endif JVM}
  621. end;
  622. end.