src/share/vm/ci/ciConstant.hpp

Tue, 23 Nov 2010 13:22:55 -0800

author
stefank
date
Tue, 23 Nov 2010 13:22:55 -0800
changeset 2314
f95d63e2154a
parent 1907
c18cbe5936b8
child 3099
c124e2e7463e
permissions
-rw-r--r--

6989984: Use standard include model for Hospot
Summary: Replaced MakeDeps and the includeDB files with more standardized solutions.
Reviewed-by: coleenp, kvn, kamg

     1 /*
     2  * Copyright (c) 1999, 2010, 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  */
    25 #ifndef SHARE_VM_CI_CICONSTANT_HPP
    26 #define SHARE_VM_CI_CICONSTANT_HPP
    28 #include "ci/ciClassList.hpp"
    29 #include "ci/ciNullObject.hpp"
    31 // ciConstant
    32 //
    33 // This class represents a constant value.
    34 class ciConstant VALUE_OBJ_CLASS_SPEC {
    35 private:
    36   friend class ciEnv;
    37   friend class ciField;
    39   BasicType _type;
    40   union {
    41     jint      _int;
    42     jlong     _long;
    43     jint      _long_half[2];
    44     jfloat    _float;
    45     jdouble   _double;
    46     ciObject* _object;
    47   } _value;
    49   // Implementation of the print method.
    50   void print_impl(outputStream* st);
    52 public:
    54   ciConstant() {
    55     _type = T_ILLEGAL; _value._long = -1;
    56   }
    57   ciConstant(BasicType type, jint value) {
    58     assert(type != T_LONG && type != T_DOUBLE && type != T_FLOAT,
    59            "using the wrong ciConstant constructor");
    60     _type = type; _value._int = value;
    61   }
    62   ciConstant(jlong value) {
    63     _type = T_LONG; _value._long = value;
    64   }
    65   ciConstant(jfloat value) {
    66     _type = T_FLOAT; _value._float = value;
    67   }
    68   ciConstant(jdouble value) {
    69     _type = T_DOUBLE; _value._double = value;
    70   }
    71   ciConstant(BasicType type, ciObject* p) {
    72     _type = type; _value._object = p;
    73   }
    75   BasicType basic_type() const { return _type; }
    77   jboolean  as_boolean() {
    78     assert(basic_type() == T_BOOLEAN, "wrong type");
    79     return (jboolean)_value._int;
    80   }
    81   jchar     as_char() {
    82     assert(basic_type() == T_CHAR, "wrong type");
    83     return (jchar)_value._int;
    84   }
    85   jbyte     as_byte() {
    86     assert(basic_type() == T_BYTE, "wrong type");
    87     return (jbyte)_value._int;
    88   }
    89   jshort    as_short() {
    90     assert(basic_type() == T_SHORT, "wrong type");
    91     return (jshort)_value._int;
    92   }
    93   jint      as_int() {
    94     assert(basic_type() == T_BOOLEAN || basic_type() == T_CHAR  ||
    95            basic_type() == T_BYTE    || basic_type() == T_SHORT ||
    96            basic_type() == T_INT, "wrong type");
    97     return _value._int;
    98   }
    99   jlong     as_long() {
   100     assert(basic_type() == T_LONG, "wrong type");
   101     return _value._long;
   102   }
   103   jfloat    as_float() {
   104     assert(basic_type() == T_FLOAT, "wrong type");
   105     return _value._float;
   106   }
   107   jdouble   as_double() {
   108     assert(basic_type() == T_DOUBLE, "wrong type");
   109     return _value._double;
   110   }
   111   ciObject* as_object() const {
   112     assert(basic_type() == T_OBJECT || basic_type() == T_ARRAY, "wrong type");
   113     return _value._object;
   114   }
   116   // Debugging output
   117   void print();
   118 };
   120 #endif // SHARE_VM_CI_CICONSTANT_HPP

mercurial