Sha256: 8a1c81c227a1371ade74fd88f49920577505bc6f64f11833727380e2647ff8fc

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

module Mirah
  module JVM
    module Types
      class ArrayType < Type
        attr_reader :component_type

        def initialize(component_type)
          @component_type = component_type
          if @component_type.jvm_type
            #@type = java.lang.reflect.Array.newInstance(@component_type.jvm_type, 0).class
          else
            # FIXME: THIS IS WRONG, but I don't know how to fix it
            #@type = @component_type
          end
          @name = component_type.name
          @type_system = component_type.type_system
          self.intrinsics
        end

        def array?
          true
        end

        def iterable?
          true
        end

        def inner_class?
          basic_type.inner_class?
        end

        def basic_type
          component_type.basic_type
        end

        def superclass
          object_type = @type_system.type(nil, 'java.lang.Object')
          if component_type.primitive?
            object_type
          elsif component_type.array?
            # fix covariance here for arrays of arrays
            # see #55
            object_type
          else
            if component_type == object_type
              object_type
            else
              component_type.superclass.array_type
            end
          end
        end

        def interfaces(include_parent=true)
          []
        end

        def meta
          @meta ||= ArrayMetaType.new(self)
        end
      end

      class ArrayMetaType < MetaType; end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mirah-0.1.0.pre-java lib/mirah/jvm/types/array_type.rb