PageRenderTime 20ms CodeModel.GetById 13ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

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