source: webkit/trunk/JavaScriptCore/runtime/Identifier.h@ 42478

Last change on this file since 42478 was 39554, checked in by [email protected], 16 years ago

Bug 23080: Remove last vestiges of KJS references

<https://bugs.webkit.org/show_bug.cgi?id=23080>

Reviewed by Darin Adler.

Also updated Apple copyright statements.

  • DerivedSources.make: Changed bison "kjsyy" prefix to "jscyy".
  • GNUmakefile.am: Ditto.
  • JavaScriptCore.pri: Ditto. Also changed KJSBISON to JSCBISON and kjsbison to jscbison.
  • JavaScriptCoreSources.bkl: Changed JSCORE_KJS_SOURCES to JSCORE_JSC_SOURCES.
  • jscore.bkl: Ditto.
  • create_hash_table: Updated copyright and removed old comment.
  • parser/Grammar.y: Changed "kjsyy" prefix to "jscyy" prefix.
  • parser/Lexer.cpp: Ditto. Also changed KJS_DEBUG_LEX to JSC_DEBUG_LEX. (jscyylex): (JSC::Lexer::lex):
  • parser/Parser.cpp: Ditto. (JSC::Parser::parse):
  • pcre/dftables: Changed "kjs_pcre_" prefix to "jsc_pcre_".
  • pcre/pcre_compile.cpp: Ditto. (getOthercaseRange): (encodeUTF8): (compileBranch): (calculateCompiledPatternLength):
  • pcre/pcre_exec.cpp: Ditto. (matchRef): (getUTF8CharAndIncrementLength): (match):
  • pcre/pcre_internal.h: Ditto. (toLowerCase): (flipCase): (classBitmapForChar): (charTypeForChar):
  • pcre/pcre_tables.cpp: Ditto.
  • pcre/pcre_ucp_searchfuncs.cpp: Ditto. (jsc_pcre_ucp_othercase):
  • pcre/pcre_xclass.cpp: Ditto. (getUTF8CharAndAdvancePointer): (jsc_pcre_xclass):
  • runtime/Collector.h: Updated header guards using the clean-header-guards script.
  • runtime/CollectorHeapIterator.h: Added missing header guard.
  • runtime/Identifier.h: Updated header guards.
  • runtime/JSFunction.h: Fixed end-of-namespace comment.
  • runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::reset): Renamed "kjsprint" debug function to "jscprint". Changed implementation method from globalFuncKJSPrint() to globalFuncJSCPrint().
  • runtime/JSGlobalObjectFunctions.cpp: (JSC::globalFuncJSCPrint): Renamed from globalFuncKJSPrint().
  • runtime/JSGlobalObjectFunctions.h: Ditto.
  • runtime/JSImmediate.h: Updated header guards.
  • runtime/JSLock.h: Ditto.
  • runtime/JSType.h: Ditto.
  • runtime/JSWrapperObject.h: Ditto.
  • runtime/Lookup.h: Ditto.
  • runtime/Operations.h: Ditto.
  • runtime/Protect.h: Ditto.
  • runtime/RegExp.h: Ditto.
  • runtime/UString.h: Ditto.
  • tests/mozilla/js1_5/Array/regress-157652.js: Changed "KJS" reference in comment to "JSC".
  • wrec/CharacterClassConstructor.cpp: Change "kjs_pcre_" function prefixes to "jsc_pcre_". (JSC::WREC::CharacterClassConstructor::put): (JSC::WREC::CharacterClassConstructor::flush):
  • wtf/unicode/Unicode.h: Change "KJS_" header guard to "WTF_".
  • wtf/unicode/icu/UnicodeIcu.h: Ditto.
  • wtf/unicode/qt4/UnicodeQt4.h: Ditto.
  • Property svn:eol-style set to native
