Code coverage for itm_result.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        := ITM_RESULT;

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


  - author      := "Sonntag Benoit (bsonntag@loria.fr)";
  - comment     := "Result value";

Section Inherit

  - parent_itm_code:ITM_CODE := ITM_CODE;

Section Public

  - is_affect:POSITION <- value.is_affect;

  - position:POSITION <- value.position;

  //
  // Data
  //

  + value:ITM_CODE;

  //
  // Constructor
  //

  - create r:ITM_CODE :SELF <-
  [
    -? {r != NULL};
    -? {r.position.code != 0};
  ]

  ( + result:SELF;

    result := clone;
    result.make r;
    result
  )
;

  - make r:ITM_CODE <-
  (
    value    := r;
  )
;

  //
  // Runnable
  //

  - to_run:INSTR <-
  ( + mul:EXPR_MULTIPLE;
    + val:EXPR;
    + result:INSTR;

    val := value.to_run_expr;
    mul ?= val;
    (mul != NULL).if {
      (mul.lower).to (mul.upper-1) do { j:INTEGER;
        result := to_run_intern (mul.item j);
        list_current.add_last result;
      }
;
      result := to_run_intern (mul.last);
    }
 else {
      result := to_run_intern val;
    }
;
    result
  )
;

  - to_run_expr:EXPR <-
  (
    crash;
    NULL
  )
;

  //
  // Display.
  //

  - append_in buffer:STRING <-
  (
    buffer.append "return(";
    value.append_in buffer;
    buffer.add_last ')';
  )
;

Section Private

  - to_run_intern val:EXPR :INSTR <-
  ( + var:LOCAL;

    var := val.static_type.get_temporary position;
    ITM_LIST.stack_result.add_last var;
    var.write position value val
  )
;