tree.pas 68 KB

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