ruby2c 1.0.0.9 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 48c5fa6b1d9d0ad39fe767091b224848115e582c4c5ede88513206abdcb826da
4
+ data.tar.gz: 698eddd47e434821160d610cf40ec9924eb0d7e70164cb94420e2eeff3ad86c9
5
+ SHA512:
6
+ metadata.gz: 5a8e9c38b1f1bd38e672400a540d5970fa44e0e369ad3549d0987333a7cae702b218a4d3b43a3de4d5dbb2c1dd30f71659e091080e45ef89982a4ff44428e5c6
7
+ data.tar.gz: 5475db786970e48b1b5fa1d61129a7c1147d7e29f5e3ed5d4716facdf43bace6f329899d6498ce15bc1d90b9fed05c5c79b1456ca293d4b4cb6121478648e55f
checksums.yaml.gz.sig ADDED
@@ -0,0 +1 @@
1
+ �<"3R������٤ x�X=d�Y~��6d3�%o�M��iM ���D�k���F�#�Jպ���E�B�s&��1�M 7�nU�=8����T�^u���RVZ����1W���8 "���f�B���-�@=}�?R2���8KD�J��ۓ*5��ն���d���0��g�It��Q��0�QR|uH�
data/History.txt CHANGED
@@ -1,3 +1,28 @@
1
+ === 1.1.1 / 2022-12-03
2
+
3
+ * 2 bug fixes:
4
+
5
+ * Added support for 3.0 parser
6
+ * Used ParseTreeTestCase#TEST_SUFFIX to make this always work when new versions added.
7
+
8
+ === 1.1.0 / 2019-09-24
9
+
10
+ * 4 minor enhancements:
11
+
12
+ * Pushed @@array_types and array_type? up to Sexp (in typed_sexp.rb).
13
+ * Pushed down @@array_types and #array_type? from Sexp to TypedSexp.
14
+ * Renamed Type to CType
15
+ * Renamed TypedSexp#sexp_type to c_type to resolve conflict/confusion w/ Sexp.
16
+
17
+ * 6 bug fixes:
18
+
19
+ * Fixed a test file randomization error (yay!) by requiring typed_sexp in rewriter.
20
+ * Fixed inspect/pretty_print to include line number for typed sexps, just like sexps.
21
+ * Fixed new ruby 2.5 warnings.
22
+ * Fixes for changes to sexp_processor, centered aroud maintaining c_type.
23
+ * Got working with ruby 2.5 parser.
24
+ * Removed obsolete attrset test
25
+
1
26
  === 1.0.0.9 / 2012-11-09
2
27
 
3
28
  * 1 bug fix:
@@ -29,12 +54,12 @@
29
54
 
30
55
  === 1.0.0.6 / 2009-06-23
31
56
 
32
- 1 major enhancement:
57
+ * 1 major enhancement:
33
58
 
34
59
  * Switched from ParseTree to ruby_parser for 1.9 compatibility. woo.
35
60
  * All translate/process methods are gone since we can't reflect at runtime.
36
61
 
37
- 43 minor enhancements:
62
+ * 43 minor enhancements:
38
63
 
39
64
  * Added IterRewriter for finding free variables in iter nodes.
40
65
  * Added dxstr.
@@ -99,104 +124,104 @@
99
124
 
100
125
  * 6 minor enhancements:
101
126
 
102
- * Split RubyToC to RubyToRubyC and RubyToAnsiC.
103
- * Extended Environment to be more flexible for various situations.
104
- * Removed propaganda (bloat) from release.
105
- * Gemified and reorganized things. Support still needs splitting up.
106
- * Flipped a lot of internal naming to use Unique.
107
- * Added ruby_to_c_show (like parse_tree_show).
127
+ * Split RubyToC to RubyToRubyC and RubyToAnsiC.
128
+ * Extended Environment to be more flexible for various situations.
129
+ * Removed propaganda (bloat) from release.
130
+ * Gemified and reorganized things. Support still needs splitting up.
131
+ * Flipped a lot of internal naming to use Unique.
132
+ * Added ruby_to_c_show (like parse_tree_show).
108
133
 
