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 8
8
require 'tmpdir'
9
9
require 'tempfile'
10
10
require 'timeout'
11
- require_relative 'variable'
12
11
require_relative 'variable_inspector'
13
12
14
13
module DEBUGGER__
Original file line number Diff line number Diff line change 4
4
require 'irb/completion'
5
5
require 'tmpdir'
6
6
require 'fileutils'
7
- require_relative 'variable'
8
7
require_relative 'variable_inspector'
9
8
10
9
module DEBUGGER__
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
- require_relative 'variable'
4
3
require_relative 'limited_pp'
5
4
6
5
module DEBUGGER__
@@ -83,4 +82,55 @@ def == other
83
82
end
84
83
end
85
84
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
86
136
end
You can’t perform that action at this time.
0 commit comments