nstatmnt.pas 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. {
  2. $Id$
  3. Copyright (C) 1998-2000 by Florian Klaempfl
  4. This unit implements block, statement nodes etc.
  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. unit nstatmnt;
  19. interface
  20. uses
  21. tree;
  22. type
  23. pblocknode = ^tblocknode;
  24. tblocknode = object(tunarynode)
  25. constructor init(l : pnode);
  26. procedure det_temp;virtual;
  27. procedure det_resulttype;virtual;
  28. procedure secondpass;virtual;
  29. end;
  30. pstatementnode = ^tstatementnode;
  31. tstatementnode = object(tbinarynode)
  32. constructor init(l,r : pnode);
  33. end;
  34. implementation
  35. uses
  36. tgobj,globtype,globals,symtable,verbose,cgbase,tgcpu;
  37. {****************************************************************************
  38. TSTAMENTNODE
  39. ****************************************************************************}
  40. constructor tstatementnode.init(l,r : pnode);
  41. begin
  42. inherited init(l,r);
  43. treetype:=statementn;
  44. end;
  45. {****************************************************************************
  46. TBLOCKNODE
  47. ****************************************************************************}
  48. constructor tblocknode.init(l : pnode);
  49. begin
  50. inherited init(l);
  51. treetype:=blockn;
  52. end;
  53. procedure tblocknode.det_resulttype;
  54. var
  55. hp : pstatementnode;
  56. begin
  57. hp:=pstatementnode(left);
  58. while assigned(hp) do
  59. begin
  60. if assigned(pstatementnode(hp)^.right) then
  61. begin
  62. tg.cleartempgen;
  63. hp^.right^.det_resulttype;
  64. if (not (cs_extsyntax in aktmoduleswitches)) and
  65. assigned(hp^.right^.resulttype) and
  66. (hp^.right^.resulttype<>pdef(voiddef)) then
  67. CGMessage(cg_e_illegal_expression);
  68. if codegenerror then
  69. exit;
  70. end;
  71. hp:=pstatementnode(hp^.left);
  72. end;
  73. end;
  74. procedure tblocknode.det_temp;
  75. var
  76. hp : pstatementnode;
  77. begin
  78. hp:=pstatementnode(left);
  79. while assigned(hp) do
  80. begin
  81. if assigned(hp^.right) then
  82. begin
  83. tg.cleartempgen;
  84. hp^.right^.det_temp;
  85. if (not (cs_extsyntax in aktmoduleswitches)) and
  86. assigned(hp^.right^.resulttype) and
  87. (hp^.right^.resulttype<>pdef(voiddef)) then
  88. CGMessage(cg_e_illegal_expression);
  89. if codegenerror then
  90. exit;
  91. hp^.registersint:=hp^.right^.registersint;
  92. hp^.registersfpu:=hp^.right^.registersfpu;
  93. {$ifdef SUPPORT_MMX}
  94. hp^.registersmmx:=hp^.right^.registersmmx;
  95. hp^.registerskni:=hp^.right^.registerskni;
  96. {$endif SUPPORT_MMX}
  97. end
  98. else
  99. hp^.registersint:=0;
  100. if hp^.registersint>registersint then
  101. registersint:=hp^.registersint;
  102. if hp^.registersfpu>registersfpu then
  103. registersfpu:=hp^.registersfpu;
  104. {$ifdef SUPPORT_MMX}
  105. if hp^.registersmmx>registersmmx then
  106. registersmmx:=hp^.registersmmx;
  107. if hp^.registerskni>registerskni then
  108. registerskni:=hp^.registerskni;
  109. {$endif}
  110. hp:=pstatementnode(hp^.left);
  111. end;
  112. end;
  113. procedure tblocknode.secondpass;
  114. begin
  115. if assigned(left) then
  116. left^.secondpass;
  117. end;
  118. end.
  119. {
  120. $Log$
  121. Revision 1.1 2000-07-13 06:30:08 michael
  122. + Initial import
  123. Revision 1.5 2000/01/07 01:14:54 peter
  124. * updated copyright to 2000
  125. Revision 1.4 1999/08/05 14:58:14 florian
  126. * some fixes for the floating point registers
  127. * more things for the new code generator
  128. Revision 1.3 1999/08/02 17:14:09 florian
  129. + changed the temp. generator to an object
  130. Revision 1.2 1999/08/01 23:36:43 florian
  131. * some changes to compile the new code generator
  132. Revision 1.1 1999/01/23 23:35:02 florian
  133. + first versions
  134. }