symconst.pas 36 KB

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