tree.pas 66 KB

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