-
Notifications
You must be signed in to change notification settings - Fork 22
/
debugscope.rb
35 lines (32 loc) · 812 Bytes
/
debugscope.rb
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
class Scope
def dump(indent = 0,data = {})
data.sort.each do |k,v|
if v.kind_of?(Scope)
STDERR.puts "#{" "*indent*2}#{k}:"
v.dump(indent + 1)
else
STDERR.puts "#{" "*indent*2}#{k}: #{v.inspect}"
end
end
end
end
class GlobalScope < Scope
def dump(indent = 0,data = {})
super(indent, @globals)
end
end
class ClassScope < ModuleScope
def dump(indent = 0,data = {})
# FIXME: Don't add e.g. Token__Atom, and fix lookup so it's irrelevant
if !@constants.empty?
STDERR.puts "#{" "*indent*2}CONSTANTS:"
super(indent + 1, @constants)
end
if !@instance_vars.empty?
STDERR.puts "#{" "*indent*2}IVARS:"
@instance_vars.sort.each do |ivar|
STDERR.puts "#{" "*(indent + 1)*2}#{ivar}"
end
end
end
end