109
- * 4(ish) bug fixes:
134
+ * 4 bug fixes:
110
135
 
111
- * Use ivars instead of cvars so inheritance won't bugger the translator.
112
- * Corrected unsupported node lists in pipeline.
113
- * Fixed bugs for splat args, iters, optional args, method name map.
114
- * Fixed many other bugs.
136
+ * Use ivars instead of cvars so inheritance won't bugger the translator.
137
+ * Corrected unsupported node lists in pipeline.
138
+ * Fixed bugs for splat args, iters, optional args, method name map.
139
+ * Fixed many other bugs.
115
140
 
116
141
  === 1.0.0-beta-4 / 2005-07-13
117
142
 
118
143
  * 1 minor enhancements:
119
144
 
120
- * Added gemspec (hastily).
145
+ * Added gemspec (hastily).
121
146
 
122
147
  * 2 bug fixes:
123
148
 
124
- * Translates bool type to VALUE since we were using Qtrue/Qfalse.
125
- * Fixed rubygems for non-gem systems.
149
+ * Translates bool type to VALUE since we were using Qtrue/Qfalse.
150
+ * Fixed rubygems for non-gem systems.
126
151
 
127
152
  === 1.0.0-beta-3 / 2005-06-08
128
153
 
129
154
  * 16 minor enhancements:
130
155
 
131
- * Added ivar and iasgn support. Needs more work.
132
- * Added limited support for self.
133
- * Added pipeline tests for bools, call_arglist, call_attrasgn, fbody.
134
- * Added process_not to RubyToC.
135
- * Added support for float and symbol literals.
136
- * Added support for gasgn, cvasgn, const (class consts, not classes).
137
- * Improved error handling/reporting, esp in RubyToC.
138
- * In TypeChecker.boostrap, pre-registered all base classes.
139
- * Modified process_class test to include a class const.
140
- * Processing :class now adds class constants to the local var scope.
141
- * Processing :const checks both genv and env now.
142
- * Rearchitected all tests into a pipeline test class.
143
- * Rewrite attrasgn into regular calls.
144
- * Rewrite fbody into a regular defn.
145
- * Rewrote :array inside call to :arglist.
146
- * Rewrote :or nodes in process_case to correctly be binary.
156
+ * Added ivar and iasgn support. Needs more work.
157
+ * Added limited support for self.
158
+ * Added pipeline tests for bools, call_arglist, call_attrasgn, fbody.
159
+ * Added process_not to RubyToC.
160
+ * Added support for float and symbol literals.
161
+ * Added support for gasgn, cvasgn, const (class consts, not classes).
162
+ * Improved error handling/reporting, esp in RubyToC.
163
+ * In TypeChecker.boostrap, pre-registered all base classes.
164
+ * Modified process_class test to include a class const.
165
+ * Processing :class now adds class constants to the local var scope.
166
+ * Processing :const checks both genv and env now.
167
+ * Rearchitected all tests into a pipeline test class.
168
+ * Rewrite attrasgn into regular calls.
169
+ * Rewrite fbody into a regular defn.
170
+ * Rewrote :array inside call to :arglist.
171
+ * Rewrote :or nodes in process_case to correctly be binary.
147
172
 
148
173
  * 1 bug fix:
149
174
 
150
- * Fixed a bug where single line while bodies were missing a semicolon.
175
+ * Fixed a bug where single line while bodies were missing a semicolon.
151
176
 
152
177
  === 1.0.0-beta-2 / 2005-02-15
153
178
 
154
179
  * 1 minor enhancement:
155
180
 
156
- * Added post-condition while/until support and tests.
181
+ * Added post-condition while/until support and tests.
157
182
 
158
183
  * 4 bug fixes:
159
184
 
