ruby2c 1.0.0.7 → 1.0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/.gemtest +0 -0
- data/History.txt +17 -0
- data/README.txt +9 -15
- data/lib/crewriter.rb +2 -2
- data/lib/r2cenvironment.rb +1 -1
- data/lib/ruby_to_ansi_c.rb +2 -7
- data/lib/ruby_to_ruby_c.rb +0 -31
- data/lib/type_checker.rb +54 -4
- data/test/r2ctestcase.rb +59 -18
- data/test/test_function_type.rb +3 -0
- data/test/test_ruby_to_ansi_c.rb +1 -1
- data/test/test_type_checker.rb +7 -7
- metadata +92 -23
- metadata.gz.sig +0 -0
data.tar.gz.sig
ADDED
Binary file
|
data/.gemtest
ADDED
File without changes
|
data/History.txt
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
=== 1.0.0.8 / 2012-11-09
|
2
|
+
|
3
|
+
* 5 minor enhancements:
|
4
|
+
|
5
|
+
* Added TypeChecker methods: rewrite_attrasgn, rewrite_call, rewrite_defn to reverse structural changes in ruby_parser 3.x.
|
6
|
+
* Added new 1.9 tests from PTTC to skip list
|
7
|
+
* Added new test case data for new 1.8 based tests
|
8
|
+
* Added process_arglist_plain and hooked it up with process_iter to deal with new block sexps.
|
9
|
+
* Renames for ruby_parser namespace changes
|
10
|
+
|
11
|
+
* 4 bug fixes:
|
12
|
+
|
13
|
+
* Environment moved in ruby_parser. Got tests running again.
|
14
|
+
* Fixed all tests broken by 1.8/1.9 split in pt_testcase.rb.
|
15
|
+
* Removed unused variables listed in 1.9 warnings
|
16
|
+
* Spastic monkey is spastic
|
17
|
+
|
1
18
|
=== 1.0.0.7 / 2009-08-18
|
2
19
|
|
3
20
|
* 1 bug fix:
|
data/README.txt
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
= RubyToC
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
* ruby2c@zenspider.com - mailing list
|
3
|
+
home :: https://github.com/seattlerb/ruby_to_c
|
4
|
+
rdoc :: http://ruby2c.rubyforge.org/ruby2c
|
6
5
|
|
7
6
|
== DESCRIPTION:
|
8
7
|
|
@@ -21,26 +20,21 @@ RubyToC has the following modules:
|
|
21
20
|
* RubyToRubyC - converts a ruby (subset) sexp to ruby interals C.
|
22
21
|
* RubyToAnsiC - converts a ruby (subset) sexp to ANSI C.
|
23
22
|
|
24
|
-
and the following tools:
|
25
|
-
|
26
|
-
* translate.rb - Translates a given file to C.
|
27
|
-
|
28
23
|
== FEATURES/PROBLEMS:
|
29
24
|
|
30
25
|
* This is a preview release! BETA BETA BETA! Do NOT use this!
|
31
|
-
* Please contact me or Eric (drbrain of segment7 dot net) if you:
|
32
|
-
* have any feedback!
|
33
|
-
* have any changes!
|
34
|
-
* want to work on this!
|
35
26
|
|
36
27
|
== SYNOPSYS:
|
37
28
|
|
38
|
-
|
29
|
+
require 'ruby_parser'
|
30
|
+
require 'ruby_to_ruby_c'
|
31
|
+
|
32
|
+
sexp = RubyParser.new.parse '1 + 1'
|
33
|
+
c = RubyToRubyC.new.process sexp
|
39
34
|
|
40
35
|
== TODO:
|
41
36
|
|
42
37
|
* Numerous, but we are trying to get them in here... sorry...
|
43
|
-
* Want to move to a gem directory structure (lib/ test/ bin/ etc)
|
44
38
|
|
45
39
|
== REQUIREMENTS:
|
46
40
|
|
@@ -48,13 +42,13 @@ and the following tools:
|
|
48
42
|
|
49
43
|
== INSTALL:
|
50
44
|
|
51
|
-
* sudo gem install
|
45
|
+
* sudo gem install ruby2c
|
52
46
|
|
53
47
|
== LICENSE:
|
54
48
|
|
55
49
|
(The MIT License)
|
56
50
|
|
57
|
-
Copyright (c)
|
51
|
+
Copyright (c) Ryan Davis, Eric Hodel, seattle.rb
|
58
52
|
|
59
53
|
Permission is hereby granted, free of charge, to any person obtaining
|
60
54
|
a copy of this software and associated documentation files (the
|
data/lib/crewriter.rb
CHANGED
@@ -41,8 +41,8 @@ class CRewriter < SexpProcessor
|
|
41
41
|
|
42
42
|
env = @env.all
|
43
43
|
|
44
|
-
free = env.select { |k, (
|
45
|
-
vars = free.map { |k, (t,
|
44
|
+
free = env.select { |k, (_, v)| bound_in_parent.include? k or not v }
|
45
|
+
vars = free.map { |k, (t, _)| [k, t] }
|
46
46
|
return vars
|
47
47
|
end
|
48
48
|
|
data/lib/r2cenvironment.rb
CHANGED
data/lib/ruby_to_ansi_c.rb
CHANGED
@@ -21,7 +21,7 @@ require 'r2cenvironment'
|
|
21
21
|
|
22
22
|
class RubyToAnsiC < SexpProcessor
|
23
23
|
|
24
|
-
VERSION = '1.0.0.
|
24
|
+
VERSION = '1.0.0.8'
|
25
25
|
|
26
26
|
# TODO: remove me
|
27
27
|
def no(exp) # :nodoc:
|
@@ -407,9 +407,7 @@ typedef char * str;
|
|
407
407
|
|
408
408
|
result = "if (#{cond_part})"
|
409
409
|
|
410
|
-
then_block = ! exp.first.nil? && exp.first.first == :block
|
411
410
|
then_part = process exp.shift
|
412
|
-
else_block = ! exp.first.nil? && exp.first.first == :block
|
413
411
|
else_part = process exp.shift
|
414
412
|
|
415
413
|
then_part = "" if then_part.nil?
|
@@ -448,9 +446,7 @@ typedef char * str;
|
|
448
446
|
@env.scope do
|
449
447
|
enum = exp[0][1][1] # HACK ugly t(:iter, t(:call, lhs <-- get lhs
|
450
448
|
|
451
|
-
|
452
|
-
|
453
|
-
call = process exp.shift
|
449
|
+
_ = process exp.shift
|
454
450
|
var = process(exp.shift).intern # semi-HACK-y
|
455
451
|
body = process exp.shift
|
456
452
|
index = "index_#{var}"
|
@@ -493,7 +489,6 @@ typedef char * str;
|
|
493
489
|
|
494
490
|
exp_type = exp.sexp_type
|
495
491
|
@env.add var.to_sym, exp_type
|
496
|
-
var_type = self.class.c_type exp_type
|
497
492
|
|
498
493
|
if exp_type.list? then
|
499
494
|
assert_type args, :array
|
data/lib/ruby_to_ruby_c.rb
CHANGED
@@ -129,36 +129,6 @@ class RubyToRubyC < RubyToAnsiC
|
|
129
129
|
# TODO: pull iasgn from obfuscator
|
130
130
|
# TODO: pull ivar from obfuscator
|
131
131
|
|
132
|
-
##
|
133
|
-
# Iterators for loops. After rewriter nearly all iter nodes
|
134
|
-
# should be able to be interpreted as a for loop. If not, then you
|
135
|
-
# are doing something not supported by C in the first place.
|
136
|
-
|
137
|
-
def process_OLD_iter(exp) # TODO/REFACTOR: audit against obfuscator
|
138
|
-
out = []
|
139
|
-
# Only support enums in C-land
|
140
|
-
raise UnsupportedNodeError if exp[0][1].nil? # HACK ugly
|
141
|
-
@env.scope do
|
142
|
-
enum = exp[0][1][1] # HACK ugly t(:iter, t(:call, lhs <-- get lhs
|
143
|
-
call = process exp.shift
|
144
|
-
var = process(exp.shift).intern # semi-HACK-y
|
145
|
-
body = process exp.shift
|
146
|
-
index = "index_#{var}"
|
147
|
-
|
148
|
-
body += ";" unless body =~ /[;}]\Z/
|
149
|
-
body.gsub!(/\n\n+/, "\n")
|
150
|
-
|
151
|
-
out << "unsigned long #{index};"
|
152
|
-
out << "unsigned long arrays_max = FIX2LONG(rb_funcall(arrays, rb_intern(\"size\"), 0));"
|
153
|
-
out << "for (#{index} = 0; #{index} < arrays_max; ++#{index}) {"
|
154
|
-
out << "VALUE x = rb_funcall(arrays, rb_intern(\"at\"), 1, LONG2FIX(index_x));"
|
155
|
-
out << body
|
156
|
-
out << "}"
|
157
|
-
end
|
158
|
-
|
159
|
-
return out.join("\n")
|
160
|
-
end
|
161
|
-
|
162
132
|
##
|
163
133
|
# Iterators for loops. After rewriter nearly all iter nodes
|
164
134
|
# should be able to be interpreted as a for loop. If not, then you
|
@@ -214,7 +184,6 @@ class RubyToRubyC < RubyToAnsiC
|
|
214
184
|
|
215
185
|
exp_type = exp.sexp_type
|
216
186
|
@env.add var.to_sym, exp_type
|
217
|
-
var_type = self.class.c_type exp_type
|
218
187
|
|
219
188
|
if exp_type.list? then
|
220
189
|
assert_type args, :array
|
data/lib/type_checker.rb
CHANGED
@@ -161,7 +161,6 @@ class TypeChecker < SexpProcessor
|
|
161
161
|
def process_arglist(exp)
|
162
162
|
args = process_array exp
|
163
163
|
args[0] = :arglist
|
164
|
-
|
165
164
|
args
|
166
165
|
end
|
167
166
|
|
@@ -179,6 +178,12 @@ class TypeChecker < SexpProcessor
|
|
179
178
|
vars
|
180
179
|
end
|
181
180
|
|
181
|
+
def rewrite_attrasgn exp
|
182
|
+
t, lhs, name, *rhs = exp
|
183
|
+
|
184
|
+
s(t, lhs, name, s(:arglist, *rhs))
|
185
|
+
end
|
186
|
+
|
182
187
|
##
|
183
188
|
# Attrasgn processes its rhs and lhs, then returns an untyped sexp.
|
184
189
|
#--
|
@@ -239,6 +244,19 @@ class TypeChecker < SexpProcessor
|
|
239
244
|
t(:block_pass, block, call)
|
240
245
|
end
|
241
246
|
|
247
|
+
def rewrite_call(exp)
|
248
|
+
t, recv, meth, *args = exp
|
249
|
+
|
250
|
+
args = args.compact
|
251
|
+
args = [s(:arglist)] if args == []
|
252
|
+
|
253
|
+
unless args.first and args.first.first == :arglist then
|
254
|
+
args = [s(:arglist, *args)]
|
255
|
+
end
|
256
|
+
|
257
|
+
s(t, recv, meth, *args)
|
258
|
+
end
|
259
|
+
|
242
260
|
##
|
243
261
|
# Call unifies the actual function paramaters against the formal function
|
244
262
|
# paramaters, if a function type signature already exists in the function
|
@@ -403,6 +421,15 @@ class TypeChecker < SexpProcessor
|
|
403
421
|
return t(:defined, thing, Type.bool)
|
404
422
|
end
|
405
423
|
|
424
|
+
def rewrite_defn(exp)
|
425
|
+
t, name, args, *body = exp
|
426
|
+
|
427
|
+
body = [s(:scope, s(:block, *body))] unless
|
428
|
+
body and body.first.first == :scope
|
429
|
+
|
430
|
+
s(t, name, args, *body)
|
431
|
+
end
|
432
|
+
|
406
433
|
##
|
407
434
|
# Defn adds the formal argument types to the local environment and attempts
|
408
435
|
# to unify itself against the function table. If no function exists in the
|
@@ -577,7 +604,7 @@ class TypeChecker < SexpProcessor
|
|
577
604
|
cond_exp.sexp_type.unify Type.bool
|
578
605
|
begin
|
579
606
|
then_exp.sexp_type.unify else_exp.sexp_type unless then_exp.nil? or else_exp.nil?
|
580
|
-
rescue TypeError
|
607
|
+
rescue TypeError
|
581
608
|
puts "Error unifying #{then_exp.inspect} with #{else_exp.inspect}"
|
582
609
|
raise
|
583
610
|
end
|
@@ -589,13 +616,33 @@ class TypeChecker < SexpProcessor
|
|
589
616
|
return t(:if, cond_exp, then_exp, else_exp, type)
|
590
617
|
end
|
591
618
|
|
619
|
+
def process_arglist_plain(exp)
|
620
|
+
vars = t(:args)
|
621
|
+
until exp.empty? do
|
622
|
+
var = exp.shift
|
623
|
+
case var
|
624
|
+
when Symbol then
|
625
|
+
vars << process(s(:lasgn, var))
|
626
|
+
when Sexp then
|
627
|
+
vars << process(var)
|
628
|
+
else
|
629
|
+
raise "Unknown arglist type: #{var.inspect}"
|
630
|
+
end
|
631
|
+
end
|
632
|
+
vars
|
633
|
+
end
|
634
|
+
|
592
635
|
##
|
593
636
|
# Iter unifies the dynamic variables against the call args (dynamic
|
594
637
|
# variables are used in the iter body) and returns a void-typed sexp.
|
595
638
|
|
596
639
|
def process_iter(exp)
|
597
640
|
call_exp = process exp.shift
|
598
|
-
|
641
|
+
|
642
|
+
dargs_exp = exp.shift
|
643
|
+
dargs_exp[0] = :arglist_plain
|
644
|
+
dargs_exp = process dargs_exp
|
645
|
+
|
599
646
|
body_exp = process exp.shift
|
600
647
|
|
601
648
|
lhs = call_exp[1] # FIX
|
@@ -604,7 +651,10 @@ class TypeChecker < SexpProcessor
|
|
604
651
|
return t(:iter, call_exp, dargs_exp, body_exp, call_exp.sexp_type)
|
605
652
|
else
|
606
653
|
Type.unknown_list.unify lhs.sexp_type # force a list type, lhs must be Enum
|
607
|
-
|
654
|
+
|
655
|
+
dargs_exp.sexp_body.each do |subexp|
|
656
|
+
Type.new(lhs.sexp_type.list_type).unify subexp.sexp_type
|
657
|
+
end
|
608
658
|
|
609
659
|
return t(:iter, call_exp, dargs_exp, body_exp, Type.void)
|
610
660
|
end
|
data/test/r2ctestcase.rb
CHANGED
@@ -388,7 +388,7 @@ class R2CTestCase < ParseTreeTestCase
|
|
388
388
|
:downto,
|
389
389
|
t(:arglist, t(:lit, 1, Type.long)),
|
390
390
|
Type.unknown),
|
391
|
-
t(:lasgn, :n, nil, Type.long),
|
391
|
+
t(:args, t(:lasgn, :n, nil, Type.long)),
|
392
392
|
t(:call, nil, :puts,
|
393
393
|
t(:arglist,
|
394
394
|
t(:call,
|
@@ -416,7 +416,7 @@ class R2CTestCase < ParseTreeTestCase
|
|
416
416
|
t(:lvar, :array, Type.long_list),
|
417
417
|
:each,
|
418
418
|
t(:arglist), Type.unknown),
|
419
|
-
t(:lasgn, :x, nil, Type.long),
|
419
|
+
t(:args, t(:lasgn, :x, nil, Type.long)),
|
420
420
|
t(:call, nil, :puts,
|
421
421
|
t(:arglist,
|
422
422
|
t(:call,
|
@@ -525,13 +525,13 @@ class R2CTestCase < ParseTreeTestCase
|
|
525
525
|
t(:lvar, :array1, Type.long_list),
|
526
526
|
:each,
|
527
527
|
t(:arglist), Type.unknown),
|
528
|
-
t(:lasgn, :x, nil, Type.long),
|
528
|
+
t(:args, t(:lasgn, :x, nil, Type.long)),
|
529
529
|
t(:iter,
|
530
530
|
t(:call,
|
531
531
|
t(:lvar, :array2, Type.long_list),
|
532
532
|
:each,
|
533
533
|
t(:arglist), Type.unknown),
|
534
|
-
t(:lasgn, :y, nil, Type.long),
|
534
|
+
t(:args, t(:lasgn, :y, nil, Type.long)),
|
535
535
|
t(:block,
|
536
536
|
t(:call, nil, :puts,
|
537
537
|
t(:arglist,
|
@@ -809,7 +809,7 @@ puts(to_s(arg3));
|
|
809
809
|
return \"foo\";
|
810
810
|
}")
|
811
811
|
|
812
|
-
add_tests("
|
812
|
+
add_tests("not__18",
|
813
813
|
"Rewriter" => :same,
|
814
814
|
"TypeChecker" => t(:not, t(:true, Type.bool), Type.bool),
|
815
815
|
"CRewriter" => :same,
|
@@ -890,6 +890,28 @@ return \"foo\";
|
|
890
890
|
"RubyToAnsiC" => "a = (void *) malloc(sizeof(void *) * 0)",
|
891
891
|
"RubyToRubyC" => "a = rb_ary_new2(0)")
|
892
892
|
|
893
|
+
add_tests("str_question_control__18",
|
894
|
+
"Rewriter" => :same,
|
895
|
+
"TypeChecker" => t(:lit, 129, Type.long),
|
896
|
+
"CRewriter" => :same,
|
897
|
+
"RubyToAnsiC" => "129",
|
898
|
+
"RubyToRubyC" => "LONG2NUM(129)")
|
899
|
+
|
900
|
+
add_tests("str_question_escape__18",
|
901
|
+
"Rewriter" => :same,
|
902
|
+
"TypeChecker" => t(:lit, 10, Type.long),
|
903
|
+
"CRewriter" => :same,
|
904
|
+
"RubyToAnsiC" => "10",
|
905
|
+
"RubyToRubyC" => "LONG2NUM(10)")
|
906
|
+
|
907
|
+
add_tests("str_question_literal__18",
|
908
|
+
"Rewriter" => :same,
|
909
|
+
"TypeChecker" => t(:lit, 97, Type.long),
|
910
|
+
"CRewriter" => :same,
|
911
|
+
"RubyToAnsiC" => "97",
|
912
|
+
"RubyToRubyC" => "LONG2NUM(97)")
|
913
|
+
|
914
|
+
i_suck_and_my_tests_are_order_dependent!
|
893
915
|
|
894
916
|
add_skipped_tests("alias",
|
895
917
|
"alias_ugh",
|
@@ -934,13 +956,14 @@ return \"foo\";
|
|
934
956
|
"call_arglist",
|
935
957
|
"call_arglist_hash",
|
936
958
|
"call_arglist_norm_hash",
|
937
|
-
"
|
938
|
-
"
|
959
|
+
"call_arglist_norm_hash_splat__18",
|
960
|
+
"call_arglist_space__18",
|
939
961
|
"call_command",
|
940
962
|
"call_expr",
|
941
963
|
"call_index",
|
942
964
|
"call_index_no_args",
|
943
965
|
"call_index_space",
|
966
|
+
"call_no_space_symbol",
|
944
967
|
"call_unary_neg",
|
945
968
|
"case",
|
946
969
|
"case_nested",
|
@@ -1024,9 +1047,10 @@ return \"foo\";
|
|
1024
1047
|
"fcall_arglist",
|
1025
1048
|
"fcall_arglist_hash",
|
1026
1049
|
"fcall_arglist_norm_hash",
|
1027
|
-
"
|
1050
|
+
"fcall_arglist_norm_hash_splat__18",
|
1028
1051
|
"fcall_block",
|
1029
1052
|
"fcall_index_space",
|
1053
|
+
"fcall_inside_parens",
|
1030
1054
|
"fcall_keyword",
|
1031
1055
|
"flip2",
|
1032
1056
|
"flip2_method",
|
@@ -1044,19 +1068,33 @@ return \"foo\";
|
|
1044
1068
|
"if_lasgn_short",
|
1045
1069
|
"if_nested",
|
1046
1070
|
"if_post",
|
1047
|
-
"
|
1071
|
+
"if_post_not__18",
|
1048
1072
|
"if_pre",
|
1049
|
-
"
|
1073
|
+
"if_pre_not__18",
|
1074
|
+
"iter_args_ivar__18",
|
1050
1075
|
"iter_call_arglist_space",
|
1051
1076
|
"iter_dasgn_curr_dasgn_madness",
|
1052
1077
|
"iter_loop_empty",
|
1053
1078
|
"iter_masgn_2",
|
1079
|
+
"iter_masgn_args_ivar__18",
|
1054
1080
|
"iter_masgn_args_splat",
|
1055
1081
|
"iter_masgn_args_splat_no_name",
|
1056
1082
|
"iter_masgn_splat",
|
1057
1083
|
"iter_masgn_splat_no_name",
|
1058
1084
|
"iter_shadowed_var",
|
1059
1085
|
"iter_upto",
|
1086
|
+
"lambda_args_anon_star",
|
1087
|
+
"lambda_args_anon_star_block",
|
1088
|
+
"lambda_args_block",
|
1089
|
+
"lambda_args_norm_anon_star",
|
1090
|
+
"lambda_args_norm_anon_star_block",
|
1091
|
+
"lambda_args_norm_block",
|
1092
|
+
"lambda_args_norm_comma",
|
1093
|
+
"lambda_args_norm_comma2",
|
1094
|
+
"lambda_args_norm_star",
|
1095
|
+
"lambda_args_norm_star_block",
|
1096
|
+
"lambda_args_star",
|
1097
|
+
"lambda_args_star_block",
|
1060
1098
|
"lvar_def_boundary",
|
1061
1099
|
"masgn",
|
1062
1100
|
"masgn_argscat",
|
@@ -1077,6 +1115,7 @@ return \"foo\";
|
|
1077
1115
|
"match2",
|
1078
1116
|
"match3",
|
1079
1117
|
"module",
|
1118
|
+
"module2",
|
1080
1119
|
"module_scoped",
|
1081
1120
|
"module_scoped3",
|
1082
1121
|
"next",
|
@@ -1156,6 +1195,8 @@ return \"foo\";
|
|
1156
1195
|
"super_block_splat",
|
1157
1196
|
"super_n",
|
1158
1197
|
"svalue",
|
1198
|
+
"ternary_nil_no_space",
|
1199
|
+
"ternary_symbol_no_spaces",
|
1159
1200
|
"to_ary",
|
1160
1201
|
"true",
|
1161
1202
|
"undef",
|
@@ -1167,24 +1208,24 @@ return \"foo\";
|
|
1167
1208
|
"undef_block_3_post",
|
1168
1209
|
"undef_block_wtf",
|
1169
1210
|
"unless_post",
|
1170
|
-
"
|
1211
|
+
"unless_post_not__18",
|
1171
1212
|
"unless_pre",
|
1172
|
-
"
|
1213
|
+
"unless_pre_not__18",
|
1173
1214
|
"until_post",
|
1174
|
-
"
|
1215
|
+
"until_post_not__18",
|
1175
1216
|
"until_pre",
|
1176
1217
|
"until_pre_mod",
|
1177
|
-
"
|
1178
|
-
"
|
1218
|
+
"until_pre_not__18",
|
1219
|
+
"until_pre_not_mod__18",
|
1179
1220
|
"valias",
|
1180
1221
|
"while_post",
|
1181
1222
|
"while_post2",
|
1182
|
-
"
|
1223
|
+
"while_post_not__18",
|
1183
1224
|
"while_pre",
|
1184
1225
|
"while_pre_mod",
|
1185
1226
|
"while_pre_nil",
|
1186
|
-
"
|
1187
|
-
"
|
1227
|
+
"while_pre_not__18",
|
1228
|
+
"while_pre_not_mod__18",
|
1188
1229
|
"xstr",
|
1189
1230
|
"yield_0",
|
1190
1231
|
"yield_1",
|
data/test/test_function_type.rb
CHANGED
@@ -116,6 +116,9 @@ class TestFunctionType < MiniTest::Unit::TestCase
|
|
116
116
|
|
117
117
|
fun9 = FunctionType.new(Type.long, [], Type.str)
|
118
118
|
funa = FunctionType.new(Type.str, [], Type.unknown)
|
119
|
+
|
120
|
+
fun9, funa = funa, fun9 # get rid of unused warnings but keep them rooted
|
121
|
+
|
119
122
|
assert_raises(TypeError) do
|
120
123
|
fun7.unify_components fun8
|
121
124
|
end
|
data/test/test_ruby_to_ansi_c.rb
CHANGED
data/test/test_type_checker.rb
CHANGED
@@ -215,8 +215,8 @@ class TestTypeChecker < R2CTestCase
|
|
215
215
|
end
|
216
216
|
|
217
217
|
def test_process_call_undefined
|
218
|
-
input = t(:call, nil, :name
|
219
|
-
output = t(:call, nil, :name,
|
218
|
+
input = t(:call, nil, :name)
|
219
|
+
output = t(:call, nil, :name, t(:arglist), Type.unknown)
|
220
220
|
|
221
221
|
assert_equal output, @type_checker.process(input)
|
222
222
|
# FIX returns unknown in s()
|
@@ -510,7 +510,7 @@ class TestTypeChecker < R2CTestCase
|
|
510
510
|
t(:lvar, :array),
|
511
511
|
:each,
|
512
512
|
nil),
|
513
|
-
t(:
|
513
|
+
t(:args, :x),
|
514
514
|
t(:call,
|
515
515
|
nil,
|
516
516
|
:puts,
|
@@ -523,9 +523,9 @@ class TestTypeChecker < R2CTestCase
|
|
523
523
|
t(:call,
|
524
524
|
t(:lvar, :array, var_type),
|
525
525
|
:each,
|
526
|
-
|
526
|
+
t(:arglist),
|
527
527
|
Type.unknown),
|
528
|
-
t(:
|
528
|
+
t(:args, t(:lasgn, :x, nil, Type.long)),
|
529
529
|
t(:call,
|
530
530
|
nil,
|
531
531
|
:puts,
|
@@ -533,7 +533,7 @@ class TestTypeChecker < R2CTestCase
|
|
533
533
|
t(:call,
|
534
534
|
t(:dvar, :x, Type.long),
|
535
535
|
:to_s,
|
536
|
-
|
536
|
+
t(:arglist),
|
537
537
|
Type.str)),
|
538
538
|
Type.void),
|
539
539
|
Type.void)
|
@@ -782,7 +782,7 @@ class TestTypeChecker < R2CTestCase
|
|
782
782
|
input = t(:while, t(:true), t(:call, t(:lit, 1), :to_s, nil), true)
|
783
783
|
expected = t(:while,
|
784
784
|
t(:true, Type.bool),
|
785
|
-
t(:call, t(:lit, 1, Type.long), :to_s,
|
785
|
+
t(:call, t(:lit, 1, Type.long), :to_s, t(:arglist),
|
786
786
|
Type.str), true)
|
787
787
|
|
788
788
|
assert_equal expected, @type_checker.process(input)
|
metadata
CHANGED
@@ -1,38 +1,105 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby2c
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 79
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
- 8
|
11
|
+
version: 1.0.0.8
|
5
12
|
platform: ruby
|
6
13
|
authors:
|
7
14
|
- Ryan Davis
|
8
15
|
- Eric Hodel
|
9
16
|
autorequire:
|
10
17
|
bindir: bin
|
11
|
-
cert_chain:
|
18
|
+
cert_chain:
|
19
|
+
- |
|
20
|
+
-----BEGIN CERTIFICATE-----
|
21
|
+
MIIDPjCCAiagAwIBAgIBADANBgkqhkiG9w0BAQUFADBFMRMwEQYDVQQDDApyeWFu
|
22
|
+
ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
|
23
|
+
GRYDY29tMB4XDTA5MDMwNjE4NTMxNVoXDTEwMDMwNjE4NTMxNVowRTETMBEGA1UE
|
24
|
+
AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
|
25
|
+
JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
|
26
|
+
b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
|
27
|
+
taCPaLmfYIaFcHHCSY4hYDJijRQkLxPeB3xbOfzfLoBDbjvx5JxgJxUjmGa7xhcT
|
28
|
+
oOvjtt5P8+GSK9zLzxQP0gVLS/D0FmoE44XuDr3iQkVS2ujU5zZL84mMNqNB1znh
|
29
|
+
GiadM9GHRaDiaxuX0cIUBj19T01mVE2iymf9I6bEsiayK/n6QujtyCbTWsAS9Rqt
|
30
|
+
qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
|
31
|
+
gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
|
32
|
+
HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBBQUAA4IB
|
33
|
+
AQAY59gYvDxqSqgC92nAP9P8dnGgfZgLxP237xS6XxFGJSghdz/nI6pusfCWKM8m
|
34
|
+
vzjjH2wUMSSf3tNudQ3rCGLf2epkcU13/rguI88wO6MrE0wi4ZqLQX+eZQFskJb/
|
35
|
+
w6x9W1ur8eR01s397LSMexySDBrJOh34cm2AlfKr/jokKCTwcM0OvVZnAutaovC0
|
36
|
+
l1SVZ0ecg88bsWHA0Yhh7NFxK1utWoIhtB6AFC/+trM0FQEB/jZkIS8SaNzn96Rl
|
37
|
+
n0sZEf77FLf5peR8TP/PtmIg7Cyqz23sLM4mCOoTGIy5OcZ8TdyiyINUHtb5ej/T
|
38
|
+
FBHgymkyj/AOSqKRIpXPhjC6
|
39
|
+
-----END CERTIFICATE-----
|
12
40
|
|
13
|
-
date:
|
14
|
-
default_executable:
|
41
|
+
date: 2012-11-10 00:00:00 Z
|
15
42
|
dependencies:
|
16
43
|
- !ruby/object:Gem::Dependency
|
17
44
|
name: ruby_parser
|
18
|
-
|
19
|
-
|
20
|
-
|
45
|
+
prerelease: false
|
46
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
21
48
|
requirements:
|
22
49
|
- - ~>
|
23
50
|
- !ruby/object:Gem::Version
|
51
|
+
hash: 3
|
52
|
+
segments:
|
53
|
+
- 2
|
54
|
+
- 0
|
24
55
|
version: "2.0"
|
25
|
-
|
56
|
+
type: :runtime
|
57
|
+
version_requirements: *id001
|
26
58
|
- !ruby/object:Gem::Dependency
|
27
|
-
name:
|
59
|
+
name: minitest
|
60
|
+
prerelease: false
|
61
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ~>
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
hash: 31
|
67
|
+
segments:
|
68
|
+
- 4
|
69
|
+
- 2
|
70
|
+
version: "4.2"
|
28
71
|
type: :development
|
29
|
-
|
30
|
-
|
72
|
+
version_requirements: *id002
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: rdoc
|
75
|
+
prerelease: false
|
76
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
31
78
|
requirements:
|
32
|
-
- -
|
79
|
+
- - ~>
|
33
80
|
- !ruby/object:Gem::Version
|
34
|
-
|
35
|
-
|
81
|
+
hash: 19
|
82
|
+
segments:
|
83
|
+
- 3
|
84
|
+
- 10
|
85
|
+
version: "3.10"
|
86
|
+
type: :development
|
87
|
+
version_requirements: *id003
|
88
|
+
- !ruby/object:Gem::Dependency
|
89
|
+
name: hoe
|
90
|
+
prerelease: false
|
91
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
hash: 3
|
97
|
+
segments:
|
98
|
+
- 3
|
99
|
+
- 2
|
100
|
+
version: "3.2"
|
101
|
+
type: :development
|
102
|
+
version_requirements: *id004
|
36
103
|
description: |-
|
37
104
|
ruby_to_c translates a static ruby subset to C. Hopefully it works.
|
38
105
|
|
@@ -48,10 +115,6 @@ description: |-
|
|
48
115
|
* TypeChecker - type inferencer for the above sexps.
|
49
116
|
* RubyToRubyC - converts a ruby (subset) sexp to ruby interals C.
|
50
117
|
* RubyToAnsiC - converts a ruby (subset) sexp to ANSI C.
|
51
|
-
|
52
|
-
and the following tools:
|
53
|
-
|
54
|
-
* translate.rb - Translates a given file to C.
|
55
118
|
email:
|
56
119
|
- ryand-ruby@zenspider.com
|
57
120
|
- drbrain@segment7.net
|
@@ -99,8 +162,8 @@ files:
|
|
99
162
|
- test/test_type.rb
|
100
163
|
- test/test_type_checker.rb
|
101
164
|
- test/test_typed_sexp.rb
|
102
|
-
|
103
|
-
homepage:
|
165
|
+
- .gemtest
|
166
|
+
homepage: https://github.com/seattlerb/ruby_to_c
|
104
167
|
licenses: []
|
105
168
|
|
106
169
|
post_install_message:
|
@@ -110,21 +173,27 @@ rdoc_options:
|
|
110
173
|
require_paths:
|
111
174
|
- lib
|
112
175
|
required_ruby_version: !ruby/object:Gem::Requirement
|
176
|
+
none: false
|
113
177
|
requirements:
|
114
178
|
- - ">="
|
115
179
|
- !ruby/object:Gem::Version
|
180
|
+
hash: 3
|
181
|
+
segments:
|
182
|
+
- 0
|
116
183
|
version: "0"
|
117
|
-
version:
|
118
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
119
186
|
requirements:
|
120
187
|
- - ">="
|
121
188
|
- !ruby/object:Gem::Version
|
189
|
+
hash: 3
|
190
|
+
segments:
|
191
|
+
- 0
|
122
192
|
version: "0"
|
123
|
-
version:
|
124
193
|
requirements: []
|
125
194
|
|
126
195
|
rubyforge_project: ruby2c
|
127
|
-
rubygems_version: 1.
|
196
|
+
rubygems_version: 1.8.24
|
128
197
|
signing_key:
|
129
198
|
specification_version: 3
|
130
199
|
summary: ruby_to_c translates a static ruby subset to C
|
metadata.gz.sig
ADDED
Binary file
|