Sha256: c9a4ebd8839aa5925e37583913575f11cf92c89405ec4d5985d5beb60d4e1b73

Contents?: true

Size: 1.58 KB

Versions: 1

Compression:

Stored size: 1.58 KB

Contents

module Mutant
  module AST
    # Groups of node types
    module Types
      symbolset = ->(strings) { strings.map(&:to_sym).to_set.freeze }

      ASSIGNABLE_VARIABLES = symbolset.(%w[ivasgn lvasgn cvasgn gvasgn])

      INDEX_ASSIGN_OPERATOR = :[]=

      # Set of nodes that cannot be on the LHS of an assignment
      NOT_ASSIGNABLE         = symbolset.(%w[int float str dstr class module self nil])

      # 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
      #
      BLACKLIST = symbolset.(%w[not])

      # Nodes that are NOT generated by parser but used by mutant / unparser.
      EXTRA = symbolset.(%w[empty])

      # All node types mutant handles
      ALL = ((Parser::Meta::NODE_TYPES + EXTRA) - BLACKLIST).to_set.freeze
    end # Types
  end # AST
end # Mutant

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mutant-0.5.24 lib/mutant/ast/types.rb