tree.pas 68 KB

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