ncon.pas 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Florian Klaempfl
  4. Type checking and register allocation for constants
  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 ncon;
  19. {$i defines.inc}
  20. interface
  21. uses
  22. node;
  23. type
  24. trealconstnode = class(tnode)
  25. value_real : bestreal;
  26. lab_real : pasmlabel;
  27. // !!!!!!! needs at least create, getcopy
  28. function pass_1 : tnode;override;
  29. end;
  30. tfixconstnode = class(tnode)
  31. value_fix: longint;
  32. // !!!!!!! needs at least create, getcopy
  33. function pass_1 : tnode;override;
  34. end;
  35. tordconstnode = class(tnode)
  36. value : TConstExprInt;
  37. // !!!!!!! needs at least create, getcopy
  38. function pass_1 : tnode;override;
  39. end;
  40. tpointerconstnode = class(tnode)
  41. value : TPointerOrd;
  42. // !!!!!!! needs at least create, getcopy
  43. function pass_1 : tnode;override;
  44. end;
  45. tstringconstnode = class(tnode)
  46. value_str : pchar;
  47. length : longint;
  48. lab_str : pasmlabel;
  49. stringtype : tstringtype
  50. // !!!!!!! needs at least create, getcopy, destroy
  51. function pass_1 : tnode;override;
  52. end;
  53. tsetconstnode = class(tnode)
  54. value_set : pconstset;
  55. lab_set : pasmlabel
  56. // !!!!!!! needs at least create, getcopy
  57. function pass_1 : tnode;override;
  58. end;
  59. tnilnode = class(tnode)
  60. // !!!!!!! needs at least create
  61. function pass_1 : tnode;override;
  62. end;
  63. implementation
  64. uses
  65. cobjects,verbose,globals,systems,
  66. symconst,symtable,aasm,types,
  67. hcodegen,pass_1,cpubase;
  68. {*****************************************************************************
  69. TREALCONSTNODE
  70. *****************************************************************************}
  71. function tpointerconstnode.pass_1 : tnode;
  72. begin
  73. if (value_real=1.0) or (value_real=0.0) then
  74. begin
  75. location.loc:=LOC_FPU;
  76. registersfpu:=1;
  77. end
  78. else
  79. location.loc:=LOC_MEM;
  80. end;
  81. {*****************************************************************************
  82. TFIXCONSTNODE
  83. *****************************************************************************}
  84. function tpointerconstnode.pass_1 : tnode;
  85. begin
  86. location.loc:=LOC_MEM;
  87. end;
  88. {*****************************************************************************
  89. TORDCONSTNODE
  90. *****************************************************************************}
  91. function tpointerconstnode.pass_1 : tnode;
  92. begin
  93. location.loc:=LOC_MEM;
  94. end;
  95. {*****************************************************************************
  96. TPOINTERCONSTNODE
  97. *****************************************************************************}
  98. function tpointerconstnode.pass_1 : tnode;
  99. begin
  100. location.loc:=LOC_MEM;
  101. end;
  102. {*****************************************************************************
  103. TSTRINGCONSTNODE
  104. *****************************************************************************}
  105. function tstringconstnode.pass_1 : tnode;
  106. begin
  107. { if cs_ansistrings in aktlocalswitches then
  108. resulttype:=cansistringdef
  109. else
  110. resulttype:=cshortstringdef; }
  111. case stringtype of
  112. st_shortstring :
  113. resulttype:=cshortstringdef;
  114. st_ansistring :
  115. resulttype:=cansistringdef;
  116. st_widestring :
  117. resulttype:=cwidestringdef;
  118. st_longstring :
  119. resulttype:=clongstringdef;
  120. end;
  121. location.loc:=LOC_MEM;
  122. end;
  123. {*****************************************************************************
  124. TSETCONSTNODE
  125. *****************************************************************************}
  126. function tsetconstnode.pass_1 : tnode;
  127. begin
  128. location.loc:=LOC_MEM;
  129. end;
  130. {*****************************************************************************
  131. TNILNODE
  132. *****************************************************************************}
  133. function tnilnode.pass_1 : tnode;
  134. begin
  135. resulttype:=voidpointerdef;
  136. location.loc:=LOC_MEM;
  137. end;
  138. end.
  139. {
  140. $Log$
  141. Revision 1.2 2000-09-24 15:06:19 peter
  142. * use defines.inc
  143. Revision 1.1 2000/09/22 21:44:48 florian
  144. + initial revision
  145. }