home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / call_prefix.e < prev    next >
Text File  |  1999-06-05  |  3KB  |  132 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 CALL_PREFIX
  17.    --
  18.    -- For all sort of prefix operators.
  19.    -- Root of all CALL_PREFIX_*.
  20.    --
  21.  
  22. inherit CALL_0 redefine feature_name, print_as_target end;
  23.  
  24. feature
  25.  
  26.    feature_name: PREFIX_NAME;
  27.  
  28. feature
  29.  
  30.    is_pre_computable: BOOLEAN is false;
  31.  
  32. feature {NONE}
  33.  
  34.    with(t: like target; fn: like feature_name; rf: RUN_FEATURE) is
  35.       require
  36.          t /= Void;
  37.          fn.to_string = operator;
  38.          rf /= Void
  39.       do
  40.          target := t;
  41.          feature_name := fn;
  42.          run_feature := rf;
  43.          run_feature_match;
  44.       ensure
  45.          target = t;
  46.          feature_name = fn;
  47.          run_feature = rf
  48.       end;
  49.  
  50. feature
  51.  
  52.    operator: STRING is
  53.       deferred
  54.       end;
  55.  
  56. feature
  57.  
  58.    frozen to_runnable(ct: TYPE): like Current is
  59.       local
  60.          t: like target;
  61.          rf: RUN_FEATURE;
  62.       do
  63.          t := runnable_expression(target,ct);
  64.          rf := run_feature_for(t,ct);
  65.          if run_feature = Void then
  66.             target := t;
  67.             run_feature := rf;
  68.             run_feature_match;
  69.             Result := Current;
  70.          elseif t = target then
  71.             check
  72.                run_feature = rf
  73.             end;
  74.             Result := Current;
  75.          else
  76.             !!Result.with(t,feature_name,rf);
  77.          end;
  78.       end;
  79.  
  80.    compile_to_c is
  81.       do
  82.          call_proc_call_c2c;
  83.       end;
  84.  
  85.    frozen bracketed_pretty_print is
  86.       do
  87.          fmt.put_character('(');
  88.          pretty_print;
  89.          fmt.put_character(')');
  90.       end;
  91.  
  92.    frozen pretty_print is
  93.       do
  94.          feature_name.pretty_print;
  95.          fmt.put_character(' ');
  96.          if target.precedence < precedence then
  97.             fmt.put_character('(');
  98.             target.pretty_print;
  99.             fmt.put_character(')');
  100.          else
  101.             target.pretty_print;
  102.          end;
  103.       end;
  104.  
  105.    frozen print_as_target is
  106.       do
  107.          fmt.put_character('(');
  108.          pretty_print;
  109.          fmt.put_character(')');
  110.          fmt.put_character('.');
  111.       end;
  112.  
  113.    frozen short is
  114.       do
  115.          short_print.a_prefix_name(feature_name);
  116.          if target.precedence < precedence then
  117.             target.bracketed_short;
  118.          else
  119.             target.short;
  120.          end;
  121.       end;
  122.  
  123.    frozen short_target is
  124.       do
  125.          bracketed_short;
  126.          short_print.a_dot;
  127.       end;
  128.  
  129. end -- CALL_PREFIX
  130.  
  131.  
  132.