node.inc 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. {
  2. $Id$
  3. Copyright (c) 1999-2000 by Florian Klaempfl
  4. The declarations of the nodes for the new code generator
  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. {****************************************************************************
  19. TNODE
  20. ****************************************************************************}
  21. constructor tnode.init;
  22. begin
  23. inherited init;
  24. treetype:=nothingn;
  25. { this allows easier error tracing }
  26. location.loc:=LOC_INVALID;
  27. { save local info }
  28. fileinfo:=aktfilepos;
  29. localswitches:=aktlocalswitches;
  30. resulttype:=nil;
  31. registersint:=0;
  32. registersfpu:=0;
  33. {$ifdef SUPPORT_MMX}
  34. registersmmx:=0;
  35. {$endif SUPPORT_MMX}
  36. flags:=[];
  37. end;
  38. destructor tnode.done;
  39. begin
  40. { reference info }
  41. if (location.loc in [LOC_MEM,LOC_REFERENCE]) and
  42. assigned(location.reference.symbol) then
  43. dispose(location.reference.symbol,done);
  44. {$ifdef EXTDEBUG}
  45. if firstpasscount>maxfirstpasscount then
  46. maxfirstpasscount:=firstpasscount;
  47. {$endif EXTDEBUG}
  48. end;
  49. procedure tnode.pass_1;
  50. begin
  51. if not(assigned(resulttype)) then
  52. det_resulttype;
  53. det_temp;
  54. end;
  55. procedure tnode.det_resulttype;
  56. begin
  57. abstract;
  58. end;
  59. procedure tnode.det_temp;
  60. begin
  61. abstract;
  62. end;
  63. procedure tnode.secondpass;
  64. begin
  65. abstract;
  66. end;
  67. procedure tnode.concattolist(l : plinkedlist);
  68. begin
  69. l^.concat(@self);
  70. end;
  71. function tnode.ischild(p : pnode) : boolean;
  72. begin
  73. ischild:=false;
  74. end;
  75. {$ifdef EXTDEBUG}
  76. procedure tnode.dowrite;
  77. const treetype2str : array[ttreetyp] of string[20] = (
  78. 'addn',
  79. 'muln',
  80. 'subn',
  81. 'divn',
  82. 'symdifn',
  83. 'modn',
  84. 'assignn',
  85. 'loadn',
  86. 'rangen',
  87. 'ltn',
  88. 'lten',
  89. 'gtn',
  90. 'gten',
  91. 'equaln',
  92. 'unequaln',
  93. 'inn',
  94. 'orn',
  95. 'xorn',
  96. 'shrn',
  97. 'shln',
  98. 'slashn',
  99. 'andn',
  100. 'subscriptn',
  101. 'derefn',
  102. 'addrn',
  103. 'doubleaddrn',
  104. 'ordconstn',
  105. 'typeconvn',
  106. 'calln',
  107. 'callparan',
  108. 'realconstn',
  109. 'fixconstn',
  110. 'umminusn',
  111. 'asmn',
  112. 'vecn',
  113. 'stringconstn',
  114. 'funcretn',
  115. 'selfn',
  116. 'notn',
  117. 'inlinen',
  118. 'niln',
  119. 'errorn',
  120. 'typen',
  121. 'hnewn',
  122. 'hdisposen',
  123. 'newn',
  124. 'simpledisposen',
  125. 'setelementn',
  126. 'setconstn',
  127. 'blockn',
  128. 'statementn',
  129. 'loopn',
  130. 'ifn',
  131. 'breakn',
  132. 'continuen',
  133. 'repeatn',
  134. 'whilen',
  135. 'forn',
  136. 'exitn',
  137. 'withn',
  138. 'casen',
  139. 'labeln',
  140. 'goton',
  141. 'simplenewn',
  142. 'tryexceptn',
  143. 'raisen',
  144. 'switchesn',
  145. 'tryfinallyn',
  146. 'onn',
  147. 'isn',
  148. 'asn',
  149. 'caretn',
  150. 'failn',
  151. 'starstarn',
  152. 'procinlinen',
  153. 'arrayconstructn',
  154. 'arrayconstructrangen',
  155. 'nothingn',
  156. 'loadvmtn',
  157. 'pointerconstn');
  158. begin
  159. write(indention,'(',treetype2str[treetype]);
  160. end;
  161. {$endif EXTDEBUG}
  162. {****************************************************************************
  163. TUNARYNODE
  164. ****************************************************************************}
  165. constructor tunarynode.init(l : pnode);
  166. begin
  167. inherited init;
  168. left:=l;
  169. end;
  170. {$ifdef extdebug}
  171. procedure tunarynode.dowrite;
  172. begin
  173. inherited dowrite;
  174. writeln(',');
  175. writenode(left);
  176. writeln(')');
  177. dec(byte(indention[0]),2);
  178. end;
  179. {$endif}
  180. procedure tunarynode.concattolist(l : plinkedlist);
  181. begin
  182. left^.parent:=@self;
  183. left^.concattolist(l);
  184. inherited concattolist(l);
  185. end;
  186. function tunarynode.ischild(p : pnode) : boolean;
  187. begin
  188. ischild:=p=left;
  189. end;
  190. procedure tunarynode.det_resulttype;
  191. begin
  192. left^.det_resulttype;
  193. end;
  194. procedure tunarynode.det_temp;
  195. begin
  196. left^.det_temp;
  197. end;
  198. {****************************************************************************
  199. TBINARYNODE
  200. ****************************************************************************}
  201. constructor tbinarynode.init(l,r : pnode);
  202. begin
  203. inherited init(l);
  204. right:=r
  205. end;
  206. procedure tbinarynode.concattolist(l : plinkedlist);
  207. begin
  208. { we could change that depending on the number of }
  209. { required registers }
  210. left^.parent:=@self;
  211. left^.concattolist(l);
  212. left^.parent:=@self;
  213. left^.concattolist(l);
  214. inherited concattolist(l);
  215. end;
  216. function tbinarynode.ischild(p : pnode) : boolean;
  217. begin
  218. ischild:=(p=right) or (p=right);
  219. end;
  220. procedure tbinarynode.det_resulttype;
  221. begin
  222. left^.det_resulttype;
  223. right^.det_resulttype;
  224. end;
  225. procedure tbinarynode.det_temp;
  226. begin
  227. left^.det_temp;
  228. right^.det_temp;
  229. end;
  230. {****************************************************************************
  231. TBINOPYNODE
  232. ****************************************************************************}
  233. constructor tbinopnode.init(l,r : pnode);
  234. begin
  235. inherited init(l,r);
  236. swaped:=false;
  237. end;
  238. {
  239. $Log$
  240. Revision 1.2 2000-07-13 11:32:54 michael
  241. + removed logs
  242. }