/src/tools/semantics/liberty_tagged.e

http://github.com/tybor/Liberty · Specman e · 60 lines · 39 code · 7 blank · 14 comment · 2 complexity · fff5cca764f9b7f4c194cb62a6819238 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. deferred class LIBERTY_TAGGED
  16. feature {LIBERTY_TAG_REF}
  17. add_tag (a_tag: LIBERTY_TAG) is
  18. require
  19. not tag_set(a_tag.id)
  20. do
  21. tags.add(a_tag, a_tag.id)
  22. ensure
  23. tag_set(a_tag.id)
  24. end
  25. set_tag (a_tag: LIBERTY_TAG) is
  26. do
  27. tags.put(a_tag, a_tag.id)
  28. ensure
  29. tag_set(a_tag.id)
  30. end
  31. tag_set (tag_id: FIXED_STRING): BOOLEAN is
  32. do
  33. if tags_memory /= Void then
  34. Result := tags_memory.fast_has(tag_id)
  35. end
  36. end
  37. tag (tag_id: FIXED_STRING): LIBERTY_TAG is
  38. require
  39. tag_set(tag_id)
  40. do
  41. Result := tags_memory.fast_reference_at(tag_id)
  42. end
  43. feature {}
  44. tags_memory: DICTIONARY[LIBERTY_TAG, FIXED_STRING]
  45. tags: like tags_memory is
  46. do
  47. Result := tags_memory
  48. if Result = Void then
  49. create {HASHED_DICTIONARY[LIBERTY_TAG, FIXED_STRING]} Result.with_capacity(3)
  50. tags_memory := Result
  51. end
  52. end
  53. end