eb6ea9a74f
Break some classes, rename stuff etc.
58 lines
949 B
Ruby
58 lines
949 B
Ruby
module Mutant
|
|
# Base class for code loaders
|
|
class Loader
|
|
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 [Subject] subject
|
|
#
|
|
# @return [undefined]
|
|
#
|
|
# @api private
|
|
#
|
|
def initialize(root, subject)
|
|
@root, @subject = root, subject
|
|
run
|
|
end
|
|
|
|
# Eval based loader
|
|
class Eval < self
|
|
|
|
private
|
|
|
|
# Run loader
|
|
#
|
|
# @return [undefined]
|
|
#
|
|
# @api private
|
|
#
|
|
def run
|
|
Kernel.eval(source, TOPLEVEL_BINDING, @subject.source_path, @subject.source_line)
|
|
end
|
|
|
|
# Return source
|
|
#
|
|
# @return [String]
|
|
#
|
|
# @api private
|
|
#
|
|
def source
|
|
ToSource.to_source(@root)
|
|
end
|
|
end
|
|
|
|
end
|
|
end
|