Sha256: 4c5ff58b88e30ac89cad6a2b7b63fdda94f31058f60d768a669bbbe445f8f857

Contents?: true

Size: 984 Bytes

Versions: 2

Compression:

Stored size: 984 Bytes

Contents

# frozen_string_literal: true

class Code
  class Object
    class IdentifierList < List
      def call(**args)
        operator = args.fetch(:operator, nil)
        arguments = args.fetch(:arguments, [])
        context = args.fetch(:context)
        value = arguments.first&.value

        case operator.to_s
        when /=$/
          sig(args) { Object }

          context = context.lookup!(raw.first)

          context =
            raw[..-2].reduce(context) do |context, identifier|
              context.code_fetch(identifier)
            end

          context.code_set(
            raw.last,
            if operator == "="
              value
            else
              context.fetch(raw.last).call(
                **args,
                operator: operator[..-2],
                arguments: [Argument.new(value)]
              )
            end
          )

          context.code_fetch(raw.last)
        else
          super
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
code-ruby-0.13.1 lib/code/object/identifier_list.rb
code-ruby-0.13.0 lib/code/object/identifier_list.rb