Class: Rubber::C_Integer

Inherits:
Object
  • Object
show all
Includes:
RegisterChildren
Defined in:
lib/rubber/codegen/integer.rb

Instance Attribute Summary

Attributes included from RegisterChildren

#child_names, #source_file, #source_line

Instance Method Summary collapse

Methods included from RegisterChildren

#cname, #register_children

Instance Method Details

#code(io) ⇒ Object


5
6
# File 'lib/rubber/codegen/integer.rb', line 5

def code(io)
end

#declare(io) ⇒ Object


7
8
9
# File 'lib/rubber/codegen/integer.rb', line 7

def declare(io)
  #io.puts "static VALUE #{cname};"
end

#default_cnameObject


11
12
13
# File 'lib/rubber/codegen/integer.rb', line 11

def default_cname
  #"enum"+name
end

#doc_rd(io) ⇒ Object


14
15
16
17
# File 'lib/rubber/codegen/integer.rb', line 14

def doc_rd(io)
  depth = (fullname.gsub(/[^:]/,'').size >> 1)
  io.puts "=#{'=' * depth} #{fullname}"
end

#fullnameObject


21
22
23
24
25
26
27
# File 'lib/rubber/codegen/integer.rb', line 21

def fullname()
  if parent and parent.respond_to?(:fullname)
    "#{parent.fullname}::#{name}"
  else
    name
  end
end

#get_rootObject


18
# File 'lib/rubber/codegen/integer.rb', line 18

def get_root(); is_root? ? self : parent.get_root; end

#is_root?Boolean

Returns:

  • (Boolean)

18
19
20
# File 'lib/rubber/codegen/integer.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
# File 'lib/rubber/codegen/integer.rb', line 32

def register(io, already_defined=false)
  if parent
    io.puts "    rb_define_const(#{parent.cname}, #{name.inspect}, INT2NUM(#{number}));"
  else
    raise "No parent for string constant #{name}"
  end
end