home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / when_item_1.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  2.9 KB  |  111 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 WHEN_ITEM_1
  17. --
  18. -- To store a single value of a when clause in an inspect instruction.
  19. --
  20. -- Exemple :
  21. --          inspect ...
  22. --              when foo, bar, then ...
  23. -- 
  24.  
  25. inherit WHEN_ITEM; 
  26.          
  27. creation {E_WHEN,WHEN_ITEM_1}
  28.    make
  29.    
  30. feature {ANY}
  31.    
  32.    expression: EXPRESSION;
  33.    
  34.    expression_value: INTEGER;
  35.    
  36. feature {NONE}
  37.    
  38.    make(v: like expression) is
  39.       require
  40.      v /= Void
  41.       do
  42.      expression := v;
  43.       ensure     
  44.      expression = v
  45.       end;
  46.    
  47. feature {ANY}
  48.    
  49.    start_position: POSITION is
  50.       do
  51.      Result := expression.start_position;
  52.       end;
  53.    
  54. feature {E_WHEN, WHEN_ITEM_1}
  55.    
  56.    to_runnable_integer(ew: like e_when): like Current is
  57.       local
  58.      e: like expression;
  59.       do
  60.      if e_when = Void then
  61.         e_when := ew;
  62.         e := expression.to_runnable(current_type);
  63.         if e /= Void and then e.result_type.is_integer then
  64.            expression := e;
  65.            expression_value := expression.to_integer;
  66.            e_when.add_when_item_1(Current);
  67.         else
  68.            error(expression.start_position,fz_biv);
  69.         end;
  70.         Result := Current;
  71.      else
  72.         !!Result.make(expression);
  73.         Result := Result.to_runnable_integer(ew);
  74.      end;
  75.       end;
  76.    
  77.    to_runnable_character(ew: like e_when): like Current is
  78.       local
  79.      e: like expression;
  80.       do
  81.      if e_when = Void then
  82.         e_when := ew;
  83.         e := expression.to_runnable(current_type);
  84.         if e /= Void and then e.result_type.is_character then
  85.            expression := e;
  86.            expression_value := expression.to_integer;
  87.            e_when.add_when_item_1(Current);
  88.         else
  89.            error(expression.start_position,fz_bcv);
  90.         end;
  91.         Result := Current;
  92.      else
  93.         !!Result.make(expression);
  94.         Result := Result.to_runnable_character(ew);
  95.      end;
  96.       end;
  97.    
  98.    pretty_print is
  99.       do
  100.      expression.pretty_print;
  101.       end;
  102.  
  103. feature {E_WHEN}
  104.  
  105.    eval(exp: INTEGER): BOOLEAN is
  106.       do
  107.      Result := expression_value = exp;
  108.       end;
  109.  
  110. end -- WHEN_ITEM_1
  111.