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
@@ -160,5 +160,33 @@ describe FastRuby, "fastruby" do
|
|
160
160
|
alias round original_round
|
161
161
|
end
|
162
162
|
end
|
163
|
-
end
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should allow replace methods when receiver types are not inferenced" do
|
166
|
+
fastruby "
|
167
|
+
class ::JU7
|
168
|
+
def foo
|
169
|
+
77
|
170
|
+
end
|
171
|
+
end
|
172
|
+
"
|
173
|
+
|
174
|
+
fastruby "
|
175
|
+
class ::JU8
|
176
|
+
def bar(l)
|
177
|
+
l.call.foo
|
178
|
+
end
|
179
|
+
end
|
180
|
+
"
|
181
|
+
|
182
|
+
::JU8.new.bar(lambda{::JU7.new}).should be == 77
|
183
|
+
|
184
|
+
class ::JU7
|
185
|
+
def foo
|
186
|
+
99
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
::JU8.new.bar(lambda{::JU7.new}).should be == 99
|
191
|
+
end
|
164
192
|
end
|
@@ -131,32 +131,63 @@ describe FastRuby, "fastruby" do
|
|
131
131
|
end
|
132
132
|
|
133
133
|
it "should allow replace CFUNC methods using ruby after they are called and compiled at runtime (through other method)" do
|
134
|
-
|
135
|
-
|
134
|
+
begin
|
135
|
+
|
136
|
+
class Fixnum
|
137
|
+
alias original_round round
|
138
|
+
end
|
139
|
+
|
140
|
+
fastruby "
|
141
|
+
class ::JU6
|
142
|
+
def foo(a)
|
143
|
+
a.round
|
144
|
+
end
|
145
|
+
end
|
146
|
+
"
|
147
|
+
|
148
|
+
::JU6.new.foo(0)
|
149
|
+
|
150
|
+
class Fixnum
|
151
|
+
def round
|
152
|
+
86
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
::JU6.new.foo(0).should be == 86
|
157
|
+
|
158
|
+
ensure
|
159
|
+
class Fixnum
|
160
|
+
alias round original_round
|
161
|
+
end
|
136
162
|
end
|
137
|
-
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should allow replace methods when receiver types are not inferenced" do
|
166
|
+
class ::JU7
|
167
|
+
def foo
|
168
|
+
77
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
138
172
|
fastruby "
|
139
|
-
class ::
|
140
|
-
def
|
141
|
-
|
173
|
+
class ::JU8
|
174
|
+
def bar(l)
|
175
|
+
l.call.foo
|
142
176
|
end
|
143
177
|
end
|
144
178
|
"
|
145
|
-
|
146
|
-
::
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
179
|
+
|
180
|
+
::JU8.new.bar(lambda{::JU7.new}).should be == 77
|
181
|
+
|
182
|
+
fastruby "
|
183
|
+
class ::JU7
|
184
|
+
def foo
|
185
|
+
99
|
151
186
|
end
|
152
|
-
|
187
|
+
|
188
|
+
end
|
189
|
+
"
|
153
190
|
|
154
|
-
::
|
155
|
-
|
156
|
-
ensure
|
157
|
-
class Fixnum
|
158
|
-
alias round original_round
|
159
|
-
end
|
160
|
-
|
161
|
-
end
|
191
|
+
::JU8.new.bar(lambda{::JU7.new}).should be == 99
|
192
|
+
end
|
162
193
|
end
|
data/spec/ruby/variable_spec.rb~
CHANGED
@@ -2,30 +2,53 @@ require "fastruby"
|
|
2
2
|
|
3
3
|
describe FastRuby, "fastruby" do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
eval("class #{classname}
|
13
|
-
fastruby #{code.inspect}
|
14
|
-
end")
|
15
|
-
eval(classname).new.foo.should be == defined_name
|
5
|
+
class ::U8
|
6
|
+
class U81
|
7
|
+
fastruby "
|
8
|
+
def foo
|
9
|
+
U8C
|
10
|
+
end
|
11
|
+
"
|
16
12
|
end
|
17
13
|
end
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
14
|
+
it "should read nested constants" do
|
15
|
+
::U8::U81::U8C = 11
|
16
|
+
::U8::U81.new.foo.should be == 11
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should read class variable" do
|
20
|
+
class ::U17
|
21
|
+
|
22
|
+
def self.foo(a)
|
23
|
+
@@a = a
|
24
|
+
end
|
25
|
+
|
26
|
+
fastruby "
|
27
|
+
def foo
|
28
|
+
@@a
|
29
|
+
end
|
30
|
+
"
|
31
|
+
end
|
32
|
+
::U17.foo(31)
|
33
|
+
::U17.new.foo.should be === 31
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should write class variable" do
|
37
|
+
class ::U18
|
38
|
+
|
39
|
+
def self.foo
|
40
|
+
@@a
|
41
|
+
end
|
42
|
+
|
43
|
+
fastruby "
|
44
|
+
def foo(a)
|
45
|
+
@@a = a
|
46
|
+
end
|
47
|
+
"
|
48
|
+
end
|
49
|
+
::U18.new.foo(71)
|
50
|
+
::U18.foo.should be == 71
|
51
|
+
end
|
52
|
+
|
30
53
|
|
31
54
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "fastruby"
|
2
|
+
|
3
|
+
describe FastRuby::FastRubySexp, "FastRubySexp" do
|
4
|
+
fastruby "
|
5
|
+
class STATICFLOW1
|
6
|
+
def foo(a)
|
7
|
+
_static do
|
8
|
+
if (FIX2INT(a))
|
9
|
+
INT2FIX(20)
|
10
|
+
else
|
11
|
+
INT2FIX(40)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
"
|
17
|
+
|
18
|
+
|
19
|
+
def self.test_static_if(*args)
|
20
|
+
args.each do |arg|
|
21
|
+
it "should should evaluate #{arg} as #{arg != 0} on static if" do
|
22
|
+
STATICFLOW1.new.foo(arg).should be == (arg == 0 ? 40 : 20)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
test_static_if false.__id__, true.__id__, nil.__id__, 10, 11
|
28
|
+
|
29
|
+
it "should allow static while" do
|
30
|
+
fastruby "
|
31
|
+
class STATICFLOW2
|
32
|
+
def foo(a)
|
33
|
+
ret = 0
|
34
|
+
_static do
|
35
|
+
while (FIX2INT(a) > 0)
|
36
|
+
a = INT2FIX(FIX2INT(a) - 1)
|
37
|
+
ret = INT2FIX(FIX2INT(ret) + 1)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
ret
|
41
|
+
end
|
42
|
+
end
|
43
|
+
"
|
44
|
+
|
45
|
+
STATICFLOW2.new.foo(7).should be == 7
|
46
|
+
STATICFLOW2.new.foo(0).should be == 0
|
47
|
+
end
|
48
|
+
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.
|
4
|
+
version: 0.0.22
|
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-
|
12
|
+
date: 2012-08-21 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: RubyInline
|
16
|
-
requirement: &
|
16
|
+
requirement: &79352690 !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: *
|
24
|
+
version_requirements: *79352690
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: ruby_parser
|
27
|
-
requirement: &
|
27
|
+
requirement: &79352440 !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: *
|
35
|
+
version_requirements: *79352440
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: define_method_handler
|
38
|
-
requirement: &
|
38
|
+
requirement: &79352200 !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: *
|
46
|
+
version_requirements: *79352200
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: method_source
|
49
|
-
requirement: &
|
49
|
+
requirement: &79351960 !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: *
|
57
|
+
version_requirements: *79351960
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: ruby2ruby
|
60
|
-
requirement: &
|
60
|
+
requirement: &79351730 !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: *
|
68
|
+
version_requirements: *79351730
|
69
69
|
description:
|
70
70
|
email: robertodarioseminara@gmail.com
|
71
71
|
executables: []
|
@@ -87,7 +87,9 @@ files:
|
|
87
87
|
- benchmarks/benchmark3.rb
|
88
88
|
- benchmarks/benchmark7.rb
|
89
89
|
- benchmarks/benchmark6.rb~
|
90
|
+
- benchmarks/benchmark8.rb
|
90
91
|
- benchmarks/benchmark4.rb
|
92
|
+
- benchmarks/benchmark8.rb~
|
91
93
|
- examples/example2.rb
|
92
94
|
- examples/example3.rb
|
93
95
|
- examples/example4.rb
|
@@ -104,14 +106,22 @@ files:
|
|
104
106
|
- lib/fastruby/builder/reductor.rb
|
105
107
|
- lib/fastruby/builder.rb~
|
106
108
|
- lib/fastruby/modules/translator/defn.rb
|
109
|
+
- lib/fastruby/modules/translator/block.rb~
|
110
|
+
- lib/fastruby/modules/translator/iter.rb~
|
111
|
+
- lib/fastruby/modules/translator/literal.rb~
|
112
|
+
- lib/fastruby/modules/translator/nonlocal.rb~
|
107
113
|
- lib/fastruby/modules/translator/iter.rb
|
108
114
|
- lib/fastruby/modules/translator/directive.rb
|
109
115
|
- lib/fastruby/modules/translator/exceptions.rb
|
110
116
|
- lib/fastruby/modules/translator/static.rb
|
117
|
+
- lib/fastruby/modules/translator/static.rb~
|
111
118
|
- lib/fastruby/modules/translator/method_group.rb
|
119
|
+
- lib/fastruby/modules/translator/exceptions.rb~
|
112
120
|
- lib/fastruby/modules/translator/nonlocal.rb
|
121
|
+
- lib/fastruby/modules/translator/variable.rb~
|
113
122
|
- lib/fastruby/modules/translator/variable.rb
|
114
123
|
- lib/fastruby/modules/translator/call.rb
|
124
|
+
- lib/fastruby/modules/translator/defn.rb~
|
115
125
|
- lib/fastruby/modules/translator/block.rb
|
116
126
|
- lib/fastruby/modules/translator/call.rb~
|
117
127
|
- lib/fastruby/modules/translator/flow.rb
|
@@ -122,6 +132,7 @@ files:
|
|
122
132
|
- lib/fastruby/modules/lvar_type/recursive.rb
|
123
133
|
- lib/fastruby/modules/lvar_type/defn.rb
|
124
134
|
- lib/fastruby/modules/lvar_type/lasgn.rb
|
135
|
+
- lib/fastruby/modules/lvar_type/lasgn.rb~
|
125
136
|
- lib/fastruby/modules/lvar_type/call.rb
|
126
137
|
- lib/fastruby/modules/inliner/recursive.rb
|
127
138
|
- lib/fastruby/modules/inliner/defn.rb
|
@@ -141,6 +152,7 @@ files:
|
|
141
152
|
- lib/fastruby/translator/scope_mode_helper.rb
|
142
153
|
- lib/fastruby/translator/translator.rb
|
143
154
|
- lib/fastruby/translator/translator_modules.rb
|
155
|
+
- lib/fastruby/translator/translator.rb~
|
144
156
|
- lib/fastruby/set_tree.rb
|
145
157
|
- lib/fastruby/object.rb~
|
146
158
|
- lib/fastruby/cache/cache.rb
|
@@ -168,16 +180,22 @@ files:
|
|
168
180
|
- spec/sexp2graph/exception_spec.rb
|
169
181
|
- spec/sexp2graph/flow_spec.rb
|
170
182
|
- spec/sexp2graph/logical_spec.rb
|
183
|
+
- spec/ruby/block/callcc_spec.rb~
|
171
184
|
- spec/ruby/block/retry_spec.rb
|
172
185
|
- spec/ruby/block/arguments_spec.rb
|
173
186
|
- spec/ruby/block/proc_spec.rb
|
174
187
|
- spec/ruby/block/break_spec.rb
|
188
|
+
- spec/ruby/block/break_spec.rb~
|
189
|
+
- spec/ruby/block/redo_spec.rb~
|
175
190
|
- spec/ruby/block/proc_as_block_spec.rb
|
191
|
+
- spec/ruby/block/proc_spec.rb~
|
176
192
|
- spec/ruby/block/next_spec.rb
|
177
193
|
- spec/ruby/block/lambda_spec.rb
|
178
194
|
- spec/ruby/block/lambda_spec.rb~
|
179
195
|
- spec/ruby/block/redo_spec.rb
|
180
196
|
- spec/ruby/block/block_as_proc_spec.rb
|
197
|
+
- spec/ruby/block/retry_spec.rb~
|
198
|
+
- spec/ruby/block/next_spec.rb~
|
181
199
|
- spec/ruby/block/proc_as_block_spec.rb~
|
182
200
|
- spec/ruby/block/callcc_spec.rb
|
183
201
|
- spec/ruby/base_spec.rb~
|
@@ -211,7 +229,9 @@ files:
|
|
211
229
|
- spec/ruby/defn/default_args_spec.rb
|
212
230
|
- spec/ruby/defn/single_function_spec.rb
|
213
231
|
- spec/ruby/defn/replacement_spec.rb
|
232
|
+
- spec/ruby/defn/multiple_args_spec.rb~
|
214
233
|
- spec/ruby/defn/replacement_spec.rb~
|
234
|
+
- spec/ruby/defn/default_args_spec.rb~
|
215
235
|
- spec/ruby/expression_spec.rb
|
216
236
|
- spec/ruby/control_spec.rb
|
217
237
|
- spec/sugar/base_spec.rb~
|
@@ -222,10 +242,12 @@ files:
|
|
222
242
|
- spec/graph/vertex_spec.rb
|
223
243
|
- spec/graph/path_spec.rb
|
224
244
|
- spec/graph/vertex_spec.rb~
|
245
|
+
- spec/fastruby_only/base_spec.rb~
|
225
246
|
- spec/fastruby_only/base_spec.rb
|
226
247
|
- spec/static/operator_spec.rb
|
227
248
|
- spec/static/base_spec.rb
|
228
249
|
- spec/static/flow_spec.rb
|
250
|
+
- spec/static/flow_spec.rb~
|
229
251
|
- spec/corelib/numeric/fixnum_spec.rb~
|
230
252
|
- spec/corelib/numeric/integer_spec.rb
|
231
253
|
- spec/corelib/numeric/integer_spec.rb~
|