///////////////////////////////////////////////////////////////////////////////
//                             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        := DTA_RD_ARGS;

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

  
  - author      := "Sonntag Benoit (bsonntag@loria.fr)";
  - comment     := "Read site with arguments";
    
Section Inherit
  
  + parent_dta:Expanded DTA;
  
Section Public
  
  - self_arg:EXPR <- argument_list.first;
  
  // Add.
  
  + argument_list:FAST_ARRAY[EXPR];
  
  + copy_argument:BOOLEAN;
  
  //
  // Creation.
  //
  
  - create p:POSITION call sl:SLOT with args:FAST_ARRAY[EXPR] :SELF <-
  ( + result:SELF;
    
    result := clone;
    result.make p call sl with args;
    result
  );
  
  - make p:POSITION call sl:SLOT with args:FAST_ARRAY[EXPR] <-
  (
    position := p;    
    context := profil_second;    
    slot          := sl;
    argument_list := args;
    result_expr   := slot.get_expr_result;
  );
  
  //
  // Display.
  //
  
  - display buffer:STRING <- 
  (
    buffer.append "DTA_RD_ARGS:";
    buffer.append (slot.name);
  );
  
  //
  // Service
  //

  - remove <-
  (
    (! copy_argument).if {
      (argument_list.lower).to (argument_list.upper) do { j:INTEGER;
	argument_list.item j.remove;
      };
      copy_argument := TRUE;
    };
  );
    
Section NODE_STYLE, SELF  
  
  - get_argument:FAST_ARRAY[EXPR] <-  
  ( + result:FAST_ARRAY[EXPR];
    
    (copy_argument).if {
      result := FAST_ARRAY[EXPR].create_with_capacity (argument_list.count);            
      (argument_list.lower).to (argument_list.upper) do { j:INTEGER;		
	result.add_last (argument_list.item j.my_copy);
      };            
    } else {
      result := argument_list;
      copy_argument := TRUE;
    };
    result
  );
  
