PageRenderTime 17ms CodeModel.GetById 13ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://github.com/tybor/Liberty
Specman e | 110 lines | 80 code | 15 blank | 15 comment | 1 complexity | 71c81965c94dd51256f1e03dc4db2da6 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_TYPE
 16
 17insert
 18   ANY
 19      redefine
 20         is_equal
 21      end
 22
 23create {ANY}
 24   make
 25
 26feature {ANY}
 27   id: INTEGER
 28
 29   attributes_count: INTEGER
 30         -- Number of attributes
 31
 32   methods_count: INTEGER is
 33      do
 34         Result := methods.count
 35      end
 36
 37   is_equal (other: like Current): BOOLEAN is
 38      do
 39         Result := id = other.id
 40            and then attributes_count = other.attributes_count
 41            and then methods.count = other.methods.count
 42            and then methods.for_all(agent other.methods.has)
 43      end
 44
 45   method (index: INTEGER): LIBERTY_ASM_METHOD is
 46      require
 47         index.in_range(0, methods_count - 1)
 48      do
 49         Result := methods.item(index)
 50      ensure
 51         Result /= Void
 52      end
 53
 54   do_all_methods (action: PROCEDURE[TUPLE[LIBERTY_ASM_METHOD]]) is
 55      require
 56         action /= Void
 57      do
 58         methods.do_all(action)
 59      end
 60
 61   resolve_method (method_id: INTEGER): LIBERTY_ASM_METHOD is
 62      do
 63         if methods.valid_index(method_id) then
 64            Result := method(method_id)
 65         end
 66      end
 67
 68feature {LIBERTY_ASM_METHOD}
 69   add_method (a_method: LIBERTY_ASM_METHOD): INTEGER is
 70      require
 71         a_method /= Void
 72         resolve_method(a_method.id) = Void
 73      do
 74         Result := methods.count
 75         methods.add_last(a_method)
 76      ensure
 77         methods_count = old methods_count + 1
 78         method(methods_count - 1) = a_method
 79      end
 80
 81   has_method (a_method: LIBERTY_ASM_METHOD): BOOLEAN is
 82      require
 83         a_method.type = Current
 84      do
 85         Result := methods.valid_index(a_method.id) and then methods.item(a_method.id) = a_method
 86      ensure
 87         assertions_only_because_it_is_obvious: Result
 88      end
 89
 90feature {}
 91   make (a_id: like id; a_attributes_count: like attributes_count) is
 92      require
 93         a_attributes_count >= 0
 94      do
 95         id := a_id
 96         attributes_count := a_attributes_count
 97         create methods.make(0)
 98      ensure
 99         id = a_id
100         attributes_count = a_attributes_count
101      end
102
103feature {LIBERTY_ASM_TYPE}
104   methods: FAST_ARRAY[LIBERTY_ASM_METHOD]
105
106invariant
107   attributes_count >= 0
108   methods /= Void
109
110end -- class LIBERTY_ASM_TYPE