27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/fastruby/builder.rb', line 27
def build(signature, method_name)
tree = self.method_tree[method_name]
locals = self.method_locals[method_name]
options = self.method_options[method_name]
mname = "_" + method_name.to_s + signature.map(&:internal_value).map(&:to_s).join
FastRuby.logger.info mname.to_s
begin
if (self.instance_method(mname))
FastRuby.logger.info "NOT Building #{self}::#{method_name} for signature #{signature.inspect}, it's already done"
return
end
rescue NameError
FastRuby.logger.info "Building #{self}::#{method_name} for signature #{signature.inspect}"
end
context = FastRuby::Context.new
context.locals = locals
context.options = options
args_tree = tree[2]
context.alt_method_name = mname
(1..signature.size).each do |i|
arg = args_tree[i]
context.infer_lvar_map[arg] = signature[i]
end
context.infer_self = signature[0]
c_code = context.to_c(tree)
inline :C do |builder|
builder.inc << context.
builder.include "<node.h>"
builder.c c_code
end
ret = instance_method(mname)
ret.extend MethodExtent
ret.yield_signature = context.yield_signature
ret
end
|