note
	description: "Internal routine for RT_DBG_ classes"
	status: "See notice at end of class."
	legal: "See notice at end of class."
	date: "$Date: 2017-04-12 13:15:47 +0000 (Wed, 12 Apr 2017) $"
	revision: "$Revision: 100150 $"

deferred class 
	RT_DBG_INTERNAL

inherit
	REFLECTOR_CONSTANTS

feature -- Object access

	frozen object_field_count (obj: ANY): INTEGER_32
			-- Field_count on obj
		require
			obj_attached: obj /= Void
		do
			Reflected_object.set_object (obj)
			Result := Reflected_object.field_count
		end

	frozen object_records (obj: ANY): detachable ARRAYED_LIST [RT_DBG_VALUE_RECORD]
			-- List of field records on obj
		require
			obj_attached: obj /= Void
		local
			i, cnb: INTEGER_32
			l_records: like object_records
		do
			cnb := object_field_count (obj)
			if cnb > 0 then
				create l_records.make (cnb)
				from
					i := 1
				until
					i > cnb
				loop
					if attached {like object_record} object_record (i, obj) as r then
						l_records.extend (r)
					end
					i := i + 1
				end
				Result := l_records
			end
		end

	frozen object_is_expanded (object: ANY): BOOLEAN
			-- Is object an expanded value ?
		require
			object_not_void: object /= Void
		do
			Result := c_object_is_expanded ($object.to_pointer)
		end

	frozen field_index_at (off: INTEGER_32; obj: ANY): INTEGER_32
			-- Field name at offset off on obj
		require
				obj /= Void
		local
			n: INTEGER_32
			l_reflected_object: like Reflected_object
		do
			from
				l_reflected_object := Reflected_object
				l_reflected_object.set_object (obj)
				n := l_reflected_object.field_count
			until
				n = 0 or Result > 0
			loop
				if off = l_reflected_object.field_offset (n) then
					Result := n
				end
				n := n - 1
			end
		end

	frozen field_name_at (off: INTEGER_32; obj: ANY): detachable STRING_8
			-- Field name at offset off on obj
		require
				obj /= Void
		local
			i: INTEGER_32
		do
			i := field_index_at (off, obj)
			if i > 0 then
				Reflected_object.set_object (obj)
				Result := Reflected_object.field_name (i)
			end
		end

	frozen field_at (off: INTEGER_32; a_field_type: NATURAL_32; object: ANY): detachable ANY
			-- Object attached at offset off field of object
			-- (directly or through a reference)
		require
			object_not_void: object /= Void
			index_large_enough: off >= 1
		local
			t: INTEGER_32
		do
			t := eif_type (a_field_type)
			inspect t
			when Boolean_type then
				Result := {ISE_RUNTIME}.boolean_field_at (off, $object.to_pointer, 0)
			when Character_8_type then
				Result := {ISE_RUNTIME}.character_8_field_at (off, $object.to_pointer, 0)
			when Character_32_type then
				Result := {ISE_RUNTIME}.character_32_field_at (off, $object.to_pointer, 0)
			when Natural_8_type then
				Result := {ISE_RUNTIME}.natural_8_field_at (off, $object.to_pointer, 0)
			when Natural_16_type then
				Result := {ISE_RUNTIME}.natural_16_field_at (off, $object.to_pointer, 0)
			when Natural_32_type then
				Result := {ISE_RUNTIME}.natural_32_field_at (off, $object.to_pointer, 0)
			when Natural_64_type then
				Result := {ISE_RUNTIME}.natural_64_field_at (off, $object.to_pointer, 0)
			when Integer_8_type then
				Result := {ISE_RUNTIME}.integer_8_field_at (off, $object.to_pointer, 0)
			when Integer_16_type then
				Result := {ISE_RUNTIME}.integer_16_field_at (off, $object.to_pointer, 0)
			when Integer_32_type then
				Result := {ISE_RUNTIME}.integer_32_field_at (off, $object.to_pointer, 0)
			when Integer_64_type then
				Result := {ISE_RUNTIME}.integer_64_field_at (off, $object.to_pointer, 0)
			when Real_32_type then
				Result := {ISE_RUNTIME}.real_32_field_at (off, $object.to_pointer, 0)
			when Real_64_type then
				Result := {ISE_RUNTIME}.real_64_field_at (off, $object.to_pointer, 0)
			when Pointer_type then
				Result := {ISE_RUNTIME}.pointer_field_at (off, $object.to_pointer, 0)
			when Reference_type then
				Result := {ISE_RUNTIME}.reference_field_at (off, $object.to_pointer, 0)
			else
			end
		end

	frozen stack_value_at (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_rt_type: NATURAL_32): detachable ANY
			-- Object attached at offset off field of object
			-- (directly or through a reference)
		require
			index_large_enough: pos >= 1
		do
			debug ("rt_dbg_internal")
				print ("%Nstack_value_at (" + dep.out + ", " + pos.out + ", 0x" + a_rt_type.to_hex_string + ")%N")
			end
			Result := c_stack_value_at (dep, a_loc_type, pos, a_rt_type)
			debug ("rt_dbg_internal")
				print ("stack_value_at -> ")
				if Result /= Void then
					print (Result.generating_type.name + " = " + Result.out)
				else
					print ("Void Result")
				end
				print ("%N")
			end
		end

	frozen eif_type (a_field_type: NATURAL_32): INTEGER_32
			-- EIF_ type from field type a_field_type
		do
			Result := c_eif_type (a_field_type)
		end

	frozen rt_dynamic_type (object: ANY): INTEGER_32
			-- Dynamic type of object
		require
			object_not_void: object /= Void
		do
			Result := c_rt_dynamic_type ($object.to_pointer)
		ensure
			rt_dynamic_type_nonnegative: Result >= 0
		end
	
