1 ///////////////////////////////////////////////////////////////////////////////
4 // LSIIT - ULP - CNRS - INRIA - FRANCE //
6 // This program is free software: you can redistribute it and/or modify //
7 // it under the terms of the GNU General Public License as published by //
8 // the Free Software Foundation, either version 3 of the License, or //
9 // (at your option) any later version. //
11 // This program is distributed in the hope that it will be useful, //
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
14 // GNU General Public License for more details. //
16 // You should have received a copy of the GNU General Public License //
17 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
19 // http://isaacproject.u-strasbg.fr/ //
20 ///////////////////////////////////////////////////////////////////////////////
23 + name := EXPR_SHIFT_R;
25 - copyright := "2003-2007 Benoit Sonntag";
28 - author := "Sonntag Benoit (bsonntag@loria.fr)";
29 - comment := "Add Binary Expression.";
33 + parent_expr_binary:Expanded EXPR_BINARY;
37 + symbol:STRING_CONSTANT := ">>";
43 - exec_conservator_right right_cst:INTEGER_CST :EXPR <-
47 (right_cst.value = 0).if {
54 - exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <-
56 //-- C1 >> -C2 -> Error.
58 (right_cst.value < 0).if {
59 warning_error (position,"Right shift count is negative.");
62 left_cst.set_value (left_cst.value >> right_cst.value);
69 //-- E(unsigned) >> E(unsigned) -> 0
72 (left == right) && {left.is_unsigned_type}.if {
73 result := INTEGER_CST.create position value 0 type static_type;
81 - exec_left left_cst:INTEGER_CST :EXPR <-
83 //-- -1(signed) >> E -> -1(signed)
86 (left_cst.value = 0).if {
89 }.elseif {left_cst.value = -1} then {
96 - exec_right right_cst:INTEGER_CST :EXPR <-
97 //-- E >> -C2 -> Error.
100 (right_cst.value < 0).if {
101 warning_error (position,"Right shift count is negative.");
102 right_cst.set_value 0;
103 right_cst.cast_type static_type;