0N/A/*
1879N/A * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#include "precompiled.hpp"
1879N/A#include "ci/ciArrayKlass.hpp"
1879N/A#include "ci/ciObjArrayKlass.hpp"
1879N/A#include "ci/ciTypeArrayKlass.hpp"
1879N/A#include "ci/ciUtilities.hpp"
0N/A
0N/A// ciArrayKlass
0N/A//
0N/A// This class represents a klassOop in the HotSpot virtual machine
0N/A// whose Klass part in an arrayKlass.
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciArrayKlass::ciArrayKlass
0N/A//
0N/A// Loaded array klass.
0N/AciArrayKlass::ciArrayKlass(KlassHandle h_k) : ciKlass(h_k) {
0N/A assert(get_Klass()->oop_is_array(), "wrong type");
0N/A _dimension = get_arrayKlass()->dimension();
0N/A}
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciArrayKlass::ciArrayKlass
0N/A//
0N/A// Unloaded array klass.
0N/AciArrayKlass::ciArrayKlass(ciSymbol* name, int dimension, ciKlass* klass)
0N/A : ciKlass(name, klass) {
0N/A _dimension = dimension;
0N/A}
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciArrayKlass::element_type
0N/A//
0N/A// What type is obtained when this array is indexed once?
0N/AciType* ciArrayKlass::element_type() {
0N/A if (is_type_array_klass()) {
0N/A return ciType::make(as_type_array_klass()->element_type());
0N/A } else {
0N/A return as_obj_array_klass()->element_klass()->as_klass();
0N/A }
0N/A}
0N/A
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciArrayKlass::base_element_type
0N/A//
0N/A// What type is obtained when this array is indexed as many times as possible?
0N/AciType* ciArrayKlass::base_element_type() {
0N/A if (is_type_array_klass()) {
0N/A return ciType::make(as_type_array_klass()->element_type());
0N/A } else {
0N/A ciKlass* ek = as_obj_array_klass()->base_element_klass();
0N/A if (ek->is_type_array_klass()) {
0N/A return ciType::make(ek->as_type_array_klass()->element_type());
0N/A }
0N/A return ek;
0N/A }
0N/A}
0N/A
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciArrayKlass::is_leaf_type
0N/Abool ciArrayKlass::is_leaf_type() {
0N/A if (is_type_array_klass()) {
0N/A return true;
0N/A } else {
0N/A return as_obj_array_klass()->base_element_klass()->is_leaf_type();
0N/A }
0N/A}
0N/A
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciArrayKlass::base_element_type
0N/A//
0N/A// What type is obtained when this array is indexed as many times as possible?
0N/AciArrayKlass* ciArrayKlass::make(ciType* element_type) {
0N/A if (element_type->is_primitive_type()) {
0N/A return ciTypeArrayKlass::make(element_type->basic_type());
0N/A } else {
0N/A return ciObjArrayKlass::make(element_type->as_klass());
0N/A }
0N/A}