types.pas 75 KB

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