source: webkit/trunk/JavaScriptCore/runtime/RegExpObject.cpp@ 67583

Last change on this file since 67583 was 65177, checked in by [email protected], 15 years ago

Rubber stamps by Darin Adler & Sam Weinig.

Bug 43867 - Some UString cleanup

Change JSC::UString data(), size(), and from(), to characters(), length(), and number() to match WTF::String.
Move string concatenation methods to a new header to simplify down UString.h. Remove is8Bit().

JavaScriptCore:

  • API/JSClassRef.cpp:

(OpaqueJSClass::~OpaqueJSClass):
(OpaqueJSClass::className):

  • API/OpaqueJSString.cpp:

(OpaqueJSString::create):

(JSC::constantName):
(JSC::idName):
(JSC::CodeBlock::registerName):
(JSC::regexpName):

  • bytecode/EvalCodeCache.h:

(JSC::EvalCodeCache::get):

  • bytecompiler/NodesCodegen.cpp:

(JSC::ResolveNode::emitBytecode):
(JSC::FunctionCallResolveNode::emitBytecode):
(JSC::ReadModifyResolveNode::emitBytecode):
(JSC::processClauseList):

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createRegex):

  • parser/ParserArena.h:

(JSC::IdentifierArena::makeNumericIdentifier):

  • parser/SourceProvider.h:

(JSC::UStringSourceProvider::data):
(JSC::UStringSourceProvider::length):

  • profiler/Profiler.cpp:
  • runtime/Arguments.cpp:

(JSC::Arguments::getOwnPropertySlot):
(JSC::Arguments::getOwnPropertyNames):
(JSC::Arguments::put):
(JSC::Arguments::deleteProperty):

  • runtime/ArrayPrototype.cpp:

(JSC::arrayProtoFuncToString):

  • runtime/DatePrototype.cpp:

(JSC::formatLocaleDate):

  • runtime/ExceptionHelpers.cpp:
  • runtime/FunctionConstructor.cpp:
  • runtime/FunctionPrototype.cpp:

(JSC::insertSemicolonIfNeeded):

  • runtime/Identifier.h:

(JSC::Identifier::characters):
(JSC::Identifier::length):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::decode):
(JSC::parseInt):
(JSC::parseFloat):
(JSC::globalFuncEscape):
(JSC::globalFuncUnescape):

  • runtime/JSNumberCell.cpp:

(JSC::JSNumberCell::toString):

  • runtime/JSONObject.cpp:

(JSC::gap):
(JSC::Stringifier::appendQuotedString):
(JSC::Stringifier::appendStringifiedValue):
(JSC::Stringifier::indent):
(JSC::Stringifier::unindent):
(JSC::Walker::walk):

  • runtime/JSString.cpp:

(JSC::JSString::replaceCharacter):
(JSC::JSString::getIndexSlowCase):

  • runtime/JSString.h:

(JSC::RopeBuilder::JSString):
(JSC::RopeBuilder::appendValueInConstructAndIncrementLength):
(JSC::RopeBuilder::fiberCount):
(JSC::jsSingleCharacterSubstring):
(JSC::jsNontrivialString):
(JSC::JSString::getIndex):
(JSC::jsString):
(JSC::jsStringWithFinalizer):
(JSC::jsSubstring):
(JSC::jsOwnedString):

  • runtime/JSStringBuilder.h:

(JSC::JSStringBuilder::append):

  • runtime/LiteralParser.h:

(JSC::LiteralParser::Lexer::Lexer):

  • runtime/NumberPrototype.cpp:

(JSC::numberProtoFuncToString):
(JSC::numberProtoFuncToFixed):
(JSC::numberProtoFuncToExponential):
(JSC::numberProtoFuncToPrecision):

  • runtime/NumericStrings.h:

(JSC::NumericStrings::add):
(JSC::NumericStrings::lookupSmallString):

  • runtime/Operations.h:

(JSC::jsString):

  • runtime/RegExp.cpp:

(JSC::RegExp::match):

  • runtime/RegExpCache.cpp:

(JSC::RegExpCache::lookupOrCreate):
(JSC::RegExpCache::create):

  • runtime/RegExpConstructor.cpp:

(JSC::RegExpConstructor::getRightContext):

  • runtime/RegExpObject.cpp:

(JSC::RegExpObject::match):

  • runtime/RegExpPrototype.cpp:

(JSC::regExpProtoFuncToString):

  • runtime/StringBuilder.h:

(JSC::StringBuilder::append):

  • runtime/StringConcatenate.h: Copied from JavaScriptCore/runtime/UString.h.

(JSC::):
(JSC::sumWithOverflow):
(JSC::tryMakeString):
(JSC::makeString):

  • runtime/StringObject.cpp:

