tree.pas 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 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. unaryminusn, {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. { do we need to parse childs to set var state }
  167. varstateset : boolean;
  168. { the location of the result of this node }
  169. location : tlocation;
  170. { the number of registers needed to evalute the node }
  171. registers32,registersfpu : longint; { must be longint !!!! }
  172. {$ifdef SUPPORT_MMX}
  173. registersmmx : longint;
  174. {$endif SUPPORT_MMX}
  175. left,right : ptree;
  176. resulttype : pdef;
  177. fileinfo : tfileposinfo;
  178. localswitches : tlocalswitches;
  179. isproperty : boolean;
  180. {$ifdef extdebug}
  181. firstpasscount : longint;
  182. {$endif extdebug}
  183. {$ifdef TEMPREGDEBUG}
  184. usableregs : longint;
  185. {$endif TEMPREGDEBUG}
  186. {$ifdef EXTTEMPREGDEBUG}
  187. reallyusedregs : longint;
  188. {$endif EXTTEMPREGDEBUG}
  189. {$ifdef TEMPS_NOT_PUSH}
  190. temp_offset : longint;
  191. {$endif TEMPS_NOT_PUSH}
  192. case treetype : ttreetyp of
  193. addn : (use_strconcat : boolean;string_typ : tstringtype);
  194. callparan : (is_colon_para : boolean;exact_match_found,
  195. convlevel1found,convlevel2found:boolean;hightree:ptree);
  196. assignn : (assigntyp : tassigntyp;concat_string : boolean);
  197. loadn : (symtableentry : psym;symtable : psymtable;
  198. is_absolute,is_first : boolean);
  199. calln : (symtableprocentry : pprocsym;
  200. symtableproc : psymtable;procdefinition : pabstractprocdef;
  201. methodpointer : ptree;
  202. no_check,unit_specific,
  203. return_value_used,static_call : boolean);
  204. addrn : (procvarload:boolean);
  205. ordconstn : (value : longint);
  206. realconstn : (value_real : bestreal;lab_real : pasmlabel);
  207. fixconstn : (value_fix: longint);
  208. funcretn : (funcretprocinfo : pointer;rettype : ttype;
  209. is_first_funcret : boolean);
  210. subscriptn : (vs : pvarsym);
  211. vecn : (memindex,memseg:boolean;callunique : boolean);
  212. stringconstn : (value_str : pchar;length : longint; lab_str : pasmlabel;stringtype : tstringtype);
  213. typeconvn : (convtyp : tconverttype;explizit : boolean);
  214. typen : (typenodetype : pdef;typenodesym:ptypesym);
  215. inlinen : (inlinenumber : byte;inlineconst:boolean);
  216. procinlinen : (inlinetree:ptree;inlineprocsym:pprocsym;retoffset,para_offset,para_size : longint);
  217. setconstn : (value_set : pconstset;lab_set:pasmlabel);
  218. loopn : (t1,t2 : ptree;backward : boolean);
  219. asmn : (p_asm : paasmoutput;object_preserved : boolean);
  220. casen : (nodes : pcaserecord;elseblock : ptree);
  221. labeln,goton : (labelnr : pasmlabel;exceptionblock : ptree;labsym : plabelsym);
  222. withn : (withsymtable : pwithsymtable;tablecount : longint;withreference:preference;islocal:boolean);
  223. onn : (exceptsymtable : psymtable;excepttype : pobjectdef);
  224. arrayconstructn : (cargs,cargswap,forcevaria,novariaallowed: boolean;constructdef:pdef);
  225. end;
  226. function gennode(t : ttreetyp;l,r : ptree) : ptree;
  227. function genlabelnode(t : ttreetyp;nr : pasmlabel) : ptree;
  228. function genloadnode(v : pvarsym;st : psymtable) : ptree;
  229. function genloadcallnode(v: pprocsym;st: psymtable): ptree;
  230. function genloadmethodcallnode(v: pprocsym;st: psymtable; mp:ptree): ptree;
  231. function gensinglenode(t : ttreetyp;l : ptree) : ptree;
  232. function gensubscriptnode(varsym : pvarsym;l : ptree) : ptree;
  233. function genordinalconstnode(v : longint;def : pdef) : ptree;
  234. function genpointerconstnode(v : longint;def : pdef) : ptree;
  235. function genfixconstnode(v : longint;def : pdef) : ptree;
  236. function gentypeconvnode(node : ptree;t : pdef) : ptree;
  237. function gentypenode(t : pdef;sym:ptypesym) : ptree;
  238. function gencallparanode(expr,next : ptree) : ptree;
  239. function genrealconstnode(v : bestreal;def : pdef) : ptree;
  240. function gencallnode(v : pprocsym;st : psymtable) : ptree;
  241. function genmethodcallnode(v : pprocsym;st : psymtable;mp : ptree) : ptree;
  242. { allow pchar or string for defining a pchar node }
  243. function genstringconstnode(const s : string;st:tstringtype) : ptree;
  244. { length is required for ansistrings }
  245. function genpcharconstnode(s : pchar;length : longint) : ptree;
  246. { helper routine for conststring node }
  247. function getpcharcopy(p : ptree) : pchar;
  248. function genzeronode(t : ttreetyp) : ptree;
  249. function geninlinenode(number : byte;is_const:boolean;l : ptree) : ptree;
  250. function genprocinlinenode(callp,code : ptree) : ptree;
  251. function gentypedconstloadnode(sym : ptypedconstsym;st : psymtable) : ptree;
  252. function genenumnode(v : penumsym) : ptree;
  253. function genselfnode(_class : pdef) : ptree;
  254. function gensetconstnode(s : pconstset;settype : psetdef) : ptree;
  255. function genloopnode(t : ttreetyp;l,r,n1: ptree;back : boolean) : ptree;
  256. function genasmnode(p_asm : paasmoutput) : ptree;
  257. function gencasenode(l,r : ptree;nodes : pcaserecord) : ptree;
  258. function genwithnode(symtable : pwithsymtable;l,r : ptree;count : longint) : ptree;
  259. function getcopy(p : ptree) : ptree;
  260. function equal_trees(t1,t2 : ptree) : boolean;
  261. procedure swaptree(p:Ptree);
  262. procedure disposetree(p : ptree);
  263. procedure putnode(p : ptree);
  264. function getnode : ptree;
  265. procedure clear_location(var loc : tlocation);
  266. procedure set_location(var destloc,sourceloc : tlocation);
  267. procedure swap_location(var destloc,sourceloc : tlocation);
  268. procedure set_file_line(from,_to : ptree);
  269. procedure set_tree_filepos(p : ptree;const filepos : tfileposinfo);
  270. {$ifdef extdebug}
  271. procedure compare_trees(oldp,p : ptree);
  272. const
  273. maxfirstpasscount : longint = 0;
  274. {$endif extdebug}
  275. { sets the callunique flag, if the node is a vecn, }
  276. { takes care of type casts etc. }
  277. procedure set_unique(p : ptree);
  278. { sets funcret_is_valid to true, if p contains a funcref node }
  279. procedure set_funcret_is_valid(p : ptree);
  280. {
  281. type
  282. tvarstaterequire = (vsr_can_be_undefined,vsr_must_be_valid,
  283. vsr_is_used_after,vsr_must_be_valid_and_is_used_after); }
  284. { sets varsym varstate field correctly }
  285. procedure set_varstate(p : ptree;must_be_valid : boolean);
  286. { gibt den ordinalen Werten der Node zurueck oder falls sie }
  287. { keinen ordinalen Wert hat, wird ein Fehler erzeugt }
  288. function get_ordinal_value(p : ptree) : longint;
  289. function is_constnode(p : ptree) : boolean;
  290. { true, if p is a pointer to a const int value }
  291. function is_constintnode(p : ptree) : boolean;
  292. function is_constboolnode(p : ptree) : boolean;
  293. function is_constrealnode(p : ptree) : boolean;
  294. function is_constcharnode(p : ptree) : boolean;
  295. function str_length(p : ptree) : longint;
  296. function is_emptyset(p : ptree):boolean;
  297. { counts the labels }
  298. function case_count_labels(root : pcaserecord) : longint;
  299. { searches the highest label }
  300. function case_get_max(root : pcaserecord) : longint;
  301. { searches the lowest label }
  302. function case_get_min(root : pcaserecord) : longint;
  303. type
  304. pptree = ^ptree;
  305. {$ifdef TEMPREGDEBUG}
  306. const
  307. curptree : pptree = nil;
  308. {$endif TEMPREGDEBUG}
  309. {$I innr.inc}
  310. {$ifdef newcg}
  311. {$I new/nodeh.inc}
  312. {$endif newcg}
  313. implementation
  314. uses
  315. systems,
  316. globals,verbose,files,types,
  317. {$ifdef newcg}
  318. cgbase
  319. {$else newcg}
  320. hcodegen
  321. {$endif newcg}
  322. ;
  323. function getnode : ptree;
  324. var
  325. hp : ptree;
  326. begin
  327. new(hp);
  328. { makes error tracking easier }
  329. fillchar(hp^,sizeof(ttree),0);
  330. { reset }
  331. hp^.location.loc:=LOC_INVALID;
  332. { save local info }
  333. hp^.fileinfo:=aktfilepos;
  334. hp^.localswitches:=aktlocalswitches;
  335. getnode:=hp;
  336. end;
  337. procedure putnode(p : ptree);
  338. begin
  339. { clean up the contents of a node }
  340. case p^.treetype of
  341. asmn : if assigned(p^.p_asm) then
  342. dispose(p^.p_asm,done);
  343. stringconstn : begin
  344. ansistringdispose(p^.value_str,p^.length);
  345. end;
  346. setconstn : begin
  347. if assigned(p^.value_set) then
  348. dispose(p^.value_set);
  349. end;
  350. end;
  351. {$ifdef extdebug}
  352. if p^.firstpasscount>maxfirstpasscount then
  353. maxfirstpasscount:=p^.firstpasscount;
  354. {$endif extdebug}
  355. dispose(p);
  356. end;
  357. function getcopy(p : ptree) : ptree;
  358. var
  359. hp : ptree;
  360. begin
  361. if not assigned(p) then
  362. begin
  363. getcopy:=nil;
  364. exit;
  365. end;
  366. hp:=getnode;
  367. hp^:=p^;
  368. case p^.disposetyp of
  369. dt_leftright :
  370. begin
  371. if assigned(p^.left) then
  372. hp^.left:=getcopy(p^.left);
  373. if assigned(p^.right) then
  374. hp^.right:=getcopy(p^.right);
  375. end;
  376. dt_leftrighthigh :
  377. begin
  378. if assigned(p^.left) then
  379. hp^.left:=getcopy(p^.left);
  380. if assigned(p^.right) then
  381. hp^.right:=getcopy(p^.right);
  382. if assigned(p^.hightree) then
  383. hp^.left:=getcopy(p^.hightree);
  384. end;
  385. dt_leftrightmethod :
  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^.methodpointer) then
  392. hp^.left:=getcopy(p^.methodpointer);
  393. end;
  394. dt_nothing : ;
  395. dt_left :
  396. if assigned(p^.left) then
  397. hp^.left:=getcopy(p^.left);
  398. dt_mbleft :
  399. if assigned(p^.left) then
  400. hp^.left:=getcopy(p^.left);
  401. dt_mbleft_and_method :
  402. begin
  403. if assigned(p^.left) then
  404. hp^.left:=getcopy(p^.left);
  405. hp^.methodpointer:=getcopy(p^.methodpointer);
  406. end;
  407. dt_loop :
  408. begin
  409. if assigned(p^.left) then
  410. hp^.left:=getcopy(p^.left);
  411. if assigned(p^.right) then
  412. hp^.right:=getcopy(p^.right);
  413. if assigned(p^.t1) then
  414. hp^.t1:=getcopy(p^.t1);
  415. if assigned(p^.t2) then
  416. hp^.t2:=getcopy(p^.t2);
  417. end;
  418. dt_typeconv : hp^.left:=getcopy(p^.left);
  419. dt_inlinen :
  420. if assigned(p^.left) then
  421. hp^.left:=getcopy(p^.left);
  422. else internalerror(11);
  423. end;
  424. { now check treetype }
  425. case p^.treetype of
  426. stringconstn : begin
  427. hp^.value_str:=getpcharcopy(p);
  428. hp^.length:=p^.length;
  429. end;
  430. setconstn : begin
  431. new(hp^.value_set);
  432. hp^.value_set:=p^.value_set;
  433. end;
  434. end;
  435. getcopy:=hp;
  436. end;
  437. procedure deletecaselabels(p : pcaserecord);
  438. begin
  439. if assigned(p^.greater) then
  440. deletecaselabels(p^.greater);
  441. if assigned(p^.less) then
  442. deletecaselabels(p^.less);
  443. dispose(p);
  444. end;
  445. procedure swaptree(p:Ptree);
  446. var swapp:Ptree;
  447. begin
  448. swapp:=p^.right;
  449. p^.right:=p^.left;
  450. p^.left:=swapp;
  451. p^.swaped:=not(p^.swaped);
  452. end;
  453. procedure disposetree(p : ptree);
  454. var
  455. symt : pwithsymtable;
  456. i : longint;
  457. begin
  458. if not(assigned(p)) then
  459. exit;
  460. if not(p^.treetype in [addn..loadvmtn]) then
  461. internalerror(26219);
  462. case p^.disposetyp of
  463. dt_leftright :
  464. begin
  465. if assigned(p^.left) then
  466. disposetree(p^.left);
  467. if assigned(p^.right) then
  468. disposetree(p^.right);
  469. end;
  470. dt_leftrighthigh :
  471. begin
  472. if assigned(p^.left) then
  473. disposetree(p^.left);
  474. if assigned(p^.right) then
  475. disposetree(p^.right);
  476. if assigned(p^.hightree) then
  477. disposetree(p^.hightree);
  478. end;
  479. dt_leftrightmethod :
  480. begin
  481. if assigned(p^.left) then
  482. disposetree(p^.left);
  483. if assigned(p^.right) then
  484. disposetree(p^.right);
  485. if assigned(p^.methodpointer) then
  486. disposetree(p^.methodpointer);
  487. end;
  488. dt_case :
  489. begin
  490. if assigned(p^.left) then
  491. disposetree(p^.left);
  492. if assigned(p^.right) then
  493. disposetree(p^.right);
  494. if assigned(p^.nodes) then
  495. deletecaselabels(p^.nodes);
  496. if assigned(p^.elseblock) then
  497. disposetree(p^.elseblock);
  498. end;
  499. dt_nothing : ;
  500. dt_left :
  501. if assigned(p^.left) then
  502. disposetree(p^.left);
  503. dt_mbleft :
  504. if assigned(p^.left) then
  505. disposetree(p^.left);
  506. dt_mbleft_and_method :
  507. begin
  508. if assigned(p^.left) then disposetree(p^.left);
  509. disposetree(p^.methodpointer);
  510. end;
  511. dt_typeconv : disposetree(p^.left);
  512. dt_inlinen :
  513. if assigned(p^.left) then
  514. disposetree(p^.left);
  515. dt_loop :
  516. begin
  517. if assigned(p^.left) then
  518. disposetree(p^.left);
  519. if assigned(p^.right) then
  520. disposetree(p^.right);
  521. if assigned(p^.t1) then
  522. disposetree(p^.t1);
  523. if assigned(p^.t2) then
  524. disposetree(p^.t2);
  525. end;
  526. dt_onn:
  527. begin
  528. if assigned(p^.left) then
  529. disposetree(p^.left);
  530. if assigned(p^.right) then
  531. disposetree(p^.right);
  532. if assigned(p^.exceptsymtable) then
  533. dispose(p^.exceptsymtable,done);
  534. end;
  535. dt_with :
  536. begin
  537. if assigned(p^.left) then
  538. disposetree(p^.left);
  539. if assigned(p^.right) then
  540. disposetree(p^.right);
  541. symt:=p^.withsymtable;
  542. for i:=1 to p^.tablecount do
  543. begin
  544. if assigned(symt) then
  545. begin
  546. p^.withsymtable:=pwithsymtable(symt^.next);
  547. dispose(symt,done);
  548. end;
  549. symt:=p^.withsymtable;
  550. end;
  551. end;
  552. else internalerror(12);
  553. end;
  554. putnode(p);
  555. end;
  556. procedure set_file_line(from,_to : ptree);
  557. begin
  558. if assigned(from) then
  559. _to^.fileinfo:=from^.fileinfo;
  560. end;
  561. procedure set_tree_filepos(p : ptree;const filepos : tfileposinfo);
  562. begin
  563. p^.fileinfo:=filepos;
  564. end;
  565. function genwithnode(symtable : pwithsymtable;l,r : ptree;count : longint) : ptree;
  566. var
  567. p : ptree;
  568. begin
  569. p:=getnode;
  570. p^.disposetyp:=dt_with;
  571. p^.treetype:=withn;
  572. p^.left:=l;
  573. p^.right:=r;
  574. p^.registers32:=0;
  575. { p^.registers16:=0;
  576. p^.registers8:=0; }
  577. p^.registersfpu:=0;
  578. {$ifdef SUPPORT_MMX}
  579. p^.registersmmx:=0;
  580. {$endif SUPPORT_MMX}
  581. p^.resulttype:=nil;
  582. p^.withsymtable:=symtable;
  583. p^.tablecount:=count;
  584. p^.withreference:=nil;
  585. p^.islocal:=false;
  586. set_file_line(l,p);
  587. genwithnode:=p;
  588. end;
  589. function genfixconstnode(v : longint;def : pdef) : ptree;
  590. var
  591. p : ptree;
  592. begin
  593. p:=getnode;
  594. p^.disposetyp:=dt_nothing;
  595. p^.treetype:=fixconstn;
  596. p^.registers32:=0;
  597. { p^.registers16:=0;
  598. p^.registers8:=0; }
  599. p^.registersfpu:=0;
  600. {$ifdef SUPPORT_MMX}
  601. p^.registersmmx:=0;
  602. {$endif SUPPORT_MMX}
  603. p^.resulttype:=def;
  604. p^.value:=v;
  605. genfixconstnode:=p;
  606. end;
  607. function gencallparanode(expr,next : ptree) : ptree;
  608. var
  609. p : ptree;
  610. begin
  611. p:=getnode;
  612. p^.disposetyp:=dt_leftrighthigh;
  613. p^.treetype:=callparan;
  614. p^.left:=expr;
  615. p^.right:=next;
  616. p^.registers32:=0;
  617. { p^.registers16:=0;
  618. p^.registers8:=0; }
  619. {$ifdef SUPPORT_MMX}
  620. p^.registersmmx:=0;
  621. {$endif SUPPORT_MMX}
  622. p^.registersfpu:=0;
  623. p^.resulttype:=nil;
  624. p^.exact_match_found:=false;
  625. p^.convlevel1found:=false;
  626. p^.convlevel2found:=false;
  627. p^.is_colon_para:=false;
  628. p^.hightree:=nil;
  629. set_file_line(expr,p);
  630. gencallparanode:=p;
  631. end;
  632. function gennode(t : ttreetyp;l,r : ptree) : ptree;
  633. var
  634. p : ptree;
  635. begin
  636. p:=getnode;
  637. p^.disposetyp:=dt_leftright;
  638. p^.treetype:=t;
  639. p^.left:=l;
  640. p^.right:=r;
  641. p^.registers32:=0;
  642. { p^.registers16:=0;
  643. p^.registers8:=0; }
  644. p^.registersfpu:=0;
  645. {$ifdef SUPPORT_MMX}
  646. p^.registersmmx:=0;
  647. {$endif SUPPORT_MMX}
  648. p^.resulttype:=nil;
  649. gennode:=p;
  650. end;
  651. function gencasenode(l,r : ptree;nodes : pcaserecord) : ptree;
  652. var
  653. p : ptree;
  654. begin
  655. p:=getnode;
  656. p^.disposetyp:=dt_case;
  657. p^.treetype:=casen;
  658. p^.left:=l;
  659. p^.right:=r;
  660. p^.nodes:=nodes;
  661. p^.registers32:=0;
  662. p^.registersfpu:=0;
  663. {$ifdef SUPPORT_MMX}
  664. p^.registersmmx:=0;
  665. {$endif SUPPORT_MMX}
  666. p^.resulttype:=nil;
  667. set_file_line(l,p);
  668. gencasenode:=p;
  669. end;
  670. function genloopnode(t : ttreetyp;l,r,n1 : ptree;back : boolean) : ptree;
  671. var
  672. p : ptree;
  673. begin
  674. p:=getnode;
  675. p^.disposetyp:=dt_loop;
  676. p^.treetype:=t;
  677. p^.left:=l;
  678. p^.right:=r;
  679. p^.t1:=n1;
  680. p^.t2:=nil;
  681. p^.registers32:=0;
  682. p^.backward:=back;
  683. { p^.registers16:=0;
  684. p^.registers8:=0; }
  685. p^.registersfpu:=0;
  686. {$ifdef SUPPORT_MMX}
  687. p^.registersmmx:=0;
  688. {$endif SUPPORT_MMX}
  689. p^.resulttype:=nil;
  690. set_file_line(l,p);
  691. genloopnode:=p;
  692. end;
  693. function genordinalconstnode(v : longint;def : pdef) : ptree;
  694. var
  695. p : ptree;
  696. begin
  697. p:=getnode;
  698. p^.disposetyp:=dt_nothing;
  699. p^.treetype:=ordconstn;
  700. p^.registers32:=0;
  701. { p^.registers16:=0;
  702. p^.registers8:=0; }
  703. p^.registersfpu:=0;
  704. {$ifdef SUPPORT_MMX}
  705. p^.registersmmx:=0;
  706. {$endif SUPPORT_MMX}
  707. p^.resulttype:=def;
  708. p^.value:=v;
  709. if p^.resulttype^.deftype=orddef then
  710. testrange(p^.resulttype,p^.value);
  711. genordinalconstnode:=p;
  712. end;
  713. function genpointerconstnode(v : longint;def : pdef) : ptree;
  714. var
  715. p : ptree;
  716. begin
  717. p:=getnode;
  718. p^.disposetyp:=dt_nothing;
  719. p^.treetype:=pointerconstn;
  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:=v;
  729. genpointerconstnode:=p;
  730. end;
  731. function genenumnode(v : penumsym) : ptree;
  732. var
  733. p : ptree;
  734. begin
  735. p:=getnode;
  736. p^.disposetyp:=dt_nothing;
  737. p^.treetype:=ordconstn;
  738. p^.registers32:=0;
  739. { p^.registers16:=0;
  740. p^.registers8:=0; }
  741. p^.registersfpu:=0;
  742. {$ifdef SUPPORT_MMX}
  743. p^.registersmmx:=0;
  744. {$endif SUPPORT_MMX}
  745. p^.resulttype:=v^.definition;
  746. p^.value:=v^.value;
  747. testrange(p^.resulttype,p^.value);
  748. genenumnode:=p;
  749. end;
  750. function genrealconstnode(v : bestreal;def : pdef) : ptree;
  751. var
  752. p : ptree;
  753. begin
  754. p:=getnode;
  755. p^.disposetyp:=dt_nothing;
  756. p^.treetype:=realconstn;
  757. p^.registers32:=0;
  758. { p^.registers16:=0;
  759. p^.registers8:=0; }
  760. p^.registersfpu:=0;
  761. {$ifdef SUPPORT_MMX}
  762. p^.registersmmx:=0;
  763. {$endif SUPPORT_MMX}
  764. p^.resulttype:=def;
  765. p^.value_real:=v;
  766. p^.lab_real:=nil;
  767. genrealconstnode:=p;
  768. end;
  769. function genstringconstnode(const s : string;st:tstringtype) : ptree;
  770. var
  771. p : ptree;
  772. l : longint;
  773. begin
  774. p:=getnode;
  775. p^.disposetyp:=dt_nothing;
  776. p^.treetype:=stringconstn;
  777. p^.registers32:=0;
  778. { p^.registers16:=0;
  779. p^.registers8:=0; }
  780. p^.registersfpu:=0;
  781. {$ifdef SUPPORT_MMX}
  782. p^.registersmmx:=0;
  783. {$endif SUPPORT_MMX}
  784. l:=length(s);
  785. p^.length:=l;
  786. { stringdup write even past a #0 }
  787. getmem(p^.value_str,l+1);
  788. move(s[1],p^.value_str^,l);
  789. p^.value_str[l]:=#0;
  790. p^.lab_str:=nil;
  791. if st=st_default then
  792. begin
  793. if cs_ansistrings in aktlocalswitches then
  794. p^.stringtype:=st_ansistring
  795. else
  796. p^.stringtype:=st_shortstring;
  797. end
  798. else
  799. p^.stringtype:=st;
  800. case p^.stringtype of
  801. st_shortstring :
  802. p^.resulttype:=cshortstringdef;
  803. st_ansistring :
  804. p^.resulttype:=cansistringdef;
  805. else
  806. internalerror(44990099);
  807. end;
  808. genstringconstnode:=p;
  809. end;
  810. function getpcharcopy(p : ptree) : pchar;
  811. var
  812. pc : pchar;
  813. begin
  814. pc:=nil;
  815. getmem(pc,p^.length+1);
  816. if pc=nil then
  817. Message(general_f_no_memory_left);
  818. move(p^.value_str^,pc^,p^.length+1);
  819. getpcharcopy:=pc;
  820. end;
  821. function genpcharconstnode(s : pchar;length : longint) : ptree;
  822. var
  823. p : ptree;
  824. begin
  825. p:=getnode;
  826. p^.disposetyp:=dt_nothing;
  827. p^.treetype:=stringconstn;
  828. p^.registers32:=0;
  829. { p^.registers16:=0;
  830. p^.registers8:=0; }
  831. p^.registersfpu:=0;
  832. {$ifdef SUPPORT_MMX}
  833. p^.registersmmx:=0;
  834. {$endif SUPPORT_MMX}
  835. p^.length:=length;
  836. if (cs_ansistrings in aktlocalswitches) or
  837. (length>255) then
  838. begin
  839. p^.stringtype:=st_ansistring;
  840. p^.resulttype:=cansistringdef;
  841. end
  842. else
  843. begin
  844. p^.stringtype:=st_shortstring;
  845. p^.resulttype:=cshortstringdef;
  846. end;
  847. p^.value_str:=s;
  848. p^.lab_str:=nil;
  849. genpcharconstnode:=p;
  850. end;
  851. function gensinglenode(t : ttreetyp;l : ptree) : ptree;
  852. var
  853. p : ptree;
  854. begin
  855. p:=getnode;
  856. p^.disposetyp:=dt_left;
  857. p^.treetype:=t;
  858. p^.left:=l;
  859. p^.registers32:=0;
  860. { p^.registers16:=0;
  861. p^.registers8:=0; }
  862. p^.registersfpu:=0;
  863. {$ifdef SUPPORT_MMX}
  864. p^.registersmmx:=0;
  865. {$endif SUPPORT_MMX}
  866. p^.resulttype:=nil;
  867. gensinglenode:=p;
  868. end;
  869. function genasmnode(p_asm : paasmoutput) : ptree;
  870. var
  871. p : ptree;
  872. begin
  873. p:=getnode;
  874. p^.disposetyp:=dt_nothing;
  875. p^.treetype:=asmn;
  876. p^.registers32:=4;
  877. p^.p_asm:=p_asm;
  878. p^.object_preserved:=false;
  879. { p^.registers16:=0;
  880. p^.registers8:=0; }
  881. p^.registersfpu:=8;
  882. {$ifdef SUPPORT_MMX}
  883. p^.registersmmx:=8;
  884. {$endif SUPPORT_MMX}
  885. p^.resulttype:=nil;
  886. genasmnode:=p;
  887. end;
  888. function genloadnode(v : pvarsym;st : psymtable) : ptree;
  889. var
  890. p : ptree;
  891. begin
  892. p:=getnode;
  893. p^.registers32:=0;
  894. { p^.registers16:=0;
  895. p^.registers8:=0; }
  896. p^.registersfpu:=0;
  897. {$ifdef SUPPORT_MMX}
  898. p^.registersmmx:=0;
  899. {$endif SUPPORT_MMX}
  900. p^.treetype:=loadn;
  901. p^.resulttype:=v^.vartype.def;
  902. p^.symtableentry:=v;
  903. p^.symtable:=st;
  904. p^.is_first := False;
  905. { method pointer load nodes can use the left subtree }
  906. p^.disposetyp:=dt_left;
  907. p^.left:=nil;
  908. genloadnode:=p;
  909. end;
  910. function genloadcallnode(v: pprocsym;st: psymtable): ptree;
  911. var
  912. p : ptree;
  913. begin
  914. p:=getnode;
  915. p^.registers32:=0;
  916. { p^.registers16:=0;
  917. p^.registers8:=0; }
  918. p^.registersfpu:=0;
  919. {$ifdef SUPPORT_MMX}
  920. p^.registersmmx:=0;
  921. {$endif SUPPORT_MMX}
  922. p^.treetype:=loadn;
  923. p^.left:=nil;
  924. p^.resulttype:=v^.definition;
  925. p^.symtableentry:=v;
  926. p^.symtable:=st;
  927. p^.is_first := False;
  928. p^.disposetyp:=dt_nothing;
  929. genloadcallnode:=p;
  930. end;
  931. function genloadmethodcallnode(v: pprocsym;st: psymtable; mp:ptree): ptree;
  932. var
  933. p : ptree;
  934. begin
  935. p:=getnode;
  936. p^.registers32:=0;
  937. { p^.registers16:=0;
  938. p^.registers8:=0; }
  939. p^.registersfpu:=0;
  940. {$ifdef SUPPORT_MMX}
  941. p^.registersmmx:=0;
  942. {$endif SUPPORT_MMX}
  943. p^.treetype:=loadn;
  944. p^.left:=nil;
  945. p^.resulttype:=v^.definition;
  946. p^.symtableentry:=v;
  947. p^.symtable:=st;
  948. p^.is_first := False;
  949. p^.disposetyp:=dt_left;
  950. p^.left:=mp;
  951. genloadmethodcallnode:=p;
  952. end;
  953. function gentypedconstloadnode(sym : ptypedconstsym;st : psymtable) : ptree;
  954. var
  955. p : ptree;
  956. begin
  957. p:=getnode;
  958. p^.registers32:=0;
  959. { p^.registers16:=0;
  960. p^.registers8:=0; }
  961. p^.registersfpu:=0;
  962. {$ifdef SUPPORT_MMX}
  963. p^.registersmmx:=0;
  964. {$endif SUPPORT_MMX}
  965. p^.treetype:=loadn;
  966. p^.left:=nil;
  967. p^.resulttype:=sym^.typedconsttype.def;
  968. p^.symtableentry:=sym;
  969. p^.symtable:=st;
  970. p^.disposetyp:=dt_nothing;
  971. gentypedconstloadnode:=p;
  972. end;
  973. function gentypeconvnode(node : ptree;t : pdef) : ptree;
  974. var
  975. p : ptree;
  976. begin
  977. p:=getnode;
  978. p^.disposetyp:=dt_typeconv;
  979. p^.treetype:=typeconvn;
  980. p^.left:=node;
  981. p^.registers32:=0;
  982. { p^.registers16:=0;
  983. p^.registers8:=0; }
  984. p^.convtyp:=tc_equal;
  985. p^.registersfpu:=0;
  986. {$ifdef SUPPORT_MMX}
  987. p^.registersmmx:=0;
  988. {$endif SUPPORT_MMX}
  989. p^.resulttype:=t;
  990. p^.explizit:=false;
  991. set_file_line(node,p);
  992. gentypeconvnode:=p;
  993. end;
  994. function gentypenode(t : pdef;sym:ptypesym) : ptree;
  995. var
  996. p : ptree;
  997. begin
  998. p:=getnode;
  999. p^.disposetyp:=dt_nothing;
  1000. p^.treetype:=typen;
  1001. p^.registers32:=0;
  1002. { p^.registers16:=0;
  1003. p^.registers8:=0; }
  1004. p^.registersfpu:=0;
  1005. {$ifdef SUPPORT_MMX}
  1006. p^.registersmmx:=0;
  1007. {$endif SUPPORT_MMX}
  1008. p^.resulttype:=generrordef;
  1009. p^.typenodetype:=t;
  1010. p^.typenodesym:=sym;
  1011. gentypenode:=p;
  1012. end;
  1013. function gencallnode(v : pprocsym;st : psymtable) : ptree;
  1014. var
  1015. p : ptree;
  1016. begin
  1017. p:=getnode;
  1018. p^.registers32:=0;
  1019. { p^.registers16:=0;
  1020. p^.registers8:=0; }
  1021. p^.registersfpu:=0;
  1022. {$ifdef SUPPORT_MMX}
  1023. p^.registersmmx:=0;
  1024. {$endif SUPPORT_MMX}
  1025. p^.treetype:=calln;
  1026. p^.symtableprocentry:=v;
  1027. p^.symtableproc:=st;
  1028. p^.unit_specific:=false;
  1029. p^.no_check:=false;
  1030. p^.return_value_used:=true;
  1031. p^.disposetyp := dt_leftrightmethod;
  1032. p^.methodpointer:=nil;
  1033. p^.left:=nil;
  1034. p^.right:=nil;
  1035. p^.procdefinition:=nil;
  1036. gencallnode:=p;
  1037. end;
  1038. function genmethodcallnode(v : pprocsym;st : psymtable;mp : ptree) : ptree;
  1039. var
  1040. p : ptree;
  1041. begin
  1042. p:=getnode;
  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^.treetype:=calln;
  1051. p^.return_value_used:=true;
  1052. p^.symtableprocentry:=v;
  1053. p^.symtableproc:=st;
  1054. p^.disposetyp:=dt_leftrightmethod;
  1055. p^.left:=nil;
  1056. p^.right:=nil;
  1057. p^.methodpointer:=mp;
  1058. p^.procdefinition:=nil;
  1059. genmethodcallnode:=p;
  1060. end;
  1061. function gensubscriptnode(varsym : pvarsym;l : ptree) : ptree;
  1062. var
  1063. p : ptree;
  1064. begin
  1065. p:=getnode;
  1066. p^.disposetyp:=dt_left;
  1067. p^.treetype:=subscriptn;
  1068. p^.left:=l;
  1069. p^.registers32:=0;
  1070. p^.vs:=varsym;
  1071. { p^.registers16:=0;
  1072. p^.registers8:=0; }
  1073. p^.registersfpu:=0;
  1074. {$ifdef SUPPORT_MMX}
  1075. p^.registersmmx:=0;
  1076. {$endif SUPPORT_MMX}
  1077. p^.resulttype:=nil;
  1078. gensubscriptnode:=p;
  1079. end;
  1080. function genzeronode(t : ttreetyp) : ptree;
  1081. var
  1082. p : ptree;
  1083. begin
  1084. p:=getnode;
  1085. p^.disposetyp:=dt_nothing;
  1086. p^.treetype:=t;
  1087. p^.registers32:=0;
  1088. { p^.registers16:=0;
  1089. p^.registers8:=0; }
  1090. p^.registersfpu:=0;
  1091. {$ifdef SUPPORT_MMX}
  1092. p^.registersmmx:=0;
  1093. {$endif SUPPORT_MMX}
  1094. p^.resulttype:=nil;
  1095. genzeronode:=p;
  1096. end;
  1097. function genlabelnode(t : ttreetyp;nr : pasmlabel) : ptree;
  1098. var
  1099. p : ptree;
  1100. begin
  1101. p:=getnode;
  1102. p^.disposetyp:=dt_nothing;
  1103. p^.treetype:=t;
  1104. p^.registers32:=0;
  1105. { p^.registers16:=0;
  1106. p^.registers8:=0; }
  1107. p^.registersfpu:=0;
  1108. {$ifdef SUPPORT_MMX}
  1109. p^.registersmmx:=0;
  1110. {$endif SUPPORT_MMX}
  1111. p^.resulttype:=nil;
  1112. { for security }
  1113. { nr^.is_used:=true;}
  1114. p^.labelnr:=nr;
  1115. p^.exceptionblock:=nil;
  1116. genlabelnode:=p;
  1117. end;
  1118. function genselfnode(_class : pdef) : ptree;
  1119. var
  1120. p : ptree;
  1121. begin
  1122. p:=getnode;
  1123. p^.disposetyp:=dt_nothing;
  1124. p^.treetype:=selfn;
  1125. p^.registers32:=0;
  1126. { p^.registers16:=0;
  1127. p^.registers8:=0; }
  1128. p^.registersfpu:=0;
  1129. {$ifdef SUPPORT_MMX}
  1130. p^.registersmmx:=0;
  1131. {$endif SUPPORT_MMX}
  1132. p^.resulttype:=_class;
  1133. genselfnode:=p;
  1134. end;
  1135. function geninlinenode(number : byte;is_const:boolean;l : ptree) : ptree;
  1136. var
  1137. p : ptree;
  1138. begin
  1139. p:=getnode;
  1140. p^.disposetyp:=dt_inlinen;
  1141. p^.treetype:=inlinen;
  1142. p^.left:=l;
  1143. p^.inlinenumber:=number;
  1144. p^.inlineconst:=is_const;
  1145. p^.registers32:=0;
  1146. { p^.registers16:=0;
  1147. p^.registers8:=0; }
  1148. p^.registersfpu:=0;
  1149. {$ifdef SUPPORT_MMX}
  1150. p^.registersmmx:=0;
  1151. {$endif SUPPORT_MMX}
  1152. p^.resulttype:=nil;
  1153. geninlinenode:=p;
  1154. end;
  1155. { uses the callnode to create the new procinline node }
  1156. function genprocinlinenode(callp,code : ptree) : ptree;
  1157. var
  1158. p : ptree;
  1159. begin
  1160. p:=getnode;
  1161. p^.disposetyp:=dt_nothing;
  1162. p^.treetype:=procinlinen;
  1163. p^.inlineprocsym:=callp^.symtableprocentry;
  1164. p^.retoffset:=-4; { less dangerous as zero (PM) }
  1165. p^.para_offset:=0;
  1166. p^.para_size:=p^.inlineprocsym^.definition^.para_size(target_os.stackalignment);
  1167. if ret_in_param(p^.inlineprocsym^.definition^.rettype.def) then
  1168. p^.para_size:=p^.para_size+target_os.size_of_pointer;
  1169. { copy args }
  1170. p^.inlinetree:=code;
  1171. p^.registers32:=code^.registers32;
  1172. p^.registersfpu:=code^.registersfpu;
  1173. {$ifdef SUPPORT_MMX}
  1174. p^.registersmmx:=0;
  1175. {$endif SUPPORT_MMX}
  1176. p^.resulttype:=p^.inlineprocsym^.definition^.rettype.def;
  1177. genprocinlinenode:=p;
  1178. end;
  1179. function gensetconstnode(s : pconstset;settype : psetdef) : ptree;
  1180. var
  1181. p : ptree;
  1182. begin
  1183. p:=getnode;
  1184. p^.disposetyp:=dt_nothing;
  1185. p^.treetype:=setconstn;
  1186. p^.registers32:=0;
  1187. p^.registersfpu:=0;
  1188. {$ifdef SUPPORT_MMX}
  1189. p^.registersmmx:=0;
  1190. {$endif SUPPORT_MMX}
  1191. p^.resulttype:=settype;
  1192. p^.left:=nil;
  1193. new(p^.value_set);
  1194. p^.value_set^:=s^;
  1195. gensetconstnode:=p;
  1196. end;
  1197. {$ifdef extdebug}
  1198. procedure compare_trees(oldp,p : ptree);
  1199. var
  1200. error_found : boolean;
  1201. begin
  1202. if oldp^.resulttype<>p^.resulttype then
  1203. begin
  1204. error_found:=true;
  1205. if is_equal(oldp^.resulttype,p^.resulttype) then
  1206. comment(v_debug,'resulttype fields are different but equal')
  1207. else
  1208. comment(v_warning,'resulttype fields are really different');
  1209. end;
  1210. if oldp^.treetype<>p^.treetype then
  1211. begin
  1212. comment(v_warning,'treetype field different');
  1213. error_found:=true;
  1214. end
  1215. else
  1216. comment(v_debug,' treetype '+tostr(longint(oldp^.treetype)));
  1217. if oldp^.error<>p^.error then
  1218. begin
  1219. comment(v_warning,'error field different');
  1220. error_found:=true;
  1221. end;
  1222. if oldp^.disposetyp<>p^.disposetyp then
  1223. begin
  1224. comment(v_warning,'disposetyp field different');
  1225. error_found:=true;
  1226. end;
  1227. { is true, if the right and left operand are swaped }
  1228. if oldp^.swaped<>p^.swaped then
  1229. begin
  1230. comment(v_warning,'swaped field different');
  1231. error_found:=true;
  1232. end;
  1233. { the location of the result of this node }
  1234. if oldp^.location.loc<>p^.location.loc then
  1235. begin
  1236. comment(v_warning,'location.loc field different');
  1237. error_found:=true;
  1238. end;
  1239. { the number of registers needed to evalute the node }
  1240. if oldp^.registers32<>p^.registers32 then
  1241. begin
  1242. comment(v_warning,'registers32 field different');
  1243. comment(v_warning,' old '+tostr(oldp^.registers32)+'<> new '+tostr(p^.registers32));
  1244. error_found:=true;
  1245. end;
  1246. if oldp^.registersfpu<>p^.registersfpu then
  1247. begin
  1248. comment(v_warning,'registersfpu field different');
  1249. error_found:=true;
  1250. end;
  1251. {$ifdef SUPPORT_MMX}
  1252. if oldp^.registersmmx<>p^.registersmmx then
  1253. begin
  1254. comment(v_warning,'registersmmx field different');
  1255. error_found:=true;
  1256. end;
  1257. {$endif SUPPORT_MMX}
  1258. if oldp^.left<>p^.left then
  1259. begin
  1260. comment(v_warning,'left field different');
  1261. error_found:=true;
  1262. end;
  1263. if oldp^.right<>p^.right then
  1264. begin
  1265. comment(v_warning,'right field different');
  1266. error_found:=true;
  1267. end;
  1268. if oldp^.fileinfo.line<>p^.fileinfo.line then
  1269. begin
  1270. comment(v_warning,'fileinfo.line field different');
  1271. error_found:=true;
  1272. end;
  1273. if oldp^.fileinfo.column<>p^.fileinfo.column then
  1274. begin
  1275. comment(v_warning,'fileinfo.column field different');
  1276. error_found:=true;
  1277. end;
  1278. if oldp^.fileinfo.fileindex<>p^.fileinfo.fileindex then
  1279. begin
  1280. comment(v_warning,'fileinfo.fileindex field different');
  1281. error_found:=true;
  1282. end;
  1283. if oldp^.localswitches<>p^.localswitches then
  1284. begin
  1285. comment(v_warning,'localswitches field different');
  1286. error_found:=true;
  1287. end;
  1288. {$ifdef extdebug}
  1289. if oldp^.firstpasscount<>p^.firstpasscount then
  1290. begin
  1291. comment(v_warning,'firstpasscount field different');
  1292. error_found:=true;
  1293. end;
  1294. {$endif extdebug}
  1295. if oldp^.treetype=p^.treetype then
  1296. case oldp^.treetype of
  1297. addn :
  1298. begin
  1299. if oldp^.use_strconcat<>p^.use_strconcat then
  1300. begin
  1301. comment(v_warning,'use_strconcat field different');
  1302. error_found:=true;
  1303. end;
  1304. if oldp^.string_typ<>p^.string_typ then
  1305. begin
  1306. comment(v_warning,'stringtyp field different');
  1307. error_found:=true;
  1308. end;
  1309. end;
  1310. callparan :
  1311. {(is_colon_para : boolean;exact_match_found : boolean);}
  1312. begin
  1313. if oldp^.is_colon_para<>p^.is_colon_para then
  1314. begin
  1315. comment(v_warning,'use_strconcat field different');
  1316. error_found:=true;
  1317. end;
  1318. if oldp^.exact_match_found<>p^.exact_match_found then
  1319. begin
  1320. comment(v_warning,'exact_match_found field different');
  1321. error_found:=true;
  1322. end;
  1323. end;
  1324. assignn :
  1325. {(assigntyp : tassigntyp;concat_string : boolean);}
  1326. begin
  1327. if oldp^.assigntyp<>p^.assigntyp then
  1328. begin
  1329. comment(v_warning,'assigntyp field different');
  1330. error_found:=true;
  1331. end;
  1332. if oldp^.concat_string<>p^.concat_string then
  1333. begin
  1334. comment(v_warning,'concat_string field different');
  1335. error_found:=true;
  1336. end;
  1337. end;
  1338. loadn :
  1339. {(symtableentry : psym;symtable : psymtable;
  1340. is_absolute,is_first : boolean);}
  1341. begin
  1342. if oldp^.symtableentry<>p^.symtableentry then
  1343. begin
  1344. comment(v_warning,'symtableentry field different');
  1345. error_found:=true;
  1346. end;
  1347. if oldp^.symtable<>p^.symtable then
  1348. begin
  1349. comment(v_warning,'symtable field different');
  1350. error_found:=true;
  1351. end;
  1352. if oldp^.is_absolute<>p^.is_absolute then
  1353. begin
  1354. comment(v_warning,'is_absolute field different');
  1355. error_found:=true;
  1356. end;
  1357. if oldp^.is_first<>p^.is_first then
  1358. begin
  1359. comment(v_warning,'is_first field different');
  1360. error_found:=true;
  1361. end;
  1362. end;
  1363. calln :
  1364. {(symtableprocentry : pprocsym;
  1365. symtableproc : psymtable;procdefinition : pprocdef;
  1366. methodpointer : ptree;
  1367. no_check,unit_specific : boolean);}
  1368. begin
  1369. if oldp^.symtableprocentry<>p^.symtableprocentry then
  1370. begin
  1371. comment(v_warning,'symtableprocentry field different');
  1372. error_found:=true;
  1373. end;
  1374. if oldp^.symtableproc<>p^.symtableproc then
  1375. begin
  1376. comment(v_warning,'symtableproc field different');
  1377. error_found:=true;
  1378. end;
  1379. if oldp^.procdefinition<>p^.procdefinition then
  1380. begin
  1381. comment(v_warning,'procdefinition field different');
  1382. error_found:=true;
  1383. end;
  1384. if oldp^.methodpointer<>p^.methodpointer then
  1385. begin
  1386. comment(v_warning,'methodpointer field different');
  1387. error_found:=true;
  1388. end;
  1389. if oldp^.no_check<>p^.no_check then
  1390. begin
  1391. comment(v_warning,'no_check field different');
  1392. error_found:=true;
  1393. end;
  1394. if oldp^.unit_specific<>p^.unit_specific then
  1395. begin
  1396. error_found:=true;
  1397. comment(v_warning,'unit_specific field different');
  1398. end;
  1399. end;
  1400. ordconstn :
  1401. begin
  1402. if oldp^.value<>p^.value then
  1403. begin
  1404. comment(v_warning,'value field different');
  1405. error_found:=true;
  1406. end;
  1407. end;
  1408. realconstn :
  1409. begin
  1410. if oldp^.value_real<>p^.value_real then
  1411. begin
  1412. comment(v_warning,'valued field different');
  1413. error_found:=true;
  1414. end;
  1415. if oldp^.lab_real<>p^.lab_real then
  1416. begin
  1417. comment(v_warning,'labnumber field different');
  1418. error_found:=true;
  1419. end;
  1420. { if oldp^.realtyp<>p^.realtyp then
  1421. begin
  1422. comment(v_warning,'realtyp field different');
  1423. error_found:=true;
  1424. end; }
  1425. end;
  1426. end;
  1427. if not error_found then
  1428. comment(v_warning,'did not find difference in trees');
  1429. end;
  1430. {$endif extdebug}
  1431. function equal_trees(t1,t2 : ptree) : boolean;
  1432. begin
  1433. if t1^.treetype=t2^.treetype then
  1434. begin
  1435. case t1^.treetype of
  1436. addn,
  1437. muln,
  1438. equaln,
  1439. orn,
  1440. xorn,
  1441. andn,
  1442. unequaln:
  1443. begin
  1444. equal_trees:=(equal_trees(t1^.left,t2^.left) and
  1445. equal_trees(t1^.right,t2^.right)) or
  1446. (equal_trees(t1^.right,t2^.left) and
  1447. equal_trees(t1^.left,t2^.right));
  1448. end;
  1449. subn,
  1450. divn,
  1451. modn,
  1452. assignn,
  1453. ltn,
  1454. lten,
  1455. gtn,
  1456. gten,
  1457. inn,
  1458. shrn,
  1459. shln,
  1460. slashn,
  1461. rangen:
  1462. begin
  1463. equal_trees:=(equal_trees(t1^.left,t2^.left) and
  1464. equal_trees(t1^.right,t2^.right));
  1465. end;
  1466. unaryminusn,
  1467. notn,
  1468. derefn,
  1469. addrn:
  1470. begin
  1471. equal_trees:=(equal_trees(t1^.left,t2^.left));
  1472. end;
  1473. loadn:
  1474. begin
  1475. equal_trees:=(t1^.symtableentry=t2^.symtableentry)
  1476. { not necessary
  1477. and (t1^.symtable=t2^.symtable)};
  1478. end;
  1479. {
  1480. subscriptn,
  1481. ordconstn,typeconvn,calln,callparan,
  1482. realconstn,asmn,vecn,
  1483. stringconstn,funcretn,selfn,
  1484. inlinen,niln,errorn,
  1485. typen,hnewn,hdisposen,newn,
  1486. disposen,setelen,setconstrn
  1487. }
  1488. else equal_trees:=false;
  1489. end;
  1490. end
  1491. else
  1492. equal_trees:=false;
  1493. end;
  1494. procedure set_unique(p : ptree);
  1495. begin
  1496. if assigned(p) then
  1497. begin
  1498. case p^.treetype of
  1499. vecn:
  1500. p^.callunique:=true;
  1501. typeconvn,subscriptn,derefn:
  1502. set_unique(p^.left);
  1503. end;
  1504. end;
  1505. end;
  1506. procedure set_funcret_is_valid(p : ptree);
  1507. begin
  1508. if assigned(p) then
  1509. begin
  1510. case p^.treetype of
  1511. funcretn:
  1512. begin
  1513. if p^.is_first_funcret then
  1514. pprocinfo(p^.funcretprocinfo)^.funcret_state:=vs_assigned;
  1515. end;
  1516. vecn,typeconvn,subscriptn,derefn:
  1517. set_funcret_is_valid(p^.left);
  1518. end;
  1519. end;
  1520. end;
  1521. procedure set_varstate(p : ptree;must_be_valid : boolean);
  1522. begin
  1523. if not assigned(p) then
  1524. exit
  1525. else
  1526. begin
  1527. if p^.varstateset then
  1528. exit;
  1529. case p^.treetype of
  1530. typeconvn :
  1531. if p^.convtyp in
  1532. [
  1533. tc_cchar_2_pchar,
  1534. tc_cstring_2_pchar,
  1535. tc_array_2_pointer
  1536. ] then
  1537. set_varstate(p^.left,false)
  1538. else if p^.convtyp in
  1539. [
  1540. tc_pchar_2_string,
  1541. tc_pointer_2_array
  1542. ] then
  1543. set_varstate(p^.left,true)
  1544. else
  1545. set_varstate(p^.left,must_be_valid);
  1546. subscriptn :
  1547. set_varstate(p^.left,must_be_valid);
  1548. vecn:
  1549. begin
  1550. if (p^.left^.resulttype^.deftype in [stringdef,arraydef]) then
  1551. set_varstate(p^.left,must_be_valid)
  1552. else
  1553. set_varstate(p^.left,true);
  1554. set_varstate(p^.right,true);
  1555. end;
  1556. { do not parse calln }
  1557. calln : ;
  1558. callparan:
  1559. begin
  1560. set_varstate(p^.left,must_be_valid);
  1561. set_varstate(p^.right,must_be_valid);
  1562. end;
  1563. loadn :
  1564. if (p^.symtableentry^.typ=varsym) then
  1565. begin
  1566. if must_be_valid and p^.is_first then
  1567. begin
  1568. if (pvarsym(p^.symtableentry)^.varstate=vs_declared_and_first_found) or
  1569. (pvarsym(p^.symtableentry)^.varstate=vs_set_but_first_not_passed) then
  1570. if (assigned(pvarsym(p^.symtableentry)^.owner) and
  1571. assigned(aktprocsym) and
  1572. (pvarsym(p^.symtableentry)^.owner = aktprocsym^.definition^.localst)) then
  1573. begin
  1574. if p^.symtable^.symtabletype=localsymtable then
  1575. CGMessage1(sym_n_uninitialized_local_variable,pvarsym(p^.symtableentry)^.name)
  1576. else
  1577. CGMessage1(sym_n_uninitialized_variable,pvarsym(p^.symtableentry)^.name);
  1578. end;
  1579. end;
  1580. if (p^.is_first) then
  1581. begin
  1582. if pvarsym(p^.symtableentry)^.varstate=vs_declared_and_first_found then
  1583. { this can only happen at left of an assignment, no ? PM }
  1584. if (parsing_para_level=0) and not must_be_valid then
  1585. pvarsym(p^.symtableentry)^.varstate:=vs_assigned
  1586. else
  1587. pvarsym(p^.symtableentry)^.varstate:=vs_used;
  1588. if pvarsym(p^.symtableentry)^.varstate=vs_set_but_first_not_passed then
  1589. pvarsym(p^.symtableentry)^.varstate:=vs_used;
  1590. p^.is_first:=false;
  1591. end
  1592. else
  1593. begin
  1594. if (pvarsym(p^.symtableentry)^.varstate=vs_assigned) and
  1595. (must_be_valid or (parsing_para_level>0) or
  1596. (p^.resulttype^.deftype=procvardef)) then
  1597. pvarsym(p^.symtableentry)^.varstate:=vs_used;
  1598. if (pvarsym(p^.symtableentry)^.varstate=vs_declared_and_first_found) and
  1599. (must_be_valid or (parsing_para_level>0) or
  1600. (p^.resulttype^.deftype=procvardef)) then
  1601. pvarsym(p^.symtableentry)^.varstate:=vs_set_but_first_not_passed;
  1602. end;
  1603. end;
  1604. funcretn:
  1605. begin
  1606. { no claim if setting higher return value_str }
  1607. if must_be_valid and
  1608. (procinfo=pprocinfo(p^.funcretprocinfo)) and
  1609. ((procinfo^.funcret_state=vs_declared) or
  1610. ((p^.is_first_funcret) and
  1611. (procinfo^.funcret_state=vs_declared_and_first_found))) then
  1612. begin
  1613. CGMessage(sym_w_function_result_not_set);
  1614. { avoid multiple warnings }
  1615. procinfo^.funcret_state:=vs_assigned;
  1616. end;
  1617. if p^.is_first_funcret and not must_be_valid then
  1618. pprocinfo(p^.funcretprocinfo)^.funcret_state:=vs_assigned;
  1619. end;
  1620. else
  1621. begin
  1622. {internalerror(565656);}
  1623. end;
  1624. end;{case }
  1625. p^.varstateset:=true;
  1626. end;
  1627. end;
  1628. procedure clear_location(var loc : tlocation);
  1629. begin
  1630. loc.loc:=LOC_INVALID;
  1631. end;
  1632. {This is needed if you want to be able to delete the string with the nodes !!}
  1633. procedure set_location(var destloc,sourceloc : tlocation);
  1634. begin
  1635. destloc:= sourceloc;
  1636. end;
  1637. procedure swap_location(var destloc,sourceloc : tlocation);
  1638. var
  1639. swapl : tlocation;
  1640. begin
  1641. swapl := destloc;
  1642. destloc := sourceloc;
  1643. sourceloc := swapl;
  1644. end;
  1645. function get_ordinal_value(p : ptree) : longint;
  1646. begin
  1647. if p^.treetype=ordconstn then
  1648. get_ordinal_value:=p^.value
  1649. else
  1650. begin
  1651. Message(type_e_ordinal_expr_expected);
  1652. get_ordinal_value:=0;
  1653. end;
  1654. end;
  1655. function is_constnode(p : ptree) : boolean;
  1656. begin
  1657. is_constnode:=(p^.treetype in [ordconstn,realconstn,stringconstn,fixconstn,setconstn]);
  1658. end;
  1659. function is_constintnode(p : ptree) : boolean;
  1660. begin
  1661. is_constintnode:=(p^.treetype=ordconstn) and is_integer(p^.resulttype);
  1662. end;
  1663. function is_constcharnode(p : ptree) : boolean;
  1664. begin
  1665. is_constcharnode:=(p^.treetype=ordconstn) and is_char(p^.resulttype);
  1666. end;
  1667. function is_constrealnode(p : ptree) : boolean;
  1668. begin
  1669. is_constrealnode:=(p^.treetype=realconstn);
  1670. end;
  1671. function is_constboolnode(p : ptree) : boolean;
  1672. begin
  1673. is_constboolnode:=(p^.treetype=ordconstn) and is_boolean(p^.resulttype);
  1674. end;
  1675. function str_length(p : ptree) : longint;
  1676. begin
  1677. str_length:=p^.length;
  1678. end;
  1679. function is_emptyset(p : ptree):boolean;
  1680. {
  1681. return true if set s is empty
  1682. }
  1683. var
  1684. i : longint;
  1685. begin
  1686. i:=0;
  1687. if p^.treetype=setconstn then
  1688. begin
  1689. while (i<32) and (p^.value_set^[i]=0) do
  1690. inc(i);
  1691. end;
  1692. is_emptyset:=(i=32);
  1693. end;
  1694. {*****************************************************************************
  1695. Case Helpers
  1696. *****************************************************************************}
  1697. function case_count_labels(root : pcaserecord) : longint;
  1698. var
  1699. _l : longint;
  1700. procedure count(p : pcaserecord);
  1701. begin
  1702. inc(_l);
  1703. if assigned(p^.less) then
  1704. count(p^.less);
  1705. if assigned(p^.greater) then
  1706. count(p^.greater);
  1707. end;
  1708. begin
  1709. _l:=0;
  1710. count(root);
  1711. case_count_labels:=_l;
  1712. end;
  1713. function case_get_max(root : pcaserecord) : longint;
  1714. var
  1715. hp : pcaserecord;
  1716. begin
  1717. hp:=root;
  1718. while assigned(hp^.greater) do
  1719. hp:=hp^.greater;
  1720. case_get_max:=hp^._high;
  1721. end;
  1722. function case_get_min(root : pcaserecord) : longint;
  1723. var
  1724. hp : pcaserecord;
  1725. begin
  1726. hp:=root;
  1727. while assigned(hp^.less) do
  1728. hp:=hp^.less;
  1729. case_get_min:=hp^._low;
  1730. end;
  1731. {$ifdef newcg}
  1732. {$I new/node.inc}
  1733. {$endif newcg}
  1734. end.
  1735. {
  1736. $Log$
  1737. Revision 1.113 2000-02-20 20:49:46 florian
  1738. * newcg is compiling
  1739. * fixed the dup id problem reported by Paul Y.
  1740. Revision 1.112 2000/02/17 14:53:43 florian
  1741. * some updates for the newcg
  1742. Revision 1.111 2000/02/09 13:23:09 peter
  1743. * log truncated
  1744. Revision 1.110 2000/01/26 12:02:30 peter
  1745. * abstractprocdef.para_size needs alignment parameter
  1746. * secondcallparan gets para_alignment size instead of dword_align
  1747. Revision 1.109 2000/01/09 23:16:07 peter
  1748. * added st_default stringtype
  1749. * genstringconstnode extended with stringtype parameter using st_default
  1750. will do the old behaviour
  1751. Revision 1.108 2000/01/07 01:14:48 peter
  1752. * updated copyright to 2000
  1753. Revision 1.107 2000/01/06 01:10:33 pierre
  1754. * fixes for set_varstate on conversions
  1755. Revision 1.106 1999/12/22 01:01:52 peter
  1756. - removed freelabel()
  1757. * added undefined label detection in internal assembler, this prevents
  1758. a lot of ld crashes and wrong .o files
  1759. * .o files aren't written anymore if errors have occured
  1760. * inlining of assembler labels is now correct
  1761. Revision 1.105 1999/12/14 09:58:42 florian
  1762. + compiler checks now if a goto leaves an exception block
  1763. Revision 1.104 1999/11/30 10:40:59 peter
  1764. + ttype, tsymlist
  1765. Revision 1.103 1999/11/18 15:34:51 pierre
  1766. * Notes/Hints for local syms changed to
  1767. Set_varstate function
  1768. Revision 1.102 1999/11/17 17:05:07 pierre
  1769. * Notes/hints changes
  1770. Revision 1.101 1999/11/06 14:34:31 peter
  1771. * truncated log to 20 revs
  1772. Revision 1.100 1999/10/22 14:37:31 peter
  1773. * error when properties are passed to var parameters
  1774. Revision 1.99 1999/09/27 23:45:03 peter
  1775. * procinfo is now a pointer
  1776. * support for result setting in sub procedure
  1777. Revision 1.98 1999/09/26 21:30:22 peter
  1778. + constant pointer support which can happend with typecasting like
  1779. const p=pointer(1)
  1780. * better procvar parsing in typed consts
  1781. Revision 1.97 1999/09/17 17:14:13 peter
  1782. * @procvar fixes for tp mode
  1783. * @<id>:= gives now an error
  1784. Revision 1.96 1999/09/16 11:34:59 pierre
  1785. * typo correction
  1786. Revision 1.95 1999/09/10 18:48:11 florian
  1787. * some bug fixes (e.g. must_be_valid and procinfo^.funcret_is_valid)
  1788. * most things for stored properties fixed
  1789. Revision 1.94 1999/09/07 07:52:20 peter
  1790. * > < >= <= support for boolean
  1791. * boolean constants are now calculated like integer constants
  1792. Revision 1.93 1999/08/27 10:38:31 pierre
  1793. + EXTTEMPREGDEBUG code added
  1794. Revision 1.92 1999/08/26 21:10:08 peter
  1795. * better error recovery for case
  1796. Revision 1.91 1999/08/23 23:26:00 pierre
  1797. + TEMPREGDEBUG code, test of register allocation
  1798. if a tree uses more than registers32 regs then
  1799. internalerror(10) is issued
  1800. + EXTTEMPREGDEBUG will also give internalerror(10) if
  1801. a same register is freed twice (happens in several part
  1802. of current compiler like addn for strings and sets)
  1803. }