File size: 5.7 KB
Line 
1/*
2 * Copyright (C) 2003, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 *
19 */
20
21#ifndef Identifier_h
22#define Identifier_h
23
24#include "JSGlobalData.h"
25#include "UString.h"
26
27namespace JSC {
28
29 class ExecState;
30
31 class Identifier {
32 friend class Structure;
33 public:
34 Identifier() { }
35
36 Identifier(ExecState* exec, const char* s) : _ustring(add(exec, s)) { } // Only to be used with string literals.
37 Identifier(ExecState* exec, const UChar* s, int length) : _ustring(add(exec, s, length)) { }
38 Identifier(ExecState* exec, UString::Rep* rep) : _ustring(add(exec, rep)) { }
39 Identifier(ExecState* exec, const UString& s) : _ustring(add(exec, s.rep())) { }
40
41 Identifier(JSGlobalData* globalData, const char* s) : _ustring(add(globalData, s)) { } // Only to be used with string literals.
42 Identifier(JSGlobalData* globalData, const UChar* s, int length) : _ustring(add(globalData, s, length)) { }
43 Identifier(JSGlobalData* globalData, UString::Rep* rep) : _ustring(add(globalData, rep)) { }
44 Identifier(JSGlobalData* globalData, const UString& s) : _ustring(add(globalData, s.rep())) { }
45
46 // Special constructor for cases where we overwrite an object in place.
47 Identifier(PlacementNewAdoptType) : _ustring(PlacementNewAdopt) { }
48
49 const UString& ustring() const { return _ustring; }
50
51 const UChar* data() const { return _ustring.data(); }
52 int size() const { return _ustring.size(); }
53
54 const char* ascii() const { return _ustring.ascii(); }
55
56 static Identifier from(ExecState* exec, unsigned y) { return Identifier(exec, UString::from(y)); }
57
58 bool isNull() const { return _ustring.isNull(); }
59 bool isEmpty() const { return _ustring.isEmpty(); }
60
61 uint32_t toUInt32(bool* ok) const { return _ustring.toUInt32(ok); }
62 uint32_t toUInt32(bool* ok, bool tolerateEmptyString) const { return _ustring.toUInt32(ok, tolerateEmptyString); };
63 uint32_t toStrictUInt32(bool* ok) const { return _ustring.toStrictUInt32(ok); }
64 unsigned toArrayIndex(bool* ok) const { return _ustring.toArrayIndex(ok); }
65 double toDouble() const { return _ustring.toDouble(); }
66
67 friend bool operator==(const Identifier&, const Identifier&);
68 friend bool operator!=(const Identifier&, const Identifier&);
69
70 friend bool operator==(const Identifier&, const char*);
71 friend bool operator!=(const Identifier&, const char*);
72
73 static void remove(UString::Rep*);
74
75 static bool equal(const UString::Rep*, const char*);
76 static bool equal(const UString::Rep*, const UChar*, int length);
77 static bool equal(const UString::Rep* a, const UString::Rep* b) { return JSC::equal(a, b); }
78
79 static PassRefPtr<UString::Rep> add(ExecState*, const char*); // Only to be used with string literals.
80 static PassRefPtr<UString::Rep> add(JSGlobalData*, const char*); // Only to be used with string literals.
81
82 private:
83 UString _ustring;
84
85 static bool equal(const Identifier& a, const Identifier& b) { return a._ustring.rep() == b._ustring.rep(); }
86 static bool equal(const Identifier& a, const char* b) { return equal(a._ustring.rep(), b); }
87
88 static PassRefPtr<UString::Rep> add(ExecState*, const UChar*, int length);
89 static PassRefPtr<UString::Rep> add(JSGlobalData*, const UChar*, int length);
90
91 static PassRefPtr<UString::Rep> add(ExecState* exec, UString::Rep* r)
92 {
93 if (r->identifierTable()) {
94#ifndef NDEBUG
95 checkSameIdentifierTable(exec, r);
96#endif
97 return r;
98 }
99 return addSlowCase(exec, r);
100 }
101 static PassRefPtr<UString::Rep> add(JSGlobalData* globalData, UString::Rep* r)
102 {
103 if (r->identifierTable()) {
104#ifndef NDEBUG
105 checkSameIdentifierTable(globalData, r);
106#endif
107 return r;
108 }
109 return addSlowCase(globalData, r);
110 }
111
112 static PassRefPtr<UString::Rep> addSlowCase(ExecState*, UString::Rep* r);
113 static PassRefPtr<UString::Rep> addSlowCase(JSGlobalData*, UString::Rep* r);
114
115 static void checkSameIdentifierTable(ExecState*, UString::Rep*);
116 static void checkSameIdentifierTable(JSGlobalData*, UString::Rep*);
117 };
118
119 inline bool operator==(const Identifier& a, const Identifier& b)
120 {
121 return Identifier::equal(a, b);
122 }
123
124 inline bool operator!=(const Identifier& a, const Identifier& b)
125 {
126 return !Identifier::equal(a, b);
127 }
128
129 inline bool operator==(const Identifier& a, const char* b)
130 {
131 return Identifier::equal(a, b);
132 }
133
134 inline bool operator!=(const Identifier& a, const char* b)
135 {
136 return !Identifier::equal(a, b);
137 }
138
139 IdentifierTable* createIdentifierTable();
140 void deleteIdentifierTable(IdentifierTable*);
141
142} // namespace JSC
143
144#endif // Identifier_h
Note: See TracBrowser for help on using the repository browser.