module Metasm::Backtrace

defines an attribute self.backtrace (array of filename/lineno) and a method backtrace_str which dumps this array to a human-readable form

Attributes

backtrace[RW]

array [file, lineno, file, lineno] if file 'A' does include 'B' you'll get ['A', linenoA, 'B', linenoB]

Public Class Methods

backtrace_str(ary) click to toggle source

builds a readable backtrace string from an array of [file, lineno, file, lineno, ..]

# File metasm/main.rb, line 158
def self.backtrace_str(ary)
        return '' if not ary
        i = ary.length
        bt = ''
        while i > 0
                bt << ",\n\tincluded from " if ary[i]
                i -= 2
                bt << "#{ary[i].inspect} line #{ary[i+1]}"
        end
        bt
end

Public Instance Methods

backtrace_str() click to toggle source

builds a readable string from self.backtrace

# File metasm/main.rb, line 153
def backtrace_str
        Backtrace.backtrace_str(@backtrace)
end
exception(msg='syntax error') click to toggle source
# File metasm/main.rb, line 170
def exception(msg='syntax error')
        ParseError.new "at #{backtrace_str}: #{msg}"
end