feature {NONE} -- Factory

	frozen object_record (i: INTEGER_32; obj: ANY): detachable RT_DBG_VALUE_RECORD
		require
			obj_attached: obj /= Void
		local
			ft: INTEGER_32
			l_reflected_object: like Reflected_object
		do
			l_reflected_object := Reflected_object
			l_reflected_object.set_object (obj)
			ft := l_reflected_object.field_type (i)
			Result := object_attribute_record (l_reflected_object.field_offset (i), c_rt_field_type (i, ft), obj)
			inspect ft
			when Integer_8_type then
				create {RT_DBG_FIELD_RECORD [INTEGER_8]} Result.make (obj, i, ft, l_reflected_object.integer_8_field (i))
			when Integer_16_type then
				create {RT_DBG_FIELD_RECORD [INTEGER_16]} Result.make (obj, i, ft, l_reflected_object.integer_16_field (i))
			when Integer_32_type then
				create {RT_DBG_FIELD_RECORD [INTEGER_32]} Result.make (obj, i, ft, l_reflected_object.integer_32_field (i))
			when Integer_64_type then
				create {RT_DBG_FIELD_RECORD [INTEGER_64]} Result.make (obj, i, ft, l_reflected_object.integer_64_field (i))
			when Natural_8_type then
				create {RT_DBG_FIELD_RECORD [NATURAL_8]} Result.make (obj, i, ft, l_reflected_object.natural_8_field (i))
			when Natural_16_type then
				create {RT_DBG_FIELD_RECORD [NATURAL_16]} Result.make (obj, i, ft, l_reflected_object.natural_16_field (i))
			when Natural_32_type then
				create {RT_DBG_FIELD_RECORD [NATURAL_32]} Result.make (obj, i, ft, l_reflected_object.natural_32_field (i))
			when Natural_64_type then
				create {RT_DBG_FIELD_RECORD [NATURAL_64]} Result.make (obj, i, ft, l_reflected_object.natural_64_field (i))
			when Pointer_type then
				create {RT_DBG_FIELD_RECORD [POINTER]} Result.make (obj, i, ft, l_reflected_object.pointer_field (i))
			when Reference_type then
				create {RT_DBG_FIELD_RECORD [detachable ANY]} Result.make (obj, i, ft, l_reflected_object.reference_field (i))
			when Expanded_type then
				create {RT_DBG_FIELD_RECORD [detachable ANY]} Result.make (obj, i, ft, l_reflected_object.field (i))
			when Boolean_type then
				create {RT_DBG_FIELD_RECORD [BOOLEAN]} Result.make (obj, i, ft, l_reflected_object.boolean_field (i))
			when Real_32_type then
				create {RT_DBG_FIELD_RECORD [REAL_32]} Result.make (obj, i, ft, l_reflected_object.real_32_field (i))
			when Real_64_type then
				create {RT_DBG_FIELD_RECORD [REAL_64]} Result.make (obj, i, ft, l_reflected_object.real_64_field (i))
			when Character_8_type then
				create {RT_DBG_FIELD_RECORD [CHARACTER_8]} Result.make (obj, i, ft, l_reflected_object.character_8_field (i))
			when Character_32_type then
				create {RT_DBG_FIELD_RECORD [CHARACTER_32]} Result.make (obj, i, ft, l_reflected_object.character_32_field (i))
			else
			end
		end

	frozen object_attribute_record (off: INTEGER_32; t: NATURAL_32; obj: ANY): detachable RT_DBG_VALUE_RECORD
			-- Record for attribute of type t at offset o on object obj
		require
			obj_attached: obj /= Void
		local
			ft: INTEGER_32
			l_reflected_object: REFLECTED_REFERENCE_OBJECT
		do
			ft := eif_type (t)
			inspect ft
			when Boolean_type then
				create {RT_DBG_ATTRIBUTE_RECORD [BOOLEAN]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.boolean_field_at (off, $obj.to_pointer, 0))
			when Character_8_type then
				create {RT_DBG_ATTRIBUTE_RECORD [CHARACTER_8]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.character_8_field_at (off, $obj.to_pointer, 0))
			when Character_32_type then
				create {RT_DBG_ATTRIBUTE_RECORD [CHARACTER_32]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.character_32_field_at (off, $obj.to_pointer, 0))
			when Integer_8_type then
				create {RT_DBG_ATTRIBUTE_RECORD [INTEGER_8]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.integer_8_field_at (off, $obj.to_pointer, 0))
			when Integer_16_type then
				create {RT_DBG_ATTRIBUTE_RECORD [INTEGER_16]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.integer_16_field_at (off, $obj.to_pointer, 0))
			when Integer_32_type then
				create {RT_DBG_ATTRIBUTE_RECORD [INTEGER_32]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.integer_32_field_at (off, $obj.to_pointer, 0))
			when Integer_64_type then
				create {RT_DBG_ATTRIBUTE_RECORD [INTEGER_64]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.integer_64_field_at (off, $obj.to_pointer, 0))
			when Natural_8_type then
				create {RT_DBG_ATTRIBUTE_RECORD [NATURAL_8]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.natural_8_field_at (off, $obj.to_pointer, 0))
			when Natural_16_type then
				create {RT_DBG_ATTRIBUTE_RECORD [NATURAL_16]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.natural_16_field_at (off, $obj.to_pointer, 0))
			when Natural_32_type then
				create {RT_DBG_ATTRIBUTE_RECORD [NATURAL_32]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.natural_8_field_at (off, $obj.to_pointer, 0).to_natural_32)
			when Natural_64_type then
				create {RT_DBG_ATTRIBUTE_RECORD [NATURAL_64]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.natural_8_field_at (off, $obj.to_pointer, 0).to_natural_64)
			when Real_32_type then
				create {RT_DBG_ATTRIBUTE_RECORD [REAL_32]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.real_32_field_at (off, $obj.to_pointer, 0))
			when Real_64_type then
				create {RT_DBG_ATTRIBUTE_RECORD [REAL_64]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.real_64_field_at (off, $obj.to_pointer, 0))
			when Pointer_type then
				create {RT_DBG_ATTRIBUTE_RECORD [POINTER]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.pointer_field_at (off, $obj.to_pointer, 0))
			when Reference_type then
				create {RT_DBG_ATTRIBUTE_RECORD [ANY]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.reference_field_at (off, $obj.to_pointer, 0))
			when Expanded_type then
				create l_reflected_object.make_for_expanded_field_at (obj, off)
				create {RT_DBG_ATTRIBUTE_RECORD [ANY]} Result.make (obj, off, ft, t, l_reflected_object.object)
			else
			end
		end

	frozen object_local_record (dep: INTEGER_32; pos: INTEGER_32; t: NATURAL_32): detachable RT_DBG_VALUE_RECORD
			-- Local or Result value record.
		local
			ft: INTEGER_32
		do
			ft := eif_type (t)
			inspect ft
			when Boolean_type then
				create {RT_DBG_LOCAL_RECORD [BOOLEAN]} Result.make (dep, pos, ft, t)
			when Character_8_type then
				create {RT_DBG_LOCAL_RECORD [CHARACTER_8]} Result.make (dep, pos, ft, t)
			when Character_32_type then
				create {RT_DBG_LOCAL_RECORD [CHARACTER_32]} Result.make (dep, pos, ft, t)
			when Natural_8_type then
				create {RT_DBG_LOCAL_RECORD [NATURAL_8]} Result.make (dep, pos, ft, t)
			when Natural_16_type then
				create {RT_DBG_LOCAL_RECORD [NATURAL_16]} Result.make (dep, pos, ft, t)
			when Natural_32_type then
				create {RT_DBG_LOCAL_RECORD [NATURAL_32]} Result.make (dep, pos, ft, t)
			when Natural_64_type then
				create {RT_DBG_LOCAL_RECORD [NATURAL_64]} Result.make (dep, pos, ft, t)
			when Integer_8_type then
				create {RT_DBG_LOCAL_RECORD [INTEGER_8]} Result.make (dep, pos, ft, t)
			when Integer_16_type then
				create {RT_DBG_LOCAL_RECORD [INTEGER_16]} Result.make (dep, pos, ft, t)
			when Integer_32_type then
				create {RT_DBG_LOCAL_RECORD [INTEGER_32]} Result.make (dep, pos, ft, t)
			when Integer_64_type then
				create {RT_DBG_LOCAL_RECORD [INTEGER_64]} Result.make (dep, pos, ft, t)
			when Real_32_type then
				create {RT_DBG_LOCAL_RECORD [REAL_32]} Result.make (dep, pos, ft, t)
			when Real_64_type then
				create {RT_DBG_LOCAL_RECORD [REAL_64]} Result.make (dep, pos, ft, t)
			when Pointer_type then
				create {RT_DBG_LOCAL_RECORD [POINTER]} Result.make (dep, pos, ft, t)
			when Reference_type then
				create {RT_DBG_LOCAL_RECORD [ANY]} Result.make (dep, pos, ft, t)
			when Expanded_type then
				create {RT_DBG_LOCAL_RECORD [ANY]} Result.make (dep, pos, ft, t)
			when None_type then
			else
			end
			if Result /= Void then
				Result.get_value
			end
		end
	
