File tree Expand file tree Collapse file tree 4 files changed +51
-59
lines changed Expand file tree Collapse file tree 4 files changed +51
-59
lines changed Original file line number Diff line number Diff line change 99require 'tmpdir'
1010require 'tempfile'
1111require 'timeout'
12- require_relative 'variable'
1312require_relative 'variable_inspector'
1413
1514module DEBUGGER__
Original file line number Diff line number Diff line change 44require 'irb/completion'
55require 'tmpdir'
66require 'fileutils'
7- require_relative 'variable'
87require_relative 'variable_inspector'
98
109module DEBUGGER__
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
3- require_relative 'variable'
43require_relative 'limited_pp'
54
65module DEBUGGER__
@@ -83,4 +82,55 @@ def == other
8382 end
8483 end
8584 end
85+
86+ class Variable
87+ attr_reader :name , :value
88+
89+ def initialize ( name :, value :, internal : false )
90+ @name = name
91+ @value = value
92+ @is_internal = internal
93+ end
94+
95+ def internal?
96+ @is_internal
97+ end
98+
99+ def self . internal name :, value :
100+ new ( name : name , value : value , internal : true )
101+ end
102+
103+ def inspect_value
104+ @inspect_value ||= if VariableInspector ::NaiveString === @value
105+ @value . str . dump
106+ else
107+ VariableInspector . value_inspect ( @value )
108+ end
109+ end
110+
111+ def value_type_name
112+ klass = M_CLASS . bind_call ( @value )
113+
114+ begin
115+ M_NAME . bind_call ( klass ) || klass . to_s
116+ rescue Exception => e
117+ "<Error: #{ e . message } (#{ e . backtrace . first } >"
118+ end
119+ end
120+
121+ def ==( other )
122+ other . instance_of? ( self . class ) &&
123+ @name == other . name &&
124+ @value == other . value &&
125+ @is_internal == other . internal?
126+ end
127+
128+ def inspect
129+ "#<Variable name=#{ @name . inspect } value=#{ inspect_value } #{ @is_internal ? " internal" : "" } >"
130+ end
131+
132+ # TODO: Replace with Reflection helpers once they are merged
133+ # https://github.com/ruby/debug/pull/1002
134+ M_CLASS = method ( :class ) . unbind
135+ end
86136end
You can’t perform that action at this time.
0 commit comments