PageRenderTime 40ms CodeModel.GetById 33ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/src/tools/semantics/code/instructions/liberty_inspect_slice.e

http://github.com/tybor/Liberty
Specman e | 91 lines | 68 code | 9 blank | 14 comment | 5 complexity | 1e266aafcdd0898c26655e68c9c4d9a6 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_INSPECT_SLICE
16
17insert
18   LIBERTY_POSITIONABLE
19   LIBERTY_REACHABLE
20
21create {LIBERTY_BUILDER_TOOLS, LIBERTY_INSPECT_SLICE}
22   make
23
24feature {ANY}
25   lower, upper: LIBERTY_EXPRESSION
26
27feature {LIBERTY_INSPECT_CLAUSE}
28   specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
29      local
30         l, u: LIBERTY_EXPRESSION
31      do
32         l := lower.specialized_in(a_type)
33         if lower = upper then
34            if l = lower then
35               Result := Current
36            else
37               create Result.make(l, l, position)
38            end
39         else
40            u := upper.specialized_in(a_type)
41            if l = lower and then u = upper then
42               Result := Current
43            else
44               create Result.make(l, u, position)
45            end
46         end
47      end
48
49feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
50   mark_reachable_code (mark: INTEGER) is
51      do
52         lower.mark_reachable_code(mark)
53         if upper /= lower then
54            upper.mark_reachable_code(mark)
55         end
56      end
57
58feature {}
59   make (a_lower: like lower; a_upper: like upper; a_position: like position) is
60      require
61         a_lower /= Void
62         a_position /= Void
63      do
64         lower := a_lower
65         if a_upper /= Void then
66            upper := a_upper
67         else
68            upper := a_lower
69         end
70         position := a_position
71      ensure
72         lower = a_lower
73         a_upper /= Void implies upper = a_upper
74         a_upper = Void implies upper = a_lower
75         position = a_position
76      end
77
78feature {ANY}
79   accept (v: VISITOR) is
80      local
81         v0: LIBERTY_INSPECT_SLICE_VISITOR
82      do
83         v0 ::= v
84         v0.visit_liberty_inspect_slice(Current)
85      end
86
87invariant
88   lower /= Void
89   upper /= Void
90
91end