types.pas 73 KB

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