Class: Apricot::LocalReference

Inherits:
Object
  • Object
show all
Defined in:
lib/apricot/variables.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(slot, depth = 0) ⇒ LocalReference

Returns a new instance of LocalReference.



5
6
7
8
# File 'lib/apricot/variables.rb', line 5

def initialize(slot, depth = 0)
  @slot = slot
  @depth = depth
end

Instance Attribute Details

#depthObject (readonly)

Returns the value of attribute depth.



3
4
5
# File 'lib/apricot/variables.rb', line 3

def depth
  @depth
end

#slotObject (readonly)

Returns the value of attribute slot.



3
4
5
# File 'lib/apricot/variables.rb', line 3

def slot
  @slot
end

Instance Method Details

#bytecode(g) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/apricot/variables.rb', line 10

def bytecode(g)
  if @depth == 0
    g.push_local @slot
  else
    g.push_local_depth @depth, @slot
  end
end