Code coverage for read_slot.li


///////////////////////////////////////////////////////////////////////////////
//                             Lisaac Compiler                               //
//                                                                           //
//                   LSIIT - ULP - CNRS - INRIA - FRANCE                     //
//                                                                           //
//   This program is free software: you can redistribute it and/or modify    //
//   it under the terms of the GNU General Public License as published by    //
//   the Free Software Foundation, either version 3 of the License, or       //
//   (at your option) any later version.                                     //
//                                                                           //
//   This program is distributed in the hope that it will be useful,         //
//   but WITHOUT ANY WARRANTY; without even the implied warranty of          //
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           //
//   GNU General Public License for more details.                            //
//                                                                           //
//   You should have received a copy of the GNU General Public License       //
//   along with this program.  If not, see <http://www.gnu.org/licenses/>.   //
//                                                                           //
//                     http://isaacproject.u-strasbg.fr/                     //
///////////////////////////////////////////////////////////////////////////////
Section Header

  + name    := READ_SLOT;

  - copyright   := "2003-2007 Benoit Sonntag";


  - author  := "Sonntag Benoit (bsonntag@loria.fr)";
  - comment := "Read for slot";

Section Inherit

  + parent_read:Expanded READ;

Section Public

  - is_slot:BOOLEAN <- TRUE;

  - is_invariant:BOOLEAN <- slot.is_invariant receiver;

  + slot:SLOT_DATA;

  + receiver:EXPR;

  - variable:VARIABLE <- slot;

  - get_last_value:EXPR <- variable.get_last_value receiver;

  //
  // Comparison.
  //

  - Self:SELF '~=' Right 60 other:EXPR :BOOLEAN <-
  ( + rd:READ_SLOT;

    rd ?= other;
    ((rd != NULL) && {slot = rd.slot} && {receiver ~= rd.receiver})
  )
;

Section SLOT

  //
  // Creation.
  //

  - create p:POSITION with (r:EXPR,s:SLOT_DATA) :SELF <-
  ( + result:SELF;

    result := clone;
    result.make p with (r,s);
    result
  )
;

  - make p:POSITION with (r:EXPR,s:SLOT_DATA) <-
  (
    position := p;
    receiver := r;
    slot     := s;
  )
;

Section Public

  - my_copy:SELF <-
  ( + result:SELF;

    result ?= slot.read position with (receiver.my_copy);
    result
  )
;

  //
  // Executing pass.
  //

  - remove <-
  (
    receiver.remove;
    parent_read.remove;
  )
;

  - execute_access_unlink:INSTR <-
  (
    slot.execute;
    receiver.execute_unlink
  )
;

  - execute_access_link <-
  (
    slot.execute;
    receiver := receiver.execute_link;
  )
;

  //
  // Genere
  //

  - genere buffer:STRING <-
  ( + tf,tf2:TYPE_FULL;
    + t:TYPE;
    + add_end:BOOLEAN;
    + ptr,ptr2:BOOLEAN;

    (is_java).if {
      receiver.genere buffer;
      //not_yet_implemented;
      buffer.add_last '.';
      buffer.append (variable.intern_name);
    }
 else {
      (slot.intern_name = ALIAS_STR.slot_self).if {
        buffer.append "((";
        tf := slot.type;
        tf.genere_declaration buffer;
        buffer.add_last ' ';
        tf.genere_star_declaration buffer;
        buffer.add_last ')';
        receiver.genere buffer;
        buffer.append ".self)";
      }
 else {
        tf := receiver.static_type;
        t  := slot.receiver_type;
        (t.alias_slot != NULL).if {
          tf2 := slot.type;
          ptr  := (! tf .is_expanded) || {tf .is_expanded_ref} || {tf .is_strict};
          ptr2 := (! tf2.is_expanded) || {tf2.is_expanded_ref} || {tf2.is_strict};
          (ptr != ptr2).if {
            add_end := TRUE;
            (ptr).if {
              buffer.append "(*(";
            }
 else {
              buffer.append "(&(";
            }
;
          }
;
        }
;
        (
          (tf.is_strict) || {tf.is_expanded_ref} || {tf.is_expanded}
        )
.if {
          receiver.genere buffer;
        }
 else {
          buffer.append "((";
          t.put_reference_declaration buffer;
          buffer.add_last ' ';
          t.put_reference_star_declaration buffer;
          buffer.add_last ')';
          receiver.genere buffer;
          buffer.add_last ')';
        }
;
        (t.alias_slot = NULL).if {
          ((tf.is_expanded) && {! tf.is_expanded_ref} && {! tf.is_strict}).if {
            buffer.add_last '.';
          }
 else {
            buffer.append "->";
          }
;
          buffer.append (variable.intern_name);
        }
.elseif {add_end} then {
          buffer.append "))";
        }
;
      }
;
    }
;
  )
;

  //
  // Display.
  //

  - display buffer:STRING <-
  (
    receiver.display buffer;
    buffer.append "->";
    parent_read.display buffer;
  )
;