PageRenderTime 21ms CodeModel.GetById 16ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

/src/tools/semantics/types/impl/liberty_delayed_type.e

http://github.com/tybor/Liberty
Specman e | 129 lines | 95 code | 17 blank | 17 comment | 3 complexity | 7d4ce73a7bf498dfd4b367cf656b2847 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--
 15class LIBERTY_DELAYED_TYPE
 16   --
 17   -- A type to be resolved later.
 18   --
 19
 20inherit
 21   LIBERTY_TYPE
 22      redefine mark_reachable_code, is_equal
 23      end
 24
 25creation {ANY}
 26   make
 27
 28feature {ANY}
 29   known_type: LIBERTY_KNOWN_TYPE
 30
 31   is_known: BOOLEAN
 32
 33   full_name: FIXED_STRING is
 34      do
 35         if is_known then
 36            Result := known_type.full_name
 37         else
 38            Result := delayed_resolver.full_name
 39         end
 40      end
 41
 42   hash_code: INTEGER is
 43      do
 44         Result := delayed_resolver.hash_code
 45      end
 46
 47   is_equal (other: like Current): BOOLEAN is
 48      do
 49         Result := other = Current
 50      end
 51
 52   out_in_tagged_out_memory is
 53      do
 54         full_name.out_in_tagged_out_memory
 55      end
 56
 57   specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
 58      local
 59         dr: like delayed_resolver
 60      do
 61         dr := delayed_resolver.specialized_in(a_type)
 62         if dr = delayed_resolver then
 63            Result := Current
 64         else
 65            create Result.make(dr)
 66         end
 67      end
 68
 69feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
 70   mark_reachable_code (mark: like reachable_mark) is
 71      local
 72         old_mark: like reachable_mark
 73      do
 74         old_mark := reachable_mark
 75         Precursor(mark)
 76         if old_mark < mark and then is_known then
 77            known_type.mark_reachable_code(mark)
 78         end
 79      end
 80
 81feature {LIBERTY_KNOWN_TYPE}
 82   full_name_in (buffer: STRING) is
 83      do
 84         buffer.append(full_name)
 85      end
 86
 87feature {LIBERTY_UNIVERSE}
 88   can_resolve: BOOLEAN is
 89      require
 90         not is_known
 91      do
 92         Result := delayed_resolver.can_resolve
 93      end
 94
 95   resolve is
 96      require
 97         can_resolve
 98      do
 99         known_type := delayed_resolver.resolved
100         is_known := True
101         fire_type_known
102         torch.burn
103      ensure
104         is_known
105      end
106
107feature {}
108   make (a_delayed_resolver: like delayed_resolver) is
109      require
110         a_delayed_resolver /= Void
111      do
112         delayed_resolver := a_delayed_resolver
113         lookup.resolver.delayed_types.add_last(Current)
114         create {FAST_ARRAY[LIBERTY_TYPE_LISTENER]} listeners.with_capacity(2)
115         create result_entity.make(Current, errors.unknown_position)
116      ensure
117         delayed_resolver = a_delayed_resolver
118         not_yet_reachable: not is_reachable
119      end
120
121   delayed_resolver: LIBERTY_DELAYED_RESOLVER
122   lookup: LIBERTY_TYPE_LOOKUP
123   errors: LIBERTY_ERRORS
124
125invariant
126   delayed_resolver /= Void
127   result_entity /= Void
128
129end -- class LIBERTY_DELAYED_TYPE