Class: Yoda::Services::Evaluator
- Inherits:
-
Object
- Object
- Yoda::Services::Evaluator
- Extended by:
- Forwardable
- Defined in:
- lib/yoda/services/evaluator.rb
Instance Attribute Summary collapse
- #ast ⇒ AST::Vnode readonly
- #environment ⇒ Model::Environment readonly
- #inferencer ⇒ Typing::Inferencer readonly
Instance Method Summary collapse
- #evaluate ⇒ void
-
#initialize(ast:, environment:) ⇒ Evaluator
constructor
A new instance of Evaluator.
- #tracer ⇒ Typing::Inferencer::Tracer
Constructor Details
#initialize(ast:, environment:) ⇒ Evaluator
Returns a new instance of Evaluator.
21 22 23 24 25 26 |
# File 'lib/yoda/services/evaluator.rb', line 21 def initialize(ast:, environment:) @ast = ast @environment = environment @inferencer = Typing::Inferencer.create_for_root(environment: environment) @lock = Concurrent::ReadWriteLock.new end |
Instance Attribute Details
#ast ⇒ AST::Vnode (readonly)
9 10 11 |
# File 'lib/yoda/services/evaluator.rb', line 9 def ast @ast end |
#environment ⇒ Model::Environment (readonly)
12 13 14 |
# File 'lib/yoda/services/evaluator.rb', line 12 def environment @environment end |
#inferencer ⇒ Typing::Inferencer (readonly)
15 16 17 |
# File 'lib/yoda/services/evaluator.rb', line 15 def inferencer @inferencer end |
Instance Method Details
#evaluate ⇒ void
This method returns an undefined value.
29 30 31 |
# File 'lib/yoda/services/evaluator.rb', line 29 def evaluate tracer end |
#tracer ⇒ Typing::Inferencer::Tracer
34 35 36 37 38 39 40 41 |
# File 'lib/yoda/services/evaluator.rb', line 34 def tracer @lock.with_write_lock do @tracer ||= begin inferencer.infer(ast) inferencer.tracer end end end |