///////////////////////////////////////////////////////////////////////////////
//                             Lisaac Example                                //
//                                                                           //
//                   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      := SLOT;

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

  - author    := "Sonntag Benoit (sonntag@icps.u-strasbg.fr)";
  - comment   := "The slot";

Section Inherit

  - parent_instr:Expanded INSTR;

Section Public
  
  + name:STRING_CONSTANT;
  
  + local_list:HASHED_DICTIONARY(LOCAL,STRING_CONSTANT);
  
  + expr_list:LINKED_LIST(EXPR);
  
  // -- VFT --
  + index:INTEGER;
  
  - set_index idx:INTEGER <-
  (
    index := idx;
  );
  // -- VFT --
  
  //
  // Creation.
  //

  - create p:INTEGER name n:STRING_CONSTANT :SELF <-
  ( + result:SELF;
    result := clone;
    result.make p name n;
    result
  );

  - make p:INTEGER name n:STRING_CONSTANT <-
  ( 
    position  := p;
    name      := n;
    expr_list := LINKED_LIST(EXPR).create;
  );
  
  //
  // Added.
  // 
  
  - set_local_list d:HASHED_DICTIONARY(LOCAL,STRING_CONSTANT) <-
  (
    local_list := d;
  );
  
  - add_expr e:EXPR <-
  (
    expr_list.add_last e;
  );
  
  //
  // Access.
  //
  
  - get_local n:STRING_CONSTANT :LOCAL <-
  ( 
    local_list.fast_reference_at n    
  );
  
  //
  // Run.
  //
  
  - run t:CLASS <-
  ( + this:LOCAL;
    // Fix dynamic type for This.
    this := get_local keyword_this;
    this.set_the_dynamic_type t;
    // Execute instr.
    (expr_list.lower).to (expr_list.upper) do { i:INTEGER;
      expr_list.item i.run;
    };      
  );
  
  //
  // Display.
  //
  
  - print <-
  (
    "  ".print;
    name.print; 
    " = \n".print;
    "  ( ".print;
    (local_list.lower).to (local_list.upper-1) do { i:INTEGER;
      local_list.item i.print;
      ','.print;
    };
    local_list.last.print;
    " |\n".print;
    (expr_list.lower).to (expr_list.upper) do { i:INTEGER;
      "    ".print;
      expr_list.item i.print;
      ";\n".print;
    };
    "  )\n".print;
  );