fastruby 0.0.20 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. data/Rakefile +1 -1
  2. data/lib/fastruby/builder.rb~ +5 -1
  3. data/lib/fastruby/corelib/fixnum.rb +1 -1
  4. data/lib/fastruby/corelib/fixnum.rb~ +0 -71
  5. data/lib/fastruby/corelib.rb~ +1 -1
  6. data/lib/fastruby/modules/inliner/call.rb~ +3 -1
  7. data/lib/fastruby/modules/translator/call.rb +1 -1
  8. data/lib/fastruby/modules/translator/call.rb~ +1 -1
  9. data/lib/fastruby/object.rb~ +0 -6
  10. data/lib/fastruby.rb +1 -1
  11. data/lib/fastruby.rb~ +1 -1
  12. data/spec/corelib/numeric/fixnum_spec.rb +1 -1
  13. data/spec/corelib/numeric/fixnum_spec.rb~ +7 -1
  14. metadata +12 -40
  15. data/lib/fastruby/builder/inference_updater.rb~ +0 -76
  16. data/lib/fastruby/builder/inliner.rb~ +0 -60
  17. data/lib/fastruby/builder/lvar_type.rb~ +0 -44
  18. data/lib/fastruby/builder/pipeline.rb~ +0 -43
  19. data/lib/fastruby/builder/reductor.rb~ +0 -42
  20. data/lib/fastruby/corelib/integer.rb~ +0 -96
  21. data/lib/fastruby/modules/inliner/defn.rb~ +0 -29
  22. data/lib/fastruby/modules/inliner/recursive.rb~ +0 -40
  23. data/lib/fastruby/modules/lvar_type/call.rb~ +0 -36
  24. data/lib/fastruby/modules/lvar_type/defn.rb~ +0 -42
  25. data/lib/fastruby/modules/lvar_type/lasgn.rb~ +0 -42
  26. data/lib/fastruby/modules/lvar_type/recursive.rb~ +0 -33
  27. data/lib/fastruby/modules/reductor/nontree.rb~ +0 -32
  28. data/lib/fastruby/modules/reductor/recursive.rb~ +0 -31
  29. data/lib/fastruby/modules/translator/defn.rb~ +0 -267
  30. data/lib/fastruby/modules/translator/directive.rb~ +0 -44
  31. data/lib/fastruby/modules/translator/exceptions.rb~ +0 -120
  32. data/lib/fastruby/modules/translator/iter.rb~ +0 -745
  33. data/lib/fastruby/modules/translator/literal.rb~ +0 -150
  34. data/lib/fastruby/modules/translator/nonlocal.rb~ +0 -298
  35. data/lib/fastruby/modules/translator/static.rb~ +0 -291
  36. data/lib/fastruby/modules/translator/variable.rb~ +0 -280
  37. data/lib/fastruby/set_tree.rb~ +0 -71
  38. data/lib/fastruby/sexp_extension.rb~ +0 -262
  39. data/lib/fastruby/translator/scope_mode_helper.rb~ +0 -138
  40. data/lib/fastruby/translator/translator.rb~ +0 -1600
  41. data/lib/fastruby/translator/translator_modules.rb~ +0 -53
  42. data/lib/fastruby_only/base.rb +0 -1
