src/share/vm/ci/ciConstant.hpp

Print this page


   1 /*
   2  * Copyright (c) 1999, 2003, 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 // ciConstant
  26 //
  27 // This class represents a constant value.
  28 class ciConstant VALUE_OBJ_CLASS_SPEC {
  29 private:
  30   friend class ciEnv;
  31   friend class ciField;
  32 
  33   BasicType _type;
  34   union {
  35     jint      _int;
  36     jlong     _long;
  37     jint      _long_half[2];
  38     jfloat    _float;
  39     jdouble   _double;
  40     ciObject* _object;
  41   } _value;
  42 
  43   // Implementation of the print method.
  44   void print_impl(outputStream* st);


  93   jlong     as_long() {
  94     assert(basic_type() == T_LONG, "wrong type");
  95     return _value._long;
  96   }
  97   jfloat    as_float() {
  98     assert(basic_type() == T_FLOAT, "wrong type");
  99     return _value._float;
 100   }
 101   jdouble   as_double() {
 102     assert(basic_type() == T_DOUBLE, "wrong type");
 103     return _value._double;
 104   }
 105   ciObject* as_object() const {
 106     assert(basic_type() == T_OBJECT || basic_type() == T_ARRAY, "wrong type");
 107     return _value._object;
 108   }
 109 
 110   // Debugging output
 111   void print();
 112 };


   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  */
  24 
  25 #ifndef SHARE_VM_CI_CICONSTANT_HPP
  26 #define SHARE_VM_CI_CICONSTANT_HPP
  27 
  28 #include "ci/ciClassList.hpp"
  29 #include "ci/ciNullObject.hpp"
  30 
  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;
  38 
  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;
  48 
  49   // Implementation of the print method.
  50   void print_impl(outputStream* st);


  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   }
 115 
 116   // Debugging output
 117   void print();
 118 };
 119 
 120 #endif // SHARE_VM_CI_CICONSTANT_HPP