types.pas 73 KB

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