Class: Yoda::Typing::Context
- Inherits:
-
Object
- Object
- Yoda::Typing::Context
- Defined in:
- lib/yoda/typing/context.rb
Defined Under Namespace
Classes: TraceStore
Instance Attribute Summary collapse
- #caller_object ⇒ Store::Objects::Base readonly
- #env ⇒ Environment readonly
- #lexical_scope ⇒ LexicalScope readonly
- #registry ⇒ Store::Registry readonly
- #trace_store ⇒ TraceStore readonly
Instance Method Summary collapse
- #bind_trace(node, trace) ⇒ Object
- #derive(caller_object: self.caller_object, lexical_scope: self.lexical_scope) ⇒ self
- #find_trace(node) ⇒ Trace::Base?
-
#initialize(registry:, caller_object:, lexical_scope:, env: Environment.new, parent: nil, trace_store: TraceStore.new) ⇒ Context
constructor
A new instance of Context.
Constructor Details
#initialize(registry:, caller_object:, lexical_scope:, env: Environment.new, parent: nil, trace_store: TraceStore.new) ⇒ Context
Returns a new instance of Context.
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/yoda/typing/context.rb', line 24 def initialize(registry:, caller_object:, lexical_scope:, env: Environment.new, parent: nil, trace_store: TraceStore.new) fail ArgumentError, registry unless registry.is_a?(Store::Registry) fail ArgumentError, caller_object unless caller_object.is_a?(Store::Objects::Base) fail ArgumentError, lexical_scope unless lexical_scope.is_a?(LexicalScope) @registry = registry @caller_object = caller_object @lexical_scope = lexical_scope @env = env @trace_store = trace_store end |
Instance Attribute Details
#caller_object ⇒ Store::Objects::Base (readonly)
10 11 12 |
# File 'lib/yoda/typing/context.rb', line 10 def caller_object @caller_object end |
#env ⇒ Environment (readonly)
16 17 18 |
# File 'lib/yoda/typing/context.rb', line 16 def env @env end |
#lexical_scope ⇒ LexicalScope (readonly)
13 14 15 |
# File 'lib/yoda/typing/context.rb', line 13 def lexical_scope @lexical_scope end |
#registry ⇒ Store::Registry (readonly)
7 8 9 |
# File 'lib/yoda/typing/context.rb', line 7 def registry @registry end |
#trace_store ⇒ TraceStore (readonly)
19 20 21 |
# File 'lib/yoda/typing/context.rb', line 19 def trace_store @trace_store end |
Instance Method Details
#bind_trace(node, trace) ⇒ Object
52 53 54 |
# File 'lib/yoda/typing/context.rb', line 52 def bind_trace(node, trace) trace_store.bind_trace(node, trace) end |
#derive(caller_object: self.caller_object, lexical_scope: self.lexical_scope) ⇒ self
40 41 42 |
# File 'lib/yoda/typing/context.rb', line 40 def derive(caller_object: self.caller_object, lexical_scope: self.lexical_scope) self.class.new(registry: registry, caller_object: caller_object, lexical_scope: lexical_scope, parent: self, trace_store: trace_store) end |
#find_trace(node) ⇒ Trace::Base?
46 47 48 |
# File 'lib/yoda/typing/context.rb', line 46 def find_trace(node) trace_store.find_trace(node) end |