mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Remove e2mmap dependency
This commit is contained in:
parent
efbca15116
commit
51ea1abb5f
11 changed files with 157 additions and 67 deletions
|
@ -9,7 +9,6 @@
|
|||
#
|
||||
#
|
||||
#
|
||||
require "e2mmap"
|
||||
require "ripper"
|
||||
|
||||
require "irb/init"
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#
|
||||
#
|
||||
#
|
||||
IRB.fail CantShiftToMultiIrbMode unless defined?(Thread)
|
||||
fail CantShiftToMultiIrbMode unless defined?(Thread)
|
||||
|
||||
module IRB
|
||||
class JobManager
|
||||
|
@ -67,8 +67,8 @@ module IRB
|
|||
# exception is raised.
|
||||
def switch(key)
|
||||
th, irb = search(key)
|
||||
IRB.fail IrbAlreadyDead unless th.alive?
|
||||
IRB.fail IrbSwitchedToCurrentThread if th == Thread.current
|
||||
fail IrbAlreadyDead unless th.alive?
|
||||
fail IrbSwitchedToCurrentThread if th == Thread.current
|
||||
@current_job = irb
|
||||
th.run
|
||||
Thread.stop
|
||||
|
@ -84,7 +84,7 @@ module IRB
|
|||
def kill(*keys)
|
||||
for key in keys
|
||||
th, _ = search(key)
|
||||
IRB.fail IrbAlreadyDead unless th.alive?
|
||||
fail IrbAlreadyDead unless th.alive?
|
||||
th.exit
|
||||
end
|
||||
end
|
||||
|
@ -114,7 +114,7 @@ module IRB
|
|||
else
|
||||
@jobs.find{|k, v| v.context.main.equal?(key)}
|
||||
end
|
||||
IRB.fail NoSuchJob, key if job.nil?
|
||||
fail NoSuchJob, key if job.nil?
|
||||
job
|
||||
end
|
||||
|
||||
|
@ -122,7 +122,7 @@ module IRB
|
|||
def delete(key)
|
||||
case key
|
||||
when Integer
|
||||
IRB.fail NoSuchJob, key unless @jobs[key]
|
||||
fail NoSuchJob, key unless @jobs[key]
|
||||
@jobs[key] = nil
|
||||
else
|
||||
catch(:EXISTS) do
|
||||
|
@ -135,7 +135,7 @@ module IRB
|
|||
throw :EXISTS
|
||||
end
|
||||
end
|
||||
IRB.fail NoSuchJob, key
|
||||
fail NoSuchJob, key
|
||||
end
|
||||
end
|
||||
until assoc = @jobs.pop; end unless @jobs.empty?
|
||||
|
|
|
@ -10,13 +10,18 @@
|
|||
#
|
||||
#
|
||||
|
||||
require "e2mmap"
|
||||
|
||||
module IRB
|
||||
class Frame
|
||||
extend Exception2MessageMapper
|
||||
def_exception :FrameOverflow, "frame overflow"
|
||||
def_exception :FrameUnderflow, "frame underflow"
|
||||
class FrameOverflow < StandardError
|
||||
def initialize
|
||||
super("frame overflow")
|
||||
end
|
||||
end
|
||||
class FrameUnderflow < StandardError
|
||||
def initialize
|
||||
super("frame underflow")
|
||||
end
|
||||
end
|
||||
|
||||
# Default number of stack frames
|
||||
INIT_STACK_TIMES = 3
|
||||
|
@ -44,7 +49,7 @@ module IRB
|
|||
# Raises FrameUnderflow if there are no frames in the given stack range.
|
||||
def top(n = 0)
|
||||
bind = @frames[-(n + CALL_STACK_OFFSET)]
|
||||
Fail FrameUnderflow unless bind
|
||||
fail FrameUnderflow unless bind
|
||||
bind
|
||||
end
|
||||
|
||||
|
@ -54,7 +59,7 @@ module IRB
|
|||
# Raises FrameOverflow if there are no frames in the given stack range.
|
||||
def bottom(n = 0)
|
||||
bind = @frames[n]
|
||||
Fail FrameOverflow unless bind
|
||||
fail FrameOverflow unless bind
|
||||
bind
|
||||
end
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ module IRB # :nodoc:
|
|||
IRB.load_modules
|
||||
|
||||
unless @CONF[:PROMPT][@CONF[:PROMPT_MODE]]
|
||||
IRB.fail(UndefinedPromptMode, @CONF[:PROMPT_MODE])
|
||||
fail UndefinedPromptMode, @CONF[:PROMPT_MODE]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -217,7 +217,7 @@ module IRB # :nodoc:
|
|||
end
|
||||
break
|
||||
when /^-/
|
||||
IRB.fail UnrecognizedSwitch, opt
|
||||
fail UnrecognizedSwitch, opt
|
||||
else
|
||||
@CONF[:SCRIPT] = opt
|
||||
$0 = opt
|
||||
|
@ -262,7 +262,7 @@ module IRB # :nodoc:
|
|||
when String
|
||||
return rc_file
|
||||
else
|
||||
IRB.fail IllegalRCNameGenerator
|
||||
fail IllegalRCNameGenerator
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ module IRB
|
|||
#
|
||||
# See IO#gets for more information.
|
||||
def gets
|
||||
IRB.fail NotImplementedError, "gets"
|
||||
fail NotImplementedError, "gets"
|
||||
end
|
||||
public :gets
|
||||
|
||||
|
|
|
@ -9,24 +9,63 @@
|
|||
#
|
||||
#
|
||||
#
|
||||
require "e2mmap"
|
||||
|
||||
# :stopdoc:
|
||||
module IRB
|
||||
|
||||
# exceptions
|
||||
extend Exception2MessageMapper
|
||||
def_exception :UnrecognizedSwitch, "Unrecognized switch: %s"
|
||||
def_exception :NotImplementedError, "Need to define `%s'"
|
||||
def_exception :CantReturnToNormalMode, "Can't return to normal mode."
|
||||
def_exception :IllegalParameter, "Invalid parameter(%s)."
|
||||
def_exception :IrbAlreadyDead, "Irb is already dead."
|
||||
def_exception :IrbSwitchedToCurrentThread, "Switched to current thread."
|
||||
def_exception :NoSuchJob, "No such job(%s)."
|
||||
def_exception :CantShiftToMultiIrbMode, "Can't shift to multi irb mode."
|
||||
def_exception :CantChangeBinding, "Can't change binding to (%s)."
|
||||
def_exception :UndefinedPromptMode, "Undefined prompt mode(%s)."
|
||||
def_exception :IllegalRCGenerator, 'Define illegal RC_NAME_GENERATOR.'
|
||||
|
||||
class UnrecognizedSwitch < StandardError
|
||||
def initialize(val)
|
||||
super("Unrecognized switch: #{val}")
|
||||
end
|
||||
end
|
||||
class NotImplementedError < StandardError
|
||||
def initialize(val)
|
||||
super("Need to define `#{val}'")
|
||||
end
|
||||
end
|
||||
class CantReturnToNormalMode < StandardError
|
||||
def initialize
|
||||
super("Can't return to normal mode.")
|
||||
end
|
||||
end
|
||||
class IllegalParameter < StandardError
|
||||
def initialize(val)
|
||||
super("Invalid parameter(#{val}).")
|
||||
end
|
||||
end
|
||||
class IrbAlreadyDead < StandardError
|
||||
def initialize
|
||||
super("Irb is already dead.")
|
||||
end
|
||||
end
|
||||
class IrbSwitchedToCurrentThread < StandardError
|
||||
def initialize
|
||||
super("Switched to current thread.")
|
||||
end
|
||||
end
|
||||
class NoSuchJob < StandardError
|
||||
def initialize(val)
|
||||
super("No such job(#{val}).")
|
||||
end
|
||||
end
|
||||
class CantShiftToMultiIrbMode < StandardError
|
||||
def initialize
|
||||
super("Can't shift to multi irb mode.")
|
||||
end
|
||||
end
|
||||
class CantChangeBinding < StandardError
|
||||
def initialize(val)
|
||||
super("Can't change binding to (#{val}).")
|
||||
end
|
||||
end
|
||||
class UndefinedPromptMode < StandardError
|
||||
def initialize(val)
|
||||
super("Undefined prompt mode(#{val}).")
|
||||
end
|
||||
end
|
||||
class IllegalRCGenerator < StandardError
|
||||
def initialize
|
||||
super("Define illegal RC_NAME_GENERATOR.")
|
||||
end
|
||||
end
|
||||
end
|
||||
# :startdoc:
|
||||
|
|
|
@ -9,23 +9,64 @@
|
|||
#
|
||||
#
|
||||
#
|
||||
require "e2mmap"
|
||||
|
||||
# :stopdoc:
|
||||
module IRB
|
||||
# exceptions
|
||||
extend Exception2MessageMapper
|
||||
def_exception :UnrecognizedSwitch, 'スイッチ(%s)が分りません'
|
||||
def_exception :NotImplementedError, '`%s\'の定義が必要です'
|
||||
def_exception :CantReturnToNormalMode, 'Normalモードに戻れません.'
|
||||
def_exception :IllegalParameter, 'パラメータ(%s)が間違っています.'
|
||||
def_exception :IrbAlreadyDead, 'Irbは既に死んでいます.'
|
||||
def_exception :IrbSwitchedToCurrentThread, 'カレントスレッドに切り替わりました.'
|
||||
def_exception :NoSuchJob, 'そのようなジョブ(%s)はありません.'
|
||||
def_exception :CantShiftToMultiIrbMode, 'multi-irb modeに移れません.'
|
||||
def_exception :CantChangeBinding, 'バインディング(%s)に変更できません.'
|
||||
def_exception :UndefinedPromptMode, 'プロンプトモード(%s)は定義されていません.'
|
||||
def_exception :IllegalRCNameGenerator, 'RC_NAME_GENERATORが正しく定義されていません.'
|
||||
class UnrecognizedSwitch < StandardError
|
||||
def initialize(val)
|
||||
super("スイッチ(#{val})が分りません")
|
||||
end
|
||||
end
|
||||
class NotImplementedError < StandardError
|
||||
def initialize(val)
|
||||
super("`#{val}'の定義が必要です")
|
||||
end
|
||||
end
|
||||
class CantReturnToNormalMode < StandardError
|
||||
def initialize
|
||||
super("Normalモードに戻れません.")
|
||||
end
|
||||
end
|
||||
class IllegalParameter < StandardError
|
||||
def initialize(val)
|
||||
super("パラメータ(#{val})が間違っています.")
|
||||
end
|
||||
end
|
||||
class IrbAlreadyDead < StandardError
|
||||
def initialize
|
||||
super("Irbは既に死んでいます.")
|
||||
end
|
||||
end
|
||||
class IrbSwitchedToCurrentThread < StandardError
|
||||
def initialize
|
||||
super("カレントスレッドに切り替わりました.")
|
||||
end
|
||||
end
|
||||
class NoSuchJob < StandardError
|
||||
def initialize(val)
|
||||
super("そのようなジョブ(#{val})はありません.")
|
||||
end
|
||||
end
|
||||
class CantShiftToMultiIrbMode < StandardError
|
||||
def initialize
|
||||
super("multi-irb modeに移れません.")
|
||||
end
|
||||
end
|
||||
class CantChangeBinding < StandardError
|
||||
def initialize(val)
|
||||
super("バインディング(#{val})に変更できません.")
|
||||
end
|
||||
end
|
||||
class UndefinedPromptMode < StandardError
|
||||
def initialize(val)
|
||||
super("プロンプトモード(#{val})は定義されていません.")
|
||||
end
|
||||
end
|
||||
class IllegalRCGenerator < StandardError
|
||||
def initialize
|
||||
super("RC_NAME_GENERATORが正しく定義されていません.")
|
||||
end
|
||||
end
|
||||
end
|
||||
# :startdoc:
|
||||
# vim:fileencoding=utf-8
|
||||
|
|
|
@ -10,17 +10,21 @@
|
|||
#
|
||||
#
|
||||
|
||||
require "e2mmap"
|
||||
require_relative "output-method"
|
||||
|
||||
module IRB
|
||||
# An output formatter used internally by the lexer.
|
||||
module Notifier
|
||||
extend Exception2MessageMapper
|
||||
def_exception :ErrUndefinedNotifier,
|
||||
"undefined notifier level: %d is specified"
|
||||
def_exception :ErrUnrecognizedLevel,
|
||||
"unrecognized notifier level: %s is specified"
|
||||
class ErrUndefinedNotifier < StandardError
|
||||
def initialize(val)
|
||||
super("undefined notifier level: #{val} is specified")
|
||||
end
|
||||
end
|
||||
class ErrUnrecognizedLevel < StandardError
|
||||
def initialize(val)
|
||||
super("unrecognized notifier level: #{val} is specified")
|
||||
end
|
||||
end
|
||||
|
||||
# Define a new Notifier output source, returning a new CompositeNotifier
|
||||
# with the given +prefix+ and +output_method+.
|
||||
|
@ -162,10 +166,10 @@ module IRB
|
|||
@level_notifier = value
|
||||
when Integer
|
||||
l = @notifiers[value]
|
||||
Notifier.Raise ErrUndefinedNotifier, value unless l
|
||||
raise ErrUndefinedNotifier, value unless l
|
||||
@level_notifier = l
|
||||
else
|
||||
Notifier.Raise ErrUnrecognizedLevel, value unless l
|
||||
raise ErrUnrecognizedLevel, value unless l
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -10,21 +10,21 @@
|
|||
#
|
||||
#
|
||||
|
||||
require "e2mmap"
|
||||
|
||||
module IRB
|
||||
# An abstract output class for IO in irb. This is mainly used internally by
|
||||
# IRB::Notifier. You can define your own output method to use with Irb.new,
|
||||
# or Context.new
|
||||
class OutputMethod
|
||||
extend Exception2MessageMapper
|
||||
def_exception :NotImplementedError, "Need to define `%s'"
|
||||
|
||||
class NotImplementedError < StandardError
|
||||
def initialize(val)
|
||||
super("Need to define `#{val}'")
|
||||
end
|
||||
end
|
||||
|
||||
# Open this method to implement your own output method, raises a
|
||||
# NotImplementedError if you don't define #print in your own class.
|
||||
def print(*opts)
|
||||
OutputMethod.Raise NotImplementedError, "print"
|
||||
raise NotImplementedError, "print"
|
||||
end
|
||||
|
||||
# Prints the given +opts+, with a newline delimiter.
|
||||
|
|
|
@ -10,14 +10,16 @@
|
|||
#
|
||||
#
|
||||
|
||||
require "e2mmap"
|
||||
require "ripper"
|
||||
|
||||
# :stopdoc:
|
||||
class RubyLex
|
||||
|
||||
extend Exception2MessageMapper
|
||||
def_exception(:TerminateLineInput, "Terminate Line Input")
|
||||
class TerminateLineInput < StandardError
|
||||
def initialize
|
||||
super("Terminate Line Input")
|
||||
end
|
||||
end
|
||||
|
||||
def initialize
|
||||
@exp_line_no = @line_no = 1
|
||||
|
|
|
@ -74,7 +74,7 @@ EOF
|
|||
begin
|
||||
@binding = eval("IRB.conf[:__MAIN__].instance_eval('binding', __FILE__, __LINE__)", @binding, __FILE__, __LINE__)
|
||||
rescue TypeError
|
||||
IRB.fail CantChangeBinding, @main.inspect
|
||||
fail CantChangeBinding, @main.inspect
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue