ruby2c 1.0.0.9 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +2 -0
- data.tar.gz.sig +1 -1
- data/History.txt +71 -53
- data/README.txt +1 -1
- data/Rakefile +2 -0
- data/lib/crewriter.rb +35 -23
- data/lib/r2cenvironment.rb +3 -3
- data/lib/rewriter.rb +2 -2
- data/lib/ruby_to_ansi_c.rb +14 -18
- data/lib/ruby_to_ruby_c.rb +3 -3
- data/lib/type.rb +3 -3
- data/lib/type_checker.rb +97 -99
- data/lib/typed_sexp.rb +49 -25
- data/test/r2ctestcase.rb +321 -288
- data/test/test_crewriter.rb +127 -128
- data/test/test_extras.rb +4 -4
- data/test/test_function_table.rb +23 -23
- data/test/test_function_type.rb +39 -40
- data/test/test_handle.rb +2 -2
- data/test/test_r2cenvironment.rb +38 -38
- data/test/test_ruby_to_ansi_c.rb +58 -58
- data/test/test_ruby_to_ruby_c.rb +26 -26
- data/test/test_type.rb +38 -38
- data/test/test_type_checker.rb +165 -165
- data/test/test_typed_sexp.rb +62 -54
- metadata +97 -150
- metadata.gz.sig +0 -0
- data/.gemtest +0 -0
data/test/test_typed_sexp.rb
CHANGED
@@ -1,117 +1,125 @@
|
|
1
1
|
#!/usr/local/bin/ruby -w
|
2
2
|
|
3
3
|
require 'minitest/autorun' if $0 == __FILE__
|
4
|
-
require 'test_sexp'
|
4
|
+
require 'test_sexp' # from sexp_processor for TestSexp
|
5
5
|
require 'typed_sexp'
|
6
6
|
|
7
7
|
class TestTypedSexp < TestSexp
|
8
8
|
def setup
|
9
9
|
super
|
10
|
-
@sexp.
|
10
|
+
@sexp.c_type = CType.str
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
assert_equal
|
15
|
-
@sexp.
|
16
|
-
assert_equal
|
13
|
+
def test__set_c_type
|
14
|
+
assert_equal CType.str, @sexp.c_type
|
15
|
+
@sexp._set_c_type CType.bool
|
16
|
+
assert_equal CType.bool, @sexp.c_type
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_equals2_tsexp
|
20
20
|
sexp2 = s(1, 2, 3)
|
21
|
-
sexp3 = t(1, 2, 3,
|
21
|
+
sexp3 = t(1, 2, 3, CType.str)
|
22
22
|
assert_equal(@sexp, sexp3)
|
23
23
|
refute_equal(@sexp, sexp2)
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_equals_array_typed
|
27
27
|
# can't use assert_equals because it uses array as receiver
|
28
|
-
refute_equal(@sexp, [1, 2, 3,
|
28
|
+
refute_equal(@sexp, [1, 2, 3, CType.str],
|
29
29
|
"Sexp must not be equal to equivalent array")
|
30
30
|
# both directions just in case
|
31
|
-
refute_equal([1, 2, 3,
|
31
|
+
refute_equal([1, 2, 3, CType.str], @sexp,
|
32
32
|
"Sexp must not be equal to equivalent array")
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_equals_not_body_typed
|
36
36
|
sexp2 = t(1, 2, 5)
|
37
|
-
sexp2.
|
37
|
+
sexp2.c_type = CType.str
|
38
38
|
refute_equal(@sexp, sexp2)
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_equals_not_type
|
42
42
|
sexp2 = t(1, 2, 3)
|
43
|
-
sexp2.
|
43
|
+
sexp2.c_type = CType.long
|
44
44
|
refute_equal(@sexp, sexp2)
|
45
45
|
end
|
46
46
|
|
47
47
|
def test_equals_sexp
|
48
|
-
sexp2 = t(1, 2, 3,
|
48
|
+
sexp2 = t(1, 2, 3, CType.str)
|
49
49
|
assert_equal(@sexp, sexp2)
|
50
50
|
end
|
51
51
|
|
52
|
-
def
|
52
|
+
def test_equals_c_typed
|
53
53
|
sexp2 = t(1, 2, 3)
|
54
|
-
sexp2.
|
54
|
+
sexp2.c_type = CType.str
|
55
55
|
assert_equal(@sexp, sexp2)
|
56
56
|
end
|
57
57
|
|
58
58
|
def test_new_nested_typed
|
59
|
-
@sexp = TypedSexp.new(:lasgn, "var", TypedSexp.new(:str, "foo",
|
59
|
+
@sexp = TypedSexp.new(:lasgn, "var", TypedSexp.new(:str, "foo", CType.str), CType.str)
|
60
60
|
assert_equal('t(:lasgn, "var", t(:str, "foo", Type.str), Type.str)',
|
61
61
|
@sexp.inspect)
|
62
62
|
end
|
63
63
|
|
64
64
|
def test_pretty_print_typed
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
65
|
+
assert_pretty_print("t(Type.str)",
|
66
|
+
t(CType.str))
|
67
|
+
assert_pretty_print("t(:a, Type.long)",
|
68
|
+
t(:a, CType.long))
|
69
|
+
assert_pretty_print("t(:a, :b, Type.long)",
|
70
|
+
t(:a, :b, CType.long))
|
71
|
+
assert_pretty_print("t(:a, t(:b, Type.long), Type.str)",
|
72
|
+
t(:a, t(:b, CType.long), CType.str))
|
73
73
|
end
|
74
74
|
|
75
|
-
def
|
76
|
-
assert_equal(
|
75
|
+
def test_c_type
|
76
|
+
assert_equal(CType.str, @sexp.c_type)
|
77
77
|
end
|
78
78
|
|
79
|
-
def
|
80
|
-
assert_equal(
|
81
|
-
# FIX: we can't set
|
82
|
-
@sexp.
|
83
|
-
assert_equal(24, @sexp.
|
79
|
+
def test_c_type=
|
80
|
+
assert_equal(CType.str, @sexp.c_type)
|
81
|
+
# FIX: we can't set c_type a second time, please expand tests
|
82
|
+
@sexp._set_c_type 24
|
83
|
+
assert_equal(24, @sexp.c_type)
|
84
84
|
end
|
85
85
|
|
86
|
-
def
|
87
|
-
@sexp = t(:array, t(:lit, 1,
|
88
|
-
t(:str, "foo",
|
89
|
-
assert_equal(
|
90
|
-
assert_equal([
|
86
|
+
def test_c_type_array_hetero
|
87
|
+
@sexp = t(:array, t(:lit, 1, CType.long),
|
88
|
+
t(:str, "foo", CType.str))
|
89
|
+
assert_equal(CType.hetero, @sexp.c_type)
|
90
|
+
assert_equal([CType.long, CType.str], @sexp.c_types)
|
91
91
|
end
|
92
92
|
|
93
|
-
def
|
94
|
-
@sexp = t(:array, t(:lit, 1,
|
95
|
-
t(:lit, 2,
|
96
|
-
assert_equal(
|
97
|
-
assert_equal([
|
93
|
+
def test_c_type_array_homo
|
94
|
+
@sexp = t(:array, t(:lit, 1, CType.long),
|
95
|
+
t(:lit, 2, CType.long))
|
96
|
+
assert_equal(CType.homo, @sexp.c_type)
|
97
|
+
assert_equal([CType.long, CType.long], @sexp.c_types)
|
98
98
|
end
|
99
99
|
|
100
|
-
def
|
101
|
-
@sexp = t(:array, t(:lit, 1,
|
102
|
-
t(:array, t(:lit, 1,
|
103
|
-
assert_equal(
|
104
|
-
assert_equal([
|
100
|
+
def test_c_type_array_nested
|
101
|
+
@sexp = t(:array, t(:lit, 1, CType.long),
|
102
|
+
t(:array, t(:lit, 1, CType.long)))
|
103
|
+
assert_equal(CType.hetero, @sexp.c_type)
|
104
|
+
assert_equal([CType.long, CType.homo], @sexp.c_types)
|
105
105
|
end
|
106
106
|
|
107
|
-
def
|
107
|
+
def test_c_types
|
108
108
|
assert_raises(RuntimeError) do
|
109
|
-
@sexp.
|
109
|
+
@sexp.c_types
|
110
110
|
end
|
111
111
|
|
112
|
-
@sexp = t(:array, t(:lit, 1,
|
112
|
+
@sexp = t(:array, t(:lit, 1, CType.long), t(:str, "blah", CType.str))
|
113
113
|
|
114
|
-
assert_equal([
|
114
|
+
assert_equal([CType.long, CType.str], @sexp.c_types)
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_sexp_body # override from TestSexp
|
118
|
+
assert_equal t(2, 3, CType.str), @sexp.sexp_body
|
119
|
+
assert_equal s(), s(:x).sexp_body
|
120
|
+
assert_equal s(), s().sexp_body
|
121
|
+
|
122
|
+
assert_instance_of Sexp, s().sexp_body
|
115
123
|
end
|
116
124
|
|
117
125
|
def test_to_a
|
@@ -120,19 +128,19 @@ class TestTypedSexp < TestSexp
|
|
120
128
|
end
|
121
129
|
|
122
130
|
def test_to_a_typed
|
123
|
-
assert_equal([1, 2, 3,
|
131
|
+
assert_equal([1, 2, 3, CType.str], @sexp.to_a)
|
124
132
|
end
|
125
133
|
|
126
134
|
def test_to_s_typed
|
127
135
|
k = @sexp_class
|
128
136
|
n = k.name[0].chr.downcase
|
129
137
|
assert_equal("#{n}(Type.long)",
|
130
|
-
k.new(
|
138
|
+
k.new(CType.long).inspect)
|
131
139
|
assert_equal("#{n}(:a, Type.long)",
|
132
|
-
k.new(:a,
|
140
|
+
k.new(:a, CType.long).inspect)
|
133
141
|
assert_equal("#{n}(:a, :b, Type.long)",
|
134
|
-
k.new(:a, :b,
|
142
|
+
k.new(:a, :b, CType.long).inspect)
|
135
143
|
assert_equal("#{n}(:a, #{n}(:b, Type.long), Type.str)",
|
136
|
-
k.new(:a, k.new(:b,
|
144
|
+
k.new(:a, k.new(:b, CType.long), CType.str).inspect)
|
137
145
|
end
|
138
146
|
end
|
metadata
CHANGED
@@ -1,26 +1,19 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby2c
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 0
|
10
|
-
- 9
|
11
|
-
version: 1.0.0.9
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
12
5
|
platform: ruby
|
13
|
-
authors:
|
6
|
+
authors:
|
14
7
|
- Ryan Davis
|
15
8
|
- Eric Hodel
|
16
9
|
autorequire:
|
17
10
|
bindir: bin
|
18
|
-
cert_chain:
|
11
|
+
cert_chain:
|
19
12
|
- |
|
20
13
|
-----BEGIN CERTIFICATE-----
|
21
|
-
|
14
|
+
MIIDPjCCAiagAwIBAgIBAzANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
|
22
15
|
ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
|
23
|
-
|
16
|
+
GRYDY29tMB4XDTE4MTIwNDIxMzA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
39
32
|
-----END CERTIFICATE-----
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
- !ruby/object:Gem::Dependency
|
33
|
+
date: 2019-09-25 00:00:00.000000000 Z
|
34
|
+
dependencies:
|
35
|
+
- !ruby/object:Gem::Dependency
|
44
36
|
name: ruby_parser
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
- !ruby/object:Gem::Version
|
51
|
-
hash: 7
|
52
|
-
segments:
|
53
|
-
- 3
|
54
|
-
- 0
|
55
|
-
version: "3.0"
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '3.0'
|
56
42
|
type: :runtime
|
57
|
-
version_requirements: *id001
|
58
|
-
- !ruby/object:Gem::Dependency
|
59
|
-
name: sexp_processor
|
60
43
|
prerelease: false
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '3.0'
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: sexp_processor
|
51
|
+
requirement: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '4.1'
|
71
56
|
type: :runtime
|
72
|
-
version_requirements: *id002
|
73
|
-
- !ruby/object:Gem::Dependency
|
74
|
-
name: minitest
|
75
57
|
prerelease: false
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
segments:
|
83
|
-
- 4
|
84
|
-
- 2
|
85
|
-
version: "4.2"
|
86
|
-
type: :development
|
87
|
-
version_requirements: *id003
|
88
|
-
- !ruby/object:Gem::Dependency
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '4.1'
|
63
|
+
- !ruby/object:Gem::Dependency
|
89
64
|
name: rdoc
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
- 3
|
99
|
-
- 10
|
100
|
-
version: "3.10"
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '4.0'
|
70
|
+
- - "<"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '7'
|
101
73
|
type: :development
|
102
|
-
version_requirements: *id004
|
103
|
-
- !ruby/object:Gem::Dependency
|
104
|
-
name: hoe
|
105
74
|
prerelease: false
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
75
|
+
version_requirements: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '4.0'
|
80
|
+
- - "<"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '7'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: hoe
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.18'
|
116
90
|
type: :development
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
* RubyToRubyC - converts a ruby (subset) sexp to ruby interals C.
|
132
|
-
* RubyToAnsiC - converts a ruby (subset) sexp to ANSI C.
|
133
|
-
email:
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.18'
|
97
|
+
description: "ruby_to_c translates a static ruby subset to C. Hopefully it works.\n\n
|
98
|
+
\ NOTE ! NOTE ! NOTE ! NOTE ! NOTE ! NOTE ! NOTE ! NOTE ! NOTE\n \n THIS
|
99
|
+
IS BETA SOFTWARE!\n \n NOTE ! NOTE ! NOTE ! NOTE ! NOTE ! NOTE ! NOTE ! NOTE !
|
100
|
+
NOTE\n\nRubyToC has the following modules:\n\n* Rewriter - massages the sexp
|
101
|
+
into a more consistent form.\n* TypeChecker - type inferencer for the above sexps.\n*
|
102
|
+
RubyToRubyC - converts a ruby (subset) sexp to ruby interals C.\n* RubyToAnsiC
|
103
|
+
\ - converts a ruby (subset) sexp to ANSI C."
|
104
|
+
email:
|
134
105
|
- ryand-ruby@zenspider.com
|
135
106
|
- drbrain@segment7.net
|
136
107
|
executables: []
|
137
|
-
|
138
108
|
extensions: []
|
139
|
-
|
140
|
-
extra_rdoc_files:
|
109
|
+
extra_rdoc_files:
|
141
110
|
- History.txt
|
142
111
|
- Manifest.txt
|
143
112
|
- README.txt
|
144
|
-
files:
|
145
|
-
- .autotest
|
113
|
+
files:
|
114
|
+
- ".autotest"
|
146
115
|
- History.txt
|
147
116
|
- Manifest.txt
|
148
117
|
- README.txt
|
@@ -177,51 +146,29 @@ files:
|
|
177
146
|
- test/test_type.rb
|
178
147
|
- test/test_type_checker.rb
|
179
148
|
- test/test_typed_sexp.rb
|
180
|
-
- .gemtest
|
181
149
|
homepage: https://github.com/seattlerb/ruby_to_c
|
182
|
-
licenses:
|
183
|
-
|
150
|
+
licenses:
|
151
|
+
- MIT
|
152
|
+
metadata: {}
|
184
153
|
post_install_message:
|
185
|
-
rdoc_options:
|
186
|
-
- --main
|
154
|
+
rdoc_options:
|
155
|
+
- "--main"
|
187
156
|
- README.txt
|
188
|
-
require_paths:
|
157
|
+
require_paths:
|
189
158
|
- lib
|
190
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
191
|
-
|
192
|
-
requirements:
|
159
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
193
161
|
- - ">="
|
194
|
-
- !ruby/object:Gem::Version
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
version: "0"
|
199
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
200
|
-
none: false
|
201
|
-
requirements:
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
202
166
|
- - ">="
|
203
|
-
- !ruby/object:Gem::Version
|
204
|
-
|
205
|
-
segments:
|
206
|
-
- 0
|
207
|
-
version: "0"
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '0'
|
208
169
|
requirements: []
|
209
|
-
|
210
|
-
rubyforge_project: ruby2c
|
211
|
-
rubygems_version: 1.8.24
|
170
|
+
rubygems_version: 3.0.6
|
212
171
|
signing_key:
|
213
|
-
specification_version:
|
172
|
+
specification_version: 4
|
214
173
|
summary: ruby_to_c translates a static ruby subset to C
|
215
|
-
test_files:
|
216
|
-
- test/test_crewriter.rb
|
217
|
-
- test/test_extras.rb
|
218
|
-
- test/test_function_table.rb
|
219
|
-
- test/test_function_type.rb
|
220
|
-
- test/test_handle.rb
|
221
|
-
- test/test_r2cenvironment.rb
|
222
|
-
- test/test_rewriter.rb
|
223
|
-
- test/test_ruby_to_ansi_c.rb
|
224
|
-
- test/test_ruby_to_ruby_c.rb
|
225
|
-
- test/test_type.rb
|
226
|
-
- test/test_type_checker.rb
|
227
|
-
- test/test_typed_sexp.rb
|
174
|
+
test_files: []
|