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
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ require "rspec/core/rake_task"
7
7
 
8
8
  spec = Gem::Specification.new do |s|
9
9
  s.name = 'fastruby'
10
- s.version = '0.0.20'
10
+ s.version = '0.0.21'
11
11
  s.author = 'Dario Seminara'
12
12
  s.email = 'robertodarioseminara@gmail.com'
13
13
  s.platform = Gem::Platform::RUBY
@@ -159,7 +159,7 @@ module FastRuby
159
159
  alt_options = options.dup
160
160
  alt_options.delete(:self)
161
161
 
162
- require "pry"; binding.pry
162
+ #require "pry"; binding.pry
163
163
  code_sha1 = FastRuby.cache.hash_snippet(inlined_tree.inspect, FastRuby::VERSION + signature.map(&:to_s).join('-') + alt_options.inspect)
164
164
 
165
165
  paths = FastRuby.cache.retrieve(code_sha1)
@@ -181,6 +181,10 @@ module FastRuby
181
181
  context.locals = FastRuby::GetLocalsProcessor.get_locals(inlined_tree)
182
182
 
183
183
  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
184
188
  c_code = context.to_c_method(inlined_tree,signature)
185
189
 
186
190
  unless options[:main]
@@ -22,7 +22,7 @@ require "fastruby/sexp_extension"
22
22
 
23
23
  class Fixnum
24
24
  fastruby(:fastruby_only => true, :skip_reduce => true) do
25
- if RUBY_VERSION =~ /^1\\.9/
25
+ if RUBY_VERSION =~ /^1\.9/
26
26
  def +(b)
27
27
  if b._class == Fixnum
28
28
  _static{LONG2NUM(FIX2LONG(self)+FIX2LONG(b))}
@@ -22,77 +22,6 @@ require "fastruby/sexp_extension"
22
22
 
23
23
  class Fixnum
24
24
  fastruby(:fastruby_only => true, :skip_reduce => true) do
25
- def times
26
- unless block_given?
27
- return _static{rb_enumeratorize(self, _dynamic{:times}, inline_c("0"), inline_c("0") ) }
28
- end
29
-
30
- if self._class == Fixnum
31
- i = 0
32
- while _static{FIX2LONG(i) < FIX2LONG(self)}
33
- yield(i)
34
- i = _static{LONG2FIX(FIX2LONG(i)+1)}
35
- end
36
- else
37
- i = 0
38
- while i < self
39
- yield(i)
40
- i = i + 1
41
- end
42
- end
43
- end
44
-
45
- def upto(x)
46
- unless block_given?
47
- return _static{rb_enumeratorize(self, _dynamic{:upto}, inline_c("1"), c_address_of(x)) }
48
- end
49
- if self._class == Fixnum
50
- if x._class == Fixnum
51
- i = self
52
- while _static{FIX2LONG(i) <= FIX2LONG(x)}
53
- yield(i)
54
- i = _static{LONG2FIX(FIX2LONG(i)+1)}
55
- end
56
-
57
- return self
58
- end
59
- end
60
-
61
- i = self
62
- while i <= x
63
- yield(i)
64
- i = i + 1
65
- end
66
-
67
- self
68
- end
69
-
70
- def downto(x)
71
- unless block_given?
72
- return _static{rb_enumeratorize(self, _dynamic{:downto}, inline_c("1"), c_address_of(x)) }
73
- end
74
-
75
- if self._class == Fixnum
76
- if x._class == Fixnum
77
- i = self
78
- while _static{FIX2LONG(i) >= FIX2LONG(x)}
79
- yield(i)
80
- i = _static{LONG2FIX(FIX2LONG(i)-1)}
81
- end
82
-
83
- return self
84
- end
85
- end
86
-
87
- i = self
88
- while i >= x
89
- yield(i)
90
- i = i - 1
91
- end
92
-
93
- self
94
- end
95
-
96
25
  if RUBY_VERSION =~ /^1\\.9/
97
26
  def +(b)
98
27
  if b._class == Fixnum
@@ -18,6 +18,6 @@ you should have received a copy of the gnu general public license
18
18
  along with fastruby. if not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  =end