160
- * Fixed bug:1422: Escape newlines to prevent multi-line strings in C.
161
- * Fixed bug:1429: Arrays of strings are not being properly.
162
- * Fixed bug:1447/1448: Readme file's website and added ParseTree dependency.
185
+ * Fixed bug:1422: Escape newlines to prevent multi-line strings in C.
186
+ * Fixed bug:1429: Arrays of strings are not being properly.
187
+ * Fixed bug:1447/1448: Readme file's website and added ParseTree dependency.
163
188
 
164
189
  === 1.0.0-beta-1 / 2005-02-01
165
190
 
166
191
  * 1 major enhancements:
167
192
 
168
- * Hit 80% non-error conversion threshold for public beta release.
193
+ * Hit 80% non-error conversion threshold for public beta release.
169
194
 
170
195
  * 3 minor enhancements:
171
196
 
172
- * (Mostly) Filled out functionality in Rewriter and TypeChecker.
173
- * Flushed out what we don't do in RubyToC.
174
- * Wrote a ton of rdoc
197
+ * (Mostly) Filled out functionality in Rewriter and TypeChecker.
198
+ * Flushed out what we don't do in RubyToC.
199
+ * Wrote a ton of rdoc
175
200
 
176
201
  === 1.0.0-a2 / 2004-12-31
177
202
 
178
203
  * 7 major enhancements:
179
204
 
180
- * Alpha 2 released to private group for critique.
181
- * Refactored and split out ParseTree package.
182
- * Gemified dependency on ParseTree.
183
- * Added iter rewriting
184
- * Added post type inference rewriting specific to C library.
185
- * Massive increase to the base we can translate.
186
- * We have stabilized the architecture but still have a ways to go.
205
+ * Alpha 2 released to private group for critique.
206
+ * Refactored and split out ParseTree package.
207
+ * Gemified dependency on ParseTree.
208
+ * Added iter rewriting
209
+ * Added post type inference rewriting specific to C library.
210
+ * Massive increase to the base we can translate.
211
+ * We have stabilized the architecture but still have a ways to go.
187
212
 
188
213
  * 2 minor enhancements:
189
214
 
190
- * Added propaganda (presentations).
191
- * Much better test coverage, now with ZenTest compliant naming.
215
+ * Added propaganda (presentations).
216
+ * Much better test coverage, now with ZenTest compliant naming.
192
217
 
193
218
  * 2 bug fixes:
194
219
 
195
- * Gem-proofed makefile.
196
- * Tons of little fixes we didn't bother to track.
220
+ * Gem-proofed makefile.
221
+ * Tons of little fixes we didn't bother to track.
197
222
 
198
223
  === 1.0.0-a1 / 2004-09-24
199
224
 
200
225
  * 1 major enhancement:
201
226
 
202
- * Birthday! Alpha 1 released to private group for critique.
227
+ * Birthday! Alpha 1 released to private group for critique.
data/README.txt CHANGED
@@ -24,7 +24,7 @@ RubyToC has the following modules:
24
24
 
25
25
  * This is a preview release! BETA BETA BETA! Do NOT use this!
26
26
 
27
- == SYNOPSYS:
27
+ == SYNOPSIS:
28
28
 
29
29
  require 'ruby_parser'
30
30
  require 'ruby_to_ruby_c'
data/Rakefile CHANGED
@@ -19,4 +19,6 @@ Hoe.spec "ruby2c" do
19
19
  dependency "sexp_processor", "~> 4.1"
20
20
  end
21
21
 
22
+ ENV["MT_NO_EXPECTATIONS"] = "1"
23
+
22
24
  # vim: syntax=ruby
data/lib/crewriter.rb CHANGED
@@ -16,10 +16,10 @@ class CRewriter < SexpProcessor
16
16
  # generating the appropriate sexp for that rewriting.
17
17
 
