PHP 8.2.31
Preview: frame.rb Size: 1.27 KB
/proc/thread-self/root/opt/alt/ruby18/lib64/ruby/1.8/irb/frame.rb

#
#   frame.rb - 
#   	$Release Version: 0.9$
#   	$Revision: 11708 $
#   	$Date: 2007-02-13 08:01:19 +0900 (Tue, 13 Feb 2007) $
#   	by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
#
# --
#
#   
#

require "e2mmap"

module IRB
  class Frame
    extend Exception2MessageMapper
    def_exception :FrameOverflow, "frame overflow"
    def_exception :FrameUnderflow, "frame underflow"

    INIT_STACK_TIMES = 3
    CALL_STACK_OFFSET = 3

    def initialize
      @frames = [TOPLEVEL_BINDING] * INIT_STACK_TIMES
    end

    def trace_func(event, file, line, id, binding)
      case event
      when 'call', 'class'
	@frames.push binding
      when 'return', 'end'
	@frames.pop
      end
    end

    def top(n = 0)
      bind = @frames[-(n + CALL_STACK_OFFSET)]
      Fail FrameUnderflow unless bind
      bind
    end

    def bottom(n = 0)
      bind = @frames[n]
      Fail FrameOverflow unless bind
      bind
    end

    # singleton functions
    def Frame.bottom(n = 0)
      @backtrace.bottom(n)
    end

    def Frame.top(n = 0)
      @backtrace.top(n)
    end

    def Frame.sender
      eval "self", @backtrace.top
    end

    @backtrace = Frame.new
    set_trace_func proc{|event, file, line, id, binding, klass|
      @backtrace.trace_func(event, file, line, id, binding)
    }
  end
end

Directory Contents

Dirs: 3 × Files: 17

Name Size Perms Modified Actions
cmd DIR
- drwxr-xr-x 2024-03-03 22:48:14
Edit Download
ext DIR
- drwxr-xr-x 2024-03-03 22:48:14
Edit Download
lc DIR
- drwxr-xr-x 2024-03-03 22:48:14
Edit Download
4.85 KB lrw-r--r-- 2007-02-12 23:01:19
Edit Download
6.01 KB lrw-r--r-- 2007-02-12 23:01:19
Edit Download
6.89 KB lrw-r--r-- 2009-11-17 06:51:29
Edit Download
1.27 KB lrw-r--r-- 2007-02-12 23:01:19
Edit Download
582 B lrw-r--r-- 2008-06-06 08:05:24
Edit Download
5.83 KB lrw-r--r-- 2009-08-09 08:44:15
Edit Download
1.81 KB lrw-r--r-- 2007-02-12 23:01:19
Edit Download
3.37 KB lrw-r--r-- 2007-02-12 23:01:19
Edit Download
2.71 KB lrw-r--r-- 2008-06-06 08:05:24
Edit Download
1.79 KB lrw-r--r-- 2007-02-12 23:01:19
Edit Download
21.38 KB lrw-r--r-- 2008-06-06 08:05:24
Edit Download
7.43 KB lrw-r--r-- 2007-02-12 23:01:19
Edit Download
6.07 KB lrw-r--r-- 2008-06-06 08:05:24
Edit Download
303 B lrw-r--r-- 2007-02-12 23:01:19
Edit Download
2.55 KB lrw-r--r-- 2007-02-12 23:01:19
Edit Download
258 B lrw-r--r-- 2007-02-12 23:01:19
Edit Download
1.48 KB lrw-r--r-- 2007-02-12 23:01:19
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).