Sha256: da50f4c8a1535a776c8ae4aa236faee6e33989ecc1a56b30f9fb4350a19f53ba

Contents?: true

Size: 816 Bytes

Versions: 5

Compression:

Stored size: 816 Bytes

Contents

require_relative "./node"

module Dentaku
  module AST
    class Access < Node
      attr_reader :structure, :index

      def self.arity
        2
      end

      def self.min_param_count
        arity
      end

      def self.max_param_count
        arity
      end

      def self.peek(*)
      end

      def initialize(data_structure, index)
        @structure = data_structure
        @index = index
      end

      def value(context = {})
        structure = @structure.value(context)
        index = @index.value(context)
        structure[index]
      end

      def dependencies(context = {})
        @structure.dependencies(context) + @index.dependencies(context)
      end

      def type
        nil
      end

      def accept(visitor)
        visitor.visit_access(self)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
dentaku-3.5.3 lib/dentaku/ast/access.rb
dentaku-3.5.2 lib/dentaku/ast/access.rb
dentaku_zevo-3.5.2 lib/dentaku/ast/access.rb
dentaku-3.5.1 lib/dentaku/ast/access.rb
dentaku-3.5.0 lib/dentaku/ast/access.rb