Class: Context

Inherits:
Object
  • Object
show all
Defined in:
lib/toylang/runtime/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_self, current_class = current_self.runtime_class) ⇒ Context

Returns a new instance of Context.



6
7
8
9
10
11
# File 'lib/toylang/runtime/context.rb', line 6

def initialize(current_self, current_class = current_self.runtime_class)
  @locals = {}
  @constants = {}
  @current_self = current_self
  @current_class = current_class
end

Instance Attribute Details

#current_classObject (readonly)

Returns the value of attribute current_class.



4
5
6
# File 'lib/toylang/runtime/context.rb', line 4

def current_class
  @current_class
end

#current_selfObject (readonly)

Returns the value of attribute current_self.



4
5
6
# File 'lib/toylang/runtime/context.rb', line 4

def current_self
  @current_self
end

#localsObject (readonly)

Returns the value of attribute locals.



4
5
6
# File 'lib/toylang/runtime/context.rb', line 4

def locals
  @locals
end

Instance Method Details

#[](name) ⇒ Object



13
14
15
# File 'lib/toylang/runtime/context.rb', line 13

def [](name)
  @constants[name]
end

#[]=(name, value) ⇒ Object



17
18
19
# File 'lib/toylang/runtime/context.rb', line 17

def []=(name, value)
  @constants[name] = value
end