fastruby 0.0.17 → 0.0.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. data/CHANGELOG +10 -0
  2. data/Rakefile +4 -2
  3. data/benchmarks/benchmark.rb +20 -44
  4. data/benchmarks/benchmark.rb~ +47 -0
  5. data/benchmarks/benchmark2.rb +19 -45
  6. data/benchmarks/benchmark2.rb~ +46 -0
  7. data/benchmarks/benchmark3.rb +19 -45
  8. data/benchmarks/benchmark3.rb~ +46 -0
  9. data/benchmarks/benchmark4.rb +30 -65
  10. data/benchmarks/benchmark4.rb~ +61 -0
  11. data/benchmarks/benchmark5.rb +25 -55
  12. data/benchmarks/benchmark5.rb~ +54 -0
  13. data/benchmarks/benchmark6.rb +19 -40
  14. data/benchmarks/benchmark6.rb~ +41 -0
  15. data/benchmarks/benchmark7.rb +23 -52
  16. data/benchmarks/benchmark7.rb~ +48 -0
  17. data/ext/fastruby_base/fastruby_base.inl +1 -0
  18. data/lib/fastruby/builder.rb +128 -76
  19. data/lib/fastruby/cache/cache.rb +9 -5
  20. data/lib/fastruby/fastruby_sexp.rb +18 -0
  21. data/lib/fastruby/inliner/inliner.rb +68 -0
  22. data/lib/fastruby/inliner/modules/call.rb +150 -0
  23. data/lib/fastruby/inliner/modules/recursive.rb +35 -0
  24. data/lib/fastruby/object.rb +17 -32
  25. data/lib/fastruby/reductor/modules/case.rb +49 -0
  26. data/lib/{fastruby.rb~ → fastruby/reductor/modules/for.rb} +11 -13
  27. data/lib/fastruby/reductor/modules/nontree.rb +31 -0
  28. data/lib/fastruby/reductor/modules/recursive.rb +31 -0
  29. data/lib/fastruby/reductor/reductor.rb +39 -0
  30. data/lib/fastruby/set_tree.rb +7 -1
  31. data/lib/fastruby/sexp_extension.rb +6 -0
  32. data/lib/fastruby/translator/modules/block.rb +4 -4
  33. data/lib/fastruby/translator/modules/call.rb +9 -26
  34. data/lib/fastruby/translator/modules/defn.rb +5 -3
  35. data/lib/fastruby/translator/modules/directive.rb +42 -0
  36. data/lib/fastruby/translator/modules/exceptions.rb +12 -30
  37. data/lib/fastruby/translator/modules/flow.rb +33 -83
  38. data/lib/fastruby/translator/modules/iter.rb +4 -7
  39. data/lib/fastruby/translator/modules/literal.rb +11 -25
  40. data/lib/fastruby/translator/modules/logical.rb +5 -3
  41. data/lib/fastruby/translator/modules/method_group.rb +4 -3
  42. data/lib/fastruby/translator/modules/nonlocal.rb +7 -5
  43. data/lib/fastruby/translator/modules/static.rb +242 -0
  44. data/lib/fastruby/translator/modules/variable.rb +16 -9
  45. data/lib/fastruby/translator/scope_mode_helper.rb +2 -27
  46. data/lib/fastruby/translator/translator.rb +131 -60
  47. data/lib/fastruby/translator/translator_modules.rb +6 -2
  48. data/lib/fastruby.rb +1 -1
  49. data/spec/reductor/base_spec.rb +46 -0
  50. data/spec/ruby/base_spec.rb~ +394 -0
  51. data/spec/ruby/block/arguments_spec.rb~ +214 -0
  52. data/spec/ruby/block/proc_as_block_spec.rb~ +23 -0
  53. data/spec/ruby/block/retry_spec.rb~ +43 -0
  54. data/spec/ruby/block_spec.rb~ +520 -0
  55. data/spec/ruby/defn/replacement_spec.rb~ +102 -0
  56. data/spec/ruby/integrity_spec.rb~ +40 -0
  57. data/spec/ruby/singleton_spec.rb~ +76 -0
  58. data/spec/scope_mode/base_spec.rb +14 -5
  59. data/spec/scope_mode/block_spec.rb +18 -9
  60. data/spec/scope_mode/call_spec.rb +11 -2
  61. data/spec/scope_mode/exception_spec.rb +11 -2
  62. data/spec/scope_mode/flow_spec.rb +18 -8
  63. data/spec/scope_mode/optimization_spec.rb +21 -13
  64. data/spec/static/base_spec.rb +54 -0
  65. data/spec/static/flow_spec.rb +48 -0
  66. data/spec/static/operator_spec.rb +104 -0
  67. metadata +58 -8
