free_mutant/lib/mutant/loader.rb

60 lines
945 B
Ruby
Raw Normal View History

module Mutant
# Base class for code loaders
class Loader
2012-11-26 05:30:00 -05:00
include AbstractType
extend MethodObject
private
# Run the loader
#
# @return [undefined]
#
# @api private
#
abstract_method :run
# Initialize and insert mutation into vm
#
# @param [Rubinius::AST::Script] root
# @param [String] file
# @param [Fixnum] line
#
# @return [undefined]
#
# @api private
#
def initialize(root, file, line)
@root, @file, @line = root, file, line
run
2012-08-19 23:01:26 -04:00
end
# Eval based loader
class Eval < self
2013-01-04 14:07:41 -05:00
private
# Run loader
#
# @return [undefined]
#
# @api private
#
def run
eval(source, TOPLEVEL_BINDING, @file, @line)
end
# Return source
#
# @return [String]
#
# @api private
#
def source
ToSource.to_source(@root)
end
end
end
end