Code coverage for itm_write.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_WRITE;
- copyright := "2003-2007 Benoit Sonntag";
- author := "Sonntag Benoit (bsonntag@loria.fr)";
- comment := "Parent for all write";
Section Inherit
+ parent_itm_code:Expanded ITM_CODE;
Section Public
//
// Data
//
+ assign:ITM_CODE;
+ value:ITM_CODE;
- type:STRING_CONSTANT <-
(
deferred;
NULL
);
//
// Constructor
//
- create p:POSITION assign n:ITM_CODE with v:ITM_CODE :SELF <-
[ -? {p != 0}; ]
( + result:SELF;
result := clone;
result.make p assign n with v;
result
);
- make p:POSITION assign n:ITM_CODE with v:ITM_CODE <-
(
position := p;
assign := n;
value := v;
);
//
// Access.
//
- get_simple_name:STRING_CONSTANT <-
( + result:STRING_CONSTANT;
+ without_arg:ITM_READ;
without_arg ?= assign;
(without_arg != NULL).if {
result := without_arg.name;
} else {
semantic_error (position,"ITM_WRITE: Not yet implemented.");
};
result
);
//
// Display.
//
- append_in buffer:STRING <-
(
assign.append_in buffer;
buffer.append type;
value.append_in buffer;
);
Section Private
- affect name:STRING_CONSTANT with v:EXPR :EXPR <-
( + loc:LOCAL;
+ result:EXPR;
loc := lookup name;
(loc != NULL).if {
result := affect_local loc with v;
} else {
result := affect_slot name with v;
};
result
);
- affect_local loc:LOCAL with v:EXPR :EXPR <-
( + e:INSTR;
+ result:EXPR;
+ val:EXPR;
(loc.style = '-').if {
result := affect_slot (loc.intern_name) with v;
} else {
(loc.style = ' ').if {
POSITION.put_error semantic text "Argument assignment is not possible.";
loc.position.put_position;
position.put_position;
POSITION.send_error;
};
val := v.check_type (loc.type) with position;
e := loc.write position value val;
list_current.add_last e;
result := loc.read position;
};
result
);
- affect_slot name:STRING_CONSTANT with v:EXPR :EXPR <-
( + loc:VARIABLE;
+ slot:SLOT;
+ slot_dta:SLOT_DATA;
+ node:NODE;
+ result:EXPR;
+ rec:EXPR;
+ type:TYPE;
+ em:EXPR_MULTIPLE;
+ new_val:EXPR;
+ lst:FAST_ARRAY(EXPR);
loc := lookup (ALIAS_STR.variable_self);
rec := loc.read position;
//
type := rec.static_type.raw;
slot := type.get_slot name;
(slot = NULL).if {
string_tmp.copy "Slot `";
string_tmp.append name;
string_tmp.append "' not found in static type ";
type.append_name_in string_tmp;
string_tmp.add_last '.';
semantic_error (position,string_tmp);
};
// Control type.
em ?= v;
slot_dta := slot.slot_data;
(em != NULL).if {
lst := em.expr_list;
(lst.lower).to (lst.upper - 1) do { j:INTEGER;
new_val := (lst.item j).check_type (slot.slot_data_list.item j.type) with (slot.position);
lst.put new_val to j;
};
new_val := (lst.last).check_type (slot_dta.type) with (slot.position);
lst.put new_val to (lst.upper);
new_val := em;
} else {
new_val := v.check_type (slot_dta.type) with (slot.position);
};
//
node := NODE.new_write position slot slot receiver rec value new_val;
list_current.add_last node;
result := node.result_expr;
result
);