Class: Necropsy::FlowInterpreter
- Inherits:
-
Object
- Object
- Necropsy::FlowInterpreter
- Defined in:
- lib/necropsy/flow_interpreter.rb
Defined Under Namespace
Classes: ControlTransfer, StepBudgetExceeded
Constant Summary collapse
- DEFAULT_MAX_STEPS =
512- MAX_ATOMS =
8
Instance Method Summary collapse
- #analyze(body) ⇒ Object
-
#initialize(constant_resolver:, max_steps: DEFAULT_MAX_STEPS) ⇒ FlowInterpreter
constructor
A new instance of FlowInterpreter.
Constructor Details
#initialize(constant_resolver:, max_steps: DEFAULT_MAX_STEPS) ⇒ FlowInterpreter
Returns a new instance of FlowInterpreter.
12 13 14 15 |
# File 'lib/necropsy/flow_interpreter.rb', line 12 def initialize(constant_resolver:, max_steps: DEFAULT_MAX_STEPS) @constant_resolver = constant_resolver @max_steps = Integer(max_steps) end |
Instance Method Details
#analyze(body) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/necropsy/flow_interpreter.rb', line 17 def analyze(body) @locals = {} @receiver_facts = {}.compare_by_identity @value_facts = {}.compare_by_identity @issues = [] @return_facts = [] @steps = 0 value = evaluate(body) FlowResult.new( receiver_facts: @receiver_facts, value_facts: @value_facts, return_fact: return_fact(value), issues: @issues, steps: @steps ) rescue StepBudgetExceeded FlowResult.new( receiver_facts: @receiver_facts, value_facts: @value_facts, return_fact: ValueFact.unknown(:step_budget), issues: [*@issues, 'step_budget'], steps: @steps ) end |