tree.pas 66 KB

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