21
- Dir.glob(FastRuby.fastruby_load_path + "/fastruby/stdlib/**/*.rb").each do |path|
21
+ Dir.glob(FastRuby.fastruby_load_path + "/fastruby/corelib/**/*.rb").each do |path|
22
22
  require path
23
23
  end
@@ -154,7 +154,7 @@ module FastRuby
154
154
  if subtree.node_type == :call
155
155
  if subtree[1] == nil
156
156
  if subtree[2] == :block_given?
157
- subtree[0..-1] = fs(:false)
157
+ subtree[0..-1] = block_tree ? fs(:true) : fs(:false)
158
158
  else
159
159
  subtree[1] = recv_tree.duplicate
160
160
  end
@@ -282,6 +282,8 @@ module FastRuby
282
282
  recv_tree = tree[1] || fs(:self)
283
283
  method_name = tree[2]
284
284
  args_tree = tree[3]
285
+
286
+ p method_name
285
287
 
286
288
  if method_name == :lvar_type
287
289
  next tree
@@ -79,7 +79,7 @@ module FastRuby
79
79
  recvtype = infer_type(recv)
80
80
 
81
81
  if args.size > 1
82
- if (not recvtype) or args.last[0] == :splat or (not RUBY_VERSION =~ /^1\\.9/)
82
+ if (not recvtype) or args.last[0] == :splat or (not RUBY_VERSION =~ /^1\.9/)
83
83
  if block_pass_arg
84
84
  call_tree = tree.dup
