tree.pas 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140
  1. {
  2. $Id$
  3. Copyright (c) 1993-98 by Florian Klaempfl
  4. This units exports some routines to manage the parse tree
  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. {$ifdef tp}
  19. {$E+,N+}
  20. {$endif}
  21. unit tree;
  22. interface
  23. uses
  24. globtype,cobjects,
  25. symconst,symtable,aasm,cpubase;
  26. type
  27. pconstset = ^tconstset;
  28. tconstset = array[0..31] of byte;
  29. ttreetyp = (
  30. addn, {Represents the + operator.}
  31. muln, {Represents the * operator.}
  32. subn, {Represents the - operator.}
  33. divn, {Represents the div operator.}
  34. symdifn, {Represents the >< operator.}
  35. modn, {Represents the mod operator.}
  36. assignn, {Represents an assignment.}
  37. loadn, {Represents the use of a variabele.}
  38. rangen, {Represents a range (i.e. 0..9).}
  39. ltn, {Represents the < operator.}
  40. lten, {Represents the <= operator.}
  41. gtn, {Represents the > operator.}
  42. gten, {Represents the >= operator.}
  43. equaln, {Represents the = operator.}
  44. unequaln, {Represents the <> operator.}
  45. inn, {Represents the in operator.}
  46. orn, {Represents the or operator.}
  47. xorn, {Represents the xor operator.}
  48. shrn, {Represents the shr operator.}
  49. shln, {Represents the shl operator.}
  50. slashn, {Represents the / operator.}
  51. andn, {Represents the and operator.}
  52. subscriptn, {??? Field in a record/object?}
  53. derefn, {Dereferences a pointer.}
  54. addrn, {Represents the @ operator.}
  55. doubleaddrn, {Represents the @@ operator.}
  56. ordconstn, {Represents an ordinal value.}
  57. typeconvn, {Represents type-conversion/typecast.}
  58. calln, {Represents a call node.}
  59. callparan, {Represents a parameter.}
  60. realconstn, {Represents a real value.}
  61. fixconstn, {Represents a fixed value.}
  62. umminusn, {Represents a sign change (i.e. -2).}
  63. asmn, {Represents an assembler node }
  64. vecn, {Represents array indexing.}
  65. stringconstn, {Represents a string constant.}
  66. funcretn, {Represents the function result var.}
  67. selfn, {Represents the self parameter.}
  68. notn, {Represents the not operator.}
  69. inlinen, {Internal procedures (i.e. writeln).}
  70. niln, {Represents the nil pointer.}
  71. errorn, {This part of the tree could not be
  72. parsed because of a compiler error.}
  73. typen, {A type name. Used for i.e. typeof(obj).}
  74. hnewn, {The new operation, constructor call.}
  75. hdisposen, {The dispose operation with destructor call.}
  76. newn, {The new operation, constructor call.}
  77. simpledisposen, {The dispose operation.}
  78. setelementn, {A set element(s) (i.e. [a,b] and also [a..b]).}
  79. setconstn, {A set constant (i.e. [1,2]).}
  80. blockn, {A block of statements.}
  81. statementn, {One statement in a block of nodes.}
  82. loopn, { used in genloopnode, must be converted }
  83. ifn, {An if statement.}
  84. breakn, {A break statement.}
  85. continuen, {A continue statement.}
  86. repeatn, {A repeat until block.}
  87. whilen, {A while do statement.}
  88. forn, {A for loop.}
  89. exitn, {An exit statement.}
  90. withn, {A with statement.}
  91. casen, {A case statement.}
  92. labeln, {A label.}
  93. goton, {A goto statement.}
  94. simplenewn, {The new operation.}
  95. tryexceptn, {A try except block.}
  96. raisen, {A raise statement.}
  97. switchesn, {??? Currently unused...}
  98. tryfinallyn, {A try finally statement.}
  99. onn, { for an on statement in exception code }
  100. isn, {Represents the is operator.}
  101. asn, {Represents the as typecast.}
  102. caretn, {Represents the ^ operator.}
  103. failn, {Represents the fail statement.}
  104. starstarn, {Represents the ** operator exponentiation }
  105. procinlinen, {Procedures that can be inlined }
  106. arrayconstructn, {Construction node for [...] parsing}
  107. arrayconstructrangen, {Range element to allow sets in array construction tree}
  108. { added for optimizations where we cannot suppress }
  109. nothingn,
  110. loadvmtn
  111. );
  112. tconverttype = (
  113. tc_equal,
  114. tc_not_possible,
  115. tc_string_2_string,
  116. tc_char_2_string,
  117. tc_pchar_2_string,
  118. tc_cchar_2_pchar,
  119. tc_cstring_2_pchar,
  120. tc_ansistring_2_pchar,
  121. tc_string_2_chararray,
  122. tc_chararray_2_string,
  123. tc_array_2_pointer,
  124. tc_pointer_2_array,
  125. tc_int_2_int,
  126. tc_int_2_bool,
  127. tc_bool_2_bool,
  128. tc_bool_2_int,
  129. tc_real_2_real,
  130. tc_int_2_real,
  131. tc_int_2_fix,
  132. tc_real_2_fix,
  133. tc_fix_2_real,
  134. tc_proc_2_procvar,
  135. tc_arrayconstructor_2_set,
  136. tc_load_smallset
  137. );
  138. { allows to determine which elementes are to be replaced }
  139. tdisposetyp = (dt_nothing,dt_leftright,dt_left,dt_leftrighthigh,
  140. dt_mbleft,dt_typeconv,dt_inlinen,dt_leftrightmethod,
  141. dt_mbleft_and_method,dt_loop,dt_case,dt_with,dt_onn);
  142. { different assignment types }
  143. tassigntyp = (at_normal,at_plus,at_minus,at_star,at_slash);
  144. pcaserecord = ^tcaserecord;
  145. tcaserecord = record
  146. { range }
  147. _low,_high : longint;
  148. { only used by gentreejmp }
  149. _at : pasmlabel;
  150. { label of instruction }
  151. statement : pasmlabel;
  152. { is this the first of an case entry, needed to release statement
  153. label (PFV) }
  154. firstlabel : boolean;
  155. { left and right tree node }
  156. less,greater : pcaserecord;
  157. end;
  158. ptree = ^ttree;
  159. ttree = record
  160. error : boolean;
  161. disposetyp : tdisposetyp;
  162. { is true, if the right and left operand are swaped }
  163. swaped : boolean;
  164. { the location of the result of this node }
  165. location : tlocation;
  166. { the number of registers needed to evalute the node }
  167. registers32,registersfpu : longint; { must be longint !!!! }
  168. {$ifdef SUPPORT_MMX}
  169. registersmmx : longint;
  170. {$endif SUPPORT_MMX}
  171. left,right : ptree;
  172. resulttype : pdef;
  173. fileinfo : tfileposinfo;
  174. localswitches : tlocalswitches;
  175. {$ifdef extdebug}
  176. firstpasscount : longint;
  177. {$endif extdebug}
  178. {$ifdef TEMPREGDEBUG}
  179. usableregs : longint;
  180. {$endif TEMPREGDEBUG}
  181. {$ifdef TEMPS_NOT_PUSH}
  182. temp_offset : longint;
  183. {$endif TEMPS_NOT_PUSH}
  184. case treetype : ttreetyp of
  185. addn : (use_strconcat : boolean;string_typ : tstringtype);
  186. callparan : (is_colon_para : boolean;exact_match_found,
  187. convlevel1found,convlevel2found:boolean;hightree:ptree);
  188. assignn : (assigntyp : tassigntyp;concat_string : boolean);
  189. loadn : (symtableentry : psym;symtable : psymtable;
  190. is_absolute,is_first : boolean);
  191. calln : (symtableprocentry : pprocsym;
  192. symtableproc : psymtable;procdefinition : pabstractprocdef;
  193. methodpointer : ptree;
  194. no_check,unit_specific,
  195. return_value_used,static_call : boolean);
  196. ordconstn : (value : longint);
  197. realconstn : (value_real : bestreal;lab_real : pasmlabel);
  198. fixconstn : (value_fix: longint);
  199. funcretn : (funcretprocinfo : pointer;retdef : pdef);
  200. subscriptn : (vs : pvarsym);
  201. vecn : (memindex,memseg:boolean;callunique : boolean);
  202. stringconstn : (value_str : pchar;length : longint; lab_str : pasmlabel;stringtype : tstringtype);
  203. typeconvn : (convtyp : tconverttype;explizit : boolean);
  204. typen : (typenodetype : pdef;typenodesym:ptypesym);
  205. inlinen : (inlinenumber : byte;inlineconst:boolean);
  206. procinlinen : (inlinetree:ptree;inlineprocsym:pprocsym;retoffset,para_offset,para_size : longint);
  207. setconstn : (value_set : pconstset;lab_set:pasmlabel);
  208. loopn : (t1,t2 : ptree;backward : boolean);
  209. asmn : (p_asm : paasmoutput;object_preserved : boolean);
  210. casen : (nodes : pcaserecord;elseblock : ptree);
  211. labeln,goton : (labelnr : pasmlabel);
  212. withn : (withsymtable : pwithsymtable;tablecount : longint;withreference:preference;islocal:boolean);
  213. onn : (exceptsymtable : psymtable;excepttype : pobjectdef);
  214. arrayconstructn : (cargs,cargswap,forcevaria,novariaallowed: boolean;constructdef:pdef);
  215. end;
  216. function gennode(t : ttreetyp;l,r : ptree) : ptree;
  217. function genlabelnode(t : ttreetyp;nr : pasmlabel) : ptree;
  218. function genloadnode(v : pvarsym;st : psymtable) : ptree;
  219. function genloadcallnode(v: pprocsym;st: psymtable): ptree;
  220. function genloadmethodcallnode(v: pprocsym;st: psymtable; mp:ptree): ptree;
  221. function gensinglenode(t : ttreetyp;l : ptree) : ptree;
  222. function gensubscriptnode(varsym : pvarsym;l : ptree) : ptree;
  223. function genordinalconstnode(v : longint;def : pdef) : ptree;
  224. function genfixconstnode(v : longint;def : pdef) : ptree;
  225. function gentypeconvnode(node : ptree;t : pdef) : ptree;
  226. function gentypenode(t : pdef;sym:ptypesym) : ptree;
  227. function gencallparanode(expr,next : ptree) : ptree;
  228. function genrealconstnode(v : bestreal;def : pdef) : ptree;
  229. function gencallnode(v : pprocsym;st : psymtable) : ptree;
  230. function genmethodcallnode(v : pprocsym;st : psymtable;mp : ptree) : ptree;
  231. { allow pchar or string for defining a pchar node }
  232. function genstringconstnode(const s : string) : ptree;
  233. { length is required for ansistrings }
  234. function genpcharconstnode(s : pchar;length : longint) : ptree;
  235. { helper routine for conststring node }
  236. function getpcharcopy(p : ptree) : pchar;
  237. function genzeronode(t : ttreetyp) : ptree;
  238. function geninlinenode(number : byte;is_const:boolean;l : ptree) : ptree;
  239. function genprocinlinenode(callp,code : ptree) : ptree;
  240. function gentypedconstloadnode(sym : ptypedconstsym;st : psymtable) : ptree;
  241. function genenumnode(v : penumsym) : ptree;
  242. function genselfnode(_class : pdef) : ptree;
  243. function gensetconstnode(s : pconstset;settype : psetdef) : ptree;
  244. function genloopnode(t : ttreetyp;l,r,n1: ptree;back : boolean) : ptree;
  245. function genasmnode(p_asm : paasmoutput) : ptree;
  246. function gencasenode(l,r : ptree;nodes : pcaserecord) : ptree;
  247. function genwithnode(symtable : pwithsymtable;l,r : ptree;count : longint) : ptree;
  248. function getcopy(p : ptree) : ptree;
  249. function equal_trees(t1,t2 : ptree) : boolean;
  250. procedure swaptree(p:Ptree);
  251. procedure disposetree(p : ptree);
  252. procedure putnode(p : ptree);
  253. function getnode : ptree;
  254. procedure clear_location(var loc : tlocation);
  255. procedure set_location(var destloc,sourceloc : tlocation);
  256. procedure swap_location(var destloc,sourceloc : tlocation);
  257. procedure set_file_line(from,_to : ptree);
  258. procedure set_tree_filepos(p : ptree;const filepos : tfileposinfo);
  259. {$ifdef extdebug}
  260. procedure compare_trees(oldp,p : ptree);
  261. const
  262. maxfirstpasscount : longint = 0;
  263. {$endif extdebug}
  264. { sets the callunique flag, if the node is a vecn, }
  265. { takes care of type casts etc. }
  266. procedure set_unique(p : ptree);
  267. { gibt den ordinalen Werten der Node zurueck oder falls sie }
  268. { keinen ordinalen Wert hat, wird ein Fehler erzeugt }
  269. function get_ordinal_value(p : ptree) : longint;
  270. function is_constnode(p : ptree) : boolean;
  271. { true, if p is a pointer to a const int value }
  272. function is_constintnode(p : ptree) : boolean;
  273. function is_constboolnode(p : ptree) : boolean;
  274. function is_constrealnode(p : ptree) : boolean;
  275. function is_constcharnode(p : ptree) : boolean;
  276. function str_length(p : ptree) : longint;
  277. function is_emptyset(p : ptree):boolean;
  278. { counts the labels }
  279. function case_count_labels(root : pcaserecord) : longint;
  280. { searches the highest label }
  281. function case_get_max(root : pcaserecord) : longint;
  282. { searches the lowest label }
  283. function case_get_min(root : pcaserecord) : longint;
  284. type
  285. pptree = ^ptree;
  286. {$ifdef TEMPREGDEBUG}
  287. const
  288. curptree : pptree = nil;
  289. {$endif TEMPREGDEBUG}
  290. {$I innr.inc}
  291. implementation
  292. uses
  293. systems,
  294. globals,verbose,files,types;
  295. function getnode : ptree;
  296. var
  297. hp : ptree;
  298. begin
  299. new(hp);
  300. { makes error tracking easier }
  301. fillchar(hp^,sizeof(ttree),0);
  302. { reset }
  303. hp^.location.loc:=LOC_INVALID;
  304. { save local info }
  305. hp^.fileinfo:=aktfilepos;
  306. hp^.localswitches:=aktlocalswitches;
  307. getnode:=hp;
  308. end;
  309. procedure putnode(p : ptree);
  310. begin
  311. { clean up the contents of a node }
  312. case p^.treetype of
  313. asmn : if assigned(p^.p_asm) then
  314. dispose(p^.p_asm,done);
  315. stringconstn : begin
  316. ansistringdispose(p^.value_str,p^.length);
  317. end;
  318. setconstn : begin
  319. if assigned(p^.value_set) then
  320. dispose(p^.value_set);
  321. end;
  322. end;
  323. {$ifdef extdebug}
  324. if p^.firstpasscount>maxfirstpasscount then
  325. maxfirstpasscount:=p^.firstpasscount;
  326. {$endif extdebug}
  327. dispose(p);
  328. end;
  329. function getcopy(p : ptree) : ptree;
  330. var
  331. hp : ptree;
  332. begin
  333. if not assigned(p) then
  334. begin
  335. getcopy:=nil;
  336. exit;
  337. end;
  338. hp:=getnode;
  339. hp^:=p^;
  340. case p^.disposetyp of
  341. dt_leftright :
  342. begin
  343. if assigned(p^.left) then
  344. hp^.left:=getcopy(p^.left);
  345. if assigned(p^.right) then
  346. hp^.right:=getcopy(p^.right);
  347. end;
  348. dt_leftrighthigh :
  349. begin
  350. if assigned(p^.left) then
  351. hp^.left:=getcopy(p^.left);
  352. if assigned(p^.right) then
  353. hp^.right:=getcopy(p^.right);
  354. if assigned(p^.hightree) then
  355. hp^.left:=getcopy(p^.hightree);
  356. end;
  357. dt_leftrightmethod :
  358. begin
  359. if assigned(p^.left) then
  360. hp^.left:=getcopy(p^.left);
  361. if assigned(p^.right) then
  362. hp^.right:=getcopy(p^.right);
  363. if assigned(p^.methodpointer) then
  364. hp^.left:=getcopy(p^.methodpointer);
  365. end;
  366. dt_nothing : ;
  367. dt_left :
  368. if assigned(p^.left) then
  369. hp^.left:=getcopy(p^.left);
  370. dt_mbleft :
  371. if assigned(p^.left) then
  372. hp^.left:=getcopy(p^.left);
  373. dt_mbleft_and_method :
  374. begin
  375. if assigned(p^.left) then
  376. hp^.left:=getcopy(p^.left);
  377. hp^.methodpointer:=getcopy(p^.methodpointer);
  378. end;
  379. dt_loop :
  380. begin
  381. if assigned(p^.left) then
  382. hp^.left:=getcopy(p^.left);
  383. if assigned(p^.right) then
  384. hp^.right:=getcopy(p^.right);
  385. if assigned(p^.t1) then
  386. hp^.t1:=getcopy(p^.t1);
  387. if assigned(p^.t2) then
  388. hp^.t2:=getcopy(p^.t2);
  389. end;
  390. dt_typeconv : hp^.left:=getcopy(p^.left);
  391. dt_inlinen :
  392. if assigned(p^.left) then
  393. hp^.left:=getcopy(p^.left);
  394. else internalerror(11);
  395. end;
  396. { now check treetype }
  397. case p^.treetype of
  398. stringconstn : begin
  399. hp^.value_str:=getpcharcopy(p);
  400. hp^.length:=p^.length;
  401. end;
  402. setconstn : begin
  403. new(hp^.value_set);
  404. hp^.value_set:=p^.value_set;
  405. end;
  406. end;
  407. getcopy:=hp;
  408. end;
  409. procedure deletecaselabels(p : pcaserecord);
  410. begin
  411. if assigned(p^.greater) then
  412. deletecaselabels(p^.greater);
  413. if assigned(p^.less) then
  414. deletecaselabels(p^.less);
  415. freelabel(p^._at);
  416. if p^.firstlabel then
  417. freelabel(p^.statement);
  418. dispose(p);
  419. end;
  420. procedure swaptree(p:Ptree);
  421. var swapp:Ptree;
  422. begin
  423. swapp:=p^.right;
  424. p^.right:=p^.left;
  425. p^.left:=swapp;
  426. p^.swaped:=not(p^.swaped);
  427. end;
  428. procedure disposetree(p : ptree);
  429. var
  430. symt : pwithsymtable;
  431. i : longint;
  432. begin
  433. if not(assigned(p)) then
  434. exit;
  435. if not(p^.treetype in [addn..loadvmtn]) then
  436. internalerror(26219);
  437. case p^.disposetyp of
  438. dt_leftright :
  439. begin
  440. if assigned(p^.left) then
  441. disposetree(p^.left);
  442. if assigned(p^.right) then
  443. disposetree(p^.right);
  444. end;
  445. dt_leftrighthigh :
  446. begin
  447. if assigned(p^.left) then
  448. disposetree(p^.left);
  449. if assigned(p^.right) then
  450. disposetree(p^.right);
  451. if assigned(p^.hightree) then
  452. disposetree(p^.hightree);
  453. end;
  454. dt_leftrightmethod :
  455. begin
  456. if assigned(p^.left) then
  457. disposetree(p^.left);
  458. if assigned(p^.right) then
  459. disposetree(p^.right);
  460. if assigned(p^.methodpointer) then
  461. disposetree(p^.methodpointer);
  462. end;
  463. dt_case :
  464. begin
  465. if assigned(p^.left) then
  466. disposetree(p^.left);
  467. if assigned(p^.right) then
  468. disposetree(p^.right);
  469. if assigned(p^.nodes) then
  470. deletecaselabels(p^.nodes);
  471. if assigned(p^.elseblock) then
  472. disposetree(p^.elseblock);
  473. end;
  474. dt_nothing : ;
  475. dt_left :
  476. if assigned(p^.left) then
  477. disposetree(p^.left);
  478. dt_mbleft :
  479. if assigned(p^.left) then
  480. disposetree(p^.left);
  481. dt_mbleft_and_method :
  482. begin
  483. if assigned(p^.left) then disposetree(p^.left);
  484. disposetree(p^.methodpointer);
  485. end;
  486. dt_typeconv : disposetree(p^.left);
  487. dt_inlinen :
  488. if assigned(p^.left) then
  489. disposetree(p^.left);
  490. dt_loop :
  491. begin
  492. if assigned(p^.left) then
  493. disposetree(p^.left);
  494. if assigned(p^.right) then
  495. disposetree(p^.right);
  496. if assigned(p^.t1) then
  497. disposetree(p^.t1);
  498. if assigned(p^.t2) then
  499. disposetree(p^.t2);
  500. end;
  501. dt_onn:
  502. begin
  503. if assigned(p^.left) then
  504. disposetree(p^.left);
  505. if assigned(p^.right) then
  506. disposetree(p^.right);
  507. if assigned(p^.exceptsymtable) then
  508. dispose(p^.exceptsymtable,done);
  509. end;
  510. dt_with :
  511. begin
  512. if assigned(p^.left) then
  513. disposetree(p^.left);
  514. if assigned(p^.right) then
  515. disposetree(p^.right);
  516. symt:=p^.withsymtable;
  517. for i:=1 to p^.tablecount do
  518. begin
  519. if assigned(symt) then
  520. begin
  521. p^.withsymtable:=pwithsymtable(symt^.next);
  522. dispose(symt,done);
  523. end;
  524. symt:=p^.withsymtable;
  525. end;
  526. end;
  527. else internalerror(12);
  528. end;
  529. putnode(p);
  530. end;
  531. procedure set_file_line(from,_to : ptree);
  532. begin
  533. if assigned(from) then
  534. _to^.fileinfo:=from^.fileinfo;
  535. end;
  536. procedure set_tree_filepos(p : ptree;const filepos : tfileposinfo);
  537. begin
  538. p^.fileinfo:=filepos;
  539. end;
  540. function genwithnode(symtable : pwithsymtable;l,r : ptree;count : longint) : ptree;
  541. var
  542. p : ptree;
  543. begin
  544. p:=getnode;
  545. p^.disposetyp:=dt_with;
  546. p^.treetype:=withn;
  547. p^.left:=l;
  548. p^.right:=r;
  549. p^.registers32:=0;
  550. { p^.registers16:=0;
  551. p^.registers8:=0; }
  552. p^.registersfpu:=0;
  553. {$ifdef SUPPORT_MMX}
  554. p^.registersmmx:=0;
  555. {$endif SUPPORT_MMX}
  556. p^.resulttype:=nil;
  557. p^.withsymtable:=symtable;
  558. p^.tablecount:=count;
  559. p^.withreference:=nil;
  560. p^.islocal:=false;
  561. set_file_line(l,p);
  562. genwithnode:=p;
  563. end;
  564. function genfixconstnode(v : longint;def : pdef) : ptree;
  565. var
  566. p : ptree;
  567. begin
  568. p:=getnode;
  569. p^.disposetyp:=dt_nothing;
  570. p^.treetype:=fixconstn;
  571. p^.registers32:=0;
  572. { p^.registers16:=0;
  573. p^.registers8:=0; }
  574. p^.registersfpu:=0;
  575. {$ifdef SUPPORT_MMX}
  576. p^.registersmmx:=0;
  577. {$endif SUPPORT_MMX}
  578. p^.resulttype:=def;
  579. p^.value:=v;
  580. genfixconstnode:=p;
  581. end;
  582. function gencallparanode(expr,next : ptree) : ptree;
  583. var
  584. p : ptree;
  585. begin
  586. p:=getnode;
  587. p^.disposetyp:=dt_leftrighthigh;
  588. p^.treetype:=callparan;
  589. p^.left:=expr;
  590. p^.right:=next;
  591. p^.registers32:=0;
  592. { p^.registers16:=0;
  593. p^.registers8:=0; }
  594. {$ifdef SUPPORT_MMX}
  595. p^.registersmmx:=0;
  596. {$endif SUPPORT_MMX}
  597. p^.registersfpu:=0;
  598. p^.resulttype:=nil;
  599. p^.exact_match_found:=false;
  600. p^.convlevel1found:=false;
  601. p^.convlevel2found:=false;
  602. p^.is_colon_para:=false;
  603. p^.hightree:=nil;
  604. set_file_line(expr,p);
  605. gencallparanode:=p;
  606. end;
  607. function gennode(t : ttreetyp;l,r : ptree) : ptree;
  608. var
  609. p : ptree;
  610. begin
  611. p:=getnode;
  612. p^.disposetyp:=dt_leftright;
  613. p^.treetype:=t;
  614. p^.left:=l;
  615. p^.right:=r;
  616. p^.registers32:=0;
  617. { p^.registers16:=0;
  618. p^.registers8:=0; }
  619. p^.registersfpu:=0;
  620. {$ifdef SUPPORT_MMX}
  621. p^.registersmmx:=0;
  622. {$endif SUPPORT_MMX}
  623. p^.resulttype:=nil;
  624. gennode:=p;
  625. end;
  626. function gencasenode(l,r : ptree;nodes : pcaserecord) : ptree;
  627. var
  628. p : ptree;
  629. begin
  630. p:=getnode;
  631. p^.disposetyp:=dt_case;
  632. p^.treetype:=casen;
  633. p^.left:=l;
  634. p^.right:=r;
  635. p^.nodes:=nodes;
  636. p^.registers32:=0;
  637. p^.registersfpu:=0;
  638. {$ifdef SUPPORT_MMX}
  639. p^.registersmmx:=0;
  640. {$endif SUPPORT_MMX}
  641. p^.resulttype:=nil;
  642. set_file_line(l,p);
  643. gencasenode:=p;
  644. end;
  645. function genloopnode(t : ttreetyp;l,r,n1 : ptree;back : boolean) : ptree;
  646. var
  647. p : ptree;
  648. begin
  649. p:=getnode;
  650. p^.disposetyp:=dt_loop;
  651. p^.treetype:=t;
  652. p^.left:=l;
  653. p^.right:=r;
  654. p^.t1:=n1;
  655. p^.t2:=nil;
  656. p^.registers32:=0;
  657. p^.backward:=back;
  658. { p^.registers16:=0;
  659. p^.registers8:=0; }
  660. p^.registersfpu:=0;
  661. {$ifdef SUPPORT_MMX}
  662. p^.registersmmx:=0;
  663. {$endif SUPPORT_MMX}
  664. p^.resulttype:=nil;
  665. set_file_line(l,p);
  666. genloopnode:=p;
  667. end;
  668. function genordinalconstnode(v : longint;def : pdef) : ptree;
  669. var
  670. p : ptree;
  671. begin
  672. p:=getnode;
  673. p^.disposetyp:=dt_nothing;
  674. p^.treetype:=ordconstn;
  675. p^.registers32:=0;
  676. { p^.registers16:=0;
  677. p^.registers8:=0; }
  678. p^.registersfpu:=0;
  679. {$ifdef SUPPORT_MMX}
  680. p^.registersmmx:=0;
  681. {$endif SUPPORT_MMX}
  682. p^.resulttype:=def;
  683. p^.value:=v;
  684. if p^.resulttype^.deftype=orddef then
  685. testrange(p^.resulttype,p^.value);
  686. genordinalconstnode:=p;
  687. end;
  688. function genenumnode(v : penumsym) : ptree;
  689. var
  690. p : ptree;
  691. begin
  692. p:=getnode;
  693. p^.disposetyp:=dt_nothing;
  694. p^.treetype:=ordconstn;
  695. p^.registers32:=0;
  696. { p^.registers16:=0;
  697. p^.registers8:=0; }
  698. p^.registersfpu:=0;
  699. {$ifdef SUPPORT_MMX}
  700. p^.registersmmx:=0;
  701. {$endif SUPPORT_MMX}
  702. p^.resulttype:=v^.definition;
  703. p^.value:=v^.value;
  704. testrange(p^.resulttype,p^.value);
  705. genenumnode:=p;
  706. end;
  707. function genrealconstnode(v : bestreal;def : pdef) : ptree;
  708. var
  709. p : ptree;
  710. begin
  711. p:=getnode;
  712. p^.disposetyp:=dt_nothing;
  713. p^.treetype:=realconstn;
  714. p^.registers32:=0;
  715. { p^.registers16:=0;
  716. p^.registers8:=0; }
  717. p^.registersfpu:=0;
  718. {$ifdef SUPPORT_MMX}
  719. p^.registersmmx:=0;
  720. {$endif SUPPORT_MMX}
  721. p^.resulttype:=def;
  722. p^.value_real:=v;
  723. p^.lab_real:=nil;
  724. genrealconstnode:=p;
  725. end;
  726. function genstringconstnode(const s : string) : ptree;
  727. var
  728. p : ptree;
  729. l : longint;
  730. begin
  731. p:=getnode;
  732. p^.disposetyp:=dt_nothing;
  733. p^.treetype:=stringconstn;
  734. p^.registers32:=0;
  735. { p^.registers16:=0;
  736. p^.registers8:=0; }
  737. p^.registersfpu:=0;
  738. {$ifdef SUPPORT_MMX}
  739. p^.registersmmx:=0;
  740. {$endif SUPPORT_MMX}
  741. l:=length(s);
  742. p^.length:=l;
  743. { stringdup write even past a #0 }
  744. getmem(p^.value_str,l+1);
  745. move(s[1],p^.value_str^,l);
  746. p^.value_str[l]:=#0;
  747. p^.lab_str:=nil;
  748. if cs_ansistrings in aktlocalswitches then
  749. begin
  750. p^.stringtype:=st_ansistring;
  751. p^.resulttype:=cansistringdef;
  752. end
  753. else
  754. begin
  755. p^.stringtype:=st_shortstring;
  756. p^.resulttype:=cshortstringdef;
  757. end;
  758. genstringconstnode:=p;
  759. end;
  760. function getpcharcopy(p : ptree) : pchar;
  761. var
  762. pc : pchar;
  763. begin
  764. pc:=nil;
  765. getmem(pc,p^.length+1);
  766. if pc=nil then
  767. Message(general_f_no_memory_left);
  768. move(p^.value_str^,pc^,p^.length+1);
  769. getpcharcopy:=pc;
  770. end;
  771. function genpcharconstnode(s : pchar;length : longint) : ptree;
  772. var
  773. p : ptree;
  774. begin
  775. p:=getnode;
  776. p^.disposetyp:=dt_nothing;
  777. p^.treetype:=stringconstn;
  778. p^.registers32:=0;
  779. { p^.registers16:=0;
  780. p^.registers8:=0; }
  781. p^.registersfpu:=0;
  782. {$ifdef SUPPORT_MMX}
  783. p^.registersmmx:=0;
  784. {$endif SUPPORT_MMX}
  785. p^.length:=length;
  786. if (cs_ansistrings in aktlocalswitches) or
  787. (length>255) then
  788. begin
  789. p^.stringtype:=st_ansistring;
  790. p^.resulttype:=cansistringdef;
  791. end
  792. else
  793. begin
  794. p^.stringtype:=st_shortstring;
  795. p^.resulttype:=cshortstringdef;
  796. end;
  797. p^.value_str:=s;
  798. p^.lab_str:=nil;
  799. genpcharconstnode:=p;
  800. end;
  801. function gensinglenode(t : ttreetyp;l : ptree) : ptree;
  802. var
  803. p : ptree;
  804. begin
  805. p:=getnode;
  806. p^.disposetyp:=dt_left;
  807. p^.treetype:=t;
  808. p^.left:=l;
  809. p^.registers32:=0;
  810. { p^.registers16:=0;
  811. p^.registers8:=0; }
  812. p^.registersfpu:=0;
  813. {$ifdef SUPPORT_MMX}
  814. p^.registersmmx:=0;
  815. {$endif SUPPORT_MMX}
  816. p^.resulttype:=nil;
  817. gensinglenode:=p;
  818. end;
  819. function genasmnode(p_asm : paasmoutput) : ptree;
  820. var
  821. p : ptree;
  822. begin
  823. p:=getnode;
  824. p^.disposetyp:=dt_nothing;
  825. p^.treetype:=asmn;
  826. p^.registers32:=4;
  827. p^.p_asm:=p_asm;
  828. p^.object_preserved:=false;
  829. { p^.registers16:=0;
  830. p^.registers8:=0; }
  831. p^.registersfpu:=8;
  832. {$ifdef SUPPORT_MMX}
  833. p^.registersmmx:=8;
  834. {$endif SUPPORT_MMX}
  835. p^.resulttype:=nil;
  836. genasmnode:=p;
  837. end;
  838. function genloadnode(v : pvarsym;st : psymtable) : ptree;
  839. var
  840. p : ptree;
  841. begin
  842. p:=getnode;
  843. p^.registers32:=0;
  844. { p^.registers16:=0;
  845. p^.registers8:=0; }
  846. p^.registersfpu:=0;
  847. {$ifdef SUPPORT_MMX}
  848. p^.registersmmx:=0;
  849. {$endif SUPPORT_MMX}
  850. p^.treetype:=loadn;
  851. p^.resulttype:=v^.definition;
  852. p^.symtableentry:=v;
  853. p^.symtable:=st;
  854. p^.is_first := False;
  855. { method pointer load nodes can use the left subtree }
  856. p^.disposetyp:=dt_left;
  857. p^.left:=nil;
  858. genloadnode:=p;
  859. end;
  860. function genloadcallnode(v: pprocsym;st: psymtable): ptree;
  861. var
  862. p : ptree;
  863. begin
  864. p:=getnode;
  865. p^.registers32:=0;
  866. { p^.registers16:=0;
  867. p^.registers8:=0; }
  868. p^.registersfpu:=0;
  869. {$ifdef SUPPORT_MMX}
  870. p^.registersmmx:=0;
  871. {$endif SUPPORT_MMX}
  872. p^.treetype:=loadn;
  873. p^.left:=nil;
  874. p^.resulttype:=v^.definition;
  875. p^.symtableentry:=v;
  876. p^.symtable:=st;
  877. p^.is_first := False;
  878. p^.disposetyp:=dt_nothing;
  879. genloadcallnode:=p;
  880. end;
  881. function genloadmethodcallnode(v: pprocsym;st: psymtable; mp:ptree): ptree;
  882. var
  883. p : ptree;
  884. begin
  885. p:=getnode;
  886. p^.registers32:=0;
  887. { p^.registers16:=0;
  888. p^.registers8:=0; }
  889. p^.registersfpu:=0;
  890. {$ifdef SUPPORT_MMX}
  891. p^.registersmmx:=0;
  892. {$endif SUPPORT_MMX}
  893. p^.treetype:=loadn;
  894. p^.left:=nil;
  895. p^.resulttype:=v^.definition;
  896. p^.symtableentry:=v;
  897. p^.symtable:=st;
  898. p^.is_first := False;
  899. p^.disposetyp:=dt_left;
  900. p^.left:=mp;
  901. genloadmethodcallnode:=p;
  902. end;
  903. function gentypedconstloadnode(sym : ptypedconstsym;st : psymtable) : ptree;
  904. var
  905. p : ptree;
  906. begin
  907. p:=getnode;
  908. p^.registers32:=0;
  909. { p^.registers16:=0;
  910. p^.registers8:=0; }
  911. p^.registersfpu:=0;
  912. {$ifdef SUPPORT_MMX}
  913. p^.registersmmx:=0;
  914. {$endif SUPPORT_MMX}
  915. p^.treetype:=loadn;
  916. p^.left:=nil;
  917. p^.resulttype:=sym^.definition;
  918. p^.symtableentry:=sym;
  919. p^.symtable:=st;
  920. p^.disposetyp:=dt_nothing;
  921. gentypedconstloadnode:=p;
  922. end;
  923. function gentypeconvnode(node : ptree;t : pdef) : ptree;
  924. var
  925. p : ptree;
  926. begin
  927. p:=getnode;
  928. p^.disposetyp:=dt_typeconv;
  929. p^.treetype:=typeconvn;
  930. p^.left:=node;
  931. p^.registers32:=0;
  932. { p^.registers16:=0;
  933. p^.registers8:=0; }
  934. p^.convtyp:=tc_equal;
  935. p^.registersfpu:=0;
  936. {$ifdef SUPPORT_MMX}
  937. p^.registersmmx:=0;
  938. {$endif SUPPORT_MMX}
  939. p^.resulttype:=t;
  940. p^.explizit:=false;
  941. set_file_line(node,p);
  942. gentypeconvnode:=p;
  943. end;
  944. function gentypenode(t : pdef;sym:ptypesym) : ptree;
  945. var
  946. p : ptree;
  947. begin
  948. p:=getnode;
  949. p^.disposetyp:=dt_nothing;
  950. p^.treetype:=typen;
  951. p^.registers32:=0;
  952. { p^.registers16:=0;
  953. p^.registers8:=0; }
  954. p^.registersfpu:=0;
  955. {$ifdef SUPPORT_MMX}
  956. p^.registersmmx:=0;
  957. {$endif SUPPORT_MMX}
  958. p^.resulttype:=generrordef;
  959. p^.typenodetype:=t;
  960. p^.typenodesym:=sym;
  961. gentypenode:=p;
  962. end;
  963. function gencallnode(v : pprocsym;st : psymtable) : ptree;
  964. var
  965. p : ptree;
  966. begin
  967. p:=getnode;
  968. p^.registers32:=0;
  969. { p^.registers16:=0;
  970. p^.registers8:=0; }
  971. p^.registersfpu:=0;
  972. {$ifdef SUPPORT_MMX}
  973. p^.registersmmx:=0;
  974. {$endif SUPPORT_MMX}
  975. p^.treetype:=calln;
  976. p^.symtableprocentry:=v;
  977. p^.symtableproc:=st;
  978. p^.unit_specific:=false;
  979. p^.no_check:=false;
  980. p^.return_value_used:=true;
  981. p^.disposetyp := dt_leftrightmethod;
  982. p^.methodpointer:=nil;
  983. p^.left:=nil;
  984. p^.right:=nil;
  985. p^.procdefinition:=nil;
  986. gencallnode:=p;
  987. end;
  988. function genmethodcallnode(v : pprocsym;st : psymtable;mp : ptree) : ptree;
  989. var
  990. p : ptree;
  991. begin
  992. p:=getnode;
  993. p^.registers32:=0;
  994. { p^.registers16:=0;
  995. p^.registers8:=0; }
  996. p^.registersfpu:=0;
  997. {$ifdef SUPPORT_MMX}
  998. p^.registersmmx:=0;
  999. {$endif SUPPORT_MMX}
  1000. p^.treetype:=calln;
  1001. p^.return_value_used:=true;
  1002. p^.symtableprocentry:=v;
  1003. p^.symtableproc:=st;
  1004. p^.disposetyp:=dt_leftrightmethod;
  1005. p^.left:=nil;
  1006. p^.right:=nil;
  1007. p^.methodpointer:=mp;
  1008. p^.procdefinition:=nil;
  1009. genmethodcallnode:=p;
  1010. end;
  1011. function gensubscriptnode(varsym : pvarsym;l : ptree) : ptree;
  1012. var
  1013. p : ptree;
  1014. begin
  1015. p:=getnode;
  1016. p^.disposetyp:=dt_left;
  1017. p^.treetype:=subscriptn;
  1018. p^.left:=l;
  1019. p^.registers32:=0;
  1020. p^.vs:=varsym;
  1021. { p^.registers16:=0;
  1022. p^.registers8:=0; }
  1023. p^.registersfpu:=0;
  1024. {$ifdef SUPPORT_MMX}
  1025. p^.registersmmx:=0;
  1026. {$endif SUPPORT_MMX}
  1027. p^.resulttype:=nil;
  1028. gensubscriptnode:=p;
  1029. end;
  1030. function genzeronode(t : ttreetyp) : ptree;
  1031. var
  1032. p : ptree;
  1033. begin
  1034. p:=getnode;
  1035. p^.disposetyp:=dt_nothing;
  1036. p^.treetype:=t;
  1037. p^.registers32:=0;
  1038. { p^.registers16:=0;
  1039. p^.registers8:=0; }
  1040. p^.registersfpu:=0;
  1041. {$ifdef SUPPORT_MMX}
  1042. p^.registersmmx:=0;
  1043. {$endif SUPPORT_MMX}
  1044. p^.resulttype:=nil;
  1045. genzeronode:=p;
  1046. end;
  1047. function genlabelnode(t : ttreetyp;nr : pasmlabel) : ptree;
  1048. var
  1049. p : ptree;
  1050. begin
  1051. p:=getnode;
  1052. p^.disposetyp:=dt_nothing;
  1053. p^.treetype:=t;
  1054. p^.registers32:=0;
  1055. { p^.registers16:=0;
  1056. p^.registers8:=0; }
  1057. p^.registersfpu:=0;
  1058. {$ifdef SUPPORT_MMX}
  1059. p^.registersmmx:=0;
  1060. {$endif SUPPORT_MMX}
  1061. p^.resulttype:=nil;
  1062. { for security }
  1063. { nr^.is_used:=true;}
  1064. p^.labelnr:=nr;
  1065. genlabelnode:=p;
  1066. end;
  1067. function genselfnode(_class : pdef) : ptree;
  1068. var
  1069. p : ptree;
  1070. begin
  1071. p:=getnode;
  1072. p^.disposetyp:=dt_nothing;
  1073. p^.treetype:=selfn;
  1074. p^.registers32:=0;
  1075. { p^.registers16:=0;
  1076. p^.registers8:=0; }
  1077. p^.registersfpu:=0;
  1078. {$ifdef SUPPORT_MMX}
  1079. p^.registersmmx:=0;
  1080. {$endif SUPPORT_MMX}
  1081. p^.resulttype:=_class;
  1082. genselfnode:=p;
  1083. end;
  1084. function geninlinenode(number : byte;is_const:boolean;l : ptree) : ptree;
  1085. var
  1086. p : ptree;
  1087. begin
  1088. p:=getnode;
  1089. p^.disposetyp:=dt_inlinen;
  1090. p^.treetype:=inlinen;
  1091. p^.left:=l;
  1092. p^.inlinenumber:=number;
  1093. p^.inlineconst:=is_const;
  1094. p^.registers32:=0;
  1095. { p^.registers16:=0;
  1096. p^.registers8:=0; }
  1097. p^.registersfpu:=0;
  1098. {$ifdef SUPPORT_MMX}
  1099. p^.registersmmx:=0;
  1100. {$endif SUPPORT_MMX}
  1101. p^.resulttype:=nil;
  1102. geninlinenode:=p;
  1103. end;
  1104. { uses the callnode to create the new procinline node }
  1105. function genprocinlinenode(callp,code : ptree) : ptree;
  1106. var
  1107. p : ptree;
  1108. begin
  1109. p:=getnode;
  1110. p^.disposetyp:=dt_nothing;
  1111. p^.treetype:=procinlinen;
  1112. p^.inlineprocsym:=callp^.symtableprocentry;
  1113. p^.retoffset:=-4; { less dangerous as zero (PM) }
  1114. p^.para_offset:=0;
  1115. p^.para_size:=p^.inlineprocsym^.definition^.para_size;
  1116. if ret_in_param(p^.inlineprocsym^.definition^.retdef) then
  1117. p^.para_size:=p^.para_size+target_os.size_of_pointer;
  1118. { copy args }
  1119. p^.inlinetree:=code;
  1120. p^.registers32:=code^.registers32;
  1121. p^.registersfpu:=code^.registersfpu;
  1122. {$ifdef SUPPORT_MMX}
  1123. p^.registersmmx:=0;
  1124. {$endif SUPPORT_MMX}
  1125. p^.resulttype:=p^.inlineprocsym^.definition^.retdef;
  1126. genprocinlinenode:=p;
  1127. end;
  1128. function gensetconstnode(s : pconstset;settype : psetdef) : ptree;
  1129. var
  1130. p : ptree;
  1131. begin
  1132. p:=getnode;
  1133. p^.disposetyp:=dt_nothing;
  1134. p^.treetype:=setconstn;
  1135. p^.registers32:=0;
  1136. p^.registersfpu:=0;
  1137. {$ifdef SUPPORT_MMX}
  1138. p^.registersmmx:=0;
  1139. {$endif SUPPORT_MMX}
  1140. p^.resulttype:=settype;
  1141. p^.left:=nil;
  1142. new(p^.value_set);
  1143. p^.value_set^:=s^;
  1144. gensetconstnode:=p;
  1145. end;
  1146. {$ifdef extdebug}
  1147. procedure compare_trees(oldp,p : ptree);
  1148. var
  1149. error_found : boolean;
  1150. begin
  1151. if oldp^.resulttype<>p^.resulttype then
  1152. begin
  1153. error_found:=true;
  1154. if is_equal(oldp^.resulttype,p^.resulttype) then
  1155. comment(v_debug,'resulttype fields are different but equal')
  1156. else
  1157. comment(v_warning,'resulttype fields are really different');
  1158. end;
  1159. if oldp^.treetype<>p^.treetype then
  1160. begin
  1161. comment(v_warning,'treetype field different');
  1162. error_found:=true;
  1163. end
  1164. else
  1165. comment(v_debug,' treetype '+tostr(longint(oldp^.treetype)));
  1166. if oldp^.error<>p^.error then
  1167. begin
  1168. comment(v_warning,'error field different');
  1169. error_found:=true;
  1170. end;
  1171. if oldp^.disposetyp<>p^.disposetyp then
  1172. begin
  1173. comment(v_warning,'disposetyp field different');
  1174. error_found:=true;
  1175. end;
  1176. { is true, if the right and left operand are swaped }
  1177. if oldp^.swaped<>p^.swaped then
  1178. begin
  1179. comment(v_warning,'swaped field different');
  1180. error_found:=true;
  1181. end;
  1182. { the location of the result of this node }
  1183. if oldp^.location.loc<>p^.location.loc then
  1184. begin
  1185. comment(v_warning,'location.loc field different');
  1186. error_found:=true;
  1187. end;
  1188. { the number of registers needed to evalute the node }
  1189. if oldp^.registers32<>p^.registers32 then
  1190. begin
  1191. comment(v_warning,'registers32 field different');
  1192. comment(v_warning,' old '+tostr(oldp^.registers32)+'<> new '+tostr(p^.registers32));
  1193. error_found:=true;
  1194. end;
  1195. if oldp^.registersfpu<>p^.registersfpu then
  1196. begin
  1197. comment(v_warning,'registersfpu field different');
  1198. error_found:=true;
  1199. end;
  1200. {$ifdef SUPPORT_MMX}
  1201. if oldp^.registersmmx<>p^.registersmmx then
  1202. begin
  1203. comment(v_warning,'registersmmx field different');
  1204. error_found:=true;
  1205. end;
  1206. {$endif SUPPORT_MMX}
  1207. if oldp^.left<>p^.left then
  1208. begin
  1209. comment(v_warning,'left field different');
  1210. error_found:=true;
  1211. end;
  1212. if oldp^.right<>p^.right then
  1213. begin
  1214. comment(v_warning,'right field different');
  1215. error_found:=true;
  1216. end;
  1217. if oldp^.fileinfo.line<>p^.fileinfo.line then
  1218. begin
  1219. comment(v_warning,'fileinfo.line field different');
  1220. error_found:=true;
  1221. end;
  1222. if oldp^.fileinfo.column<>p^.fileinfo.column then
  1223. begin
  1224. comment(v_warning,'fileinfo.column field different');
  1225. error_found:=true;
  1226. end;
  1227. if oldp^.fileinfo.fileindex<>p^.fileinfo.fileindex then
  1228. begin
  1229. comment(v_warning,'fileinfo.fileindex field different');
  1230. error_found:=true;
  1231. end;
  1232. if oldp^.localswitches<>p^.localswitches then
  1233. begin
  1234. comment(v_warning,'localswitches field different');
  1235. error_found:=true;
  1236. end;
  1237. {$ifdef extdebug}
  1238. if oldp^.firstpasscount<>p^.firstpasscount then
  1239. begin
  1240. comment(v_warning,'firstpasscount field different');
  1241. error_found:=true;
  1242. end;
  1243. {$endif extdebug}
  1244. if oldp^.treetype=p^.treetype then
  1245. case oldp^.treetype of
  1246. addn :
  1247. begin
  1248. if oldp^.use_strconcat<>p^.use_strconcat then
  1249. begin
  1250. comment(v_warning,'use_strconcat field different');
  1251. error_found:=true;
  1252. end;
  1253. if oldp^.string_typ<>p^.string_typ then
  1254. begin
  1255. comment(v_warning,'stringtyp field different');
  1256. error_found:=true;
  1257. end;
  1258. end;
  1259. callparan :
  1260. {(is_colon_para : boolean;exact_match_found : boolean);}
  1261. begin
  1262. if oldp^.is_colon_para<>p^.is_colon_para then
  1263. begin
  1264. comment(v_warning,'use_strconcat field different');
  1265. error_found:=true;
  1266. end;
  1267. if oldp^.exact_match_found<>p^.exact_match_found then
  1268. begin
  1269. comment(v_warning,'exact_match_found field different');
  1270. error_found:=true;
  1271. end;
  1272. end;
  1273. assignn :
  1274. {(assigntyp : tassigntyp;concat_string : boolean);}
  1275. begin
  1276. if oldp^.assigntyp<>p^.assigntyp then
  1277. begin
  1278. comment(v_warning,'assigntyp field different');
  1279. error_found:=true;
  1280. end;
  1281. if oldp^.concat_string<>p^.concat_string then
  1282. begin
  1283. comment(v_warning,'concat_string field different');
  1284. error_found:=true;
  1285. end;
  1286. end;
  1287. loadn :
  1288. {(symtableentry : psym;symtable : psymtable;
  1289. is_absolute,is_first : boolean);}
  1290. begin
  1291. if oldp^.symtableentry<>p^.symtableentry then
  1292. begin
  1293. comment(v_warning,'symtableentry field different');
  1294. error_found:=true;
  1295. end;
  1296. if oldp^.symtable<>p^.symtable then
  1297. begin
  1298. comment(v_warning,'symtable field different');
  1299. error_found:=true;
  1300. end;
  1301. if oldp^.is_absolute<>p^.is_absolute then
  1302. begin
  1303. comment(v_warning,'is_absolute field different');
  1304. error_found:=true;
  1305. end;
  1306. if oldp^.is_first<>p^.is_first then
  1307. begin
  1308. comment(v_warning,'is_first field different');
  1309. error_found:=true;
  1310. end;
  1311. end;
  1312. calln :
  1313. {(symtableprocentry : pprocsym;
  1314. symtableproc : psymtable;procdefinition : pprocdef;
  1315. methodpointer : ptree;
  1316. no_check,unit_specific : boolean);}
  1317. begin
  1318. if oldp^.symtableprocentry<>p^.symtableprocentry then
  1319. begin
  1320. comment(v_warning,'symtableprocentry field different');
  1321. error_found:=true;
  1322. end;
  1323. if oldp^.symtableproc<>p^.symtableproc then
  1324. begin
  1325. comment(v_warning,'symtableproc field different');
  1326. error_found:=true;
  1327. end;
  1328. if oldp^.procdefinition<>p^.procdefinition then
  1329. begin
  1330. comment(v_warning,'procdefinition field different');
  1331. error_found:=true;
  1332. end;
  1333. if oldp^.methodpointer<>p^.methodpointer then
  1334. begin
  1335. comment(v_warning,'methodpointer field different');
  1336. error_found:=true;
  1337. end;
  1338. if oldp^.no_check<>p^.no_check then
  1339. begin
  1340. comment(v_warning,'no_check field different');
  1341. error_found:=true;
  1342. end;
  1343. if oldp^.unit_specific<>p^.unit_specific then
  1344. begin
  1345. error_found:=true;
  1346. comment(v_warning,'unit_specific field different');
  1347. end;
  1348. end;
  1349. ordconstn :
  1350. begin
  1351. if oldp^.value<>p^.value then
  1352. begin
  1353. comment(v_warning,'value field different');
  1354. error_found:=true;
  1355. end;
  1356. end;
  1357. realconstn :
  1358. begin
  1359. if oldp^.value_real<>p^.value_real then
  1360. begin
  1361. comment(v_warning,'valued field different');
  1362. error_found:=true;
  1363. end;
  1364. if oldp^.lab_real<>p^.lab_real then
  1365. begin
  1366. comment(v_warning,'labnumber field different');
  1367. error_found:=true;
  1368. end;
  1369. { if oldp^.realtyp<>p^.realtyp then
  1370. begin
  1371. comment(v_warning,'realtyp field different');
  1372. error_found:=true;
  1373. end; }
  1374. end;
  1375. end;
  1376. if not error_found then
  1377. comment(v_warning,'did not find difference in trees');
  1378. end;
  1379. {$endif extdebug}
  1380. function equal_trees(t1,t2 : ptree) : boolean;
  1381. begin
  1382. if t1^.treetype=t2^.treetype then
  1383. begin
  1384. case t1^.treetype of
  1385. addn,
  1386. muln,
  1387. equaln,
  1388. orn,
  1389. xorn,
  1390. andn,
  1391. unequaln:
  1392. begin
  1393. equal_trees:=(equal_trees(t1^.left,t2^.left) and
  1394. equal_trees(t1^.right,t2^.right)) or
  1395. (equal_trees(t1^.right,t2^.left) and
  1396. equal_trees(t1^.left,t2^.right));
  1397. end;
  1398. subn,
  1399. divn,
  1400. modn,
  1401. assignn,
  1402. ltn,
  1403. lten,
  1404. gtn,
  1405. gten,
  1406. inn,
  1407. shrn,
  1408. shln,
  1409. slashn,
  1410. rangen:
  1411. begin
  1412. equal_trees:=(equal_trees(t1^.left,t2^.left) and
  1413. equal_trees(t1^.right,t2^.right));
  1414. end;
  1415. umminusn,
  1416. notn,
  1417. derefn,
  1418. addrn:
  1419. begin
  1420. equal_trees:=(equal_trees(t1^.left,t2^.left));
  1421. end;
  1422. loadn:
  1423. begin
  1424. equal_trees:=(t1^.symtableentry=t2^.symtableentry)
  1425. { not necessary
  1426. and (t1^.symtable=t2^.symtable)};
  1427. end;
  1428. {
  1429. subscriptn,
  1430. ordconstn,typeconvn,calln,callparan,
  1431. realconstn,asmn,vecn,
  1432. stringconstn,funcretn,selfn,
  1433. inlinen,niln,errorn,
  1434. typen,hnewn,hdisposen,newn,
  1435. disposen,setelen,setconstrn
  1436. }
  1437. else equal_trees:=false;
  1438. end;
  1439. end
  1440. else
  1441. equal_trees:=false;
  1442. end;
  1443. procedure set_unique(p : ptree);
  1444. begin
  1445. if assigned(p) then
  1446. begin
  1447. case p^.treetype of
  1448. vecn:
  1449. p^.callunique:=true;
  1450. typeconvn:
  1451. set_unique(p^.left);
  1452. end;
  1453. end;
  1454. end;
  1455. procedure clear_location(var loc : tlocation);
  1456. begin
  1457. loc.loc:=LOC_INVALID;
  1458. end;
  1459. {This is needed if you want to be able to delete the string with the nodes !!}
  1460. procedure set_location(var destloc,sourceloc : tlocation);
  1461. begin
  1462. destloc:= sourceloc;
  1463. end;
  1464. procedure swap_location(var destloc,sourceloc : tlocation);
  1465. var
  1466. swapl : tlocation;
  1467. begin
  1468. swapl := destloc;
  1469. destloc := sourceloc;
  1470. sourceloc := swapl;
  1471. end;
  1472. function get_ordinal_value(p : ptree) : longint;
  1473. begin
  1474. if p^.treetype=ordconstn then
  1475. get_ordinal_value:=p^.value
  1476. else
  1477. begin
  1478. Message(type_e_ordinal_expr_expected);
  1479. get_ordinal_value:=0;
  1480. end;
  1481. end;
  1482. function is_constnode(p : ptree) : boolean;
  1483. begin
  1484. is_constnode:=(p^.treetype in [ordconstn,realconstn,stringconstn,fixconstn,setconstn]);
  1485. end;
  1486. function is_constintnode(p : ptree) : boolean;
  1487. begin
  1488. is_constintnode:=(p^.treetype=ordconstn) and is_integer(p^.resulttype);
  1489. end;
  1490. function is_constcharnode(p : ptree) : boolean;
  1491. begin
  1492. is_constcharnode:=((p^.treetype=ordconstn) and
  1493. (p^.resulttype^.deftype=orddef) and
  1494. (porddef(p^.resulttype)^.typ=uchar));
  1495. end;
  1496. function is_constrealnode(p : ptree) : boolean;
  1497. begin
  1498. is_constrealnode:=(p^.treetype=realconstn);
  1499. end;
  1500. function is_constboolnode(p : ptree) : boolean;
  1501. begin
  1502. is_constboolnode:=((p^.treetype=ordconstn) and
  1503. (p^.resulttype^.deftype=orddef) and
  1504. (porddef(p^.resulttype)^.typ in [bool8bit,bool16bit,bool32bit]));
  1505. end;
  1506. function str_length(p : ptree) : longint;
  1507. begin
  1508. str_length:=p^.length;
  1509. end;
  1510. function is_emptyset(p : ptree):boolean;
  1511. {
  1512. return true if set s is empty
  1513. }
  1514. var
  1515. i : longint;
  1516. begin
  1517. i:=0;
  1518. if p^.treetype=setconstn then
  1519. begin
  1520. while (i<32) and (p^.value_set^[i]=0) do
  1521. inc(i);
  1522. end;
  1523. is_emptyset:=(i=32);
  1524. end;
  1525. {*****************************************************************************
  1526. Case Helpers
  1527. *****************************************************************************}
  1528. function case_count_labels(root : pcaserecord) : longint;
  1529. var
  1530. _l : longint;
  1531. procedure count(p : pcaserecord);
  1532. begin
  1533. inc(_l);
  1534. if assigned(p^.less) then
  1535. count(p^.less);
  1536. if assigned(p^.greater) then
  1537. count(p^.greater);
  1538. end;
  1539. begin
  1540. _l:=0;
  1541. count(root);
  1542. case_count_labels:=_l;
  1543. end;
  1544. function case_get_max(root : pcaserecord) : longint;
  1545. var
  1546. hp : pcaserecord;
  1547. begin
  1548. hp:=root;
  1549. while assigned(hp^.greater) do
  1550. hp:=hp^.greater;
  1551. case_get_max:=hp^._high;
  1552. end;
  1553. function case_get_min(root : pcaserecord) : longint;
  1554. var
  1555. hp : pcaserecord;
  1556. begin
  1557. hp:=root;
  1558. while assigned(hp^.less) do
  1559. hp:=hp^.less;
  1560. case_get_min:=hp^._low;
  1561. end;
  1562. end.
  1563. {
  1564. $Log$
  1565. Revision 1.92 1999-08-26 21:10:08 peter
  1566. * better error recovery for case
  1567. Revision 1.91 1999/08/23 23:26:00 pierre
  1568. + TEMPREGDEBUG code, test of register allocation
  1569. if a tree uses more than registers32 regs then
  1570. internalerror(10) is issued
  1571. + EXTTEMPREGDEBUG will also give internalerror(10) if
  1572. a same register is freed twice (happens in several part
  1573. of current compiler like addn for strings and sets)
  1574. Revision 1.90 1999/08/17 13:26:09 peter
  1575. * arrayconstructor -> arrayofconst fixed when arraycosntructor was not
  1576. variant.
  1577. Revision 1.89 1999/08/16 23:23:42 peter
  1578. * arrayconstructor -> openarray type conversions for element types
  1579. Revision 1.88 1999/08/13 21:33:18 peter
  1580. * support for array constructors extended and more error checking
  1581. Revision 1.87 1999/08/09 22:14:46 peter
  1582. * fixed disposing of tree node
  1583. Revision 1.86 1999/08/04 00:23:49 florian
  1584. * renamed i386asm and i386base to cpuasm and cpubase
  1585. Revision 1.85 1999/08/03 22:03:40 peter
  1586. * moved bitmask constants to sets
  1587. * some other type/const renamings
  1588. Revision 1.84 1999/07/27 23:42:24 peter
  1589. * indirect type referencing is now allowed
  1590. Revision 1.83 1999/05/27 19:45:29 peter
  1591. * removed oldasm
  1592. * plabel -> pasmlabel
  1593. * -a switches to source writing automaticly
  1594. * assembler readers OOPed
  1595. * asmsymbol automaticly external
  1596. * jumptables and other label fixes for asm readers
  1597. Revision 1.82 1999/05/18 14:15:59 peter
  1598. * containsself fixes
  1599. * checktypes()
  1600. Revision 1.81 1999/05/18 09:52:22 peter
  1601. * procedure of object and addrn fixes
  1602. Revision 1.80 1999/05/17 23:51:48 peter
  1603. * with temp vars now use a reference with a persistant temp instead
  1604. of setting datasize
  1605. Revision 1.79 1999/05/17 13:00:36 pierre
  1606. * old field suppressed was still in debug code
  1607. Revision 1.78 1999/05/12 00:20:03 peter
  1608. * removed R_DEFAULT_SEG
  1609. * uniform float names
  1610. Revision 1.77 1999/05/06 09:05:39 peter
  1611. * generic write_float and str_float
  1612. * fixed constant float conversions
  1613. Revision 1.76 1999/05/04 14:27:04 pierre
  1614. * avoid RTE220 in gentypedconstloadnode
  1615. Revision 1.75 1999/05/01 13:25:02 peter
  1616. * merged nasm compiler
  1617. * old asm moved to oldasm/
  1618. Revision 1.74 1999/04/21 21:45:31 pierre
  1619. * wrong log fro v1.73 corrected
  1620. Revision 1.73 1999/04/21 16:31:49 pierre
  1621. + offset field for temp storage added $ifdef TEMPS_NOT_PUSH
  1622. Revision 1.72 1999/04/15 09:01:35 peter
  1623. * fixed set loading
  1624. * object inheritance support for browser
  1625. Revision 1.71 1999/03/31 13:55:28 peter
  1626. * assembler inlining working for ag386bin
  1627. Revision 1.70 1999/03/26 00:05:49 peter
  1628. * released valintern
  1629. + deffile is now removed when compiling is finished
  1630. * ^( compiles now correct
  1631. + static directive
  1632. * shrd fixed
  1633. Revision 1.69 1999/03/24 23:17:41 peter
  1634. * fixed bugs 212,222,225,227,229,231,233
  1635. Revision 1.68 1999/03/02 18:24:25 peter
  1636. * fixed overloading of array of char
  1637. Revision 1.67 1999/02/25 21:02:56 peter
  1638. * ag386bin updates
  1639. + coff writer
  1640. Revision 1.66 1999/02/22 02:15:59 peter
  1641. * updates for ag386bin
  1642. Revision 1.65 1999/02/11 09:46:31 pierre
  1643. * fix for normal method calls inside static methods :
  1644. WARNING there were both parser and codegen errors !!
  1645. added static_call boolean to calln tree
  1646. Revision 1.64 1999/01/27 12:57:22 pierre
  1647. * memory leaks with hightree solved by adding a new disposetyp
  1648. dt_leftrighthigh
  1649. Revision 1.63 1999/01/27 00:14:00 florian
  1650. * "procedure of object"-stuff fixed
  1651. Revision 1.62 1999/01/21 22:10:52 peter
  1652. * fixed array of const
  1653. * generic platform independent high() support
  1654. Revision 1.61 1999/01/21 16:41:09 pierre
  1655. * fix for constructor inside with statements
  1656. Revision 1.60 1998/12/15 11:52:19 peter
  1657. * fixed dup release of statement label in case
  1658. Revision 1.59 1998/12/15 10:23:32 peter
  1659. + -iSO, -iSP, -iTO, -iTP
  1660. Revision 1.58 1998/12/11 00:04:02 peter
  1661. + globtype,tokens,version unit splitted from globals
  1662. Revision 1.57 1998/12/04 10:18:13 florian
  1663. * some stuff for procedures of object added
  1664. * bug with overridden virtual constructors fixed (reported by Italo Gomes)
  1665. Revision 1.56 1998/12/02 16:23:32 jonas
  1666. * changed "if longintvar in set" to case or "if () or () .." statements
  1667. * tree.pas: changed inlinenumber (and associated constructor/vars) to a byte
  1668. Revision 1.55 1998/11/29 12:40:20 peter
  1669. * newcnv -> not oldcnv
  1670. Revision 1.54 1998/11/26 13:10:44 peter
  1671. * new int - int conversion -dNEWCNV
  1672. * some function renamings
  1673. Revision 1.53 1998/11/24 12:52:42 peter
  1674. * sets are not written twice anymore
  1675. * optimize for emptyset+single element which uses a new routine from
  1676. set.inc FPC_SET_CREATE_ELEMENT
  1677. Revision 1.52 1998/11/23 17:51:58 pierre
  1678. * added checking before dispose of reference string
  1679. Revision 1.51 1998/11/13 10:15:53 peter
  1680. * fixed ptr() with constants
  1681. Revision 1.50 1998/11/10 10:09:20 peter
  1682. * va_list -> array of const
  1683. Revision 1.49 1998/11/05 12:03:07 peter
  1684. * released useansistring
  1685. * removed -Sv, its now available in fpc modes
  1686. Revision 1.48 1998/10/21 15:12:59 pierre
  1687. * bug fix for IOCHECK inside a procedure with iocheck modifier
  1688. * removed the GPF for unexistant overloading
  1689. (firstcall was called with procedinition=nil !)
  1690. * changed typen to what Florian proposed
  1691. gentypenode(p : pdef) sets the typenodetype field
  1692. and resulttype is only set if inside bt_type block !
  1693. Revision 1.47 1998/10/20 08:07:07 pierre
  1694. * several memory corruptions due to double freemem solved
  1695. => never use p^.loc.location:=p^.left^.loc.location;
  1696. + finally I added now by default
  1697. that ra386dir translates global and unit symbols
  1698. + added a first field in tsymtable and
  1699. a nextsym field in tsym
  1700. (this allows to obtain ordered type info for
  1701. records and objects in gdb !)
  1702. Revision 1.46 1998/10/08 17:17:37 pierre
  1703. * current_module old scanner tagged as invalid if unit is recompiled
  1704. + added ppheap for better info on tracegetmem of heaptrc
  1705. (adds line column and file index)
  1706. * several memory leaks removed ith help of heaptrc !!
  1707. Revision 1.45 1998/10/05 21:33:33 peter
  1708. * fixed 161,165,166,167,168
  1709. Revision 1.44 1998/09/28 16:57:28 pierre
  1710. * changed all length(p^.value_str^) into str_length(p)
  1711. to get it work with and without ansistrings
  1712. * changed sourcefiles field of tmodule to a pointer
  1713. Revision 1.43 1998/09/27 10:16:28 florian
  1714. * type casts pchar<->ansistring fixed
  1715. * ansistring[..] calls does now an unique call
  1716. Revision 1.42 1998/09/23 12:03:59 peter
  1717. * overloading fix for array of const
  1718. Revision 1.41 1998/09/23 09:58:55 peter
  1719. * first working array of const things
  1720. Revision 1.40 1998/09/22 15:34:07 peter
  1721. + pchar -> string conversion
  1722. Revision 1.39 1998/09/21 08:45:27 pierre
  1723. + added vmt_offset in tobjectdef.write for fututre use
  1724. (first steps to have objects without vmt if no virtual !!)
  1725. + added fpu_used field for tabstractprocdef :
  1726. sets this level to 2 if the functions return with value in FPU
  1727. (is then set to correct value at parsing of implementation)
  1728. THIS MIGHT refuse some code with FPU expression too complex
  1729. that were accepted before and even in some cases
  1730. that don't overflow in fact
  1731. ( like if f : float; is a forward that finally in implementation
  1732. only uses one fpu register !!)
  1733. Nevertheless I think that it will improve security on
  1734. FPU operations !!
  1735. * most other changes only for UseBrowser code
  1736. (added symtable references for record and objects)
  1737. local switch for refs to args and local of each function
  1738. (static symtable still missing)
  1739. UseBrowser still not stable and probably broken by
  1740. the definition hash array !!
  1741. Revision 1.38 1998/09/16 01:06:47 carl
  1742. * crash bugfix in firstaddr
  1743. Revision 1.37 1998/09/08 10:38:04 pierre
  1744. * some variable fields inside conditionnal were not updated
  1745. Revision 1.36 1998/09/07 18:46:17 peter
  1746. * update smartlinking, uses getdatalabel
  1747. * renamed ptree.value vars to value_str,value_real,value_set
  1748. Revision 1.35 1998/09/04 08:42:11 peter
  1749. * updated some error messages
  1750. Revision 1.34 1998/09/01 17:39:54 peter
  1751. + internal constant functions
  1752. Revision 1.33 1998/08/28 12:51:44 florian
  1753. + ansistring to pchar type cast fixed
  1754. Revision 1.32 1998/08/28 10:54:25 peter
  1755. * fixed smallset generation from elements, it has never worked before!
  1756. Revision 1.31 1998/08/21 14:08:58 pierre
  1757. + TEST_FUNCRET now default (old code removed)
  1758. works also for m68k (at least compiles)
  1759. Revision 1.30 1998/08/18 09:24:47 pierre
  1760. * small warning position bug fixed
  1761. * support_mmx switches splitting was missing
  1762. * rhide error and warning output corrected
  1763. Revision 1.29 1998/08/14 18:18:48 peter
  1764. + dynamic set contruction
  1765. * smallsets are now working (always longint size)
  1766. Revision 1.28 1998/08/13 11:00:13 peter
  1767. * fixed procedure<>procedure construct
  1768. Revision 1.27 1998/08/10 14:50:35 peter
  1769. + localswitches, moduleswitches, globalswitches splitting
  1770. Revision 1.26 1998/08/10 09:57:19 peter
  1771. - Remove InitTree which was empty and obsolete
  1772. Revision 1.25 1998/08/02 16:42:02 florian
  1773. * on o : tobject do should also work now, the exceptsymtable shouldn't be
  1774. disposed by dellexlevel
  1775. Revision 1.24 1998/07/30 11:18:23 florian
  1776. + first implementation of try ... except on .. do end;
  1777. * limitiation of 65535 bytes parameters for cdecl removed
  1778. Revision 1.23 1998/07/24 22:17:01 florian
  1779. * internal error 10 together with array access fixed. I hope
  1780. that's the final fix.
  1781. Revision 1.22 1998/07/20 10:23:05 florian
  1782. * better ansi string assignement
  1783. Revision 1.21 1998/07/14 21:46:56 peter
  1784. * updated messages file
  1785. Revision 1.20 1998/07/14 14:47:11 peter
  1786. * released NEWINPUT
  1787. Revision 1.19 1998/07/08 14:56:53 daniel
  1788. * Fixed $ifdef TP.
  1789. Revision 1.18 1998/07/07 11:20:18 peter
  1790. + NEWINPUT for a better inputfile and scanner object
  1791. Revision 1.17 1998/06/22 08:59:03 daniel
  1792. - Removed pool of nodes.
  1793. Revision 1.16 1998/06/12 14:50:49 peter
  1794. * removed the tree dependency to types.pas
  1795. * long_fil.pas support (not fully tested yet)
  1796. Revision 1.15 1998/06/06 08:39:07 peter
  1797. * it needs types
  1798. Revision 1.14 1998/06/05 14:37:40 pierre
  1799. * fixes for inline for operators
  1800. * inline procedure more correctly restricted
  1801. Revision 1.13 1998/06/04 09:55:49 pierre
  1802. * demangled name of procsym reworked to become independant of the mangling scheme
  1803. Revision 1.12 1998/06/03 22:49:06 peter
  1804. + wordbool,longbool
  1805. * rename bis,von -> high,low
  1806. * moved some systemunit loading/creating to psystem.pas
  1807. Revision 1.10 1998/05/20 09:42:38 pierre
  1808. + UseTokenInfo now default
  1809. * unit in interface uses and implementation uses gives error now
  1810. * only one error for unknown symbol (uses lastsymknown boolean)
  1811. the problem came from the label code !
  1812. + first inlined procedures and function work
  1813. (warning there might be allowed cases were the result is still wrong !!)
  1814. * UseBrower updated gives a global list of all position of all used symbols
  1815. with switch -gb
  1816. Revision 1.9 1998/05/12 10:47:00 peter
  1817. * moved printstatus to verb_def
  1818. + V_Normal which is between V_Error and V_Warning and doesn't have a
  1819. prefix like error: warning: and is included in V_Default
  1820. * fixed some messages
  1821. * first time parameter scan is only for -v and -T
  1822. - removed old style messages
  1823. Revision 1.8 1998/05/07 00:17:01 peter
  1824. * smartlinking for sets
  1825. + consts labels are now concated/generated in hcodegen
  1826. * moved some cpu code to cga and some none cpu depended code from cga
  1827. to tree and hcodegen and cleanup of hcodegen
  1828. * assembling .. output reduced for smartlinking ;)
  1829. Revision 1.7 1998/05/06 15:04:21 pierre
  1830. + when trying to find source files of a ppufile
  1831. check the includepathlist for included files
  1832. the main file must still be in the same directory
  1833. Revision 1.6 1998/05/06 08:38:52 pierre
  1834. * better position info with UseTokenInfo
  1835. UseTokenInfo greatly simplified
  1836. + added check for changed tree after first time firstpass
  1837. (if we could remove all the cases were it happen
  1838. we could skip all firstpass if firstpasscount > 1)
  1839. Only with ExtDebug
  1840. Revision 1.5 1998/04/30 15:59:43 pierre
  1841. * GDB works again better :
  1842. correct type info in one pass
  1843. + UseTokenInfo for better source position
  1844. * fixed one remaining bug in scanner for line counts
  1845. * several little fixes
  1846. Revision 1.4 1998/04/29 10:34:08 pierre
  1847. + added some code for ansistring (not complete nor working yet)
  1848. * corrected operator overloading
  1849. * corrected nasm output
  1850. + started inline procedures
  1851. + added starstarn : use ** for exponentiation (^ gave problems)
  1852. + started UseTokenInfo cond to get accurate positions
  1853. Revision 1.3 1998/04/21 10:16:49 peter
  1854. * patches from strasbourg
  1855. * objects is not used anymore in the fpc compiled version
  1856. Revision 1.2 1998/04/07 22:45:05 florian
  1857. * bug0092, bug0115 and bug0121 fixed
  1858. + packed object/class/array
  1859. }