Sha256: f02879af3272379965d0b1c7614b435e03e70b5a1d796fef4a6ef61fe18e943b

Contents?: true

Size: 1.46 KB

Versions: 14

Compression:

Stored size: 1.46 KB

Contents

# encoding: utf-8

module Mutant

  # Return a frozen set of symbols from string enumerable
  #
  # @param [Enumerable<String>]
  #
  # @return [Set<Symbol>]
  #
  # @api private
  #
  def self.symbolset(strings)
    strings.map(&:to_sym).to_set.freeze
  end
  private_class_method :symbolset

  # 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 %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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
mutant-0.5.10 lib/mutant/constants.rb
mutant-0.5.9 lib/mutant/constants.rb
mutant-0.5.8 lib/mutant/constants.rb
mutant-0.5.7 lib/mutant/constants.rb
mutant-0.5.6 lib/mutant/constants.rb
mutant-0.5.5 lib/mutant/constants.rb
mutant-0.5.4 lib/mutant/constants.rb
mutant-0.5.3 lib/mutant/constants.rb
mutant-0.5.2 lib/mutant/constants.rb
mutant-0.5.1 lib/mutant/constants.rb
mutant-0.5.0 lib/mutant/constants.rb
mutant-0.3.6 lib/mutant/constants.rb
mutant-0.3.5 lib/mutant/constants.rb
mutant-0.3.4 lib/mutant/constants.rb