File tree Expand file tree Collapse file tree 3 files changed +47
-3
lines changed Expand file tree Collapse file tree 3 files changed +47
-3
lines changed Original file line number Diff line number Diff line change 27
27
require 'output_functions'
28
28
require 'globals'
29
29
30
+ require 'debugscope'
30
31
31
32
class Compiler
32
- attr_reader :global_functions
33
+ attr_reader :global_functions , :global_scope
33
34
attr_writer :trace , :stackfence
34
35
35
36
# list of all predefined keywords with a corresponding compile-method
@@ -196,7 +197,10 @@ def clean_method_name(name)
196
197
#
197
198
def compile_deref ( scope , left , right )
198
199
cscope = scope . find_constant ( left )
199
- raise "Unable to resolve: #{ left } ::#{ right } statically (FIXME)" if !cscope || !cscope . is_a? ( ClassScope )
200
+ if !cscope || !cscope . is_a? ( ClassScope )
201
+ global_scope . dump
202
+ error ( "Unable to resolve: #{ left } ::#{ right } statically (FIXME)" , scope )
203
+ end
200
204
get_arg ( cscope , right )
201
205
end
202
206
Original file line number Diff line number Diff line change
1
+
2
+ class Scope
3
+ def dump ( indent = 0 , data = { } )
4
+ data . sort . each do |k , v |
5
+ if v . kind_of? ( Scope )
6
+ STDERR . puts "#{ " " *indent *2 } #{ k } :"
7
+ v . dump ( indent + 1 )
8
+ else
9
+ STDERR . puts "#{ " " *indent *2 } #{ k } : #{ v . inspect } "
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ class GlobalScope < Scope
16
+ def dump ( indent = 0 , data = { } )
17
+ super ( indent , @globals )
18
+ end
19
+ end
20
+
21
+ class ClassScope < Scope
22
+ def dump ( indent = 0 , data = { } )
23
+ # FIXME: Don't add e.g. Token__Atom, and fix lookup so it's irrelevant
24
+ if !@constants . empty?
25
+ STDERR . puts "#{ " " *indent *2 } CONSTANTS:"
26
+ super ( indent + 1 , @constants )
27
+ end
28
+ if !@instance_vars . empty?
29
+ STDERR . puts "#{ " " *indent *2 } IVARS:"
30
+ @instance_vars . sort . each do |ivar |
31
+ STDERR . puts "#{ " " *( indent + 1 ) *2 } #{ ivar } "
32
+ end
33
+ end
34
+ end
35
+ end
Original file line number Diff line number Diff line change 6
6
stackfence = ARGV . include? ( "--stackfence" )
7
7
transform = !ARGV . include? ( "--notransform" )
8
8
nostabs = ARGV . include? ( "--nostabs" )
9
+ dumpsymtabs = ARGV . include? ( "--dumpsymtabs" )
9
10
10
11
# Option to not rewrite the parse tree (breaks compilation, but useful for debugging of the parser)
11
12
OpPrec ::TreeOutput . dont_rewrite if ARGV . include? ( "--dont-rewrite" )
66
67
67
68
c . preprocess ( prog ) if transform
68
69
69
- print_sexp prog if dump
70
+ if dump || dumpsymtabs
71
+ print_sexp prog if dump
72
+ c . global_scope . dump if dumpsymtabs
73
+ exit ( 1 )
74
+ end
70
75
71
76
c . compile ( prog )
72
77
end
You can’t perform that action at this time.
0 commit comments