home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / real_constant.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  2.4 KB  |  98 lines

  1. --          This file is part of SmallEiffel The GNU Eiffel Compiler.
  2. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  3. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr 
  4. --                       http://www.loria.fr/SmallEiffel
  5. -- SmallEiffel is  free  software;  you can  redistribute it and/or modify it 
  6. -- under the terms of the GNU General Public License as published by the Free
  7. -- Software  Foundation;  either  version  2, or (at your option)  any  later 
  8. -- version. SmallEiffel is distributed in the hope that it will be useful,but
  9. -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. -- or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU General Public License 
  11. -- for  more  details.  You  should  have  received a copy of the GNU General 
  12. -- Public  License  along  with  SmallEiffel;  see the file COPYING.  If not,
  13. -- write to the  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. -- Boston, MA 02111-1307, USA.
  15. --
  16. class REAL_CONSTANT
  17.    --
  18.    -- For Manifest Constant REAL.
  19.    -- 
  20.    
  21. inherit BASE_TYPE_CONSTANT;
  22.  
  23. creation make
  24.  
  25. feature 
  26.    
  27.    to_string: STRING;
  28.      -- Cleanly written view of the constant.
  29.      -- ANSI C compatible.
  30.  
  31. feature 
  32.  
  33.    c_simple: BOOLEAN is true;
  34.    
  35.    is_static: BOOLEAN is false;
  36.       
  37. feature
  38.    
  39.    make(sp: like start_position; ts: like to_string) is
  40.       require      
  41.      sp /= Void; 
  42.      ts /= Void
  43.       do
  44.      start_position := sp; 
  45.      to_string := ts;
  46.       ensure      
  47.      start_position = sp; 
  48.      to_string = ts
  49.       end;
  50.    
  51.    compile_to_c is
  52.       do
  53.      cpp.put_string(to_string);
  54.       end;
  55.    
  56.    compile_target_to_jvm, compile_to_jvm is
  57.       do
  58.      code_attribute.opcode_push_as_float(to_string);
  59.       end;
  60.    
  61.    jvm_branch_if_false: INTEGER is
  62.       do
  63.       end;
  64.  
  65.    jvm_branch_if_true: INTEGER is
  66.       do
  67.       end;
  68.    
  69.    compile_to_jvm_into(dest: TYPE): INTEGER is
  70.       do
  71.      if dest.is_real then
  72.         code_attribute.opcode_push_as_float(to_string);
  73.         Result := 1;
  74.      elseif dest.is_double then
  75.         code_attribute.opcode_push_as_double(to_string);
  76.         Result := 2;
  77.      else
  78.         Result := standard_compile_to_jvm_into(dest);
  79.      end;
  80.       end;
  81.  
  82. feature -- Following features do not change Current :
  83.    
  84.    result_type: TYPE_REAL is
  85.       once
  86.      !!Result.make(Void);
  87.       end;
  88.  
  89. feature {EIFFEL_PARSER}
  90.    
  91.    unary_minus is
  92.       do
  93.      to_string.add_first('-');
  94.       end;
  95.  
  96. end -- REAL_CONSTANT
  97.  
  98.