feature {NONE} -- External implementation

	frozen c_object_is_expanded (object: POINTER): BOOLEAN
		external
			"C inline use %"eif_eiffel.h%""
		alias
			"eif_is_expanded(HEADER($object)->ov_flags)"
		end

	frozen c_eif_type (a_field_type: NATURAL_32): INTEGER_32
			-- EIF_ type related to a_field_type
		external
			"C inline use %"eif_internal.h%""
		alias
			"ei_eif_type((uint32) $a_field_type)"
		end

	frozen c_rt_field_type (i: INTEGER_32; a_type_id: INTEGER_32): NATURAL_32
			-- RT field type related to i on a_type_id
		external
			"C inline use %"eif_internal.h%""
		alias
			"System(To_dtype($a_type_id)).cn_types[$i]"
		end

	frozen c_rt_dynamic_type (object: POINTER): INTEGER_32
			-- Dynamic type of object.
		external
			"C macro signature (EIF_REFERENCE): EIF_INTEGER use %"eif_macros.h%""
		alias
			"Dtype"
		end
	
feature -- Change field

	set_field_at (off: INTEGER_32; a_type: NATURAL_32; value: detachable ANY; object: ANY)
		require
			object_attached: object /= Void
		local
			a_eif_type: INTEGER_32
		do
			debug ("rt_dbg_internal")
				print ("set_field_at (" + off.out + ", " + a_type.out + ", value, " + object.generator + ") %N")
			end
			a_eif_type := eif_type (a_type)
			inspect a_eif_type
			when Boolean_type then
				if attached {BOOLEAN} value as bool then
					{ISE_RUNTIME}.set_boolean_field_at (off, $object.to_pointer, 0, bool)
				end
			when Character_8_type then
				if attached {CHARACTER_8} value as c8 then
					{ISE_RUNTIME}.set_character_8_field_at (off, $object.to_pointer, 0, c8)
				end
			when Character_32_type then
				if attached {CHARACTER_32} value as c32 then
					{ISE_RUNTIME}.set_character_32_field_at (off, $object.to_pointer, 0, c32)
				end
			when Natural_8_type then
				if attached {NATURAL_8} value as n8 then
					{ISE_RUNTIME}.set_natural_8_field_at (off, $object.to_pointer, 0, n8)
				end
			when Natural_16_type then
				if attached {NATURAL_16} value as n16 then
					{ISE_RUNTIME}.set_natural_16_field_at (off, $object.to_pointer, 0, n16)
				end
			when Natural_32_type then
				if attached {NATURAL_32} value as n32 then
					{ISE_RUNTIME}.set_natural_32_field_at (off, $object.to_pointer, 0, n32)
				end
			when Natural_64_type then
				if attached {NATURAL_64} value as n64 then
					{ISE_RUNTIME}.set_natural_64_field_at (off, $object.to_pointer, 0, n64)
				end
			when Integer_8_type then
				if attached {INTEGER_8} value as i8 then
					{ISE_RUNTIME}.set_integer_8_field_at (off, $object.to_pointer, 0, i8)
				end
			when Integer_16_type then
				if attached {INTEGER_16} value as i16 then
					{ISE_RUNTIME}.set_integer_16_field_at (off, $object.to_pointer, 0, i16)
				end
			when Integer_32_type then
				if attached {INTEGER_32} value as i32 then
					{ISE_RUNTIME}.set_integer_32_field_at (off, $object.to_pointer, 0, i32)
				end
			when Integer_64_type then
				if attached {INTEGER_64} value as i64 then
					{ISE_RUNTIME}.set_integer_64_field_at (off, $object.to_pointer, 0, i64)
				end
			when Real_32_type then
				if attached {REAL_32} value as r32 then
					{ISE_RUNTIME}.set_real_32_field_at (off, $object.to_pointer, 0, r32)
				end
			when Real_64_type then
				if attached {REAL_64} value as r64 then
					{ISE_RUNTIME}.set_real_64_field_at (off, $object.to_pointer, 0, r64)
				end
			when Pointer_type then
				if attached {POINTER} value as ptr then
					{ISE_RUNTIME}.set_pointer_field_at (off, $object.to_pointer, 0, ptr)
				end
			when Reference_type then
				{ISE_RUNTIME}.set_reference_field_at (off, $object.to_pointer, 0, value)
			else
			end
		end
	
