home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / SmallEiffel 0.3.3 / SmallEiffel PPC / lib_std / boolean.e < prev    next >
Encoding:
Text File  |  1996-06-13  |  1.8 KB  |  95 lines  |  [TEXT/EDIT]

  1. -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C) 
  2. -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
  3. --
  4. expanded class BOOLEAN
  5. --
  6. -- Note : corresponding C type is "int"
  7. --
  8. inherit
  9.    BOOLEAN_REF
  10.       redefine
  11.      infix "and", infix "and then", infix "or",
  12.      infix "or else", infix "implies", infix "xor",
  13.      prefix "not", to_string, to_integer, fill_tagged_out_memory
  14.       end;
  15.  
  16. feature {ANY}
  17.  
  18.    infix "and" (other: BOOLEAN): BOOLEAN is
  19.      -- `and' of Current with `other'.
  20.       do
  21.      Result := Current and then other;
  22.       end;
  23.  
  24.    infix "and then" (other: BOOLEAN): BOOLEAN is
  25.      -- Semi-strict `and' of Current with `other'.
  26.       external "CSE"
  27.       end;
  28.  
  29.    infix "implies"(other: BOOLEAN): BOOLEAN is
  30.      -- Does Current imply `other'.
  31.       external "CSE"
  32.       end;
  33.  
  34.    infix "or" (other: BOOLEAN): BOOLEAN is
  35.      -- `or' of Current with `other'
  36.       do
  37.      Result := Current or else other;
  38.       end;
  39.  
  40.    infix "or else" (other: BOOLEAN): BOOLEAN is
  41.      -- Semi-strict `or' of Current with `other'
  42.       external "CSE"
  43.       end;
  44.  
  45.    infix "xor" (other: BOOLEAN): BOOLEAN is
  46.      -- `xor' of Current with `other'
  47.       do
  48.      if Current then
  49.         Result := not other;
  50.      else
  51.         Result := other;
  52.      end;
  53.       end;
  54.  
  55.    prefix "not": BOOLEAN is
  56.      -- `not' of Current.
  57.       do
  58.      if Current then
  59.      else
  60.         Result := true;
  61.      end;
  62.       end;
  63.  
  64.    to_string: STRING is
  65.       do
  66.          if Current then
  67.             Result := "true";
  68.          else
  69.             Result := "false";
  70.          end;
  71.       end;
  72.  
  73.    to_integer: INTEGER is
  74.       do
  75.      if Current then
  76.         Result := 1;
  77.      else
  78.         Result := 0;
  79.      end;
  80.       end;
  81.  
  82.    append_in(str: STRING) is
  83.       do
  84.      str.append(to_string);
  85.       end;
  86.  
  87. feature -- Object Printing :
  88.  
  89.    fill_tagged_out_memory is
  90.       do
  91.      tagged_out_memory.append(to_string);
  92.       end;
  93.  
  94. end -- BOOLEAN
  95.