ncon.pas 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. globtype,node,aasm,cpuinfo,symconst;
  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. symtable,types,
  67. hcodegen,pass_1,cpubase;
  68. {*****************************************************************************
  69. TREALCONSTNODE
  70. *****************************************************************************}
  71. function trealconstnode.pass_1 : tnode;
  72. begin
  73. pass_1:=nil;
  74. if (value_real=1.0) or (value_real=0.0) then
  75. begin
  76. location.loc:=LOC_FPU;
  77. registersfpu:=1;
  78. end
  79. else
  80. location.loc:=LOC_MEM;
  81. end;
  82. {*****************************************************************************
  83. TFIXCONSTNODE
  84. *****************************************************************************}
  85. function tfixconstnode.pass_1 : tnode;
  86. begin
  87. pass_1:=nil;
  88. location.loc:=LOC_MEM;
  89. end;
  90. {*****************************************************************************
  91. TORDCONSTNODE
  92. *****************************************************************************}
  93. function tordconstnode.pass_1 : tnode;
  94. begin
  95. pass_1:=nil;
  96. location.loc:=LOC_MEM;
  97. end;
  98. {*****************************************************************************
  99. TPOINTERCONSTNODE
  100. *****************************************************************************}
  101. function tpointerconstnode.pass_1 : tnode;
  102. begin
  103. pass_1:=nil;
  104. location.loc:=LOC_MEM;
  105. end;
  106. {*****************************************************************************
  107. TSTRINGCONSTNODE
  108. *****************************************************************************}
  109. function tstringconstnode.pass_1 : tnode;
  110. begin
  111. pass_1:=nil;
  112. { if cs_ansistrings in aktlocalswitches then
  113. resulttype:=cansistringdef
  114. else
  115. resulttype:=cshortstringdef; }
  116. case stringtype of
  117. st_shortstring :
  118. resulttype:=cshortstringdef;
  119. st_ansistring :
  120. resulttype:=cansistringdef;
  121. st_widestring :
  122. resulttype:=cwidestringdef;
  123. st_longstring :
  124. resulttype:=clongstringdef;
  125. end;
  126. location.loc:=LOC_MEM;
  127. end;
  128. {*****************************************************************************
  129. TSETCONSTNODE
  130. *****************************************************************************}
  131. function tsetconstnode.pass_1 : tnode;
  132. begin
  133. pass_1:=nil;
  134. location.loc:=LOC_MEM;
  135. end;
  136. {*****************************************************************************
  137. TNILNODE
  138. *****************************************************************************}
  139. function tnilnode.pass_1 : tnode;
  140. begin
  141. pass_1:=nil;
  142. resulttype:=voidpointerdef;
  143. location.loc:=LOC_MEM;
  144. end;
  145. end.
  146. {
  147. $Log$
  148. Revision 1.3 2000-09-24 21:15:34 florian
  149. * some errors fix to get more stuff compilable
  150. Revision 1.2 2000/09/24 15:06:19 peter
  151. * use defines.inc
  152. Revision 1.1 2000/09/22 21:44:48 florian
  153. + initial revision
  154. }