aaef3816e8
::Mutant is a global registred object. That symbolset hack does not need to persist after loading the constants. The lvar used in constant.rb body will not leak outside lvar scope so is a better choice.
42 lines
1.3 KiB
Ruby
42 lines
1.3 KiB
Ruby
# encoding: utf-8
|
|
|
|
module Mutant
|
|
|
|
symbolset = ->(strings) { strings.map(&:to_sym).to_set.freeze }
|
|
|
|
# Set of nodes that cannot be on the LHS of an assignment
|
|
NOT_ASSIGNABLE = symbolset.(%w(int float str dstr class module self))
|
|
|
|
# Set of op-assign types
|
|
OP_ASSIGN = symbolset.call(%w(or_asgn and_asgn op_asgn))
|
|
# Set of node types that are not valid when emitted standalone
|
|
NOT_STANDALONE = symbolset.(%w( splat restarg block_pass))
|
|
INDEX_OPERATORS = symbolset.(%w([] []=))
|
|
UNARY_METHOD_OPERATORS = symbolset.(%w(~@ +@ -@ !))
|
|
|
|
# Operators ruby implementeds as methods
|
|
METHOD_OPERATORS = symbolset.(%w(
|
|
<=> === []= [] <= >= == !~ != =~ <<
|
|
>> ** * % / | ^ & < > + - ~@ +@ -@ !
|
|
))
|
|
|
|
BINARY_METHOD_OPERATORS = (
|
|
METHOD_OPERATORS - (INDEX_OPERATORS + UNARY_METHOD_OPERATORS)
|
|
).to_set.freeze
|
|
|
|
OPERATOR_METHODS = (
|
|
METHOD_OPERATORS + INDEX_OPERATORS + UNARY_METHOD_OPERATORS
|
|
).to_set.freeze
|
|
|
|
# Nodes that are NOT handled by mutant.
|
|
#
|
|
# not - 1.8 only, mutant does not support 1.8
|
|
#
|
|
NODE_BLACKLIST = symbolset.(%w(not))
|
|
|
|
# Nodes that are NOT generated by parser but used by mutant / unparser.
|
|
NODE_EXTRA = symbolset.(%w(empty))
|
|
|
|
NODE_TYPES = ((Parser::Meta::NODE_TYPES + NODE_EXTRA) - NODE_BLACKLIST).to_set.freeze
|
|
|
|
end # Mutant
|