0N/A/*
2772N/A * Copyright (c) 1999, 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_CI_CICONSTANT_HPP
1879N/A#define SHARE_VM_CI_CICONSTANT_HPP
1879N/A
1879N/A#include "ci/ciClassList.hpp"
1879N/A#include "ci/ciNullObject.hpp"
1879N/A
0N/A// ciConstant
0N/A//
0N/A// This class represents a constant value.
0N/Aclass ciConstant VALUE_OBJ_CLASS_SPEC {
2772N/A friend class VMStructs;
0N/Aprivate:
0N/A friend class ciEnv;
0N/A friend class ciField;
0N/A
0N/A BasicType _type;
0N/A union {
0N/A jint _int;
0N/A jlong _long;
0N/A jint _long_half[2];
0N/A jfloat _float;
0N/A jdouble _double;
0N/A ciObject* _object;
0N/A } _value;
0N/A
0N/Apublic:
0N/A
0N/A ciConstant() {
0N/A _type = T_ILLEGAL; _value._long = -1;
0N/A }
0N/A ciConstant(BasicType type, jint value) {
0N/A assert(type != T_LONG && type != T_DOUBLE && type != T_FLOAT,
0N/A "using the wrong ciConstant constructor");
0N/A _type = type; _value._int = value;
0N/A }
0N/A ciConstant(jlong value) {
0N/A _type = T_LONG; _value._long = value;
0N/A }
0N/A ciConstant(jfloat value) {
0N/A _type = T_FLOAT; _value._float = value;
0N/A }
0N/A ciConstant(jdouble value) {
0N/A _type = T_DOUBLE; _value._double = value;
0N/A }
0N/A ciConstant(BasicType type, ciObject* p) {
0N/A _type = type; _value._object = p;
0N/A }
0N/A
0N/A BasicType basic_type() const { return _type; }
0N/A
0N/A jboolean as_boolean() {
0N/A assert(basic_type() == T_BOOLEAN, "wrong type");
0N/A return (jboolean)_value._int;
0N/A }
0N/A jchar as_char() {
0N/A assert(basic_type() == T_CHAR, "wrong type");
0N/A return (jchar)_value._int;
0N/A }
0N/A jbyte as_byte() {
0N/A assert(basic_type() == T_BYTE, "wrong type");
0N/A return (jbyte)_value._int;
0N/A }
0N/A jshort as_short() {
0N/A assert(basic_type() == T_SHORT, "wrong type");
0N/A return (jshort)_value._int;
0N/A }
0N/A jint as_int() {
0N/A assert(basic_type() == T_BOOLEAN || basic_type() == T_CHAR ||
0N/A basic_type() == T_BYTE || basic_type() == T_SHORT ||
0N/A basic_type() == T_INT, "wrong type");
0N/A return _value._int;
0N/A }
0N/A jlong as_long() {
0N/A assert(basic_type() == T_LONG, "wrong type");
0N/A return _value._long;
0N/A }
0N/A jfloat as_float() {
0N/A assert(basic_type() == T_FLOAT, "wrong type");
0N/A return _value._float;
0N/A }
0N/A jdouble as_double() {
0N/A assert(basic_type() == T_DOUBLE, "wrong type");
0N/A return _value._double;
0N/A }
0N/A ciObject* as_object() const {
0N/A assert(basic_type() == T_OBJECT || basic_type() == T_ARRAY, "wrong type");
0N/A return _value._object;
0N/A }
0N/A
0N/A // Debugging output
0N/A void print();
0N/A};
1879N/A
1879N/A#endif // SHARE_VM_CI_CICONSTANT_HPP