PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

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

http://github.com/tybor/Liberty
Specman e | 84 lines | 60 code | 8 blank | 16 comment | 1 complexity | 051f07e44dd20f80d8a5520af137ab6c 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_COMPARISON
16
17inherit
18   LIBERTY_EXPRESSION
19
20feature {ANY}
21   left, right: LIBERTY_EXPRESSION
22   result_type: LIBERTY_TYPE
23
24   specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
25      local
26         l, r: LIBERTY_EXPRESSION
27      do
28         check result_type.specialized_in(a_type) = result_type end
29         l := left.specialized_in(a_type)
30         r := right.specialized_in(a_type)
31         if l = left and then r = right then
32            Result := Current
33         else
34            Result := make_new(l, r, result_type, position)
35         end
36      end
37
38feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
39   mark_reachable_code (mark: INTEGER) is
40      do
41         left.mark_reachable_code(mark)
42         right.mark_reachable_code(mark)
43      end
44
45feature {}
46   make_new (a_left: like left; a_right: like right; a_result_type: like result_type; a_position: like position): like Current is
47      require
48         a_left /= Void
49         a_right /= Void
50         a_result_type /= Void
51         -- a_result_type is BOOLEAN
52         a_position /= Void
53      deferred
54      ensure
55         Result.left = a_left
56         Result.right = a_right
57         Result.result_type = a_result_type
58         Result.position = a_position
59      end
60
61   make (a_left: like left; a_right: like right; a_result_type: like result_type; a_position: like position) is
62      require
63         a_left /= Void
64         a_right /= Void
65         a_result_type /= Void
66         -- a_result_type is BOOLEAN
67         a_position /= Void
68      do
69         left := a_left
70         right := a_right
71         result_type := a_result_type
72         position := a_position
73      ensure
74         left = a_left
75         right = a_right
76         result_type = a_result_type
77         position = a_position
78      end
79
80invariant
81   left /= Void
82   right /= Void
83
84end