types.pas 75 KB

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