home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / character_constant.e < prev    next >
Text File  |  1999-06-05  |  4KB  |  141 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 CHARACTER_CONSTANT
  17. --
  18. -- For Manifest Constant CHARACTER.
  19. --
  20.  
  21. inherit BASE_TYPE_CONSTANT redefine to_integer end;
  22.  
  23. creation make
  24.  
  25. feature
  26.  
  27.    value: CHARACTER;
  28.  
  29. feature
  30.  
  31.    pretty_print_mode: INTEGER;
  32.  
  33.    std_pretty_print: INTEGER is 0;
  34.  
  35.    percent_pretty_print: INTEGER is 1;
  36.  
  37.    ascii_pretty_print: INTEGER is 2;
  38.  
  39.    c_simple: BOOLEAN is true;
  40.  
  41.    is_static: BOOLEAN is true;
  42.  
  43. feature {NONE}
  44.  
  45.    make(sp: like start_position; v: like value;
  46.         pm: like pretty_print_mode) is
  47.       require
  48.          sp /= Void;
  49.       do
  50.          start_position := sp;
  51.          value := v;
  52.          set_pretty_print_mode(pm);
  53.       ensure
  54.          start_position = sp;
  55.          value = v;
  56.          pretty_print_mode = pm;
  57.       end;
  58.  
  59. feature
  60.  
  61.    static_result_base_class: BASE_CLASS is
  62.       do
  63.          Result := small_eiffel.get_class(as_character);
  64.       end;
  65.  
  66.    static_value, to_integer: INTEGER is
  67.       do
  68.          Result := value.code;
  69.       end;
  70.  
  71.    compile_to_c is
  72.       do
  73.          cpp.put_character('%'');
  74.          if value.is_letter or else value.is_digit then
  75.             cpp.put_character(value);
  76.          elseif value = '%N' then
  77.             cpp.put_character('\');
  78.             cpp.put_character('n');
  79.          else
  80.             cpp.put_character('\');
  81.             cpp.put_integer(value.code.to_octal);
  82.          end;
  83.          cpp.put_character('%'');
  84.       end;
  85.  
  86.    compile_to_jvm, compile_target_to_jvm is
  87.       do
  88.          code_attribute.opcode_push_integer(value.code);
  89.       end;
  90.  
  91.    jvm_branch_if_false: INTEGER is
  92.       do
  93.       end;
  94.  
  95.    jvm_branch_if_true: INTEGER is
  96.       do
  97.       end;
  98.  
  99.    compile_to_jvm_into(dest: TYPE): INTEGER is
  100.       do
  101.          Result := standard_compile_to_jvm_into(dest);
  102.       end;
  103.  
  104.    set_pretty_print_mode(pm: like pretty_print_mode) is
  105.       require
  106.          pm = std_pretty_print or else
  107.          pm = percent_pretty_print or else
  108.          pm = ascii_pretty_print
  109.       do
  110.          pretty_print_mode := pm;
  111.       ensure
  112.          pretty_print_mode = pm;
  113.       end;
  114.  
  115.    to_string: STRING is
  116.       do
  117.          !!Result.make(0);
  118.          Result.extend('%'');
  119.          inspect
  120.             pretty_print_mode
  121.          when std_pretty_print then
  122.             Result.extend(value);
  123.          when percent_pretty_print then
  124.             character_coding(value,Result);
  125.          when ascii_pretty_print then
  126.             Result.extend('%%');
  127.             Result.extend('/');
  128.             value.code.append_in(Result);
  129.             Result.extend('/');
  130.          end;
  131.          Result.extend('%'');
  132.       end;
  133.  
  134.    result_type: TYPE_CHARACTER is
  135.       once
  136.          !!Result.make(Void);
  137.       end;
  138.  
  139. end -- CHARACTER_CONSTANT
  140.  
  141.