0N/A/*
2273N/A * Copyright (c) 1997, 2011, 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#ifndef SHARE_VM_RUNTIME_FIELDTYPE_HPP
1879N/A#define SHARE_VM_RUNTIME_FIELDTYPE_HPP
1879N/A
1879N/A#include "memory/allocation.hpp"
2062N/A#include "oops/symbol.hpp"
1879N/A
0N/A// Note: FieldType should be based on the SignatureIterator (or vice versa).
0N/A// In any case, this structure should be re-thought at some point.
0N/A
0N/A// A FieldType is used to determine the type of a field from a signature string.
0N/A
2062N/A// Information returned by get_array_info, which is scoped to decrement
2062N/A// reference count if a Symbol is created in the case of T_OBJECT
2062N/Aclass FieldArrayInfo : public StackObj {
2062N/A friend class FieldType; // field type can set these fields.
2062N/A int _dimension;
2062N/A Symbol* _object_key;
2062N/A public:
2062N/A int dimension() { return _dimension; }
2062N/A Symbol* object_key() { return _object_key; }
2062N/A // basic constructor
2062N/A FieldArrayInfo() : _dimension(0), _object_key(NULL) {}
2062N/A // destructor decrements object key's refcount if created
2062N/A ~FieldArrayInfo() { if (_object_key != NULL) _object_key->decrement_refcount(); }
2062N/A};
2062N/A
2062N/A
0N/Aclass FieldType: public AllStatic {
0N/A private:
2062N/A static void skip_optional_size(Symbol* signature, int* index);
2062N/A static bool is_valid_array_signature(Symbol* signature);
0N/A public:
0N/A
0N/A // Return basic type
2062N/A static BasicType basic_type(Symbol* signature);
0N/A
0N/A // Testing
2062N/A static bool is_array(Symbol* signature) { return signature->utf8_length() > 1 && signature->byte_at(0) == '[' && is_valid_array_signature(signature); }
0N/A
2062N/A static bool is_obj(Symbol* signature) {
0N/A int sig_length = signature->utf8_length();
0N/A // Must start with 'L' and end with ';'
0N/A return (sig_length >= 2 &&
0N/A (signature->byte_at(0) == 'L') &&
0N/A (signature->byte_at(sig_length - 1) == ';'));
0N/A }
0N/A
0N/A // Parse field and extract array information. Works for T_ARRAY only.
2062N/A static BasicType get_array_info(Symbol* signature, FieldArrayInfo& ai, TRAPS);
0N/A};
1879N/A
1879N/A#endif // SHARE_VM_RUNTIME_FIELDTYPE_HPP