PageRenderTime 11ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

/src/tools/semantics/liberty_type.e

http://github.com/tybor/Liberty
Specman e | 136 lines | 103 code | 16 blank | 17 comment | 3 complexity | a013bad8dc0398dfb13a4950a40a8add 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_TYPE
 16   --
 17   -- The type referenced in entity definitions
 18   --
 19
 20inherit
 21   HASHABLE
 22      undefine out_in_tagged_out_memory
 23      end
 24   LOGGING
 25      undefine out_in_tagged_out_memory
 26      end
 27
 28insert
 29   LIBERTY_REACHABLE_MARKED
 30      undefine out_in_tagged_out_memory, is_equal
 31      end
 32
 33feature {ANY}
 34   known_type: LIBERTY_KNOWN_TYPE is
 35      require
 36         is_known
 37      deferred
 38      end
 39
 40   result_entity: LIBERTY_RESULT
 41
 42   is_known: BOOLEAN is
 43      deferred
 44      end
 45
 46   full_name: FIXED_STRING is
 47      deferred
 48      ensure
 49         Result /= Void
 50      end
 51
 52   specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
 53      deferred
 54      ensure
 55         Result /= Void
 56      end
 57
 58feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
 59   mark_reachable_code (mark: like reachable_mark) is
 60      do
 61         if not is_reachable then
 62            torch.burn
 63            log.trace.put_string(once "Marked reachable the type: ")
 64            log.trace.put_line(full_name)
 65         end
 66         reachable_mark := mark
 67      end
 68
 69feature {LIBERTY_KNOWN_TYPE}
 70   full_name_in (buffer: STRING) is
 71      require
 72         buffer /= Void
 73      deferred
 74      end
 75
 76feature {LIBERTY_TYPE_LISTENER}
 77   add_listener (a_listener: LIBERTY_TYPE_LISTENER) is
 78      require
 79         a_listener /= Void
 80         not has_listener(a_listener)
 81      do
 82         if is_known then
 83            known_type.add_listener(a_listener)
 84         else
 85            listeners.add_last(a_listener)
 86         end
 87      ensure
 88         not is_known implies has_listener(a_listener)
 89      end
 90
 91   remove_listener (a_listener: LIBERTY_TYPE_LISTENER) is
 92      require
 93         a_listener /= Void
 94         has_listener(a_listener)
 95      do
 96         listeners.remove(listeners.fast_first_index_of(a_listener))
 97      ensure
 98         not has_listener(a_listener)
 99      end
100
101   has_listener (a_listener: LIBERTY_TYPE_LISTENER): BOOLEAN is
102      require
103         a_listener /= Void
104      do
105         Result := listeners /= Void and then listeners.fast_has(a_listener)
106      end
107
108feature {}
109   fire_type_known is
110      local
111         i: INTEGER
112         listener: LIBERTY_TYPE_LISTENER
113      do
114         from
115            i := listeners.lower
116         until
117            i > listeners.upper
118         loop
119            listener := listeners.item(i)
120            listener.on_type_known(Current)
121            if not known_type.has_listener(listener) then
122               known_type.add_listener(listener)
123            end
124            i := i + 1
125         end
126         listeners := Void
127      end
128
129feature {}
130   listeners: COLLECTION[LIBERTY_TYPE_LISTENER]
131   torch: LIBERTY_ENLIGHTENING_THE_WORLD
132
133invariant
134   not is_known implies listeners /= Void
135
136end