home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / instruction.e < prev    next >
Text File  |  1999-06-05  |  4KB  |  142 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 INSTRUCTION
  17.    --
  18.    -- For all differents kinds of Eiffel instruction.
  19.    --
  20.  
  21. inherit GLOBALS;
  22.  
  23. feature
  24.  
  25.    start_position: POSITION is
  26.          -- Of the first character of the instruction.
  27.       deferred
  28.       ensure
  29.          Result /= Void
  30.       end;
  31.  
  32.    pretty_print is
  33.       require
  34.          fmt.indent_level >= 3;
  35.       deferred
  36.       ensure
  37.          fmt.indent_level = old fmt.indent_level;
  38.       end;
  39.  
  40.    use_current: BOOLEAN is
  41.       -- Does instruction use Current ?
  42.       require
  43.          small_eiffel.is_ready
  44.       deferred
  45.       end;
  46.  
  47.    to_runnable(ct: TYPE): like Current is
  48.          -- Gives a checked instruction runnable in `ct'.
  49.       require
  50.          ct.run_type = ct;
  51.          ct.run_class /= Void
  52.       deferred
  53.       ensure
  54.          nb_errors = 0 implies Result /= Void
  55.       end;
  56.  
  57.    end_mark_comment: BOOLEAN is
  58.          -- True for instructions with a possible end mark comment
  59.          -- like instruction "loop" "debug" or "check" for example.
  60.       deferred
  61.       end;
  62.  
  63.    afd_check is
  64.          -- After Falling Down Check.
  65.       deferred
  66.       end;
  67.  
  68.    collect_c_tmp is
  69.          -- Traverse the instruction to collect needed C tmp variables
  70.          -- just before `compile_to_c'.
  71.       require
  72.          small_eiffel.is_ready
  73.       deferred
  74.       end;
  75.  
  76.    compile_to_c is
  77.       require
  78.          small_eiffel.is_ready;
  79.          cpp.on_c
  80.       deferred
  81.       ensure
  82.          cpp.on_c
  83.       end;
  84.  
  85.    compile_to_jvm is
  86.       require
  87.          small_eiffel.is_ready
  88.       deferred
  89.       end;
  90.  
  91.    is_pre_computable: BOOLEAN is
  92.          -- Assume the current instruction is inside a once function.
  93.          -- Result is true when the instruction can be precomputed.
  94.       require
  95.          small_eiffel.is_ready
  96.       deferred
  97.       end;
  98.  
  99. feature {EIFFEL_PARSER}
  100.  
  101.    frozen add_comment(c: COMMENT): INSTRUCTION is
  102.          -- Attach `c' to the instruction.
  103.       require
  104.          eiffel_parser.is_running
  105.       do
  106.          if c = Void or else c.count = 0 then
  107.             Result := Current
  108.          elseif end_mark_comment then
  109.             if c.count = 1 then
  110.                Result := Current;
  111.             else
  112.                !INSTRUCTION_WITH_COMMENT!Result.make(Current,c);
  113.             end;
  114.          else
  115.             !INSTRUCTION_WITH_COMMENT!Result.make(Current,c);
  116.          end;
  117.       end;
  118.  
  119. feature {NONE}
  120.  
  121.    pretty_print_assignment(rhs: EXPRESSION; op: STRING; lhs: EXPRESSION) is
  122.       local
  123.          semi_colon_flag: BOOLEAN;
  124.       do
  125.          rhs.pretty_print;
  126.          fmt.put_character(' ');
  127.          fmt.put_string(op);
  128.          fmt.put_character(' ');
  129.          semi_colon_flag := fmt.semi_colon_flag;
  130.          fmt.level_incr;
  131.          fmt.set_semi_colon_flag(false);
  132.          lhs.pretty_print;
  133.          fmt.set_semi_colon_flag(semi_colon_flag);
  134.          if semi_colon_flag then
  135.             fmt.put_character(';');
  136.          end;
  137.          fmt.level_decr;
  138.       end;
  139.  
  140. end -- INSTRUCTION
  141.  
  142.