home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / instruction_with_comment.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  2.9 KB  |  130 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://www.loria.fr/SmallEiffel
  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 
  22.    INSTRUCTION 
  23.       redefine add_comment, is_pre_computable
  24.       end;
  25.    
  26. creation make
  27.    
  28. feature 
  29.    
  30.    instruction : INSTRUCTION;
  31.    
  32.    comment : COMMENT;
  33.    
  34. feature 
  35.    
  36.    make(i: like instruction; c: like comment) is
  37.       require
  38.      i /= void;
  39.      really_a_comment: c.count > 0;
  40.       do
  41.      instruction := i;
  42.      comment := c;
  43.       end;
  44.    
  45. feature
  46.    
  47.    end_mark_comment: BOOLEAN is false;
  48.  
  49. feature
  50.  
  51.    use_current: BOOLEAN is
  52.       do
  53.      Result := instruction.use_current;
  54.       end;        
  55.  
  56.    add_comment(c: COMMENT): like Current is
  57.       do
  58.       end;
  59.    
  60.    afd_check is   
  61.       do
  62.      instruction.afd_check;
  63.       end;
  64.    
  65.    compile_to_c is   
  66.       do
  67.      instruction.compile_to_c;
  68.       end;
  69.    
  70.    compile_to_jvm is
  71.       do
  72.      instruction.compile_to_jvm;
  73.       end;
  74.    
  75.    is_pre_computable: BOOLEAN is   
  76.       do
  77.      Result := instruction.is_pre_computable;
  78.       end;
  79.    
  80.    start_position: POSITION is
  81.       do
  82.      Result := instruction.start_position;
  83.       end;
  84.    
  85.    to_runnable(rc: like run_compound): like Current is
  86.       local
  87.      ri: like instruction;
  88.       do
  89.      if run_compound = Void then
  90.         run_compound := rc;
  91.         ri := instruction.to_runnable(rc);
  92.         if ri = Void then
  93.            error(instruction.start_position,"Bad instruction.");
  94.         else
  95.            instruction := ri;
  96.            Result := Current;
  97.         end;
  98.      else
  99.         !!Result.make(instruction,comment);
  100.         Result := Result.to_runnable(rc);
  101.      end;
  102.       end;
  103.    
  104.    pretty_print is
  105.       local
  106.      fmt_mode: INTEGER;
  107.       do
  108.      if comment.dummy then
  109.         instruction.pretty_print;
  110.      else
  111.         fmt_mode := fmt.mode;
  112.         fmt.set_zen;
  113.         instruction.pretty_print;
  114.         fmt.level_incr;
  115.         fmt.indent;
  116.         fmt.level_decr;
  117.         comment.pretty_print;
  118.         fmt.set_mode(fmt_mode);
  119.      end;
  120.       end;
  121.  
  122. invariant
  123.    
  124.    instruction /= Void;
  125.    
  126.    comment /= Void;
  127.    
  128. end -- INSTRUCTION_WITH_COMMENT
  129.  
  130.