@@ -1,96 +0,0 @@
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
- class Integer
22
- fastruby(:fastruby_only => true, :skip_reduce => true) do
23
- def times
24
- unless block_given?
25
- return _static{rb_enumeratorize(self, _dynamic{:times}, inline_c("0"), inline_c("0") ) }
26
- end
27
-
28
- if self._class == Fixnum
29
- i = 0
30
- while _static{FIX2LONG(i) < FIX2LONG(self)}
31
- yield(i)
32
- i = _static{LONG2FIX(FIX2LONG(i)+1)}
33
- end
34
- else
35
- i = 0
36
- while i < self
37
- yield(i)
38
- i = i + 1
39
- end
40
- end
41
- end
42
-
43
- def uptox(x)
44
- unless block_given?
45
- return _static{rb_enumeratorize(self, _dynamic{:upto}, inline_c("1"), c_address_of(x)) }
46
- end
47
-
48
- if self._class == Fixnum
49
- if x._class == Fixnum
50
- i = self
51
- while _static{FIX2LONG(i) <= FIX2LONG(x)}
52
- yield(i)
53
- i = _static{LONG2FIX(FIX2LONG(i)+1)}
54
- end
55
-
56
- return self
57
- end
58
- end
59
-
60
- i = self
61
- while i <= x
62
- yield(i)
63
- i = i + 1
64
- end
65
-
66
- self
67
- end
68
-
69
- def downto(x)
70
- unless block_given?
71
- return _static{rb_enumeratorize(self, _dynamic{:downto}, inline_c("1"), c_address_of(x)) }
72
- end
73
-
74
- if self._class == Fixnum
75
- if x._class == Fixnum
76
- i = self
77
- while _static{FIX2LONG(i) >= FIX2LONG(x)}
78
- yield(i)
79
- i = _static{LONG2FIX(FIX2LONG(i)-1)}
80
- end
81
-
82
- return self
83
- end
84
- end
85
-
86
- i = self
87
- while i >= x
88
- yield(i)
89
- i = i - 1
90
- end
91
-
92
- self
93
- end
94
-
95
- end
96
- end
@@ -1,29 +0,0 @@
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
- require "set"
22
- require "sexp"
23
- require "define_method_handler"
24
-
25
- module FastRuby
26
- class Inliner
27
-
28
- end
29
- end
@@ -1,40 +0,0 @@
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
- require "set"
22
- require "sexp"
23
- require "define_method_handler"
24
-
25
- module FastRuby
26
- class Inliner
27
-
28
- def recursive_inline(tree)
29
- tree.map &method(:inline)
30
- end
31
-
32
- define_method_handler(:inline, :priority => -100) {|tree|
33
- tree.map{|subtree| inline subtree}
34
- }.condition{|tree| tree.respond_to?(:node_type)}
35
-
36
- define_method_handler(:inline, :priority => 1000) {|tree|
37
- tree
38
- }.condition{|tree| not tree.respond_to?(:node_type)}
39
- end
40
- end
@@ -1,36 +0,0 @@
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
- require "define_method_handler"
22
-
23
- module FastRuby
24
- class LvarType
25
- define_method_handler(:process) {|tree|
26
- args = tree[3]
27
- lvar_name = args[1][1] || args[1][2]
28
- lvar_type = eval(args[2][1].to_s)
29
-
30
- @infer_lvar_map[lvar_name] = lvar_type
31
- @inferencer.infer_lvar_map[lvar_name] = lvar_type
32
-
33
- tree
34
- }.condition{|tree| tree && tree.node_type == :call && tree[2] == :lvar_type }
35
- end
36
- end
@@ -1,42 +0,0 @@
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
- require "define_method_handler"
22
-
23
- module FastRuby
24
- class LvarType
25
- define_method_handler(:process) {|tree|
26
- if @process_defn_disabled
27
- tree
28
- else
29
- old = @process_defn_disabled
30
- @process_defn_disabled = true
31
- begin
32
- next tree.map &method(:process)
33
- ensure
34
- @process_defn_disabled = old
35
- end
36
- end
37
-
38
- tree
39
- }.condition{|tree| tree.node_type == :defn or tree.node_type == :defs}
40
-
41
- end
42
- end
@@ -1,42 +0,0 @@
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
- require "define_method_handler"
22
-
23
- module FastRuby
24
- class LvarType
25
-
26
- if RUBY_VERSION =~ /^1\\.9/
27
- define_method_handler(:process) {|tree|
28
- @current_index = (@current_index || 1) + 1
29
- varname = "lvar_type_tmp_#{@current_index}".to_sym
30
- class_condition = fs("_static{CLASS_OF(_a) == ::#{@infer_lvar_map[tree[1]].to_s}._invariant }", :_a => fs(:lvar,varname))
31
-
32
- fs(:block,
33
- fs(:lasgn, varname, tree[2]),
34
- fs(:if, class_condition, fs(:lasgn, tree[1], fs(:lvar, varname.to_sym)), fs('_raise(FastRuby::TypeMismatchAssignmentException, "")') )
35
- )
36
- }.condition{|tree| tree &&
37
- tree.node_type == :lasgn &&
38
- tree.size == 3 &&
39
- @infer_lvar_map[tree[1]] }
40
- end
41
- end
42
- end
@@ -1,33 +0,0 @@
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
- require "define_method_handler"
22
-
23
- module FastRuby
24
- class LvarType
25
- define_method_handler(:process, :priority => -100) {|tree|
26
- tree.map &method(:process)
27
- }.condition{|tree| tree.respond_to?(:node_type)}
28
-
29
- define_method_handler(:process, :priority => 1000) {|tree|
30
- tree
31
- }.condition{|tree| not tree.respond_to?(:node_type)}
32
- end
33
- end
@@ -1,32 +0,0 @@
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
- require "set"
22
- require "sexp"
23
- require "define_method_handler"
24
-
25
- module FastRuby
26
- class Reductor
27
- define_method_handler(:reduce, :priority => -100) {|tree|
28
- print caller.join("\n")
29
- tree
30
- }.condition{|tree| not tree.respond_to?(:node_type)}
31
- end
32
- end
@@ -1,31 +0,0 @@
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
- require "set"
22
- require "sexp"
23
- require "define_method_handler"
24
-
25
- module FastRuby
26
- class Reductor
27
- define_method_handler(:reduce, :priority => -100) {|*x| tree = x.first;
28
- tree.map{|subtree| reduce subtree}
29
- }.condition{|*x| tree = x.first; tree.respond_to?(:node_type)}
30
- end
31
- end
@@ -1,267 +0,0 @@
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(:defn, :method => :to_c_defn)
25
- def to_c_defn(tree, result_var = nil)
26
-
27
- method_name = tree[1]
28
- args_tree = tree[2].select{|x| x.to_s[0] != ?&}
29
-
30
- global_klass_variable = add_global_name("VALUE", "Qnil");
31
-
32
- hash = Hash.new
33
- value_cast = ( ["VALUE"]*(args_tree.size+2) ).join(",")
34
-
35
- strmethodargs = "self,block,(VALUE)&frame"
36
-
37
- anonymous_method_name = anonymous_dispatcher(global_klass_variable, method_name)
38
- alt_options = options.dup
39
-
40
- alt_options.delete(:self)
41
- alt_options.delete(:main)
42
-
43
- code = "
44
-
45
-
46
- if (rb_obj_is_kind_of(plocals->self, rb_cClass) || rb_obj_is_kind_of(plocals->self, rb_cModule)) {
47
-
48
- #{unless options[:fastruby_only]
49
- "rb_define_method(plocals->self, #{method_name.to_s.inspect}, #{anonymous_method_name}, -1);"
50
- end
51
- }
52
-
53
- #{global_klass_variable} = plocals->self;
54
- // set tree
55
- rb_funcall(#{literal_value FastRuby}, #{intern_num :set_tree}, 4,
56
- #{global_klass_variable},
57
- rb_str_new2(#{method_name.to_s.inspect}),
58
- #{literal_value tree},
59
- #{literal_value alt_options}
60
-
61
- );
62
-
63
- } else {
64
- VALUE obj = plocals->self;
65
- rb_define_singleton_method(obj, #{method_name.to_s.inspect}, #{anonymous_method_name}, -1 );
66
-
67
- #{global_klass_variable} = CLASS_OF(obj);
68
- // set tree
69
- rb_funcall(#{literal_value FastRuby}, #{intern_num :set_tree}, 4,
70
- #{global_klass_variable},
71
- rb_str_new2(#{method_name.to_s.inspect}),
72
- #{literal_value tree},
73
- #{literal_value alt_options}
74
-
75
- );
76
- }
77
-
78
- "
79
-
80
- if result_var
81
- code + "\n#{result_var} = Qnil;"
82
- else
83
- inline_block code + "\nreturn Qnil;\n"
84
- end
85
- end
86
-
87
- define_translator_for(:defs, :method => :to_c_defs)
88
- def to_c_defs(tree, result_var = nil)
89
- method_name = tree[2]
90
- args_tree = tree[3].select{|x| x.to_s[0] != ?&}
91
-
92
- global_klass_variable = add_global_name("VALUE", "Qnil");
93
-
94
- hash = Hash.new
95
- value_cast = ( ["VALUE"]*(args_tree.size+2) ).join(",")
96
-
97
- strmethodargs = "self,block,(VALUE)&frame"
98
-
99
- anonymous_method_name = anonymous_dispatcher(global_klass_variable, method_name)
100
-
101
- alt_options = options.dup
102
-
103
- alt_options.delete(:self)
104
- alt_options.delete(:main)
105
-
106
- code = "
107
-
108
- VALUE obj = Qnil;
109
- #{to_c tree[1], "obj"};
110
- rb_define_singleton_method(obj, #{method_name.to_s.inspect}, #{anonymous_method_name}, -1 );
111
-
112
- #{global_klass_variable} = CLASS_OF(obj);
113
- // set tree
114
- rb_funcall(#{literal_value FastRuby}, #{intern_num :set_tree}, 4,
115
- #{global_klass_variable},
116
- rb_str_new2(#{method_name.to_s.inspect}),
117
- #{literal_value tree},
118
- #{literal_value alt_options}
119
-
120
- );
121
-
122
- "
123
-
124
- if result_var
125
- code + "\n#{result_var} = Qnil;"
126
- else
127
- inline_block code + "\nreturn Qnil;\n"
128
- end
129
-
130
- end
131
-
132
- define_translator_for(:scope, :method => :to_c_scope)
133
- def to_c_scope(tree, result_var = nil)
134
- if tree[1]
135
- if result_var
136
- to_c(tree[1], result_var)
137
- else
138
- to_c(tree[1])
139
- end
140
- else
141
- "Qnil"
142
- end
143
- end
144
-
145
- private
146
-
147
- def anonymous_dispatcher(global_klass_variable, method_name)
148
-
149
- strmethodargs = "self,block,(VALUE)&frame"
150
-
151
- anonymous_function{ |anonymous_method_name| "VALUE #{anonymous_method_name}(int argc_, VALUE* argv, VALUE self) {
152
- VALUE klass = #{global_klass_variable};
153
- char method_name[argc_*40+64];
154
-
155
- method_name[0] = '_';
156
- method_name[1] = 0;
157
-
158
- sprintf(method_name+1, \"#{method_name}\");
159
- sprintf(method_name+strlen(method_name), \"%l\", (long)NUM2PTR(rb_obj_id(CLASS_OF(self))));
160
-
161
- int i;
162
- for (i=0; i<argc_; i++) {
163
- sprintf(method_name+strlen(method_name), \"%l\", (long)NUM2PTR(rb_obj_id(CLASS_OF(argv[i]))));
164
- }
165
-
166
- void** address = 0;
167
- void* fptr = 0;
168
- ID id;
169
- VALUE rb_method_hash;
170
-
171
- id = rb_intern(method_name);
172
- rb_method_hash = rb_funcall(klass, #{intern_num :method_hash},1,#{literal_value method_name});
173
-
174
- if (rb_method_hash != Qnil) {
175
- VALUE tmp = rb_hash_aref(rb_method_hash, PTR2NUM(id));
176
- if (tmp != Qnil) {
177
- address = (void**)NUM2PTR(tmp);
178
- fptr = *address;
179
- }
180
- }
181
-
182
- if (fptr == 0) {
183
- VALUE argv_class[argc_+1];
184
-
185
- argv_class[0] = CLASS_OF(self);
186
- for (i=0; i<argc_; i++) {
187
- argv_class[i+1] = CLASS_OF(argv[i]);
188
- }
189
-
190
- VALUE signature = rb_ary_new4(argc_+1,argv_class);
191
-
192
- rb_funcall(#{global_klass_variable}, #{intern_num :build}, 2, signature,rb_str_new2(#{method_name.to_s.inspect}));
193
-
194
- id = rb_intern(method_name);
195
- rb_method_hash = rb_funcall(klass, #{intern_num :method_hash},1,#{literal_value method_name});
196
-
197
- if (rb_method_hash != Qnil) {
198
- VALUE tmp = rb_hash_aref(rb_method_hash, PTR2NUM(id));
199
- if (tmp != Qnil) {
200
- address = (void**)NUM2PTR(tmp);
201
- fptr = *address;
202
- }
203
- }
204
-
205
- if (fptr == 0) {
206
- rb_raise(rb_eRuntimeError, \"Error: method not found after build\");
207
- }
208
-
209
- }
210
-
211
- struct {
212
- void* parent_frame;
213
- void* plocals;
214
- jmp_buf jmp;
215
- VALUE return_value;
216
- int rescue;
217
- VALUE last_error;
218
- VALUE next_recv;
219
- int targetted;
220
- struct FASTRUBYTHREADDATA* thread_data;
221
- } frame;
222
-
223
- frame.parent_frame = 0;
224
- frame.rescue = 0;
225
- frame.return_value = Qnil;
226
- frame.thread_data = rb_current_thread_data();
227
- frame.targetted = 0;
228
-
229
- volatile VALUE block = Qfalse;
230
-
231
- if (rb_block_given_p()) {
232
- struct {
233
- void* block_function_address;
234
- void* block_function_param;
235
- VALUE proc;
236
- } block_struct;
237
-
238
- block_struct.block_function_address = re_yield;
239
- block_struct.block_function_param = 0;
240
- block_struct.proc = rb_block_proc();
241
-
242
- block = (VALUE)&block_struct;
243
- }
244
-
245
- int aux = setjmp(frame.jmp);
246
- if (aux != 0) {
247
- if (aux == FASTRUBY_TAG_RAISE) {
248
- rb_funcall(self, #{intern_num :raise}, 1, frame.thread_data->exception);
249
- }
250
-
251
- if (frame.targetted == 0) {
252
- frb_jump_tag(aux);
253
- }
254
-
255
- return Qnil;
256
- }
257
-
258
- VALUE tmp = Qnil;
259
- if (argv == 0) argv = &tmp;
260
-
261
- return ((VALUE(*)(VALUE,VALUE,VALUE,int,VALUE*))fptr)(#{strmethodargs}, argc_, argv);
262
- }"
263
- }
264
-
265
- end
266
- end
267
- end
@@ -1,44 +0,0 @@
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){ |*x|
25
- tree, result_var = x
26
-
27
- directive_code = directive(tree)
28
-
29
- if result_var
30
- return "#{result_var} = #{directive_code};\n"
31
- else
32
- return directive_code
33
- end
34
-
35
- }.condition{|*x|
36
- tree = x.first; tree.node_type == :call && directive(tree)
37
- }
38
-
39
- define_translator_for(:call, :method => :to_c_attrasgn, :arity => 1)
40
- def to_c_attrasgn(tree)
41
- to_c_call(tree)
42
- end
43
- end
44
- end