18
18
  REWRITES = {
19
- [Type.str, :+, Type.str] => proc { |l,n,r|
20
- t(:call, nil, :strcat, r.unshift(r.shift, l), Type.str)
19
+ [CType.str, :+, CType.str] => proc { |l,n,r|
20
+ t(:call, nil, :strcat, r.unshift(r.shift, l), CType.str)
21
21
  },
22
- [Type.file, :puts, Type.str] => proc { |l,n,r|
22
+ [CType.file, :puts, CType.str] => proc { |l,n,r|
23
23
  t(:call, nil, :fputs, r.push(l))
24
24
  },
25
25
  }
@@ -35,6 +35,18 @@ class CRewriter < SexpProcessor
35
35
  @extra_methods = []
36
36
  end
37
37
 
38
+ # def rewrite exp
39
+ # result = super
40
+ # result.c_type ||= exp.c_type if Sexp === exp and exp.c_type
41
+ # result
42
+ # end
43
+
44
+ def process exp, _src = nil, _timeout = nil
45
+ result = super(exp)
46
+ result.c_type ||= exp.c_type if Sexp === exp and exp.c_type
47
+ result
48
+ end
49
+
38
50
  def free # REFACTOR: this is a violation of responsibility, should be in Env
39
51
  parent = @env.env[0..-2]
40
52
  bound_in_parent = parent.map { |h| h.keys }.flatten
@@ -57,14 +69,14 @@ class CRewriter < SexpProcessor
57
69
  name = exp.shift
58
70
  rhs = process exp.shift
59
71
 
60
- lhs_type = lhs.sexp_type rescue nil
72
+ lhs_type = lhs.c_type rescue nil
61
73
  type_signature = [lhs_type, name]
62
- type_signature += rhs[1..-1].map { |sexp| sexp.sexp_type } unless rhs.nil?
74
+ type_signature += rhs[1..-1].map { |sexp| sexp.c_type }.to_a unless rhs.nil?
63
75
 
64
76
  result = if REWRITES.has_key? type_signature then
65
77
  REWRITES[type_signature].call(lhs, name, rhs)
66
78
  else
67
- t(:call, lhs, name, rhs, exp.sexp_type)
79
+ t(:call, lhs, name, rhs, exp.c_type)
68
80
  end
69
81
 
70
82
  return result
@@ -83,7 +95,7 @@ class CRewriter < SexpProcessor
83
95
  @extra_methods.reverse_each do |defx| methods.unshift defx end
84
96
  @extra_methods.clear
85
97
 
86
- result = t(:class, klassname, superklassname, Type.zclass)
98
+ result = t(:class, klassname, superklassname, CType.zclass)
87
99
  result.push(*methods)
88
100
 
89
101
  return result
@@ -96,7 +108,7 @@ class CRewriter < SexpProcessor
96
108
  iter_method_name = Unique.next
97
109
 
98
110
  value_var_name = Unique.next
99
- value_var_type = Type.unknown
111
+ value_var_type = CType.unknown
100
112
 
101
113
  memo_var_name = Unique.next
102
114
 
@@ -111,8 +123,8 @@ class CRewriter < SexpProcessor
111
123
 
112
124
  var_names = var_names_in vars
113
125
 
114
- frees = t(:array, Type.void)
115
- statics = t(:array, Type.void)
126
+ frees = t(:array, CType.void)
127
+ statics = t(:array, CType.void)
116
128
  defx_body_block = t(:block)
117
129
 
118
130
  # set statics first so block vars can update statics
@@ -132,7 +144,7 @@ class CRewriter < SexpProcessor
132
144
  var_names.first.last)
133
145
 
134
146
  else # expand block args to masgn
135
- value_var_type = Type.value
147
+ value_var_type = CType.value
136
148
  dyn_vars = t(:array)
137
149
 
138
150
  var_names.each do |name, type|
@@ -141,29 +153,29 @@ class CRewriter < SexpProcessor
141
153
 
142
154
  defx_body_block << t(:masgn,
143
155
  dyn_vars,
144
- t(:to_ary, t(:lvar, value_var_name, Type.value)))
156
+ t(:to_ary, t(:lvar, value_var_name, CType.value)))
145
157
  end
