note description: "Abstract representation of a routine" legal: "See notice at end of class." status: "See notice at end of class." date: "$Date$" revision: "$Revision$" deferred class PROCEDURE_I inherit FEATURE_I redefine arguments, assert_id_set, duplicate, duplicate_arguments, has_code, is_routine, obsolete_message, set_arguments, set_assert_id_set, transfer_from, transfer_to end feature -- Access arguments: FEAT_ARG -- Arguments type obsolete_message_id: INTEGER -- Id of `obsolete_message' in `names_heap' table. assert_id_set: ASSERT_ID_SET -- Assertions to which the procedure belongs to feature {INTERNAL_COMPILER_STRING_EXPORTER} -- Access obsolete_message: STRING -- Obsolete message -- (Void if Current is not obsolete) do Result := names_heap.item (obsolete_message_id) end feature -- Status report is_routine: BOOLEAN = True -- Current is a procedure. has_code: BOOLEAN = True -- feature -- Settings set_assert_id_set (set: like assert_id_set) -- Assign `set' to assert_id_set. do assert_id_set := set end set_arguments (args: like arguments) -- Assign `args' to `arguments'. do arguments := args ensure then arguments_set: arguments = args end set_obsolete_message_id (v: like obsolete_message_id) -- Assign `v' to `obsolete_message_id' do obsolete_message_id := v ensure obsolete_message_id_set: obsolete_message_id = v end feature {INTERNAL_COMPILER_STRING_EXPORTER} -- Modification set_obsolete_message (s: STRING) -- Assign `s' to `obsolete_message'. require s_not_void: s /= Void local l_names_heap: like names_heap do l_names_heap := names_heap l_names_heap.put (s) obsolete_message_id := l_names_heap.found_item ensure obsolete_message_set: equal (obsolete_message, s) end feature -- Initialization duplicate_arguments -- Do a clone of the arguments (for replication) do if arguments /= Void then arguments := arguments.twin end end init_assertion_flags (content: ROUTINE_AS) -- Initialize assertion flags with `content'. require content_not_void: content /= Void do set_is_require_else (content.is_require_else) set_is_ensure_then (content.is_ensure_then) set_has_precondition (content.has_precondition) set_has_postcondition (content.has_postcondition) set_has_false_postcondition (content.has_false_postcondition) end duplicate: like Current -- Duplicate feature do Result := Precursor {FEATURE_I} Result.duplicate_arguments end init_arg (argument_as: EIFFEL_LIST [TYPE_DEC_AS]; a_context_class: CLASS_C) -- Initialization of arguments. require argument_as_not_void: argument_as /= Void a_context_class_not_void: a_context_class /= Void local i, j, l_count, dec_count, nb_arg: INTEGER arg_type: TYPE_A arg_dec: TYPE_DEC_AS id_list: IDENTIFIER_LIST do -- Calculate the number of arguments. from i := 1 l_count := argument_as.count until i > l_count loop nb_arg := nb_arg + argument_as.i_th (i).id_list.count i := i + 1 end -- Creation of data structures create arguments.make (nb_arg) -- Fill the data structures from i := 1 until i > l_count loop arg_dec := argument_as.i_th (i) from j := 1 id_list := arg_dec.id_list arg_type := type_a_generator.evaluate_type (arg_dec.type, a_context_class) dec_count := id_list.count until j > dec_count loop arguments.extend_with_name (arg_type, id_list.i_th (j)) j := j + 1 end i := i + 1 end end transfer_to (other: PROCEDURE_I) -- Transfer datas form `other' into Current. do Precursor {FEATURE_I} (other) other.set_arguments (arguments) other.set_is_require_else (is_require_else) other.set_is_ensure_then (is_ensure_then) other.set_obsolete_message_id (obsolete_message_id) other.set_has_precondition (has_precondition) other.set_has_postcondition (has_postcondition) other.set_has_false_postcondition (has_false_postcondition) other.set_assert_id_set (assert_id_set) other.set_has_rescue_clause (has_rescue_clause) end transfer_from (other: PROCEDURE_I) -- Transfer datas form `other' into Current. do Precursor {FEATURE_I} (other) arguments := other.arguments obsolete_message_id := other.obsolete_message_id assert_id_set := other.assert_id_set end -- Note: `require else' can be used even if the feature has no -- precursor. There is no problem to raise an error in the normal case, -- the only case where we cannot do anything is when aliases are used -- and one name references a feature with a predecessor and not the -- other one -- check_assertions is -- local -- fas: FEATURE_AS -- body: BODY_AS -- ras: ROUTINE_AS -- precondition: REQUIRE_AS -- postcondition: ENSURE_AS -- ve05: VE05 -- do -- if is_origin then -- fas := Body_server.item (body_index) -- body := fas.body -- ras ?= body.content -- if ras /= Void then -- precondition := ras.precondition -- postcondition := ras.postcondition -- if -- (precondition /= Void and then precondition.is_else) -- or else -- (postcondition /= Void and then postcondition.is_then) -- then --io.error.put_string ("Error VE05: require else or ensure then%NClass: ") --io.error.put_string (System.current_class.name) --io.error.put_string ("%NFeature: ") --io.error.put_string (feature_name) --io.error.put_new_line -- !!ve05 -- ve05.set_class (System.current_class) -- ve05.set_feature (Current) -- Error_handler.insert_error (ve05) -- Error_handler.checksum -- end -- end -- end -- end feature {NONE} -- Implementation new_api_feature: E_ROUTINE -- API feature creation do create {E_PROCEDURE} Result.make_with_aliases (feature_name_id, alias_names, has_convert_mark, feature_id) update_api (Result) end update_api (f: E_ROUTINE) -- Update the attributes of api feature `f'. require f_not_void: f /= Void local args: like arguments do args := arguments if args /= Void then f.set_arguments (args.api_args) end f.set_has_precondition (has_precondition) f.set_has_postcondition (has_postcondition) f.set_obsolete_message (obsolete_message) f.set_class (is_class) end note copyright: "Copyright (c) 1984-2019, Eiffel Software" license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)" licensing_options: "http://www.eiffel.com/licensing" copying: "[ This file is part of Eiffel Software's Eiffel Development Environment. Eiffel Software's Eiffel Development Environment is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2 of the License (available at the URL listed under "license" above). Eiffel Software's Eiffel Development Environment is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Eiffel Software's Eiffel Development Environment; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ]" source: "[ Eiffel Software 5949 Hollister Ave., Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Website http://www.eiffel.com Customer support http://support.eiffel.com ]" end