lib/preval.rb in preval-0.3.0 vs lib/preval.rb in preval-0.4.0
- old
+ new
@@ -6,12 +6,21 @@
SyntaxError = Class.new(SyntaxError)
class << self
attr_reader :visitors
+ def enable_all!
+ Visitors::Arithmetic.enable!
+ Visitors::AttrAccessor.enable!
+ Visitors::Fasterer.enable!
+ Visitors::Loops.enable!
+ end
+
def process(source)
- visitors.inject(source) { |accum, visitor| visitor.process(accum) }
+ visitors.inject(Parser.parse(source)) do |current, visitor|
+ current.tap { |ast| ast.visit(visitor) }
+ end.to_source
end
end
@visitors = []
end
@@ -21,11 +30,12 @@
require 'preval/parser'
require 'preval/version'
require 'preval/visitor'
require 'preval/visitors/arithmetic'
+require 'preval/visitors/attr_accessor'
+require 'preval/visitors/fasterer'
require 'preval/visitors/loops'
-require 'preval/visitors/micro'
if defined?(Bootsnap)
load_iseq = RubyVM::InstructionSequence.method(:load_iseq)
if load_iseq.source_location[0].include?('/bootsnap/')