1/*
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25#ifndef SHARE_VM_CI_CIMETHODTYPE_HPP
26#define SHARE_VM_CI_CIMETHODTYPE_HPP
27
28#include "ci/ciInstance.hpp"
29#include "ci/ciUtilities.hpp"
30#include "classfile/javaClasses.hpp"
31
32// ciMethodType
33//
34// The class represents a java.lang.invoke.MethodType object.
35class ciMethodType : public ciInstance {
36private:
37  ciType* class_to_citype(oop klass_oop) const {
38    if (java_lang_Class::is_primitive(klass_oop)) {
39      BasicType bt = java_lang_Class::primitive_type(klass_oop);
40      return ciType::make(bt);
41    } else {
42      Klass* k = java_lang_Class::as_Klass(klass_oop);
43      return CURRENT_ENV->get_klass(k);
44    }
45  }
46
47public:
48  ciMethodType(instanceHandle h_i) : ciInstance(h_i) {}
49
50  // What kind of ciObject is this?
51  bool is_method_type() const { return true; }
52
53  ciType* rtype() const {
54    GUARDED_VM_ENTRY(
55      oop rtype = java_lang_invoke_MethodType::rtype(get_oop());
56      return class_to_citype(rtype);
57    )
58  }
59
60  int ptype_count() const {
61    GUARDED_VM_ENTRY(return java_lang_invoke_MethodType::ptype_count(get_oop());)
62  }
63
64  int ptype_slot_count() const {
65    GUARDED_VM_ENTRY(return java_lang_invoke_MethodType::ptype_slot_count(get_oop());)
66  }
67
68  ciType* ptype_at(int index) const {
69    GUARDED_VM_ENTRY(
70      oop ptype = java_lang_invoke_MethodType::ptype(get_oop(), index);
71      return class_to_citype(ptype);
72    )
73  }
74};
75
76#endif // SHARE_VM_CI_CIMETHODTYPE_HPP
77