/src/tools/semantics/types/conformance_checker/liberty_tuple_conformance_checker.e

http://github.com/tybor/Liberty · 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. --
  15. class LIBERTY_TUPLE_CONFORMANCE_CHECKER
  16. inherit
  17. LIBERTY_GENERICS_CONFORMANCE_CHECKER
  18. undefine
  19. is_equal
  20. end
  21. insert
  22. SINGLETON
  23. creation {LIBERTY_UNIVERSE}
  24. make
  25. feature {LIBERTY_ACTUAL_TYPE}
  26. inherits (parent, child: LIBERTY_KNOWN_TYPE): BOOLEAN is
  27. do
  28. Result := check_inheritance(parent, child, True)
  29. end
  30. inserts (parent, child: LIBERTY_KNOWN_TYPE): BOOLEAN is
  31. do
  32. Result := check_inheritance(parent, child, False)
  33. end
  34. feature {}
  35. check_inheritance (parent, child: LIBERTY_KNOWN_TYPE; conformance: BOOLEAN): BOOLEAN is
  36. local
  37. i: INTEGER
  38. do
  39. check
  40. parent.parameters.lower = child.parameters.lower
  41. end
  42. from
  43. Result := parent.parameters.count <= child.parameters.count
  44. i := parent.parameters.lower
  45. until
  46. not Result or else i > parent.parameters.upper
  47. loop
  48. check
  49. parent.parameters.item(i).is_known
  50. child.parameters.item(i).is_known
  51. end
  52. if conformance then
  53. Result := child.parameters.item(i).known_type.is_conform_to(parent.parameters.item(i).known_type)
  54. else
  55. Result := child.parameters.item(i).known_type.is_non_conformant_child_of(parent.parameters.item(i).known_type)
  56. end
  57. i := i + 1
  58. end
  59. end
  60. feature {}
  61. make is
  62. do
  63. end
  64. end -- class LIBERTY_TUPLE_CONFORMANCE_CHECKER