rubysl-irb 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/LICENSE +25 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/irb/cmd/chws.rb +33 -0
- data/lib/irb/cmd/fork.rb +39 -0
- data/lib/irb/cmd/help.rb +31 -0
- data/lib/irb/cmd/load.rb +67 -0
- data/lib/irb/cmd/nop.rb +39 -0
- data/lib/irb/cmd/pushws.rb +39 -0
- data/lib/irb/cmd/subirb.rb +43 -0
- data/lib/irb/completion.rb +205 -0
- data/lib/irb/context.rb +255 -0
- data/lib/irb/ext/change-ws.rb +62 -0
- data/lib/irb/ext/history.rb +110 -0
- data/lib/irb/ext/loader.rb +120 -0
- data/lib/irb/ext/math-mode.rb +37 -0
- data/lib/irb/ext/multi-irb.rb +241 -0
- data/lib/irb/ext/save-history.rb +70 -0
- data/lib/irb/ext/tracer.rb +61 -0
- data/lib/irb/ext/use-loader.rb +65 -0
- data/lib/irb/ext/workspaces.rb +56 -0
- data/lib/irb/extend-command.rb +264 -0
- data/lib/irb/frame.rb +67 -0
- data/lib/irb/help.rb +35 -0
- data/lib/irb/init.rb +258 -0
- data/lib/irb/input-method.rb +120 -0
- data/lib/irb/lc/error.rb +30 -0
- data/lib/irb/lc/help-message.rb +37 -0
- data/lib/irb/lc/ja/error.rb +27 -0
- data/lib/irb/lc/ja/help-message +36 -0
- data/lib/irb/locale.rb +184 -0
- data/lib/irb/notifier.rb +145 -0
- data/lib/irb/output-method.rb +85 -0
- data/lib/irb/rubinius.rb +55 -0
- data/lib/irb/ruby-lex.rb +1149 -0
- data/lib/irb/ruby-token.rb +273 -0
- data/lib/irb/slex.rb +285 -0
- data/lib/irb/version.rb +16 -0
- data/lib/irb/workspace.rb +107 -0
- data/lib/irb/ws-for-case-2.rb +15 -0
- data/lib/irb/xmp.rb +86 -0
- data/lib/irb.rb +1 -0
- data/lib/rubysl/irb/irb.rb +356 -0
- data/lib/rubysl/irb/version.rb +5 -0
- data/lib/rubysl/irb.rb +2 -0
- data/rubysl-irb.gemspec +31 -0
- metadata +219 -0
data/lib/irb/version.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#
|
2
|
+
# irb/version.rb - irb version definition file
|
3
|
+
# $Release Version: 0.9.5$
|
4
|
+
# $Revision: 11708 $
|
5
|
+
# $Date: 2007-02-12 15:01:19 -0800 (Mon, 12 Feb 2007) $
|
6
|
+
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
|
7
|
+
#
|
8
|
+
# --
|
9
|
+
#
|
10
|
+
#
|
11
|
+
#
|
12
|
+
|
13
|
+
module IRB
|
14
|
+
@RELEASE_VERSION = "0.9.5"
|
15
|
+
@LAST_UPDATE_DATE = "05/04/13"
|
16
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
#
|
2
|
+
# irb/workspace-binding.rb -
|
3
|
+
# $Release Version: 0.9.5$
|
4
|
+
# $Revision: 11708 $
|
5
|
+
# $Date: 2007-02-12 15:01:19 -0800 (Mon, 12 Feb 2007) $
|
6
|
+
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
7
|
+
#
|
8
|
+
# --
|
9
|
+
#
|
10
|
+
#
|
11
|
+
#
|
12
|
+
module IRB
|
13
|
+
class WorkSpace
|
14
|
+
# create new workspace. set self to main if specified, otherwise
|
15
|
+
# inherit main from TOPLEVEL_BINDING.
|
16
|
+
def initialize(*main)
|
17
|
+
if main[0].kind_of?(Binding)
|
18
|
+
@binding = main.shift
|
19
|
+
elsif IRB.conf[:SINGLE_IRB]
|
20
|
+
@binding = TOPLEVEL_BINDING
|
21
|
+
else
|
22
|
+
case IRB.conf[:CONTEXT_MODE]
|
23
|
+
when 0 # binding in proc on TOPLEVEL_BINDING
|
24
|
+
@binding = eval("proc{binding}.call",
|
25
|
+
TOPLEVEL_BINDING,
|
26
|
+
__FILE__,
|
27
|
+
__LINE__)
|
28
|
+
when 1 # binding in loaded file
|
29
|
+
require "tempfile"
|
30
|
+
f = Tempfile.open("irb-binding")
|
31
|
+
f.print <<EOF
|
32
|
+
$binding = binding
|
33
|
+
EOF
|
34
|
+
f.close
|
35
|
+
load f.path
|
36
|
+
@binding = $binding
|
37
|
+
|
38
|
+
when 2 # binding in loaded file(thread use)
|
39
|
+
unless defined? BINDING_QUEUE
|
40
|
+
require "thread"
|
41
|
+
|
42
|
+
IRB.const_set("BINDING_QUEUE", SizedQueue.new(1))
|
43
|
+
Thread.abort_on_exception = true
|
44
|
+
Thread.start do
|
45
|
+
eval "require \"irb/ws-for-case-2\"", TOPLEVEL_BINDING, __FILE__, __LINE__
|
46
|
+
end
|
47
|
+
Thread.pass
|
48
|
+
end
|
49
|
+
@binding = BINDING_QUEUE.pop
|
50
|
+
|
51
|
+
when 3 # binging in function on TOPLEVEL_BINDING(default)
|
52
|
+
@binding = eval("def irb_binding; binding; end; irb_binding",
|
53
|
+
TOPLEVEL_BINDING,
|
54
|
+
__FILE__,
|
55
|
+
__LINE__ - 3)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
if main.empty?
|
59
|
+
@main = eval("self", @binding)
|
60
|
+
else
|
61
|
+
@main = main[0]
|
62
|
+
IRB.conf[:__MAIN__] = @main
|
63
|
+
case @main
|
64
|
+
when Module
|
65
|
+
@binding = eval("IRB.conf[:__MAIN__].module_eval('binding', __FILE__, __LINE__)", @binding, __FILE__, __LINE__)
|
66
|
+
else
|
67
|
+
begin
|
68
|
+
@binding = eval("IRB.conf[:__MAIN__].instance_eval('binding', __FILE__, __LINE__)", @binding, __FILE__, __LINE__)
|
69
|
+
rescue TypeError
|
70
|
+
IRB.fail CantChangeBinding, @main.inspect
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
eval("_=nil", @binding)
|
75
|
+
end
|
76
|
+
|
77
|
+
attr_reader :binding
|
78
|
+
attr_reader :main
|
79
|
+
|
80
|
+
def evaluate(context, statements, file = __FILE__, line = __LINE__)
|
81
|
+
eval(statements, @binding, file, line)
|
82
|
+
end
|
83
|
+
|
84
|
+
# error message manipulator
|
85
|
+
def filter_backtrace(bt)
|
86
|
+
case IRB.conf[:CONTEXT_MODE]
|
87
|
+
when 0
|
88
|
+
return nil if bt =~ /\(irb_local_binding\)/
|
89
|
+
when 1
|
90
|
+
if(bt =~ %r!/tmp/irb-binding! or
|
91
|
+
bt =~ %r!irb/.*\.rb! or
|
92
|
+
bt =~ /irb\.rb/)
|
93
|
+
return nil
|
94
|
+
end
|
95
|
+
when 2
|
96
|
+
return nil if bt =~ /irb\/.*\.rb/
|
97
|
+
when 3
|
98
|
+
return nil if bt =~ /irb\/.*\.rb/
|
99
|
+
bt.sub!(/:\s*in `irb_binding'/){""}
|
100
|
+
end
|
101
|
+
bt
|
102
|
+
end
|
103
|
+
|
104
|
+
def IRB.delete_caller
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#
|
2
|
+
# irb/ws-for-case-2.rb -
|
3
|
+
# $Release Version: 0.9.5$
|
4
|
+
# $Revision: 11708 $
|
5
|
+
# $Date: 2007-02-12 15:01:19 -0800 (Mon, 12 Feb 2007) $
|
6
|
+
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
7
|
+
#
|
8
|
+
# --
|
9
|
+
#
|
10
|
+
#
|
11
|
+
#
|
12
|
+
|
13
|
+
while true
|
14
|
+
IRB::BINDING_QUEUE.push b = binding
|
15
|
+
end
|
data/lib/irb/xmp.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
#
|
2
|
+
# xmp.rb - irb version of gotoken xmp
|
3
|
+
# $Release Version: 0.9$
|
4
|
+
# $Revision: 11708 $
|
5
|
+
# $Date: 2007-02-12 15:01:19 -0800 (Mon, 12 Feb 2007) $
|
6
|
+
# by Keiju ISHITSUKA(Nippon Rational Inc.)
|
7
|
+
#
|
8
|
+
# --
|
9
|
+
#
|
10
|
+
#
|
11
|
+
#
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
require "irb/frame"
|
15
|
+
|
16
|
+
class XMP
|
17
|
+
@RCS_ID='-$Id: xmp.rb 11708 2007-02-12 23:01:19Z shyouhei $-'
|
18
|
+
|
19
|
+
def initialize(bind = nil)
|
20
|
+
IRB.init_config(nil)
|
21
|
+
#IRB.parse_opts
|
22
|
+
#IRB.load_modules
|
23
|
+
|
24
|
+
IRB.conf[:PROMPT_MODE] = :XMP
|
25
|
+
|
26
|
+
bind = IRB::Frame.top(1) unless bind
|
27
|
+
ws = IRB::WorkSpace.new(bind)
|
28
|
+
@io = StringInputMethod.new
|
29
|
+
@irb = IRB::Irb.new(ws, @io)
|
30
|
+
@irb.context.ignore_sigint = false
|
31
|
+
|
32
|
+
# IRB.conf[:IRB_RC].call(@irb.context) if IRB.conf[:IRB_RC]
|
33
|
+
IRB.conf[:MAIN_CONTEXT] = @irb.context
|
34
|
+
end
|
35
|
+
|
36
|
+
def puts(exps)
|
37
|
+
@io.puts exps
|
38
|
+
|
39
|
+
if @irb.context.ignore_sigint
|
40
|
+
begin
|
41
|
+
trap_proc_b = trap("SIGINT"){@irb.signal_handle}
|
42
|
+
catch(:IRB_EXIT) do
|
43
|
+
@irb.eval_input
|
44
|
+
end
|
45
|
+
ensure
|
46
|
+
trap("SIGINT", trap_proc_b)
|
47
|
+
end
|
48
|
+
else
|
49
|
+
catch(:IRB_EXIT) do
|
50
|
+
@irb.eval_input
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class StringInputMethod < IRB::InputMethod
|
56
|
+
def initialize
|
57
|
+
super
|
58
|
+
@exps = []
|
59
|
+
end
|
60
|
+
|
61
|
+
def eof?
|
62
|
+
@exps.empty?
|
63
|
+
end
|
64
|
+
|
65
|
+
def gets
|
66
|
+
while l = @exps.shift
|
67
|
+
next if /^\s+$/ =~ l
|
68
|
+
l.concat "\n"
|
69
|
+
print @prompt, l
|
70
|
+
break
|
71
|
+
end
|
72
|
+
l
|
73
|
+
end
|
74
|
+
|
75
|
+
def puts(exps)
|
76
|
+
@exps.concat exps.split(/\n/)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def xmp(exps, bind = nil)
|
82
|
+
bind = IRB::Frame.top(1) unless bind
|
83
|
+
xmp = XMP.new(bind)
|
84
|
+
xmp.puts exps
|
85
|
+
xmp
|
86
|
+
end
|
data/lib/irb.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "rubysl/irb"
|
@@ -0,0 +1,356 @@
|
|
1
|
+
#
|
2
|
+
# irb.rb - irb main module
|
3
|
+
# $Release Version: 0.9.5 $
|
4
|
+
# $Revision: 15408 $
|
5
|
+
# $Date: 2008-02-08 07:44:54 -0800 (Fri, 08 Feb 2008) $
|
6
|
+
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
7
|
+
#
|
8
|
+
# --
|
9
|
+
#
|
10
|
+
#
|
11
|
+
#
|
12
|
+
require "e2mmap"
|
13
|
+
|
14
|
+
require "irb/init"
|
15
|
+
require "irb/context"
|
16
|
+
require "irb/extend-command"
|
17
|
+
#require "irb/workspace"
|
18
|
+
|
19
|
+
require "irb/ruby-lex"
|
20
|
+
require "irb/input-method"
|
21
|
+
require "irb/locale"
|
22
|
+
|
23
|
+
STDOUT.sync = true
|
24
|
+
|
25
|
+
module IRB
|
26
|
+
@RCS_ID='-$Id: irb.rb 15408 2008-02-08 15:44:54Z nobu $-'
|
27
|
+
|
28
|
+
class Abort < Exception;end
|
29
|
+
|
30
|
+
#
|
31
|
+
@CONF = {}
|
32
|
+
|
33
|
+
def IRB.conf
|
34
|
+
@CONF
|
35
|
+
end
|
36
|
+
|
37
|
+
# IRB version method
|
38
|
+
def IRB.version
|
39
|
+
if v = @CONF[:VERSION] then return v end
|
40
|
+
|
41
|
+
require "irb/version"
|
42
|
+
rv = @RELEASE_VERSION.sub(/\.0/, "")
|
43
|
+
@CONF[:VERSION] = format("irb %s(%s)", rv, @LAST_UPDATE_DATE)
|
44
|
+
end
|
45
|
+
|
46
|
+
def IRB.CurrentContext
|
47
|
+
IRB.conf[:MAIN_CONTEXT]
|
48
|
+
end
|
49
|
+
|
50
|
+
# initialize IRB and start TOP_LEVEL irb
|
51
|
+
def IRB.start(ap_path = nil)
|
52
|
+
$0 = File::basename(ap_path, ".rb") if ap_path
|
53
|
+
|
54
|
+
IRB.setup(ap_path)
|
55
|
+
|
56
|
+
if @CONF[:IRB_CLASS]
|
57
|
+
klass = @CONF[:IRB_CLASS]
|
58
|
+
else
|
59
|
+
klass = Irb
|
60
|
+
end
|
61
|
+
|
62
|
+
if @CONF[:SCRIPT]
|
63
|
+
irb = klass.new(nil, @CONF[:SCRIPT])
|
64
|
+
else
|
65
|
+
irb = klass.new
|
66
|
+
end
|
67
|
+
|
68
|
+
@CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
|
69
|
+
@CONF[:MAIN_CONTEXT] = irb.context
|
70
|
+
|
71
|
+
trap("SIGINT") do
|
72
|
+
irb.signal_handle
|
73
|
+
end
|
74
|
+
|
75
|
+
catch(:IRB_EXIT) do
|
76
|
+
irb.eval_input
|
77
|
+
end
|
78
|
+
# print "\n"
|
79
|
+
end
|
80
|
+
|
81
|
+
def IRB.irb_exit(irb, ret)
|
82
|
+
throw :IRB_EXIT, ret
|
83
|
+
end
|
84
|
+
|
85
|
+
def IRB.irb_abort(irb, exception = Abort)
|
86
|
+
if defined? Thread
|
87
|
+
irb.context.thread.raise exception, "abort then interrupt!!"
|
88
|
+
else
|
89
|
+
raise exception, "abort then interrupt!!"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
#
|
94
|
+
# irb interpriter main routine
|
95
|
+
#
|
96
|
+
class Irb
|
97
|
+
def initialize(workspace = nil, input_method = nil, output_method = nil)
|
98
|
+
@context = Context.new(self, workspace, input_method, output_method)
|
99
|
+
@context.main.extend ExtendCommandBundle
|
100
|
+
@signal_status = :IN_IRB
|
101
|
+
|
102
|
+
@scanner = RubyLex.new
|
103
|
+
@scanner.exception_on_syntax_error = false
|
104
|
+
end
|
105
|
+
attr_reader :context
|
106
|
+
attr_accessor :scanner
|
107
|
+
|
108
|
+
def eval_input
|
109
|
+
@scanner.set_prompt do
|
110
|
+
|ltype, indent, continue, line_no|
|
111
|
+
if ltype
|
112
|
+
f = @context.prompt_s
|
113
|
+
elsif continue
|
114
|
+
f = @context.prompt_c
|
115
|
+
elsif indent > 0
|
116
|
+
f = @context.prompt_n
|
117
|
+
else @context.prompt_i
|
118
|
+
f = @context.prompt_i
|
119
|
+
end
|
120
|
+
f = "" unless f
|
121
|
+
if @context.prompting?
|
122
|
+
@context.io.prompt = p = prompt(f, ltype, indent, line_no)
|
123
|
+
else
|
124
|
+
@context.io.prompt = p = ""
|
125
|
+
end
|
126
|
+
if @context.auto_indent_mode
|
127
|
+
unless ltype
|
128
|
+
ind = prompt(@context.prompt_i, ltype, indent, line_no)[/.*\z/].size +
|
129
|
+
indent * 2 - p.size
|
130
|
+
ind += 2 if continue
|
131
|
+
@context.io.prompt = p + " " * ind if ind > 0
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
@scanner.set_input(@context.io) do
|
137
|
+
signal_status(:IN_INPUT) do
|
138
|
+
if l = @context.io.gets
|
139
|
+
print l if @context.verbose?
|
140
|
+
else
|
141
|
+
if @context.ignore_eof? and @context.io.readable_atfer_eof?
|
142
|
+
l = "\n"
|
143
|
+
if @context.verbose?
|
144
|
+
printf "Use \"exit\" to leave %s\n", @context.ap_name
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
l
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
process_statements
|
153
|
+
end
|
154
|
+
|
155
|
+
def process_statements
|
156
|
+
@scanner.each_top_level_statement do |line, line_no|
|
157
|
+
signal_status(:IN_EVAL) do
|
158
|
+
begin
|
159
|
+
line.untaint
|
160
|
+
@context.evaluate(line, line_no)
|
161
|
+
output_value if @context.echo?
|
162
|
+
exc = nil
|
163
|
+
rescue Interrupt => exc
|
164
|
+
rescue SystemExit, SignalException
|
165
|
+
raise
|
166
|
+
rescue Exception => exc
|
167
|
+
end
|
168
|
+
if exc
|
169
|
+
print exc.class, ": ", exc, "\n"
|
170
|
+
if exc.backtrace[0] =~ /irb(2)?(\/.*|-.*|\.rb)?:/ && exc.class.to_s !~ /^IRB/
|
171
|
+
irb_bug = true
|
172
|
+
else
|
173
|
+
irb_bug = false
|
174
|
+
end
|
175
|
+
|
176
|
+
messages = []
|
177
|
+
lasts = []
|
178
|
+
levels = 0
|
179
|
+
for m in exc.backtrace
|
180
|
+
m = @context.workspace.filter_backtrace(m) unless irb_bug
|
181
|
+
if m
|
182
|
+
if messages.size < @context.back_trace_limit
|
183
|
+
messages.push "\tfrom "+m
|
184
|
+
else
|
185
|
+
lasts.push "\tfrom "+m
|
186
|
+
if lasts.size > @context.back_trace_limit
|
187
|
+
lasts.shift
|
188
|
+
levels += 1
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
print messages.join("\n"), "\n"
|
194
|
+
unless lasts.empty?
|
195
|
+
printf "... %d levels...\n", levels if levels > 0
|
196
|
+
print lasts.join("\n")
|
197
|
+
end
|
198
|
+
print "Maybe IRB bug!!\n" if irb_bug
|
199
|
+
end
|
200
|
+
if $SAFE > 2
|
201
|
+
abort "Error: irb does not work for $SAFE level higher than 2"
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
def suspend_name(path = nil, name = nil)
|
208
|
+
@context.irb_path, back_path = path, @context.irb_path if path
|
209
|
+
@context.irb_name, back_name = name, @context.irb_name if name
|
210
|
+
begin
|
211
|
+
yield back_path, back_name
|
212
|
+
ensure
|
213
|
+
@context.irb_path = back_path if path
|
214
|
+
@context.irb_name = back_name if name
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
def suspend_workspace(workspace)
|
219
|
+
@context.workspace, back_workspace = workspace, @context.workspace
|
220
|
+
begin
|
221
|
+
yield back_workspace
|
222
|
+
ensure
|
223
|
+
@context.workspace = back_workspace
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
def suspend_input_method(input_method)
|
228
|
+
back_io = @context.io
|
229
|
+
@context.instance_eval{@io = input_method}
|
230
|
+
begin
|
231
|
+
yield back_io
|
232
|
+
ensure
|
233
|
+
@context.instance_eval{@io = back_io}
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
def suspend_context(context)
|
238
|
+
@context, back_context = context, @context
|
239
|
+
begin
|
240
|
+
yield back_context
|
241
|
+
ensure
|
242
|
+
@context = back_context
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
def signal_handle
|
247
|
+
unless @context.ignore_sigint?
|
248
|
+
print "\nabort!!\n" if @context.verbose?
|
249
|
+
exit
|
250
|
+
end
|
251
|
+
|
252
|
+
case @signal_status
|
253
|
+
when :IN_INPUT
|
254
|
+
print "^C\n"
|
255
|
+
raise RubyLex::TerminateLineInput
|
256
|
+
when :IN_EVAL
|
257
|
+
IRB.irb_abort(self)
|
258
|
+
when :IN_LOAD
|
259
|
+
IRB.irb_abort(self, LoadAbort)
|
260
|
+
when :IN_IRB
|
261
|
+
# ignore
|
262
|
+
else
|
263
|
+
# ignore other cases as well
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
def signal_status(status)
|
268
|
+
return yield if @signal_status == :IN_LOAD
|
269
|
+
|
270
|
+
signal_status_back = @signal_status
|
271
|
+
@signal_status = status
|
272
|
+
begin
|
273
|
+
yield
|
274
|
+
ensure
|
275
|
+
@signal_status = signal_status_back
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
def prompt(prompt, ltype, indent, line_no)
|
280
|
+
p = prompt.dup
|
281
|
+
p.gsub!(/%([0-9]+)?([a-zA-Z])/) do
|
282
|
+
case $2
|
283
|
+
when "N"
|
284
|
+
@context.irb_name
|
285
|
+
when "m"
|
286
|
+
@context.main.to_s
|
287
|
+
when "M"
|
288
|
+
@context.main.inspect
|
289
|
+
when "l"
|
290
|
+
ltype
|
291
|
+
when "i"
|
292
|
+
if $1
|
293
|
+
format("%" + $1 + "d", indent)
|
294
|
+
else
|
295
|
+
indent.to_s
|
296
|
+
end
|
297
|
+
when "n"
|
298
|
+
if $1
|
299
|
+
format("%" + $1 + "d", line_no)
|
300
|
+
else
|
301
|
+
line_no.to_s
|
302
|
+
end
|
303
|
+
when "%"
|
304
|
+
"%"
|
305
|
+
end
|
306
|
+
end
|
307
|
+
p
|
308
|
+
end
|
309
|
+
|
310
|
+
def output_value
|
311
|
+
if @context.inspect?
|
312
|
+
printf @context.return_format, @context.last_value.inspect
|
313
|
+
else
|
314
|
+
printf @context.return_format, @context.last_value
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
def inspect
|
319
|
+
ary = []
|
320
|
+
for iv in instance_variables
|
321
|
+
case iv
|
322
|
+
when "@signal_status"
|
323
|
+
ary.push format("%s=:%s", iv, @signal_status.id2name)
|
324
|
+
when "@context"
|
325
|
+
ary.push format("%s=%s", iv, eval(iv).__to_s__)
|
326
|
+
else
|
327
|
+
ary.push format("%s=%s", iv, eval(iv))
|
328
|
+
end
|
329
|
+
end
|
330
|
+
format("#<%s: %s>", self.class, ary.join(", "))
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
# Singleton method
|
335
|
+
def @CONF.inspect
|
336
|
+
IRB.version unless self[:VERSION]
|
337
|
+
|
338
|
+
array = []
|
339
|
+
for k, v in sort{|a1, a2| a1[0].id2name <=> a2[0].id2name}
|
340
|
+
case k
|
341
|
+
when :MAIN_CONTEXT, :__TMP__EHV__
|
342
|
+
array.push format("CONF[:%s]=...myself...", k.id2name)
|
343
|
+
when :PROMPT
|
344
|
+
s = v.collect{
|
345
|
+
|kk, vv|
|
346
|
+
ss = vv.collect{|kkk, vvv| ":#{kkk.id2name}=>#{vvv.inspect}"}
|
347
|
+
format(":%s=>{%s}", kk.id2name, ss.join(", "))
|
348
|
+
}
|
349
|
+
array.push format("CONF[:%s]={%s}", k.id2name, s.join(", "))
|
350
|
+
else
|
351
|
+
array.push format("CONF[:%s]=%s", k.id2name, v.inspect)
|
352
|
+
end
|
353
|
+
end
|
354
|
+
array.join("\n")
|
355
|
+
end
|
356
|
+
end
|