Class: Kumi::Core::Analyzer::Passes::Toposorter
- Defined in:
- lib/kumi/core/analyzer/passes/toposorter.rb
Overview
RESPONSIBILITY: Compute topological ordering of declarations, blocking all cycles DEPENDENCIES: :dependencies from DependencyResolver, :declarations from NameIndexer PRODUCES: :evaluation_order - Array of declaration names in evaluation order INTERFACE: new(schema, state).run(errors)
Instance Method Summary collapse
Methods inherited from PassBase
#debug, #debug_enabled?, #initialize
Methods included from ErrorReporting
#inferred_location, #raise_localized_error, #raise_syntax_error, #raise_type_error, #report_enhanced_error, #report_error, #report_semantic_error, #report_syntax_error, #report_type_error
Constructor Details
This class inherits a constructor from Kumi::Core::Analyzer::Passes::PassBase
Instance Method Details
#run(errors) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/kumi/core/analyzer/passes/toposorter.rb', line 12 def run(errors) dependency_graph = get_state(:dependencies, required: false) || {} definitions = get_state(:declarations, required: false) || {} order = compute_topological_order(dependency_graph, definitions, errors) state.with(:evaluation_order, order) end |