defines an attribute self.backtrace (array of filename/lineno) and a method #backtrace_str which dumps this array to a human-readable form
array [file, lineno, file, lineno] if file 'A' does include 'B' you'll get ['A', linenoA, 'B', linenoB]
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
builds a readable string from self.backtrace
# File metasm/main.rb, line 153 def backtrace_str Backtrace.backtrace_str(@backtrace) end
# File metasm/main.rb, line 170 def exception(msg='syntax error') ParseError.new "at #{backtrace_str}: #{msg}" end