Class: Atomy::Code::Constant
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
- #bytecode(gen, mod) ⇒ Object
-
#initialize(name, parent = nil) ⇒ Constant
constructor
A new instance of Constant.
Constructor Details
#initialize(name, parent = nil) ⇒ Constant
Returns a new instance of Constant.
6 7 8 9 |
# File 'lib/atomy/code/constant.rb', line 6 def initialize(name, parent = nil) @name = name @parent = parent end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/atomy/code/constant.rb', line 4 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
4 5 6 |
# File 'lib/atomy/code/constant.rb', line 4 def parent @parent end |
Instance Method Details
#bytecode(gen, mod) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/atomy/code/constant.rb', line 11 def bytecode(gen, mod) if @parent mod.compile(gen, @parent) gen.find_const(@name) else gen.push_const(@name) end end |