Class: Evilution::Integration::Loading::MutationApplier
- Inherits:
-
Object
- Object
- Evilution::Integration::Loading::MutationApplier
- Defined in:
- lib/evilution/integration/loading/mutation_applier.rb
Overview
Composes the load-time pipeline that applies a mutation’s new source to the running VM: syntax-validate -> pin top-level constants (beats Zeitwerk) -> clear AS::Concern state -> eval inside a redefinition-recovery wrapper. The eval target is mutation.eval_source, which Mutator::Base pre-populates with the neutralized form (non-idempotent class-body calls replaced with ‘nil`). The neutralization itself happens once at mutation-generation time rather than per-iter — SyntaxValidator still runs Prism per mutation, but the extra neutralizer parse stays out of the hot path. Falls back to mutation.mutated_source when no pre-eval transform was attached. RedefinitionRecovery stays as a safety net for cases the neutralizer’s allowlist heuristic misses. Returns nil on success or a failure-shaped hash on any error.
Instance Method Summary collapse
- #call(mutation) ⇒ Object
-
#initialize(syntax_validator: Evilution::Integration::Loading::SyntaxValidator.new, constant_pinner: Evilution::Integration::Loading::ConstantPinner.new, concern_state_cleaner: Evilution::Integration::Loading::ConcernStateCleaner.new, source_evaluator: Evilution::Integration::Loading::SourceEvaluator.new, redefinition_recovery: Evilution::Integration::Loading::RedefinitionRecovery.new) ⇒ MutationApplier
constructor
A new instance of MutationApplier.
Constructor Details
#initialize(syntax_validator: Evilution::Integration::Loading::SyntaxValidator.new, constant_pinner: Evilution::Integration::Loading::ConstantPinner.new, concern_state_cleaner: Evilution::Integration::Loading::ConcernStateCleaner.new, source_evaluator: Evilution::Integration::Loading::SourceEvaluator.new, redefinition_recovery: Evilution::Integration::Loading::RedefinitionRecovery.new) ⇒ MutationApplier
Returns a new instance of MutationApplier.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/evilution/integration/loading/mutation_applier.rb', line 23 def initialize(syntax_validator: Evilution::Integration::Loading::SyntaxValidator.new, constant_pinner: Evilution::Integration::Loading::ConstantPinner.new, concern_state_cleaner: Evilution::Integration::Loading::ConcernStateCleaner.new, source_evaluator: Evilution::Integration::Loading::SourceEvaluator.new, redefinition_recovery: Evilution::Integration::Loading::RedefinitionRecovery.new) @syntax_validator = syntax_validator @constant_pinner = constant_pinner @concern_state_cleaner = concern_state_cleaner @source_evaluator = source_evaluator @redefinition_recovery = redefinition_recovery end |
Instance Method Details
#call(mutation) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/evilution/integration/loading/mutation_applier.rb', line 35 def call(mutation) eval_target = resolve_eval_target(mutation) syntax_error = @syntax_validator.call(eval_target) return syntax_error if syntax_error apply(mutation, eval_target) nil rescue SyntaxError => e failure_result(e, "syntax error in mutated source: #{e.}") rescue ScriptError, StandardError => e failure_result(e, "#{e.class}: #{e.}") end |