crystalizer 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. data/Changelog +27 -0
  2. data/README +79 -0
  3. data/Rakefile +24 -0
  4. data/TODO +14 -0
  5. data/VERSION +1 -0
  6. data/benchmarks/bench.rb +129 -0
  7. data/benchmarks/concretize_test.rb +26 -0
  8. data/benchmarks/extconf.rb +10 -0
  9. data/benchmarks/tak_rb.rb +7 -0
  10. data/benchmarks/tak_so.rb +7 -0
  11. data/benchmarks/tak_source.rb +16 -0
  12. data/bin/rb2cx +162 -0
  13. data/doc/eval2c.txt +246 -0
  14. data/doc/gen_html.rb +26 -0
  15. data/doc/html_template +10 -0
  16. data/doc/index.txt +169 -0
  17. data/doc/limitations.txt +529 -0
  18. data/doc/optimizations.txt +185 -0
  19. data/doc/rb2cx.txt +130 -0
  20. data/doc/style.css +27 -0
  21. data/lib/concretizer.rb +3 -0
  22. data/lib/ruby2cext/c_function.rb +617 -0
  23. data/lib/ruby2cext/common_node_comp.rb +1412 -0
  24. data/lib/ruby2cext/compiler.rb +311 -0
  25. data/lib/ruby2cext/concretize.rb +269 -0
  26. data/lib/ruby2cext/error.rb +15 -0
  27. data/lib/ruby2cext/eval2c.rb +126 -0
  28. data/lib/ruby2cext/parser.rb +36 -0
  29. data/lib/ruby2cext/plugin.rb +24 -0
  30. data/lib/ruby2cext/plugins/builtin_methods.rb +817 -0
  31. data/lib/ruby2cext/plugins/cache_call.rb +293 -0
  32. data/lib/ruby2cext/plugins/case_optimize.rb +102 -0
  33. data/lib/ruby2cext/plugins/const_cache.rb +36 -0
  34. data/lib/ruby2cext/plugins/direct_self_call.rb +70 -0
  35. data/lib/ruby2cext/plugins/inline_builtin.rb +797 -0
  36. data/lib/ruby2cext/plugins/inline_methods.rb +68 -0
  37. data/lib/ruby2cext/plugins/ivar_cache.rb +147 -0
  38. data/lib/ruby2cext/plugins/require_include.rb +69 -0
  39. data/lib/ruby2cext/plugins/util.rb +154 -0
  40. data/lib/ruby2cext/plugins/warnings.rb +121 -0
  41. data/lib/ruby2cext/scopes.rb +225 -0
  42. data/lib/ruby2cext/str_to_c_strlit.rb +12 -0
  43. data/lib/ruby2cext/tools.rb +80 -0
  44. data/lib/ruby2cext/version.rb +22 -0
  45. data/results +68 -0
  46. data/setup.rb +1585 -0
  47. data/stuff/builtin_methods.rb +69 -0
  48. data/stuff/builtin_methods_test.rb +37 -0
  49. data/test/bootstrap.rb +10 -0
  50. data/test/causes_crash_all_opts.rb +1165 -0
  51. data/test/eval2c/test_eval2c.rb +37 -0
  52. data/test/temp_17.rb +16 -0
  53. data/test/temp_18.rb +8 -0
  54. data/test/temp_19.rb +8 -0
  55. data/test/temp_2.rb +7 -0
  56. data/test/temp_20.rb +5 -0
  57. data/test/temp_21.rb +161 -0
  58. data/test/temp_22.rb +7 -0
  59. data/test/temp_23.rb +7 -0
  60. data/test/temp_24.rb +219 -0
  61. data/test/temp_25.rb +7 -0
  62. data/test/temp_26.rb +11 -0
  63. data/test/temp_27.rb +11 -0
  64. data/test/temp_28.rb +9 -0
  65. data/test/temp_29.rb +9 -0
  66. data/test/temp_3.rb +0 -0
  67. data/test/temp_30.rb +0 -0
  68. data/test/temp_31.rb +10 -0
  69. data/test/temp_32.rb +10 -0
  70. data/test/temp_33.rb +15 -0
  71. data/test/temp_34.rb +15 -0
  72. data/test/temp_35.rb +7 -0
  73. data/test/temp_36.rb +7 -0
  74. data/test/temp_37.rb +10 -0
  75. data/test/temp_38.rb +10 -0
  76. data/test/temp_39.rb +0 -0
  77. data/test/temp_4.rb +7 -0
  78. data/test/temp_40.rb +50 -0
  79. data/test/temp_41.rb +50 -0
  80. data/test/temp_42.rb +8 -0
  81. data/test/temp_43.rb +8 -0
  82. data/test/temp_44.rb +0 -0
  83. data/test/temp_48.rb +7 -0
  84. data/test/temp_49.rb +7 -0
  85. data/test/temp_5.rb +7 -0
  86. data/test/temp_59.rb +7 -0
  87. data/test/temp_6.rb +7 -0
  88. data/test/temp_60.rb +7 -0
  89. data/test/temp_68.rb +239 -0
  90. data/test/temp_7.rb +7 -0
  91. data/test/temp_70.rb +7 -0
  92. data/test/temp_71.rb +7 -0
  93. data/test/temp_72.rb +13 -0
  94. data/test/temp_73.rb +7 -0
  95. data/test/temp_74.rb +7 -0
  96. data/test/temp_76.rb +7 -0
  97. data/test/temp_77.rb +13 -0
  98. data/test/temp_79.rb +7 -0
  99. data/test/temp_8.rb +14 -0
  100. data/test/temp_81.rb +14 -0
  101. data/test/temp_83.rb +0 -0
  102. data/test/temp_84.rb +7 -0
  103. data/test/temp_85.rb +7 -0
  104. data/test/temp_86.rb +14 -0
  105. data/test/temp_87.rb +7 -0
  106. data/test/temp_88.rb +7 -0
  107. data/test/temp_89.rb +7 -0
  108. data/test/temp_9.rb +14 -0
  109. data/test/temp_90.rb +0 -0
  110. data/test/temp_91.rb +7 -0
  111. data/test/temp_92.rb +7 -0
  112. data/test/temp_93.rb +7 -0
  113. data/test/temp_94.rb +7 -0
  114. data/test/temp_95.rb +7 -0
  115. data/test/temp_96.rb +0 -0
  116. data/test/temp_97.rb +0 -0
  117. data/test/temp_98.rb +7 -0
  118. data/test/temp_99.rb +7 -0
  119. data/test/test_concretize.rb +132 -0
  120. data/test/test_concretize_all.rb +15 -0
  121. data/test/test_crystalize_block.rb +73 -0
  122. data/test/test_files/test.rb +615 -0
  123. data/test/test_files/vmode_test.rb +73 -0
  124. data/test/test_files/warn_test.rb +35 -0
  125. data/test/test_syntax.rb +25 -0
  126. metadata +268 -0