@@ -19,30 +19,12 @@ along with fastruby. if not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  =end
21
21
  module FastRuby
22
- module CallTranslator
23
-
24
- register_translator_module self
22
+ class Context
25
23
 
24
+ define_translator_for(:call, :method => :to_c_call)
26
25
  def to_c_call(tree, result_var = nil)
27
- directive_code = directive(tree)
28
26
  repass_var = @repass_var
29
27
 
30
- if directive_code
31
- if result_var
32
- return "#{result_var} = #{directive_code};\n"
33
- else
34
- return directive_code
35
- end
36
- end
37
-
38
- if tree[2] == :require
39
- tree[2] = :fastruby_require
40
- elsif tree[2] == :raise
41
- # raise code
42
- args = tree[3]
43
- return _raise(args[1],args[2])
44
- end
45
-
46
28
  recv = tree[1]
47
29
  mname = tree[2]
48
30
  args = tree[3]
@@ -221,11 +203,11 @@ module FastRuby
221
203
 
222
204
  #{if result_var
223
205
  "
224
- #{result_var} = ((VALUE(*)(#{value_cast}))#{encode_address(recvtype,signature,mname,tree,inference_complete)})(recv, (VALUE)pblock, (VALUE)pframe);
206
+ #{result_var} = ((VALUE(*)(VALUE,VALUE,VALUE,int,VALUE*))#{encode_address(recvtype,signature,mname,tree,inference_complete)})(recv, (VALUE)pblock, (VALUE)pframe, 0, (VALUE[]){});
225
207
  "
226
208
  else
227
209
  "
