fastruby 0.0.19 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +8 -0
- data/{README → README.rdoc} +6 -1
- data/Rakefile +7 -7
- data/benchmarks/benchmark.rb~ +14 -2
- data/ext/fastruby_base/fastruby_base.inl +8 -4
- data/lib/fastruby/builder/inference_updater.rb +76 -0
- data/lib/fastruby/builder/inference_updater.rb~ +76 -0
- data/lib/fastruby/builder/inferencer.rb +38 -0
- data/lib/fastruby/{inliner → builder}/inliner.rb +16 -27
- data/lib/fastruby/builder/inliner.rb~ +60 -0
- data/lib/fastruby/builder/locals_inference.rb +53 -0
- data/lib/fastruby/builder/lvar_type.rb +43 -0
- data/lib/fastruby/builder/lvar_type.rb~ +44 -0
- data/lib/fastruby/builder/pipeline.rb +43 -0
- data/lib/fastruby/builder/pipeline.rb~ +43 -0
- data/lib/fastruby/{reductor → builder}/reductor.rb +6 -3
- data/lib/fastruby/builder/reductor.rb~ +42 -0
- data/lib/fastruby/builder.rb +73 -25
- data/lib/fastruby/builder.rb~ +311 -0
- data/lib/fastruby/corelib/fixnum.rb +75 -0
- data/lib/fastruby/corelib/fixnum.rb~ +146 -0
- data/lib/fastruby/corelib/integer.rb +96 -0
- data/lib/fastruby/corelib/integer.rb~ +96 -0
- data/lib/fastruby/corelib.rb +23 -0
- data/lib/fastruby/corelib.rb~ +23 -0
- data/lib/fastruby/getlocals.rb +3 -1
- data/lib/fastruby/logging.rb +2 -2
- data/lib/fastruby/modules/inferencer/infer.rb +31 -0
- data/lib/fastruby/modules/inferencer/literal.rb +42 -0
- data/lib/fastruby/modules/inliner/call.rb +327 -0
- data/lib/fastruby/{inliner/modules/call.rb → modules/inliner/call.rb~} +14 -24
- data/lib/fastruby/modules/inliner/defn.rb +41 -0
- data/lib/fastruby/modules/inliner/defn.rb~ +29 -0
- data/lib/fastruby/modules/inliner/recursive.rb +40 -0
- data/lib/fastruby/{inliner/modules/recursive.rb → modules/inliner/recursive.rb~} +1 -1
- data/lib/fastruby/modules/lvar_type/call.rb +36 -0
- data/lib/fastruby/modules/lvar_type/call.rb~ +36 -0
- data/lib/fastruby/modules/lvar_type/defn.rb +42 -0
- data/lib/fastruby/modules/lvar_type/defn.rb~ +42 -0
- data/lib/fastruby/modules/lvar_type/lasgn.rb +41 -0
- data/lib/fastruby/modules/lvar_type/lasgn.rb~ +42 -0
- data/lib/fastruby/modules/lvar_type/recursive.rb +33 -0
- data/lib/fastruby/modules/lvar_type/recursive.rb~ +33 -0
- data/lib/fastruby/{reductor/modules → modules/reductor}/case.rb +0 -0
- data/lib/fastruby/modules/reductor/fastruby_flag.rb +33 -0
- data/lib/fastruby/{reductor/modules → modules/reductor}/for.rb +0 -0
- data/lib/fastruby/{reductor/modules → modules/reductor}/nontree.rb +0 -0
- data/lib/fastruby/modules/reductor/nontree.rb~ +32 -0
- data/lib/fastruby/{reductor/modules → modules/reductor}/recursive.rb +1 -1
- data/lib/fastruby/modules/reductor/recursive.rb~ +31 -0
- data/lib/fastruby/{translator/modules → modules/translator}/block.rb +0 -0
- data/lib/fastruby/modules/translator/call.rb +344 -0
- data/lib/fastruby/{translator/modules/call.rb → modules/translator/call.rb~} +24 -3
- data/lib/fastruby/{translator/modules → modules/translator}/defn.rb +10 -9
- data/lib/fastruby/modules/translator/defn.rb~ +267 -0
- data/lib/fastruby/{translator/modules → modules/translator}/directive.rb +3 -1
- data/lib/fastruby/modules/translator/directive.rb~ +44 -0
- data/lib/fastruby/{translator/modules → modules/translator}/exceptions.rb +3 -1
- data/lib/fastruby/modules/translator/exceptions.rb~ +120 -0
- data/lib/fastruby/{translator/modules → modules/translator}/flow.rb +0 -0
- data/lib/fastruby/modules/translator/iter.rb +745 -0
- data/lib/fastruby/{translator/modules/iter.rb → modules/translator/iter.rb~} +103 -48
- data/lib/fastruby/modules/translator/literal.rb +150 -0
- data/lib/fastruby/{translator/modules/literal.rb → modules/translator/literal.rb~} +3 -3
- data/lib/fastruby/{translator/modules → modules/translator}/logical.rb +0 -0
- data/lib/fastruby/{translator/modules → modules/translator}/method_group.rb +0 -0
- data/lib/fastruby/{translator/modules → modules/translator}/nonlocal.rb +18 -6
- data/lib/fastruby/modules/translator/nonlocal.rb~ +298 -0
- data/lib/fastruby/modules/translator/static.rb +290 -0
- data/lib/fastruby/{translator/modules/static.rb → modules/translator/static.rb~} +66 -17
- data/lib/fastruby/modules/translator/variable.rb +280 -0
- data/lib/fastruby/{translator/modules/variable.rb → modules/translator/variable.rb~} +14 -44
- data/lib/fastruby/modules.rb +30 -0
- data/lib/fastruby/object.rb +42 -6
- data/lib/fastruby/object.rb~ +159 -0
- data/lib/fastruby/set_tree.rb +7 -11
- data/lib/fastruby/set_tree.rb~ +71 -0
- data/lib/fastruby/sexp_extension.rb +29 -7
- data/lib/fastruby/sexp_extension.rb~ +262 -0
- data/lib/fastruby/translator/scope_mode_helper.rb~ +138 -0
- data/lib/fastruby/translator/translator.rb +87 -92
- data/lib/fastruby/translator/translator.rb~ +1600 -0
- data/lib/fastruby/translator/translator_modules.rb +3 -1
- data/lib/fastruby/translator/translator_modules.rb~ +53 -0
- data/lib/fastruby.rb +3 -1
- data/lib/fastruby.rb~ +3 -1
- data/lib/fastruby_only/base.rb +1 -0
- data/spec/corelib/numeric/fixnum_spec.rb +110 -0
- data/spec/corelib/numeric/fixnum_spec.rb~ +104 -0
- data/spec/corelib/numeric/integer_spec.rb +173 -0
- data/spec/corelib/numeric/integer_spec.rb~ +173 -0
- data/spec/fastruby_only/base_spec.rb +74 -0
- data/spec/graph/base_spec.rb +2 -1
- data/spec/graph/base_spec.rb~ +35 -0
- data/spec/graph/path_spec.rb +2 -2
- data/spec/graph/path_spec.rb~ +48 -0
- data/spec/graph/vertex_spec.rb +2 -1
- data/spec/graph/vertex_spec.rb~ +58 -0
- data/spec/reductor/base_spec.rb +1 -1
- data/spec/ruby/block/lambda_spec.rb~ +163 -0
- data/spec/ruby/block/proc_as_block_spec.rb~ +69 -1
- data/spec/ruby/block_spec.rb~ +2 -494
- data/spec/ruby/call/base_call_spec.rb +1 -1
- data/spec/ruby/call/base_call_spec.rb~ +2 -60
- data/spec/ruby/defn/replacement_spec.rb +26 -14
- data/spec/ruby/defn/replacement_spec.rb~ +13 -3
- data/spec/ruby/exception/internal_ex_spec.rb~ +86 -0
- data/spec/ruby/integrity_spec.rb~ +35 -1
- data/spec/ruby/variable_spec.rb~ +31 -0
- data/spec/scope_mode/flow_spec.rb +1 -1
- data/spec/scope_mode/flow_spec.rb~ +109 -0
- data/spec/sugar/base_spec.rb +29 -0
- data/spec/sugar/base_spec.rb~ +16 -0
- metadata +100 -43
- data/spec/fastruby/inliner/modules/call_spec.rb +0 -0
- data/spec/fastruby/translator/modules/nonlocal_spec.rb +0 -0
- data/spec/fastruby/translator/translator_spec.rb +0 -0
- data/spec/ruby/block/arguments_spec.rb~ +0 -214
- data/spec/ruby/block/break_spec.rb~ +0 -236
- data/spec/ruby/block/next_spec.rb~ +0 -85
- data/spec/ruby/block/retry_spec.rb~ +0 -43
@@ -71,8 +71,7 @@ module FastRuby
|
|
71
71
|
|
72
72
|
str_lvar_initialization = "#{@frame_struct} *pframe;
|
73
73
|
#{@locals_struct} *plocals;
|
74
|
-
|
75
|
-
plocals = (void*)pframe->plocals;
|
74
|
+
|
76
75
|
"
|
77
76
|
|
78
77
|
str_arg_initialization = ""
|
@@ -150,8 +149,11 @@ module FastRuby
|
|
150
149
|
static VALUE #{name}(VALUE param) {
|
151
150
|
// call to #{call_tree[2]}
|
152
151
|
VALUE last_expression = Qnil;
|
152
|
+
VALUE* args_array = (VALUE*)param;
|
153
153
|
|
154
154
|
#{str_lvar_initialization}
|
155
|
+
pframe = (void*)args_array[0];
|
156
|
+
plocals = (void*)pframe->plocals;
|
155
157
|
#{str_evaluate_args};
|
156
158
|
|
157
159
|
VALUE ret = rb_funcall(#{str_recv}, #{intern_num call_tree[2]}, #{call_args_tree.size-1} #{strargs});
|
@@ -193,40 +195,16 @@ module FastRuby
|
|
193
195
|
static VALUE #{name}(VALUE param) {
|
194
196
|
// call to #{call_tree[2]}
|
195
197
|
|
198
|
+
VALUE* args_array = (VALUE*)param;
|
199
|
+
int argc = args_array[1];
|
200
|
+
VALUE* argv = args_array[2];
|
201
|
+
|
196
202
|
VALUE last_expression = Qnil;
|
197
203
|
#{str_lvar_initialization}
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
if (TYPE(array) != T_ARRAY) {
|
204
|
-
array = rb_ary_new4(1,&array);
|
205
|
-
}
|
206
|
-
|
207
|
-
int argc = #{call_args_tree.size-2};
|
208
|
-
VALUE argv[#{call_args_tree.size} + _RARRAY_LEN(array)];
|
209
|
-
|
210
|
-
VALUE aux_ = Qnil;;
|
211
|
-
#{
|
212
|
-
i = -1
|
213
|
-
call_args_tree[1..-2].map {|arg|
|
214
|
-
i = i + 1
|
215
|
-
"
|
216
|
-
#{to_c arg, "aux_"};
|
217
|
-
argv[#{i}] = aux_;
|
218
|
-
"
|
219
|
-
}.join(";\n")
|
220
|
-
};
|
221
|
-
|
222
|
-
int array_len = _RARRAY_LEN(array);
|
223
|
-
|
224
|
-
int i;
|
225
|
-
for (i=0; i<array_len;i++) {
|
226
|
-
argv[argc] = rb_ary_entry(array,i);
|
227
|
-
argc++;
|
228
|
-
}
|
229
|
-
|
204
|
+
|
205
|
+
pframe = (void*)args_array[0];
|
206
|
+
plocals = (void*)pframe->plocals;
|
207
|
+
|
230
208
|
return rb_funcall2(#{str_recv}, #{intern_num call_tree[2]}, argc, argv);
|
231
209
|
}
|
232
210
|
"
|
@@ -235,15 +213,10 @@ module FastRuby
|
|
235
213
|
str_evaluate_args = "
|
236
214
|
#{
|
237
215
|
(0..call_args_tree.size-2).map{|i|
|
238
|
-
"VALUE arg#{i} =
|
239
|
-
}.join("\n")
|
240
|
-
}
|
241
|
-
|
242
|
-
#{
|
243
|
-
(0..call_args_tree.size-2).map{|i|
|
244
|
-
to_c(call_args_tree[i+1], "arg#{i}")+";"
|
216
|
+
"VALUE arg#{i} = args_array[#{i+1}];"
|
245
217
|
}.join("\n")
|
246
218
|
}
|
219
|
+
|
247
220
|
"
|
248
221
|
end
|
249
222
|
end
|
@@ -313,7 +286,17 @@ if call_type == :lambda
|
|
313
286
|
|
314
287
|
} else if (aux == FASTRUBY_TAG_BREAK) {
|
315
288
|
last_expression = frame.return_value;
|
316
|
-
|
289
|
+
typeof(pframe) target_frame_ = (void*)plocals->call_frame;
|
290
|
+
|
291
|
+
if (target_frame_ == 0) {
|
292
|
+
goto fastruby_local_next;
|
293
|
+
} else {
|
294
|
+
if (target_frame_->targetted == 1) {
|
295
|
+
goto fastruby_local_next;
|
296
|
+
} else {
|
297
|
+
#{_raise("rb_eLocalJumpError","illegal break")};
|
298
|
+
}
|
299
|
+
}
|
317
300
|
"
|
318
301
|
end
|
319
302
|
}
|
@@ -586,12 +569,73 @@ fastruby_local_next:
|
|
586
569
|
}
|
587
570
|
|
588
571
|
|
572
|
+
#{if call_args_tree.size > 1 and call_args_tree.last[0] == :splat
|
573
|
+
"
|
574
|
+
VALUE args_array[3];
|
575
|
+
VALUE array = Qnil;
|
576
|
+
|
577
|
+
#{to_c call_args_tree.last[1], "array"};
|
578
|
+
|
579
|
+
if (TYPE(array) != T_ARRAY) {
|
580
|
+
array = rb_ary_new4(1,&array);
|
581
|
+
}
|
582
|
+
|
583
|
+
int argc = #{call_args_tree.size-2};
|
584
|
+
VALUE argv[#{call_args_tree.size} + _RARRAY_LEN(array)];
|
585
|
+
|
586
|
+
VALUE aux_ = Qnil;;
|
587
|
+
#{
|
588
|
+
i = -1
|
589
|
+
call_args_tree[1..-2].map {|arg|
|
590
|
+
i = i + 1
|
591
|
+
"
|
592
|
+
#{to_c arg, "aux_"};
|
593
|
+
argv[#{i}] = aux_;
|
594
|
+
"
|
595
|
+
}.join(";\n")
|
596
|
+
};
|
597
|
+
|
598
|
+
int array_len = _RARRAY_LEN(array);
|
599
|
+
|
600
|
+
int i;
|
601
|
+
for (i=0; i<array_len;i++) {
|
602
|
+
argv[argc] = rb_ary_entry(array,i);
|
603
|
+
argc++;
|
604
|
+
}
|
605
|
+
|
606
|
+
args_array[0] = (VALUE)pframe;
|
607
|
+
args_array[1] = (VALUE)argc;
|
608
|
+
args_array[2] = (VALUE)argv;
|
609
|
+
|
589
610
|
last_expression = rb_iterate(
|
590
611
|
caller_func,
|
591
|
-
(VALUE)
|
612
|
+
(VALUE)args_array,
|
592
613
|
block_func,
|
593
614
|
(VALUE)plocals);
|
594
615
|
|
616
|
+
"
|
617
|
+
else
|
618
|
+
"
|
619
|
+
|
620
|
+
VALUE args_array[#{call_args_tree.size+2}];
|
621
|
+
VALUE aux___ = Qnil;
|
622
|
+
args_array[0] = (VALUE)pframe;
|
623
|
+
|
624
|
+
#{
|
625
|
+
(0..call_args_tree.size-2).map{|i|
|
626
|
+
to_c(call_args_tree[i+1], "aux___")+";"+
|
627
|
+
"args_array[#{i+1}] = aux___;"
|
628
|
+
}.join("\n")
|
629
|
+
}
|
630
|
+
|
631
|
+
last_expression = rb_iterate(
|
632
|
+
caller_func,
|
633
|
+
(VALUE)args_array,
|
634
|
+
block_func,
|
635
|
+
(VALUE)plocals);
|
636
|
+
"
|
637
|
+
end
|
638
|
+
}
|
595
639
|
if (node == #{@callcc_node_gvar}) {
|
596
640
|
|
597
641
|
// remove active flags of abandoned stack
|
@@ -625,7 +669,7 @@ fastruby_local_next:
|
|
625
669
|
funcall_call_code
|
626
670
|
end
|
627
671
|
else
|
628
|
-
encoded_address = encode_address(recvtype,signature,mname,call_tree,inference_complete,convention_global_name)
|
672
|
+
encoded_address = encode_address(recvtype,signature,mname,call_tree,inference_complete,convention_global_name, true)
|
629
673
|
|
630
674
|
if call_args_tree.size > 1
|
631
675
|
strargs = (0..call_args_tree.size-2).map{|i| "arg#{i}"}.join(",")
|
@@ -635,10 +679,21 @@ fastruby_local_next:
|
|
635
679
|
|
636
680
|
fastruby_call_code = "
|
637
681
|
// call to #{call_tree[2]}
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
682
|
+
#{
|
683
|
+
if call_args_tree.size > 1
|
684
|
+
" #{
|
685
|
+
(0..call_args_tree.size-2).map{|i|
|
686
|
+
"VALUE arg#{i} = Qnil;"
|
687
|
+
}.join("\n")
|
688
|
+
}
|
689
|
+
|
690
|
+
#{
|
691
|
+
(0..call_args_tree.size-2).map{|i|
|
692
|
+
to_c(call_args_tree[i+1], "arg#{i}")+";"
|
693
|
+
}.join("\n")
|
694
|
+
}
|
695
|
+
"
|
696
|
+
end
|
642
697
|
};
|
643
698
|
|
644
699
|
VALUE recv = plocals->self;
|
@@ -0,0 +1,150 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
This file is part of the fastruby project, http://github.com/tario/fastruby
|
4
|
+
|
5
|
+
Copyright (c) 2011 Roberto Dario Seminara <robertodarioseminara@gmail.com>
|
6
|
+
|
7
|
+
fastruby is free software: you can redistribute it and/or modify
|
8
|
+
it under the terms of the gnu general public license as published by
|
9
|
+
the free software foundation, either version 3 of the license, or
|
10
|
+
(at your option) any later version.
|
11
|
+
|
12
|
+
fastruby is distributed in the hope that it will be useful,
|
13
|
+
but without any warranty; without even the implied warranty of
|
14
|
+
merchantability or fitness for a particular purpose. see the
|
15
|
+
gnu general public license for more details.
|
16
|
+
|
17
|
+
you should have received a copy of the gnu general public license
|
18
|
+
along with fastruby. if not, see <http://www.gnu.org/licenses/>.
|
19
|
+
|
20
|
+
=end
|
21
|
+
module FastRuby
|
22
|
+
class Context
|
23
|
+
|
24
|
+
define_translator_for(:lit, :arity => 1){|*x| tree = x.first; literal_value tree[1]}
|
25
|
+
define_translator_for(:nil, :arity => 1){|*x| tree = x.first; "Qnil"}
|
26
|
+
define_translator_for(:str, :arity => 1){|*x| tree = x.first; literal_value tree[1]}
|
27
|
+
|
28
|
+
define_translator_for(:hash, :method => :to_c_hash)
|
29
|
+
def to_c_hash(tree, result_var = nil)
|
30
|
+
|
31
|
+
hash_tmp_var = "_hash_"+rand(1000000).to_s
|
32
|
+
key_tmp_var = "_key_"+rand(1000000).to_s
|
33
|
+
value_tmp_var = "_value_"+rand(1000000).to_s
|
34
|
+
|
35
|
+
code = proc{
|
36
|
+
hash_aset_code = ""
|
37
|
+
(0..(tree.size-3)/2).each do |i|
|
38
|
+
strkey = to_c tree[1 + i * 2]
|
39
|
+
strvalue = to_c tree[2 + i * 2]
|
40
|
+
hash_aset_code << "
|
41
|
+
{
|
42
|
+
VALUE #{key_tmp_var} = Qnil;
|
43
|
+
VALUE #{value_tmp_var} = Qnil;
|
44
|
+
|
45
|
+
#{to_c tree[1 + i * 2], key_tmp_var};
|
46
|
+
#{to_c tree[2 + i * 2], value_tmp_var};
|
47
|
+
|
48
|
+
rb_hash_aset(#{hash_tmp_var}, #{key_tmp_var}, #{value_tmp_var});
|
49
|
+
}
|
50
|
+
"
|
51
|
+
end
|
52
|
+
|
53
|
+
"
|
54
|
+
{
|
55
|
+
VALUE #{hash_tmp_var} = rb_hash_new();
|
56
|
+
#{hash_aset_code};
|
57
|
+
#{
|
58
|
+
if result_var
|
59
|
+
"#{result_var} = #{hash_tmp_var}"
|
60
|
+
else
|
61
|
+
"return #{hash_tmp_var}"
|
62
|
+
end
|
63
|
+
};
|
64
|
+
}
|
65
|
+
"}
|
66
|
+
|
67
|
+
if result_var
|
68
|
+
code.call
|
69
|
+
else
|
70
|
+
inline_block &code
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
define_translator_for(:array, :method => :to_c_array)
|
75
|
+
def to_c_array(tree, result_var = nil)
|
76
|
+
if tree.size > 1
|
77
|
+
if result_var
|
78
|
+
prefix = "_array_element_" + rand(10000000).to_s + "_"
|
79
|
+
"
|
80
|
+
{
|
81
|
+
#{
|
82
|
+
(0..tree.size-2).map{|x|
|
83
|
+
"VALUE #{prefix}#{x};"
|
84
|
+
}.join("\n");
|
85
|
+
}
|
86
|
+
|
87
|
+
#{
|
88
|
+
(0..tree.size-2).map{|x|
|
89
|
+
to_c(tree[x+1], prefix+x.to_s)
|
90
|
+
}.join("\n");
|
91
|
+
}
|
92
|
+
|
93
|
+
#{result_var} = rb_ary_new3(#{tree.size-1}, #{(0..tree.size-2).map{|x| prefix+x.to_s}.join(",")} );
|
94
|
+
}
|
95
|
+
"
|
96
|
+
else
|
97
|
+
strargs = tree[1..-1].map{|subtree| to_c subtree}.join(",")
|
98
|
+
"rb_ary_new3(#{tree.size-1}, #{strargs})"
|
99
|
+
end
|
100
|
+
else
|
101
|
+
if result_var
|
102
|
+
"#{result_var} = rb_ary_new3(0);"
|
103
|
+
else
|
104
|
+
"rb_ary_new3(0)"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
define_translator_for(:self, :arity => 1){|*x| tree = x.first; locals_accessor + "self"}
|
110
|
+
define_translator_for(:false, :arity => 1){|*x| "Qfalse"}
|
111
|
+
define_translator_for(:true, :arity => 1){|*x| "Qtrue"}
|
112
|
+
|
113
|
+
define_translator_for(:dot2, :method => :to_c_dot2)
|
114
|
+
def to_c_dot2(tree, result_var = nil)
|
115
|
+
|
116
|
+
begin_var = "_begin"+rand(10000000).to_s
|
117
|
+
end_var = "_end"+rand(10000000).to_s
|
118
|
+
|
119
|
+
if result_var
|
120
|
+
"
|
121
|
+
{
|
122
|
+
VALUE #{begin_var} = Qnil;
|
123
|
+
VALUE #{end_var} = Qnil;
|
124
|
+
|
125
|
+
#{to_c tree[1], begin_var};
|
126
|
+
#{to_c tree[2], end_var};
|
127
|
+
|
128
|
+
#{result_var} = rb_range_new(#{begin_var}, #{end_var},0);
|
129
|
+
}
|
130
|
+
"
|
131
|
+
else
|
132
|
+
if result_var
|
133
|
+
"
|
134
|
+
{
|
135
|
+
VALUE #{begin_var} = Qnil;
|
136
|
+
VALUE #{end_var} = Qnil;
|
137
|
+
#{to_c tree[1], begin_var};
|
138
|
+
#{to_c tree[2], end_var};
|
139
|
+
|
140
|
+
#{result_var} = rb_range_new(#{begin_var}, #{end_var},0)
|
141
|
+
}
|
142
|
+
"
|
143
|
+
else
|
144
|
+
"rb_range_new(#{to_c tree[1]}, #{to_c tree[2]},0)"
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
end
|
@@ -21,9 +21,9 @@ along with fastruby. if not, see <http://www.gnu.org/licenses/>.
|
|
21
21
|
module FastRuby
|
22
22
|
class Context
|
23
23
|
|
24
|
-
define_translator_for(:lit, :arity => 1){|tree
|
25
|
-
define_translator_for(:nil, :arity => 1){|tree
|
26
|
-
define_translator_for(:str, :arity => 1){|tree
|
24
|
+
define_translator_for(:lit, :arity => 1){|*x| tree = x.first; literal_value tree[1]}
|
25
|
+
define_translator_for(:nil, :arity => 1){|*x| tree = x.first; "Qnil"}
|
26
|
+
define_translator_for(:str, :arity => 1){|*x| tree = x.first; literal_value tree[1]}
|
27
27
|
|
28
28
|
define_translator_for(:hash, :method => :to_c_hash)
|
29
29
|
def to_c_hash(tree, result_var = nil)
|
File without changes
|
File without changes
|
@@ -142,7 +142,9 @@ module FastRuby
|
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
145
|
-
define_method_handler(:to_c, :priority => 100) { |
|
145
|
+
define_method_handler(:to_c, :priority => 100) { |*x|
|
146
|
+
tree, result_var = x
|
147
|
+
|
146
148
|
|
147
149
|
call_tree = tree[1]
|
148
150
|
catch_tag_id = call_tree[3][1][1]
|
@@ -240,11 +242,15 @@ module FastRuby
|
|
240
242
|
"
|
241
243
|
end
|
242
244
|
|
243
|
-
}.condition{|
|
245
|
+
}.condition{|*x|
|
246
|
+
tree, result_var = x
|
247
|
+
|
244
248
|
tree.node_type == :iter && tree[1][2] == :_catch
|
245
249
|
}
|
246
250
|
|
247
|
-
define_method_handler(:to_c, :priority => 100) { |
|
251
|
+
define_method_handler(:to_c, :priority => 100) { |*x|
|
252
|
+
tree, result_var = x
|
253
|
+
|
248
254
|
code = ""
|
249
255
|
|
250
256
|
catch_tag_id = tree[3][1][1]
|
@@ -262,11 +268,15 @@ module FastRuby
|
|
262
268
|
else
|
263
269
|
inline_block code
|
264
270
|
end
|
265
|
-
}.condition{|
|
271
|
+
}.condition{|*x|
|
272
|
+
tree, result_var = x
|
273
|
+
|
266
274
|
tree.node_type == :call && tree[2] == :_throw
|
267
275
|
}
|
268
276
|
|
269
|
-
define_method_handler(:to_c, :priority => 100) { |
|
277
|
+
define_method_handler(:to_c, :priority => 100) { |*x|
|
278
|
+
tree, result_var = x
|
279
|
+
|
270
280
|
code = ""
|
271
281
|
|
272
282
|
catch_tag_id = tree[3][1][1]
|
@@ -277,7 +287,9 @@ module FastRuby
|
|
277
287
|
else
|
278
288
|
inline_block code
|
279
289
|
end
|
280
|
-
}.condition{|
|
290
|
+
}.condition{|*x|
|
291
|
+
tree, result_var = x
|
292
|
+
|
281
293
|
tree.node_type == :call && tree[2] == :_loop
|
282
294
|
}
|
283
295
|
|