Class: Rubber::C_Array
Instance Attribute Summary
#child_names, #source_file, #source_line
Instance Method Summary
collapse
#cname, #register_children
Instance Method Details
#code(io) ⇒ Object
5
6
|
# File 'lib/rubber/codegen/array.rb', line 5
def code(io)
end
|
#declare(io) ⇒ Object
7
8
9
|
# File 'lib/rubber/codegen/array.rb', line 7
def declare(io)
end
|
#default_cname ⇒ Object
11
12
13
|
# File 'lib/rubber/codegen/array.rb', line 11
def default_cname
end
|
#doc_rd(io) ⇒ Object
14
15
16
17
|
# File 'lib/rubber/codegen/array.rb', line 14
def doc_rd(io)
depth = (fullname.gsub(/[^:]/,'').size >> 1)
io.puts "=#{'=' * depth} #{fullname}"
end
|
#fullname ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/rubber/codegen/array.rb', line 21
def fullname()
if parent and parent.respond_to?(:fullname)
"#{parent.fullname}::#{name}"
else
name
end
end
|
#get_root ⇒ Object
18
|
# File 'lib/rubber/codegen/array.rb', line 18
def get_root(); is_root? ? self : parent.get_root; end
|
#is_root? ⇒ Boolean
18
19
20
|
# File 'lib/rubber/codegen/array.rb', line 18
def is_root?()
not parent.respond_to?(:fullname)
end
|
#register(io, already_defined = false) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/rubber/codegen/array.rb', line 32
def register(io, already_defined=false)
if parent
args = "#{@values.size}"
@values.each_with_index do |hash, index|
args << ", "
case hash.keys[0]
when :int
args << "INT2NUM(#{hash.values[0]})"
when :bool
args << "((#{hash.values[0]}) ? Qtrue : Qfalse)"
when :float
args << "FLOAT2NUM(#{hash.values[0]})"
when :string
args << "rb_str_new2(#{hash.values[0]})"
when :nil
args << "Qnil"
else
raise "Unknown key type for static array - #{hash.keys[0]}"
end
end
io.puts " rb_define_const(#{parent.cname}, #{name.inspect}, rb_ary_new3(#{args}));"
else
raise "No parent for string constant #{name}"
end
end
|