feature -- Access local

	frozen c_stack_value_at (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_rt_type: NATURAL_32): detachable ANY
			-- Object value referenced at off offset of object
		external
			"C inline use %"eif_debug.h%""
		alias
			"[
				#ifdef WORKBENCH
					return (EIF_REFERENCE) rt_dbg_stack_value((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (uint32)$a_rt_type);
				#else
					return NULL;
				#endif
			]"
		end
	
feature -- Change local

	Rt_dlt_argument: INTEGER_32 = 0
			-- DLT=DebugLocalType, the type is an argument of a function

	Rt_dlt_localvar: INTEGER_32 = 1
			-- DLT=DebugLocalType, the type is a local variable inside a function

	Rt_dlt_result: INTEGER_32 = 2
			-- DLT=DebugLocalType, the type is the Result of the current feature

	set_stack_value_at (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_rt_type: NATURAL_32; value: detachable ANY): INTEGER_32
			-- Set stack value at position pos on stack of depth dep with value
		require
			a_loc_type_valid: a_loc_type = Rt_dlt_localvar or a_loc_type = Rt_dlt_argument or a_loc_type = Rt_dlt_result
		local
			a_eif_type: INTEGER_32
		do
			debug ("rt_dbg_internal")
				print ("set_stack_value_at (dep=" + dep.out + ", loc_type=" + a_loc_type.out + ", pos=" + pos.out + ", type=0x" + a_rt_type.to_hex_string + ", value=")
				if value = Void then
					print ("Void) %N")
				else
					print (value.generating_type.name + ": " + value.out + ") %N")
				end
			end
			a_eif_type := eif_type (a_rt_type)
			inspect a_eif_type
			when Boolean_type then
				if attached {BOOLEAN} value as bool then
					Result := c_set_boolean_stack_value (dep, a_loc_type, pos, bool)
				end
			when Character_8_type then
				if attached {CHARACTER_8} value as c8 then
					Result := c_set_character_8_stack_value (dep, a_loc_type, pos, c8)
				end
			when Character_32_type then
				if attached {CHARACTER_32} value as c32 then
					Result := c_set_character_32_stack_value (dep, a_loc_type, pos, c32)
				end
			when Natural_8_type then
				if attached {NATURAL_8} value as n8 then
					Result := c_set_natural_8_stack_value (dep, a_loc_type, pos, n8)
				end
			when Natural_16_type then
				if attached {NATURAL_16} value as n16 then
					Result := c_set_natural_16_stack_value (dep, a_loc_type, pos, n16)
				end
			when Natural_32_type then
				if attached {NATURAL_32} value as n32 then
					Result := c_set_natural_32_stack_value (dep, a_loc_type, pos, n32)
				end
			when Natural_64_type then
				if attached {NATURAL_64} value as n64 then
					Result := c_set_natural_64_stack_value (dep, a_loc_type, pos, n64)
				end
			when Integer_8_type then
				if attached {INTEGER_8} value as i8 then
					Result := c_set_integer_8_stack_value (dep, a_loc_type, pos, i8)
				end
			when Integer_16_type then
				if attached {INTEGER_16} value as i16 then
					Result := c_set_integer_16_stack_value (dep, a_loc_type, pos, i16)
				end
			when Integer_32_type then
				if attached {INTEGER_32} value as i32 then
					Result := c_set_integer_32_stack_value (dep, a_loc_type, pos, i32)
				end
			when Integer_64_type then
				if attached {INTEGER_64} value as i64 then
					Result := c_set_integer_64_stack_value (dep, a_loc_type, pos, i64)
				end
			when Real_32_type then
				if attached {REAL_32} value as r32 then
					Result := c_set_real_32_stack_value (dep, a_loc_type, pos, r32)
				end
			when Real_64_type then
				if attached {REAL_64} value as r64 then
					Result := c_set_real_64_stack_value (dep, a_loc_type, pos, r64)
				end
			when Pointer_type then
				if attached {POINTER} value as ptr then
					Result := c_set_pointer_stack_value (dep, a_loc_type, pos, ptr)
				end
			when Reference_type then
				if value /= Void then
					Result := c_set_reference_stack_value (dep, a_loc_type, pos, $value.to_pointer)
				else
					Result := c_set_void_stack_value (dep, a_loc_type, pos)
				end
			else
				Result := 2
			end
			debug ("rt_dbg_internal")
				print ("set_stack_value_at (dep=" + dep.out + ", loc_type=" + a_loc_type.out + ", pos=" + pos.out + ", ...) -> " + Result.out + " %N")
				print ("set_stack_value_at: check modification -> ")
				if attached stack_value_at (dep, a_loc_type, pos, a_rt_type) as a then
					print (a.generating_type.name + ": " + a.out + "%N")
				else
					print (" Void %N")
				end
			end
		end

	frozen c_set_boolean_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_bool: BOOLEAN): INTEGER_32
		external
			"C inline use %"eif_debug.h%""
		alias
			"[
				#ifdef WORKBENCH
					EIF_TYPED_VALUE a_val; a_val.type = SK_BOOL; a_val.it_bool = (EIF_BOOLEAN) $a_bool;
					return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val);
				#else
					return 0;
				#endif
			]"
		end

	frozen c_set_character_8_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_ch8: CHARACTER_8): INTEGER_32
		external
			"C inline use %"eif_debug.h%""
		alias
			"[
				#ifdef WORKBENCH
					EIF_TYPED_VALUE a_val; a_val.type = SK_CHAR; a_val.it_c1 = (EIF_CHARACTER) $a_ch8;
					return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val);
				#else
					return 0;
				#endif
			]"
		end

	frozen c_set_character_32_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_ch32: CHARACTER_32): INTEGER_32
		external
			"C inline use %"eif_debug.h%""
		alias
			"[
				#ifdef WORKBENCH
					EIF_TYPED_VALUE a_val; a_val.type = SK_WCHAR; a_val.it_c4 = (EIF_WIDE_CHAR) $a_ch32;
					return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val);
				#else
					return 0;
				#endif
			]"
		end

	frozen c_set_natural_8_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_n8: NATURAL_8): INTEGER_32
		external
			"C inline use %"eif_debug.h%""
		alias
			"[
				#ifdef WORKBENCH
					EIF_TYPED_VALUE a_val; a_val.type = SK_UINT8; a_val.it_n1 = (EIF_NATURAL_8) $a_n8;
					return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val);
				#else
					return 0;
				#endif
			]"
		end

	frozen c_set_natural_16_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_n16: NATURAL_16): INTEGER_32
		external
			"C inline use %"eif_debug.h%""
		alias
			"[
				#ifdef WORKBENCH
					EIF_TYPED_VALUE a_val; a_val.type = SK_UINT16; a_val.it_n2 = (EIF_NATURAL_16) $a_n16;
					return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val);
				#else
					return 0;
				#endif
			]"
		end

	frozen c_set_natural_32_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_n32: NATURAL_32): INTEGER_32
		external
			"C inline use %"eif_debug.h%""
		alias
			"[
				#ifdef WORKBENCH
					EIF_TYPED_VALUE a_val; a_val.type = SK_UINT32; a_val.it_n4 = (EIF_NATURAL_32) $a_n32;
					return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val);
				#else
					return 0;
				#endif
			]"
		end

	frozen c_set_natural_64_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_n64: NATURAL_64): INTEGER_32
		external
			"C inline use %"eif_debug.h%""
		alias
			"[
				#ifdef WORKBENCH
					EIF_TYPED_VALUE a_val; a_val.type = SK_UINT64; a_val.it_n8 = (EIF_NATURAL_64) $a_n64;
					return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val);
				#else
					return 0;
				#endif
			]"
		end

	frozen c_set_integer_8_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_i8: INTEGER_8): INTEGER_32
		external
			"C inline use %"eif_debug.h%""
		alias
			"[
				#ifdef WORKBENCH
					EIF_TYPED_VALUE a_val; a_val.type = SK_INT8; a_val.it_i1 = (EIF_INTEGER_8) $a_i8;
					return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val);
				#else
					return 0;
				#endif
			]"
		end

	frozen c_set_integer_16_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_i16: INTEGER_16): INTEGER_32
		external
			"C inline use %"eif_debug.h%""
		alias
			"[
				#ifdef WORKBENCH
					EIF_TYPED_VALUE a_val; a_val.type = SK_INT16; a_val.it_i2 = (EIF_INTEGER_16) $a_i16;
					return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val);
				#else
					return 0;
				#endif
			]"
		end

	frozen c_set_integer_32_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_i32: INTEGER_32): INTEGER_32
		external
			"C inline use %"eif_debug.h%""
		alias
			"[
				#ifdef WORKBENCH
					EIF_TYPED_VALUE a_val; a_val.type = SK_INT32; a_val.it_i4 = (EIF_INTEGER_32) $a_i32;
					return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val);
				#else
					return 0;
				#endif
			]"
		end

	frozen c_set_integer_64_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_i64: INTEGER_64): INTEGER_32
		external
			"C inline use %"eif_debug.h%""
		alias
			"[
				#ifdef WORKBENCH
					EIF_TYPED_VALUE a_val; a_val.type = SK_INT64; a_val.it_i8 = (EIF_INTEGER_64) $a_i64;
					return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val);
				#else
					return 0;
				#endif
			]"
		end

	frozen c_set_real_32_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_i32: REAL_32): INTEGER_32
		external
			"C inline use %"eif_debug.h%""
		alias
			"[
				#ifdef WORKBENCH
					EIF_TYPED_VALUE a_val; a_val.type = SK_REAL32; a_val.it_r4 = (EIF_REAL_32) $a_i32;
					return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val);
				#else
					return 0;
				#endif
			]"
		end

	frozen c_set_real_64_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_i64: REAL_64): INTEGER_32
		external
			"C inline use %"eif_debug.h%""
		alias
			"[
				#ifdef WORKBENCH
					EIF_TYPED_VALUE a_val; a_val.type = SK_REAL64; a_val.it_r8 = (EIF_REAL_64) $a_i64;
					return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val);
				#else
					return 0;
				#endif
			]"
		end

	frozen c_set_pointer_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_p: POINTER): INTEGER_32
		external
			"C inline use %"eif_debug.h%""
		alias
			"[
				#ifdef WORKBENCH
					EIF_TYPED_VALUE a_val; a_val.type = SK_POINTER; a_val.it_p = (EIF_POINTER) $a_p;
					return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val);
				#else
					return 0;
				#endif
			]"
		end

	frozen c_set_reference_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_ref: POINTER): INTEGER_32
		require
			a_ref_not_null: a_ref /= default_pointer
		external
			"C inline use %"eif_debug.h%""
		alias
			"[
				#ifdef WORKBENCH
					EIF_TYPED_VALUE a_val; 
					a_val.type = SK_REF; 
					a_val.it_ref = (EIF_REFERENCE) &($a_ref);
					return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val);
				#else
					return 0;
				#endif
			]"
		end

	frozen c_set_void_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32): INTEGER_32
		external
			"C inline use %"eif_debug.h%""
		alias
			"[
				#ifdef WORKBENCH
					EIF_TYPED_VALUE a_val; 
					a_val.type = SK_VOID; 
					a_val.it_ref = (char*) 0;
					return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val);
				#else
					return 0;
				#endif
			]"
		end
	