146
158
 
147
159
  defx_body_block << body
148
160
 
149
161
  free_vars.each do |name, static_name, type|
150
162
  defx_body_block << t(:lasgn, static_name, t(:lvar, name, type), type)
151
- @extra_methods << t(:static, "static VALUE #{static_name};", Type.fucked)
163
+ @extra_methods << t(:static, "static VALUE #{static_name};", CType.fucked)
152
164
  end
153
165
 
154
- defx_body_block << t(:return, t(:nil, Type.value))
166
+ defx_body_block << t(:return, t(:nil, CType.value))
155
167
 
156
168
  defx = t(:defx,
157
169
  iter_method_name,
158
170
  t(:args,
159
171
  t(value_var_name, value_var_type),
160
- t(memo_var_name, Type.value)),
172
+ t(memo_var_name, CType.value)),
161
173
  t(:scope, defx_body_block),
162
- Type.void)
174
+ CType.void)
163
175
 
164
176
  @extra_methods << defx
165
177
 
166
- args = t(:args, frees, statics, Type.void)
178
+ args = t(:args, frees, statics, CType.void)
167
179
 
168
180
  return t(:iter, call, args, iter_method_name)
169
181
  end
@@ -172,27 +184,27 @@ class CRewriter < SexpProcessor
172
184
  name = exp.shift
173
185
  value = process(exp.shift)
174
186
 
175
- @env.add name, exp.sexp_type
187
+ @env.add name, exp.c_type
176
188
  @env.set_val name, true
177
189
 
178
- return t(:lasgn, name, value, exp.sexp_type)
190
+ return t(:lasgn, name, value, exp.c_type)
179
191
  end
180
192
 
181
193
  def process_lvar(exp)
182
194
  name = exp.shift
183
195
 
184
- @env.add name, Type.value
196
+ @env.add name, CType.value
185
197
  @env.lookup name rescue @env.set_val name, false
186
198
 
187
- return t(:lvar, name, exp.sexp_type)
199
+ return t(:lvar, name, exp.c_type)
188
200
  end
189
201
 
190
202
  def var_names_in(exp)
191
- return [[exp.last, exp.sexp_type]] if exp.length == 2 and not Sexp === exp.last
203
+ return [[exp.last, exp.c_type]] if exp.length == 2 and not Sexp === exp.last
192
204
 
193
205
  var_names = []
194
206
  exp.each_of_type :dasgn_curr do |sexp|
195
- var_names << [sexp.sexp_body.first, sexp.sexp_type]
207
+ var_names << [sexp.sexp_body.first, sexp.c_type]
196
208
  end
197
209
  return var_names
198
210
  end
@@ -10,8 +10,8 @@ class R2CEnvironment < RubyParserStuff::Environment
10
10
  def add(id, type, depth = 0)
11
11
  raise "Adding illegal identifier #{id.inspect}" unless
12
12
  Symbol === id
13
- raise ArgumentError, "type must be a valid Type instance" unless
14
- Type === type
13
+ raise ArgumentError, "type must be a valid Type instance: #{type.inspect}" unless
14
+ CType === type
15
15
 
16
16
  @env[depth][id.to_s.sub(/^\*/, '').intern][TYPE] = type
17
17
  end
@@ -31,7 +31,7 @@ class R2CEnvironment < RubyParserStuff::Environment
31
31
 
32
32
  def lookup(name)
33
33
  # HACK: if name is :self, cheat for now until we have full defn remapping
34
- return Type.fucked if name == :self
34
+ return CType.fucked if name == :self
35
35
 
36
36
  return self._get(name)[TYPE]
37
37
  end
data/lib/rewriter.rb CHANGED
@@ -1,9 +1,10 @@
1
-
2
1
  begin require 'rubygems'; rescue LoadError; end
