PageRenderTime 21ms CodeModel.GetById 15ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/src/tools/semantics/code/expressions/liberty_entity_reference.e

http://github.com/tybor/Liberty
Specman e | 76 lines | 51 code | 9 blank | 16 comment | 1 complexity | 34ed95e116e4af9e30b1e65acdcc45f2 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_ENTITY_REFERENCE
16   -- expressions like "$entity"
17
18inherit
19   LIBERTY_EXPRESSION
20
21create {LIBERTY_BUILDER_TOOLS, LIBERTY_ENTITY_REFERENCE}
22   make
23
24feature {ANY}
25   entity: LIBERTY_ENTITY
26   result_type: LIBERTY_TYPE
27
28   specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
29      local
30         e: like entity
31      do
32         check result_type.specialized_in(a_type) = result_type end
33         e := entity.specialized_in(a_type)
34         if e = entity then
35            Result := Current
36         else
37            create Result.make(result_type, e, position)
38         end
39      end
40
41feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
42   mark_reachable_code (mark: INTEGER) is
43      do
44         -- nothing
45      end
46
47feature {}
48   make (type: like result_type; a_entity: like entity; a_position: like position) is
49      require
50         type /= Void -- type is POINTER
51         a_entity /= Void
52         a_position /= Void
53      do
54         result_type := type
55         entity := a_entity
56         position := a_position
57      ensure
58         result_type = type
59         entity = a_entity
60         position = a_position
61      end
62
63feature {ANY}
64   accept (v: VISITOR) is
65      local
66         v0: LIBERTY_ENTITY_REFERENCE_VISITOR
67      do
68         v0 ::= v
69         v0.visit_liberty_entity_reference(Current)
70      end
71
72invariant
73   result_type /= Void -- result_type is POINTER
74   entity /= Void
75
76end