(JSC::StringObject::getOwnPropertyNames):

  • runtime/StringPrototype.cpp:

(JSC::substituteBackreferencesSlow):
(JSC::localeCompare):
(JSC::jsSpliceSubstringsWithSeparators):
(JSC::stringProtoFuncReplace):
(JSC::stringProtoFuncCharAt):
(JSC::stringProtoFuncCharCodeAt):
(JSC::stringProtoFuncIndexOf):
(JSC::stringProtoFuncLastIndexOf):
(JSC::stringProtoFuncSlice):
(JSC::stringProtoFuncSplit):
(JSC::stringProtoFuncSubstr):
(JSC::stringProtoFuncSubstring):
(JSC::stringProtoFuncToLowerCase):
(JSC::stringProtoFuncToUpperCase):
(JSC::stringProtoFuncFontsize):
(JSC::stringProtoFuncLink):
(JSC::trimString):

  • runtime/UString.cpp:

(JSC::UString::number):
(JSC::UString::ascii):
(JSC::UString::operator[]):
(JSC::UString::toDouble):
(JSC::UString::find):
(JSC::UString::rfind):
(JSC::UString::substr):
(JSC::operator==):
(JSC::operator<):
(JSC::operator>):
(JSC::UString::UTF8String):

  • runtime/UString.h:

(JSC::UString::UString):
(JSC::UString::adopt):
(JSC::UString::length):
(JSC::UString::characters):
(JSC::UString::isNull):
(JSC::UString::isEmpty):
(JSC::UString::impl):
(JSC::UString::cost):
(JSC::operator==):
(JSC::operator!=):
(JSC::codePointCompare):
(JSC::UString::toArrayIndex):
(JSC::IdentifierRepHash::hash):
(WTF::):

  • yarr/RegexJIT.cpp:

(JSC::Yarr::jitCompileRegex):

  • yarr/RegexParser.h:

(JSC::Yarr::Parser::Parser):

JavaScriptGlue:

  • JSUtils.cpp:

(UStringToCFString):
(KJSValueToCFTypeInternal):

  • JavaScriptGlue.xcodeproj/project.pbxproj:

WebCore:

  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/JSCSSStyleDeclarationCustom.cpp:

(WebCore::hasCSSPropertyNamePrefix):
(WebCore::cssPropertyName):

  • bindings/js/JSLocationCustom.cpp:

(WebCore::JSLocation::setPort):

  • bindings/js/ScriptDebugServer.cpp:

(WebCore::ScriptDebugServer::dispatchDidParseSource):

  • bindings/js/ScriptString.h:

(WebCore::ScriptString::size):

  • bindings/js/ScriptValue.cpp:

(WebCore::jsToInspectorValue):

  • bindings/objc/WebScriptObject.mm:

(+[WebScriptObject _convertValueToObjcValue:originRootObject:rootObject:]):

  • bridge/jni/jni_jsobject.mm:

(JavaJSObject::convertValueToJObject):

  • bridge/jni/jsc/JNIUtilityPrivate.cpp:

(JSC::Bindings::convertArrayInstanceToJavaArray):
(JSC::Bindings::convertValueToJValue):

  • bridge/objc/objc_runtime.mm:

(JSC::Bindings::callObjCFallbackObject):

WebKit/mac:

  • WebView/WebScriptDebugger.mm:

(toNSString):

  • Property svn:eol-style set to native
