Module: Apricot::StorageScope

Included in:
OverloadScope, TopLevelScope
Defined in:
lib/apricot/scopes.rb

Overview

This is a scope with real local variable storage, i.e. it is part of a block of code like a fn or the top level program. Let scopes do not have storage and must ask for storage from one of these.

Instance Method Summary collapse

Instance Method Details

#local_countObject



20
21
22
# File 'lib/apricot/scopes.rb', line 20

def local_count
  variable_names.size
end

#local_namesObject



24
25
26
# File 'lib/apricot/scopes.rb', line 24

def local_names
  variable_names
end

#next_slotObject



16
17
18
# File 'lib/apricot/scopes.rb', line 16

def next_slot
  variable_names.size
end

#store_new_local(name) ⇒ Object



10
11
12
13
14
# File 'lib/apricot/scopes.rb', line 10

def store_new_local(name)
  slot = next_slot
  variable_names << name
  slot
end

#variable_namesObject



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

def variable_names
  @variable_names ||= []
end