class Yoda::Typing::Context

Attributes

caller_object[R]

@return [Store::Objects::Base]

env[R]

@return [Environment]

lexical_scope[R]

@return [LexicalScope]

registry[R]

@return [Store::Registry]

trace_store[R]

@return [TraceStore]

Public Class Methods

new(registry:, caller_object:, lexical_scope:, env: Environment.new, parent: nil, trace_store: TraceStore.new) click to toggle source

@param registry [Store::Registry] @param caller_object [Store::Objects::Base] represents who is the evaluator of the code. @param lexical_scope [Array<Path>] represents where the code presents.

# 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

Public Instance Methods

bind_trace(node, trace) click to toggle source

@param node [::AST::Node] @param trace [Trace::Base]

# 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) click to toggle source

@param registry [Store::Registry] @param caller_object [Store::Objects::Base] represents who is the evaluator of the code. @param lexical_scope [Array<Path>] represents where the code presents. @return [self]

# 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) click to toggle source

@param node [::AST::Node] @return [Trace::Base, nil]

# File lib/yoda/typing/context.rb, line 46
def find_trace(node)
  trace_store.find_trace(node)
end