fastruby 0.0.21 → 0.0.22
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/benchmarks/benchmark.rb +3 -0
- data/benchmarks/benchmark.rb~ +3 -12
- data/benchmarks/benchmark8.rb +48 -0
- data/benchmarks/benchmark8.rb~ +46 -0
- data/lib/fastruby.rb +2 -1
- data/lib/fastruby.rb~ +2 -1
- data/lib/fastruby/builder.rb +18 -1
- data/lib/fastruby/builder.rb~ +18 -5
- data/lib/fastruby/modules/lvar_type/lasgn.rb~ +41 -0
- data/lib/fastruby/modules/translator/block.rb +1 -1
- data/lib/fastruby/modules/translator/block.rb~ +128 -0
- data/lib/fastruby/modules/translator/call.rb +62 -139
- data/lib/fastruby/modules/translator/call.rb~ +61 -140
- data/lib/fastruby/modules/translator/defn.rb +49 -105
- data/lib/fastruby/modules/translator/defn.rb~ +211 -0
- data/lib/fastruby/modules/translator/exceptions.rb +1 -0
- data/lib/fastruby/modules/translator/exceptions.rb~ +120 -0
- data/lib/fastruby/modules/translator/iter.rb +13 -20
- data/lib/fastruby/modules/translator/iter.rb~ +738 -0
- data/lib/fastruby/modules/translator/literal.rb +8 -1
- data/lib/fastruby/modules/translator/literal.rb~ +157 -0
- data/lib/fastruby/modules/translator/nonlocal.rb +7 -0
- data/lib/fastruby/modules/translator/nonlocal.rb~ +304 -0
- data/lib/fastruby/modules/translator/static.rb +1 -0
- data/lib/fastruby/modules/translator/static.rb~ +290 -0
- data/lib/fastruby/modules/translator/variable.rb +24 -6
- data/lib/fastruby/modules/translator/variable.rb~ +298 -0
- data/lib/fastruby/translator/translator.rb +411 -284
- data/lib/fastruby/translator/translator.rb~ +1728 -0
- data/spec/fastruby_only/base_spec.rb~ +74 -0
- data/spec/ruby/base_spec.rb~ +1 -338
- data/spec/ruby/block/break_spec.rb~ +21 -0
- data/spec/ruby/block/callcc_spec.rb~ +236 -0
- data/spec/ruby/block/lambda_spec.rb~ +1 -178
- data/spec/ruby/block/next_spec.rb~ +85 -0
- data/spec/ruby/block/proc_spec.rb~ +22 -0
- data/spec/ruby/block/redo_spec.rb~ +133 -0
- data/spec/ruby/block/retry_spec.rb~ +135 -0
- data/spec/ruby/block_spec.rb~ +494 -2
- data/spec/ruby/call/base_call_spec.rb~ +60 -2
- data/spec/ruby/defn/default_args_spec.rb~ +303 -0
- data/spec/ruby/defn/multiple_args_spec.rb~ +317 -0
- data/spec/ruby/defn/replacement_spec.rb +29 -1
- data/spec/ruby/defn/replacement_spec.rb~ +52 -21
- data/spec/ruby/exception/internal_ex_spec.rb~ +2 -2
- data/spec/ruby/variable_spec.rb~ +46 -23
- data/spec/static/flow_spec.rb~ +48 -0
- metadata +34 -12
data/Rakefile
CHANGED
data/benchmarks/benchmark.rb
CHANGED
data/benchmarks/benchmark.rb~
CHANGED
@@ -1,18 +1,6 @@
|
|
1
1
|
require "rubygems"
|
2
2
|
require "fastruby"
|
3
3
|
|
4
|
-
class Fixnum
|
5
|
-
fastruby(:fastruby_only => true) do
|
6
|
-
def +(b)
|
7
|
-
_static{INT2FIX(FIX2INT(self)+FIX2INT(b))}
|
8
|
-
end
|
9
|
-
|
10
|
-
def -(b)
|
11
|
-
_static{INT2FIX(FIX2INT(self)-FIX2INT(b))}
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
4
|
class X
|
17
5
|
def foo(a,b)
|
18
6
|
return a+b
|
@@ -50,6 +38,9 @@ Benchmark::bm(20) do |b|
|
|
50
38
|
Y.optimize(:bar)
|
51
39
|
X.build([X,Fixnum,Fixnum],:foo)
|
52
40
|
Y.build([Y,X],:bar)
|
41
|
+
Fixnum.build([Fixnum,Fixnum],:-)
|
42
|
+
Fixnum.build([Fixnum,Fixnum],:>)
|
43
|
+
Fixnum.build([Fixnum,Fixnum],:+)
|
53
44
|
|
54
45
|
b.report("fastruby") do
|
55
46
|
y.bar(x)
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "fastruby"
|
3
|
+
|
4
|
+
class X
|
5
|
+
def foo(a,b)
|
6
|
+
return a+b
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Y
|
11
|
+
def bar(x)
|
12
|
+
i = 1000000
|
13
|
+
|
14
|
+
# removed lvar_type (see benchmark.rb)
|
15
|
+
|
16
|
+
ret = 0
|
17
|
+
while i > 0
|
18
|
+
ret = x.foo(i,i)
|
19
|
+
i = i - 1
|
20
|
+
end
|
21
|
+
return ret
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
x = X.new
|
27
|
+
y = Y.new
|
28
|
+
|
29
|
+
require 'benchmark'
|
30
|
+
|
31
|
+
Benchmark::bm(20) do |b|
|
32
|
+
|
33
|
+
b.report("ruby") do
|
34
|
+
y.bar(x)
|
35
|
+
end
|
36
|
+
|
37
|
+
X.optimize(:foo)
|
38
|
+
Y.optimize(:bar)
|
39
|
+
X.build([X,Fixnum,Fixnum],:foo)
|
40
|
+
Y.build([Y,X],:bar)
|
41
|
+
Fixnum.build([Fixnum,Fixnum],:-)
|
42
|
+
Fixnum.build([Fixnum,Fixnum],:>)
|
43
|
+
Fixnum.build([Fixnum,Fixnum],:+)
|
44
|
+
|
45
|
+
b.report("fastruby") do
|
46
|
+
y.bar(x)
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "fastruby"
|
3
|
+
|
4
|
+
class X
|
5
|
+
def foo(a,b)
|
6
|
+
return a+b
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Y
|
11
|
+
def bar(x)
|
12
|
+
i = 1000000
|
13
|
+
|
14
|
+
ret = 0
|
15
|
+
while i > 0
|
16
|
+
ret = x.foo(i,i)
|
17
|
+
i = i - 1
|
18
|
+
end
|
19
|
+
return ret
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
x = X.new
|
25
|
+
y = Y.new
|
26
|
+
|
27
|
+
require 'benchmark'
|
28
|
+
|
29
|
+
Benchmark::bm(20) do |b|
|
30
|
+
|
31
|
+
b.report("ruby") do
|
32
|
+
y.bar(x)
|
33
|
+
end
|
34
|
+
|
35
|
+
X.optimize(:foo)
|
36
|
+
Y.optimize(:bar)
|
37
|
+
X.build([X,Fixnum,Fixnum],:foo)
|
38
|
+
Y.build([Y,X],:bar)
|
39
|
+
Fixnum.build([Fixnum,Fixnum],:-)
|
40
|
+
Fixnum.build([Fixnum,Fixnum],:>)
|
41
|
+
Fixnum.build([Fixnum,Fixnum],:+)
|
42
|
+
|
43
|
+
b.report("fastruby") do
|
44
|
+
y.bar(x)
|
45
|
+
end
|
46
|
+
end
|
data/lib/fastruby.rb
CHANGED
@@ -23,6 +23,7 @@ require "fastruby/object"
|
|
23
23
|
require "fastruby/exceptions"
|
24
24
|
require "fastruby/custom_require"
|
25
25
|
require "fastruby/set_tree"
|
26
|
+
require "continuation" if RUBY_VERSION =~ /^1\.9/
|
26
27
|
require "base64"
|
27
28
|
|
28
29
|
class Object
|
@@ -32,7 +33,7 @@ class Object
|
|
32
33
|
end
|
33
34
|
|
34
35
|
module FastRuby
|
35
|
-
VERSION = "0.0.
|
36
|
+
VERSION = "0.0.22" unless defined? FastRuby::VERSION
|
36
37
|
end
|
37
38
|
|
38
39
|
require "fastruby/corelib"
|
data/lib/fastruby.rb~
CHANGED
@@ -23,6 +23,7 @@ require "fastruby/object"
|
|
23
23
|
require "fastruby/exceptions"
|
24
24
|
require "fastruby/custom_require"
|
25
25
|
require "fastruby/set_tree"
|
26
|
+
require "continuation" if RUBY_VERSION =~ /^1\.9/
|
26
27
|
require "base64"
|
27
28
|
|
28
29
|
class Object
|
@@ -32,7 +33,7 @@ class Object
|
|
32
33
|
end
|
33
34
|
|
34
35
|
module FastRuby
|
35
|
-
VERSION = "0.0.
|
36
|
+
VERSION = "0.0.21" unless defined? FastRuby::VERSION
|
36
37
|
end
|
37
38
|
|
38
39
|
require "fastruby/corelib"
|
data/lib/fastruby/builder.rb
CHANGED
@@ -34,7 +34,22 @@ require FastRuby.fastruby_load_path + "/../ext/fastruby_base/fastruby_base"
|
|
34
34
|
module FastRuby
|
35
35
|
class Method
|
36
36
|
attr_accessor :options
|
37
|
-
|
37
|
+
|
38
|
+
def self.observe_method_name(mname, &blk)
|
39
|
+
@observers ||= Hash.new
|
40
|
+
@observers[mname] = @observers[mname] || Array.new
|
41
|
+
@observers[mname] << lambda(&blk)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.notify_method_name(mname)
|
45
|
+
return unless @observers
|
46
|
+
return unless @observers[mname]
|
47
|
+
|
48
|
+
@observers[mname].each do |obs|
|
49
|
+
obs.call
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
38
53
|
def initialize(method_name, owner)
|
39
54
|
@method_name = method_name
|
40
55
|
@owner = owner
|
@@ -46,6 +61,8 @@ module FastRuby
|
|
46
61
|
end
|
47
62
|
|
48
63
|
def tree_changed
|
64
|
+
FastRuby::Method.notify_method_name(@method_name)
|
65
|
+
|
49
66
|
@observers.values.each do |observer|
|
50
67
|
observer.call(self)
|
51
68
|
end
|
data/lib/fastruby/builder.rb~
CHANGED
@@ -34,7 +34,22 @@ require FastRuby.fastruby_load_path + "/../ext/fastruby_base/fastruby_base"
|
|
34
34
|
module FastRuby
|
35
35
|
class Method
|
36
36
|
attr_accessor :options
|
37
|
-
|
37
|
+
|
38
|
+
def self.observe_method_name(mname, &blk)
|
39
|
+
@observers ||= Hash.new
|
40
|
+
@observers[mname] = @observers[mname] || Array.new
|
41
|
+
@observers[mname] << lambda(&blk)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.notify_method_name(mname)
|
45
|
+
return unless @observers
|
46
|
+
return unless @observers[mname]
|
47
|
+
|
48
|
+
@observers[mname].each do |obs|
|
49
|
+
obs.call
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
38
53
|
def initialize(method_name, owner)
|
39
54
|
@method_name = method_name
|
40
55
|
@owner = owner
|
@@ -46,6 +61,8 @@ module FastRuby
|
|
46
61
|
end
|
47
62
|
|
48
63
|
def tree_changed
|
64
|
+
FastRuby::Method.notify_method_name(@method_name)
|
65
|
+
|
49
66
|
@observers.values.each do |observer|
|
50
67
|
observer.call(self)
|
51
68
|
end
|
@@ -181,10 +198,6 @@ module FastRuby
|
|
181
198
|
context.locals = FastRuby::GetLocalsProcessor.get_locals(inlined_tree)
|
182
199
|
|
183
200
|
FastRuby.logger.info "Compiling #{@owner}::#{@method_name} for signature #{signature.inspect}"
|
184
|
-
|
185
|
-
if @method_name == :bar
|
186
|
-
print inlined_tree.to_ruby
|
187
|
-
end
|
188
201
|
c_code = context.to_c_method(inlined_tree,signature)
|
189
202
|
|
190
203
|
unless options[:main]
|
@@ -0,0 +1,41 @@
|
|
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
|
+
|
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
|
@@ -0,0 +1,128 @@
|
|
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(:yield, :method => :to_c_yield, :arity => 1)
|
25
|
+
def to_c_yield(tree)
|
26
|
+
require "pry"; binding.pry
|
27
|
+
@has_yield = true
|
28
|
+
block_code = proc { |name| "
|
29
|
+
static VALUE #{name}(VALUE frame_param, VALUE* block_args, int size) {
|
30
|
+
|
31
|
+
#{@locals_struct} *plocals;
|
32
|
+
#{@frame_struct} *pframe;
|
33
|
+
pframe = (void*)frame_param;
|
34
|
+
plocals = (void*)pframe->plocals;
|
35
|
+
|
36
|
+
if ((plocals->block_function_address) == 0) {
|
37
|
+
#{_raise("rb_eLocalJumpError", "no block given")};
|
38
|
+
} else {
|
39
|
+
return ((VALUE(*)(int,VALUE*,VALUE,VALUE))(plocals->block_function_address))(size, block_args, (VALUE)(plocals->block_function_param), (VALUE)pframe);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
"
|
43
|
+
}
|
44
|
+
|
45
|
+
splat_arg = tree.find{|x| x == :yield ? false : x[0] == :splat}
|
46
|
+
|
47
|
+
protected_block(false) do
|
48
|
+
if splat_arg
|
49
|
+
"
|
50
|
+
VALUE splat_array = Qnil;
|
51
|
+
VALUE block_aux = Qnil;
|
52
|
+
#{to_c(splat_arg[1], "splat_array")};
|
53
|
+
|
54
|
+
if (CLASS_OF(splat_array) == rb_cArray) {
|
55
|
+
VALUE block_args[_RARRAY_LEN(splat_array) + #{tree.size}];
|
56
|
+
int i;
|
57
|
+
#{
|
58
|
+
(0..tree.size-3).map{|i|
|
59
|
+
"
|
60
|
+
#{to_c(tree[i+1], "block_aux")};
|
61
|
+
block_args[#{i}] = block_aux;
|
62
|
+
"
|
63
|
+
}.join(";\n")
|
64
|
+
};
|
65
|
+
|
66
|
+
for (i=0; i<_RARRAY_LEN(splat_array); i++) {
|
67
|
+
block_args[i+#{tree.size-2}] = rb_ary_entry(splat_array,i);
|
68
|
+
}
|
69
|
+
|
70
|
+
last_expression = #{anonymous_function(&block_code)}((VALUE)pframe, block_args, _RARRAY_LEN(splat_array) + #{tree.size-2});
|
71
|
+
} else {
|
72
|
+
VALUE block_args[1+#{tree.size}];
|
73
|
+
#{
|
74
|
+
(0..tree.size-3).map{|i|
|
75
|
+
"
|
76
|
+
#{to_c(tree[i+1], "block_aux")};
|
77
|
+
block_args[#{i}] = block_aux;
|
78
|
+
"
|
79
|
+
}.join(";\n")
|
80
|
+
};
|
81
|
+
|
82
|
+
block_args[#{tree.size-2}] = splat_array;
|
83
|
+
last_expression = #{anonymous_function(&block_code)}((VALUE)pframe, block_args, #{tree.size-1});
|
84
|
+
}
|
85
|
+
|
86
|
+
"
|
87
|
+
else
|
88
|
+
if tree.size > 1
|
89
|
+
"last_expression = " + anonymous_function(&block_code)+"((VALUE)pframe, (VALUE[]){#{tree[1..-1].map{|subtree| to_c subtree}.join(",")}},#{tree.size-1})"
|
90
|
+
else
|
91
|
+
"last_expression = " + anonymous_function(&block_code)+"((VALUE)pframe, (VALUE[]){}, #{tree.size-1})"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
define_translator_for(:block, :method => :to_c_block)
|
98
|
+
def to_c_block(tree, result_variable = nil)
|
99
|
+
if tree.size == 1
|
100
|
+
return inline_block("return Qnil;")
|
101
|
+
end
|
102
|
+
|
103
|
+
code = proc{
|
104
|
+
|
105
|
+
str = tree[1..-2].map{ |subtree|
|
106
|
+
to_c(subtree,"last_expression")
|
107
|
+
}.join(";")
|
108
|
+
|
109
|
+
if tree[-1]
|
110
|
+
str = str + ";#{to_c(tree[-1],"last_expression")};"
|
111
|
+
end
|
112
|
+
|
113
|
+
if result_variable
|
114
|
+
str << "#{result_variable} = last_expression;"
|
115
|
+
else
|
116
|
+
str << "return last_expression;"
|
117
|
+
end
|
118
|
+
str
|
119
|
+
}
|
120
|
+
|
121
|
+
if result_variable
|
122
|
+
code.call
|
123
|
+
else
|
124
|
+
inline_block &code
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -106,6 +106,8 @@ module FastRuby
|
|
106
106
|
|
107
107
|
if args.last[0] == :splat
|
108
108
|
aux_varname = "_aux_" + rand(1000000).to_s
|
109
|
+
|
110
|
+
@has_inline_block = true
|
109
111
|
code = protected_block(
|
110
112
|
"
|
111
113
|
|
@@ -152,55 +154,37 @@ module FastRuby
|
|
152
154
|
end
|
153
155
|
end
|
154
156
|
end
|
157
|
+
|
158
|
+
signature = if recvtype
|
159
|
+
[recvtype]
|
160
|
+
else
|
161
|
+
[nil]
|
162
|
+
end
|
163
|
+
|
164
|
+
args[1..-1].each do |arg|
|
165
|
+
argtype = infer_type(arg)
|
166
|
+
signature << argtype
|
167
|
+
end
|
168
|
+
|
169
|
+
if block_pass_arg
|
155
170
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
inference_complete = true
|
162
|
-
signature = [recvtype]
|
163
|
-
|
164
|
-
args[1..-1].each do |arg|
|
165
|
-
argtype = infer_type(arg)
|
166
|
-
signature << argtype
|
167
|
-
unless argtype
|
168
|
-
inference_complete = false
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
if repass_var
|
173
|
-
extraargs = ","+repass_var
|
174
|
-
extraargs_signature = ",VALUE " + repass_var
|
175
|
-
else
|
176
|
-
extraargs = ""
|
177
|
-
extraargs_signature = ""
|
178
|
-
end
|
179
|
-
|
180
|
-
block_proc_tree = s(:call, block_pass_arg[1], :to_proc, s(:arglist)) if block_pass_arg
|
181
|
-
|
182
|
-
block_wrapping_proc = proc { |name| "
|
183
|
-
static VALUE #{name}(int argc, VALUE* argv, VALUE _locals, VALUE _parent_frame) {
|
184
|
-
return rb_proc_call(_locals, rb_ary_new4(argc, argv));
|
185
|
-
}
|
186
|
-
"
|
171
|
+
block_proc_tree = s(:call, block_pass_arg[1], :to_proc, s(:arglist))
|
172
|
+
block_wrapping_proc = proc { |name| "
|
173
|
+
static VALUE #{name}(int argc, VALUE* argv, VALUE _locals, VALUE _parent_frame) {
|
174
|
+
return rb_proc_call(_locals, rb_ary_new4(argc, argv));
|
187
175
|
}
|
188
|
-
|
176
|
+
"
|
177
|
+
}
|
178
|
+
|
179
|
+
code = inline_block do
|
189
180
|
if argnum == 0
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
{
|
196
|
-
VALUE recv = Qnil;
|
197
|
-
#{to_c recv, "recv"};
|
198
|
-
|
199
|
-
#{@block_struct} block, *pblock = Qfalse;
|
181
|
+
"
|
182
|
+
#{@block_struct} block, *pblock = Qfalse;
|
183
|
+
|
184
|
+
VALUE proc = Qnil;
|
185
|
+
VALUE recv = Qnil;
|
200
186
|
|
201
|
-
#{
|
202
|
-
"
|
203
|
-
VALUE proc = Qnil;
|
187
|
+
#{to_c(recv, "recv")}
|
204
188
|
#{to_c(block_proc_tree, "proc") }
|
205
189
|
|
206
190
|
VALUE block_address_value = rb_ivar_get(proc, #{intern_num "__block_address"});
|
@@ -217,61 +201,21 @@ module FastRuby
|
|
217
201
|
block.proc = proc;
|
218
202
|
pblock = █
|
219
203
|
}
|
220
|
-
|
221
|
-
|
222
|
-
end
|
223
|
-
}
|
224
|
-
|
225
|
-
#{if result_var
|
226
|
-
"
|
227
|
-
#{result_var} = ((VALUE(*)(VALUE,VALUE,VALUE,int,VALUE*))#{encode_address(recvtype,signature,mname,tree,inference_complete)})(recv, (VALUE)pblock, (VALUE)pframe, 0, (VALUE[]){});
|
228
|
-
"
|
229
|
-
else
|
230
|
-
"
|
231
|
-
((VALUE(*)(VALUE,VALUE,VALUE,int,VALUE*))#{encode_address(recvtype,signature,mname,tree,inference_complete)})(recv, (VALUE)pblock, (VALUE)pframe, 0, (VALUE[]){});
|
232
|
-
"
|
233
|
-
end
|
234
|
-
}
|
235
|
-
}
|
236
|
-
"
|
237
|
-
}
|
238
|
-
|
239
|
-
result_var ? code.call : inline_block(&code)
|
240
|
-
else
|
241
|
-
"((VALUE(*)(VALUE,VALUE,VALUE,int,VALUE*))#{encode_address(recvtype,signature,mname,tree,inference_complete)})(#{to_c recv}, Qfalse, (VALUE)pframe, 0, (VALUE[]){})"
|
242
|
-
end
|
243
|
-
|
204
|
+
|
205
|
+
return #{dynamic_call(signature,mname)}(recv, (void*)pblock, (void*)pframe, 0, (VALUE[]){});"
|
244
206
|
else
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
{
|
252
|
-
VALUE recv = Qnil;
|
253
|
-
|
254
|
-
#{
|
255
|
-
(0..args_tree.size-2).map{ |x|
|
256
|
-
"VALUE #{suffix}arg#{x};"
|
257
|
-
}.join("\n")
|
258
|
-
}
|
259
|
-
|
260
|
-
#{
|
261
|
-
(0..args_tree.size-2).map{ |x|
|
262
|
-
to_c(args_tree[x+1], "#{suffix}arg#{x}") + ";"
|
263
|
-
}.join("\n")
|
264
|
-
}
|
265
|
-
|
266
|
-
#{to_c recv, "recv"};
|
267
|
-
|
268
|
-
#{@block_struct} block, *pblock = Qfalse;
|
207
|
+
strargs = args[1..-1].map{|arg| to_c arg}.join(",")
|
208
|
+
"
|
209
|
+
#{@block_struct} block, *pblock = Qfalse;
|
210
|
+
|
211
|
+
VALUE proc = Qnil;
|
212
|
+
VALUE recv = Qnil;
|
269
213
|
|
270
|
-
#{
|
271
|
-
"
|
272
|
-
VALUE proc = Qnil;
|
214
|
+
#{to_c(recv, "recv")}
|
273
215
|
#{to_c(block_proc_tree, "proc") }
|
216
|
+
|
274
217
|
VALUE block_address_value = rb_ivar_get(proc, #{intern_num "__block_address"});
|
218
|
+
|
275
219
|
if (block_address_value != Qnil) {
|
276
220
|
block.block_function_address = NUM2PTR(block_address_value);
|
277
221
|
block.block_function_param = NUM2PTR(rb_ivar_get(proc, #{intern_num "__block_param"}));
|
@@ -284,56 +228,35 @@ module FastRuby
|
|
284
228
|
block.proc = proc;
|
285
229
|
pblock = █
|
286
230
|
}
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
}
|
291
|
-
|
292
|
-
#{if result_var
|
293
|
-
"
|
294
|
-
#{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}});
|
295
|
-
"
|
296
|
-
else
|
297
|
-
"
|
298
|
-
((VALUE(*)(VALUE,VALUE,VALUE,int,VALUE*))#{encode_address(recvtype,signature,mname,tree,inference_complete)})(recv, (VALUE)pblock, (VALUE)pframe, #{args.size-1}, (VALUE[]){#{strargs}});
|
299
|
-
"
|
300
|
-
end
|
301
|
-
}
|
302
|
-
|
303
|
-
|
304
|
-
}
|
305
|
-
"
|
306
|
-
}
|
307
|
-
|
308
|
-
result_var ? code.call : inline_block(&code)
|
309
|
-
else
|
310
|
-
strargs = args[1..-1].map{|arg| to_c arg}.join(",")
|
311
|
-
"((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}})"
|
312
|
-
end
|
231
|
+
|
232
|
+
|
233
|
+
return #{dynamic_call(signature,mname)}(recv, (void*)pblock, (void*)pframe, #{args.size-1}, (VALUE[]){#{strargs}});"
|
313
234
|
end
|
314
|
-
|
315
|
-
|
316
|
-
if
|
317
|
-
code = protected_block("last_expression = rb_funcall(#{to_c recv}, #{intern_num tree[2]}, 0)", true, repass_var)
|
318
|
-
if result_var
|
235
|
+
end
|
236
|
+
|
237
|
+
return (if result_var
|
319
238
|
"
|
320
|
-
|
239
|
+
#{result_var} = #{code};
|
321
240
|
"
|
322
|
-
|
323
|
-
|
324
|
-
|
241
|
+
else
|
242
|
+
code
|
243
|
+
end)
|
244
|
+
else
|
245
|
+
code = if argnum == 0
|
246
|
+
"#{dynamic_call(signature,mname)}(#{to_c recv}, (void*)Qfalse, (void*)pframe, 0, (VALUE[]){})"
|
325
247
|
else
|
326
248
|
strargs = args[1..-1].map{|arg| to_c arg}.join(",")
|
327
|
-
|
328
|
-
|
249
|
+
"#{dynamic_call(signature,mname)}(#{to_c recv}, (void*)Qfalse, (void*)pframe, #{args.size-1}, (VALUE[]){#{strargs}})"
|
250
|
+
end
|
251
|
+
|
252
|
+
return (if result_var
|
329
253
|
"
|
330
|
-
|
254
|
+
#{result_var} = #{code};
|
331
255
|
"
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
end # if recvtype
|
256
|
+
else
|
257
|
+
code
|
258
|
+
end)
|
259
|
+
end
|
337
260
|
end
|
338
261
|
|
339
262
|
define_translator_for(:call, :method => :to_c_attrasgn, :arity => 1)
|