PageRenderTime 19ms CodeModel.GetById 12ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/src/tools/semantics/code/liberty_precursor.e

http://github.com/tybor/Liberty
Specman e | 95 lines | 72 code | 9 blank | 14 comment | 3 complexity | 05395c8995f9fcc9d72c89904aba7a04 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_PRECURSOR
16
17insert
18   LIBERTY_POSITIONABLE
19   LIBERTY_REACHABLE
20
21feature {ANY}
22   the_feature: LIBERTY_FEATURE
23   actuals: TRAVERSABLE[LIBERTY_EXPRESSION] is
24      do
25         Result := actuals_list
26      end
27
28   specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
29      local
30         f: like the_feature
31         a: like actuals_list
32         e: LIBERTY_EXPRESSION
33         i: INTEGER
34      do
35         f := the_feature.specialized_in(a_type)
36         from
37            a := actuals_list
38            i := a.lower
39         until
40            i > a.upper
41         loop
42            e := a.item(i).specialized_in(a_type)
43            if e /= a.item(i) then
44               if a = actuals_list then
45                  a := a.twin
46               end
47               a.put(e, i)
48            end
49            i := i + 1
50         end
51         if f = the_feature and then a = actuals_list then
52            Result := Current
53         else
54            Result := make_new(f, a, position)
55         end
56      end
57
58feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
59   mark_reachable_code (mark: INTEGER) is
60      do
61         the_feature.mark_reachable_code(mark)
62         expressions_marker.mark_reachable_code(mark, actuals)
63      end
64
65feature {}
66   make_new (a_feature: like the_feature; a_actuals: like actuals_list; a_position: like position): like Current is
67      deferred
68      ensure
69         Result.the_feature = a_feature
70         Result.actuals = a_actuals
71         Result.position = a_position
72      end
73
74   make (a_feature: like the_feature; a_actuals: like actuals_list; a_position: like position) is
75      require
76         a_feature /= Void
77         a_actuals /= Void
78         a_position /= Void
79      do
80         the_feature := a_feature
81         actuals_list := a_actuals
82         position := a_position
83      ensure
84         the_feature = a_feature
85         actuals_list = a_actuals
86         position = a_position
87      end
88
89   actuals_list: COLLECTION[LIBERTY_EXPRESSION]
90
91invariant
92   the_feature /= Void
93   actuals /= Void
94
95end