home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / abstract_result.e < prev    next >
Text File  |  1999-06-05  |  6KB  |  252 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. deferred class ABSTRACT_RESULT
  17.    --
  18.    -- Handling of the pseudo variable `Result'.
  19.    -- Common root of ONCE_RESULT and ORDINARY_RESULT.
  20.    --
  21.  
  22. inherit EXPRESSION;
  23.  
  24. feature
  25.  
  26.    start_position: POSITION;
  27.  
  28. feature
  29.  
  30.    make(sp: like start_position) is
  31.       require
  32.          sp /= Void
  33.       do
  34.          start_position := sp;
  35.       ensure
  36.          start_position = sp
  37.       end;
  38.  
  39. feature
  40.  
  41.    is_result: BOOLEAN is true;
  42.  
  43.    is_writable: BOOLEAN is true;
  44.  
  45.    is_current: BOOLEAN is false;
  46.  
  47.    is_manifest_string: BOOLEAN is false;
  48.  
  49.    is_void: BOOLEAN is false;
  50.  
  51.    is_static: BOOLEAN is false;
  52.  
  53.    is_pre_computable: BOOLEAN is false;
  54.  
  55.    isa_dca_inline_argument: INTEGER is 0;
  56.  
  57.    can_be_dropped: BOOLEAN is true;
  58.  
  59.    c_simple: BOOLEAN is true;
  60.  
  61.    use_current: BOOLEAN is false;
  62.  
  63. feature
  64.  
  65.    result_type: TYPE is
  66.       deferred
  67.       end;
  68.  
  69.    frozen to_string, frozen to_key: STRING is
  70.       do
  71.          Result := as_result;
  72.       end;
  73.  
  74.    frozen static_result_base_class: BASE_CLASS is
  75.       local
  76.          rf: RUN_FEATURE;
  77.          e_feature: E_FEATURE;
  78.          rt: TYPE;
  79.          bcn: CLASS_NAME;
  80.       do
  81.          rf := small_eiffel.top_rf;
  82.          e_feature := rf.base_feature;
  83.          rt := e_feature.result_type;
  84.          bcn := rt.static_base_class_name;
  85.          if bcn /= Void then
  86.             Result := bcn.base_class;
  87.          end;
  88.       end;
  89.  
  90.    frozen static_value: INTEGER is
  91.       do
  92.       end;
  93.  
  94.    frozen assertion_check(tag: CHARACTER) is
  95.       do
  96.       end;
  97.  
  98.    frozen afd_check is
  99.       do
  100.       end;
  101.  
  102.    frozen dca_inline_argument(formal_arg_type: TYPE) is
  103.       do
  104.       end;
  105.  
  106.    frozen bracketed_pretty_print, frozen pretty_print is
  107.       do
  108.          fmt.put_string(as_result);
  109.       end;
  110.  
  111.    frozen print_as_target is
  112.       do
  113.          fmt.put_string(as_result);
  114.          fmt.put_character('.');
  115.       end;
  116.  
  117.    frozen short is
  118.       do
  119.          short_print.hook_or(as_result,as_result);
  120.       end;
  121.  
  122.    frozen short_target is
  123.       do
  124.          short;
  125.          short_print.a_dot;
  126.       end;
  127.  
  128.    frozen mapping_c_target(target_type: TYPE) is
  129.       local
  130.          flag: BOOLEAN;
  131.          rt: like result_type;
  132.       do
  133.          flag := cpp.call_invariant_start(target_type);
  134.          rt := result_type.run_type;
  135.          if rt.is_reference then
  136.             if target_type.is_reference then
  137.                -- Reference into Reference :
  138.                cpp.put_string(fz_b7);
  139.                cpp.put_integer(target_type.id);
  140.                cpp.put_string(fz_b8);
  141.                compile_to_c;
  142.                cpp.put_character(')');
  143.             else
  144.                -- Reference into Expanded :
  145.                rt.to_expanded;
  146.                cpp.put_character('(');
  147.                compile_to_c;
  148.                cpp.put_character(')');
  149.             end;
  150.          else
  151.             if target_type.is_reference then
  152.                -- Expanded into Reference :
  153.                rt.to_reference;
  154.                cpp.put_character('(');
  155.                compile_to_c;
  156.                cpp.put_character(')');
  157.             else
  158.                -- Expanded into Expanded :
  159.                if rt.need_c_struct then
  160.                   cpp.put_character('&');
  161.                end;
  162.                compile_to_c;
  163.             end;
  164.          end;
  165.          if flag then
  166.             cpp.call_invariant_end;
  167.          end;
  168.       end;
  169.  
  170.    frozen mapping_c_arg(formal_arg_type: TYPE) is
  171.       local
  172.          rt: like result_type;
  173.       do
  174.          rt := result_type.run_type;
  175.          if rt.is_reference then
  176.             if formal_arg_type.is_reference then
  177.                -- Reference into Reference :
  178.                compile_to_c;
  179.             else
  180.                -- Reference into Expanded :
  181.                rt.to_expanded;
  182.                cpp.put_character('(');
  183.                compile_to_c;
  184.                cpp.put_character(')');
  185.             end;
  186.          else
  187.             if formal_arg_type.is_reference then
  188.                -- Expanded into Reference :
  189.                rt.to_reference;
  190.                cpp.put_character('(');
  191.                compile_to_c;
  192.                cpp.put_character(')');
  193.             else
  194.                -- Expanded into Expanded :
  195.                if rt.need_c_struct then
  196.                   cpp.put_character('&');
  197.                end;
  198.                compile_to_c;
  199.             end;
  200.          end;
  201.       end;
  202.  
  203.    frozen collect_c_tmp is
  204.       do
  205.       end;
  206.  
  207.    frozen c_declare_for_old is
  208.       do
  209.       end;
  210.  
  211.    frozen compile_to_c_old is
  212.       do
  213.       end;
  214.  
  215.    frozen compile_to_jvm_old is
  216.       do
  217.       end;
  218.  
  219.    frozen compile_target_to_jvm is
  220.       do
  221.          standard_compile_target_to_jvm;
  222.       end;
  223.  
  224.    frozen jvm_branch_if_false: INTEGER is
  225.       do
  226.          compile_to_jvm;
  227.          Result := code_attribute.opcode_ifeq;
  228.       end;
  229.  
  230.    frozen jvm_branch_if_true: INTEGER is
  231.       do
  232.          compile_to_jvm;
  233.          Result := code_attribute.opcode_ifne;
  234.       end;
  235.  
  236.    frozen compile_to_jvm_into(dest: TYPE): INTEGER is
  237.       do
  238.          Result := standard_compile_to_jvm_into(dest);
  239.       end;
  240.  
  241.    frozen precedence: INTEGER is
  242.       do
  243.          Result := atomic_precedence;
  244.       end;
  245.  
  246. invariant
  247.  
  248.    start_position /= Void
  249.  
  250. end -- ABSTRACT_RESULT
  251.  
  252.