PageRenderTime 14ms CodeModel.GetById 9ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

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