File size: 5.7 KB
Line 
1/*
2 * Copyright (C) 1999-2000 Harri Porten ([email protected])
3 * Copyright (C) 2003, 2007, 2008 Apple Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 */
20
21#include "config.h"
22#include "RegExpObject.h"
23
24#include "Error.h"
25#include "ExceptionHelpers.h"
26#include "JSArray.h"
27#include "JSGlobalObject.h"
28#include "JSString.h"
29#include "Lookup.h"
30#include "RegExpConstructor.h"
31#include "RegExpPrototype.h"
32#include "StringConcatenate.h"
33#include <wtf/PassOwnPtr.h>
34
35namespace JSC {
36
37static JSValue regExpObjectGlobal(ExecState*, JSValue, const Identifier&);
38static JSValue regExpObjectIgnoreCase(ExecState*, JSValue, const Identifier&);
39static JSValue regExpObjectMultiline(ExecState*, JSValue, const Identifier&);
40static JSValue regExpObjectSource(ExecState*, JSValue, const Identifier&);
41static JSValue regExpObjectLastIndex(ExecState*, JSValue, const Identifier&);
42static void setRegExpObjectLastIndex(ExecState*, JSObject*, JSValue);
43
44} // namespace JSC
45
46#include "RegExpObject.lut.h"
47
48namespace JSC {
49
50ASSERT_CLASS_FITS_IN_CELL(RegExpObject);
51
52const ClassInfo RegExpObject::info = { "RegExp", 0, 0, ExecState::regExpTable };
53
54/* Source for RegExpObject.lut.h
55@begin regExpTable
56 global regExpObjectGlobal DontDelete|ReadOnly|DontEnum
57 ignoreCase regExpObjectIgnoreCase DontDelete|ReadOnly|DontEnum
58 multiline regExpObjectMultiline DontDelete|ReadOnly|DontEnum
59 source regExpObjectSource DontDelete|ReadOnly|DontEnum
60 lastIndex regExpObjectLastIndex DontDelete|DontEnum
61@end
62*/
63
64RegExpObject::RegExpObject(JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, NonNullPassRefPtr<RegExp> regExp)
65 : JSObjectWithGlobalObject(globalObject, structure)
66 , d(adoptPtr(new RegExpObjectData(regExp, 0)))
67{
68}
69
70RegExpObject::~RegExpObject()
71{
72}
73
74bool RegExpObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
75{
76 return getStaticValueSlot<RegExpObject, JSObject>(exec, ExecState::regExpTable(exec), this, propertyName, slot);
77}
78
79bool RegExpObject::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
80{
81 return getStaticValueDescriptor<RegExpObject, JSObject>(exec, ExecState::regExpTable(exec), this, propertyName, descriptor);
82}
83
84JSValue regExpObjectGlobal(ExecState*, JSValue slotBase, const Identifier&)
85{
86 return jsBoolean(asRegExpObject(slotBase)->regExp()->global());
87}
88
89JSValue regExpObjectIgnoreCase(ExecState*, JSValue slotBase, const Identifier&)
90{
91 return jsBoolean(asRegExpObject(slotBase)->regExp()->ignoreCase());
92}
93
94JSValue regExpObjectMultiline(ExecState*, JSValue slotBase, const Identifier&)
95{
96 return jsBoolean(asRegExpObject(slotBase)->regExp()->multiline());
97}
98
99JSValue regExpObjectSource(ExecState* exec, JSValue slotBase, const Identifier&)
100{
101 return jsString(exec, asRegExpObject(slotBase)->regExp()->pattern());
102}
103
104JSValue regExpObjectLastIndex(ExecState* exec, JSValue slotBase, const Identifier&)
105{
106 return jsNumber(exec, asRegExpObject(slotBase)->lastIndex());
107}
108
109void RegExpObject::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
110{
111 lookupPut<RegExpObject, JSObject>(exec, propertyName, value, ExecState::regExpTable(exec), this, slot);
112}
113
114void setRegExpObjectLastIndex(ExecState* exec, JSObject* baseObject, JSValue value)
115{
116 asRegExpObject(baseObject)->setLastIndex(value.toInteger(exec));
117}
118
119JSValue RegExpObject::test(ExecState* exec)
120{
121 return jsBoolean(match(exec));
122}
123
124JSValue RegExpObject::exec(ExecState* exec)
125{
126 if (match(exec))
127 return exec->lexicalGlobalObject()->regExpConstructor()->arrayOfMatches(exec);
128 return jsNull();
129}
130
131static EncodedJSValue JSC_HOST_CALL callRegExpObject(ExecState* exec)
132{
133 return JSValue::encode(asRegExpObject(exec->callee())->exec(exec));
134}
135
136CallType RegExpObject::getCallData(CallData& callData)
137{
138 callData.native.function = callRegExpObject;
139 return CallTypeHost;
140}
141
142// Shared implementation used by test and exec.
143bool RegExpObject::match(ExecState* exec)
144{
145 RegExpConstructor* regExpConstructor = exec->lexicalGlobalObject()->regExpConstructor();
146
147 UString input = !exec->argumentCount() ? regExpConstructor->input() : exec->argument(0).toString(exec);
148 if (input.isNull()) {
149 throwError(exec, createError(exec, makeString("No input to ", toString(exec), ".")));
150 return false;
151 }
152
153 if (!regExp()->global()) {
154 int position;
155 int length;
156 regExpConstructor->performMatch(d->regExp.get(), input, 0, position, length);
157 return position >= 0;
158 }
159
160 if (d->lastIndex < 0 || d->lastIndex > input.length()) {
161 d->lastIndex = 0;
162 return false;
163 }
164
165 int position;
166 int length = 0;
167 regExpConstructor->performMatch(d->regExp.get(), input, static_cast<int>(d->lastIndex), position, length);
168 if (position < 0) {
169 d->lastIndex = 0;
170 return false;
171 }
172
173 d->lastIndex = position + length;
174 return true;
175}
176
177} // namespace JSC
Note: See TracBrowser for help on using the repository browser.