/src/tools/semantics/types/conformance_checker/liberty_tuple_conformance_checker.e
Specman e | 72 lines | 50 code | 8 blank | 14 comment | 2 complexity | 9e3a88731fecb618b9c564808307b070 MD5 | raw file
1-- This file is part of Liberty Eiffel. 2-- 3-- Liberty Eiffel is free software: you can redistribute it and/or modify 4-- it under the terms of the GNU General Public License as published by 5-- the Free Software Foundation, version 3 of the License. 6-- 7-- Liberty Eiffel is distributed in the hope that it will be useful, 8-- but WITHOUT ANY WARRANTY; without even the implied warranty of 9-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10-- GNU General Public License for more details. 11-- 12-- You should have received a copy of the GNU General Public License 13-- along with Liberty Eiffel. If not, see <http://www.gnu.org/licenses/>. 14-- 15class LIBERTY_TUPLE_CONFORMANCE_CHECKER 16 17inherit 18 LIBERTY_GENERICS_CONFORMANCE_CHECKER 19 undefine 20 is_equal 21 end 22 23insert 24 SINGLETON 25 26creation {LIBERTY_UNIVERSE} 27 make 28 29feature {LIBERTY_ACTUAL_TYPE} 30 inherits (parent, child: LIBERTY_KNOWN_TYPE): BOOLEAN is 31 do 32 Result := check_inheritance(parent, child, True) 33 end 34 35 inserts (parent, child: LIBERTY_KNOWN_TYPE): BOOLEAN is 36 do 37 Result := check_inheritance(parent, child, False) 38 end 39 40feature {} 41 check_inheritance (parent, child: LIBERTY_KNOWN_TYPE; conformance: BOOLEAN): BOOLEAN is 42 local 43 i: INTEGER 44 do 45 check 46 parent.parameters.lower = child.parameters.lower 47 end 48 from 49 Result := parent.parameters.count <= child.parameters.count 50 i := parent.parameters.lower 51 until 52 not Result or else i > parent.parameters.upper 53 loop 54 check 55 parent.parameters.item(i).is_known 56 child.parameters.item(i).is_known 57 end 58 if conformance then 59 Result := child.parameters.item(i).known_type.is_conform_to(parent.parameters.item(i).known_type) 60 else 61 Result := child.parameters.item(i).known_type.is_non_conformant_child_of(parent.parameters.item(i).known_type) 62 end 63 i := i + 1 64 end 65 end 66 67feature {} 68 make is 69 do 70 end 71 72end -- class LIBERTY_TUPLE_CONFORMANCE_CHECKER