types.pas 76 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146
  1. {
  2. $Id$
  3. Copyright (C) 1998-2000 by Florian Klaempfl
  4. This unit provides some help routines for type handling
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit types;
  19. {$i defines.inc}
  20. interface
  21. uses
  22. cclasses,
  23. cpuinfo,
  24. node,
  25. symconst,symbase,symtype,symdef,symsym;
  26. type
  27. tmmxtype = (mmxno,mmxu8bit,mmxs8bit,mmxu16bit,mmxs16bit,
  28. mmxu32bit,mmxs32bit,mmxfixed16,mmxsingle);
  29. const
  30. { true if we must never copy this parameter }
  31. never_copy_const_param : boolean = false;
  32. {*****************************************************************************
  33. Basic type functions
  34. *****************************************************************************}
  35. { returns true, if def defines an ordinal type }
  36. function is_ordinal(def : tdef) : boolean;
  37. { returns the min. value of the type }
  38. function get_min_value(def : tdef) : longint;
  39. { returns basetype of the specified range }
  40. function range_to_basetype(low,high:TConstExprInt):tbasetype;
  41. { returns true, if def defines an ordinal type }
  42. function is_integer(def : tdef) : boolean;
  43. { true if p is a boolean }
  44. function is_boolean(def : tdef) : boolean;
  45. { true if p is a char }
  46. function is_char(def : tdef) : boolean;
  47. { true if p is a widechar }
  48. function is_widechar(def : tdef) : boolean;
  49. { true if p is a void}
  50. function is_void(def : tdef) : boolean;
  51. { true if p is a smallset def }
  52. function is_smallset(p : tdef) : boolean;
  53. { returns true, if def defines a signed data type (only for ordinal types) }
  54. function is_signed(def : tdef) : boolean;
  55. {*****************************************************************************
  56. Array helper functions
  57. *****************************************************************************}
  58. { true, if p points to a zero based (non special like open or
  59. dynamic array def, mainly this is used to see if the array
  60. is convertable to a pointer }
  61. function is_zero_based_array(p : tdef) : boolean;
  62. { true if p points to an open array def }
  63. function is_open_array(p : tdef) : boolean;
  64. { true if p points to a dynamic array def }
  65. function is_dynamic_array(p : tdef) : boolean;
  66. { true, if p points to an array of const def }
  67. function is_array_constructor(p : tdef) : boolean;
  68. { true, if p points to a variant array }
  69. function is_variant_array(p : tdef) : boolean;
  70. { true, if p points to an array of const }
  71. function is_array_of_const(p : tdef) : boolean;
  72. { true, if p points any kind of special array }
  73. function is_special_array(p : tdef) : boolean;
  74. { true if p is a char array def }
  75. function is_chararray(p : tdef) : boolean;
  76. { true if p is a wide char array def }
  77. function is_widechararray(p : tdef) : boolean;
  78. {*****************************************************************************
  79. String helper functions
  80. *****************************************************************************}
  81. { true if p points to an open string def }
  82. function is_open_string(p : tdef) : boolean;
  83. { true if p is an ansi string def }
  84. function is_ansistring(p : tdef) : boolean;
  85. { true if p is a long string def }
  86. function is_longstring(p : tdef) : boolean;
  87. { true if p is a wide string def }
  88. function is_widestring(p : tdef) : boolean;
  89. { true if p is a short string def }
  90. function is_shortstring(p : tdef) : boolean;
  91. { true if p is a pchar def }
  92. function is_pchar(p : tdef) : boolean;
  93. { true if p is a pwidechar def }
  94. function is_pwidechar(p : tdef) : boolean;
  95. { true if p is a voidpointer def }
  96. function is_voidpointer(p : tdef) : boolean;
  97. { returns true, if def uses FPU }
  98. function is_fpu(def : tdef) : boolean;
  99. { true if the return value is in EAX }
  100. function ret_in_acc(def : tdef) : boolean;
  101. { true if uses a parameter as return value }
  102. function ret_in_param(def : tdef) : boolean;
  103. { true, if def is a 64 bit int type }
  104. function is_64bitint(def : tdef) : boolean;
  105. function push_high_param(def : tdef) : boolean;
  106. { true if a parameter is too large to copy and only the address is pushed }
  107. function push_addr_param(def : tdef) : boolean;
  108. { true, if def1 and def2 are semantical the same }
  109. function is_equal(def1,def2 : tdef) : boolean;
  110. { checks for type compatibility (subgroups of type) }
  111. { used for case statements... probably missing stuff }
  112. { to use on other types }
  113. function is_subequal(def1, def2: tdef): boolean;
  114. type
  115. tconverttype = (
  116. tc_equal,
  117. tc_not_possible,
  118. tc_string_2_string,
  119. tc_char_2_string,
  120. tc_char_2_chararray,
  121. tc_pchar_2_string,
  122. tc_cchar_2_pchar,
  123. tc_cstring_2_pchar,
  124. tc_ansistring_2_pchar,
  125. tc_string_2_chararray,
  126. tc_chararray_2_string,
  127. tc_array_2_pointer,
  128. tc_pointer_2_array,
  129. tc_int_2_int,
  130. tc_int_2_bool,
  131. tc_bool_2_bool,
  132. tc_bool_2_int,
  133. tc_real_2_real,
  134. tc_int_2_real,
  135. tc_proc_2_procvar,
  136. tc_arrayconstructor_2_set,
  137. tc_load_smallset,
  138. tc_cord_2_pointer,
  139. tc_intf_2_string,
  140. tc_intf_2_guid,
  141. tc_class_2_intf,
  142. tc_char_2_char,
  143. tc_normal_2_smallset,
  144. tc_dynarray_2_openarray
  145. );
  146. function assignment_overloaded(from_def,to_def : tdef) : tprocdef;
  147. { Returns:
  148. 0 - Not convertable
  149. 1 - Convertable
  150. 2 - Convertable, but not first choice }
  151. function isconvertable(def_from,def_to : tdef;
  152. var doconv : tconverttype;
  153. fromtreetype : tnodetype;
  154. explicit : boolean) : byte;
  155. { same as is_equal, but with error message if failed }
  156. function CheckTypes(def1,def2 : tdef) : boolean;
  157. function equal_constsym(sym1,sym2:tconstsym):boolean;
  158. { true, if two parameter lists are equal }
  159. { if acp is cp_none, all have to match exactly }
  160. { if acp is cp_value_equal_const call by value }
  161. { and call by const parameter are assumed as }
  162. { equal }
  163. { if acp is cp_all the var const or nothing are considered equal }
  164. type
  165. compare_type = ( cp_none, cp_value_equal_const, cp_all);
  166. function equal_paras(paralist1,paralist2 : tlinkedlist; acp : compare_type) : boolean;
  167. { true if a type can be allowed for another one
  168. in a func var }
  169. function convertable_paras(paralist1,paralist2 : tlinkedlist; acp : compare_type) : boolean;
  170. { true if a function can be assigned to a procvar }
  171. { changed first argument type to pabstractprocdef so that it can also be }
  172. { used to test compatibility between two pprocvardefs (JM) }
  173. function proc_to_procvar_equal(def1:tabstractprocdef;def2:tprocvardef;exact:boolean) : boolean;
  174. function get_proc_2_procvar_def(p:tprocsym;d:tprocvardef):tprocdef;
  175. { if l isn't in the range of def a range check error (if not explicit) is generated and
  176. the value is placed within the range }
  177. procedure testrange(def : tdef;var l : tconstexprint;explicit:boolean);
  178. { returns the range of def }
  179. procedure getrange(def : tdef;var l : TConstExprInt;var h : TConstExprInt);
  180. { some type helper routines for MMX support }
  181. function is_mmx_able_array(p : tdef) : boolean;
  182. { returns the mmx type }
  183. function mmx_type(p : tdef) : tmmxtype;
  184. { returns true, if sym needs an entry in the proplist of a class rtti }
  185. function needs_prop_entry(sym : tsym) : boolean;
  186. implementation
  187. uses
  188. globtype,globals,systems,tokens,verbose,
  189. symtable;
  190. function needs_prop_entry(sym : tsym) : boolean;
  191. begin
  192. needs_prop_entry:=(sp_published in tsym(sym).symoptions) and
  193. (sym.typ in [propertysym,varsym]);
  194. end;
  195. function equal_constsym(sym1,sym2:tconstsym):boolean;
  196. var
  197. p1,p2,pend : pchar;
  198. begin
  199. equal_constsym:=false;
  200. if sym1.consttyp<>sym2.consttyp then
  201. exit;
  202. case sym1.consttyp of
  203. constint,
  204. constbool,
  205. constchar,
  206. constord :
  207. equal_constsym:=(sym1.valueord=sym2.valueord);
  208. constpointer :
  209. equal_constsym:=(sym1.valueordptr=sym2.valueordptr);
  210. conststring,constresourcestring :
  211. begin
  212. if sym1.len=sym2.len then
  213. begin
  214. p1:=pchar(sym1.valueptr);
  215. p2:=pchar(sym2.valueptr);
  216. pend:=p1+sym1.len;
  217. while (p1<pend) do
  218. begin
  219. if p1^<>p2^ then
  220. break;
  221. inc(p1);
  222. inc(p2);
  223. end;
  224. if (p1=pend) then
  225. equal_constsym:=true;
  226. end;
  227. end;
  228. constreal :
  229. equal_constsym:=(pbestreal(sym1.valueptr)^=pbestreal(sym2.valueptr)^);
  230. constset :
  231. equal_constsym:=(pnormalset(sym1.valueptr)^=pnormalset(sym2.valueptr)^);
  232. constnil :
  233. equal_constsym:=true;
  234. end;
  235. end;
  236. { compare_type = ( cp_none, cp_value_equal_const, cp_all); }
  237. function equal_paras(paralist1,paralist2 : TLinkedList; acp : compare_type) : boolean;
  238. var
  239. def1,def2 : TParaItem;
  240. begin
  241. def1:=TParaItem(paralist1.first);
  242. def2:=TParaItem(paralist2.first);
  243. while (assigned(def1)) and (assigned(def2)) do
  244. begin
  245. case acp of
  246. cp_value_equal_const :
  247. begin
  248. if not(is_equal(def1.paratype.def,def2.paratype.def)) or
  249. ((def1.paratyp<>def2.paratyp) and
  250. ((def1.paratyp in [vs_var,vs_out]) or
  251. (def2.paratyp in [vs_var,vs_out])
  252. )
  253. ) then
  254. begin
  255. equal_paras:=false;
  256. exit;
  257. end;
  258. end;
  259. cp_all :
  260. begin
  261. if not(is_equal(def1.paratype.def,def2.paratype.def)) or
  262. (def1.paratyp<>def2.paratyp) then
  263. begin
  264. equal_paras:=false;
  265. exit;
  266. end;
  267. end;
  268. cp_none :
  269. begin
  270. if not(is_equal(def1.paratype.def,def2.paratype.def)) then
  271. begin
  272. equal_paras:=false;
  273. exit;
  274. end;
  275. { also check default value if both have it declared }
  276. if assigned(def1.defaultvalue) and
  277. assigned(def2.defaultvalue) then
  278. begin
  279. if not equal_constsym(tconstsym(def1.defaultvalue),tconstsym(def2.defaultvalue)) then
  280. begin
  281. equal_paras:=false;
  282. exit;
  283. end;
  284. end;
  285. end;
  286. end;
  287. def1:=TParaItem(def1.next);
  288. def2:=TParaItem(def2.next);
  289. end;
  290. if (def1=nil) and (def2=nil) then
  291. equal_paras:=true
  292. else
  293. equal_paras:=false;
  294. end;
  295. function convertable_paras(paralist1,paralist2 : TLinkedList;acp : compare_type) : boolean;
  296. var
  297. def1,def2 : TParaItem;
  298. doconv : tconverttype;
  299. begin
  300. def1:=TParaItem(paralist1.first);
  301. def2:=TParaItem(paralist2.first);
  302. while (assigned(def1)) and (assigned(def2)) do
  303. begin
  304. case acp of
  305. cp_value_equal_const :
  306. begin
  307. if (isconvertable(def1.paratype.def,def2.paratype.def,doconv,callparan,false)=0) or
  308. ((def1.paratyp<>def2.paratyp) and
  309. ((def1.paratyp in [vs_out,vs_var]) or
  310. (def2.paratyp in [vs_out,vs_var])
  311. )
  312. ) then
  313. begin
  314. convertable_paras:=false;
  315. exit;
  316. end;
  317. end;
  318. cp_all :
  319. begin
  320. if (isconvertable(def1.paratype.def,def2.paratype.def,doconv,callparan,false)=0) or
  321. (def1.paratyp<>def2.paratyp) then
  322. begin
  323. convertable_paras:=false;
  324. exit;
  325. end;
  326. end;
  327. cp_none :
  328. begin
  329. if (isconvertable(def1.paratype.def,def2.paratype.def,doconv,callparan,false)=0) then
  330. begin
  331. convertable_paras:=false;
  332. exit;
  333. end;
  334. end;
  335. end;
  336. def1:=TParaItem(def1.next);
  337. def2:=TParaItem(def2.next);
  338. end;
  339. if (def1=nil) and (def2=nil) then
  340. convertable_paras:=true
  341. else
  342. convertable_paras:=false;
  343. end;
  344. { true if a function can be assigned to a procvar }
  345. { changed first argument type to pabstractprocdef so that it can also be }
  346. { used to test compatibility between two pprocvardefs (JM) }
  347. function proc_to_procvar_equal(def1:tabstractprocdef;def2:tprocvardef;exact:boolean) : boolean;
  348. const
  349. po_comp = po_compatibility_options-[po_methodpointer,po_classmethod];
  350. var
  351. ismethod : boolean;
  352. begin
  353. proc_to_procvar_equal:=false;
  354. if not(assigned(def1)) or not(assigned(def2)) then
  355. exit;
  356. { check for method pointer }
  357. if def1.deftype=procvardef then
  358. begin
  359. ismethod:=(po_methodpointer in def1.procoptions);
  360. end
  361. else
  362. begin
  363. ismethod:=assigned(def1.owner) and
  364. (def1.owner.symtabletype=objectsymtable);
  365. end;
  366. if (ismethod and not (po_methodpointer in def2.procoptions)) or
  367. (not(ismethod) and (po_methodpointer in def2.procoptions)) then
  368. begin
  369. Message(type_e_no_method_and_procedure_not_compatible);
  370. exit;
  371. end;
  372. { check return value and para's and options, methodpointer is already checked
  373. parameters may also be convertable }
  374. if is_equal(def1.rettype.def,def2.rettype.def) and
  375. (equal_paras(def1.para,def2.para,cp_all) or
  376. ((not exact) and convertable_paras(def1.para,def2.para,cp_all))) and
  377. ((po_comp * def1.procoptions)= (po_comp * def2.procoptions)) then
  378. proc_to_procvar_equal:=true
  379. else
  380. proc_to_procvar_equal:=false;
  381. end;
  382. function get_proc_2_procvar_def(p:tprocsym;d:tprocvardef):tprocdef;
  383. var
  384. matchprocdef : tprocdef;
  385. pd : pprocdeflist;
  386. begin
  387. { This function will return the pprocdef of pprocsym that
  388. is the best match for procvardef. When there are multiple
  389. matches it returns nil }
  390. { exact match }
  391. matchprocdef:=nil;
  392. pd:=p.defs;
  393. while assigned(pd) do
  394. begin
  395. if proc_to_procvar_equal(pd^.def,d,true) then
  396. begin
  397. { already found a match ? Then stop and return nil }
  398. if assigned(matchprocdef) then
  399. begin
  400. matchprocdef:=nil;
  401. break;
  402. end;
  403. matchprocdef:=pd^.def;
  404. end;
  405. pd:=pd^.next;
  406. end;
  407. { convertable match, if no exact match was found }
  408. if not assigned(matchprocdef) and
  409. not assigned(pd) then
  410. begin
  411. pd:=p.defs;
  412. while assigned(pd) do
  413. begin
  414. if proc_to_procvar_equal(pd^.def,d,false) then
  415. begin
  416. { already found a match ? Then stop and return nil }
  417. if assigned(matchprocdef) then
  418. begin
  419. matchprocdef:=nil;
  420. break;
  421. end;
  422. matchprocdef:=pd^.def;
  423. end;
  424. pd:=pd^.next;
  425. end;
  426. end;
  427. get_proc_2_procvar_def:=matchprocdef;
  428. end;
  429. { returns true, if def uses FPU }
  430. function is_fpu(def : tdef) : boolean;
  431. begin
  432. is_fpu:=(def.deftype=floatdef);
  433. end;
  434. function range_to_basetype(low,high:TConstExprInt):tbasetype;
  435. begin
  436. { generate a unsigned range if high<0 and low>=0 }
  437. if (low>=0) and (high<0) then
  438. range_to_basetype:=u32bit
  439. else if (low>=0) and (high<=255) then
  440. range_to_basetype:=u8bit
  441. else if (low>=-128) and (high<=127) then
  442. range_to_basetype:=s8bit
  443. else if (low>=0) and (high<=65536) then
  444. range_to_basetype:=u16bit
  445. else if (low>=-32768) and (high<=32767) then
  446. range_to_basetype:=s16bit
  447. else
  448. range_to_basetype:=s32bit;
  449. end;
  450. { true if p is an ordinal }
  451. function is_ordinal(def : tdef) : boolean;
  452. var
  453. dt : tbasetype;
  454. begin
  455. case def.deftype of
  456. orddef :
  457. begin
  458. dt:=torddef(def).typ;
  459. is_ordinal:=dt in [uchar,uwidechar,
  460. u8bit,u16bit,u32bit,u64bit,
  461. s8bit,s16bit,s32bit,s64bit,
  462. bool8bit,bool16bit,bool32bit];
  463. end;
  464. enumdef :
  465. is_ordinal:=true;
  466. else
  467. is_ordinal:=false;
  468. end;
  469. end;
  470. { returns the min. value of the type }
  471. function get_min_value(def : tdef) : longint;
  472. begin
  473. case def.deftype of
  474. orddef:
  475. get_min_value:=torddef(def).low;
  476. enumdef:
  477. get_min_value:=tenumdef(def).min;
  478. else
  479. get_min_value:=0;
  480. end;
  481. end;
  482. { true if p is an integer }
  483. function is_integer(def : tdef) : boolean;
  484. begin
  485. is_integer:=(def.deftype=orddef) and
  486. (torddef(def).typ in [u8bit,u16bit,u32bit,u64bit,
  487. s8bit,s16bit,s32bit,s64bit]);
  488. end;
  489. { true if p is a boolean }
  490. function is_boolean(def : tdef) : boolean;
  491. begin
  492. is_boolean:=(def.deftype=orddef) and
  493. (torddef(def).typ in [bool8bit,bool16bit,bool32bit]);
  494. end;
  495. { true if p is a void }
  496. function is_void(def : tdef) : boolean;
  497. begin
  498. is_void:=(def.deftype=orddef) and
  499. (torddef(def).typ=uvoid);
  500. end;
  501. { true if p is a char }
  502. function is_char(def : tdef) : boolean;
  503. begin
  504. is_char:=(def.deftype=orddef) and
  505. (torddef(def).typ=uchar);
  506. end;
  507. { true if p is a wchar }
  508. function is_widechar(def : tdef) : boolean;
  509. begin
  510. is_widechar:=(def.deftype=orddef) and
  511. (torddef(def).typ=uwidechar);
  512. end;
  513. { true if p is signed (integer) }
  514. function is_signed(def : tdef) : boolean;
  515. var
  516. dt : tbasetype;
  517. begin
  518. case def.deftype of
  519. orddef :
  520. begin
  521. dt:=torddef(def).typ;
  522. is_signed:=(dt in [s8bit,s16bit,s32bit,s64bit]);
  523. end;
  524. enumdef :
  525. is_signed:=tenumdef(def).min < 0;
  526. arraydef :
  527. is_signed:=is_signed(tarraydef(def).rangetype.def);
  528. else
  529. is_signed:=false;
  530. end;
  531. end;
  532. { true, if p points to an open array def }
  533. function is_open_string(p : tdef) : boolean;
  534. begin
  535. is_open_string:=(p.deftype=stringdef) and
  536. (tstringdef(p).string_typ=st_shortstring) and
  537. (tstringdef(p).len=0);
  538. end;
  539. { true, if p points to a zero based array def }
  540. function is_zero_based_array(p : tdef) : boolean;
  541. begin
  542. is_zero_based_array:=(p.deftype=arraydef) and
  543. (tarraydef(p).lowrange=0) and
  544. not(is_special_array(p));
  545. end;
  546. { true if p points to a dynamic array def }
  547. function is_dynamic_array(p : tdef) : boolean;
  548. begin
  549. is_dynamic_array:=(p.deftype=arraydef) and
  550. tarraydef(p).IsDynamicArray;
  551. end;
  552. { true, if p points to an open array def }
  553. function is_open_array(p : tdef) : boolean;
  554. begin
  555. { check for s32bittype is needed, because for u32bit the high
  556. range is also -1 ! (PFV) }
  557. is_open_array:=(p.deftype=arraydef) and
  558. (tarraydef(p).rangetype.def=s32bittype.def) and
  559. (tarraydef(p).lowrange=0) and
  560. (tarraydef(p).highrange=-1) and
  561. not(tarraydef(p).IsConstructor) and
  562. not(tarraydef(p).IsVariant) and
  563. not(tarraydef(p).IsArrayOfConst) and
  564. not(tarraydef(p).IsDynamicArray);
  565. end;
  566. { true, if p points to an array of const def }
  567. function is_array_constructor(p : tdef) : boolean;
  568. begin
  569. is_array_constructor:=(p.deftype=arraydef) and
  570. (tarraydef(p).IsConstructor);
  571. end;
  572. { true, if p points to a variant array }
  573. function is_variant_array(p : tdef) : boolean;
  574. begin
  575. is_variant_array:=(p.deftype=arraydef) and
  576. (tarraydef(p).IsVariant);
  577. end;
  578. { true, if p points to an array of const }
  579. function is_array_of_const(p : tdef) : boolean;
  580. begin
  581. is_array_of_const:=(p.deftype=arraydef) and
  582. (tarraydef(p).IsArrayOfConst);
  583. end;
  584. { true, if p points to a special array }
  585. function is_special_array(p : tdef) : boolean;
  586. begin
  587. is_special_array:=(p.deftype=arraydef) and
  588. ((tarraydef(p).IsVariant) or
  589. (tarraydef(p).IsArrayOfConst) or
  590. (tarraydef(p).IsConstructor) or
  591. is_open_array(p)
  592. );
  593. end;
  594. { true if p is an ansi string def }
  595. function is_ansistring(p : tdef) : boolean;
  596. begin
  597. is_ansistring:=(p.deftype=stringdef) and
  598. (tstringdef(p).string_typ=st_ansistring);
  599. end;
  600. { true if p is an long string def }
  601. function is_longstring(p : tdef) : boolean;
  602. begin
  603. is_longstring:=(p.deftype=stringdef) and
  604. (tstringdef(p).string_typ=st_longstring);
  605. end;
  606. { true if p is an wide string def }
  607. function is_widestring(p : tdef) : boolean;
  608. begin
  609. is_widestring:=(p.deftype=stringdef) and
  610. (tstringdef(p).string_typ=st_widestring);
  611. end;
  612. { true if p is an short string def }
  613. function is_shortstring(p : tdef) : boolean;
  614. begin
  615. is_shortstring:=(p.deftype=stringdef) and
  616. (tstringdef(p).string_typ=st_shortstring);
  617. end;
  618. { true if p is a char array def }
  619. function is_chararray(p : tdef) : boolean;
  620. begin
  621. is_chararray:=(p.deftype=arraydef) and
  622. is_equal(tarraydef(p).elementtype.def,cchartype.def) and
  623. not(is_special_array(p));
  624. end;
  625. { true if p is a widechar array def }
  626. function is_widechararray(p : tdef) : boolean;
  627. begin
  628. is_widechararray:=(p.deftype=arraydef) and
  629. is_equal(tarraydef(p).elementtype.def,cwidechartype.def) and
  630. not(is_special_array(p));
  631. end;
  632. { true if p is a pchar def }
  633. function is_pchar(p : tdef) : boolean;
  634. begin
  635. is_pchar:=(p.deftype=pointerdef) and
  636. (is_equal(tpointerdef(p).pointertype.def,cchartype.def) or
  637. (is_zero_based_array(tpointerdef(p).pointertype.def) and
  638. is_chararray(tpointerdef(p).pointertype.def)));
  639. end;
  640. { true if p is a pchar def }
  641. function is_pwidechar(p : tdef) : boolean;
  642. begin
  643. is_pwidechar:=(p.deftype=pointerdef) and
  644. (is_equal(tpointerdef(p).pointertype.def,cwidechartype.def) or
  645. (is_zero_based_array(tpointerdef(p).pointertype.def) and
  646. is_widechararray(tpointerdef(p).pointertype.def)));
  647. end;
  648. { true if p is a voidpointer def }
  649. function is_voidpointer(p : tdef) : boolean;
  650. begin
  651. is_voidpointer:=(p.deftype=pointerdef) and
  652. (tpointerdef(p).pointertype.def.deftype=orddef) and
  653. (torddef(tpointerdef(p).pointertype.def).typ=uvoid);
  654. end;
  655. { true if p is a smallset def }
  656. function is_smallset(p : tdef) : boolean;
  657. begin
  658. is_smallset:=(p.deftype=setdef) and
  659. (tsetdef(p).settype=smallset);
  660. end;
  661. { true if the return value is in accumulator (EAX for i386), D0 for 68k }
  662. function ret_in_acc(def : tdef) : boolean;
  663. begin
  664. ret_in_acc:=(def.deftype in [orddef,pointerdef,enumdef,classrefdef]) or
  665. ((def.deftype=stringdef) and (tstringdef(def).string_typ in [st_ansistring,st_widestring])) or
  666. ((def.deftype=procvardef) and not(po_methodpointer in tprocvardef(def).procoptions)) or
  667. ((def.deftype=objectdef) and not is_object(def)) or
  668. ((def.deftype=setdef) and (tsetdef(def).settype=smallset));
  669. end;
  670. { true, if def is a 64 bit int type }
  671. function is_64bitint(def : tdef) : boolean;
  672. begin
  673. is_64bitint:=(def.deftype=orddef) and (torddef(def).typ in [u64bit,s64bit])
  674. end;
  675. { true if uses a parameter as return value }
  676. function ret_in_param(def : tdef) : boolean;
  677. begin
  678. ret_in_param:=(def.deftype in [arraydef,recorddef]) or
  679. ((def.deftype=stringdef) and (tstringdef(def).string_typ in [st_shortstring,st_longstring])) or
  680. ((def.deftype=procvardef) and (po_methodpointer in tprocvardef(def).procoptions)) or
  681. ((def.deftype=objectdef) and is_object(def)) or
  682. (def.deftype=variantdef) or
  683. ((def.deftype=setdef) and (tsetdef(def).settype<>smallset));
  684. end;
  685. function push_high_param(def : tdef) : boolean;
  686. begin
  687. push_high_param:=is_open_array(def) or
  688. is_open_string(def) or
  689. is_array_of_const(def);
  690. end;
  691. { true if a parameter is too large to copy and only the address is pushed }
  692. function push_addr_param(def : tdef) : boolean;
  693. begin
  694. push_addr_param:=false;
  695. if never_copy_const_param then
  696. push_addr_param:=true
  697. else
  698. begin
  699. case def.deftype of
  700. variantdef,
  701. formaldef :
  702. push_addr_param:=true;
  703. recorddef :
  704. push_addr_param:=(def.size>target_info.size_of_pointer);
  705. arraydef :
  706. push_addr_param:=((tarraydef(def).highrange>=tarraydef(def).lowrange) and (def.size>target_info.size_of_pointer)) or
  707. is_open_array(def) or
  708. is_array_of_const(def) or
  709. is_array_constructor(def);
  710. objectdef :
  711. push_addr_param:=is_object(def);
  712. stringdef :
  713. push_addr_param:=tstringdef(def).string_typ in [st_shortstring,st_longstring];
  714. procvardef :
  715. push_addr_param:=(po_methodpointer in tprocvardef(def).procoptions);
  716. setdef :
  717. push_addr_param:=(tsetdef(def).settype<>smallset);
  718. end;
  719. end;
  720. end;
  721. { if l isn't in the range of def a range check error (if not explicit) is generated and
  722. the value is placed within the range }
  723. procedure testrange(def : tdef;var l : tconstexprint;explicit:boolean);
  724. var
  725. lv,hv: TConstExprInt;
  726. error: boolean;
  727. begin
  728. error := false;
  729. { for 64 bit types we need only to check if it is less than }
  730. { zero, if def is a qword node }
  731. if is_64bitint(def) then
  732. begin
  733. if (l<0) and (torddef(def).typ=u64bit) then
  734. begin
  735. { don't zero the result, because it may come from hex notation
  736. like $ffffffffffffffff! (JM)
  737. l:=0; }
  738. if not explicit then
  739. begin
  740. if (cs_check_range in aktlocalswitches) then
  741. Message(parser_e_range_check_error)
  742. else
  743. Message(parser_w_range_check_error);
  744. end;
  745. error := true;
  746. end;
  747. end
  748. else
  749. begin
  750. getrange(def,lv,hv);
  751. if (def.deftype=orddef) and
  752. (torddef(def).typ=u32bit) then
  753. begin
  754. if (l < cardinal(lv)) or
  755. (l > cardinal(hv)) then
  756. begin
  757. if not explicit then
  758. begin
  759. if (cs_check_range in aktlocalswitches) then
  760. Message(parser_e_range_check_error)
  761. else
  762. Message(parser_w_range_check_error);
  763. end;
  764. error := true;
  765. end;
  766. end
  767. else if (l<lv) or (l>hv) then
  768. begin
  769. if not explicit then
  770. begin
  771. if ((def.deftype=enumdef) and
  772. { delphi allows range check errors in
  773. enumeration type casts FK }
  774. not(m_delphi in aktmodeswitches)) or
  775. (cs_check_range in aktlocalswitches) then
  776. Message(parser_e_range_check_error)
  777. else
  778. Message(parser_w_range_check_error);
  779. end;
  780. error := true;
  781. end;
  782. end;
  783. if error then
  784. begin
  785. { Fix the value to fit in the allocated space for this type of variable }
  786. case def.size of
  787. 1: l := l and $ff;
  788. 2: l := l and $ffff;
  789. { work around sign extension bug (to be fixed) (JM) }
  790. 4: l := l and (int64($fffffff) shl 4 + $f);
  791. end;
  792. { do sign extension if necessary (JM) }
  793. if is_signed(def) then
  794. begin
  795. case def.size of
  796. 1: l := shortint(l);
  797. 2: l := smallint(l);
  798. 4: l := longint(l);
  799. end;
  800. end;
  801. end;
  802. end;
  803. { return the range from def in l and h }
  804. procedure getrange(def : tdef;var l : TConstExprInt;var h : TConstExprInt);
  805. begin
  806. case def.deftype of
  807. orddef :
  808. begin
  809. l:=torddef(def).low;
  810. h:=torddef(def).high;
  811. end;
  812. enumdef :
  813. begin
  814. l:=tenumdef(def).min;
  815. h:=tenumdef(def).max;
  816. end;
  817. arraydef :
  818. begin
  819. l:=tarraydef(def).lowrange;
  820. h:=tarraydef(def).highrange;
  821. end;
  822. else
  823. internalerror(987);
  824. end;
  825. end;
  826. function mmx_type(p : tdef) : tmmxtype;
  827. begin
  828. mmx_type:=mmxno;
  829. if is_mmx_able_array(p) then
  830. begin
  831. if tarraydef(p).elementtype.def.deftype=floatdef then
  832. case tfloatdef(tarraydef(p).elementtype.def).typ of
  833. s32real:
  834. mmx_type:=mmxsingle;
  835. end
  836. else
  837. case torddef(tarraydef(p).elementtype.def).typ of
  838. u8bit:
  839. mmx_type:=mmxu8bit;
  840. s8bit:
  841. mmx_type:=mmxs8bit;
  842. u16bit:
  843. mmx_type:=mmxu16bit;
  844. s16bit:
  845. mmx_type:=mmxs16bit;
  846. u32bit:
  847. mmx_type:=mmxu32bit;
  848. s32bit:
  849. mmx_type:=mmxs32bit;
  850. end;
  851. end;
  852. end;
  853. function is_mmx_able_array(p : tdef) : boolean;
  854. begin
  855. {$ifdef SUPPORT_MMX}
  856. if (cs_mmx_saturation in aktlocalswitches) then
  857. begin
  858. is_mmx_able_array:=(p.deftype=arraydef) and
  859. not(is_special_array(p)) and
  860. (
  861. (
  862. (tarraydef(p).elementtype.def.deftype=orddef) and
  863. (
  864. (
  865. (tarraydef(p).lowrange=0) and
  866. (tarraydef(p).highrange=1) and
  867. (torddef(tarraydef(p).elementtype.def).typ in [u32bit,s32bit])
  868. )
  869. or
  870. (
  871. (tarraydef(p).lowrange=0) and
  872. (tarraydef(p).highrange=3) and
  873. (torddef(tarraydef(p).elementtype.def).typ in [u16bit,s16bit])
  874. )
  875. )
  876. )
  877. or
  878. (
  879. (
  880. (tarraydef(p).elementtype.def.deftype=floatdef) and
  881. (
  882. (tarraydef(p).lowrange=0) and
  883. (tarraydef(p).highrange=1) and
  884. (tfloatdef(tarraydef(p).elementtype.def).typ=s32real)
  885. )
  886. )
  887. )
  888. );
  889. end
  890. else
  891. begin
  892. is_mmx_able_array:=(p.deftype=arraydef) and
  893. (
  894. (
  895. (tarraydef(p).elementtype.def.deftype=orddef) and
  896. (
  897. (
  898. (tarraydef(p).lowrange=0) and
  899. (tarraydef(p).highrange=1) and
  900. (torddef(tarraydef(p).elementtype.def).typ in [u32bit,s32bit])
  901. )
  902. or
  903. (
  904. (tarraydef(p).lowrange=0) and
  905. (tarraydef(p).highrange=3) and
  906. (torddef(tarraydef(p).elementtype.def).typ in [u16bit,s16bit])
  907. )
  908. or
  909. (
  910. (tarraydef(p).lowrange=0) and
  911. (tarraydef(p).highrange=7) and
  912. (torddef(tarraydef(p).elementtype.def).typ in [u8bit,s8bit])
  913. )
  914. )
  915. )
  916. or
  917. (
  918. (tarraydef(p).elementtype.def.deftype=floatdef) and
  919. (
  920. (tarraydef(p).lowrange=0) and
  921. (tarraydef(p).highrange=1) and
  922. (tfloatdef(tarraydef(p).elementtype.def).typ=s32real)
  923. )
  924. )
  925. );
  926. end;
  927. {$else SUPPORT_MMX}
  928. is_mmx_able_array:=false;
  929. {$endif SUPPORT_MMX}
  930. end;
  931. function is_equal(def1,def2 : tdef) : boolean;
  932. var
  933. b : boolean;
  934. hd : tdef;
  935. begin
  936. { both types must exists }
  937. if not (assigned(def1) and assigned(def2)) then
  938. begin
  939. is_equal:=false;
  940. exit;
  941. end;
  942. { be sure, that if there is a stringdef, that this is def1 }
  943. if def2.deftype=stringdef then
  944. begin
  945. hd:=def1;
  946. def1:=def2;
  947. def2:=hd;
  948. end;
  949. b:=false;
  950. { both point to the same definition ? }
  951. if def1=def2 then
  952. b:=true
  953. else
  954. { pointer with an equal definition are equal }
  955. if (def1.deftype=pointerdef) and (def2.deftype=pointerdef) then
  956. begin
  957. { check if both are farpointer }
  958. if (tpointerdef(def1).is_far=tpointerdef(def2).is_far) then
  959. begin
  960. { here a problem detected in tabsolutesym }
  961. { the types can be forward type !! }
  962. if assigned(def1.typesym) and (tpointerdef(def1).pointertype.def.deftype=forwarddef) then
  963. b:=(def1.typesym=def2.typesym)
  964. else
  965. b:=tpointerdef(def1).pointertype.def=tpointerdef(def2).pointertype.def;
  966. end
  967. else
  968. b:=false;
  969. end
  970. else
  971. { ordinals are equal only when the ordinal type is equal }
  972. if (def1.deftype=orddef) and (def2.deftype=orddef) then
  973. begin
  974. case torddef(def1).typ of
  975. u8bit,u16bit,u32bit,
  976. s8bit,s16bit,s32bit:
  977. b:=((torddef(def1).typ=torddef(def2).typ) and
  978. (torddef(def1).low=torddef(def2).low) and
  979. (torddef(def1).high=torddef(def2).high));
  980. uvoid,uchar,uwidechar,
  981. bool8bit,bool16bit,bool32bit:
  982. b:=(torddef(def1).typ=torddef(def2).typ);
  983. end;
  984. end
  985. else
  986. if (def1.deftype=floatdef) and (def2.deftype=floatdef) then
  987. b:=tfloatdef(def1).typ=tfloatdef(def2).typ
  988. else
  989. { strings with the same length are equal }
  990. if (def1.deftype=stringdef) and (def2.deftype=stringdef) and
  991. (tstringdef(def1).string_typ=tstringdef(def2).string_typ) then
  992. begin
  993. b:=not(is_shortstring(def1)) or
  994. (tstringdef(def1).len=tstringdef(def2).len);
  995. end
  996. else
  997. if (def1.deftype=formaldef) and (def2.deftype=formaldef) then
  998. b:=true
  999. { file types with the same file element type are equal }
  1000. { this is a problem for assign !! }
  1001. { changed to allow if one is untyped }
  1002. { all typed files are equal to the special }
  1003. { typed file that has voiddef as elemnt type }
  1004. { but must NOT match for text file !!! }
  1005. else
  1006. if (def1.deftype=filedef) and (def2.deftype=filedef) then
  1007. b:=(tfiledef(def1).filetyp=tfiledef(def2).filetyp) and
  1008. ((
  1009. ((tfiledef(def1).typedfiletype.def=nil) and
  1010. (tfiledef(def2).typedfiletype.def=nil)) or
  1011. (
  1012. (tfiledef(def1).typedfiletype.def<>nil) and
  1013. (tfiledef(def2).typedfiletype.def<>nil) and
  1014. is_equal(tfiledef(def1).typedfiletype.def,tfiledef(def2).typedfiletype.def)
  1015. ) or
  1016. ( (tfiledef(def1).typedfiletype.def=tdef(voidtype.def)) or
  1017. (tfiledef(def2).typedfiletype.def=tdef(voidtype.def))
  1018. )))
  1019. { sets with the same element base type are equal }
  1020. else
  1021. if (def1.deftype=setdef) and (def2.deftype=setdef) then
  1022. begin
  1023. if assigned(tsetdef(def1).elementtype.def) and
  1024. assigned(tsetdef(def2).elementtype.def) then
  1025. b:=is_subequal(tsetdef(def1).elementtype.def,tsetdef(def2).elementtype.def)
  1026. else
  1027. { empty set is compatible with everything }
  1028. b:=true;
  1029. end
  1030. else
  1031. if (def1.deftype=procvardef) and (def2.deftype=procvardef) then
  1032. begin
  1033. { poassembler isn't important for compatibility }
  1034. { if a method is assigned to a methodpointer }
  1035. { is checked before }
  1036. b:=(tprocvardef(def1).proctypeoption=tprocvardef(def2).proctypeoption) and
  1037. (tprocvardef(def1).proccalloption=tprocvardef(def2).proccalloption) and
  1038. ((tprocvardef(def1).procoptions * po_compatibility_options)=
  1039. (tprocvardef(def2).procoptions * po_compatibility_options)) and
  1040. is_equal(tprocvardef(def1).rettype.def,tprocvardef(def2).rettype.def) and
  1041. equal_paras(tprocvardef(def1).para,tprocvardef(def2).para,cp_all);
  1042. end
  1043. else
  1044. if (def1.deftype=arraydef) and (def2.deftype=arraydef) then
  1045. begin
  1046. if is_dynamic_array(def1) and is_dynamic_array(def2) then
  1047. b:=is_equal(tarraydef(def1).elementtype.def,tarraydef(def2).elementtype.def)
  1048. else
  1049. if is_array_of_const(def1) or is_array_of_const(def2) then
  1050. begin
  1051. b:=(is_array_of_const(def1) and is_array_of_const(def2)) or
  1052. (is_array_of_const(def1) and is_array_constructor(def2)) or
  1053. (is_array_of_const(def2) and is_array_constructor(def1));
  1054. end
  1055. else
  1056. if (is_dynamic_array(def1) or is_dynamic_array(def2)) then
  1057. begin
  1058. b := is_dynamic_array(def1) and is_dynamic_array(def2) and
  1059. is_equal(tarraydef(def1).elementtype.def,tarraydef(def2).elementtype.def);
  1060. end
  1061. else
  1062. if is_open_array(def1) or is_open_array(def2) then
  1063. begin
  1064. b:=is_equal(tarraydef(def1).elementtype.def,tarraydef(def2).elementtype.def);
  1065. end
  1066. else
  1067. begin
  1068. b:=not(m_tp in aktmodeswitches) and
  1069. not(m_delphi in aktmodeswitches) and
  1070. (tarraydef(def1).lowrange=tarraydef(def2).lowrange) and
  1071. (tarraydef(def1).highrange=tarraydef(def2).highrange) and
  1072. is_equal(tarraydef(def1).elementtype.def,tarraydef(def2).elementtype.def) and
  1073. is_equal(tarraydef(def1).rangetype.def,tarraydef(def2).rangetype.def);
  1074. end;
  1075. end
  1076. else
  1077. if (def1.deftype=classrefdef) and (def2.deftype=classrefdef) then
  1078. begin
  1079. { similar to pointerdef: }
  1080. if assigned(def1.typesym) and (tclassrefdef(def1).pointertype.def.deftype=forwarddef) then
  1081. b:=(def1.typesym=def2.typesym)
  1082. else
  1083. b:=is_equal(tclassrefdef(def1).pointertype.def,tclassrefdef(def2).pointertype.def);
  1084. end;
  1085. is_equal:=b;
  1086. end;
  1087. function is_subequal(def1, def2: tdef): boolean;
  1088. var
  1089. basedef1,basedef2 : tenumdef;
  1090. Begin
  1091. is_subequal := false;
  1092. if assigned(def1) and assigned(def2) then
  1093. Begin
  1094. if (def1.deftype = orddef) and (def2.deftype = orddef) then
  1095. Begin
  1096. { see p.47 of Turbo Pascal 7.01 manual for the separation of types }
  1097. { range checking for case statements is done with testrange }
  1098. case torddef(def1).typ of
  1099. u8bit,u16bit,u32bit,
  1100. s8bit,s16bit,s32bit,s64bit,u64bit :
  1101. is_subequal:=(torddef(def2).typ in [s64bit,u64bit,s32bit,u32bit,u8bit,s8bit,s16bit,u16bit]);
  1102. bool8bit,bool16bit,bool32bit :
  1103. is_subequal:=(torddef(def2).typ in [bool8bit,bool16bit,bool32bit]);
  1104. uchar :
  1105. is_subequal:=(torddef(def2).typ=uchar);
  1106. uwidechar :
  1107. is_subequal:=(torddef(def2).typ=uwidechar);
  1108. end;
  1109. end
  1110. else
  1111. Begin
  1112. { I assume that both enumerations are equal when the first }
  1113. { pointers are equal. }
  1114. { I changed this to assume that the enums are equal }
  1115. { if the basedefs are equal (FK) }
  1116. if (def1.deftype=enumdef) and (def2.deftype=enumdef) then
  1117. Begin
  1118. { get both basedefs }
  1119. basedef1:=tenumdef(def1);
  1120. while assigned(basedef1.basedef) do
  1121. basedef1:=basedef1.basedef;
  1122. basedef2:=tenumdef(def2);
  1123. while assigned(basedef2.basedef) do
  1124. basedef2:=basedef2.basedef;
  1125. is_subequal:=basedef1=basedef2;
  1126. {
  1127. if tenumdef(def1).firstenum = tenumdef(def2).firstenum then
  1128. is_subequal := TRUE;
  1129. }
  1130. end;
  1131. end;
  1132. end; { endif assigned ... }
  1133. end;
  1134. function assignment_overloaded(from_def,to_def : tdef) : tprocdef;
  1135. var
  1136. passprocs : pprocdeflist;
  1137. convtyp : tconverttype;
  1138. begin
  1139. assignment_overloaded:=nil;
  1140. if not assigned(overloaded_operators[_ASSIGNMENT]) then
  1141. exit;
  1142. { look for an exact match first }
  1143. passprocs:=overloaded_operators[_ASSIGNMENT].defs;
  1144. while assigned(passprocs) do
  1145. begin
  1146. if is_equal(passprocs^.def.rettype.def,to_def) and
  1147. (TParaItem(passprocs^.def.Para.first).paratype.def=from_def) then
  1148. begin
  1149. assignment_overloaded:=passprocs^.def;
  1150. exit;
  1151. end;
  1152. passprocs:=passprocs^.next;
  1153. end;
  1154. { .... then look for an equal match }
  1155. passprocs:=overloaded_operators[_ASSIGNMENT].defs;
  1156. while assigned(passprocs) do
  1157. begin
  1158. if is_equal(passprocs^.def.rettype.def,to_def) and
  1159. is_equal(TParaItem(passprocs^.def.Para.first).paratype.def,from_def) then
  1160. begin
  1161. assignment_overloaded:=passprocs^.def;
  1162. exit;
  1163. end;
  1164. passprocs:=passprocs^.next;
  1165. end;
  1166. { .... then for convert level 1 }
  1167. passprocs:=overloaded_operators[_ASSIGNMENT].defs;
  1168. while assigned(passprocs) do
  1169. begin
  1170. if is_equal(passprocs^.def.rettype.def,to_def) and
  1171. (isconvertable(from_def,TParaItem(passprocs^.def.Para.first).paratype.def,convtyp,ordconstn,false)=1) then
  1172. begin
  1173. assignment_overloaded:=passprocs^.def;
  1174. exit;
  1175. end;
  1176. passprocs:=passprocs^.next;
  1177. end;
  1178. end;
  1179. { Returns:
  1180. 0 - Not convertable
  1181. 1 - Convertable
  1182. 2 - Convertable, but not first choice }
  1183. function isconvertable(def_from,def_to : tdef;
  1184. var doconv : tconverttype;
  1185. fromtreetype : tnodetype;
  1186. explicit : boolean) : byte;
  1187. { Tbasetype:
  1188. uvoid,
  1189. u8bit,u16bit,u32bit,u64bit,
  1190. s8bit,s16bit,s32bit,s64bit,
  1191. bool8bit,bool16bit,bool32bit,
  1192. uchar,uwidechar }
  1193. type
  1194. tbasedef=(bvoid,bchar,bint,bbool);
  1195. const
  1196. basedeftbl:array[tbasetype] of tbasedef =
  1197. (bvoid,
  1198. bint,bint,bint,bint,
  1199. bint,bint,bint,bint,
  1200. bbool,bbool,bbool,
  1201. bchar,bchar);
  1202. basedefconverts : array[tbasedef,tbasedef] of tconverttype =
  1203. ((tc_not_possible,tc_not_possible,tc_not_possible,tc_not_possible),
  1204. (tc_not_possible,tc_char_2_char,tc_not_possible,tc_not_possible),
  1205. (tc_not_possible,tc_not_possible,tc_int_2_int,tc_int_2_bool),
  1206. (tc_not_possible,tc_not_possible,tc_bool_2_int,tc_bool_2_bool));
  1207. var
  1208. b : byte;
  1209. hd1,hd2 : tdef;
  1210. hct : tconverttype;
  1211. begin
  1212. { safety check }
  1213. if not(assigned(def_from) and assigned(def_to)) then
  1214. begin
  1215. isconvertable:=0;
  1216. exit;
  1217. end;
  1218. { tp7 procvar def support, in tp7 a procvar is always called, if the
  1219. procvar is passed explicit a addrn would be there }
  1220. if (m_tp_procvar in aktmodeswitches) and
  1221. (def_from.deftype=procvardef) and
  1222. (fromtreetype=loadn) then
  1223. begin
  1224. def_from:=tprocvardef(def_from).rettype.def;
  1225. end;
  1226. { we walk the wanted (def_to) types and check then the def_from
  1227. types if there is a conversion possible }
  1228. b:=0;
  1229. case def_to.deftype of
  1230. orddef :
  1231. begin
  1232. case def_from.deftype of
  1233. orddef :
  1234. begin
  1235. doconv:=basedefconverts[basedeftbl[torddef(def_from).typ],basedeftbl[torddef(def_to).typ]];
  1236. b:=1;
  1237. if (doconv=tc_not_possible) or
  1238. ((doconv=tc_int_2_bool) and
  1239. (not explicit) and
  1240. (not is_boolean(def_from))) or
  1241. ((doconv=tc_bool_2_int) and
  1242. (not explicit) and
  1243. (not is_boolean(def_to))) then
  1244. b:=0;
  1245. end;
  1246. enumdef :
  1247. begin
  1248. { needed for char(enum) }
  1249. if explicit then
  1250. begin
  1251. doconv:=tc_int_2_int;
  1252. b:=1;
  1253. end;
  1254. end;
  1255. end;
  1256. end;
  1257. stringdef :
  1258. begin
  1259. case def_from.deftype of
  1260. stringdef :
  1261. begin
  1262. doconv:=tc_string_2_string;
  1263. b:=1;
  1264. end;
  1265. orddef :
  1266. begin
  1267. { char to string}
  1268. if is_char(def_from) or
  1269. is_widechar(def_from) then
  1270. begin
  1271. doconv:=tc_char_2_string;
  1272. b:=1;
  1273. end;
  1274. end;
  1275. arraydef :
  1276. begin
  1277. { array of char to string, the length check is done by the firstpass of this node }
  1278. if is_chararray(def_from) or
  1279. (is_equal(tarraydef(def_from).elementtype.def,cchartype.def) and
  1280. is_open_array(def_from)) then
  1281. begin
  1282. doconv:=tc_chararray_2_string;
  1283. if is_open_array(def_from) or
  1284. (is_shortstring(def_to) and
  1285. (def_from.size <= 255)) or
  1286. (is_ansistring(def_to) and
  1287. (def_from.size > 255)) then
  1288. b:=1
  1289. else
  1290. b:=2;
  1291. end;
  1292. end;
  1293. pointerdef :
  1294. begin
  1295. { pchar can be assigned to short/ansistrings,
  1296. but not in tp7 compatible mode }
  1297. if is_pchar(def_from) and not(m_tp7 in aktmodeswitches) then
  1298. begin
  1299. doconv:=tc_pchar_2_string;
  1300. { trefer ansistrings because pchars can overflow shortstrings, }
  1301. { but only if ansistrings are the default (JM) }
  1302. if (is_shortstring(def_to) and
  1303. not(cs_ansistrings in aktlocalswitches)) or
  1304. (is_ansistring(def_to) and
  1305. (cs_ansistrings in aktlocalswitches)) then
  1306. b:=1
  1307. else
  1308. b:=2;
  1309. end;
  1310. end;
  1311. end;
  1312. end;
  1313. floatdef :
  1314. begin
  1315. case def_from.deftype of
  1316. orddef :
  1317. begin { ordinal to real }
  1318. if is_integer(def_from) then
  1319. begin
  1320. doconv:=tc_int_2_real;
  1321. b:=1;
  1322. end;
  1323. end;
  1324. floatdef :
  1325. begin { 2 float types ? }
  1326. if tfloatdef(def_from).typ=tfloatdef(def_to).typ then
  1327. doconv:=tc_equal
  1328. else
  1329. doconv:=tc_real_2_real;
  1330. b:=1;
  1331. end;
  1332. end;
  1333. end;
  1334. enumdef :
  1335. begin
  1336. if (def_from.deftype=enumdef) then
  1337. begin
  1338. if explicit then
  1339. begin
  1340. b:=1;
  1341. doconv:=tc_int_2_int;
  1342. end
  1343. else
  1344. begin
  1345. hd1:=def_from;
  1346. while assigned(tenumdef(hd1).basedef) do
  1347. hd1:=tenumdef(hd1).basedef;
  1348. hd2:=def_to;
  1349. while assigned(tenumdef(hd2).basedef) do
  1350. hd2:=tenumdef(hd2).basedef;
  1351. if (hd1=hd2) then
  1352. begin
  1353. b:=1;
  1354. { because of packenum they can have different sizes! (JM) }
  1355. doconv:=tc_int_2_int;
  1356. end;
  1357. end;
  1358. end;
  1359. end;
  1360. arraydef :
  1361. begin
  1362. { open array is also compatible with a single element of its base type }
  1363. if is_open_array(def_to) and
  1364. is_equal(tarraydef(def_to).elementtype.def,def_from) then
  1365. begin
  1366. doconv:=tc_equal;
  1367. b:=1;
  1368. end
  1369. else
  1370. begin
  1371. case def_from.deftype of
  1372. arraydef :
  1373. begin
  1374. { array constructor -> open array }
  1375. if is_open_array(def_to) and
  1376. is_array_constructor(def_from) then
  1377. begin
  1378. if is_void(tarraydef(def_from).elementtype.def) or
  1379. is_equal(tarraydef(def_to).elementtype.def,tarraydef(def_from).elementtype.def) then
  1380. begin
  1381. doconv:=tc_equal;
  1382. b:=1;
  1383. end
  1384. else
  1385. if isconvertable(tarraydef(def_from).elementtype.def,
  1386. tarraydef(def_to).elementtype.def,hct,arrayconstructorn,false)<>0 then
  1387. begin
  1388. doconv:=hct;
  1389. b:=2;
  1390. end;
  1391. end
  1392. else
  1393. { dynamic array -> open array }
  1394. if is_dynamic_array(def_from) and
  1395. is_open_array(def_to) and
  1396. is_equal(tarraydef(def_to).elementtype.def,tarraydef(def_from).elementtype.def) then
  1397. begin
  1398. doconv := tc_dynarray_2_openarray;
  1399. b := 2;
  1400. end
  1401. else
  1402. { array of tvarrec -> array of const }
  1403. if is_array_of_const(def_to) and
  1404. is_equal(tarraydef(def_to).elementtype.def,tarraydef(def_from).elementtype.def) then
  1405. begin
  1406. doconv:=tc_equal;
  1407. b:=1;
  1408. end;
  1409. end;
  1410. pointerdef :
  1411. begin
  1412. if is_zero_based_array(def_to) and
  1413. is_equal(tpointerdef(def_from).pointertype.def,tarraydef(def_to).elementtype.def) then
  1414. begin
  1415. doconv:=tc_pointer_2_array;
  1416. b:=1;
  1417. end;
  1418. end;
  1419. stringdef :
  1420. begin
  1421. { string to char array }
  1422. if (not is_special_array(def_to)) and
  1423. is_char(tarraydef(def_to).elementtype.def) then
  1424. begin
  1425. doconv:=tc_string_2_chararray;
  1426. b:=1;
  1427. end;
  1428. end;
  1429. orddef:
  1430. begin
  1431. if is_chararray(def_to) and
  1432. is_char(def_from) then
  1433. begin
  1434. doconv:=tc_char_2_chararray;
  1435. b:=2;
  1436. end;
  1437. end;
  1438. recorddef :
  1439. begin
  1440. { tvarrec -> array of constconst }
  1441. if is_array_of_const(def_to) and
  1442. is_equal(def_from,tarraydef(def_to).elementtype.def) then
  1443. begin
  1444. doconv:=tc_equal;
  1445. b:=1;
  1446. end;
  1447. end;
  1448. end;
  1449. end;
  1450. end;
  1451. pointerdef :
  1452. begin
  1453. case def_from.deftype of
  1454. stringdef :
  1455. begin
  1456. { string constant (which can be part of array constructor)
  1457. to zero terminated string constant }
  1458. if (fromtreetype in [arrayconstructorn,stringconstn]) and
  1459. is_pchar(def_to) or is_pwidechar(def_to) then
  1460. begin
  1461. doconv:=tc_cstring_2_pchar;
  1462. b:=1;
  1463. end;
  1464. end;
  1465. orddef :
  1466. begin
  1467. { char constant to zero terminated string constant }
  1468. if (fromtreetype=ordconstn) then
  1469. begin
  1470. if is_equal(def_from,cchartype.def) and
  1471. is_pchar(def_to) then
  1472. begin
  1473. doconv:=tc_cchar_2_pchar;
  1474. b:=1;
  1475. end
  1476. else
  1477. if is_integer(def_from) then
  1478. begin
  1479. doconv:=tc_cord_2_pointer;
  1480. b:=1;
  1481. end;
  1482. end;
  1483. end;
  1484. arraydef :
  1485. begin
  1486. { chararray to pointer }
  1487. if is_zero_based_array(def_from) and
  1488. is_equal(tarraydef(def_from).elementtype.def,tpointerdef(def_to).pointertype.def) then
  1489. begin
  1490. doconv:=tc_array_2_pointer;
  1491. b:=1;
  1492. end;
  1493. end;
  1494. pointerdef :
  1495. begin
  1496. { child class pointer can be assigned to anchestor pointers }
  1497. if (
  1498. (tpointerdef(def_from).pointertype.def.deftype=objectdef) and
  1499. (tpointerdef(def_to).pointertype.def.deftype=objectdef) and
  1500. tobjectdef(tpointerdef(def_from).pointertype.def).is_related(
  1501. tobjectdef(tpointerdef(def_to).pointertype.def))
  1502. ) or
  1503. { all pointers can be assigned to void-pointer }
  1504. is_equal(tpointerdef(def_to).pointertype.def,voidtype.def) or
  1505. { in my opnion, is this not clean pascal }
  1506. { well, but it's handy to use, it isn't ? (FK) }
  1507. is_equal(tpointerdef(def_from).pointertype.def,voidtype.def) then
  1508. begin
  1509. { but don't allow conversion between farpointer-pointer }
  1510. if (tpointerdef(def_to).is_far=tpointerdef(def_from).is_far) then
  1511. begin
  1512. doconv:=tc_equal;
  1513. b:=1;
  1514. end;
  1515. end;
  1516. end;
  1517. procvardef :
  1518. begin
  1519. { procedure variable can be assigned to an void pointer }
  1520. { Not anymore. Use the @ operator now.}
  1521. if not(m_tp_procvar in aktmodeswitches) and
  1522. (tpointerdef(def_to).pointertype.def.deftype=orddef) and
  1523. (torddef(tpointerdef(def_to).pointertype.def).typ=uvoid) then
  1524. begin
  1525. doconv:=tc_equal;
  1526. b:=1;
  1527. end;
  1528. end;
  1529. classrefdef,
  1530. objectdef :
  1531. begin
  1532. { class types and class reference type
  1533. can be assigned to void pointers }
  1534. if (
  1535. is_class_or_interface(def_from) or
  1536. (def_from.deftype=classrefdef)
  1537. ) and
  1538. (tpointerdef(def_to).pointertype.def.deftype=orddef) and
  1539. (torddef(tpointerdef(def_to).pointertype.def).typ=uvoid) then
  1540. begin
  1541. doconv:=tc_equal;
  1542. b:=1;
  1543. end;
  1544. end;
  1545. end;
  1546. end;
  1547. setdef :
  1548. begin
  1549. { automatic arrayconstructor -> set conversion }
  1550. if is_array_constructor(def_from) then
  1551. begin
  1552. doconv:=tc_arrayconstructor_2_set;
  1553. b:=1;
  1554. end;
  1555. end;
  1556. procvardef :
  1557. begin
  1558. { proc -> procvar }
  1559. if (def_from.deftype=procdef) and
  1560. (m_tp_procvar in aktmodeswitches) then
  1561. begin
  1562. doconv:=tc_proc_2_procvar;
  1563. if proc_to_procvar_equal(tprocdef(def_from),tprocvardef(def_to),false) then
  1564. b:=1;
  1565. end
  1566. { procvar -> procvar }
  1567. else
  1568. if (def_from.deftype=procvardef) and
  1569. (proc_to_procvar_equal(tprocvardef(def_from),tprocvardef(def_to),false)) then
  1570. begin
  1571. doconv:=tc_equal;
  1572. b := 2;
  1573. end
  1574. else
  1575. { for example delphi allows the assignement from pointers }
  1576. { to procedure variables }
  1577. if (m_pointer_2_procedure in aktmodeswitches) and
  1578. (def_from.deftype=pointerdef) and
  1579. (tpointerdef(def_from).pointertype.def.deftype=orddef) and
  1580. (torddef(tpointerdef(def_from).pointertype.def).typ=uvoid) then
  1581. begin
  1582. doconv:=tc_equal;
  1583. b:=1;
  1584. end
  1585. else
  1586. { nil is compatible with procvars }
  1587. if (fromtreetype=niln) then
  1588. begin
  1589. doconv:=tc_equal;
  1590. b:=1;
  1591. end;
  1592. end;
  1593. objectdef :
  1594. begin
  1595. { object pascal objects }
  1596. if (def_from.deftype=objectdef) and
  1597. tobjectdef(def_from).is_related(tobjectdef(def_to)) then
  1598. begin
  1599. doconv:=tc_equal;
  1600. b:=1;
  1601. end
  1602. else
  1603. { Class/interface specific }
  1604. if is_class_or_interface(def_to) then
  1605. begin
  1606. { void pointer also for delphi mode }
  1607. if (m_delphi in aktmodeswitches) and
  1608. is_voidpointer(def_from) then
  1609. begin
  1610. doconv:=tc_equal;
  1611. b:=1;
  1612. end
  1613. else
  1614. { nil is compatible with class instances and interfaces }
  1615. if (fromtreetype=niln) then
  1616. begin
  1617. doconv:=tc_equal;
  1618. b:=1;
  1619. end
  1620. { classes can be assigned to interfaces }
  1621. else if is_interface(def_to) and
  1622. is_class(def_from) and
  1623. assigned(tobjectdef(def_from).implementedinterfaces) and
  1624. (tobjectdef(def_from).implementedinterfaces.searchintf(def_to)<>-1) then
  1625. begin
  1626. doconv:=tc_class_2_intf;
  1627. b:=1;
  1628. end
  1629. { Interface 2 GUID handling }
  1630. else if (def_to=tdef(rec_tguid)) and
  1631. (fromtreetype=typen) and
  1632. is_interface(def_from) and
  1633. tobjectdef(def_from).isiidguidvalid then
  1634. begin
  1635. b:=1;
  1636. doconv:=tc_equal;
  1637. end;
  1638. end;
  1639. end;
  1640. classrefdef :
  1641. begin
  1642. { class reference types }
  1643. if (def_from.deftype=classrefdef) then
  1644. begin
  1645. doconv:=tc_equal;
  1646. if tobjectdef(tclassrefdef(def_from).pointertype.def).is_related(
  1647. tobjectdef(tclassrefdef(def_to).pointertype.def)) then
  1648. b:=1;
  1649. end
  1650. else
  1651. { nil is compatible with class references }
  1652. if (fromtreetype=niln) then
  1653. begin
  1654. doconv:=tc_equal;
  1655. b:=1;
  1656. end;
  1657. end;
  1658. filedef :
  1659. begin
  1660. { typed files are all equal to the abstract file type
  1661. name TYPEDFILE in system.pp in is_equal in types.pas
  1662. the problem is that it sholud be also compatible to FILE
  1663. but this would leed to a problem for ASSIGN RESET and REWRITE
  1664. when trying to find the good overloaded function !!
  1665. so all file function are doubled in system.pp
  1666. this is not very beautiful !!}
  1667. if (def_from.deftype=filedef) and
  1668. (
  1669. (
  1670. (tfiledef(def_from).filetyp = ft_typed) and
  1671. (tfiledef(def_to).filetyp = ft_typed) and
  1672. (
  1673. (tfiledef(def_from).typedfiletype.def = tdef(voidtype.def)) or
  1674. (tfiledef(def_to).typedfiletype.def = tdef(voidtype.def))
  1675. )
  1676. ) or
  1677. (
  1678. (
  1679. (tfiledef(def_from).filetyp = ft_untyped) and
  1680. (tfiledef(def_to).filetyp = ft_typed)
  1681. ) or
  1682. (
  1683. (tfiledef(def_from).filetyp = ft_typed) and
  1684. (tfiledef(def_to).filetyp = ft_untyped)
  1685. )
  1686. )
  1687. ) then
  1688. begin
  1689. doconv:=tc_equal;
  1690. b:=1;
  1691. end
  1692. end;
  1693. recorddef :
  1694. begin
  1695. { interface -> guid }
  1696. if is_interface(def_from) and
  1697. (def_to=rec_tguid) then
  1698. begin
  1699. doconv:=tc_intf_2_guid;
  1700. b:=1;
  1701. end
  1702. else
  1703. begin
  1704. { assignment overwritten ?? }
  1705. if assignment_overloaded(def_from,def_to)<>nil then
  1706. b:=2;
  1707. end;
  1708. end;
  1709. else
  1710. begin
  1711. { assignment overwritten ?? }
  1712. if assignment_overloaded(def_from,def_to)<>nil then
  1713. b:=2;
  1714. end;
  1715. end;
  1716. isconvertable:=b;
  1717. end;
  1718. function CheckTypes(def1,def2 : tdef) : boolean;
  1719. var
  1720. s1,s2 : string;
  1721. begin
  1722. if not is_equal(def1,def2) then
  1723. begin
  1724. { Crash prevention }
  1725. if (not assigned(def1)) or (not assigned(def2)) then
  1726. Message(type_e_mismatch)
  1727. else
  1728. begin
  1729. s1:=def1.typename;
  1730. s2:=def2.typename;
  1731. if (s1<>'<unknown type>') and (s2<>'<unknown type>') then
  1732. Message2(type_e_not_equal_types,def1.typename,def2.typename)
  1733. else
  1734. Message(type_e_mismatch);
  1735. end;
  1736. CheckTypes:=false;
  1737. end
  1738. else
  1739. CheckTypes:=true;
  1740. end;
  1741. end.
  1742. {
  1743. $Log$
  1744. Revision 1.62 2002-01-06 21:50:44 peter
  1745. * proc_to_procvar_equal fixed for procvar-procvar
  1746. Revision 1.61 2002/01/06 12:08:16 peter
  1747. * removed uauto from orddef, use new range_to_basetype generating
  1748. the correct ordinal type for a range
  1749. Revision 1.60 2001/12/17 12:49:08 jonas
  1750. * added type conversion from procvar to procvar (if their arguments are
  1751. convertable, two procvars are convertable too) ("merged")
  1752. Revision 1.59 2001/12/10 14:34:04 jonas
  1753. * fixed type conversions from dynamic arrays to open arrays
  1754. Revision 1.58 2001/12/03 21:48:43 peter
  1755. * freemem change to value parameter
  1756. * torddef low/high range changed to int64
  1757. Revision 1.57 2001/11/14 01:12:45 florian
  1758. * variant paramter passing and functions results fixed
  1759. Revision 1.56 2001/11/02 23:24:12 jonas
  1760. * fixed web bug 1665 (allow char to chararray type conversion) ("merged")
  1761. Revision 1.55 2001/11/02 22:58:09 peter
  1762. * procsym definition rewrite
  1763. Revision 1.54 2001/10/28 17:22:25 peter
  1764. * allow assignment of overloaded procedures to procvars when we know
  1765. which procedure to take
  1766. Revision 1.52 2001/10/22 21:21:09 peter
  1767. * allow enum(enum)
  1768. Revision 1.51 2001/10/22 15:13:49 jonas
  1769. * allow typeconversion of open array-of-char to string
  1770. Revision 1.50 2001/10/20 19:28:39 peter
  1771. * interface 2 guid support
  1772. * guid constants support
  1773. Revision 1.49 2001/10/17 22:41:05 florian
  1774. * several widechar fixes, case works now
  1775. Revision 1.48 2001/10/16 17:15:44 jonas
  1776. * auto-converting from int64 to real is again allowed for all modes
  1777. (it's allowed in Delphi too)
  1778. Revision 1.47 2001/09/03 13:27:41 jonas
  1779. * compilerproc implementation of set addition/substraction/...
  1780. * changed the declaration of some set helpers somewhat to accomodate the
  1781. above change
  1782. * i386 still uses the old code for comparisons of sets, because its
  1783. helpers return the results in the flags
  1784. * dummy tc_normal_2_small_set type conversion because I need the original
  1785. resulttype of the set add nodes
  1786. NOTE: you have to start a cycle with 1.0.5!
  1787. Revision 1.46 2001/09/02 21:15:34 peter
  1788. * don't allow int64->real for delphi mode
  1789. Revision 1.45 2001/08/19 21:11:21 florian
  1790. * some bugs fix:
  1791. - overload; with external procedures fixed
  1792. - better selection of routine to do an overloaded
  1793. type case
  1794. - ... some more
  1795. Revision 1.44 2001/07/08 21:00:16 peter
  1796. * various widestring updates, it works now mostly without charset
  1797. mapping supported
  1798. Revision 1.43 2001/06/29 14:16:57 jonas
  1799. * fixed inconsistent handling of procvars in FPC mode (sometimes @ was
  1800. required to assign the address of a procedure to a procvar, sometimes
  1801. not. Now it is always required) (merged)
  1802. Revision 1.42 2001/05/08 21:06:33 florian
  1803. * some more support for widechars commited especially
  1804. regarding type casting and constants
  1805. Revision 1.41 2001/04/22 22:46:49 florian
  1806. * more variant support
  1807. Revision 1.40 2001/04/18 22:02:00 peter
  1808. * registration of targets and assemblers
  1809. Revision 1.39 2001/04/13 01:22:17 peter
  1810. * symtable change to classes
  1811. * range check generation and errors fixed, make cycle DEBUG=1 works
  1812. * memory leaks fixed
  1813. Revision 1.38 2001/04/04 21:30:47 florian
  1814. * applied several fixes to get the DD8 Delphi Unit compiled
  1815. e.g. "forward"-interfaces are working now
  1816. Revision 1.37 2001/04/02 21:20:35 peter
  1817. * resulttype rewrite
  1818. Revision 1.36 2001/03/23 00:16:07 florian
  1819. + some stuff to compile FreeCLX added
  1820. Revision 1.35 2001/03/03 12:38:33 jonas
  1821. + support for arraydefs in is_signed (for their rangetype, used in rangechecks)
  1822. Revision 1.34 2001/02/26 19:44:55 peter
  1823. * merged generic m68k updates from fixes branch
  1824. Revision 1.33 2001/02/26 12:47:46 jonas
  1825. * fixed bug in type checking for compatibility of set elements (merged)
  1826. * released fix in options.pas from Carl also for FPC (merged)
  1827. Revision 1.32 2001/02/20 21:44:25 peter
  1828. * tvarrec -> array of const fixed
  1829. Revision 1.31 2001/01/22 11:20:15 jonas
  1830. * fixed web bug 1363 (merged)
  1831. Revision 1.30 2001/01/08 21:43:38 peter
  1832. * string isn't compatible with array of char
  1833. Revision 1.29 2000/12/25 00:07:30 peter
  1834. + new tlinkedlist class (merge of old tstringqueue,tcontainer and
  1835. tlinkedlist objects)
  1836. Revision 1.28 2000/12/22 22:38:12 peter
  1837. * fixed bug #1286
  1838. Revision 1.27 2000/12/20 15:59:40 jonas
  1839. - removed obsolete special case for range checking of cardinal constants
  1840. at compile time
  1841. Revision 1.26 2000/12/11 19:13:54 jonas
  1842. * fixed range checking of cardinal constants
  1843. * fixed range checking of "qword constants" (they don't really exist,
  1844. but values > high(int64) were set to zero if assigned to qword)
  1845. Revision 1.25 2000/12/08 14:06:11 jonas
  1846. * fix for web bug 1245: arrays of char with size >255 are now passed to
  1847. overloaded procedures which expect ansistrings instead of shortstrings
  1848. if possible
  1849. * pointer to array of chars (when using $t+) are now also considered
  1850. pchars
  1851. Revision 1.24 2000/11/20 15:52:47 jonas
  1852. * testrange now always cuts a constant to the size of the destination
  1853. if a rangeerror occurred
  1854. * changed an "and $ffffffff" to "and (int64($fffffff) shl 4 + $f" to
  1855. work around the constant evaluation problem we currently have
  1856. Revision 1.23 2000/11/13 14:42:41 jonas
  1857. * fix in testrange so that 64bit constants are properly truncated when
  1858. assigned to 32bit vars
  1859. Revision 1.22 2000/11/13 11:30:55 florian
  1860. * some bugs with interfaces and NIL fixed
  1861. Revision 1.21 2000/11/12 23:24:12 florian
  1862. * interfaces are basically running
  1863. Revision 1.20 2000/11/11 16:13:31 peter
  1864. * farpointer and normal pointer aren't compatible
  1865. Revision 1.19 2000/11/06 22:30:30 peter
  1866. * more fixes
  1867. Revision 1.18 2000/11/04 14:25:22 florian
  1868. + merged Attila's changes for interfaces, not tested yet
  1869. Revision 1.17 2000/10/31 22:30:13 peter
  1870. * merged asm result patch part 2
  1871. Revision 1.16 2000/10/31 22:02:55 peter
  1872. * symtable splitted, no real code changes
  1873. Revision 1.15 2000/10/21 18:16:12 florian
  1874. * a lot of changes:
  1875. - basic dyn. array support
  1876. - basic C++ support
  1877. - some work for interfaces done
  1878. ....
  1879. Revision 1.14 2000/10/14 10:14:56 peter
  1880. * moehrendorf oct 2000 rewrite
  1881. Revision 1.13 2000/10/01 19:48:26 peter
  1882. * lot of compile updates for cg11
  1883. Revision 1.12 2000/09/30 16:08:46 peter
  1884. * more cg11 updates
  1885. Revision 1.11 2000/09/24 15:06:32 peter
  1886. * use defines.inc
  1887. Revision 1.10 2000/09/18 12:31:15 jonas
  1888. * fixed bug in push_addr_param for arrays (merged from fixes branch)
  1889. Revision 1.9 2000/09/10 20:16:21 peter
  1890. * array of const isn't equal with array of <type> (merged)
  1891. Revision 1.8 2000/08/19 19:51:03 peter
  1892. * fixed bug with comparing constsym strings
  1893. Revision 1.7 2000/08/16 13:06:07 florian
  1894. + support of 64 bit integer constants
  1895. Revision 1.6 2000/08/13 13:07:18 peter
  1896. * equal_paras now also checks default parameter value
  1897. Revision 1.5 2000/08/12 06:49:22 florian
  1898. + case statement for int64/qword implemented
  1899. Revision 1.4 2000/08/08 19:26:41 peter
  1900. * equal_constsym() needed for default para
  1901. Revision 1.3 2000/07/13 12:08:28 michael
  1902. + patched to 1.1.0 with former 1.09patch from peter
  1903. Revision 1.2 2000/07/13 11:32:53 michael
  1904. + removed logs
  1905. }