types.pas 76 KB

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