symconst.pas 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl, Pierre Muller
  3. Symbol table constants
  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 symconst;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. globtype;
  22. const
  23. def_alignment = 4;
  24. C_alignment = -1;
  25. bit_alignment = -2;
  26. mac68k_alignment = -3;
  27. { if you change one of the following contants, }
  28. { you have also to change the typinfo unit}
  29. { and the rtl/i386,template/rttip.inc files }
  30. tkUnknown = 0;
  31. tkInteger = 1;
  32. tkChar = 2;
  33. tkEnumeration = 3;
  34. tkFloat = 4;
  35. tkSet = 5;
  36. tkMethod = 6;
  37. tkSString = 7;
  38. tkString = tkSString;
  39. tkLString = 8;
  40. tkAString = 9;
  41. tkWString = 10;
  42. tkVariant = 11;
  43. tkArray = 12;
  44. tkRecord = 13;
  45. tkInterface= 14;
  46. tkClass = 15;
  47. tkObject = 16;
  48. tkWChar = 17;
  49. tkBool = 18;
  50. tkInt64 = 19;
  51. tkQWord = 20;
  52. tkDynArray = 21;
  53. tkInterfaceCorba = 22;
  54. tkProcVar = 23;
  55. tkUString = 24;
  56. tkUChar = 25;
  57. tkHelper = 26;
  58. tkFile = 27;
  59. tkClassRef = 28;
  60. tkPointer = 29;
  61. otSByte = 0;
  62. otUByte = 1;
  63. otSWord = 2;
  64. otUWord = 3;
  65. otSLong = 4;
  66. otULong = 5;
  67. otSQWord = 6;
  68. otUQWord = 7;
  69. ftSingle = 0;
  70. ftDouble = 1;
  71. ftExtended = 2;
  72. ftComp = 3;
  73. ftCurr = 4;
  74. ftFloat128 = 5;
  75. mkProcedure = 0;
  76. mkFunction = 1;
  77. mkConstructor = 2;
  78. mkDestructor = 3;
  79. mkClassProcedure = 4;
  80. mkClassFunction = 5;
  81. mkClassConstructor = 6;
  82. mkClassDestructor = 7;
  83. mkOperatorOverload = 8;
  84. // delphi has the next too:
  85. //mkSafeProcedure = 9;
  86. //mkSafeFunction = 10;
  87. pfvar = 1;
  88. pfConst = 2;
  89. pfArray = 4;
  90. pfAddress = 8;
  91. pfReference= 16;
  92. pfOut = 32;
  93. pfConstRef = 64;
  94. pfHidden = 128;
  95. pfHigh = 256;
  96. pfSelf = 512;
  97. pfVmt = 1024;
  98. pfResult = 2048;
  99. riifNonTrivialChild = 1;
  100. riifParentHasNonTrivialChild = 2;
  101. unknown_level = 0;
  102. main_program_level = 1;
  103. normal_function_level = 2;
  104. { implicit parameter positions, normal parameters start at 10
  105. and will increase with 10 for each parameter. The high parameters
  106. will be inserted with n+1 }
  107. paranr_blockselfpara = 1;
  108. paranr_parentfp_delphi_cc_leftright = 2;
  109. {$if defined(aarch64) and defined(llvm)}
  110. { for AArch64 on LLVM, the "sret" parameter must always be the first
  111. (it gets passed in a dedicated register, so it won't shift the register
  112. assignments) -> give it a lower number; can't do it for other platforms,
  113. because that would change the register assignment/parameter order }
  114. paranr_result = 2;
  115. paranr_parentfp = 3;
  116. paranr_self = 4;
  117. {$else}
  118. paranr_parentfp = 2;
  119. paranr_self = 3;
  120. paranr_result = 4;
  121. {$endif}
  122. { pointers to managed result parameters must always be passed in the same way as the first regular
  123. parameter, regardless of ABI conventions, because the RTL expects the two following declarations
  124. to be handled in the same way:
  125. function f: com_interface;
  126. procedure p(out o: obj);
  127. }
  128. paranr_result_managed = 5;
  129. paranr_vmt = 6;
  130. { the implicit parameters for Objective-C methods need to come
  131. after the hidden result parameter }
  132. paranr_objc_self = 7;
  133. paranr_objc_cmd = 8;
  134. { Required to support variations of syscalls on Amiga-likes }
  135. paranr_syscall_lib_first = 9; { for basefirst on MorphOS/ppc and AmigaOS4/ppc }
  136. paranr_syscall_lib_last = high(word)-3; { everything else }
  137. paranr_result_leftright = high(word)-2;
  138. paranr_parentfp_delphi_cc = high(word)-1;
  139. { prefix for names of class helper procsyms added to regular symtables }
  140. class_helper_prefix = 'CH$';
  141. { name of the Invoke method of a function reference interface }
  142. method_name_funcref_invoke_decl = 'Invoke';
  143. method_name_funcref_invoke_find = 'INVOKE';
  144. { tsym.symid value in case the sym has not yet been registered }
  145. symid_not_registered = -2;
  146. { tsym.symid value in case the sym has been registered, but not put in a
  147. symtable }
  148. symid_registered_nost = -1;
  149. { tdef.defid value in case the def has not yet been registered }
  150. defid_not_registered = -2;
  151. { tdef.defid value in case the sym has been registered, but not put in a
  152. symtable }
  153. defid_registered_nost = -1;
  154. type
  155. { keep this in sync with TIntfFlag in rtl/objpas/typinfo.pp }
  156. TCompilerIntfFlag = (ifHasGuid,ifDispInterface,ifDispatch,ifHasStrGUID);
  157. { Deref entry options }
  158. tdereftype = (deref_nil,
  159. deref_unit,
  160. deref_symid,
  161. deref_defid
  162. );
  163. { symbol visibility }
  164. tvisibility=(
  165. vis_hidden,
  166. vis_strictprivate,
  167. vis_private,
  168. vis_strictprotected,
  169. vis_protected,
  170. vis_public,
  171. vis_published,
  172. vis_none
  173. );
  174. tvisibilities=set of tvisibility;
  175. { symbol options }
  176. tsymoption=(sp_none,
  177. sp_static, { static symbol in class/object/record }
  178. sp_hint_deprecated,
  179. sp_hint_platform,
  180. sp_hint_library,
  181. sp_hint_unimplemented,
  182. sp_has_overloaded,
  183. sp_internal, { internal symbol, not reported as unused }
  184. sp_implicitrename,
  185. sp_hint_experimental,
  186. sp_generic_para,
  187. sp_has_deprecated_msg,
  188. sp_generic_dummy, { this is used for symbols that are generated when a
  189. generic is encountered to ease inline
  190. specializations, etc; those symbols can be
  191. "overridden" with a completely different symbol }
  192. sp_explicitrename, { this is used to keep track of type renames created
  193. by the user }
  194. sp_generic_const,
  195. sp_generic_unnamed_type { type symbol created for an anonymous type during
  196. an implicit function specialization }
  197. );
  198. tsymoptions=set of tsymoption;
  199. { flags for a definition }
  200. tdefoption=(df_none,
  201. { type is unique, i.e. declared with type = type <tdef>; }
  202. df_unique,
  203. { type is a generic }
  204. df_generic,
  205. { type is a specialization of a generic type }
  206. df_specialization,
  207. { def has been copied from another def so symtable is not owned }
  208. df_copied_def,
  209. { def was created as a generic constraint and thus is only "shallow" }
  210. df_genconstraint,
  211. { don't free def after finishing the implementation section even if it
  212. wasn't written to the ppu, as this def may still be referred (e.g. because
  213. it was used to set the type of a paraloc, since paralocs are reused
  214. across units) -- never stored to ppu, because in that case the def would
  215. be registered }
  216. df_not_registered_no_free,
  217. { don't pack this record at the llvm level -- can't do this via symllvm
  218. because we have to access this information in the symtable unit }
  219. df_llvm_no_struct_packing,
  220. { internal def that's not for any export }
  221. df_internal,
  222. { the local def is referenced from a public function }
  223. df_has_global_ref,
  224. { the def was derived with generic type or const fields so the size
  225. of the def can not be determined }
  226. df_has_generic_fields,
  227. { never use the typename for this type, always expand full definition }
  228. df_llvm_no_typename
  229. );
  230. tdefoptions=set of tdefoption;
  231. tdefstate=(ds_none,
  232. ds_vmt_written,
  233. ds_rtti_table_used,
  234. ds_init_table_used,
  235. ds_rtti_table_written,
  236. ds_init_table_written,
  237. ds_dwarf_dbg_info_used,
  238. ds_dwarf_dbg_info_written
  239. );
  240. tdefstates=set of tdefstate;
  241. { flags for generic type constraints }
  242. tgenericconstraintflag=(gcf_none,
  243. gcf_constructor, { specialization type needs to have a constructor }
  244. gcf_class, { specialization type needs to be a class }
  245. gcf_record { specialization type needs to be a record type }
  246. );
  247. tgenericconstraintflags=set of tgenericconstraintflag;
  248. { tsymlist entry types }
  249. tsltype = (sl_none,
  250. sl_load,
  251. sl_call,
  252. sl_subscript,
  253. sl_vec,
  254. sl_typeconv,
  255. sl_absolutetype
  256. );
  257. { base types for orddef }
  258. tordtype = (
  259. uvoid,
  260. u8bit,u16bit,u32bit,u64bit,u128bit,
  261. s8bit,s16bit,s32bit,s64bit,s128bit,
  262. pasbool1,pasbool8,pasbool16,pasbool32,pasbool64,
  263. bool8bit,bool16bit,bool32bit,bool64bit,
  264. uchar,uwidechar,scurrency,customint
  265. );
  266. tordtypeset = set of tordtype;
  267. { string types }
  268. tstringtype = (
  269. st_shortstring,
  270. st_longstring,
  271. st_ansistring,
  272. st_widestring,
  273. st_unicodestring
  274. );
  275. tvarianttype = (
  276. vt_normalvariant,vt_olevariant
  277. );
  278. tcallercallee = (callnoside,callerside,calleeside,callbothsides);
  279. { basic type for tprocdef and tprocvardef }
  280. tproctypeoption=(potype_none,
  281. potype_proginit, { Program initialization }
  282. potype_unitinit, { unit initialization }
  283. potype_unitfinalize, { unit finalization }
  284. potype_constructor, { Procedure is a constructor }
  285. potype_destructor, { Procedure is a destructor }
  286. potype_operator, { Procedure defines an operator }
  287. potype_procedure,
  288. potype_function,
  289. potype_class_constructor, { class constructor }
  290. potype_class_destructor, { class destructor }
  291. potype_propgetter, { Dispinterface property accessors }
  292. potype_propsetter,
  293. potype_exceptfilter, { SEH exception filter or termination handler }
  294. potype_mainstub, { "main" function that calls through to FPC_SYSTEMMAIN }
  295. potype_pkgstub, { stub for a package file, that tells OS that all is OK }
  296. potype_libmainstub { "main" function for a library that calls through to FPC_LIBMAIN }
  297. );
  298. tproctypeoptions=set of tproctypeoption;
  299. { other options for tprocdef and tprocvardef }
  300. tprocoption=(po_none,
  301. po_classmethod, { class method }
  302. po_virtualmethod, { Procedure is a virtual method }
  303. po_abstractmethod, { Procedure is an abstract method }
  304. po_finalmethod, { Procedure is a final method }
  305. po_staticmethod, { static method }
  306. po_overridingmethod, { method with override directive }
  307. po_methodpointer, { method pointer, only in procvardef, also used for 'with object do'
  308. and anonymous functions assigned to method pointers }
  309. po_interrupt, { Procedure is an interrupt handler }
  310. po_iocheck, { IO checking should be done after a call to the procedure }
  311. po_assembler, { Procedure is written in assembler }
  312. po_msgstr, { method for string message handling }
  313. po_msgint, { method for int message handling }
  314. po_exports, { Procedure has export directive (needed for OS/2) }
  315. po_external, { Procedure is external (in other object or lib)}
  316. po_overload, { procedure is declared with overload directive }
  317. po_varargs, { printf like arguments }
  318. po_internconst, { procedure has constant evaluator intern }
  319. { flag that only the address of a method is returned and not a full methodpointer }
  320. po_addressonly,
  321. { procedure is exported }
  322. po_public,
  323. { calling convention is specified explicitly }
  324. po_hascallingconvention,
  325. { reintroduce flag }
  326. po_reintroduce,
  327. { location of parameters is given explicitly as it is necessary for some syscall
  328. conventions like that one of MorphOS }
  329. po_explicitparaloc,
  330. { no stackframe will be generated, used by lowlevel assembler like get_frame }
  331. po_nostackframe,
  332. po_has_mangledname,
  333. po_has_public_name,
  334. po_forward,
  335. po_global,
  336. { Generic syscall procoption, for systems like Atari, Palm, etc }
  337. po_syscall,
  338. { The different kind of syscalls on Amiga-like systems }
  339. po_syscall_legacy,
  340. po_syscall_basenone,
  341. po_syscall_basefirst,
  342. po_syscall_baselast,
  343. po_syscall_basereg,
  344. { Used to record the fact that a symbol is associated to this syscall }
  345. po_syscall_has_libsym,
  346. { Syscall uses the import Nr. }
  347. po_syscall_has_importnr,
  348. { Procedure can be inlined }
  349. po_inline,
  350. { Procedure is used for internal compiler calls }
  351. po_compilerproc,
  352. { importing }
  353. po_has_importdll,
  354. po_has_importname,
  355. po_kylixlocal,
  356. po_dispid,
  357. { weakly linked (i.e., may or may not exist at run time) }
  358. po_weakexternal,
  359. { Objective-C method }
  360. po_objc,
  361. { enumerator support }
  362. po_enumerator_movenext,
  363. { optional Objective-C protocol method }
  364. po_optional,
  365. { nested procedure that uses Delphi-style calling convention for passing
  366. the frame pointer (pushed on the stack, always the last parameter,
  367. removed by the caller). Required for nested procvar compatibility,
  368. because such procvars can hold both regular and nested procedures
  369. (when calling a regular procedure using the above convention, it will
  370. simply not see the frame pointer parameter, and since the caller cleans
  371. up the stack will also remain balanced) }
  372. po_delphi_nested_cc,
  373. { allows the routine's RawByteString var/out parameters to accept parameters
  374. that do not match exactly (without typeconversion) }
  375. po_rtlproc,
  376. { Non-virtual method of a Java class that has been transformed into a
  377. "virtual; final;" method for JVM-implementation reasons }
  378. po_java_nonvirtual,
  379. { automatically inherited routine from parent class, ignore for resolving
  380. overloads (on the JVM target, constructors are not automatically
  381. inherited, so we explicitly have to add the constructors of the parent
  382. class to the child class; this influences the overload resolution logic
  383. though, so ignore them there) }
  384. po_ignore_for_overload_resolution,
  385. { the visibility of of this procdef was raised automatically by the
  386. compiler, e.g. because it was designated as a getter/setter for a property
  387. with a higher visibility on the JVM target }
  388. po_auto_raised_visibility,
  389. { procedure is far (x86 only) }
  390. po_far,
  391. { near/far call model is specified explicitly (x86 only) }
  392. po_hasnearfarcallmodel,
  393. { the procedure never returns, this information is usefull for dfa }
  394. po_noreturn,
  395. { procvar is a function reference }
  396. po_is_function_ref,
  397. { procvar is a block (http://en.wikipedia.org/wiki/Blocks_(C_language_extension) ) }
  398. po_is_block,
  399. { procedure is an automatically generated property getter }
  400. po_is_auto_getter,
  401. { procedure is an automatically generated property setter }
  402. po_is_auto_setter,
  403. { must never be inlined by auto-inlining }
  404. po_noinline,
  405. { same as po_varargs, but with an array-of-const parameter instead of with the
  406. "varargs" modifier or Mac-Pascal ".." parameter }
  407. po_variadic,
  408. { implicitly return same type as the class instance to which the message is sent }
  409. po_objc_related_result_type,
  410. { Delphi-style anonymous function }
  411. po_anonymous,
  412. { WebAssembly funcref reference type (an opaque reference to a function, that
  413. is managed by the host. It doesn't have an in-memory representation, which
  414. means it cannot be stored in linear memory or have its address taken. It can
  415. however be stored in WebAssembly globals, locals, used in function parameters
  416. and returns and it can be called.) }
  417. po_wasm_funcref,
  418. { WebAssembly suspending external }
  419. po_wasm_suspending
  420. );
  421. tprocoptions=set of tprocoption;
  422. { options that should not trigger the recompilation of a unit if they change
  423. between the interface and the implementation }
  424. timplprocoption = (
  425. { the routine contains no code }
  426. pio_empty,
  427. { the inline body of this routine is available }
  428. pio_has_inlininginfo,
  429. { inline is not possible (has assembler block, etc) }
  430. pio_inline_not_possible,
  431. { a nested routine accesses a local variable from this routine }
  432. pio_nested_access,
  433. { a stub/thunk }
  434. pio_thunk,
  435. { compiled with fastmath enabled }
  436. pio_fastmath,
  437. { inline is forbidden (calls get_frame) }
  438. pio_inline_forbidden
  439. );
  440. timplprocoptions = set of timplprocoption;
  441. { kinds of synthetic procdefs that can be generated }
  442. tsynthetickind = (
  443. tsk_none,
  444. tsk_anon_inherited, // anonymous inherited call
  445. tsk_jvm_clone, // Java-style clone method
  446. tsk_record_deepcopy, // deepcopy for records field by field
  447. tsk_record_initialize, // initialize for records field by field (explicit rather than via rtti)
  448. tsk_empty, // an empty routine
  449. tsk_tcinit, // initialisation of typed constants
  450. tsk_callthrough, // call through to another routine with the same parameters/return type (its def is stored in the skpara field)
  451. tsk_callthrough_nonabstract,// call through to another routine if the current class not abstract (otherwise do the same as tsk_empty)
  452. tsk_jvm_enum_values, // Java "values" class method of JLEnum descendants
  453. tsk_jvm_enum_valueof, // Java "valueOf" class method of JLEnum descendants
  454. tsk_jvm_enum_classconstr, // Java class constructor for JLEnum descendants
  455. tsk_jvm_enum_jumps_constr, // Java constructor for JLEnum descendants for enums with jumps
  456. tsk_jvm_enum_fpcordinal, // Java FPCOrdinal function that returns the enum's ordinal value from an FPC POV
  457. tsk_jvm_enum_fpcvalueof, // Java FPCValueOf function that returns the enum instance corresponding to an ordinal from an FPC POV
  458. tsk_jvm_enum_long2set, // Java fpcLongToEnumSet function that returns an enumset corresponding to a bit pattern in a jlong
  459. tsk_jvm_enum_bitset2set, // Java fpcBitSetToEnumSet function that returns an enumset corresponding to a BitSet
  460. tsk_jvm_enum_set2Set, // Java fpcEnumSetToEnumSet function that returns an enumset corresponding to another enumset (different enum kind)
  461. tsk_jvm_procvar_invoke, // Java invoke method that calls a wrapped procvar
  462. tsk_jvm_procvar_intconstr, // Java procvar class constructor that accepts an interface instance for easy Java interoperation
  463. tsk_jvm_virtual_clmethod, // Java wrapper for virtual class method
  464. tsk_field_getter, // getter for a field (callthrough property is passed in skpara)
  465. tsk_field_setter, // Setter for a field (callthrough property is passed in skpara)
  466. tsk_block_invoke_procvar, // Call a procvar to invoke inside a block
  467. tsk_interface_wrapper, // Call through to a method from an interface wrapper
  468. tsk_call_no_parameters, // Call skpara procedure without passing any parameters nor returning a result
  469. tsk_wasm_suspending_first, // WebAssembly suspending external wrapper, suspender object is first argument
  470. tsk_wasm_suspending_last, // WebAssembly suspending external wrapper, suspender object is last argument
  471. tsk_wasm_promising, // WebAssembly promising export wrapper
  472. tsk_invoke_helper // Method invoke helper, primarily used in WebAssembly.
  473. );
  474. { synthetic procdef supplementary information (tprocdef.skpara) }
  475. tskpara_interface_wrapper = record
  476. pd: pointer;
  477. offset: longint;
  478. end;
  479. pskpara_interface_wrapper = ^tskpara_interface_wrapper;
  480. { options for objects and classes }
  481. tobjecttyp = (odt_none,
  482. odt_class,
  483. odt_object,
  484. odt_interfacecom,
  485. odt_interfacecom_property,
  486. odt_interfacecom_function,
  487. odt_interfacecorba,
  488. odt_cppclass,
  489. odt_dispinterface,
  490. odt_objcclass,
  491. odt_objcprotocol,
  492. odt_objccategory, { note that these are changed into odt_class afterwards }
  493. odt_helper,
  494. odt_javaclass,
  495. odt_interfacejava
  496. );
  497. { defines the type of the extended "structure"; only used for parsing }
  498. thelpertype=(ht_none,
  499. ht_class,
  500. ht_record,
  501. ht_type
  502. );
  503. { Variations in interfaces implementation }
  504. { Beware, this data is duplicated in the compiler and rtl. }
  505. { Do not change the order of the fields. }
  506. tinterfaceentrytype = (etStandard,
  507. etVirtualMethodResult,
  508. etStaticMethodResult,
  509. etFieldValue,
  510. etVirtualMethodClass,
  511. etStaticMethodClass,
  512. etFieldValueClass
  513. );
  514. { options for objects and classes }
  515. tobjectoption=(oo_none,
  516. oo_is_forward, { the class is only a forward declared yet }
  517. oo_is_abstract, { the class is abstract - only descendants can be used }
  518. oo_is_sealed, { the class is sealed - can't have descendants }
  519. oo_has_virtual, { the object/class has virtual methods }
  520. oo_has_private,
  521. oo_has_protected,
  522. oo_has_strictprivate,
  523. oo_has_strictprotected,
  524. oo_has_constructor, { the object/class has a constructor }
  525. oo_has_destructor, { the object/class has a destructor }
  526. oo_has_vmt, { the object/class has a vmt }
  527. oo_has_msgstr,
  528. oo_has_msgint,
  529. oo_can_have_published,{ the class has rtti, i.e. you can publish properties }
  530. oo_has_default_property,
  531. oo_has_valid_guid,
  532. oo_has_enumerator_movenext,
  533. oo_has_enumerator_current,
  534. oo_is_external, { the class is externally implemented (objcclass, cppclass) }
  535. oo_is_formal, { the class is only formally defined in this module (x = objcclass; external [name 'x'];) }
  536. oo_is_classhelper, { objcclasses that represent categories, and Delpi-style class helpers, are marked like this }
  537. oo_has_class_constructor, { the object/class has a class constructor }
  538. oo_has_class_destructor, { the object/class has a class destructor }
  539. oo_is_enum_class, { the class represents an enum (JVM) }
  540. oo_has_new_destructor,{ the object/class declares a destructor (apart from potentially inherting one from the parent) }
  541. oo_is_funcref, { interface has a single Invoke method that can be directly called }
  542. oo_is_invokable, { interface that is invokable like a function }
  543. oo_is_capturer, { the class is the capturer for anonymous functions (or converted proc(var)s) }
  544. oo_inherits_not_specialized { the class inherits from a not yet specialized type }
  545. );
  546. tobjectoptions=set of tobjectoption;
  547. tarraydefoption=(
  548. ado_IsConvertedPointer, // array created from pointer (e.g. PInteger(Ptr)[1])
  549. ado_IsDynamicArray, // dynamic array
  550. ado_IsVariant, //
  551. ado_IsConstructor, // array constructor (e.g. something = [1,2,3])
  552. ado_IsArrayOfConst, // array of const
  553. ado_IsConstString, // string constant
  554. ado_IsBitPacked, // bitpacked array
  555. ado_IsVector, // Vector
  556. ado_IsGeneric, // the index of the array is generic (meaning that the size is not yet known)
  557. ado_OpenArray // open array, replaces the old hack with high being -1 for an open array:
  558. // this is still true, but this flag is set as well
  559. );
  560. tarraydefoptions=set of tarraydefoption;
  561. { options for properties }
  562. tpropertyoption=(ppo_none,
  563. ppo_indexed, { delcared wwith "index" keyword }
  564. ppo_defaultproperty,
  565. ppo_stored,
  566. ppo_hasparameters, { has parameters: prop[param1, param2: type] }
  567. ppo_implements,
  568. ppo_enumerator_current, { implements current property for enumerator }
  569. ppo_overrides, { overrides ancestor property }
  570. ppo_dispid_write { no longer used }
  571. );
  572. tpropertyoptions=set of tpropertyoption;
  573. { options for variables }
  574. tvaroption=(vo_none,
  575. vo_is_external,
  576. vo_is_dll_var,
  577. vo_is_thread_var,
  578. vo_has_local_copy,
  579. vo_is_const, { variable is declared as const (parameter) and can't be written to }
  580. vo_is_public,
  581. vo_is_high_para,
  582. vo_is_funcret,
  583. vo_is_self,
  584. vo_is_vmt,
  585. vo_is_result, { special result variable }
  586. vo_is_parentfp,
  587. vo_is_loop_counter, { used to detect assignments to loop counter }
  588. vo_is_hidden_para,
  589. vo_has_explicit_paraloc,
  590. vo_is_syscall_lib,
  591. vo_has_mangledname,
  592. vo_is_typed_const,
  593. vo_is_range_check,
  594. vo_is_overflow_check,
  595. vo_is_typinfo_para,
  596. vo_is_weak_external,
  597. { Objective-C message selector parameter }
  598. vo_is_msgsel,
  599. { first field of variant part of a record }
  600. vo_is_first_field,
  601. vo_volatile,
  602. vo_has_section,
  603. { variable contains a winlike WideString which should be finalized
  604. even in $J- state }
  605. vo_force_finalize,
  606. { this is an internal variable that is used for Default() intrinsic in code
  607. sections }
  608. vo_is_default_var,
  609. { i8086 'external far' (can only be used in combination with vo_is_external) }
  610. vo_is_far,
  611. { a static symbol that is referenced from a global function }
  612. vo_has_global_ref,
  613. vo_is_internal
  614. );
  615. tvaroptions=set of tvaroption;
  616. { variable symbol access flags }
  617. tvarsymaccessflag = (
  618. { this symbol's address has been taken }
  619. vsa_addr_taken,
  620. { this symbol is accessed from a different scope }
  621. vsa_different_scope
  622. );
  623. tvarsymaccessflags = set of tvarsymaccessflag;
  624. tmanagementoperator=(mop_none,
  625. mop_initialize,
  626. mop_finalize,
  627. mop_addref,
  628. mop_copy
  629. );
  630. tmanagementoperators=set of tmanagementoperator;
  631. { register variable }
  632. tvarregable=(vr_none,
  633. vr_intreg,
  634. vr_fpureg,
  635. vr_mmreg,
  636. { does not mean "needs address register", but "if it's a parameter which is }
  637. { passed by reference, then its address can be put in a register }
  638. vr_addr
  639. );
  640. { types of the symtables }
  641. TSymtabletype = (
  642. abstractsymtable, { not a real symtable }
  643. globalsymtable, { unit interface symtable }
  644. staticsymtable, { unit implementation symtable }
  645. ObjectSymtable, { object symtable }
  646. recordsymtable, { record symtable }
  647. localsymtable, { subroutine symtable }
  648. parasymtable, { arguments symtable }
  649. withsymtable, { with operator symtable }
  650. exceptsymtable, { try/except symtable }
  651. exportedmacrosymtable, { }
  652. localmacrosymtable, { }
  653. enumsymtable, { symtable for enum members }
  654. arraysymtable { used to store parameterised type
  655. in array }
  656. );
  657. { options for symtables }
  658. tsymtableoption = (
  659. sto_has_helper, { contains at least one helper symbol }
  660. sto_has_generic, { contains at least one generic symbol }
  661. sto_has_operator, { contains at least one operator overload }
  662. sto_needs_init_final, { the symtable needs initialization and/or
  663. finalization of variables/constants }
  664. sto_has_non_trivial_init { contains at least on managed type that is not
  665. initialized to zero (e.g. a record with management
  666. operators }
  667. );
  668. tsymtableoptions = set of tsymtableoption;
  669. { definition contains the informations about a type }
  670. tdeftyp = (abstractdef,
  671. arraydef,recorddef,pointerdef,orddef,
  672. stringdef,enumdef,procdef,objectdef,errordef,
  673. filedef,formaldef,setdef,procvardef,floatdef,
  674. classrefdef,forwarddef,variantdef,undefineddef
  675. );
  676. { possible types for symtable entries }
  677. tsymtyp = (abstractsym,
  678. staticvarsym,localvarsym,paravarsym,fieldvarsym,
  679. typesym,procsym,unitsym,constsym,enumsym,
  680. errorsym,syssym,labelsym,absolutevarsym,propertysym,
  681. macrosym,namespacesym,undefinedsym,programparasym
  682. );
  683. { State of the variable:
  684. vs_declared: variable has been declared, not initialised
  685. (e.g. normal variable, out parameter)
  686. vs_initialised: variable has been declared and is valid
  687. (e.g. typed constant, var/const parameter)
  688. vs_read: variable has been read and the read was checked for validity
  689. (so a warning has been given if necessary)
  690. vs_read_not_warned: variable has been read, but we didn't warn about
  691. whether or not the variable was valid
  692. (e.g. read of global variable -> warn at end of compilation unit if
  693. the state is vs_read_not_warned, since that means it's only read and
  694. never written)
  695. vs_referred_not_inited: variable has been used in length/low/high/@/...
  696. expression, was not yet initialised and needn't be at that time
  697. (e.g. length() of a statically allocated array, or sizeof(variable))
  698. vs_written: variable has been assigned/written to, but not yet read
  699. (e.g. assigning something to a variable/parameter)
  700. vs_readwritten: variable has been written to and read from }
  701. tvarstate=(vs_none,
  702. vs_declared,vs_initialised,vs_read,vs_read_not_warned,
  703. vs_referred_not_inited,vs_written,vs_readwritten
  704. );
  705. tvarspez = (vs_value,vs_const,vs_var,vs_out,vs_constref,vs_final);
  706. absolutetyp = (tovar,toasm,toaddr);
  707. tconsttyp = (constnone,
  708. constord,conststring,constreal,
  709. constset,constpointer,constnil,
  710. constresourcestring,constwstring,
  711. constguid,constwresourcestring
  712. );
  713. { RTTI information to store }
  714. trttitype = (
  715. fullrtti,initrtti,
  716. { Objective-C }
  717. objcmetartti,objcmetarortti,
  718. objcclassrtti,objcclassrortti
  719. );
  720. { prefixes for internally generated type names (centralised to avoid
  721. accidental collisions) }
  722. tinternaltypeprefix = (
  723. itp_1byte,
  724. itp_emptyrec,
  725. itp_llvmstruct,
  726. itp_vmt_tstringmesssagetable,
  727. itp_vmt_msgint_table_entries,
  728. itp_vmt_tmethod_name_table,
  729. itp_vmt_intern_msgint_table,
  730. itp_vmt_intern_tmethodnamerec,
  731. itp_vmt_intern_tmethodnametable,
  732. itp_vmt_afterconstruction_local,
  733. itp_rttidef,
  734. itp_rtti_header,
  735. itp_rtti_outer,
  736. itp_rtti_case,
  737. itp_rtti_common_data,
  738. itp_rtti_prop,
  739. itp_rtti_ansistr,
  740. itp_rtti_attr_list,
  741. itp_rtti_attr_entry,
  742. itp_rtti_ord_outer,
  743. itp_rtti_ord_middle,
  744. itp_rtti_ord_inner,
  745. itp_rtti_ord_64bit,
  746. itp_rtti_normal_array,
  747. itp_rtti_normal_array_inner,
  748. itp_rtti_dyn_array,
  749. itp_rtti_dyn_array_inner,
  750. itp_rtti_pointer,
  751. itp_rtti_classref,
  752. itp_rtti_float,
  753. itp_rtti_proc_param,
  754. itp_rtti_enum_size_start_rec,
  755. itp_rtti_enum_size_start_rec2,
  756. itp_rtti_enum_min_max_rec,
  757. itp_rtti_enum_basetype_array_rec,
  758. itp_rtti_ref,
  759. itp_rtti_set_outer,
  760. itp_rtti_set_middle,
  761. itp_rtti_set_inner,
  762. itp_rtti_record,
  763. itp_rtti_record_inner,
  764. itp_init_mop_offset_entry,
  765. itp_threadvar_record,
  766. itp_objc_method_list,
  767. itp_objc_proto_list,
  768. itp_objc_cat_methods,
  769. itb_objc_nf_ivars,
  770. itb_objc_nf_category,
  771. itb_objc_nf_class_ro_part,
  772. itb_objc_nf_meta_class,
  773. itb_objc_nf_class,
  774. itb_objc_fr_protocol_ext,
  775. itb_objc_fr_protocol,
  776. itb_objc_fr_category,
  777. itb_objc_fr_meta_class,
  778. itb_objc_fr_class,
  779. itp_vardisp_calldesc,
  780. itp_extended_rtti_table,
  781. itp_extended_rtti_field
  782. );
  783. { The order is from low priority to high priority,
  784. Note: the operators > and < are used on this list }
  785. tequaltype = (
  786. te_incompatible,
  787. te_convert_operator,
  788. te_convert_l6,
  789. te_convert_l5, { ad infinitum... }
  790. te_convert_l4, { and yet even less preferred conversion }
  791. te_convert_l3, { even less preferred conversion (possibly with loss of data) }
  792. te_convert_l2, { compatible less preferred conversion }
  793. te_convert_l1, { compatible conversion }
  794. te_equal, { the definitions are equal }
  795. te_exact
  796. );
  797. tvariantequaltype = (
  798. tve_incompatible,
  799. tve_chari64,
  800. tve_sstring,
  801. tve_astring,
  802. tve_wstring,
  803. tve_ustring,
  804. tve_boolformal,
  805. tve_extended,
  806. tve_dblcurrency,
  807. tve_single,
  808. tve_cardinal,
  809. tve_longint,
  810. tve_smallint,
  811. tve_word,
  812. tve_shortint,
  813. tve_byte
  814. );
  815. tvariantequaltypes = set of tvariantequaltype;
  816. tdefdbgstatus = (
  817. dbg_state_unused,
  818. dbg_state_used,
  819. dbg_state_writing,
  820. dbg_state_written,
  821. dbg_state_queued
  822. );
  823. tx86pointertyp = (x86pt_near, x86pt_near_cs, x86pt_near_ds, x86pt_near_ss,
  824. x86pt_near_es, x86pt_near_fs, x86pt_near_gs, x86pt_far, x86pt_huge);
  825. var
  826. clearstack_pocalls : tproccalloptions;
  827. cdecl_pocalls : tproccalloptions;
  828. const
  829. {$ifndef jvm}
  830. inherited_objectoptions : tobjectoptions = [oo_has_virtual,oo_has_private,oo_has_protected,
  831. oo_has_strictprotected,oo_has_strictprivate,oo_has_constructor,oo_has_destructor,
  832. oo_can_have_published,oo_inherits_not_specialized];
  833. {$else not jvm}
  834. { constructors are not inherited in Java }
  835. inherited_objectoptions : tobjectoptions = [oo_has_virtual,oo_has_private,oo_has_protected,
  836. oo_has_strictprotected,oo_has_strictprivate,oo_has_destructor,
  837. oo_can_have_published];
  838. {$endif not jvm}
  839. {$if defined(i8086) or defined(i386)}
  840. { we only take this into account on i8086 and i386, on other platforms we always
  841. push in the same order
  842. }
  843. pushleftright_pocalls : tproccalloptions = [pocall_register,pocall_pascal];
  844. {$endif}
  845. SymTypeName : array[tsymtyp] of string[14] = (
  846. 'abstractsym','globalvar','localvar','paravar','fieldvar',
  847. 'type','proc','unit','const','enum',
  848. 'errorsym','system sym','label','absolutevar','property',
  849. 'macrosym','namespace','undefinedsym','programparasym'
  850. );
  851. typName : array[tdeftyp] of string[12] = (
  852. 'abstractdef','arraydef','recorddef','pointerdef','orddef',
  853. 'stringdef','enumdef','procdef','objectdef','errordef',
  854. 'filedef','formaldef','setdef','procvardef','floatdef',
  855. 'classrefdef','forwarddef','variantdef','undefineddef'
  856. );
  857. EqualTypeName : array[tequaltype] of string[16] = (
  858. 'incompatible','convert_operator','convert_l6', 'convert_l5','convert_l4','convert_l3',
  859. 'convert_l2','convert_l1','equal','exact'
  860. );
  861. visibilityName : array[tvisibility] of string[16] = (
  862. 'hidden','strict private','private','strict protected','protected',
  863. 'public','published',''
  864. );
  865. internaltypeprefixName : array[tinternaltypeprefix] of TSymStr = (
  866. '$1byte$',
  867. '$emptyrec',
  868. '$llvmstruct$',
  869. '$vmt_TStringMesssageTable$',
  870. '$vmt_msgint_table_entries$',
  871. '$vmt_tmethod_name_table$',
  872. '$vmt_intern_msgint_table$',
  873. '$vmt_intern_tmethodnamerec$',
  874. '$vmt_intern_tmethodnametable$',
  875. '$vmt_afterconstruction_local',
  876. '$rttidef$',
  877. '$rtti_header$',
  878. '$rtti_outer$',
  879. '$rtti_case$',
  880. '$rtti_common_data$',
  881. '$rtti_prop$',
  882. '$rtti_ansistr$',
  883. '$rtti_attr_list$',
  884. '$rtti_attr_entry$',
  885. '$rtti_ord_outer$',
  886. '$rtti_ord_middle$',
  887. '$rtti_ord_inner$',
  888. '$rtti_ord_64bit$',
  889. '$rtti_normal_array$',
  890. '$rtti_normal_array_inner$',
  891. '$rtti_dyn_array$',
  892. '$rtti_dyn_array_inner$',
  893. '$rtti_dyn_pointer$',
  894. '$rtti_dyn_classref$',
  895. '$rtti_dyn_float$',
  896. '$rtti_proc_param$',
  897. '$rtti_enum_size_start_rec$',
  898. '$rtti_enum_size_start_rec2$',
  899. '$rtti_enum_min_max_rec$',
  900. '$rtti_enum_basetype_array_rec$',
  901. '$rtti_ref$',
  902. '$rtti_set_outer$',
  903. '$rtti_set_middle$',
  904. '$rtti_set_inner$',
  905. '$rtti_record$',
  906. '$rtti_record_inner$',
  907. '$init_mop_offset_entry$',
  908. '$threadvar_record$',
  909. '$objc_method_list$',
  910. '$objc_proto_list$',
  911. '$objc_cat_methods$',
  912. '$objc_nf_ivars$',
  913. '$objc_nf_category$',
  914. '$objc_nf_class_ro_part$',
  915. '$objc_nf_meta_class$',
  916. '$objc_nf_class$',
  917. '$objc_fr_protocol_ext$',
  918. '$objc_fr_protocol$',
  919. '$objc_fr_category$',
  920. '$objc_fr_meta_class$',
  921. '$objc_fr_class$',
  922. '$itp_vardisp_calldesc$',
  923. '$extended_rtti_table$',
  924. '$extended_rtti_field$'
  925. );
  926. {$ifndef jvm}
  927. default_class_type=odt_class;
  928. {$else not jvm}
  929. default_class_type=odt_javaclass;
  930. {$endif not jvm}
  931. objecttypes_with_helpers=[odt_class,odt_interfacecom,odt_interfacecorba,odt_dispinterface];
  932. objecttypes_with_thunk=[odt_interfacecorba,odt_interfacecom];
  933. { !! Be sure to keep these in sync with ones in rtl/inc/varianth.inc }
  934. varempty = 0;
  935. varnull = 1;
  936. varsmallint = 2;
  937. varinteger = 3;
  938. varsingle = 4;
  939. vardouble = 5;
  940. varcurrency = 6;
  941. vardate = 7;
  942. varolestr = 8;
  943. vardispatch = 9;
  944. varerror = 10;
  945. varboolean = 11;
  946. varvariant = 12;
  947. varunknown = 13;
  948. vardecimal = 14;
  949. varshortint = 16;
  950. varbyte = 17;
  951. varword = 18;
  952. varlongword = 19;
  953. varint64 = 20;
  954. varqword = 21;
  955. varUndefined = -1;
  956. varstrarg = $48;
  957. varustrarg = $49;
  958. varstring = $100;
  959. varany = $101;
  960. varustring = $102;
  961. vardefmask = $fff;
  962. vararray = $2000;
  963. varbyref = $4000;
  964. { blocks-related constants }
  965. blocks_procvar_invoke_type_name = '__FPC_invoke_pvtype';
  966. { suffix for indirect symbols (AB_INDIRECT) }
  967. suffix_indirect = '$indirect';
  968. { TProcTypeOption string identifiers for error messsages }
  969. ProcTypeOptionKeywords: array[tproctypeoption] of ShortString = (
  970. 'potype_none', {potype_none}
  971. 'program initialization',{potype_proginit}
  972. '"INITIALIZATION"', {potype_unitinit}
  973. '"FINALIZATION"', {potype_unitfinalize}
  974. '"CONSTRUCTOR"', {potype_constructor}
  975. '"DESTRUCTOR"', {potype_destructor}
  976. '"OPERATOR"', {potype_operator}
  977. '"PROCEDURE"', {potype_procedure}
  978. '"FUNCTION"', {potype_function}
  979. '"CLASS CONSTRUCTOR"',{potype_class_constructor}
  980. '"CLASS DESTRUCTOR"', {potype_class_destructor}
  981. 'property getters', {potype_propgetter}
  982. 'property setters', {potype_propsetter}
  983. 'exception filters', {potype_exceptfilter}
  984. '"main" stub', {potype_mainstub}
  985. 'package stub', {potype_pkgstub}
  986. 'lib "main" stub' {potype_libmainstub}
  987. );
  988. { TProcOption string identifiers for error messages }
  989. ProcOptionKeywords: array[tprocoption] of ShortString = (
  990. 'po_none', {po_none}
  991. '"CLASS"', {po_classmethod}
  992. '"VIRTUAL"', {po_virtualmethod}
  993. '"ABSTRACT"', {po_abstractmethod}
  994. '"FINAL"', {po_finalmethod}
  995. '"STATIC"', {po_staticmethod}
  996. '"OVERRIDE"', {po_overridingmethod}
  997. 'method pointers', {po_methodpointer}
  998. '"INTERRUPT"', {po_interrupt}
  999. 'po_iocheck', {po_iocheck}
  1000. '"ASSEMBLER"', {po_assembler}
  1001. '"MESSAGE"', {po_msgstr}
  1002. '"MESSAGE"', {po_msgint}
  1003. '"EXPORT"', {po_exports}
  1004. '"EXTERNAL"', {po_external}
  1005. '"OVERLOAD"', {po_overload}
  1006. 'variable argument lists',{po_varargs}
  1007. 'po_internconst', {po_internconst}
  1008. 'po_addressonly', {po_addressonly}
  1009. '"PUBLIC"', {po_public}
  1010. 'po_hascallingconvention',{po_hascallingconvention}
  1011. '"REINTRODUCE"', {po_reintroduce}
  1012. 'po_explicitparaloc', {po_explicitparaloc}
  1013. '"NOSTACKFRAME"', {po_nostackframe}
  1014. 'po_has_mangledname', {po_has_mangledname}
  1015. 'po_has_public_name', {po_has_public_name}
  1016. '"FORWARD"', {po_forward}
  1017. 'global routines', {po_global}
  1018. '"SYSCALL"', {po_syscall}
  1019. '"SYSCALL"', {po_syscall_legacy}
  1020. '"SYSCALL"', {po_syscall_basenone}
  1021. '"SYSCALL"', {po_syscall_basefirst}
  1022. '"SYSCALL"', {po_syscall_baselast}
  1023. '"SYSCALL"', {po_syscall_basereg}
  1024. '"SYSCALL"', {po_syscall_has_libsym}
  1025. '"SYSCALL"', {po_syscall_has_importnr}
  1026. '"INLINE"', {po_inline}
  1027. '"COMPILERPROC"', {po_compilerproc}
  1028. 'po_has_importdll', {po_has_importdll}
  1029. 'po_has_importname', {po_has_importname}
  1030. 'po_kylixlocal', {po_kylixlocal}
  1031. '"DISPID"', {po_dispid}
  1032. 'po_weakexternal', {po_weakexternal}
  1033. 'po_objc', {po_objc}
  1034. 'po_enumerator_movenext',{po_enumerator_movenext}
  1035. 'po_optional', {po_optional}
  1036. 'po_delphi_nested_cc',{po_delphi_nested_cc}
  1037. 'RTL procedures', {po_rtlproc}
  1038. 'non-virtual Java methods',{po_java_nonvirtual}
  1039. 'po_ignore_for_overload_resolution',{po_ignore_for_overload_resolution}
  1040. 'po_auto_raised_visibility',{po_auto_raised_visibility}
  1041. '"FAR"', {po_far}
  1042. 'po_hasnearfarcallmodel',{po_hasnearfarcallmodel}
  1043. '"NORETURN"',{po_noreturn}
  1044. 'po_is_function_ref',{po_is_function_ref}
  1045. 'C-style blocks',{po_is_block}
  1046. 'po_is_auto_getter',{po_is_auto_getter}
  1047. 'po_is_auto_setter',{po_is_auto_setter}
  1048. 'po_noinline',{po_noinline}
  1049. 'C-style array-of-const', {po_variadic}
  1050. 'objc-related-result-type', {po_objc_related_result_type}
  1051. 'po_anonymous', {po_anonymous}
  1052. '"WASMFUNCREF"', {po_wasm_funcref}
  1053. '"SUSPENDING"' {po_wasm_suspending}
  1054. );
  1055. implementation
  1056. end.