1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
#
# workspace-binding.rb -
# $Release Version: $
# $Revision: 1.1 $
# $Date: 1997/08/08 00:57:08 $
# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
#
# --
#
#
#
module IRB
# create new workspace.
# (JP: workspace. mainselfȤ. ά,
# TOPLEVEL_BINDINGmainΤޤȤ. )
def IRB.workspace_binding(*main)
if @CONF[:SINGLE_IRB]
bind = TOPLEVEL_BINDING
else
case @CONF[:CONTEXT_MODE]
when 0
bind = eval("proc{binding}.call",
TOPLEVEL_BINDING,
"(irb_local_binding)",
1)
when 1
require "tempfile"
f = Tempfile.open("irb-binding")
f.print <<EOF
$binding = binding
EOF
f.close
load f.path
bind = $binding
when 2
unless defined? BINDING_QUEUE
require "thread"
IRB.const_set("BINDING_QUEUE", SizedQueue.new(1))
Thread.abort_on_exception = true
Thread.start do
eval "require \"irb/workspace-binding-2\"", TOPLEVEL_BINDING, __FILE__, __LINE__
end
Thread.pass
end
bind = BINDING_QUEUE.pop
when 3
bind = eval("def irb_binding; binding; end; irb_binding",
TOPLEVEL_BINDING,
__FILE__,
__LINE__ - 3)
end
end
unless main.empty?
@CONF[:__MAIN__] = main[0]
case main[0]
when Module
bind = eval("IRB.conf[:__MAIN__].module_eval('binding')", bind)
else
begin
bind = eval("IRB.conf[:__MAIN__].instance_eval('binding')", bind)
rescue TypeError
IRB.fail CanNotChangeBinding, main[0].inspect
end
end
end
eval("_=nil", bind)
bind
end
def IRB.delete_caller
end
end
|