home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / real_constant.e < prev    next >
Text File  |  1999-06-05  |  3KB  |  109 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://SmallEiffel.loria.fr
  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. feature
  52.  
  53.    static_result_base_class: BASE_CLASS is
  54.       do
  55.          Result := small_eiffel.get_class(as_real);
  56.       end;
  57.  
  58.    static_value: INTEGER is
  59.       do
  60.       end;
  61.  
  62.    compile_to_c is
  63.       do
  64.          cpp.put_string(to_string);
  65.       end;
  66.  
  67.    compile_target_to_jvm, compile_to_jvm is
  68.       do
  69.          code_attribute.opcode_push_as_float(to_string);
  70.       end;
  71.  
  72.    jvm_branch_if_false: INTEGER is
  73.       do
  74.       end;
  75.  
  76.    jvm_branch_if_true: INTEGER is
  77.       do
  78.       end;
  79.  
  80.    compile_to_jvm_into(dest: TYPE): INTEGER is
  81.       do
  82.          if dest.is_real then
  83.             code_attribute.opcode_push_as_float(to_string);
  84.             Result := 1;
  85.          elseif dest.is_double then
  86.             code_attribute.opcode_push_as_double(to_string);
  87.             Result := 2;
  88.          else
  89.             Result := standard_compile_to_jvm_into(dest);
  90.          end;
  91.       end;
  92.  
  93. feature -- Following features do not change Current :
  94.  
  95.    result_type: TYPE_REAL is
  96.       once
  97.          !!Result.make(Void);
  98.       end;
  99.  
  100. feature {EIFFEL_PARSER}
  101.  
  102.    unary_minus is
  103.       do
  104.          to_string.add_first('-');
  105.       end;
  106.  
  107. end -- REAL_CONSTANT
  108.  
  109.