{
  ex4.s

  Contents:

     1. a normal class A
     2. a reflective(shell) class B
     3. a reflective(shell) class D that inherits from B
     4. a shell class C whose allowed set contains A, B and D

  Tests:
     1. the use of shells with objects of classes of three categories:
         - normal
         - reflective(shell) without inheritance
         - reflective(shell) that inherits from a reflective(shell) class
     2. message sends to "object" in these three categories.

  }

class A
  private:
    var i :  integer;
  public:
   proc get() : integer
     begin
     write(100);
     return i;
     end
   proc put( NewI : integer )
     begin
     i = NewI;
     write(200);
     end
endclass


reflective(shell) class B 
  private:
    var i :  integer;
  public:
   proc get() : integer
     begin
     write(100);
     return i;
     end
   proc put( NewI : integer )
     begin
     i = NewI;
     write(200);
     end
endclass


reflective(shell) class D inherits B
  private:
    var k : integer;
  public:
    proc put( nk : integer )
      begin
      super.put(nk);
      self.k = nk;
      end
endclass


shell class C(A)  B  D
  private:
    var k : integer;
  public:
    proc put( newI : integer )
      begin
      object.put(newI);
      write(newI);
      k = 2*newI;
      write(k);
      end
endclass



class Program
  public:
    proc run()
        var a : A;
            b : B;
            d : D;
      begin
      a = A.new();
      a.put(4);
      if Reflect.attachShell(a, C.new()) == 0
      then
        a.put(5);
        if Reflect.removeShell(a) == 0
        then
          a.put(5);
        endif
      endif
      b = B.new();
      b.put(1);
      if Reflect.attachShell(b, C.new()) == 0
      then
        b.put(2);
        if Reflect.removeShell(b) == 0
        then
          b.put(3);
        endif
      endif
      d = D.new();
      d.put(1);
      if Reflect.attachShell(d, C.new()) == 0
      then
        d.put(2);
        if Reflect.removeShell(d) == 0
        then
          d.put(3);
        endif
      endif
      end
endclass