@@ -0,0 +1,73 @@
1
+ def a; end
2
+ public
3
+ def b; end
4
+ private
5
+ def c; end
6
+ protected rescue puts("failed OK")
7
+ def d; end
8
+ module_function rescue puts("failed OK")
9
+ def e; end
10
+
11
+ module A
12
+ def a; end
13
+ public
14
+ def b; end
15
+ private
16
+ def c; end
17
+ protected
18
+ def d; end
19
+ module_function
20
+ def e; end
21
+ end
22
+
23
+ class B
24
+ def a; end
25
+ public
26
+ def b; end
27
+ private
28
+ def c; end
29
+ protected
30
+ def d; end
31
+ module_function rescue puts("failed OK")
32
+ def e; end
33
+ end
34
+
35
+ class << "xxx"
36
+ def a; end
37
+ public
38
+ def b; end
39
+ private
40
+ def c; end
41
+ protected
42
+ def d; end
43
+ module_function rescue puts("failed OK")
44
+ def e; end
45
+ end
46
+
47
+ class C
48
+ def foo
49
+ def a; end
50
+ public rescue puts("failed OK")
51
+ def b; end
52
+ private rescue puts("failed OK")
53
+ def c; end
54
+ protected rescue puts("failed OK")
55
+ def d; end
56
+ module_function rescue puts("failed OK")
57
+ def e; end
58
+ end
59
+ end
60
+
61
+ C.new.foo
62
+
63
+ Module.new.class_eval {
64
+ def a; end
65
+ public
66
+ def b; end
67
+ private
68
+ def c; end
69
+ protected
70
+ def d; end
71
+ module_function
72
+ def e; end
73
+ }
@@ -0,0 +1,35 @@
1
+ eval("1")
2
+ method(:eval).arity
3
+ class A
4
+ define_method(:evxx, method(:eval))
5
+ attr :a1
6
+ attr_reader :a2, :a3
7
+ attr_writer :a4, :a5
8
+ attr_accessor :a7
9
+ end
10
+ def foo
11
+ local_variables +
12
+ [binding]
13
+ end
14
+
15
+ class A
16
+ p=proc{}
17
+ instance_eval(&p)
18
+ module_eval(&p)
19
+ class_eval(&p)
20
+ define_method(:xx, &p)
21
+ instance_eval("1")
22
+ module_eval("1")
23
+ class_eval("1")
24
+ define_method(:yy) {}
25
+ end
26
+
27
+ callcc(&proc{})
28
+ callcc { |cc| cc }
29
+
30
+ # no warnings below
31
+ class A
32
+ instance_eval { 1 }
33
+ module_eval { 1 }
34
+ class_eval { 1 }
35
+ end
@@ -0,0 +1,25 @@
1
+ # just runs the compiler against some sample files in the test_files directory
2
+
3
+ require File.dirname(__FILE__) + '/bootstrap'
4
+ include Ruby2CExtension
5
+
6
+
7
+ dir = File.dirname(__FILE__)
8
+ Dir.glob(dir + '/test_files/*.{c,so,o}').each{|f| File.delete f} # cleanup
9
+
10
+ logger = Logger.new STDOUT
11
+
12
+ for file_name in Dir[dir + '/test_files/*.rb']
13
+ # TODO grab the normal ruby output, then grab the ruby2c output :)
14
+ logger = Logger.new STDOUT
15
+ out = Compiler.compile_file(file_name, plugins = {},
16
+ include_paths = [], only_c = true, logger)
17
+ raise unless out
18
+ end
19
+
20
+ Compiler.compile_file(dir + '/test_files/test.rb', plugins = {},
21
+ include_paths = [], only_c = false, logger)
22
+ require dir + '/test_files/test.so'
23
+ raise "non worky" unless defined?(AliasTest) # should have loaded it in
24
+
25
+ puts 'success'
metadata ADDED
@@ -0,0 +1,268 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: crystalizer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.2
5
+ platform: ruby
6
+ authors:
7
+ - Dominik Bathon, rogerdpack
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-10 00:00:00 -07:00
13
+ default_executable: rb2cx
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rubynode
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.1.1
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: sane
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: event_hook
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: backports
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: ruby2ruby
57
+ type: :runtime
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
65
+ - !ruby/object:Gem::Dependency
66
+ name: ParseTree
67
+ type: :runtime
68
+ version_requirement:
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: "0"
74
+ version:
75
+ - !ruby/object:Gem::Dependency
76
+ name: assert2
77
+ type: :development
78
+ version_requirement:
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: "0"
84
+ version:
85
+ - !ruby/object:Gem::Dependency
86
+ name: backtracer
87
+ type: :development
88
+ version_requirement:
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: "0"
94
+ version:
95
+ description:
96
+ email: dbatml@gmx.de
97
+ executables:
98
+ - rb2cx
99
+ extensions: []
100
+
101
+ extra_rdoc_files:
102
+ - Changelog
103
+ - README
104
+ files:
105
+ - Changelog
106
+ - README
107
+ - Rakefile
108
+ - TODO
109
+ - VERSION
110
+ - benchmarks/bench.rb
111
+ - benchmarks/concretize_test.rb
112
+ - benchmarks/extconf.rb
113
+ - benchmarks/tak_rb.rb
114
+ - benchmarks/tak_so.rb
115
+ - benchmarks/tak_source.rb
116
+ - bin/rb2cx
117
+ - doc/eval2c.txt
118
+ - doc/gen_html.rb
119
+ - doc/html_template
120
+ - doc/index.txt
121
+ - doc/limitations.txt
122
+ - doc/optimizations.txt
123
+ - doc/rb2cx.txt
124
+ - doc/style.css
125
+ - lib/concretizer.rb
126
+ - lib/ruby2cext/c_function.rb
127
+ - lib/ruby2cext/common_node_comp.rb
128
+ - lib/ruby2cext/compiler.rb
129
+ - lib/ruby2cext/concretize.rb
130
+ - lib/ruby2cext/error.rb
131
+ - lib/ruby2cext/eval2c.rb
132
+ - lib/ruby2cext/parser.rb
133
+ - lib/ruby2cext/plugin.rb
134
+ - lib/ruby2cext/plugins/builtin_methods.rb
135
+ - lib/ruby2cext/plugins/cache_call.rb
136
+ - lib/ruby2cext/plugins/case_optimize.rb
137
+ - lib/ruby2cext/plugins/const_cache.rb
138
+ - lib/ruby2cext/plugins/direct_self_call.rb
139
+ - lib/ruby2cext/plugins/inline_builtin.rb
140
+ - lib/ruby2cext/plugins/inline_methods.rb
141
+ - lib/ruby2cext/plugins/ivar_cache.rb
142
+ - lib/ruby2cext/plugins/require_include.rb
143
+ - lib/ruby2cext/plugins/util.rb
144
+ - lib/ruby2cext/plugins/warnings.rb
145
+ - lib/ruby2cext/scopes.rb
146
+ - lib/ruby2cext/str_to_c_strlit.rb
147
+ - lib/ruby2cext/tools.rb
148
+ - lib/ruby2cext/version.rb
149
+ - results
150
+ - setup.rb
151
+ - stuff/builtin_methods.rb
152
+ - stuff/builtin_methods_test.rb
153
+ - test/bootstrap.rb
154
+ - test/causes_crash_all_opts.rb
155
+ - test/eval2c/test_eval2c.rb
156
+ - test/test_concretize.rb
157
+ - test/test_concretize_all.rb
158
+ - test/test_crystalize_block.rb
159
+ - test/test_files/test.rb
160
+ - test/test_files/vmode_test.rb
161
+ - test/test_files/warn_test.rb
162
+ - test/test_syntax.rb
163
+ has_rdoc: true
164
+ homepage:
165
+ licenses: []
166
+
167
+ post_install_message:
168
+ rdoc_options:
169
+ - --charset=UTF-8
170
+ require_paths:
171
+ - lib
172
+ required_ruby_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: "0"
177
+ version:
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: "0"
183
+ version:
184
+ requirements: []
185
+
186
+ rubyforge_project:
187
+ rubygems_version: 1.3.5
188
+ signing_key:
189
+ specification_version: 3
190
+ summary: Ruby2CExtension is a Ruby to C extension translator/compiler/concretizer.
191
+ test_files:
192
+ - test/bootstrap.rb
193
+ - test/causes_crash_all_opts.rb
194
+ - test/eval2c/test_eval2c.rb
195
+ - test/temp_17.rb
196
+ - test/temp_18.rb
197
+ - test/temp_19.rb
198
+ - test/temp_2.rb
199
+ - test/temp_20.rb
200
+ - test/temp_21.rb
201
+ - test/temp_22.rb
202
+ - test/temp_23.rb
203
+ - test/temp_24.rb
204
+ - test/temp_25.rb
205
+ - test/temp_26.rb
206
+ - test/temp_27.rb
207
+ - test/temp_28.rb
208
+ - test/temp_29.rb
209
+ - test/temp_3.rb
210
+ - test/temp_30.rb
211
+ - test/temp_31.rb
212
+ - test/temp_32.rb
213
+ - test/temp_33.rb
214
+ - test/temp_34.rb
215
+ - test/temp_35.rb
216
+ - test/temp_36.rb
217
+ - test/temp_37.rb
218
+ - test/temp_38.rb
219
+ - test/temp_39.rb
220
+ - test/temp_4.rb
221
+ - test/temp_40.rb
222
+ - test/temp_41.rb
223
+ - test/temp_42.rb
224
+ - test/temp_43.rb
225
+ - test/temp_44.rb
226
+ - test/temp_48.rb
227
+ - test/temp_49.rb
228
+ - test/temp_5.rb
229
+ - test/temp_59.rb
230
+ - test/temp_6.rb
231
+ - test/temp_60.rb
232
+ - test/temp_68.rb
233
+ - test/temp_7.rb
234
+ - test/temp_70.rb
235
+ - test/temp_71.rb
236
+ - test/temp_72.rb
237
+ - test/temp_73.rb
238
+ - test/temp_74.rb
239
+ - test/temp_76.rb
240
+ - test/temp_77.rb
241
+ - test/temp_79.rb
242
+ - test/temp_8.rb
243
+ - test/temp_81.rb
244
+ - test/temp_83.rb
245
+ - test/temp_84.rb
246
+ - test/temp_85.rb
247
+ - test/temp_86.rb
248
+ - test/temp_87.rb
249
+ - test/temp_88.rb
250
+ - test/temp_89.rb
251
+ - test/temp_9.rb
252
+ - test/temp_90.rb
253
+ - test/temp_91.rb
254
+ - test/temp_92.rb
255
+ - test/temp_93.rb
256
+ - test/temp_94.rb
257
+ - test/temp_95.rb
258
+ - test/temp_96.rb
259
+ - test/temp_97.rb
260
+ - test/temp_98.rb
261
+ - test/temp_99.rb
262
+ - test/test_concretize.rb
263
+ - test/test_concretize_all.rb
264
+ - test/test_crystalize_block.rb
265
+ - test/test_files/test.rb
266
+ - test/test_files/vmode_test.rb
267
+ - test/test_files/warn_test.rb
268
+ - test/test_syntax.rb