/src/tools/semantics/types/type_builder/liberty_type_builder_tools.e

http://github.com/tybor/Liberty · Specman e · 67 lines · 55 code · 11 blank · 1 comment · 2 complexity · d383688c8d417bd86e5b1d4216ab9947 MD5 · raw file

  1. expanded class LIBERTY_TYPE_BUILDER_TOOLS
  2. insert
  3. LIBERTY_BUILDER_TOOLS
  4. feature {} -- Client list
  5. list_clients (clients: LIBERTY_AST_CLIENTS): COLLECTION[LIBERTY_TYPE] is
  6. local
  7. i: INTEGER
  8. do
  9. if clients.is_empty then
  10. --|*** TODO: add warning (client list should always be set)
  11. Result := any_client_list
  12. elseif clients.list_is_empty then
  13. Result := empty_client_list
  14. else
  15. create {FAST_ARRAY[LIBERTY_TYPE]} Result.with_capacity(clients.list_count)
  16. from
  17. i := clients.list_lower
  18. until
  19. errors.has_error or else i > clients.list_upper
  20. loop
  21. Result.add_last(type_lookup.resolver.export_type(clients.list_item(i).type_definition))
  22. i := i + 1
  23. end
  24. end
  25. end
  26. empty_client_list: COLLECTION[LIBERTY_TYPE] is
  27. once
  28. create {FAST_ARRAY[LIBERTY_TYPE]} Result.with_capacity(0)
  29. end
  30. any_client_list: COLLECTION[LIBERTY_TYPE] is
  31. once
  32. Result := {FAST_ARRAY[LIBERTY_TYPE] << universe.type_any >> }
  33. end
  34. feature {}
  35. builder: LIBERTY_TYPE_BUILDER
  36. type: LIBERTY_ACTUAL_TYPE
  37. ast: LIBERTY_AST_NON_TERMINAL_NODE is
  38. do
  39. Result := type.ast
  40. end
  41. file: FIXED_STRING is
  42. do
  43. Result := type.file
  44. end
  45. is_any: BOOLEAN is
  46. do
  47. Result := type.name = any_type_name
  48. end
  49. any_type_name: FIXED_STRING is
  50. once
  51. Result := "ANY".intern
  52. end
  53. invariant
  54. builder /= Void
  55. type /= Void
  56. end -- class LIBERTY_TYPE_BUILDER_TOOLS