types.pas 74 KB

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