ruby2c 1.0.0.9 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +2 -0
- data.tar.gz.sig +1 -1
- data/History.txt +71 -53
- data/README.txt +1 -1
- data/Rakefile +2 -0
- data/lib/crewriter.rb +35 -23
- data/lib/r2cenvironment.rb +3 -3
- data/lib/rewriter.rb +2 -2
- data/lib/ruby_to_ansi_c.rb +14 -18
- data/lib/ruby_to_ruby_c.rb +3 -3
- data/lib/type.rb +3 -3
- data/lib/type_checker.rb +97 -99
- data/lib/typed_sexp.rb +49 -25
- data/test/r2ctestcase.rb +321 -288
- data/test/test_crewriter.rb +127 -128
- data/test/test_extras.rb +4 -4
- data/test/test_function_table.rb +23 -23
- data/test/test_function_type.rb +39 -40
- data/test/test_handle.rb +2 -2
- data/test/test_r2cenvironment.rb +38 -38
- data/test/test_ruby_to_ansi_c.rb +58 -58
- data/test/test_ruby_to_ruby_c.rb +26 -26
- data/test/test_type.rb +38 -38
- data/test/test_type_checker.rb +165 -165
- data/test/test_typed_sexp.rb +62 -54
- metadata +97 -150
- metadata.gz.sig +0 -0
- data/.gemtest +0 -0
data/lib/typed_sexp.rb
CHANGED
@@ -1,77 +1,101 @@
|
|
1
|
-
|
2
1
|
begin require 'rubygems'; rescue LoadError; end
|
3
2
|
require 'sexp'
|
4
3
|
require 'type'
|
5
4
|
|
6
5
|
$TESTING = false unless defined? $TESTING
|
7
6
|
|
8
|
-
class
|
7
|
+
class Sexp
|
8
|
+
@@array_types = [ :array, :args ]
|
9
|
+
|
10
|
+
alias array_type? array_type? # shuts up duplicate method warning
|
9
11
|
|
12
|
+
##
|
13
|
+
# Returns true if the node_type is +array+ or +args+.
|
14
|
+
|
15
|
+
def array_type?
|
16
|
+
type = self.sexp_type
|
17
|
+
@@array_types.include? type
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class TypedSexp < Sexp
|
10
22
|
def ==(obj)
|
11
23
|
case obj
|
12
24
|
when TypedSexp
|
13
|
-
super &&
|
25
|
+
super && c_type == obj.c_type
|
14
26
|
else
|
15
27
|
false
|
16
28
|
end
|
17
29
|
end
|
18
30
|
|
19
|
-
def
|
20
|
-
|
31
|
+
def new(*stuff)
|
32
|
+
r = super
|
33
|
+
r.c_type = self.c_type if self.c_type
|
34
|
+
r
|
35
|
+
end
|
36
|
+
|
37
|
+
def _set_c_type(o)
|
38
|
+
@c_type = o
|
21
39
|
end
|
22
40
|
|
23
41
|
def initialize(*args)
|
24
|
-
# TODO: should probably be
|
25
|
-
@
|
42
|
+
# TODO: should probably be CType.unknown
|
43
|
+
@c_type = CType === args.last ? args.pop : nil
|
26
44
|
super(*args)
|
27
45
|
end
|
28
46
|
|
29
47
|
def inspect
|
30
48
|
sexp_str = self.map {|x|x.inspect}.join(', ')
|
31
|
-
|
32
|
-
|
49
|
+
c_type_str = (sexp_str.empty? ? "" : ", ") + "#{array_type? ? c_types.inspect : c_type}" unless c_type.nil?
|
50
|
+
nnd = ")"
|
51
|
+
nnd << ".line(#{line})" if line && ENV["VERBOSE"]
|
52
|
+
"t(#{sexp_str}#{c_type_str}#{nnd}"
|
33
53
|
end
|
34
54
|
|
35
55
|
def pretty_print(q)
|
36
|
-
|
56
|
+
nnd = ")"
|
57
|
+
nnd << ".line(#{line})" if line && ENV["VERBOSE"]
|
58
|
+
|
59
|
+
q.group(1, 't(', nnd) do
|
37
60
|
q.seplist(self) {|v| q.pp v }
|
38
|
-
unless @
|
61
|
+
unless @c_type.nil? then
|
39
62
|
q.text ", " unless self.empty?
|
40
|
-
q.pp @
|
63
|
+
q.pp @c_type
|
41
64
|
end
|
42
65
|
end
|
43
66
|
end
|
44
67
|
|
45
|
-
def
|
68
|
+
def c_type
|
46
69
|
unless array_type? then
|
47
|
-
@
|
70
|
+
defined?(@c_type) && @c_type
|
48
71
|
else
|
49
|
-
types = self.
|
72
|
+
types = self.c_types.flatten.uniq
|
50
73
|
|
51
74
|
if types.size > 1 then
|
52
|
-
|
75
|
+
CType.hetero
|
53
76
|
else
|
54
|
-
|
77
|
+
CType.homo
|
55
78
|
end
|
56
79
|
end
|
57
80
|
end
|
58
81
|
|
59
|
-
def
|
60
|
-
raise "You shouldn't call this on an #{first}" if array_type?
|
82
|
+
def c_type=(o)
|
83
|
+
# HACK raise "You shouldn't call this on an #{first}" if array_type?
|
84
|
+
# c_type is different in ruby2c than from sexp_processor. need renames
|
61
85
|
raise "You shouldn't call this a second time, ever" unless
|
62
|
-
@
|
63
|
-
|
86
|
+
@c_type.nil? or @c_type == CType.unknown
|
87
|
+
_set_c_type(o)
|
64
88
|
end
|
65
89
|
|
66
|
-
def
|
90
|
+
def c_types
|
67
91
|
raise "You shouldn't call this if not an #{@@array_types.join(' or ')}, was #{first} (#{self.inspect})" unless array_type?
|
68
|
-
self.grep(Sexp).map { |x| x.
|
92
|
+
self.grep(Sexp).map { |x| x.c_type }
|
69
93
|
end
|
70
94
|
|
71
95
|
def to_a
|
72
96
|
result = super
|
73
|
-
if defined?(@
|
74
|
-
result += [ @
|
97
|
+
if defined?(@c_type) and not @c_type.nil? then
|
98
|
+
result += [ @c_type ]
|
75
99
|
end
|
76
100
|
result
|
77
101
|
end
|
data/test/r2ctestcase.rb
CHANGED
@@ -7,9 +7,8 @@ require 'unique'
|
|
7
7
|
# TODO: add tests that mix types up to fuck up RubyC type checker
|
8
8
|
|
9
9
|
class R2CTestCase < ParseTreeTestCase
|
10
|
-
|
11
10
|
def self.add_skipped_tests *names
|
12
|
-
names.each do |name|
|
11
|
+
names.flatten.each do |name|
|
13
12
|
add_tests(name,
|
14
13
|
"Rewriter" => :same,
|
15
14
|
"TypeChecker" => :skip,
|
@@ -19,6 +18,10 @@ class R2CTestCase < ParseTreeTestCase
|
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
21
|
+
def self.add_skipped_tests19 *names
|
22
|
+
add_skipped_tests names.map { |s| "#{s}__19_20_21_22_23_24_25_26" }
|
23
|
+
end
|
24
|
+
|
22
25
|
testcase_order.push(*%w(Ruby ParseTree Rewriter TypeChecker
|
23
26
|
CRewriter RubyToAnsiC RubyToRubyC))
|
24
27
|
|
@@ -27,9 +30,9 @@ class R2CTestCase < ParseTreeTestCase
|
|
27
30
|
add_tests("and",
|
28
31
|
"Rewriter" => :same,
|
29
32
|
"TypeChecker" => t(:and,
|
30
|
-
t(:call, nil, :a, t(:arglist),
|
31
|
-
t(:call, nil, :b, t(:arglist),
|
32
|
-
|
33
|
+
t(:call, nil, :a, t(:arglist), CType.bool),
|
34
|
+
t(:call, nil, :b, t(:arglist), CType.bool),
|
35
|
+
CType.bool),
|
33
36
|
"CRewriter" => :same,
|
34
37
|
"RubyToAnsiC" => "a() && b()",
|
35
38
|
"RubyToRubyC" => 'rb_funcall(self, rb_intern("a"), 0) && rb_funcall(self, rb_intern("b"), 0)')
|
@@ -37,10 +40,10 @@ class R2CTestCase < ParseTreeTestCase
|
|
37
40
|
add_tests("array",
|
38
41
|
"Rewriter" => :same,
|
39
42
|
"TypeChecker" => t(:array,
|
40
|
-
t(:lit, 1,
|
41
|
-
t(:lit, :b,
|
42
|
-
t(:str, "c",
|
43
|
-
|
43
|
+
t(:lit, 1, CType.long),
|
44
|
+
t(:lit, :b, CType.symbol),
|
45
|
+
t(:str, "c", CType.str),
|
46
|
+
CType.hetero),
|
44
47
|
"CRewriter" => :same,
|
45
48
|
"RubyToAnsiC" => "1, \"b\", \"c\"",
|
46
49
|
"RubyToRubyC" => "LONG2NUM(1), ID2SYM(rb_intern(\"b\")), rb_str_new2(\"c\")")
|
@@ -48,9 +51,9 @@ class R2CTestCase < ParseTreeTestCase
|
|
48
51
|
add_tests("array_pct_W",
|
49
52
|
"Rewriter" => :same,
|
50
53
|
"TypeChecker" => t(:array,
|
51
|
-
t(:str, "a",
|
52
|
-
t(:str, "b",
|
53
|
-
t(:str, "c",
|
54
|
+
t(:str, "a", CType.str),
|
55
|
+
t(:str, "b", CType.str),
|
56
|
+
t(:str, "c", CType.str)),
|
54
57
|
"CRewriter" => :same,
|
55
58
|
"RubyToAnsiC" => "\"a\", \"b\", \"c\"",
|
56
59
|
"RubyToRubyC" => "rb_str_new2(\"a\"), rb_str_new2(\"b\"), rb_str_new2(\"c\")")
|
@@ -58,9 +61,9 @@ class R2CTestCase < ParseTreeTestCase
|
|
58
61
|
add_tests("array_pct_w",
|
59
62
|
"Rewriter" => :same,
|
60
63
|
"TypeChecker" => t(:array,
|
61
|
-
t(:str, "a",
|
62
|
-
t(:str, "b",
|
63
|
-
t(:str, "c",
|
64
|
+
t(:str, "a", CType.str),
|
65
|
+
t(:str, "b", CType.str),
|
66
|
+
t(:str, "c", CType.str)),
|
64
67
|
"CRewriter" => :same,
|
65
68
|
"RubyToAnsiC" => "\"a\", \"b\", \"c\"",
|
66
69
|
"RubyToRubyC" => "rb_str_new2(\"a\"), rb_str_new2(\"b\"), rb_str_new2(\"c\")")
|
@@ -68,11 +71,11 @@ class R2CTestCase < ParseTreeTestCase
|
|
68
71
|
add_tests("attrasgn_index_equals",
|
69
72
|
"Rewriter" => :same,
|
70
73
|
"TypeChecker" => t(:attrasgn,
|
71
|
-
t(:call, nil, :a, t(:arglist),
|
74
|
+
t(:call, nil, :a, t(:arglist), CType.unknown),
|
72
75
|
:[]=,
|
73
76
|
t(:arglist,
|
74
|
-
t(:lit, 42,
|
75
|
-
t(:lit, 24,
|
77
|
+
t(:lit, 42, CType.long),
|
78
|
+
t(:lit, 24, CType.long))),
|
76
79
|
"CRewriter" => :same,
|
77
80
|
"RubyToAnsiC" => :skip,
|
78
81
|
"RubyToRubyC" => :skip) # TODO: rubyc should be ok with this
|
@@ -80,63 +83,41 @@ class R2CTestCase < ParseTreeTestCase
|
|
80
83
|
add_tests("attrasgn_index_equals_space",
|
81
84
|
"Rewriter" => :same,
|
82
85
|
"TypeChecker" => t(:block,
|
83
|
-
t(:lasgn, :a, t(:array),
|
86
|
+
t(:lasgn, :a, t(:array), CType.unknown_list),
|
84
87
|
t(:attrasgn,
|
85
|
-
t(:lvar, :a,
|
88
|
+
t(:lvar, :a, CType.unknown_list),
|
86
89
|
:[]=,
|
87
90
|
t(:arglist,
|
88
|
-
t(:lit, 42,
|
89
|
-
t(:lit, 24,
|
91
|
+
t(:lit, 42, CType.long),
|
92
|
+
t(:lit, 24, CType.long))), CType.unknown),
|
90
93
|
"CRewriter" => :same,
|
91
94
|
"RubyToAnsiC" => :skip,
|
92
95
|
"RubyToRubyC" => :skip) # TODO: rubyc should be ok with this
|
93
96
|
|
94
|
-
add_tests("attrset",
|
95
|
-
"Rewriter" => s(:defn, :writer=,
|
96
|
-
s(:args, :arg),
|
97
|
-
s(:scope,
|
98
|
-
s(:block,
|
99
|
-
s(:return,
|
100
|
-
s(:iasgn, :@writer, s(:lvar, :arg)))))),
|
101
|
-
"TypeChecker" => t(:defn, :writer=,
|
102
|
-
t(:args, t(:arg, Type.unknown)),
|
103
|
-
t(:scope,
|
104
|
-
t(:block,
|
105
|
-
t(:return,
|
106
|
-
t(:iasgn, :@writer,
|
107
|
-
t(:lvar, :arg, Type.unknown),
|
108
|
-
Type.unknown),
|
109
|
-
Type.void), Type.unknown), Type.void),
|
110
|
-
Type.function(Type.unknown,
|
111
|
-
[Type.unknown], Type.unknown)),
|
112
|
-
"CRewriter" => :same,
|
113
|
-
"RubyToAnsiC" => "void *\nwriter=(void * arg) {\nreturn self->writer = arg;\n}",
|
114
|
-
"RubyToRubyC" => "static VALUE\nrrc_c_writer_equals(VALUE self, VALUE arg) {\nreturn self->writer = arg;\n}")
|
115
|
-
|
116
97
|
add_tests("bools", # NOTE: not in pttc
|
117
98
|
"Rewriter" => :skip,
|
118
99
|
# TODO: why does return false have type void?
|
119
100
|
"TypeChecker" => t(:defn, :bools,
|
120
|
-
t(:args, t(:arg1,
|
101
|
+
t(:args, t(:arg1, CType.value)),
|
121
102
|
t(:scope,
|
122
103
|
t(:block,
|
123
104
|
t(:if,
|
124
105
|
t(:call,
|
125
|
-
t(:lvar, :arg1,
|
106
|
+
t(:lvar, :arg1, CType.value),
|
126
107
|
:nil?,
|
127
108
|
nil,
|
128
|
-
|
109
|
+
CType.bool),
|
129
110
|
t(:return,
|
130
|
-
t(:false,
|
131
|
-
|
111
|
+
t(:false, CType.bool),
|
112
|
+
CType.void),
|
132
113
|
t(:return,
|
133
|
-
t(:true,
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
[
|
114
|
+
t(:true, CType.bool),
|
115
|
+
CType.void),
|
116
|
+
CType.void),
|
117
|
+
CType.unknown),
|
118
|
+
CType.void),
|
119
|
+
CType.function(CType.unknown,
|
120
|
+
[CType.value], CType.bool)),
|
140
121
|
"CRewriter" => :same,
|
141
122
|
"RubyToAnsiC" => "bool\nbools(void * arg1) {\nif (arg1) {\nreturn 0;\n} else {\nreturn 1;\n}\n}",
|
142
123
|
"RubyToRubyC" => "static VALUE\nrrc_c_bools(VALUE self, VALUE arg1) {\nif (NIL_P(arg1)) {\nreturn Qfalse;\n} else {\nreturn Qtrue;\n}\n}")
|
@@ -149,96 +130,96 @@ class R2CTestCase < ParseTreeTestCase
|
|
149
130
|
t(:block,
|
150
131
|
t(:lasgn,
|
151
132
|
:var,
|
152
|
-
t(:lit, 2,
|
153
|
-
|
133
|
+
t(:lit, 2, CType.long),
|
134
|
+
CType.long),
|
154
135
|
t(:lasgn,
|
155
136
|
:result,
|
156
|
-
t(:str, "",
|
157
|
-
|
137
|
+
t(:str, "", CType.str),
|
138
|
+
CType.str),
|
158
139
|
t(:if,
|
159
140
|
t(:call,
|
160
|
-
t(:lvar, :var,
|
141
|
+
t(:lvar, :var, CType.long),
|
161
142
|
:case_equal_long,
|
162
|
-
t(:arglist, t(:lit, 1,
|
163
|
-
|
143
|
+
t(:arglist, t(:lit, 1, CType.long)),
|
144
|
+
CType.bool),
|
164
145
|
t(:block,
|
165
146
|
t(:call,
|
166
147
|
nil,
|
167
148
|
:puts,
|
168
149
|
t(:arglist,
|
169
|
-
t(:str, "something",
|
170
|
-
|
150
|
+
t(:str, "something", CType.str)),
|
151
|
+
CType.void),
|
171
152
|
t(:lasgn,
|
172
153
|
:result,
|
173
|
-
t(:str, "red",
|
174
|
-
|
175
|
-
|
154
|
+
t(:str, "red", CType.str),
|
155
|
+
CType.str),
|
156
|
+
CType.str),
|
176
157
|
t(:if,
|
177
158
|
t(:or,
|
178
159
|
t(:call,
|
179
|
-
t(:lvar, :var,
|
160
|
+
t(:lvar, :var, CType.long),
|
180
161
|
:case_equal_long,
|
181
|
-
t(:arglist, t(:lit, 2,
|
182
|
-
|
162
|
+
t(:arglist, t(:lit, 2, CType.long)),
|
163
|
+
CType.bool),
|
183
164
|
t(:call,
|
184
|
-
t(:lvar, :var,
|
165
|
+
t(:lvar, :var, CType.long),
|
185
166
|
:case_equal_long,
|
186
|
-
t(:arglist, t(:lit, 3,
|
187
|
-
|
188
|
-
|
167
|
+
t(:arglist, t(:lit, 3, CType.long)),
|
168
|
+
CType.bool),
|
169
|
+
CType.bool),
|
189
170
|
t(:lasgn,
|
190
171
|
:result,
|
191
|
-
t(:str, "yellow",
|
192
|
-
|
172
|
+
t(:str, "yellow", CType.str),
|
173
|
+
CType.str),
|
193
174
|
t(:if,
|
194
175
|
t(:call,
|
195
|
-
t(:lvar, :var,
|
176
|
+
t(:lvar, :var, CType.long),
|
196
177
|
:case_equal_long,
|
197
|
-
t(:arglist, t(:lit, 4,
|
198
|
-
|
178
|
+
t(:arglist, t(:lit, 4, CType.long)),
|
179
|
+
CType.bool),
|
199
180
|
nil,
|
200
181
|
t(:lasgn,
|
201
182
|
:result,
|
202
|
-
t(:str, "green",
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
183
|
+
t(:str, "green", CType.str),
|
184
|
+
CType.str),
|
185
|
+
CType.str),
|
186
|
+
CType.str),
|
187
|
+
CType.str),
|
207
188
|
t(:if,
|
208
189
|
t(:call,
|
209
|
-
t(:lvar, :result,
|
190
|
+
t(:lvar, :result, CType.str),
|
210
191
|
:case_equal_str,
|
211
|
-
t(:arglist, t(:str, "red",
|
212
|
-
|
213
|
-
t(:lasgn, :var, t(:lit, 1,
|
192
|
+
t(:arglist, t(:str, "red", CType.str)),
|
193
|
+
CType.bool),
|
194
|
+
t(:lasgn, :var, t(:lit, 1, CType.long), CType.long),
|
214
195
|
t(:if,
|
215
196
|
t(:call,
|
216
|
-
t(:lvar, :result,
|
197
|
+
t(:lvar, :result, CType.str),
|
217
198
|
:case_equal_str,
|
218
|
-
t(:arglist, t(:str, "yellow",
|
219
|
-
|
220
|
-
t(:lasgn, :var, t(:lit, 2,
|
199
|
+
t(:arglist, t(:str, "yellow", CType.str)),
|
200
|
+
CType.bool),
|
201
|
+
t(:lasgn, :var, t(:lit, 2, CType.long), CType.long),
|
221
202
|
t(:if,
|
222
203
|
t(:call,
|
223
|
-
t(:lvar, :result,
|
204
|
+
t(:lvar, :result, CType.str),
|
224
205
|
:case_equal_str,
|
225
206
|
t(:arglist,
|
226
|
-
t(:str, "green",
|
227
|
-
|
207
|
+
t(:str, "green", CType.str)),
|
208
|
+
CType.bool),
|
228
209
|
t(:lasgn,
|
229
210
|
:var,
|
230
|
-
t(:lit, 3,
|
231
|
-
|
211
|
+
t(:lit, 3, CType.long),
|
212
|
+
CType.long),
|
232
213
|
nil,
|
233
|
-
|
234
|
-
|
235
|
-
|
214
|
+
CType.long),
|
215
|
+
CType.long),
|
216
|
+
CType.long),
|
236
217
|
t(:return,
|
237
|
-
t(:lvar, :result,
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
218
|
+
t(:lvar, :result, CType.str),
|
219
|
+
CType.void),
|
220
|
+
CType.unknown),
|
221
|
+
CType.void),
|
222
|
+
CType.function(CType.unknown, [], CType.str)),
|
242
223
|
"CRewriter" => :same,
|
243
224
|
# HACK: I don't like the semis after the if blocks, but it is a compromise right now
|
244
225
|
"RubyToAnsiC" => "str\ncase_stmt() {\nstr result;\nlong var;\nvar = 2;\nresult = \"\";\nif (case_equal_long(var, 1)) {\nputs(\"something\");\nresult = \"red\";\n} else {\nif (case_equal_long(var, 2) || case_equal_long(var, 3)) {\nresult = \"yellow\";\n} else {\nif (case_equal_long(var, 4)) {\n;\n} else {\nresult = \"green\";\n}\n}\n};\nif (case_equal_str(result, \"red\")) {\nvar = 1;\n} else {\nif (case_equal_str(result, \"yellow\")) {\nvar = 2;\n} else {\nif (case_equal_str(result, \"green\")) {\nvar = 3;\n}\n}\n};\nreturn result;\n}",
|
@@ -250,10 +231,10 @@ class R2CTestCase < ParseTreeTestCase
|
|
250
231
|
t(:args),
|
251
232
|
t(:scope,
|
252
233
|
t(:block,
|
253
|
-
t(:nil,
|
254
|
-
|
255
|
-
|
256
|
-
|
234
|
+
t(:nil, CType.value),
|
235
|
+
CType.unknown),
|
236
|
+
CType.void),
|
237
|
+
CType.function(CType.unknown, [], CType.void)),
|
257
238
|
"CRewriter" => :same,
|
258
239
|
"RubyToAnsiC" => "void\nempty() {\nNULL;\n}",
|
259
240
|
"RubyToRubyC" => "static VALUE\nrrc_c_empty(VALUE self) {\nQnil;\n}")
|
@@ -264,10 +245,10 @@ class R2CTestCase < ParseTreeTestCase
|
|
264
245
|
t(:args),
|
265
246
|
t(:scope,
|
266
247
|
t(:block,
|
267
|
-
t(:nil,
|
268
|
-
|
269
|
-
|
270
|
-
|
248
|
+
t(:nil, CType.value),
|
249
|
+
CType.unknown),
|
250
|
+
CType.void),
|
251
|
+
CType.function(CType.unknown, [], CType.void)),
|
271
252
|
"CRewriter" => :same,
|
272
253
|
"RubyToAnsiC" => "void\nis_something() {\nNULL;\n}",
|
273
254
|
"RubyToRubyC" => "static VALUE\nrrc_c_is_something(VALUE self) {\nQnil;\n}")
|
@@ -275,14 +256,14 @@ class R2CTestCase < ParseTreeTestCase
|
|
275
256
|
add_tests("defn_or",
|
276
257
|
"Rewriter" => :same,
|
277
258
|
"TypeChecker" => t(:defn, :|,
|
278
|
-
t(:args, t(:o,
|
259
|
+
t(:args, t(:o, CType.unknown)),
|
279
260
|
t(:scope,
|
280
261
|
t(:block,
|
281
|
-
t(:nil,
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
262
|
+
t(:nil, CType.value),
|
263
|
+
CType.unknown),
|
264
|
+
CType.void),
|
265
|
+
CType.function(CType.unknown, [CType.unknown],
|
266
|
+
CType.void)),
|
286
267
|
"CRewriter" => :same,
|
287
268
|
"RubyToAnsiC" => "void\nor(void * o) {\nNULL;\n}",
|
288
269
|
"RubyToRubyC" => "static VALUE\nrrc_c_or(VALUE self, VALUE o) {\nQnil;\n}")
|
@@ -294,12 +275,12 @@ class R2CTestCase < ParseTreeTestCase
|
|
294
275
|
t(:args),
|
295
276
|
t(:scope,
|
296
277
|
t(:block,
|
297
|
-
t(:lasgn, :a, t(:array),
|
278
|
+
t(:lasgn, :a, t(:array), CType.unknown_list),
|
298
279
|
t(:return,
|
299
280
|
t(:lvar,
|
300
|
-
:a,
|
301
|
-
|
302
|
-
|
281
|
+
:a, CType.unknown_list), CType.void),
|
282
|
+
CType.unknown), CType.void),
|
283
|
+
CType.function(CType.unknown, [], CType.unknown_list)),
|
303
284
|
"CRewriter" => :same,
|
304
285
|
"RubyToAnsiC" => "void *\nzarray() {\nvoid * a;\na = (void *) malloc(sizeof(void *) * 0);\nreturn a;\n}",
|
305
286
|
"RubyToRubyC" => "static VALUE\nrrc_c_zarray(VALUE self) {\nVALUE a;\na = rb_ary_new2(0);\nreturn a;\n}")
|
@@ -314,35 +295,34 @@ class R2CTestCase < ParseTreeTestCase
|
|
314
295
|
t(:ensure,
|
315
296
|
t(:rescue,
|
316
297
|
t(:call,
|
317
|
-
t(:lit, 1,
|
298
|
+
t(:lit, 1, CType.long),
|
318
299
|
:+,
|
319
|
-
t(:arglist, t(:lit, 1,
|
300
|
+
t(:arglist, t(:lit, 1, CType.long)), CType.long),
|
320
301
|
t(:resbody,
|
321
|
-
t(:array, t(:const, :SyntaxError,
|
302
|
+
t(:array, t(:const, :SyntaxError, CType.fucked)),
|
322
303
|
t(:block,
|
323
|
-
t(:lasgn, :e1, t(:gvar, :$!,
|
324
|
-
|
325
|
-
t(:lit, 2,
|
304
|
+
t(:lasgn, :e1, t(:gvar, :$!, CType.unknown),
|
305
|
+
CType.unknown),
|
306
|
+
t(:lit, 2, CType.long), CType.unknown),
|
326
307
|
t(:resbody,
|
327
|
-
t(:array, t(:const, :Exception,
|
308
|
+
t(:array, t(:const, :Exception, CType.fucked)),
|
328
309
|
t(:block,
|
329
|
-
t(:lasgn, :e2, t(:gvar, :$!,
|
330
|
-
|
331
|
-
t(:lit, 3,
|
332
|
-
|
333
|
-
t(:lit, 4,
|
334
|
-
t(:lit, 5,
|
335
|
-
|
336
|
-
|
310
|
+
t(:lasgn, :e2, t(:gvar, :$!, CType.unknown),
|
311
|
+
CType.unknown),
|
312
|
+
t(:lit, 3, CType.long), CType.unknown),
|
313
|
+
CType.unknown), CType.long),
|
314
|
+
t(:lit, 4, CType.long), CType.long),
|
315
|
+
t(:lit, 5, CType.long))), CType.unknown),
|
316
|
+
CType.void),
|
317
|
+
CType.function(CType.unknown, [], CType.void)),
|
337
318
|
"CRewriter" => :same,
|
338
319
|
"RubyToAnsiC" => :unsupported,
|
339
320
|
"RubyToRubyC" => :unsupported)
|
340
321
|
|
341
322
|
add_tests("global",
|
342
323
|
"Rewriter" => :same,
|
343
|
-
|
344
|
-
|
345
|
-
"TypeChecker" => t(:gvar, :$stderr, Type.file),
|
324
|
+
# TODO: test s(:gvar, :$stderr) != t(:gvar, $stderr, CType.file)
|
325
|
+
"TypeChecker" => t(:gvar, :$stderr, CType.file),
|
346
326
|
"CRewriter" => :same,
|
347
327
|
"RubyToAnsiC" => "stderr",
|
348
328
|
"RubyToRubyC" => "rb_gv_get(\"$stderr\")")
|
@@ -351,9 +331,9 @@ class R2CTestCase < ParseTreeTestCase
|
|
351
331
|
"Rewriter" => :skip,
|
352
332
|
"TypeChecker" => t(:dstr,
|
353
333
|
"var is ",
|
354
|
-
t(:lvar, :argl,
|
355
|
-
t(:str, ". So there.",
|
356
|
-
|
334
|
+
t(:lvar, :argl, CType.long),
|
335
|
+
t(:str, ". So there.", CType.str),
|
336
|
+
CType.str),
|
357
337
|
"CRewriter" => :same,
|
358
338
|
"RubyToAnsiC" => :unsupported,
|
359
339
|
"RubyToRubyC" => "rb_funcall(rb_mKernel, rb_intern(\"sprintf\"), 4, rb_str_new2(\"%s%s%s\"), rb_str_new2(\"var is \"), argl, rb_str_new2(\". So there.\"))")
|
@@ -361,22 +341,22 @@ class R2CTestCase < ParseTreeTestCase
|
|
361
341
|
add_tests("iter", # TODO: not in pttc
|
362
342
|
"Rewriter" => :skip,
|
363
343
|
"TypeChecker" => t(:iter,
|
364
|
-
t(:call, nil, :loop, nil,
|
365
|
-
t(:dasgn_curr, :temp_1,
|
344
|
+
t(:call, nil, :loop, nil, CType.unknown),
|
345
|
+
t(:dasgn_curr, :temp_1, CType.unknown),
|
366
346
|
nil,
|
367
|
-
|
347
|
+
CType.unknown),
|
368
348
|
"CRewriter" => :skip, # HACK don't do rb_iterate stuff for loop
|
369
349
|
# "CRewriter" => [:defx,
|
370
350
|
# t(:iter,
|
371
|
-
# t(:call, nil, :loop, nil,
|
351
|
+
# t(:call, nil, :loop, nil, CType.unknown),
|
372
352
|
# t(:args,
|
373
|
-
# t(:array, t(:dasgn_curr, :temp_1,
|
374
|
-
# t(:array,
|
353
|
+
# t(:array, t(:dasgn_curr, :temp_1, CType.unknown), CType.void),
|
354
|
+
# t(:array, CType.void), CType.void),
|
375
355
|
# t(:call, nil, :temp_1, nil)),
|
376
356
|
# [t(:defx,
|
377
357
|
# :temp_2,
|
378
358
|
# t(:args, :temp_2, :temp_3),
|
379
|
-
# t(:scope, t(:block, nil)),
|
359
|
+
# t(:scope, t(:block, nil)), CType.void)]],
|
380
360
|
"RubyToAnsiC" => "",
|
381
361
|
"RubyToRubyC" => "")
|
382
362
|
|
@@ -384,20 +364,20 @@ class R2CTestCase < ParseTreeTestCase
|
|
384
364
|
"Rewriter" => :same,
|
385
365
|
"TypeChecker" => t(:iter,
|
386
366
|
t(:call,
|
387
|
-
t(:lit, 3,
|
367
|
+
t(:lit, 3, CType.long),
|
388
368
|
:downto,
|
389
|
-
t(:arglist, t(:lit, 1,
|
390
|
-
|
391
|
-
t(:args, t(:lasgn, :n, nil,
|
369
|
+
t(:arglist, t(:lit, 1, CType.long)),
|
370
|
+
CType.unknown),
|
371
|
+
t(:args, t(:lasgn, :n, nil, CType.long)),
|
392
372
|
t(:call, nil, :puts,
|
393
373
|
t(:arglist,
|
394
374
|
t(:call,
|
395
|
-
t(:lvar, :n,
|
375
|
+
t(:lvar, :n, CType.long),
|
396
376
|
:to_s,
|
397
377
|
t(:arglist),
|
398
|
-
|
399
|
-
|
400
|
-
|
378
|
+
CType.str)),
|
379
|
+
CType.void),
|
380
|
+
CType.void),
|
401
381
|
"CRewriter" => :skip,
|
402
382
|
"RubyToAnsiC" => "n = 1;\nwhile (n <= 3) {\nputs(to_s(n));\nn = n + 1;\n}",
|
403
383
|
"RubyToRubyC" => "n = LONG2NUM(1);\nwhile (rb_funcall(n, rb_intern(\"<=\"), 1, LONG2NUM(3))) {\nrb_funcall(self, rb_intern(\"puts\"), 1, rb_funcall(n, rb_intern(\"to_s\"), 0));\nn = rb_funcall(n, rb_intern(\"+\"), 1, LONG2NUM(1));\n}")
|
@@ -407,76 +387,76 @@ class R2CTestCase < ParseTreeTestCase
|
|
407
387
|
"TypeChecker" => t(:block,
|
408
388
|
t(:lasgn, :array,
|
409
389
|
t(:array,
|
410
|
-
t(:lit, 1,
|
411
|
-
t(:lit, 2,
|
412
|
-
t(:lit, 3,
|
413
|
-
|
390
|
+
t(:lit, 1, CType.long),
|
391
|
+
t(:lit, 2, CType.long),
|
392
|
+
t(:lit, 3, CType.long)),
|
393
|
+
CType.long_list),
|
414
394
|
t(:iter,
|
415
395
|
t(:call,
|
416
|
-
t(:lvar, :array,
|
396
|
+
t(:lvar, :array, CType.long_list),
|
417
397
|
:each,
|
418
|
-
t(:arglist),
|
419
|
-
t(:args, t(:lasgn, :x, nil,
|
398
|
+
t(:arglist), CType.unknown),
|
399
|
+
t(:args, t(:lasgn, :x, nil, CType.long)),
|
420
400
|
t(:call, nil, :puts,
|
421
401
|
t(:arglist,
|
422
402
|
t(:call,
|
423
|
-
t(:lvar, :x,
|
403
|
+
t(:lvar, :x, CType.long),
|
424
404
|
:to_s,
|
425
405
|
t(:arglist),
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
"CRewriter" =>
|
406
|
+
CType.str)),
|
407
|
+
CType.void),
|
408
|
+
CType.void),
|
409
|
+
CType.unknown),
|
410
|
+
"CRewriter" => s(:defx,
|
431
411
|
t(:block,
|
432
412
|
t(:lasgn, :array,
|
433
413
|
t(:array,
|
434
|
-
t(:lit, 1,
|
435
|
-
t(:lit, 2,
|
436
|
-
t(:lit, 3,
|
437
|
-
|
414
|
+
t(:lit, 1, CType.long),
|
415
|
+
t(:lit, 2, CType.long),
|
416
|
+
t(:lit, 3, CType.long)),
|
417
|
+
CType.long_list),
|
438
418
|
t(:iter,
|
439
419
|
t(:call,
|
440
|
-
t(:lvar, :array,
|
420
|
+
t(:lvar, :array, CType.long_list),
|
441
421
|
:each,
|
442
|
-
t(:arglist),
|
422
|
+
t(:arglist), CType.unknown),
|
443
423
|
t(:args,
|
444
|
-
t(:array, t(:lvar, :x,
|
445
|
-
t(:array, t(:lvar, :static_temp_4,
|
446
|
-
|
447
|
-
:temp_1),
|
448
|
-
|
449
|
-
[t(:static, "static VALUE static_temp_4;",
|
424
|
+
t(:array, t(:lvar, :x, CType.value), CType.void),
|
425
|
+
t(:array, t(:lvar, :static_temp_4, CType.value), CType.void),
|
426
|
+
CType.void),
|
427
|
+
:temp_1, CType.void),
|
428
|
+
CType.unknown),
|
429
|
+
[t(:static, "static VALUE static_temp_4;", CType.fucked),
|
450
430
|
t(:defx,
|
451
431
|
:temp_1,
|
452
432
|
t(:args,
|
453
|
-
t(:temp_2,
|
454
|
-
t(:temp_3,
|
433
|
+
t(:temp_2, CType.value),
|
434
|
+
t(:temp_3, CType.value)),
|
455
435
|
t(:scope,
|
456
436
|
t(:block,
|
457
437
|
t(:lasgn, :x,
|
458
|
-
t(:lvar, :static_temp_4,
|
459
|
-
|
438
|
+
t(:lvar, :static_temp_4, CType.value),
|
439
|
+
CType.value),
|
460
440
|
t(:masgn,
|
461
441
|
t(:array),
|
462
442
|
t(:to_ary,
|
463
|
-
t(:lvar, :temp_2,
|
443
|
+
t(:lvar, :temp_2, CType.value))),
|
464
444
|
t(:call,
|
465
445
|
nil,
|
466
446
|
:puts,
|
467
447
|
t(:arglist,
|
468
448
|
t(:call,
|
469
|
-
t(:lvar, :x,
|
449
|
+
t(:lvar, :x, CType.long),
|
470
450
|
:to_s,
|
471
451
|
t(:arglist),
|
472
|
-
|
473
|
-
|
452
|
+
CType.str)),
|
453
|
+
CType.void),
|
474
454
|
t(:lasgn,
|
475
455
|
:static_temp_4,
|
476
|
-
t(:lvar, :x,
|
477
|
-
|
478
|
-
t(:return, t(:nil,
|
479
|
-
|
456
|
+
t(:lvar, :x, CType.value),
|
457
|
+
CType.value),
|
458
|
+
t(:return, t(:nil, CType.value)))),
|
459
|
+
CType.void)]),
|
480
460
|
"RubyToAnsiC" => :skip, # because eric sucks soooo much
|
481
461
|
# 'unsigned long index_x;
|
482
462
|
# for (index_x = 0; arrays[index_x] != NULL; ++index_x) {
|
@@ -511,46 +491,46 @@ class R2CTestCase < ParseTreeTestCase
|
|
511
491
|
"TypeChecker" => t(:block,
|
512
492
|
t(:lasgn, :array1,
|
513
493
|
t(:array,
|
514
|
-
t(:lit, 1,
|
515
|
-
t(:lit, 2,
|
516
|
-
t(:lit, 3,
|
494
|
+
t(:lit, 1, CType.long),
|
495
|
+
t(:lit, 2, CType.long),
|
496
|
+
t(:lit, 3, CType.long)), CType.long_list),
|
517
497
|
t(:lasgn, :array2,
|
518
498
|
t(:array,
|
519
|
-
t(:lit, 4,
|
520
|
-
t(:lit, 5,
|
521
|
-
t(:lit, 6,
|
522
|
-
t(:lit, 7,
|
499
|
+
t(:lit, 4, CType.long),
|
500
|
+
t(:lit, 5, CType.long),
|
501
|
+
t(:lit, 6, CType.long),
|
502
|
+
t(:lit, 7, CType.long)), CType.long_list),
|
523
503
|
t(:iter,
|
524
504
|
t(:call,
|
525
|
-
t(:lvar, :array1,
|
505
|
+
t(:lvar, :array1, CType.long_list),
|
526
506
|
:each,
|
527
|
-
t(:arglist),
|
528
|
-
t(:args, t(:lasgn, :x, nil,
|
507
|
+
t(:arglist), CType.unknown),
|
508
|
+
t(:args, t(:lasgn, :x, nil, CType.long)),
|
529
509
|
t(:iter,
|
530
510
|
t(:call,
|
531
|
-
t(:lvar, :array2,
|
511
|
+
t(:lvar, :array2, CType.long_list),
|
532
512
|
:each,
|
533
|
-
t(:arglist),
|
534
|
-
t(:args, t(:lasgn, :y, nil,
|
513
|
+
t(:arglist), CType.unknown),
|
514
|
+
t(:args, t(:lasgn, :y, nil, CType.long)),
|
535
515
|
t(:block,
|
536
516
|
t(:call, nil, :puts,
|
537
517
|
t(:arglist,
|
538
518
|
t(:call,
|
539
|
-
t(:lvar, :x,
|
519
|
+
t(:lvar, :x, CType.long),
|
540
520
|
:to_s,
|
541
|
-
t(:arglist),
|
542
|
-
|
521
|
+
t(:arglist), CType.str)),
|
522
|
+
CType.void),
|
543
523
|
t(:call, nil, :puts,
|
544
524
|
t(:arglist,
|
545
525
|
t(:call,
|
546
|
-
t(:lvar, :y,
|
526
|
+
t(:lvar, :y, CType.long),
|
547
527
|
:to_s,
|
548
|
-
t(:arglist),
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
528
|
+
t(:arglist), CType.str)),
|
529
|
+
CType.void),
|
530
|
+
CType.unknown),
|
531
|
+
CType.void),
|
532
|
+
CType.void),
|
533
|
+
CType.unknown),
|
554
534
|
"CRewriter" => :skip,
|
555
535
|
"RubyToAnsiC" => 'while (argl >= 1) {
|
556
536
|
puts("hello");
|
@@ -565,26 +545,26 @@ argl = rb_funcall(argl, rb_intern("-"), 1, LONG2NUM(1));
|
|
565
545
|
"Rewriter" => :same,
|
566
546
|
"TypeChecker" => t(:block,
|
567
547
|
t(:lasgn, :argl,
|
568
|
-
t(:lit, 10,
|
548
|
+
t(:lit, 10, CType.long), CType.long),
|
569
549
|
t(:while,
|
570
550
|
t(:call,
|
571
|
-
t(:lvar, :argl,
|
551
|
+
t(:lvar, :argl, CType.long),
|
572
552
|
:>=,
|
573
|
-
t(:arglist, t(:lit, 1,
|
553
|
+
t(:arglist, t(:lit, 1, CType.long)), CType.bool),
|
574
554
|
t(:block,
|
575
555
|
t(:call, nil, :puts,
|
576
556
|
t(:arglist,
|
577
|
-
t(:str, 'hello',
|
578
|
-
|
557
|
+
t(:str, 'hello', CType.str)),
|
558
|
+
CType.void),
|
579
559
|
t(:lasgn, :argl,
|
580
560
|
t(:call,
|
581
|
-
t(:lvar, :argl,
|
561
|
+
t(:lvar, :argl, CType.long),
|
582
562
|
:-,
|
583
|
-
t(:arglist, t(:lit, 1,
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
563
|
+
t(:arglist, t(:lit, 1, CType.long)),
|
564
|
+
CType.long),
|
565
|
+
CType.long),
|
566
|
+
CType.unknown), true),
|
567
|
+
CType.unknown),
|
588
568
|
"CRewriter" => :same,
|
589
569
|
"RubyToAnsiC" => "argl = 10;\nwhile (argl >= 1) {\nputs(\"hello\");\nargl = argl - 1;\n}\n",
|
590
570
|
"RubyToRubyC" => "argl = LONG2NUM(10);\nwhile (rb_funcall(argl, rb_intern(\">=\"), 1, LONG2NUM(1))) {\nrb_funcall(self, rb_intern(\"puts\"), 1, rb_str_new2(\"hello\"));\nargl = rb_funcall(argl, rb_intern(\"-\"), 1, LONG2NUM(1));\n}\n")
|
@@ -605,9 +585,9 @@ argl = rb_funcall(argl, rb_intern("-"), 1, LONG2NUM(1));
|
|
605
585
|
"TypeChecker" => t(:lasgn,
|
606
586
|
:var,
|
607
587
|
t(:array,
|
608
|
-
t(:str, "foo",
|
609
|
-
t(:str, "bar",
|
610
|
-
|
588
|
+
t(:str, "foo", CType.str),
|
589
|
+
t(:str, "bar", CType.str)),
|
590
|
+
CType.str_list),
|
611
591
|
"CRewriter" => :same,
|
612
592
|
"RubyToRubyC" => 'var = rb_ary_new2(2);
|
613
593
|
rb_ary_store(var, 0, rb_str_new2("foo"));
|
@@ -620,68 +600,68 @@ var[1] = "bar"')
|
|
620
600
|
"Rewriter" => :same,
|
621
601
|
"TypeChecker" => t(:lasgn, :c,
|
622
602
|
t(:call,
|
623
|
-
t(:lit, 2,
|
603
|
+
t(:lit, 2, CType.long),
|
624
604
|
:+,
|
625
605
|
t(:arglist,
|
626
|
-
t(:lit, 3,
|
627
|
-
|
628
|
-
|
606
|
+
t(:lit, 3, CType.long)),
|
607
|
+
CType.long),
|
608
|
+
CType.long),
|
629
609
|
"CRewriter" => :same,
|
630
610
|
"RubyToAnsiC" => "c = 2 + 3", # FIX: probably not "c =
|
631
611
|
"RubyToRubyC" => 'c = rb_funcall(LONG2NUM(2), rb_intern("+"), 1, LONG2NUM(3))')
|
632
612
|
|
633
613
|
add_tests("lit_bool_false",
|
634
614
|
"Rewriter" => :same,
|
635
|
-
"TypeChecker" => t(:false,
|
615
|
+
"TypeChecker" => t(:false, CType.bool),
|
636
616
|
"CRewriter" => :same,
|
637
617
|
"RubyToAnsiC" => "0",
|
638
618
|
"RubyToRubyC" => "Qfalse")
|
639
619
|
|
640
620
|
add_tests("lit_bool_true",
|
641
621
|
"Rewriter" => :same,
|
642
|
-
"TypeChecker" => t(:true,
|
622
|
+
"TypeChecker" => t(:true, CType.bool),
|
643
623
|
"CRewriter" => :same,
|
644
624
|
"RubyToAnsiC" => "1",
|
645
625
|
"RubyToRubyC" => "Qtrue")
|
646
626
|
|
647
627
|
add_tests("lit_float",
|
648
628
|
"Rewriter" => :same,
|
649
|
-
"TypeChecker" => t(:lit, 1.1,
|
629
|
+
"TypeChecker" => t(:lit, 1.1, CType.float),
|
650
630
|
"CRewriter" => :same,
|
651
631
|
"RubyToAnsiC" => "1.1",
|
652
632
|
"RubyToRubyC" => "rb_float_new(1.1)")
|
653
633
|
|
654
634
|
add_tests("lit_long",
|
655
635
|
"Rewriter" => :same,
|
656
|
-
"TypeChecker" => t(:lit, 1,
|
636
|
+
"TypeChecker" => t(:lit, 1, CType.long),
|
657
637
|
"CRewriter" => :same,
|
658
638
|
"RubyToAnsiC" => "1",
|
659
639
|
"RubyToRubyC" => "LONG2NUM(1)")
|
660
640
|
|
661
641
|
add_tests("lit_long_negative",
|
662
642
|
"Rewriter" => :same,
|
663
|
-
"TypeChecker" => t(:lit, -1,
|
643
|
+
"TypeChecker" => t(:lit, -1, CType.long),
|
664
644
|
"CRewriter" => :same,
|
665
645
|
"RubyToAnsiC" => "-1",
|
666
646
|
"RubyToRubyC" => "LONG2NUM(-1)")
|
667
647
|
|
668
648
|
add_tests("lit_range2",
|
669
649
|
"Rewriter" => :same,
|
670
|
-
"TypeChecker" => t(:lit, 1..10,
|
650
|
+
"TypeChecker" => t(:lit, 1..10, CType.range),
|
671
651
|
"CRewriter" => :same,
|
672
652
|
"RubyToAnsiC" => :skip,
|
673
653
|
"RubyToRubyC" => :skip)
|
674
654
|
|
675
655
|
add_tests("lit_range3",
|
676
656
|
"Rewriter" => :same,
|
677
|
-
"TypeChecker" => t(:lit, 1...10,
|
657
|
+
"TypeChecker" => t(:lit, 1...10, CType.range),
|
678
658
|
"CRewriter" => :same,
|
679
659
|
"RubyToAnsiC" => :skip,
|
680
660
|
"RubyToRubyC" => :skip)
|
681
661
|
|
682
662
|
add_tests("lit_regexp",
|
683
663
|
"Rewriter" => :same,
|
684
|
-
"TypeChecker" => t(:lit, /x/,
|
664
|
+
"TypeChecker" => t(:lit, /x/, CType.regexp),
|
685
665
|
"CRewriter" => :same,
|
686
666
|
"RubyToAnsiC" => :skip,
|
687
667
|
"RubyToRubyC" => :skip)
|
@@ -689,24 +669,24 @@ var[1] = "bar"')
|
|
689
669
|
add_tests("lit_regexp_i_wwtt",
|
690
670
|
"Rewriter" => :same,
|
691
671
|
"TypeChecker" => t(:call,
|
692
|
-
t(:call, nil, :str, t(:arglist),
|
672
|
+
t(:call, nil, :str, t(:arglist), CType.unknown),
|
693
673
|
:split,
|
694
|
-
t(:arglist, t(:lit, //i,
|
695
|
-
|
674
|
+
t(:arglist, t(:lit, //i, CType.regexp)),
|
675
|
+
CType.unknown),
|
696
676
|
"CRewriter" => :same,
|
697
677
|
"RubyToAnsiC" => :skip,
|
698
678
|
"RubyToRubyC" => :skip)
|
699
679
|
|
700
680
|
add_tests("lit_regexp_n",
|
701
681
|
"Rewriter" => :same,
|
702
|
-
"TypeChecker" => t(:lit, /x/n,
|
682
|
+
"TypeChecker" => t(:lit, /x/n, CType.regexp),
|
703
683
|
"CRewriter" => :same,
|
704
684
|
"RubyToAnsiC" => :skip,
|
705
685
|
"RubyToRubyC" => :skip)
|
706
686
|
|
707
687
|
add_tests("lit_regexp_once",
|
708
688
|
"Rewriter" => :same,
|
709
|
-
"TypeChecker" => t(:lit, /x/,
|
689
|
+
"TypeChecker" => t(:lit, /x/, CType.regexp), # HACK - once?
|
710
690
|
"CRewriter" => :same,
|
711
691
|
"RubyToAnsiC" => :skip,
|
712
692
|
"RubyToRubyC" => :skip)
|
@@ -714,21 +694,21 @@ var[1] = "bar"')
|
|
714
694
|
add_tests("lit_str", # TODO: not in pttc
|
715
695
|
"ParseTree" => s(:str, "x"),
|
716
696
|
"Rewriter" => :same,
|
717
|
-
"TypeChecker" => t(:str, "x",
|
697
|
+
"TypeChecker" => t(:str, "x", CType.str),
|
718
698
|
"CRewriter" => :same,
|
719
699
|
"RubyToAnsiC" => '"x"',
|
720
700
|
"RubyToRubyC" => 'rb_str_new2("x")')
|
721
701
|
|
722
702
|
add_tests("lit_sym",
|
723
703
|
"Rewriter" => :same,
|
724
|
-
"TypeChecker" => t(:lit, :x,
|
704
|
+
"TypeChecker" => t(:lit, :x, CType.symbol),
|
725
705
|
"CRewriter" => :same,
|
726
706
|
"RubyToAnsiC" => '"x"', # HACK WRONG! (or... is it?
|
727
707
|
"RubyToRubyC" => 'ID2SYM(rb_intern("x"))')
|
728
708
|
|
729
709
|
add_tests("lit_sym_splat",
|
730
710
|
"Rewriter" => :same,
|
731
|
-
"TypeChecker" => t(:lit, :"*args",
|
711
|
+
"TypeChecker" => t(:lit, :"*args", CType.symbol),
|
732
712
|
"CRewriter" => :same,
|
733
713
|
"RubyToAnsiC" => '"*args"',
|
734
714
|
"RubyToRubyC" => 'ID2SYM(rb_intern("*args"))')
|
@@ -761,38 +741,38 @@ var[1] = "bar"')
|
|
761
741
|
"Rewriter" => :same,
|
762
742
|
"TypeChecker" => t(:defn, :multi_args,
|
763
743
|
t(:args,
|
764
|
-
t(:arg1,
|
765
|
-
t(:arg2,
|
744
|
+
t(:arg1, CType.long),
|
745
|
+
t(:arg2, CType.long)),
|
766
746
|
t(:scope,
|
767
747
|
t(:block,
|
768
748
|
t(:lasgn,
|
769
749
|
:arg3,
|
770
750
|
t(:call,
|
771
751
|
t(:call,
|
772
|
-
t(:lvar, :arg1,
|
752
|
+
t(:lvar, :arg1, CType.long),
|
773
753
|
:*,
|
774
|
-
t(:arglist, t(:lvar, :arg2,
|
775
|
-
|
754
|
+
t(:arglist, t(:lvar, :arg2, CType.long)),
|
755
|
+
CType.long),
|
776
756
|
:*,
|
777
|
-
t(:arglist, t(:lit, 7,
|
778
|
-
|
779
|
-
|
757
|
+
t(:arglist, t(:lit, 7, CType.long)),
|
758
|
+
CType.long),
|
759
|
+
CType.long),
|
780
760
|
t(:call,
|
781
761
|
nil,
|
782
762
|
:puts,
|
783
763
|
t(:arglist,
|
784
764
|
t(:call,
|
785
|
-
t(:lvar, :arg3,
|
765
|
+
t(:lvar, :arg3, CType.long),
|
786
766
|
:to_s,
|
787
767
|
t(:arglist),
|
788
|
-
|
789
|
-
|
790
|
-
t(:return, t(:str, "foo",
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
[
|
768
|
+
CType.str)),
|
769
|
+
CType.void),
|
770
|
+
t(:return, t(:str, "foo", CType.str),
|
771
|
+
CType.void),
|
772
|
+
CType.unknown),
|
773
|
+
CType.void),
|
774
|
+
CType.function(CType.unknown,
|
775
|
+
[CType.long, CType.long], CType.str)),
|
796
776
|
"CRewriter" => :same,
|
797
777
|
"RubyToRubyC" => "static VALUE
|
798
778
|
rrc_c_multi_args(VALUE self, VALUE arg1, VALUE arg2) {
|
@@ -811,7 +791,7 @@ return \"foo\";
|
|
811
791
|
|
812
792
|
add_tests("not__18",
|
813
793
|
"Rewriter" => :same,
|
814
|
-
"TypeChecker" => t(:not, t(:true,
|
794
|
+
"TypeChecker" => t(:not, t(:true, CType.bool), CType.bool),
|
815
795
|
"CRewriter" => :same,
|
816
796
|
"RubyToAnsiC" => "!(1)",
|
817
797
|
"RubyToRubyC" => "!(Qtrue)")
|
@@ -819,16 +799,16 @@ return \"foo\";
|
|
819
799
|
add_tests("or",
|
820
800
|
"Rewriter" => :same,
|
821
801
|
"TypeChecker" => t(:or,
|
822
|
-
t(:call, nil, :a, t(:arglist),
|
823
|
-
t(:call, nil, :b, t(:arglist),
|
824
|
-
|
802
|
+
t(:call, nil, :a, t(:arglist), CType.bool),
|
803
|
+
t(:call, nil, :b, t(:arglist), CType.bool),
|
804
|
+
CType.bool),
|
825
805
|
"CRewriter" => :same,
|
826
806
|
"RubyToAnsiC" => 'a() || b()',
|
827
807
|
"RubyToRubyC" => 'rb_funcall(self, rb_intern("a"), 0) || rb_funcall(self, rb_intern("b"), 0)')
|
828
808
|
|
829
809
|
add_tests("vcall",
|
830
810
|
"Rewriter" => :same,
|
831
|
-
"TypeChecker" => t(:call, nil, :method, t(:arglist),
|
811
|
+
"TypeChecker" => t(:call, nil, :method, t(:arglist), CType.unknown),
|
832
812
|
"CRewriter" => :same,
|
833
813
|
"RubyToAnsiC" => "method()",
|
834
814
|
"RubyToRubyC" => "rb_funcall(self, rb_intern(\"method\"), 0)")
|
@@ -862,29 +842,29 @@ return \"foo\";
|
|
862
842
|
t(:scope,
|
863
843
|
t(:block,
|
864
844
|
t(:while,
|
865
|
-
t(:false,
|
845
|
+
t(:false, CType.bool),
|
866
846
|
t(:call,
|
867
847
|
nil,
|
868
848
|
:puts,
|
869
|
-
t(:arglist, t(:str, "false",
|
849
|
+
t(:arglist, t(:str, "false", CType.str)), CType.void),
|
870
850
|
true),
|
871
851
|
t(:while,
|
872
|
-
t(:false,
|
852
|
+
t(:false, CType.bool),
|
873
853
|
t(:call,
|
874
854
|
nil,
|
875
855
|
:puts,
|
876
|
-
t(:arglist, t(:str, "true",
|
856
|
+
t(:arglist, t(:str, "true", CType.str)), CType.void),
|
877
857
|
false),
|
878
|
-
|
879
|
-
|
880
|
-
|
858
|
+
CType.unknown),
|
859
|
+
CType.void),
|
860
|
+
CType.function(CType.unknown, [], CType.void)),
|
881
861
|
"CRewriter" => :same,
|
882
862
|
"RubyToAnsiC" => "void\nwhiles() {\nwhile (0) {\nputs(\"false\");\n};\n{\nputs(\"true\");\n} while (0);\n}",
|
883
863
|
"RubyToRubyC" => "static VALUE\nrrc_c_whiles(VALUE self) {\nwhile (Qfalse) {\nrb_funcall(self, rb_intern(\"puts\"), 1, rb_str_new2(\"false\"));\n};\n{\nrb_funcall(self, rb_intern(\"puts\"), 1, rb_str_new2(\"true\"));\n} while (Qfalse);\n}")
|
884
864
|
|
885
865
|
add_tests("zarray",
|
886
866
|
"Rewriter" => :same,
|
887
|
-
"TypeChecker" => t(:lasgn, :a, t(:array),
|
867
|
+
"TypeChecker" => t(:lasgn, :a, t(:array), CType.unknown_list),
|
888
868
|
"CRewriter" => :same,
|
889
869
|
# TODO: need to verify that our variable decl will be correct
|
890
870
|
"RubyToAnsiC" => "a = (void *) malloc(sizeof(void *) * 0)",
|
@@ -892,21 +872,21 @@ return \"foo\";
|
|
892
872
|
|
893
873
|
add_tests("str_question_control__18",
|
894
874
|
"Rewriter" => :same,
|
895
|
-
"TypeChecker" => t(:lit, 129,
|
875
|
+
"TypeChecker" => t(:lit, 129, CType.long),
|
896
876
|
"CRewriter" => :same,
|
897
877
|
"RubyToAnsiC" => "129",
|
898
878
|
"RubyToRubyC" => "LONG2NUM(129)")
|
899
879
|
|
900
880
|
add_tests("str_question_escape__18",
|
901
881
|
"Rewriter" => :same,
|
902
|
-
"TypeChecker" => t(:lit, 10,
|
882
|
+
"TypeChecker" => t(:lit, 10, CType.long),
|
903
883
|
"CRewriter" => :same,
|
904
884
|
"RubyToAnsiC" => "10",
|
905
885
|
"RubyToRubyC" => "LONG2NUM(10)")
|
906
886
|
|
907
887
|
add_tests("str_question_literal__18",
|
908
888
|
"Rewriter" => :same,
|
909
|
-
"TypeChecker" => t(:lit, 97,
|
889
|
+
"TypeChecker" => t(:lit, 97, CType.long),
|
910
890
|
"CRewriter" => :same,
|
911
891
|
"RubyToAnsiC" => "97",
|
912
892
|
"RubyToRubyC" => "LONG2NUM(97)")
|
@@ -1156,6 +1136,7 @@ return \"foo\";
|
|
1156
1136
|
"return_1_splatted",
|
1157
1137
|
"return_n",
|
1158
1138
|
"sclass",
|
1139
|
+
"sclass_multiple",
|
1159
1140
|
"sclass_trailing_class",
|
1160
1141
|
"splat",
|
1161
1142
|
"splat_array",
|
@@ -1187,7 +1168,6 @@ return \"foo\";
|
|
1187
1168
|
"structure_extra_block_for_dvar_scoping",
|
1188
1169
|
"structure_remove_begin_1",
|
1189
1170
|
"structure_remove_begin_2",
|
1190
|
-
"structure_unused_literal_wwtt",
|
1191
1171
|
"super_0",
|
1192
1172
|
"super_1",
|
1193
1173
|
"super_1_array",
|
@@ -1233,5 +1213,58 @@ return \"foo\";
|
|
1233
1213
|
"yield_array_1",
|
1234
1214
|
"yield_array_n",
|
1235
1215
|
"yield_n",
|
1216
|
+
"if_args_no_space_symbol__18",
|
1236
1217
|
"zsuper")
|
1218
|
+
|
1219
|
+
add_skipped_tests19("array_bare_hash",
|
1220
|
+
"array_bare_hash_labels",
|
1221
|
+
"call_arglist_norm_hash_colons",
|
1222
|
+
"call_arglist_trailing_comma",
|
1223
|
+
"call_bang",
|
1224
|
+
"call_bang_empty",
|
1225
|
+
"call_fonz",
|
1226
|
+
"call_fonz_cm",
|
1227
|
+
"call_not",
|
1228
|
+
"call_not_equal",
|
1229
|
+
"call_splat_mid",
|
1230
|
+
"defn_args_mand_opt_mand",
|
1231
|
+
"defn_args_mand_opt_splat_mand",
|
1232
|
+
"defn_args_opt_mand",
|
1233
|
+
"defn_args_opt_splat_mand",
|
1234
|
+
"defn_args_splat_mand",
|
1235
|
+
"defn_args_splat_middle",
|
1236
|
+
"fcall_arglist_hash_colons",
|
1237
|
+
"hash_new",
|
1238
|
+
"hash_new_no_space",
|
1239
|
+
"hash_new_with_keyword",
|
1240
|
+
"if_post_not",
|
1241
|
+
"if_pre_not",
|
1242
|
+
"label_in_bare_hash_in_array_in_ternary",
|
1243
|
+
"label_in_callargs_in_ternary",
|
1244
|
+
"not",
|
1245
|
+
"splat_fcall_middle",
|
1246
|
+
"stabby_args_0_no_parens",
|
1247
|
+
"stabby_args_0_no_parens_doend",
|
1248
|
+
"stabby_args_0_spacebar_broken",
|
1249
|
+
"stabby_args_1",
|
1250
|
+
"stabby_args_1_doend",
|
1251
|
+
"stabby_args_1_no_parens",
|
1252
|
+
"stabby_args_1_no_parens_doend",
|
1253
|
+
"stabby_args_2",
|
1254
|
+
"stabby_args_2_doend",
|
1255
|
+
"stabby_args_2_no_parens",
|
1256
|
+
"stabby_args_2_no_parens_doend",
|
1257
|
+
"stabby_args",
|
1258
|
+
"stabby_args_doend",
|
1259
|
+
"str_question_control",
|
1260
|
+
"str_question_escape",
|
1261
|
+
"str_question_literal",
|
1262
|
+
"unless_post_not",
|
1263
|
+
"unless_pre_not",
|
1264
|
+
"until_post_not",
|
1265
|
+
"until_pre_not",
|
1266
|
+
"until_pre_not_mod",
|
1267
|
+
"while_post_not",
|
1268
|
+
"while_pre_not",
|
1269
|
+
"while_pre_not_mod")
|
1237
1270
|
end
|