2012-07-26 13:25:23 -04:00
|
|
|
module Mutant
|
|
|
|
# An abstract context where mutations can be appied to.
|
|
|
|
class Context
|
2012-08-02 19:28:15 -04:00
|
|
|
include Immutable, Abstract
|
2012-07-26 13:25:23 -04:00
|
|
|
|
2012-08-15 22:10:54 -04:00
|
|
|
# Return root ast node
|
2012-07-26 13:25:23 -04:00
|
|
|
#
|
|
|
|
# @param [Rubinius::AST::Node] node
|
|
|
|
#
|
|
|
|
# @return [Rubinis::AST::Script]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2012-08-02 19:28:15 -04:00
|
|
|
abstract_method :root
|
2012-08-14 06:26:56 -04:00
|
|
|
|
2012-08-15 22:10:54 -04:00
|
|
|
# Return source path
|
|
|
|
#
|
|
|
|
# @return [String]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2012-08-20 11:53:41 -04:00
|
|
|
def source_path
|
|
|
|
@source_path
|
|
|
|
end
|
2012-08-15 22:10:54 -04:00
|
|
|
|
2012-08-14 06:26:56 -04:00
|
|
|
private
|
|
|
|
|
|
|
|
# Initialize context
|
|
|
|
#
|
|
|
|
# @param [String] source_path
|
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def initialize(source_path)
|
|
|
|
@source_path = source_path
|
|
|
|
end
|
|
|
|
|
|
|
|
# Return script node
|
|
|
|
#
|
|
|
|
# @param [Rubinius::AST::Node] node
|
|
|
|
#
|
|
|
|
# @return [Rubinius::AST::Script]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def script(node)
|
|
|
|
Rubinius::AST::Script.new(node).tap do |script|
|
|
|
|
script.file = @source_path
|
|
|
|
end
|
|
|
|
end
|
2012-07-26 13:25:23 -04:00
|
|
|
end
|
|
|
|
end
|