85
85
  call_tree[3] = args.select{|arg| if arg == :arglist
@@ -79,7 +79,7 @@ module FastRuby
79
79
  recvtype = infer_type(recv)
80
80
 
81
81
  if args.size > 1
82
- if (not recvtype) or args.last[0] == :splat or true
82
+ if (not recvtype) or args.last[0] == :splat or (not RUBY_VERSION =~ /^1\\.9/)
83
83
  if block_pass_arg
84
84
  call_tree = tree.dup
85
85
  call_tree[3] = args.select{|arg| if arg == :arglist
@@ -83,12 +83,6 @@ class Object
83
83
  m = instance_method(mname)
84
84
  if fastruby_options[:fastruby_only]
85
85
  tree = FastRuby::FastRubySexp.parse m.source
86
-
87
- unless FastRuby.acceptable_tree?(tree)
88
- _self.class_eval(m.source)
89
- return
90
- end
91
-
92
86
  FastRuby.set_tree(_self, tree[1], tree, fastruby_options)
93
87
  else
94
88
  @_self.fastruby m.source, fastruby_options
data/lib/fastruby.rb CHANGED
@@ -32,7 +32,7 @@ class Object
32
32
  end
33
33
 
34
34
  module FastRuby
35
- VERSION = "0.0.20" unless defined? FastRuby::VERSION
35
+ VERSION = "0.0.21" unless defined? FastRuby::VERSION
36
36
  end
37
37
 
38
38
  require "fastruby/corelib"
data/lib/fastruby.rb~ CHANGED
@@ -32,7 +32,7 @@ class Object
32
32
  end
33
33
 
34
34
  module FastRuby
35
- VERSION = "0.0.19" unless defined? FastRuby::VERSION
35
+ VERSION = "0.0.20" unless defined? FastRuby::VERSION
36
36
  end
37
37
 
38
38
  require "fastruby/corelib"
@@ -82,7 +82,7 @@ describe FastRuby, "fastruby fixnum corelib" do
82
82
 
83
83
 
84
84
  test_methods = [:-@, :abs, :to_f, :size, :zero?, :odd?, :even?, :succ]
85
- if RUBY_VERSION =~ /^1\\.9/
85
+ if RUBY_VERSION =~ /^1\.9/
86
86
  test_methods << :magnitude
87
87
  end
88
88
 
@@ -80,7 +80,13 @@ describe FastRuby, "fastruby fixnum corelib" do
80
80
  end
81
81
  end
82
82
 
83
- [:-@, :abs, :magnitude, :to_f, :size, :zero?, :odd?, :even?, :succ].each do |op|
83
+
84
+ test_methods = [:-@, :abs, :to_f, :size, :zero?, :odd?, :even?, :succ]
85
+ if RUBY_VERSION =~ /^1\\.9/
86
+ test_methods << :magnitude
87
+ end
88
+
89
+ test_methods.each do |op|
84
90
  test_unary_op(31,op)
85
91
  test_unary_op(-31,op)
86
92
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20
4
+ version: 0.0.21
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-22 00:00:00.000000000Z
12
+ date: 2012-04-24 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: RubyInline
16
- requirement: &72410660 !ruby/object:Gem::Requirement
16
+ requirement: &73515840 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - =
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.11.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *72410660
24
+ version_requirements: *73515840
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: ruby_parser
27
- requirement: &72401420 !ruby/object:Gem::Requirement
27
+ requirement: &73515590 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.0.6
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *72401420
35
+ version_requirements: *73515590
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: define_method_handler
38
- requirement: &72401170 !ruby/object:Gem::Requirement
38
+ requirement: &73515350 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.0.6
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *72401170
46
+ version_requirements: *73515350
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: method_source
49
- requirement: &72400940 !ruby/object:Gem::Requirement
49
+ requirement: &73515110 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.6.7
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *72400940
57
+ version_requirements: *73515110
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: ruby2ruby
60
- requirement: &72400710 !ruby/object:Gem::Requirement
60
+ requirement: &73514880 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: 1.3.1
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *72400710
68
+ version_requirements: *73514880
69
69
  description:
70
70
  email: robertodarioseminara@gmail.com
71
71
  executables: []
@@ -92,67 +92,45 @@ files:
92
92
  - examples/example3.rb
93
93
  - examples/example4.rb
94
94
  - examples/example1.rb
95
- - lib/fastruby/sexp_extension.rb~
96
95
  - lib/fastruby/corelib.rb
97
96
  - lib/fastruby/sexp_extension.rb
98
97
  - lib/fastruby/object.rb
99
98
  - lib/fastruby/builder/inliner.rb
100
99
  - lib/fastruby/builder/lvar_type.rb
101
100
  - lib/fastruby/builder/pipeline.rb
102
- - lib/fastruby/builder/pipeline.rb~
103
- - lib/fastruby/builder/inliner.rb~
104
- - lib/fastruby/builder/lvar_type.rb~
105
101
  - lib/fastruby/builder/locals_inference.rb
106
102
  - lib/fastruby/builder/inference_updater.rb
107
- - lib/fastruby/builder/inference_updater.rb~
108
103
  - lib/fastruby/builder/inferencer.rb
109
- - lib/fastruby/builder/reductor.rb~
110
104
  - lib/fastruby/builder/reductor.rb
111
105
  - lib/fastruby/builder.rb~
112
106
  - lib/fastruby/modules/translator/defn.rb
113
- - lib/fastruby/modules/translator/iter.rb~
114
- - lib/fastruby/modules/translator/literal.rb~
115
- - lib/fastruby/modules/translator/nonlocal.rb~
116
107
  - lib/fastruby/modules/translator/iter.rb
117
108
  - lib/fastruby/modules/translator/directive.rb
118
109
  - lib/fastruby/modules/translator/exceptions.rb
119
110
  - lib/fastruby/modules/translator/static.rb
120
- - lib/fastruby/modules/translator/static.rb~
121
111
  - lib/fastruby/modules/translator/method_group.rb
122
- - lib/fastruby/modules/translator/exceptions.rb~
123
112
  - lib/fastruby/modules/translator/nonlocal.rb
124
- - lib/fastruby/modules/translator/variable.rb~
125
113
  - lib/fastruby/modules/translator/variable.rb
126
114
  - lib/fastruby/modules/translator/call.rb
127
- - lib/fastruby/modules/translator/defn.rb~
128
115
  - lib/fastruby/modules/translator/block.rb
129
116
  - lib/fastruby/modules/translator/call.rb~
130
117
  - lib/fastruby/modules/translator/flow.rb
131
118
  - lib/fastruby/modules/translator/logical.rb
132
- - lib/fastruby/modules/translator/directive.rb~
133
119
  - lib/fastruby/modules/translator/literal.rb
134
120
  - lib/fastruby/modules/inferencer/infer.rb
135
121
  - lib/fastruby/modules/inferencer/literal.rb
136
122
  - lib/fastruby/modules/lvar_type/recursive.rb
137
- - lib/fastruby/modules/lvar_type/recursive.rb~
138
123
  - lib/fastruby/modules/lvar_type/defn.rb
139
124
  - lib/fastruby/modules/lvar_type/lasgn.rb
140
- - lib/fastruby/modules/lvar_type/lasgn.rb~
141
125
  - lib/fastruby/modules/lvar_type/call.rb
142
- - lib/fastruby/modules/lvar_type/defn.rb~
143
- - lib/fastruby/modules/lvar_type/call.rb~
144
126
  - lib/fastruby/modules/inliner/recursive.rb
145
- - lib/fastruby/modules/inliner/recursive.rb~
146
127
  - lib/fastruby/modules/inliner/defn.rb
147
128
  - lib/fastruby/modules/inliner/call.rb
148
- - lib/fastruby/modules/inliner/defn.rb~
149
129
  - lib/fastruby/modules/inliner/call.rb~
150
130
  - lib/fastruby/modules/reductor/for.rb
151
131
  - lib/fastruby/modules/reductor/recursive.rb
152
- - lib/fastruby/modules/reductor/recursive.rb~
153
132
  - lib/fastruby/modules/reductor/nontree.rb
154
133
  - lib/fastruby/modules/reductor/fastruby_flag.rb
155
- - lib/fastruby/modules/reductor/nontree.rb~
156
134
  - lib/fastruby/modules/reductor/case.rb
157
135
  - lib/fastruby/builder.rb
158
136
  - lib/fastruby/inline_extension.rb
@@ -162,25 +140,19 @@ files:
162
140
  - lib/fastruby/exceptions.rb
163
141
  - lib/fastruby/translator/scope_mode_helper.rb
164
142
  - lib/fastruby/translator/translator.rb
165
- - lib/fastruby/translator/translator_modules.rb~
166
143
  - lib/fastruby/translator/translator_modules.rb
167
- - lib/fastruby/translator/translator.rb~
168
- - lib/fastruby/translator/scope_mode_helper.rb~
169
144
  - lib/fastruby/set_tree.rb
170
145
  - lib/fastruby/object.rb~
171
146
  - lib/fastruby/cache/cache.rb
172
147
  - lib/fastruby/modules.rb
173
148
  - lib/fastruby/method_extension.rb
174
149
  - lib/fastruby/custom_require.rb
175
- - lib/fastruby/set_tree.rb~
176
150
  - lib/fastruby/getlocals.rb
177
151
  - lib/fastruby/corelib/fixnum.rb~
178
152
  - lib/fastruby/corelib/integer.rb
179
- - lib/fastruby/corelib/integer.rb~
180
153
  - lib/fastruby/corelib/fixnum.rb
181
154
  - lib/fastruby/fastruby_sexp.rb
182
155
  - lib/fastruby.rb~
183
- - lib/fastruby_only/base.rb
184
156
  - lib/fastruby_load_path.rb
185
157
  - lib/fastruby.rb
186
158
  - spec/edges_helper.rb
@@ -1,76 +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 InferenceUpdater
23
- class AddInfer
24
- attr_accessor :variable_hash
25
-
26
- define_method_handler(:process, :priority => 1) {|tree|
27
- tree
28
- }.condition{|tree| (tree.node_type == :iter and tree[1][2] == :_static) or (tree.node_type == :call and tree[2] == :infer) }
29
-
30
- define_method_handler(:process, :priority => -1) {|tree|
31
- tree.map &method(:process)
32
- }.condition{|tree| tree.respond_to?(:node_type) }
33
-
34
- define_method_handler(:process, :priority => 1) {|tree|
35
- tree
36
- }.condition{|tree| not tree.respond_to?(:node_type) }
37
-
38
- define_method_handler(:process) {|tree|
39
- fs(:call, tree, :infer, fs(:arglist, fs(:const, variable_hash[tree[1]].to_s.to_sym)))
40
- }.condition{|tree| tree.node_type == :lvar and variable_hash[tree[1]] and variable_hash[tree[1]] != :dynamic}
41
-
42
- end
43
-
44
- def initialize(inferencer)
45
- @inferencer = inferencer
46
- end
47
-
48
- def call(tree)
49
- variable_hash = Hash.new
50
-
51
- # search variable assignments
52
- tree.walk_tree do |subtree|
53
- if subtree.node_type == :lasgn and subtree[2]
54
- types = @inferencer.infer(subtree[2])
55
- lname = subtree[1]
56
- if types.size == 1
57
- if variable_hash[lname]
58
- if variable_hash[lname] != types.first
59
- variable_hash[lname] = :dynamic
60
- end
61
- else
62
- variable_hash[lname] = types.first
63
- end
64
- elsif types.size == 0
65
- variable_hash[lname] = :dynamic
66
- end
67
- end
68
- end
69
-
70
- add_infer = AddInfer.new
71
- add_infer.variable_hash = variable_hash
72
-
73
- add_infer.process(tree)
74
- end
75
- end
76
- end
@@ -1,60 +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
- require "fastruby/modules"
23
-
24
- module FastRuby
25
- class Inliner
26
- attr_reader :inlined_methods
27
-
28
- def initialize(inferencer)
29
- @inlined_methods = Array.new
30
- @inferencer = inferencer
31
- end
32
-
33
- define_method_handler(:inline, :priority => -1000) do |tree|
34
- FastRubySexp.from_sexp(tree)
35
- end
36
-
37
- def call(*args)
38
-
39
- return args.first
40
-
41
- if args.first.find_tree{|tree| tree.node_type == :call && tree[2] != :infer && infer_type(tree[1] || fs(:self))}
42
- inline *args
43
- else
44
- args.first
45
- end
46
- end
47
-
48
- FastRuby::Modules.load_all("inliner")
49
-
50
- def infer_type(recv)
51
- array = @inferencer.infer(recv).to_a
52
-
53
- if array.size == 1
54
- array[0]
55
- else
56
- nil
57
- end
58
- end
59
- end
60
- 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
- require "set"
22
- require "sexp"
23
- require "define_method_handler"
24
- require "fastruby/modules"
25
-
26
- module FastRuby
27
- class LvarType
28
- def initialize(inferencer)
29
- @infer_lvar_map = Hash.new
30
- @inferencer = inferencer
31
- end
32
-
33
- def call(*args)
34
- p args.first
35
- # if args.first.find_tree{|tree| tree.node_type == :call && tree[2] == :lvar_type}
36
- # process *args
37
- # else
38
- args.first
39
- # end
40
- end
41
-
42
- FastRuby::Modules.load_all("lvar_type")
43
- end
44
- end
@@ -1,43 +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 Pipeline
25
- def initialize
26
- @array = Array.new
27
- end
28
-
29
- def << (object)
30
- @array << object
31
- end
32
-
33
- def call(arg)
34
-
35
- last_result = arg
36
- @array.each do |processor|
37
- last_result = processor.call(last_result)
38
- end
39
-
40
- last_result
41
- end
42
- end
43
- 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 "set"
22
- require "sexp"
23
- require "define_method_handler"
24
- require "fastruby/modules"
25
-
26
- module FastRuby
27
- class Reductor
28
- def self.reduce_for(ntype, options = {}, &blk)
29
- define_method_handler(:reduce, options, &blk).condition{|*x| tree = x.first; tree.respond_to?(:node_type) && tree.node_type == ntype}
30
- end
31
-
32
- def call(*args)
33
- reduce args.first
34
- end
35
-
36
- define_method_handler(:reduce, :priority => -1000) do |*x| tree = x.first;
37
- FastRubySexp.from_sexp(tree)
38
- end
39
-
40
- FastRuby::Modules.load_all("reductor")
41
- end
42
- end