3
2
  require 'sexp'
4
3
  require 'sexp_processor'
5
4
  require 'unique'
6
5
 
6
+ require 'typed_sexp' # ensure @@array_types is defined
7
+
7
8
  class Sexp
8
9
  # add arglist because we introduce the new array type in this file
9
10
  @@array_types << :arglist
@@ -17,6 +18,10 @@ end
17
18
  # what it does.
18
19
 
19
20
  class Rewriter < SexpProcessor
21
+ def process exp, _src = nil, _timeout = nil
22
+ super(exp)
23
+ end
24
+
20
25
  def rewrite_defn(exp)
21
26
  case exp.last[0]
22
27
  when :ivar then
@@ -31,4 +36,3 @@ class Rewriter < SexpProcessor
31
36
  exp
32
37
  end
33
38
  end
34
-
@@ -20,7 +20,7 @@ require 'r2cenvironment'
20
20
 
21
21
  class RubyToAnsiC < SexpProcessor
22
22
 
23
- VERSION = '1.0.0.9'
23
+ VERSION = '1.1.1'
24
24
 
25
25
  # TODO: remove me
26
26
  def no(exp) # :nodoc:
@@ -133,6 +133,10 @@ typedef char * str;
133
133
  @prototypes = []
134
134
  end
135
135
 
136
+ def process exp, _src = nil, _timeout = nil
137
+ super(exp)
138
+ end
139
+
136
140
  ##
137
141
  # Logical And. Nothing exciting here
138
142
 
@@ -160,7 +164,7 @@ typedef char * str;
160
164
  until exp.empty? do
161
165
  arg = exp.shift
162
166
  name = arg.first.to_s.sub(/^\*/, '').intern
163
- type = arg.sexp_type
167
+ type = arg.c_type
164
168
  @env.add name, type
165
169
  args << "#{self.class.c_type(type)} #{name}"
166
170
  end
@@ -212,10 +216,6 @@ typedef char * str;
212
216
  receiver = exp.shift
213
217
  name = exp.shift
214
218
 
215
- receiver_type = Type.unknown
216
- unless receiver.nil? then
217
- receiver_type = receiver.sexp_type
218
- end
219
219
  receiver = process receiver
220
220
 
221
221
  case name
@@ -304,7 +304,7 @@ typedef char * str;
304
304
 
305
305
  def process_dasgn_curr(exp) # TODO: audit against obfuscator
306
306
  var = exp.shift
307
- @env.add var.to_sym, exp.sexp_type
307
+ @env.add var.to_sym, exp.c_type
308
308
  return var.to_s
309
309
  end
310
310
 
@@ -323,7 +323,7 @@ typedef char * str;
323
323
  name = name.to_s.sub(/(.*)\?$/, 'is_\1').intern
324
324
  args = process exp.shift
325
325
  body = process exp.shift
326
- function_type = exp.sexp_type
326
+ function_type = exp.c_type
327
327
 
328
328
  ret_type = self.class.c_type function_type.list_type.return_type
329
329
 
@@ -351,7 +351,7 @@ typedef char * str;
351
351
 
352
352
  def process_dvar(exp)
353
353
  var = exp.shift
354
- @env.add var.to_sym, exp.sexp_type
354
+ @env.add var.to_sym, exp.c_type
355
355
  return var.to_s
356
356
  end
357
357
 
@@ -378,7 +378,7 @@ typedef char * str;
378
378
 
379
379
  def process_gvar(exp)
380
380
  name = exp.shift
381
- type = exp.sexp_type
381
+ type = exp.c_type
382
382
  case name
383
383
  when :$stderr then
384
384
  "stderr"
@@ -486,21 +486,21 @@ typedef char * str;
486
486
  arg_count = value.length - 1 if value.first == :array
487
487
  args = value
488
488
 
