ciSymbol.hpp revision 0:a61af66fc99e
11541Srgrimes/*
21541Srgrimes * Copyright 1999-2001 Sun Microsystems, Inc.  All Rights Reserved.
31541Srgrimes * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
41541Srgrimes *
51541Srgrimes * This code is free software; you can redistribute it and/or modify it
61541Srgrimes * under the terms of the GNU General Public License version 2 only, as
71541Srgrimes * published by the Free Software Foundation.
81541Srgrimes *
91541Srgrimes * This code is distributed in the hope that it will be useful, but WITHOUT
101541Srgrimes * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
111541Srgrimes * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
121541Srgrimes * version 2 for more details (a copy is included in the LICENSE file that
131541Srgrimes * accompanied this code).
141541Srgrimes *
151541Srgrimes * You should have received a copy of the GNU General Public License version
161541Srgrimes * 2 along with this work; if not, write to the Free Software Foundation,
171541Srgrimes * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
181541Srgrimes *
191541Srgrimes * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
201541Srgrimes * CA 95054 USA or visit www.sun.com if you need additional information or
211541Srgrimes * have any questions.
221541Srgrimes *
231541Srgrimes */
241541Srgrimes
251541Srgrimes// ciSymbol
261541Srgrimes//
271541Srgrimes// This class represents a symbolOop in the HotSpot virtual
281541Srgrimes// machine.
291541Srgrimesclass ciSymbol : public ciObject {
301541Srgrimes  CI_PACKAGE_ACCESS
311541Srgrimes  friend class ciEnv;
321541Srgrimes  friend class ciInstanceKlass;
331541Srgrimes  friend class ciSignature;
3450477Speter  friend class ciMethod;
351541Srgrimes  friend class ciObjArrayKlass;
361541Srgrimes
372165Spaulprivate:
3859774Sbde  ciSymbol(symbolOop s) : ciObject(s) {}
392165Spaul  ciSymbol(symbolHandle s);   // for use with vmSymbolHandles
4095759Stanimura
4195759Stanimura  symbolOop get_symbolOop() { return (symbolOop)get_oop(); }
4241086Struckman
4341086Struckman  const char* type_string() { return "ciSymbol"; }
441541Srgrimes
451541Srgrimes  void print_impl(outputStream* st);
461541Srgrimes
471541Srgrimes  int         byte_at(int i);
481541Srgrimes  jbyte*      base();
491541Srgrimes
501541Srgrimes  // Make a ciSymbol from a C string (implementation).
511541Srgrimes  static ciSymbol* make_impl(const char* s);
521541Srgrimes
531541Srgrimespublic:
541541Srgrimes  // The text of the symbol as a null-terminated utf8 string.
551541Srgrimes  const char* as_utf8();
561541Srgrimes  int         utf8_length();
571541Srgrimes
581541Srgrimes  // What kind of ciObject is this?
598876Srgrimes  bool is_symbol() { return true; }
601541Srgrimes
611541Srgrimes  void print_symbol_on(outputStream* st);
621541Srgrimes  void print_symbol() {
631541Srgrimes    print_symbol_on(tty);
641541Srgrimes  }
651541Srgrimes
6651649Sphk  // Make a ciSymbol from a C string.
671541Srgrimes  // Consider adding to vmSymbols.hpp instead of using this constructor.
6889306Salfred  // (Your code will be less subject to typographical bugs.)
6989306Salfred  static ciSymbol* make(const char* s);
701541Srgrimes
711541Srgrimes#define CI_SYMBOL_DECLARE(name, ignore_def) \
7259288Sjlemon  static ciSymbol* name() { return ciObjectFactory::vm_symbol_at(vmSymbols::VM_SYMBOL_ENUM_NAME(name)); }
7359288Sjlemon  VM_SYMBOLS_DO(CI_SYMBOL_DECLARE, CI_SYMBOL_DECLARE)
7459288Sjlemon#undef CI_SYMBOL_DECLARE
7559288Sjlemon};
7659288Sjlemon