PageRenderTime 4ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/tools/semantics/code/features/liberty_feature_routine.e

http://github.com/tybor/Liberty
Specman e | 93 lines | 69 code | 10 blank | 14 comment | 3 complexity | b2687f3897c4443e8cafa6efb7fa2303 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_FEATURE_ROUTINE
16
17inherit
18   LIBERTY_FEATURE
19      rename
20         make as make_late_binding
21      redefine
22         mark_reachable_code, set_specialized_in
23      end
24
25feature {ANY}
26   block_instruction: LIBERTY_INSTRUCTION
27
28   rescue_instruction: LIBERTY_INSTRUCTION
29
30   locals: TRAVERSABLE[LIBERTY_LOCAL] is
31      require
32         has_context
33      do
34         Result := context.locals
35      ensure
36         exists: Result /= Void
37      end
38
39feature {LIBERTY_FEATURE}
40   set_specialized_in (a_original: like Current; a_context: like context) is
41      do
42         Precursor(a_original, a_context)
43         block_instruction := block_instruction.specialized_in(a_context.current_type)
44         if rescue_instruction /= Void then
45            rescue_instruction := rescue_instruction.specialized_in(a_context.current_type)
46         end
47      end
48
49feature {LIBERTY_BUILDER_TOOLS}
50   set_rescue (a_rescue: like rescue_instruction) is
51      require
52         rescue_instruction = Void
53         a_rescue /= Void
54      do
55         rescue_instruction := a_rescue
56      ensure
57         rescue_instruction = a_rescue
58      end
59
60feature {}
61   make (a_definition_type: like definition_type; a_instruction: like block_instruction; a_accelerator: like accelerator) is
62      require
63         a_definition_type /= Void
64         a_instruction /= Void
65         a_accelerator /= Void
66      do
67         make_late_binding(a_definition_type, a_accelerator)
68         block_instruction := a_instruction
69      ensure
70         definition_type = a_definition_type
71         block_instruction = a_instruction
72      end
73
74feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
75   mark_reachable_code (mark: INTEGER) is
76      local
77         old_mark: like reachable_mark
78      do
79         old_mark := reachable_mark
80         Precursor(mark)
81         if old_mark < mark then
82            block_instruction.mark_reachable_code(mark)
83            if rescue_instruction /= Void then
84               rescue_instruction.mark_reachable_code(mark)
85            end
86         end
87      end
88
89invariant
90   block_instruction /= Void
91   accelerator /= Void
92
93end