489
- exp_type = exp.sexp_type
489
+ exp_type = exp.c_type
490
490
  @env.add var.to_sym, exp_type
491
491
 
492
492
  if exp_type.list? then
493
493
  assert_type args, :array
494
494
 
495
- raise "array must be of one type" unless args.sexp_type == Type.homo
495
+ raise "array must be of one type" unless args.c_type == CType.homo
496
496
 
497
497
  # HACK: until we figure out properly what to do w/ zarray
498
498
  # before we know what its type is, we will default to long.
499
- array_type = args.sexp_types.empty? ? 'void *' : self.class.c_type(args.sexp_types.first)
499
+ array_type = args.c_types.empty? ? 'void *' : self.class.c_type(args.c_types.first)
500
500
 
501
501
  args.shift # :arglist
502
502
  # TODO: look into alloca
503
- out << "#{var} = (#{array_type}) malloc(sizeof(#{array_type}) * #{args.length});\n"
503
+ out << "#{var} = (#{array_type}) malloc(sizeof(#{array_type}) * #{arg_count});\n"
504
504
  args.each_with_index do |o,i|
505
505
  out << "#{var}[#{i}] = #{process o};\n"
506
506
  end
@@ -522,11 +522,11 @@ typedef char * str;
522
522
  # TODO what about floats and big numbers?
523
523
 
524
524
  value = exp.shift
525
- sexp_type = exp.sexp_type
526
- case sexp_type
527
- when Type.long, Type.float then
525
+ c_type = exp.c_type
526
+ case c_type
527
+ when CType.long, CType.float then
528
528
  return value.to_s
529
- when Type.symbol then
529
+ when CType.symbol then
530
530
  return value.to_s.inspect # HACK wrong! write test!
531
531
  else
532
532
  raise "Bug! no: Unknown literal #{value}:#{value.class}"
@@ -181,17 +181,17 @@ class RubyToRubyC < RubyToAnsiC
181
181
  arg_count = value.length - 1 if value.first == :array
182
182
  args = value
183
183
 
184
- exp_type = exp.sexp_type
184
+ exp_type = exp.c_type
185
185
  @env.add var.to_sym, exp_type
186
186
 
187
187
  if exp_type.list? then
188
188
  assert_type args, :array
189
189
 
190
- raise "array must be of one type" unless args.sexp_type == Type.homo
190
+ raise "array must be of one type" unless args.c_type == CType.homo
191
191
 
192
192
  args.shift # :arglist
193
193
  # REFACTOR: this (here down) is the only diff w/ super
194
- out << "#{var} = rb_ary_new2(#{args.length});\n"
194
+ out << "#{var} = rb_ary_new2(#{arg_count});\n"
195
195
  args.each_with_index do |o,i|
196
196
  out << "rb_ary_store(#{var}, #{i}, #{process o});\n"
197
197
  end
data/lib/type.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  require 'handle'
3
3
  require 'function_type'
4
4
 
5
- class Type
5
+ class CType
6
6
 
7
7
  # REFACTOR: nuke this
8
8
  KNOWN_TYPES = {
@@ -40,7 +40,7 @@ class Type
40
40
  # TODO: gross, maybe go back to the *args version from method_missing
41
41
  return_type = arg_types
42
42
  arg_types = lhs_type
43
- lhs_type = Type.unknown
43
+ lhs_type = CType.unknown
44
44
  end
45
45
 
46
46
  self.new FunctionType.new(lhs_type, arg_types, return_type)
@@ -52,7 +52,7 @@ class Type
52
52
 
53
53
  def self.method_missing(type, *args)
54
54
  raise "Unknown type Type.#{type} (#{type.inspect})" unless
55
- Type::KNOWN_TYPES.has_key?(type)
55
+ KNOWN_TYPES.has_key?(type)
56
56
 
57
57
  if type.to_s =~ /(.*)_list$/ then
58
58
  TYPES[type] = self.new($1.intern, true) unless TYPES.has_key?(type)