Class: Context
- Inherits:
-
Object
- Object
- Context
- Defined in:
- lib/toylang/runtime/context.rb
Instance Attribute Summary collapse
-
#current_class ⇒ Object
readonly
Returns the value of attribute current_class.
-
#current_self ⇒ Object
readonly
Returns the value of attribute current_self.
-
#locals ⇒ Object
readonly
Returns the value of attribute locals.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, value) ⇒ Object
-
#initialize(current_self, current_class = current_self.runtime_class) ⇒ Context
constructor
A new instance of Context.
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_class ⇒ Object (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_self ⇒ Object (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 |
#locals ⇒ Object (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 |