tree.pas 67 KB

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