home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / instruction.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  4.7 KB  |  206 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. deferred class INSTRUCTION
  17. --
  18. -- For all differents kinds of Eiffel instruction.
  19. --
  20.    
  21. inherit 
  22.    GLOBALS
  23.       redefine fill_tagged_out_memory 
  24.       end; 
  25.  
  26.    
  27. feature 
  28.  
  29.    fill_tagged_out_memory is
  30.       local
  31.      p: POSITION;
  32.      ct: TYPE;
  33.      rtm: STRING;
  34.       do
  35.      p := start_position;
  36.      if p /= Void then
  37.         p.fill_tagged_out_memory;
  38.      end;
  39.      if run_compound /= Void then
  40.         ct := run_compound.current_type;
  41.         if ct /= Void then
  42.            rtm := ct.run_time_mark;
  43.            if rtm /= Void then
  44.           tagged_out_memory.append(" ct=");
  45.           tagged_out_memory.append(rtm);
  46.            end;
  47.         end;
  48.      end;
  49.       end;
  50.  
  51.    run_compound: COMPOUND;
  52.      -- When not Void, the instruction is checked and belongs to
  53.      -- this compound
  54.       
  55.    start_position: POSITION is
  56.      -- Of the first character of the instruction.
  57.       deferred
  58.       ensure
  59.      Result /= Void
  60.       end;
  61.    
  62.    pretty_print is
  63.       require
  64.      fmt.indent_level >= 3;
  65.       deferred
  66.       ensure
  67.      fmt.indent_level = old fmt.indent_level;
  68.       end;
  69.    
  70.    use_current: BOOLEAN is 
  71.       -- Does instruction use Current ?
  72.       require
  73.      is_checked;
  74.      small_eiffel.is_ready;
  75.       deferred 
  76.       end;
  77.    
  78.    to_runnable(rc: like run_compound): like Current is
  79.       -- Gives a checked instruction runnable in `rc.current_type'.
  80.       require
  81.      rc /= Void;
  82.      rc.current_type /= Void;
  83.      rc.current_type.is_run_type
  84.       deferred
  85.       ensure
  86.      nb_errors = 0 implies Result /= Void;
  87.      Result /= Void implies Result.run_compound = rc;
  88.       end;
  89.    
  90.    is_checked: BOOLEAN is
  91.      -- Instruction is checked ?
  92.       do
  93.      Result := run_compound /= Void;
  94.       end;
  95.    
  96.    run_class: RUN_CLASS is
  97.       require
  98.      is_checked
  99.       do
  100.      Result := run_compound.run_class;
  101.       ensure
  102.      Result /= Void;
  103.       end;
  104.    
  105.    current_type: TYPE is
  106.       require
  107.      is_checked
  108.       do
  109.      if run_compound /= Void then
  110.         Result := run_compound.current_type;
  111.      end;
  112.       ensure
  113.      Result /= Void;
  114.       end;
  115.    
  116.    end_mark_comment: BOOLEAN is 
  117.      -- True for instructions with a possible end mark comment 
  118.      -- like instruction "loop" "debug" or "check" for example.
  119.       deferred
  120.       end;
  121.  
  122.    afd_check is
  123.      -- After Falling Down Check.
  124.       require
  125.      is_checked;
  126.       deferred
  127.       end;
  128.    
  129.    compile_to_c is
  130.       require
  131.      is_checked;
  132.      cpp.on_c
  133.       deferred
  134.       ensure     
  135.      cpp.on_c
  136.       end;
  137.  
  138.    compile_to_jvm is
  139.       require
  140.      is_checked
  141.       deferred
  142.       ensure     
  143.       end;
  144.    
  145.    is_pre_computable: BOOLEAN is
  146.      -- Assume the current instruction is inside a once function.
  147.      -- Result is true when the instruction can be precomputed.
  148.       require
  149.      is_checked;
  150.      small_eiffel.is_ready
  151.       deferred
  152.       end;
  153.  
  154. feature {EIFFEL_PARSER}
  155.    
  156.    add_comment(c: COMMENT): INSTRUCTION is
  157.      -- Attach `c' to the instruction.
  158.       require
  159.      eiffel_parser.is_running
  160.       do
  161.      if c = Void or else c.count = 0 then
  162.         Result := Current
  163.      elseif end_mark_comment then
  164.         if c.count = 1 then
  165.            Result := Current;
  166.         else
  167.            !INSTRUCTION_WITH_COMMENT!Result.make(Current,c);
  168.         end;
  169.      else
  170.         !INSTRUCTION_WITH_COMMENT!Result.make(Current,c);
  171.      end;
  172.       end;
  173.    
  174. feature {INSTRUCTION}
  175.    
  176.    set_run_compound(rc: like run_compound) is
  177.       do
  178.      run_compound := rc;
  179.       ensure     
  180.      run_compound = rc;
  181.       end;
  182.    
  183. feature {NONE}
  184.    
  185.    pretty_print_assignment(rhs: EXPRESSION; op: STRING; lhs: EXPRESSION) is
  186.       local
  187.      semi_colon_flag: BOOLEAN;
  188.       do
  189.      rhs.pretty_print;
  190.      fmt.put_character(' ');
  191.      fmt.put_string(op);
  192.      fmt.put_character(' ');
  193.      semi_colon_flag := fmt.semi_colon_flag;
  194.      fmt.level_incr;
  195.      fmt.set_semi_colon_flag(false);
  196.      lhs.pretty_print;
  197.      fmt.set_semi_colon_flag(semi_colon_flag);
  198.      if semi_colon_flag then
  199.         fmt.put_character(';');
  200.      end;
  201.      fmt.level_decr;
  202.       end;
  203.    
  204. end -- INSTRUCTION
  205.  
  206.