feature -- Testing

	c_rt_set_is_inside_rt_eiffel_code (v: INTEGER_32)
		external
			"C inline use %"eif_debug.h%""
		alias
			"[
				#ifdef WORKBENCH
					EIF_GET_CONTEXT; is_inside_rt_eiffel_code = $v;
				#endif
			]"
		end

	test_locals (dep: INTEGER_32; loc_pos: INTEGER_32; val: ANY; a_rt_type: NATURAL_32)
		local
			s: STRING_8
			retried: BOOLEAN
		do
			if not retried then
				c_rt_set_is_inside_rt_eiffel_code (1)
				s := "----------------------------------%N"
				s.append ("Loc #" + loc_pos.out + "(stack depth=" + dep.out + ")")
				if val /= Void then
					s.append (": should be " + val.generating_type.name)
				end
				s.append ("%N")
				print (s)
				s.append (" -> ")
				if attached stack_value_at (dep, Rt_dlt_localvar, loc_pos, a_rt_type) as a then
					s.append (a.generating_type.name + "=" + a.out)
				else
					s.append ("Void object")
				end
				s.append ("%N")
				print (s)
				c_rt_set_is_inside_rt_eiffel_code (0)
			else
				print ("Rescued%N")
				c_rt_set_is_inside_rt_eiffel_code (0)
			end
		rescue
			retried := True
			retry
		end

	test_set_local (dep: INTEGER_32; loc_pos: INTEGER_32; val: ANY; a_rt_type: NATURAL_32)
		local
			s: STRING_8
			r: INTEGER_32
			retried: BOOLEAN
		do
			if not retried then
				c_rt_set_is_inside_rt_eiffel_code (1)
				s := "----------------------------------%N"
				s.append ("SetLoc #" + loc_pos.out + "(stack depth=" + dep.out + ")")
				if val /= Void then
					s.append (": value " + val.generating_type.name)
				else
					s.append (": value Void")
				end
				s.append ("%N")
				print (s)
				r := set_stack_value_at (dep, Rt_dlt_localvar, loc_pos, a_rt_type, val)
				s.append (" -> ")
				s.append ("Result = " + r.out)
				s.append ("%N")
				print (s)
				c_rt_set_is_inside_rt_eiffel_code (0)
			else
				print ("Rescued%N")
				c_rt_set_is_inside_rt_eiffel_code (0)
			end
		rescue
			retried := True
			retry
		end
	
feature {NONE} -- Implementation

	Reflected_object: REFLECTED_REFERENCE_OBJECT
			-- To enable object introspection.
		once
			create Result.make (Current)
		end

	Reflector: REFLECTOR
			-- To enable type discovery
		once
			create Result
		end
	
note
	library: "EiffelBase: Library of reusable components for Eiffel."
	copyright: "Copyright (c) 1984-2017, Eiffel Software and others"
	license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
	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 -- class RT_DBG_INTERNAL

Generated by ISE EiffelStudio