228
- ((VALUE(*)(#{value_cast}))#{encode_address(recvtype,signature,mname,tree,inference_complete)})(recv, (VALUE)pblock, (VALUE)pframe);
210
+ ((VALUE(*)(VALUE,VALUE,VALUE,int,VALUE*))#{encode_address(recvtype,signature,mname,tree,inference_complete)})(recv, (VALUE)pblock, (VALUE)pframe, 0, (VALUE[]){});
229
211
  "
230
212
  end
231
213
  }
@@ -234,7 +216,7 @@ module FastRuby
234
216
 
235
217
  result_var ? code : inline_block(code)
236
218
  else
237
- "((VALUE(*)(#{value_cast}))#{encode_address(recvtype,signature,mname,tree,inference_complete)})(#{to_c recv}, Qfalse, (VALUE)pframe)"
219
+ "((VALUE(*)(VALUE,VALUE,VALUE,int,VALUE*))#{encode_address(recvtype,signature,mname,tree,inference_complete)})(#{to_c recv}, Qfalse, (VALUE)pframe, 0, (VALUE[]){})"
238
220
  end
239
221
 
240
222
  else
@@ -287,11 +269,11 @@ module FastRuby
287
269
 
288
270
  #{if result_var
289
271
  "
290
- #{result_var} = ((VALUE(*)(#{value_cast}))#{encode_address(recvtype,signature,mname,tree,inference_complete)})(recv, (VALUE)pblock, (VALUE)pframe, #{strargs});
272
+ #{result_var} = ((VALUE(*)(VALUE,VALUE,VALUE,int,VALUE*))#{encode_address(recvtype,signature,mname,tree,inference_complete)})(recv, (VALUE)pblock, (VALUE)pframe, #{args.size-1}, (VALUE[]){#{strargs}});
291
273
  "
292
274
  else
293
275
  "
294
- ((VALUE(*)(#{value_cast}))#{encode_address(recvtype,signature,mname,tree,inference_complete)})(recv, (VALUE)pblock, (VALUE)pframe, #{strargs});
276
+ ((VALUE(*)(VALUE,VALUE,VALUE,int,VALUE*))#{encode_address(recvtype,signature,mname,tree,inference_complete)})(recv, (VALUE)pblock, (VALUE)pframe, #{args.size-1}, (VALUE[]){#{strargs}});
295
277
  "
296
278
  end
297
279
  }
@@ -302,7 +284,7 @@ module FastRuby
302
284
  result_var ? code : inline_block(code)
303
285
  else
304
286
  strargs = args[1..-1].map{|arg| to_c arg}.join(",")
305
- "((VALUE(*)(#{value_cast}))#{encode_address(recvtype,signature,mname,tree,inference_complete)})(#{to_c recv}, Qfalse, (VALUE)pframe, #{strargs})"
287
+ "((VALUE(*)(VALUE,VALUE,VALUE,int,VALUE*))#{encode_address(recvtype,signature,mname,tree,inference_complete)})(#{to_c recv}, Qfalse, (VALUE)pframe, #{args.size-1}, (VALUE[]){#{strargs}})"
306
288
  end
307
289
  end
308
290
 
@@ -330,6 +312,7 @@ module FastRuby
330
312
  end # if recvtype
331
313
  end
332
314
 
315
+ define_translator_for(:call, :method => :to_c_attrasgn, :arity => 1)
333
316
  def to_c_attrasgn(tree)
334
317
  to_c_call(tree)
335
318
  end
@@ -19,9 +19,9 @@ along with fastruby. if not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  =end
21
21
  module FastRuby
22
- module DefnTranslator
23
- register_translator_module self
24
-
22
+ class Context
23
+
24
+ define_translator_for(:defn, :method => :to_c_defn)
25
25
  def to_c_defn(tree, result_var = nil)
26
26
 
27
27
  method_name = tree[1]
@@ -82,6 +82,7 @@ module FastRuby
82
82
  end
83
83
  end
84
84
 
85
+ define_translator_for(:defs, :method => :to_c_defs)
85
86
  def to_c_defs(tree, result_var = nil)
86
87
  method_name = tree[2]
87
88
  args_tree = tree[3].select{|x| x.to_s[0] != ?&}
@@ -127,6 +128,7 @@ module FastRuby
127
128
 
128
129
  end
129
130
 
131
+ define_translator_for(:scope, :method => :to_c_scope)
130
132
  def to_c_scope(tree, result_var = nil)
131
133
  if tree[1]
132
134
  if result_var
@@ -0,0 +1,42 @@
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(:call, :priority => 100){ |tree, result_var=nil|
25
+ directive_code = directive(tree)
26
+
27
+ if result_var
28
+ return "#{result_var} = #{directive_code};\n"
29
+ else
30
+ return directive_code
31
+ end
32
+
33
+ }.condition{|*x|
34
+ tree = x.first; tree.node_type == :call && directive(tree)
35
+ }
36
+
37
+ define_translator_for(:call, :method => :to_c_attrasgn, :arity => 1)
38
+ def to_c_attrasgn(tree)
39
+ to_c_call(tree)
40
+ end
41
+ end
42
+ end
@@ -19,10 +19,9 @@ along with fastruby. if not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  =end
21
21
  module FastRuby
22
- module ExceptionsTranslator
23
- register_translator_module self
24
-
25
-
22
+ class Context
23
+
24
+ define_translator_for(:rescue, :method => :to_c_rescue, :arity => 1)
26
25
  def to_c_rescue(tree)
27
26
  if tree[1][0] == :resbody
28
27
  else_tree = tree[2]
@@ -51,7 +50,7 @@ module FastRuby
51
50
  next if resbody_tree[0] != :resbody
52
51
 
53
52
  if resbody_tree[1].size == 1
54
- resbody_tree[1][1] = [:const, :Exception]
53
+ resbody_tree[1][1] = s(:const, :Exception)
55
54
  end
56
55
 
57
56
  if resbody_tree[1].last[0] == :lasgn
@@ -94,6 +93,7 @@ module FastRuby
94
93
  end
95
94
  end
96
95
 
96
+ define_translator_for(:ensure, :method => :to_c_ensure, :arity => 1)
97
97
  def to_c_ensure(tree)
98
98
  if tree.size == 2
99
99
  to_c tree[1]
@@ -105,30 +105,12 @@ module FastRuby
105
105
  end
106
106
  end
107
107
 
108
- def _raise(class_tree, message_tree = nil)
109
- class_tree = to_c class_tree unless class_tree.instance_of? String
110
-
111
- if message_tree.instance_of? String
112
- message_tree = "rb_str_new2(#{message_tree.inspect})"
113
- else
114
- message_tree = to_c message_tree
115
- end
116
-
117
- if message_tree
118
- return inline_block("
119
- pframe->thread_data->exception = rb_funcall(#{class_tree}, #{intern_num :exception},1,#{message_tree});
120
- longjmp(pframe->jmp, FASTRUBY_TAG_RAISE);
121
- return Qnil;
122
- ")
123
- else
124
- return inline_block("
125
- pframe->thread_data->exception = rb_funcall(#{class_tree}, #{intern_num :exception},0);
126
- longjmp(pframe->jmp, FASTRUBY_TAG_RAISE);
127
- return Qnil;
128
- ")
129
- end
130
-
131
- end
132
-
108
+ define_translator_for(:call, :priority => 100){ |tree, result_var=nil|
109
+ # raise code
110
+ args = tree[3]
111
+ _raise(args[1],args[2])
112
+ }.condition{|*x|
113
+ tree = x.first; tree.node_type == :call && tree[2] == :raise
114
+ }
133
115
  end
134
116
  end
@@ -19,66 +19,8 @@ along with fastruby. if not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  =end
21
21
  module FastRuby
22
- module FlowControlTranslator
23
-
24
- register_translator_module self
25
-
26
- def to_c_case(tree, result_var = nil)
27
-
28
- tmpvarname = "tmp" + rand(1000000).to_s;
29
- @repass_var = tmpvarname
30
- outputvar = result_var || ("tmp_" + rand(1000000).to_s);
31
-
32
- code = tree[2..-2].map{|subtree|
33
-
34
- # this subtree is a when
35
- subtree[1][1..-1].map{|subsubtree|
36
- c_calltree = s(:call, nil, :inline_c, s(:arglist, s(:str, tmpvarname), s(:false)))
37
- calltree = s(:call, subsubtree, :===, s(:arglist, c_calltree))
38
- "
39
- if (RTEST(#{to_c_call(calltree)})) {
40
- #{to_c(subtree[2],outputvar)};
41
- }
42
- "
43
- }.join(" else ")
44
-
45
- }.join(" else ") + "else {
46
- #{
47
- if tree[-1]
48
- to_c tree[-1],outputvar
49
- end
50
- };
51
- }
52
- "
53
-
54
- ret_code = "
55
- {
56
- #{
57
- unless result_var
58
- VALUE #{outputvar} = Qnil;
59
- end
60
- }
61
-
62
- VALUE #{tmpvarname} = Qnil;
63
- #{to_c tree[1], tmpvarname};
64
-
65
- // case
66
- #{code}
67
- #{
68
- unless result_var
69
- "return #{outputvar};"
70
- end
71
- }
72
- }
73
- "
74
-
75
- if result_var
76
- ret_code
77
- else
78
- inline_block ret_code
79
- end
80
- end
81
-
22
+ class Context
23
+ define_translator_for(:if, :method => :to_c_if)
82
24
  def to_c_if(tree, result_variable_ = nil)
83
25
  condition_tree = tree[1]
84
26
  impl_tree = tree[2]
@@ -86,35 +28,43 @@ module FastRuby
86
28
 
87
29
  result_variable = result_variable_ || "last_expression"
88
30
 
89
- code = "
90
- {
91
- VALUE condition_result;
92
- #{to_c condition_tree, "condition_result"};
93
- if (RTEST(condition_result)) {
94
- #{to_c impl_tree, result_variable};
95
- }#{else_tree ?
96
- " else {
97
- #{to_c else_tree, result_variable};
31
+ infered_value = infer_value(condition_tree)
32
+ unless infered_value
33
+
34
+ code = "
35
+ {
36
+ VALUE condition_result;
37
+ #{to_c condition_tree, "condition_result"};
38
+ if (RTEST(condition_result)) {
39
+ #{to_c impl_tree, result_variable};
40
+ }#{else_tree ?
41
+ " else {
42
+ #{to_c else_tree, result_variable};
43
+ }
44
+ " : ""
98
45
  }
99
- " : ""
100
46
  }
101
- }
102
- "
103
-
104
- if result_variable_
105
- code
47
+ "
48
+
49
+ if result_variable_
50
+ code
51
+ else
52
+ inline_block code + "; return last_expression;"
53
+ end
106
54
  else
107
- inline_block code + "; return last_expression;"
55
+ if infered_value.value
56
+ to_c(impl_tree, result_variable_)
57
+ else
58
+ if else_tree
59
+ to_c(else_tree, result_variable_)
60
+ else
61
+ to_c(s(:nil), result_variable_)
62
+ end
63
+ end
108
64
  end
109
65
  end
110
66
 
111
- def to_c_for(tree)
112
- alter_tree = tree.dup
113
- alter_tree[0] = :iter
114
- alter_tree[1] = [:call, alter_tree[1], :each, [:arglist]]
115
- to_c alter_tree
116
- end
117
-
67
+ define_translator_for(:while, :method => :to_c_while)
118
68
  def to_c_while(tree, result_var = nil)
119
69
 
120
70
  begin_while = "begin_while_"+rand(10000000).to_s
@@ -19,10 +19,9 @@ along with fastruby. if not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  =end
21
21
  module FastRuby
22
- module IterTranslator
22
+ class Context
23
23
 
24
- register_translator_module IterTranslator
25
-
24
+ define_translator_for(:iter, :method => :to_c_iter)
26
25
  def to_c_iter(tree, result_var = nil)
27
26
 
28
27
  call_tree = tree[1]
@@ -629,10 +628,8 @@ fastruby_local_next:
629
628
  encoded_address = encode_address(recvtype,signature,mname,call_tree,inference_complete,convention_global_name)
630
629
 
631
630
  if call_args_tree.size > 1
632
- value_cast = ( ["VALUE"]*(call_tree[3].size) ).join(",") + ", VALUE, VALUE"
633
- strargs = "," + (0..call_args_tree.size-2).map{|i| "arg#{i}"}.join(",")
631
+ strargs = (0..call_args_tree.size-2).map{|i| "arg#{i}"}.join(",")
634
632
  else
635
- value_cast = "VALUE,VALUE,VALUE"
636
633
  strargs = ""
637
634
  end
638
635
 
@@ -652,7 +649,7 @@ fastruby_local_next:
652
649
  end
653
650
  }
654
651
 
655
- ret = ((VALUE(*)(#{value_cast}))#{encoded_address})(recv, (VALUE)&block, (VALUE)&call_frame #{strargs});
652
+ ret = ((VALUE(*)(VALUE,VALUE,VALUE,int,VALUE*))#{encoded_address})(recv, (VALUE)&block, (VALUE)&call_frame, #{call_args_tree.size-1}, (VALUE[]){#{strargs}});
656
653
  "
657
654
 
658
655
  code = "
@@ -19,21 +19,13 @@ along with fastruby. if not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  =end
21
21
  module FastRuby
22
- module LiteralTranslator
23
- register_translator_module self
24
-
25
- def to_c_lit(tree)
26
- literal_value tree[1]
27
- end
28
-
29
- def to_c_nil(tree)
30
- "Qnil"
31
- end
32
-
33
- def to_c_str(tree)
34
- literal_value tree[1]
35
- end
22
+ class Context
23
+
24
+ define_translator_for(:lit, :arity => 1){|tree| literal_value tree[1]}
25
+ define_translator_for(:nil, :arity => 1){|tree| "Qnil"}
26
+ define_translator_for(:str, :arity => 1){|tree| literal_value tree[1]}
36
27
 
28
+ define_translator_for(:hash, :method => :to_c_hash)
37
29
  def to_c_hash(tree, result_var = nil)
38
30
 
39
31
  hash_tmp_var = "_hash_"+rand(1000000).to_s
@@ -78,6 +70,7 @@ module FastRuby
78
70
  end
79
71
  end
80
72
 
73
+ define_translator_for(:array, :method => :to_c_array)
81
74
  def to_c_array(tree, result_var = nil)
82
75
  if tree.size > 1
83
76
  if result_var
@@ -112,18 +105,11 @@ module FastRuby
112
105
  end
113
106
  end
114
107
 
115
- def to_c_self(tree)
116
- locals_accessor + "self"
117
- end
118
-
119
- def to_c_false(tree)
120
- "Qfalse"
121
- end
122
-
123
- def to_c_true(tree)
124
- "Qtrue"
125
- end
108
+ define_translator_for(:self, :arity => 1){|tree| locals_accessor + "self"}
109
+ define_translator_for(:false, :arity => 1){|tree| "Qfalse"}
110
+ define_translator_for(:true, :arity => 1){|tree| "Qtrue"}
126
111
 
112
+ define_translator_for(:dot2, :method => :to_c_dot2)
127
113
  def to_c_dot2(tree, result_var = nil)
128
114
 
129
115
  begin_var = "_begin"+rand(10000000).to_s
@@ -19,9 +19,9 @@ along with fastruby. if not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  =end
21
21
  module FastRuby
22
- module LogicalOperatorTranslator
23
- register_translator_module self
24
-
22
+ class Context
23
+
24
+ define_translator_for(:and, :method => :to_c_and)
25
25
  def to_c_and(tree, return_var = nil)
26
26
  if return_var
27
27
  "
@@ -39,6 +39,7 @@ module FastRuby
39
39
 
40
40
  end
41
41
 
42
+ define_translator_for(:or, :method => :to_c_or)
42
43
  def to_c_or(tree, return_var = nil)
43
44
  if return_var
44
45
  "
@@ -55,6 +56,7 @@ module FastRuby
55
56
  end
56
57
  end
57
58
 
59
+ define_translator_for(:not, :method => :to_c_not)
58
60
  def to_c_not(tree, return_var = nil)
59
61
  if return_var
60
62
  "
@@ -19,9 +19,9 @@ along with fastruby. if not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  =end
21
21
  module FastRuby
22
- module BlockTranslator
23
- register_translator_module self
24
-
22
+ class Context
23
+
24
+ define_translator_for(:class, :method => :to_c_class)
25
25
  def to_c_class(tree, result_var = nil)
26
26
  str_class_name = get_class_name(tree[1])
27
27
  container_tree = get_container_tree(tree[1])
@@ -60,6 +60,7 @@ module FastRuby
60
60
  end
61
61
  end
62
62
 
63
+ define_translator_for(:module, :method => :to_c_module)
63
64
  def to_c_module(tree, result_var = nil)
64
65
  str_class_name = get_class_name(tree[1])
65
66
  container_tree = get_container_tree(tree[1])
@@ -19,9 +19,9 @@ along with fastruby. if not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  =end
21
21
  module FastRuby
22
- module NonLocalTranslator
23
- register_translator_module self
24
-
22
+ class Context
23
+
24
+ define_translator_for(:return, :method => :to_c_return)
25
25
  def to_c_return(tree, return_variable = nil)
26
26
  code = "
27
27
  #{to_c(tree[1],"last_expression")};
@@ -35,6 +35,7 @@ module FastRuby
35
35
  end
36
36
  end
37
37
 
38
+ define_translator_for(:break, :method => :to_c_break)
38
39
  def to_c_break(tree, result_var = nil)
39
40
 
40
41
  value_tmp_var = "value_" + rand(10000000).to_s
@@ -73,6 +74,7 @@ module FastRuby
73
74
  end
74
75
  end
75
76
 
77
+ define_translator_for(:retry, :method => :to_c_retry)
76
78
  def to_c_retry(tree, result_var = nil)
77
79
  code = "
78
80
  {
@@ -94,6 +96,7 @@ module FastRuby
94
96
  end
95
97
  end
96
98
 
99
+ define_translator_for(:redo, :method => :to_c_redo)
97
100
  def to_c_redo(tree, result_var = nil)
98
101
  if @on_block
99
102
  code = "
@@ -110,6 +113,7 @@ module FastRuby
110
113
  end
111
114
  end
112
115
 
116
+ define_translator_for(:next, :method => :to_c_next)
113
117
  def to_c_next(tree, result_var = nil)
114
118
  tmp_varname = "_acc_" + rand(10000000).to_s
115
119
  if @on_block
@@ -135,7 +139,5 @@ module FastRuby
135
139
  _raise("rb_eLocalJumpError","illegal next");
136
140
  end
137
141
  end
138
-
139
-
140
142
  end
141
143
  end