home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / instruction_with_comment.e < prev    next >
Text File  |  1999-06-05  |  3KB  |  124 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 INSTRUCTION_WITH_COMMENT
  17.    --
  18.    -- To store one instruction with a following comment.
  19.    --
  20.  
  21. inherit INSTRUCTION;
  22.  
  23. creation make
  24.  
  25. feature
  26.  
  27.    instruction : INSTRUCTION;
  28.  
  29.    comment : COMMENT;
  30.  
  31. feature
  32.  
  33.    make(i: like instruction; c: like comment) is
  34.       require
  35.          i /= void;
  36.          really_a_comment: c.count > 0;
  37.       do
  38.          instruction := i;
  39.          comment := c;
  40.       end;
  41.  
  42. feature
  43.  
  44.    end_mark_comment: BOOLEAN is false;
  45.  
  46. feature
  47.  
  48.    use_current: BOOLEAN is
  49.       do
  50.          Result := instruction.use_current;
  51.       end;
  52.  
  53.    afd_check is
  54.       do
  55.          instruction.afd_check;
  56.       end;
  57.  
  58.    collect_c_tmp is
  59.       do
  60.          instruction.collect_c_tmp;
  61.       end;
  62.  
  63.    compile_to_c is
  64.       do
  65.          instruction.compile_to_c;
  66.       end;
  67.  
  68.    compile_to_jvm is
  69.       do
  70.          instruction.compile_to_jvm;
  71.       end;
  72.  
  73.    is_pre_computable: BOOLEAN is
  74.       do
  75.          Result := instruction.is_pre_computable;
  76.       end;
  77.  
  78.    start_position: POSITION is
  79.       do
  80.          Result := instruction.start_position;
  81.       end;
  82.  
  83.    to_runnable(ct: TYPE): like Current is
  84.       local
  85.          ri: like instruction;
  86.       do
  87.          ri := instruction.to_runnable(ct);
  88.          if ri = Void then
  89.             error(instruction.start_position,"Bad instruction.");
  90.             Result := Current;
  91.          elseif ri = instruction then
  92.             Result := Current;
  93.          else
  94.             !!Result.make(ri,comment);
  95.          end;
  96.       end;
  97.  
  98.    pretty_print is
  99.       local
  100.          fmt_mode: INTEGER;
  101.       do
  102.          if comment.dummy then
  103.             instruction.pretty_print;
  104.          else
  105.             fmt_mode := fmt.mode;
  106.             fmt.set_zen;
  107.             instruction.pretty_print;
  108.             fmt.level_incr;
  109.             fmt.indent;
  110.             fmt.level_decr;
  111.             comment.pretty_print;
  112.             fmt.set_mode(fmt_mode);
  113.          end;
  114.       end;
  115.  
  116. invariant
  117.  
  118.    instruction /= Void;
  119.  
  120.    comment /= Void;
  121.  
  122. end -- INSTRUCTION_WITH_COMMENT
  123.  
  124.