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

/src/tools/compiler/asm/data/liberty_asm_method.e

http://github.com/tybor/Liberty
Specman e | 153 lines | 119 code | 20 blank | 14 comment | 0 complexity | 3a55e025ed3548fa7ed2bbbe42842c0f 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_ASM_METHOD
 16
 17insert
 18   SAFE_EQUAL[LIBERTY_ASM_INSTRUCTION]
 19      redefine
 20         is_equal
 21      end
 22
 23create {ANY}
 24   make
 25
 26feature {ANY}
 27   id: INTEGER
 28   type: LIBERTY_ASM_TYPE
 29
 30   code: LIBERTY_ASM_INSTRUCTION
 31   code_size: INTEGER
 32
 33   retry_code: LIBERTY_ASM_INSTRUCTION
 34   retry_size: INTEGER
 35
 36   precondition: LIBERTY_ASM_INSTRUCTION
 37   precondition_size: INTEGER
 38
 39   postcondition: LIBERTY_ASM_INSTRUCTION
 40   postcondition_size: INTEGER
 41
 42   parameters: COLLECTION[LIBERTY_ASM_PARAMETER]
 43
 44   is_equal (other: like Current): BOOLEAN is
 45      do
 46         Result := id = other.id and then type.id = other.type.id -- don't check type.is_equal because it would incur an infinite recursion
 47            and then parameters.is_equal(other.parameters)
 48            and then safe_equal(code, other.code)
 49            and then safe_equal(retry_code, other.retry_code)
 50            and then safe_equal(precondition, other.precondition)
 51            and then safe_equal(postcondition, other.postcondition)
 52      end
 53
 54   set_code (a_code: like code) is
 55      require
 56         a_code /= Void
 57      do
 58         code := a_code
 59      ensure
 60         code = a_code
 61      end
 62
 63   set_code_size (a_code_size: like code_size) is
 64      require
 65         code_size = 0
 66         a_code_size > 0
 67      do
 68         code_size := a_code_size
 69      ensure
 70         code_size = a_code_size
 71      end
 72
 73   set_retry (a_retry: like retry_code) is
 74      require
 75         retry_code /= Void implies a_retry /= Void
 76      do
 77         retry_code := a_retry
 78      ensure
 79         retry_code = a_retry
 80      end
 81
 82   set_retry_size (a_retry_size: like retry_size) is
 83      require
 84         a_retry_size > 0
 85         retry_code /= Void
 86      do
 87         retry_size := a_retry_size
 88      ensure
 89         retry_size = a_retry_size
 90      end
 91
 92   set_precondition (a_precondition: like precondition) is
 93      require
 94         precondition /= Void implies a_precondition /= Void
 95      do
 96         precondition := a_precondition
 97      ensure
 98         precondition = a_precondition
 99      end
100
101   set_precondition_size (a_precondition_size: like precondition_size) is
102      require
103         a_precondition_size > 0
104         precondition /= Void
105      do
106         precondition_size := a_precondition_size
107      ensure
108         precondition_size = a_precondition_size
109      end
110
111   set_postcondition (a_postcondition: like postcondition) is
112      require
113         postcondition /= Void implies a_postcondition /= Void
114      do
115         postcondition := a_postcondition
116      ensure
117         postcondition = a_postcondition
118      end
119
120   set_postcondition_size (a_postcondition_size: like postcondition_size) is
121      require
122         a_postcondition_size > 0
123         postcondition /= Void
124      do
125         postcondition_size := a_postcondition_size
126      ensure
127         postcondition_size = a_postcondition_size
128      end
129
130feature {}
131   make (a_type: like type; a_code: like code; a_parameters: like parameters) is
132      require
133         a_type /= Void
134         a_code /= Void
135         a_parameters /= Void
136      do
137         type := a_type
138         code := a_code
139         parameters := a_parameters
140         id := type.add_method(Current)
141      ensure
142         type = a_type
143         type.has_method(Current)
144         code = a_code
145         parameters = a_parameters
146      end
147
148invariant
149   type /= Void
150   code /= Void
151   parameters /= Void
152
153end -- class LIBERTY_ASM_METHOD