1
|
1 |
/*
|
|
2 |
* Copyright 1999-2007 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 |
* have any questions.
|
|
22 |
*
|
|
23 |
*/
|
|
24 |
|
|
25 |
#include "incls/_precompiled.incl"
|
|
26 |
#include "incls/_ciSymbol.cpp.incl"
|
|
27 |
|
|
28 |
// ------------------------------------------------------------------
|
|
29 |
// ciSymbol::ciSymbol
|
|
30 |
//
|
|
31 |
// Preallocated handle variant. Used with handles from vmSymboHandles.
|
|
32 |
ciSymbol::ciSymbol(symbolHandle h_s) : ciObject(h_s) {
|
|
33 |
}
|
|
34 |
|
|
35 |
// ciSymbol
|
|
36 |
//
|
|
37 |
// This class represents a symbolOop in the HotSpot virtual
|
|
38 |
// machine.
|
|
39 |
|
|
40 |
// ------------------------------------------------------------------
|
|
41 |
// ciSymbol::as_utf8
|
|
42 |
//
|
|
43 |
// The text of the symbol as a null-terminated C string.
|
|
44 |
const char* ciSymbol::as_utf8() {
|
|
45 |
VM_QUICK_ENTRY_MARK;
|
|
46 |
symbolOop s = get_symbolOop();
|
|
47 |
return s->as_utf8();
|
|
48 |
}
|
|
49 |
|
|
50 |
// ------------------------------------------------------------------
|
|
51 |
// ciSymbol::base
|
|
52 |
jbyte* ciSymbol::base() {
|
|
53 |
GUARDED_VM_ENTRY(return get_symbolOop()->base();)
|
|
54 |
}
|
|
55 |
|
|
56 |
// ------------------------------------------------------------------
|
|
57 |
// ciSymbol::byte_at
|
|
58 |
int ciSymbol::byte_at(int i) {
|
|
59 |
GUARDED_VM_ENTRY(return get_symbolOop()->byte_at(i);)
|
|
60 |
}
|
|
61 |
|
|
62 |
// ------------------------------------------------------------------
|
|
63 |
// ciSymbol::utf8_length
|
|
64 |
int ciSymbol::utf8_length() {
|
|
65 |
GUARDED_VM_ENTRY(return get_symbolOop()->utf8_length();)
|
|
66 |
}
|
|
67 |
|
|
68 |
// ------------------------------------------------------------------
|
|
69 |
// ciSymbol::print_impl
|
|
70 |
//
|
|
71 |
// Implementation of the print method
|
|
72 |
void ciSymbol::print_impl(outputStream* st) {
|
|
73 |
st->print(" value=");
|
|
74 |
print_symbol_on(st);
|
|
75 |
}
|
|
76 |
|
|
77 |
// ------------------------------------------------------------------
|
|
78 |
// ciSymbol::print_symbol_on
|
|
79 |
//
|
|
80 |
// Print the value of this symbol on an outputStream
|
|
81 |
void ciSymbol::print_symbol_on(outputStream *st) {
|
|
82 |
GUARDED_VM_ENTRY(get_symbolOop()->print_symbol_on(st);)
|
|
83 |
}
|
|
84 |
|
|
85 |
// ------------------------------------------------------------------
|
|
86 |
// ciSymbol::make_impl
|
|
87 |
//
|
|
88 |
// Make a ciSymbol from a C string (implementation).
|
|
89 |
ciSymbol* ciSymbol::make_impl(const char* s) {
|
|
90 |
EXCEPTION_CONTEXT;
|
|
91 |
// For some reason, oopFactory::new_symbol doesn't declare its
|
|
92 |
// char* argument as const.
|
|
93 |
symbolOop sym = oopFactory::new_symbol((char*)s, (int)strlen(s), THREAD);
|
|
94 |
if (HAS_PENDING_EXCEPTION) {
|
|
95 |
CLEAR_PENDING_EXCEPTION;
|
|
96 |
CURRENT_THREAD_ENV->record_out_of_memory_failure();
|
|
97 |
return ciEnv::_unloaded_cisymbol;
|
|
98 |
}
|
|
99 |
return CURRENT_THREAD_ENV->get_object(sym)->as_symbol();
|
|
100 |
}
|
|
101 |
|
|
102 |
// ------------------------------------------------------------------
|
|
103 |
// ciSymbol::make
|
|
104 |
//
|
|
105 |
// Make a ciSymbol from a C string.
|
|
106 |
ciSymbol* ciSymbol::make(const char* s) {
|
|
107 |
GUARDED_VM_ENTRY(return make_impl(s);)
|
|
108 |
}
|