/src/tools/semantics/types/conformance_checker/liberty_agent_conformance_checker.e
Specman e | 84 lines | 61 code | 8 blank | 15 comment | 4 complexity | 3e1c6ad89b61133329072b9c246a96a2 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_AGENT_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 not parent.parameters.is_empty 48 not child.parameters.is_empty 49 end 50 Result := parent.parameters.count = child.parameters.count 51 if Result then 52 check 53 -- parent.parameters.first and child.parameters.first both are tuples 54 end 55 if conformance then 56 Result := parent.parameters.first.known_type.is_conform_to(child.parameters.first.known_type) 57 else 58 Result := parent.parameters.first.known_type.is_non_conformant_child_of(child.parameters.first.known_type) 59 end 60 from 61 i := parent.parameters.lower + 1 62 until 63 not Result or else i > parent.parameters.upper 64 loop 65 check 66 parent.parameters.item(i).is_known 67 child.parameters.item(i).is_known 68 end 69 if conformance then 70 Result := child.parameters.item(i).known_type.is_conform_to(parent.parameters.item(i).known_type) 71 else 72 Result := child.parameters.item(i).known_type.is_non_conformant_child_of(parent.parameters.item(i).known_type) 73 end 74 i := i + 1 75 end 76 end 77 end 78 79feature {} 80 make is 81 do 82 end 83 84end -- class LIBERTY_AGENT_CONFORMANCE_CHECKER