: exec->dynamicInterpreter()->builtinObjectPrototype();
JSObject* constructor = new JSCallbackConstructor(exec, jsClass, callAsConstructor);
- constructor->put(exec, prototypePropertyName, jsPrototype, DontEnum|DontDelete|ReadOnly);
+ constructor->put(exec, exec->propertyNames().prototype, jsPrototype, DontEnum|DontDelete|ReadOnly);
return toRef(constructor);
}
kjs/array_object.cpp
kjs/bool_object.cpp
kjs/collector.cpp
+ kjs/CommonIdentifiers.cpp
kjs/Context.cpp
kjs/date_object.cpp
kjs/debugger.cpp
+2007-03-18 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Mark.
+
+ - avoid static construction (and global variable access) in a smarter, more portable way,
+ to later enable MUTLI_THREAD mode to work on other platforms and compilers.
+
+ * kjs/CommonIdentifiers.cpp: Added. New class to hold all the shared identifiers.
+ (KJS::CommonIdentifiers::CommonIdentifiers):
+ (KJS::CommonIdentifiers::shared):
+ * kjs/CommonIdentifiers.h: Added.
+
+ * kjs/ExecState.h:
+ (KJS::ExecState::propertyNames): Hand the CommonIdentifiers instance here for easy access.
+ (KJS::ExecState::ExecState):
+
+ * API/JSObjectRef.cpp:
+ (JSObjectMakeConstructor):
+ * CMakeLists.txt:
+ * JavaScriptCore.exp:
+ * JavaScriptCore.pri:
+ * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
+ * JavaScriptCore.xcodeproj/project.pbxproj:
+ * JavaScriptCoreSources.bkl:
+ * bindings/runtime_array.cpp:
+ (RuntimeArray::getOwnPropertySlot):
+ (RuntimeArray::put):
+ * bindings/runtime_method.cpp:
+ (RuntimeMethod::getOwnPropertySlot):
+ * kjs/array_object.cpp:
+ (ArrayInstance::getOwnPropertySlot):
+ (ArrayInstance::put):
+ (ArrayInstance::deleteProperty):
+ (ArrayProtoFunc::ArrayProtoFunc):
+ (ArrayProtoFunc::callAsFunction):
+ (ArrayObjectImp::ArrayObjectImp):
+ * kjs/bool_object.cpp:
+ (BooleanPrototype::BooleanPrototype):
+ (BooleanProtoFunc::BooleanProtoFunc):
+ (BooleanProtoFunc::callAsFunction):
+ (BooleanObjectImp::BooleanObjectImp):
+ * kjs/completion.h:
+ (KJS::Completion::Completion):
+ * kjs/date_object.cpp:
+ (KJS::DateProtoFunc::DateProtoFunc):
+ (KJS::DateObjectImp::DateObjectImp):
+ (KJS::DateObjectFuncImp::DateObjectFuncImp):
+ * kjs/error_object.cpp:
+ (ErrorPrototype::ErrorPrototype):
+ (ErrorProtoFunc::ErrorProtoFunc):
+ (ErrorProtoFunc::callAsFunction):
+ (ErrorObjectImp::ErrorObjectImp):
+ (ErrorObjectImp::construct):
+ (NativeErrorPrototype::NativeErrorPrototype):
+ (NativeErrorImp::NativeErrorImp):
+ (NativeErrorImp::construct):
+ (NativeErrorImp::callAsFunction):
+ * kjs/function.cpp:
+ (KJS::FunctionImp::getOwnPropertySlot):
+ (KJS::FunctionImp::put):
+ (KJS::FunctionImp::deleteProperty):
+ (KJS::FunctionImp::getParameterName):
+ (KJS::DeclaredFunctionImp::construct):
+ (KJS::IndexToNameMap::unMap):
+ (KJS::Arguments::Arguments):
+ (KJS::ActivationImp::getOwnPropertySlot):
+ (KJS::ActivationImp::deleteProperty):
+ (KJS::GlobalFuncImp::GlobalFuncImp):
+ * kjs/function_object.cpp:
+ (FunctionPrototype::FunctionPrototype):
+ (FunctionProtoFunc::FunctionProtoFunc):
+ (FunctionProtoFunc::callAsFunction):
+ (FunctionObjectImp::FunctionObjectImp):
+ (FunctionObjectImp::construct):
+ * kjs/grammar.y:
+ * kjs/identifier.cpp:
+ * kjs/identifier.h:
+ * kjs/interpreter.cpp:
+ (KJS::Interpreter::init):
+ (KJS::Interpreter::initGlobalObject):
+ * kjs/interpreter.h:
+ * kjs/lookup.h:
+ * kjs/math_object.cpp:
+ (MathFuncImp::MathFuncImp):
+ * kjs/nodes.cpp:
+ (ArrayNode::evaluate):
+ (FuncDeclNode::processFuncDecl):
+ (FuncExprNode::evaluate):
+ * kjs/number_object.cpp:
+ (NumberPrototype::NumberPrototype):
+ (NumberProtoFunc::NumberProtoFunc):
+ (NumberObjectImp::NumberObjectImp):
+ * kjs/object.cpp:
+ (KJS::JSObject::put):
+ (KJS::JSObject::defaultValue):
+ (KJS::JSObject::hasInstance):
+ * kjs/object.h:
+ (KJS::JSObject::getOwnPropertySlot):
+ * kjs/object_object.cpp:
+ (ObjectPrototype::ObjectPrototype):
+ (ObjectProtoFunc::ObjectProtoFunc):
+ (ObjectObjectImp::ObjectObjectImp):
+ * kjs/regexp_object.cpp:
+ (RegExpPrototype::RegExpPrototype):
+ (RegExpProtoFunc::RegExpProtoFunc):
+ (RegExpObjectImp::RegExpObjectImp):
+ * kjs/string_object.cpp:
+ (KJS::StringInstance::getOwnPropertySlot):
+ (KJS::StringInstance::put):
+ (KJS::StringInstance::deleteProperty):
+ (KJS::StringPrototype::StringPrototype):
+ (KJS::StringProtoFunc::StringProtoFunc):
+ (KJS::StringProtoFunc::callAsFunction):
+ (KJS::StringObjectImp::StringObjectImp):
+ (KJS::StringObjectFuncImp::StringObjectFuncImp):
+ * kjs/testkjs.cpp:
+ (TestFunctionImp::TestFunctionImp):
+
2007-03-18 Andrew Wellington <proton@wiretapped.net>
Reviewed by Mark Rowe
__ZN3KJS16RuntimeObjectImp4infoE
__ZN3KJS16RuntimeObjectImpC1EPNS_8Bindings8InstanceE
__ZN3KJS17PropertyNameArray3addERKNS_10IdentifierE
-__ZN3KJS18lengthPropertyNameE
__ZN3KJS19InternalFunctionImp4infoE
__ZN3KJS19InternalFunctionImpC2EPNS_17FunctionPrototypeERKNS_10IdentifierE
-__ZN3KJS19messagePropertyNameE
-__ZN3KJS21prototypePropertyNameE
__ZN3KJS4List6appendEPNS_7JSValueE
__ZN3KJS4List7releaseEv
__ZN3KJS4ListC1Ev
kjs/array_object.cpp \
kjs/bool_object.cpp \
kjs/collector.cpp \
+ kjs/CommonIdentifiers.cpp \
kjs/Context.cpp \
kjs/date_object.cpp \
kjs/debugger.cpp \
RelativePath="..\..\kjs\completion.h"
>
</File>
+ <File
+ RelativePath="..\..\kjs\CommonIdentifiers.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\kjs\CommonIdentifiers.h"
+ >
+ </File>
<File
RelativePath="..\..\kjs\config.h"
>
65E217C008E7EECC0023E5F6 /* FastMalloc.h in Headers */ = {isa = PBXBuildFile; fileRef = 65E217BA08E7EECC0023E5F6 /* FastMalloc.h */; settings = {ATTRIBUTES = (Private, ); }; };
65EA4C9B092AF9E20093D800 /* JSLock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65EA4C99092AF9E20093D800 /* JSLock.cpp */; };
65EA4C9C092AF9E20093D800 /* JSLock.h in Headers */ = {isa = PBXBuildFile; fileRef = 65EA4C9A092AF9E20093D800 /* JSLock.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 65EA73640BAE35D1001BB560 /* CommonIdentifiers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65EA73620BAE35D1001BB560 /* CommonIdentifiers.cpp */; };
+ 65EA73650BAE35D1001BB560 /* CommonIdentifiers.h in Headers */ = {isa = PBXBuildFile; fileRef = 65EA73630BAE35D1001BB560 /* CommonIdentifiers.h */; settings = {ATTRIBUTES = (Private, ); }; };
65FB3EB309D109F000F49DEB /* lexer.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 65FB3EB209D109F000F49DEB /* lexer.lut.h */; };
65FB3F4F09D11B2400F49DEB /* date_object.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 65FB3F4709D11B2400F49DEB /* date_object.lut.h */; };
65FB3F5009D11B2400F49DEB /* grammar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65FB3F4809D11B2400F49DEB /* grammar.cpp */; };
65E217BA08E7EECC0023E5F6 /* FastMalloc.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = FastMalloc.h; sourceTree = "<group>"; tabWidth = 8; };
65EA4C99092AF9E20093D800 /* JSLock.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSLock.cpp; sourceTree = "<group>"; tabWidth = 8; };
65EA4C9A092AF9E20093D800 /* JSLock.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = JSLock.h; sourceTree = "<group>"; tabWidth = 8; };
+ 65EA73620BAE35D1001BB560 /* CommonIdentifiers.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CommonIdentifiers.cpp; sourceTree = "<group>"; };
+ 65EA73630BAE35D1001BB560 /* CommonIdentifiers.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CommonIdentifiers.h; sourceTree = "<group>"; };
65FB3EB209D109F000F49DEB /* lexer.lut.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = lexer.lut.h; sourceTree = "<group>"; };
65FB3F4709D11B2400F49DEB /* date_object.lut.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = date_object.lut.h; sourceTree = "<group>"; };
65FB3F4809D11B2400F49DEB /* grammar.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = grammar.cpp; sourceTree = "<group>"; };
isa = PBXGroup;
children = (
65C7A1710A8EAACB00FA37EA /* JSWrapperObject.cpp */,
+ 65EA73620BAE35D1001BB560 /* CommonIdentifiers.cpp */,
+ 65EA73630BAE35D1001BB560 /* CommonIdentifiers.h */,
65C7A1720A8EAACB00FA37EA /* JSWrapperObject.h */,
65400C0F0A69BAF200509887 /* PropertyNameArray.cpp */,
65400C100A69BAF200509887 /* PropertyNameArray.h */,
E11D51760B2E798D0056C188 /* StringExtras.h in Headers */,
146AAB2B0B66A84900E55F16 /* JSStringRefCF.h in Headers */,
657EB7460B708F540063461B /* ListHashSet.h in Headers */,
+ 65EA73650BAE35D1001BB560 /* CommonIdentifiers.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
D212022A0AD4310D00ED79B6 /* DateMath.cpp in Sources */,
146AAB380B66A94400E55F16 /* JSStringRefCF.cpp in Sources */,
9302043B0B790750000C6115 /* FastMallocPCRE.cpp in Sources */,
+ 65EA73640BAE35D1001BB560 /* CommonIdentifiers.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
<makefile>
<set append="1" var="JSCORE_SOURCES_KJS">
DerivedSources/JavaScriptCore/grammar.cpp
+ kjs/CommonIdentifiers.cpp
kjs/Context.cpp
kjs/DateMath.cpp
kjs/ExecState.cpp
return thisObj->getConcreteArray()->valueAt(exec, slot.index());
}
-bool RuntimeArray::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
+bool RuntimeArray::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
- if (propertyName == lengthPropertyName) {
+ if (propertyName == exec->propertyNames().length) {
slot.setCustom(this, lengthGetter);
return true;
}
return ArrayInstance::getOwnPropertySlot(exec, index, slot);
}
-void RuntimeArray::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
+void RuntimeArray::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
{
- if (propertyName == lengthPropertyName) {
+ if (propertyName == exec->propertyNames().length) {
throwError(exec, RangeError);
return;
}
return jsNumber(thisObj->_methodList.methodAt(0)->numParameters());
}
-bool RuntimeMethod::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot)
+bool RuntimeMethod::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot &slot)
{
- if (propertyName == lengthPropertyName) {
+ if (propertyName == exec->propertyNames().length) {
slot.setCustom(this, lengthGetter);
return true;
}
--- /dev/null
+/*
+ * Copyright (C) 2003, 2007 Apple Computer, Inc
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "CommonIdentifiers.h"
+
+namespace KJS {
+
+const char* const nullCString = 0;
+
+#define INITIALIZE_PROPERTY_NAME(name) , name ( #name )
+
+CommonIdentifiers::CommonIdentifiers()
+ : nullIdentifier(nullCString)
+ , underscoreProto("__proto__")
+ KJS_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(INITIALIZE_PROPERTY_NAME)
+{
+}
+
+CommonIdentifiers* CommonIdentifiers::shared()
+{
+ static CommonIdentifiers* sharedInstance;
+ if (!sharedInstance) {
+ JSLock lock;
+ sharedInstance = new CommonIdentifiers;
+ }
+ return sharedInstance;
+}
+
+} // namespace KJS
--- /dev/null
+/*
+ * Copyright (C) 2003,2007 Apple Computer, Inc
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef KJS_COMMON_IDENTIFIERS_H
+#define KJS_COMMON_IDENTIFIERS_H
+
+#include "identifier.h"
+#include <wtf/Noncopyable.h>
+
+// List of property names, passed to a macro so we can do set them up various
+// ways without repeating the list.
+#define KJS_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(macro) \
+ macro(arguments) \
+ macro(callee) \
+ macro(caller) \
+ macro(constructor) \
+ macro(fromCharCode) \
+ macro(length) \
+ macro(message) \
+ macro(name) \
+ macro(prototype) \
+ macro(toLocaleString) \
+ macro(toString) \
+ macro(toFixed) \
+ macro(toExponential) \
+ macro(toPrecision) \
+ macro(valueOf)
+
+namespace KJS {
+
+ class CommonIdentifiers : Noncopyable {
+
+ private:
+ CommonIdentifiers();
+
+ public:
+ static CommonIdentifiers* shared();
+
+ const Identifier nullIdentifier;
+ const Identifier underscoreProto;
+
+#define KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL(name) const Identifier name;
+ KJS_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL)
+#undef KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL
+ };
+} // namespace KJS
+
+#endif // KJS_COMMON_IDENTIFIERS_H
+
#include "value.h"
#include "types.h"
+#include "CommonIdentifiers.h"
namespace KJS {
class Context;
JSValue** exceptionSlot() { return &m_exception; }
bool hadException() const { return !!m_exception; }
+ // This is a workaround to avoid accessing the global variables for these identifiers in
+ // important property lookup functions, to avoid taking PIC branches in Mach-O binaries
+ const CommonIdentifiers& propertyNames() const { return *m_propertyNames; }
+
private:
ExecState(Interpreter* interp, Context* con)
: m_interpreter(interp)
, m_context(con)
, m_exception(0)
+ , m_propertyNames(CommonIdentifiers::shared())
{
}
Interpreter* m_interpreter;
Context* m_context;
JSValue* m_exception;
+ CommonIdentifiers* m_propertyNames;
};
} // namespace KJS
bool ArrayInstance::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
- if (propertyName == lengthPropertyName) {
+ if (propertyName == exec->propertyNames().length) {
slot.setCustom(this, lengthGetter);
return true;
}
}
// Special implementation of [[Put]] - see ECMA 15.4.5.1
-void ArrayInstance::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
+void ArrayInstance::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
{
- if (propertyName == lengthPropertyName) {
+ if (propertyName == exec->propertyNames().length) {
unsigned int newLen = value->toUInt32(exec);
if (value->toNumber(exec) != double(newLen)) {
throwError(exec, RangeError, "Invalid array length.");
JSObject::put(exec, Identifier::from(index), value, attr);
}
-bool ArrayInstance::deleteProperty(ExecState *exec, const Identifier &propertyName)
+bool ArrayInstance::deleteProperty(ExecState* exec, const Identifier &propertyName)
{
- if (propertyName == lengthPropertyName)
+ if (propertyName == exec->propertyNames().length)
return false;
bool ok;
// ------------------------------ ArrayProtoFunc ----------------------------
-ArrayProtoFunc::ArrayProtoFunc(ExecState *exec, int i, int len, const Identifier& name)
+ArrayProtoFunc::ArrayProtoFunc(ExecState* exec, int i, int len, const Identifier& name)
: InternalFunctionImp(static_cast<FunctionPrototype*>
(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
, id(i)
{
- put(exec,lengthPropertyName,jsNumber(len),DontDelete|ReadOnly|DontEnum);
+ put(exec, exec->propertyNames().length, jsNumber(len), DontDelete | ReadOnly | DontEnum);
}
static JSValue *getProperty(ExecState *exec, JSObject *obj, unsigned index)
}
// ECMA 15.4.4
-JSValue *ArrayProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
+JSValue* ArrayProtoFunc::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
{
- unsigned length = thisObj->get(exec,lengthPropertyName)->toUInt32(exec);
+ unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
JSValue *result = 0; // work around gcc 4.0 bug in uninitialized variable warning
bool fallback = false;
if (id == ToLocaleString) {
JSObject* o = element->toObject(exec);
- JSValue* conversionFunction = o->get(exec, toLocaleStringPropertyName);
+ JSValue* conversionFunction = o->get(exec, exec->propertyNames().toLocaleString);
if (conversionFunction->isObject() && static_cast<JSObject*>(conversionFunction)->implementsCall())
str += static_cast<JSObject*>(conversionFunction)->call(exec, o, List())->toString(exec);
else
unsigned int k = 0;
// Older versions tried to optimize out getting the length of thisObj
// by checking for n != 0, but that doesn't work if thisObj is an empty array.
- length = curObj->get(exec,lengthPropertyName)->toUInt32(exec);
+ length = curObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
while (k < length) {
if (JSValue *v = getProperty(exec, curObj, k))
arr->put(exec, n, v);
curArg = *it;
curObj = static_cast<JSObject *>(it++); // may be 0
}
- arr->put(exec,lengthPropertyName, jsNumber(n), DontEnum | DontDelete);
+ arr->put(exec, exec->propertyNames().length, jsNumber(n), DontEnum | DontDelete);
result = arr;
break;
}
case Pop:{
if (length == 0) {
- thisObj->put(exec, lengthPropertyName, jsNumber(length), DontEnum | DontDelete);
+ thisObj->put(exec, exec->propertyNames().length, jsNumber(length), DontEnum | DontDelete);
result = jsUndefined();
} else {
result = thisObj->get(exec, length - 1);
- thisObj->put(exec, lengthPropertyName, jsNumber(length - 1), DontEnum | DontDelete);
+ thisObj->put(exec, exec->propertyNames().length, jsNumber(length - 1), DontEnum | DontDelete);
}
break;
}
for (int n = 0; n < args.size(); n++)
thisObj->put(exec, length + n, args[n]);
length += args.size();
- thisObj->put(exec,lengthPropertyName, jsNumber(length), DontEnum | DontDelete);
+ thisObj->put(exec, exec->propertyNames().length, jsNumber(length), DontEnum | DontDelete);
result = jsNumber(length);
break;
}
}
case Shift: {
if (length == 0) {
- thisObj->put(exec, lengthPropertyName, jsNumber(length), DontEnum | DontDelete);
+ thisObj->put(exec, exec->propertyNames().length, jsNumber(length), DontEnum | DontDelete);
result = jsUndefined();
} else {
result = thisObj->get(exec, 0);
thisObj->deleteProperty(exec, k-1);
}
thisObj->deleteProperty(exec, length - 1);
- thisObj->put(exec, lengthPropertyName, jsNumber(length - 1), DontEnum | DontDelete);
+ thisObj->put(exec, exec->propertyNames().length, jsNumber(length - 1), DontEnum | DontDelete);
}
break;
}
if (JSValue *v = getProperty(exec, thisObj, k))
resObj->put(exec, n, v);
}
- resObj->put(exec, lengthPropertyName, jsNumber(n), DontEnum | DontDelete);
+ resObj->put(exec, exec->propertyNames().length, jsNumber(n), DontEnum | DontDelete);
break;
}
case Sort:{
}
if (length == 0) {
- thisObj->put(exec, lengthPropertyName, jsNumber(0), DontEnum | DontDelete);
+ thisObj->put(exec, exec->propertyNames().length, jsNumber(0), DontEnum | DontDelete);
result = thisObj;
break;
}
if (JSValue *v = getProperty(exec, thisObj, k+begin))
resObj->put(exec, k, v);
}
- resObj->put(exec, lengthPropertyName, jsNumber(deleteCount), DontEnum | DontDelete);
+ resObj->put(exec, exec->propertyNames().length, jsNumber(deleteCount), DontEnum | DontDelete);
unsigned int additionalArgs = maxInt( args.size() - 2, 0 );
if ( additionalArgs != deleteCount )
{
thisObj->put(exec, k+begin, args[k+2]);
}
- thisObj->put(exec, lengthPropertyName, jsNumber(length - deleteCount + additionalArgs), DontEnum | DontDelete);
+ thisObj->put(exec, exec->propertyNames().length, jsNumber(length - deleteCount + additionalArgs), DontEnum | DontDelete);
break;
}
case UnShift: { // 15.4.4.13
for ( unsigned int k = 0; k < nrArgs; ++k )
thisObj->put(exec, k, args[k]);
result = jsNumber(length + nrArgs);
- thisObj->put(exec, lengthPropertyName, result, DontEnum | DontDelete);
+ thisObj->put(exec, exec->propertyNames().length, result, DontEnum | DontDelete);
break;
}
case Filter:
: InternalFunctionImp(funcProto)
{
// ECMA 15.4.3.1 Array.prototype
- put(exec, prototypePropertyName, arrayProto, DontEnum|DontDelete|ReadOnly);
+ put(exec, exec->propertyNames().prototype, arrayProto, DontEnum|DontDelete|ReadOnly);
// no. of arguments for constructor
- put(exec, lengthPropertyName, jsNumber(1), ReadOnly|DontDelete|DontEnum);
+ put(exec, exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
}
bool ArrayObjectImp::implementsConstruct() const
{
// The constructor will be added later by Interpreter::Interpreter()
- putDirectFunction(new BooleanProtoFunc(exec, funcProto, BooleanProtoFunc::ToString, 0, toStringPropertyName), DontEnum);
- putDirectFunction(new BooleanProtoFunc(exec, funcProto, BooleanProtoFunc::ValueOf, 0, valueOfPropertyName), DontEnum);
+ putDirectFunction(new BooleanProtoFunc(exec, funcProto, BooleanProtoFunc::ToString, 0, exec->propertyNames().toString), DontEnum);
+ putDirectFunction(new BooleanProtoFunc(exec, funcProto, BooleanProtoFunc::ValueOf, 0, exec->propertyNames().valueOf), DontEnum);
setInternalValue(jsBoolean(false));
}
// ------------------------------ BooleanProtoFunc --------------------------
-BooleanProtoFunc::BooleanProtoFunc(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
+BooleanProtoFunc::BooleanProtoFunc(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
: InternalFunctionImp(funcProto, name)
, id(i)
{
- putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
+ putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum);
}
// ECMA 15.6.4.2 + 15.6.4.3
-JSValue *BooleanProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &/*args*/)
+JSValue *BooleanProtoFunc::callAsFunction(ExecState* exec, JSObject *thisObj, const List &/*args*/)
{
// no generic function. "this" has to be a Boolean object
if (!thisObj->inherits(&BooleanInstance::info))
// ------------------------------ BooleanObjectImp -----------------------------
-BooleanObjectImp::BooleanObjectImp(ExecState*, FunctionPrototype* funcProto, BooleanPrototype* booleanProto)
+BooleanObjectImp::BooleanObjectImp(ExecState* exec, FunctionPrototype* funcProto, BooleanPrototype* booleanProto)
: InternalFunctionImp(funcProto)
{
- putDirect(prototypePropertyName, booleanProto, DontEnum|DontDelete|ReadOnly);
+ putDirect(exec->propertyNames().prototype, booleanProto, DontEnum|DontDelete|ReadOnly);
// no. of arguments for constructor
- putDirect(lengthPropertyName, jsNumber(1), ReadOnly|DontDelete|DontEnum);
+ putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
}
#ifndef _KJS_COMPLETION_H_
#define _KJS_COMPLETION_H_
-#include "identifier.h"
+#include "CommonIdentifiers.h"
#include "value.h"
namespace KJS {
*/
class Completion {
public:
- Completion(ComplType c = Normal, JSValue *v = NULL, const Identifier &t = Identifier::null())
+ Completion(ComplType c = Normal, JSValue *v = NULL, const Identifier &t = CommonIdentifiers::shared()->nullIdentifier)
: comp(c), val(v), tar(t) { }
ComplType complType() const { return comp; }
// ------------------------------ DateProtoFunc -----------------------------
-DateProtoFunc::DateProtoFunc(ExecState *exec, int i, int len, const Identifier& name)
+DateProtoFunc::DateProtoFunc(ExecState* exec, int i, int len, const Identifier& name)
: InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
, id(abs(i))
, utc(i < 0)
// We use a negative ID to denote the "UTC" variant.
{
- putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
+ putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum);
}
JSValue *DateProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
static const Identifier* parsePropertyName = new Identifier("parse");
static const Identifier* UTCPropertyName = new Identifier("UTC");
- putDirect(prototypePropertyName, dateProto, DontEnum|DontDelete|ReadOnly);
+ putDirect(exec->propertyNames().prototype, dateProto, DontEnum|DontDelete|ReadOnly);
putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::Parse, 1, *parsePropertyName), DontEnum);
putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::UTC, 7, *UTCPropertyName), DontEnum);
- putDirect(lengthPropertyName, 7, ReadOnly|DontDelete|DontEnum);
+ putDirect(exec->propertyNames().length, 7, ReadOnly|DontDelete|DontEnum);
}
bool DateObjectImp::implementsConstruct() const
// ------------------------------ DateObjectFuncImp ----------------------------
-DateObjectFuncImp::DateObjectFuncImp(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
+DateObjectFuncImp::DateObjectFuncImp(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
: InternalFunctionImp(funcProto, name), id(i)
{
- putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
+ putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum);
}
// ECMA 15.9.4.2 - 3
// ------------------------------ ErrorPrototype ----------------------------
// ECMA 15.9.4
-ErrorPrototype::ErrorPrototype(ExecState *exec,
- ObjectPrototype *objectProto,
- FunctionPrototype *funcProto)
+ErrorPrototype::ErrorPrototype(ExecState* exec, ObjectPrototype* objectProto, FunctionPrototype* funcProto)
: JSObject(objectProto)
{
// The constructor will be added later in ErrorObjectImp's constructor
- put(exec, namePropertyName, jsString("Error"), DontEnum);
- put(exec, messagePropertyName, jsString("Unknown error"), DontEnum);
- putDirectFunction(new ErrorProtoFunc(exec, funcProto, toStringPropertyName), DontEnum);
+ put(exec, exec->propertyNames().name, jsString("Error"), DontEnum);
+ put(exec, exec->propertyNames().message, jsString("Unknown error"), DontEnum);
+ putDirectFunction(new ErrorProtoFunc(exec, funcProto, exec->propertyNames().toString), DontEnum);
}
// ------------------------------ ErrorProtoFunc ----------------------------
-ErrorProtoFunc::ErrorProtoFunc(ExecState*, FunctionPrototype* funcProto, const Identifier& name)
+ErrorProtoFunc::ErrorProtoFunc(ExecState* exec, FunctionPrototype* funcProto, const Identifier& name)
: InternalFunctionImp(funcProto, name)
{
- putDirect(lengthPropertyName, jsNumber(0), DontDelete|ReadOnly|DontEnum);
+ putDirect(exec->propertyNames().length, jsNumber(0), DontDelete|ReadOnly|DontEnum);
}
-JSValue *ErrorProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &/*args*/)
+JSValue* ErrorProtoFunc::callAsFunction(ExecState* exec, JSObject* thisObj, const List &/*args*/)
{
// toString()
UString s = "Error";
- JSValue *v = thisObj->get(exec, namePropertyName);
+ JSValue* v = thisObj->get(exec, exec->propertyNames().name);
if (!v->isUndefined()) {
s = v->toString(exec);
}
- v = thisObj->get(exec, messagePropertyName);
+ v = thisObj->get(exec, exec->propertyNames().message);
if (!v->isUndefined()) {
s += ": " + v->toString(exec); // Mozilla compatible format
}
// ------------------------------ ErrorObjectImp -------------------------------
-ErrorObjectImp::ErrorObjectImp(ExecState*, FunctionPrototype* funcProto, ErrorPrototype* errorProto)
+ErrorObjectImp::ErrorObjectImp(ExecState* exec, FunctionPrototype* funcProto, ErrorPrototype* errorProto)
: InternalFunctionImp(funcProto)
{
// ECMA 15.11.3.1 Error.prototype
- putDirect(prototypePropertyName, errorProto, DontEnum|DontDelete|ReadOnly);
- putDirect(lengthPropertyName, jsNumber(1), DontDelete|ReadOnly|DontEnum);
+ putDirect(exec->propertyNames().prototype, errorProto, DontEnum|DontDelete|ReadOnly);
+ putDirect(exec->propertyNames().length, jsNumber(1), DontDelete|ReadOnly|DontEnum);
//putDirect(namePropertyName, jsString(n));
}
}
// ECMA 15.9.3
-JSObject *ErrorObjectImp::construct(ExecState *exec, const List &args)
+JSObject* ErrorObjectImp::construct(ExecState* exec, const List &args)
{
- JSObject *proto = static_cast<JSObject *>(exec->lexicalInterpreter()->builtinErrorPrototype());
- JSObject *imp = new ErrorInstance(proto);
- JSObject *obj(imp);
+ JSObject* proto = static_cast<JSObject*>(exec->lexicalInterpreter()->builtinErrorPrototype());
+ JSObject* imp = new ErrorInstance(proto);
+ JSObject* obj(imp);
if (!args[0]->isUndefined())
- imp->putDirect(messagePropertyName, jsString(args[0]->toString(exec)));
+ imp->putDirect(exec->propertyNames().message, jsString(args[0]->toString(exec)));
return obj;
}
// ------------------------------ NativeErrorPrototype ----------------------
-NativeErrorPrototype::NativeErrorPrototype(ExecState*, ErrorPrototype* errorProto, ErrorType et, UString name, UString message)
+NativeErrorPrototype::NativeErrorPrototype(ExecState* exec, ErrorPrototype* errorProto, ErrorType et, UString name, UString message)
: JSObject(errorProto)
{
errType = et;
- putDirect(namePropertyName, jsString(name), 0);
- putDirect(messagePropertyName, jsString(message), 0);
+ putDirect(exec->propertyNames().name, jsString(name), 0);
+ putDirect(exec->propertyNames().message, jsString(message), 0);
}
// ------------------------------ NativeErrorImp -------------------------------
const ClassInfo NativeErrorImp::info = {"Function", &InternalFunctionImp::info, 0, 0};
-NativeErrorImp::NativeErrorImp(ExecState*, FunctionPrototype* funcProto, JSObject* prot)
+NativeErrorImp::NativeErrorImp(ExecState* exec, FunctionPrototype* funcProto, JSObject* prot)
: InternalFunctionImp(funcProto)
, proto(prot)
{
- putDirect(lengthPropertyName, jsNumber(1), DontDelete|ReadOnly|DontEnum); // ECMA 15.11.7.5
- putDirect(prototypePropertyName, proto, DontDelete|ReadOnly|DontEnum);
+ putDirect(exec->propertyNames().length, jsNumber(1), DontDelete|ReadOnly|DontEnum); // ECMA 15.11.7.5
+ putDirect(exec->propertyNames().prototype, proto, DontDelete|ReadOnly|DontEnum);
}
bool NativeErrorImp::implementsConstruct() const
return true;
}
-JSObject *NativeErrorImp::construct(ExecState *exec, const List &args)
+JSObject* NativeErrorImp::construct(ExecState* exec, const List& args)
{
- JSObject *imp = new ErrorInstance(proto);
- JSObject *obj(imp);
+ JSObject* imp = new ErrorInstance(proto);
+ JSObject* obj(imp);
if (!args[0]->isUndefined())
- imp->putDirect(messagePropertyName, jsString(args[0]->toString(exec)));
+ imp->putDirect(exec->propertyNames().message, jsString(args[0]->toString(exec)));
return obj;
}
-JSValue *NativeErrorImp::callAsFunction(ExecState *exec, JSObject* /*thisObj*/, const List &args)
+JSValue* NativeErrorImp::callAsFunction(ExecState* exec, JSObject*, const List& args)
{
- return construct(exec,args);
+ return construct(exec, args);
}
void NativeErrorImp::mark()
bool FunctionImp::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
// Find the arguments from the closest context.
- if (propertyName == exec->dynamicInterpreter()->argumentsIdentifier()) {
+ if (propertyName == exec->propertyNames().arguments) {
slot.setCustom(this, argumentsGetter);
return true;
}
// Compute length of parameters.
- if (propertyName == lengthPropertyName) {
+ if (propertyName == exec->propertyNames().length) {
slot.setCustom(this, lengthGetter);
return true;
}
- if (propertyName == callerPropertyName) {
+ if (propertyName == exec->propertyNames().caller) {
slot.setCustom(this, callerGetter);
return true;
}
void FunctionImp::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
{
- if (propertyName == exec->dynamicInterpreter()->argumentsIdentifier() || propertyName == lengthPropertyName)
+ if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length)
return;
InternalFunctionImp::put(exec, propertyName, value, attr);
}
bool FunctionImp::deleteProperty(ExecState* exec, const Identifier& propertyName)
{
- if (propertyName == exec->dynamicInterpreter()->argumentsIdentifier() || propertyName == lengthPropertyName)
+ if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length)
return false;
return InternalFunctionImp::deleteProperty(exec, propertyName);
}
Identifier FunctionImp::getParameterName(int index)
{
if (!parameters)
- return Identifier::null();
+ return CommonIdentifiers::shared()->nullIdentifier;
if (static_cast<size_t>(index) >= parameters->size())
- return Identifier::null();
+ return CommonIdentifiers::shared()->nullIdentifier;
Identifier name = parameters->at(index).name;
// Are there any subsequent parameters with the same name?
for (size_t i = index + 1; i < parameters->size(); ++i)
if (parameters->at(i).name == name)
- return Identifier::null();
+ return CommonIdentifiers::shared()->nullIdentifier;
return name;
}
JSObject* DeclaredFunctionImp::construct(ExecState* exec, const List& args)
{
JSObject* proto;
- JSValue* p = get(exec,prototypePropertyName);
+ JSValue* p = get(exec, exec->propertyNames().prototype);
if (p->isObject())
proto = static_cast<JSObject*>(p);
else
assert(indexIsNumber && indexAsNumber < size);
- _map[indexAsNumber] = Identifier::null();
+ _map[indexAsNumber] = CommonIdentifiers::shared()->nullIdentifier;
}
Identifier& IndexToNameMap::operator[](int index)
_activationObject(act),
indexToNameMap(func, args)
{
- putDirect(calleePropertyName, func, DontEnum);
- putDirect(lengthPropertyName, args.size(), DontEnum);
+ putDirect(exec->propertyNames().callee, func, DontEnum);
+ putDirect(exec->propertyNames().length, args.size(), DontEnum);
int i = 0;
ListIterator iterator = args.begin();
return true;
}
- if (propertyName == exec->dynamicInterpreter()->argumentsIdentifier()) {
+ if (propertyName == exec->propertyNames().arguments) {
slot.setCustom(this, getArgumentsGetter());
return true;
}
bool ActivationImp::deleteProperty(ExecState* exec, const Identifier& propertyName)
{
- if (propertyName == exec->dynamicInterpreter()->argumentsIdentifier())
+ if (propertyName == exec->propertyNames().arguments)
return false;
return JSObject::deleteProperty(exec, propertyName);
}
// ------------------------------ GlobalFunc -----------------------------------
-GlobalFuncImp::GlobalFuncImp(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
+GlobalFuncImp::GlobalFuncImp(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
: InternalFunctionImp(funcProto, name)
, id(i)
{
- putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
+ putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum);
}
CodeType GlobalFuncImp::codeType() const
static const Identifier* applyPropertyName = new Identifier("apply");
static const Identifier* callPropertyName = new Identifier("call");
- putDirect(lengthPropertyName, jsNumber(0), DontDelete|ReadOnly|DontEnum);
- putDirectFunction(new FunctionProtoFunc(exec, this, FunctionProtoFunc::ToString, 0, toStringPropertyName), DontEnum);
+ putDirect(exec->propertyNames().length, jsNumber(0), DontDelete | ReadOnly | DontEnum);
+ putDirectFunction(new FunctionProtoFunc(exec, this, FunctionProtoFunc::ToString, 0, exec->propertyNames().toString), DontEnum);
putDirectFunction(new FunctionProtoFunc(exec, this, FunctionProtoFunc::Apply, 2, *applyPropertyName), DontEnum);
putDirectFunction(new FunctionProtoFunc(exec, this, FunctionProtoFunc::Call, 1, *callPropertyName), DontEnum);
}
// ------------------------------ FunctionProtoFunc -------------------------
-FunctionProtoFunc::FunctionProtoFunc(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
+FunctionProtoFunc::FunctionProtoFunc(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
: InternalFunctionImp(funcProto, name)
, id(i)
{
- putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
+ putDirect(exec->propertyNames().length, len, DontDelete | ReadOnly | DontEnum);
}
-JSValue *FunctionProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
+JSValue* FunctionProtoFunc::callAsFunction(ExecState* exec, JSObject* thisObj, const List &args)
{
- JSValue *result = NULL;
+ JSValue* result = NULL;
switch (id) {
case ToString:
static_cast<JSObject *>(argArray)->inherits(&Arguments::info))) {
JSObject *argArrayObj = static_cast<JSObject *>(argArray);
- unsigned int length = argArrayObj->get(exec,lengthPropertyName)->toUInt32(exec);
+ unsigned int length = argArrayObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
for (unsigned int i = 0; i < length; i++)
applyArgs.append(argArrayObj->get(exec,i));
}
// ------------------------------ FunctionObjectImp ----------------------------
-FunctionObjectImp::FunctionObjectImp(ExecState*, FunctionPrototype* funcProto)
+FunctionObjectImp::FunctionObjectImp(ExecState* exec, FunctionPrototype* funcProto)
: InternalFunctionImp(funcProto)
{
- putDirect(prototypePropertyName, funcProto, DontEnum|DontDelete|ReadOnly);
+ putDirect(exec->propertyNames().prototype, funcProto, DontEnum|DontDelete|ReadOnly);
// no. of arguments for constructor
- putDirect(lengthPropertyName, jsNumber(1), ReadOnly|DontDelete|DontEnum);
+ putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
}
FunctionObjectImp::~FunctionObjectImp()
List consArgs;
- JSObject *objCons = exec->lexicalInterpreter()->builtinObject();
- JSObject *prototype = objCons->construct(exec,List::empty());
- prototype->put(exec, constructorPropertyName, fimp, DontEnum|DontDelete|ReadOnly);
- fimp->put(exec, prototypePropertyName, prototype, Internal|DontDelete);
+ JSObject* objCons = exec->lexicalInterpreter()->builtinObject();
+ JSObject* prototype = objCons->construct(exec,List::empty());
+ prototype->put(exec, exec->propertyNames().constructor, fimp, DontEnum|DontDelete|ReadOnly);
+ fimp->put(exec, exec->propertyNames().prototype, prototype, Internal|DontDelete);
return fimp;
}
#include "nodes.h"
#include "lexer.h"
#include "internal.h"
-
+#include "CommonIdentifiers.h"
+
// Not sure why, but yacc doesn't add this define along with the others.
#define yylloc kjsyylloc
;
TryStatement:
- TRY Block FINALLY Block { $$ = new TryNode($2, Identifier::null(), 0, $4); DBG($$, @1, @2); }
+TRY Block FINALLY Block { $$ = new TryNode($2, CommonIdentifiers::shared()->nullIdentifier, 0, $4); DBG($$, @1, @2); }
| TRY Block CATCH '(' IDENT ')' Block { $$ = new TryNode($2, *$5, $7, 0); DBG($$, @1, @2); }
| TRY Block CATCH '(' IDENT ')' Block FINALLY Block
{ $$ = new TryNode($2, *$5, $7, $9); DBG($$, @1, @2); }
;
FunctionExpr:
- FUNCTION '(' ')' FunctionBody { $$ = new FuncExprNode(Identifier::null(), $4); }
+ FUNCTION '(' ')' FunctionBody { $$ = new FuncExprNode(CommonIdentifiers::shared()->nullIdentifier, $4); }
| FUNCTION '(' FormalParameterList ')' FunctionBody
- { $$ = new FuncExprNode(Identifier::null(), $5, $3); }
+ { $$ = new FuncExprNode(CommonIdentifiers::shared()->nullIdentifier, $5, $3); }
| FUNCTION IDENT '(' ')' FunctionBody { $$ = new FuncExprNode(*$2, $5); }
| FUNCTION IDENT '(' FormalParameterList ')' FunctionBody
{ $$ = new FuncExprNode(*$2, $6, $4); }
return false;
result = new PropertyNode(new PropertyNameNode(name),
- new FuncExprNode(Identifier::null(), body, params), type);
+ new FuncExprNode(CommonIdentifiers::shared()->nullIdentifier, body, params), type);
return true;
}
*/
#include "config.h"
-// For JavaScriptCore we need to avoid having static constructors.
-// Our strategy is to declare the global objects with a different type (initialized to 0)
-// and then use placement new to initialize the global objects later. This is not completely
-// portable, and it would be good to figure out a 100% clean way that still avoids code that
-// runs at init time.
-
-#if !PLATFORM(WIN_OS) // can't get this to compile on Visual C++ yet
-#define AVOID_STATIC_CONSTRUCTORS 1
-#else
-#define AVOID_STATIC_CONSTRUCTORS 0
-#endif
-
-#if AVOID_STATIC_CONSTRUCTORS
-#define KJS_IDENTIFIER_HIDE_GLOBALS 1
-#endif
#include "identifier.h"
identifierTable().remove(r);
}
-// Global constants for property name strings.
-
-#if !AVOID_STATIC_CONSTRUCTORS
- // Define an Identifier in the normal way.
- #define DEFINE_GLOBAL(name, string) extern const Identifier name(string);
-#else
- // Define an Identifier-sized array of pointers to avoid static initialization.
- // Use an array of pointers instead of an array of char in case there is some alignment issue.
- #define DEFINE_GLOBAL(name, string) \
- void * name[(sizeof(Identifier) + sizeof(void *) - 1) / sizeof(void *)];
-#endif
-
-const char * const nullCString = 0;
-
-DEFINE_GLOBAL(nullIdentifier, nullCString)
-DEFINE_GLOBAL(specialPrototypePropertyName, "__proto__")
-
-#define DEFINE_PROPERTY_NAME_GLOBAL(name) DEFINE_GLOBAL(name ## PropertyName, #name)
-KJS_IDENTIFIER_EACH_PROPERTY_NAME_GLOBAL(DEFINE_PROPERTY_NAME_GLOBAL)
-
-void Identifier::init()
-{
-#if AVOID_STATIC_CONSTRUCTORS
- static bool initialized;
- if (!initialized) {
- // Use placement new to initialize the globals.
-
- new (&nullIdentifier) Identifier(nullCString);
- new (&specialPrototypePropertyName) Identifier("__proto__");
-
- #define PLACEMENT_NEW_PROPERTY_NAME_GLOBAL(name) new(&name ## PropertyName) Identifier(#name);
- KJS_IDENTIFIER_EACH_PROPERTY_NAME_GLOBAL(PLACEMENT_NEW_PROPERTY_NAME_GLOBAL)
-
- initialized = true;
- }
-#endif
-}
-
} // namespace KJS
class Identifier {
friend class PropertyMap;
public:
- static void init();
-
Identifier() { }
Identifier(const char* s) : _ustring(add(s)) { }
Identifier(const UChar* s, int length) : _ustring(add(s, length)) { }
unsigned toArrayIndex(bool* ok) const { return _ustring.toArrayIndex(ok); }
double toDouble() const { return _ustring.toDouble(); }
- static const Identifier& null();
-
friend bool operator==(const Identifier&, const Identifier&);
friend bool operator!=(const Identifier&, const Identifier&);
static PassRefPtr<UString::Rep> add(UString::Rep*);
};
-#ifndef KJS_IDENTIFIER_HIDE_GLOBALS
- extern const Identifier nullIdentifier;
-
- inline const Identifier& Identifier::null()
- { return nullIdentifier; }
-#endif
-
inline bool operator==(const Identifier& a, const Identifier& b)
{ return Identifier::equal(a, b); }
inline bool operator==(const Identifier& a, const char* b)
{ return Identifier::equal(a, b); }
- // List of property names, passed to a macro so we can do set them up various
- // ways without repeating the list.
- #define KJS_IDENTIFIER_EACH_PROPERTY_NAME_GLOBAL(macro) \
- macro(arguments) \
- macro(callee) \
- macro(caller) \
- macro(constructor) \
- macro(fromCharCode) \
- macro(length) \
- macro(message) \
- macro(name) \
- macro(prototype) \
- macro(toLocaleString) \
- macro(toString) \
- macro(toFixed) \
- macro(toExponential) \
- macro(toPrecision) \
- macro(valueOf)
-
- // Define external global variables for all property names above (and one more).
-#ifndef KJS_IDENTIFIER_HIDE_GLOBALS
- extern const Identifier specialPrototypePropertyName;
-
- #define KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL(name) extern const Identifier name ## PropertyName;
- KJS_IDENTIFIER_EACH_PROPERTY_NAME_GLOBAL(KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL)
- #undef KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL
-#endif
-
} // namespace KJS
#endif // KJS_IDENTIFIER_H
{
JSLock lock;
- Identifier::init();
-
m_refCount = 0;
m_timeoutTime = 0;
m_recursion = 0;
m_timeoutCheckCount = 0;
m_compatMode = NativeMode;
- m_argumentsPropertyName = &argumentsPropertyName;
- m_specialPrototypePropertyName = &specialPrototypePropertyName;
if (s_hook) {
prev = s_hook;
m_TypeError = new NativeErrorImp(&m_globalExec, m_FunctionPrototype, m_TypeErrorPrototype);
m_UriError = new NativeErrorImp(&m_globalExec, m_FunctionPrototype, m_UriErrorPrototype);
- m_FunctionPrototype->put(&m_globalExec, constructorPropertyName, m_Function, DontEnum);
- m_ObjectPrototype->put(&m_globalExec, constructorPropertyName, m_Object, DontEnum | DontDelete | ReadOnly);
- m_FunctionPrototype->put(&m_globalExec, constructorPropertyName, m_Function, DontEnum | DontDelete | ReadOnly);
- m_ArrayPrototype->put(&m_globalExec, constructorPropertyName, m_Array, DontEnum | DontDelete | ReadOnly);
- m_BooleanPrototype->put(&m_globalExec, constructorPropertyName, m_Boolean, DontEnum | DontDelete | ReadOnly);
- m_StringPrototype->put(&m_globalExec, constructorPropertyName, m_String, DontEnum | DontDelete | ReadOnly);
- m_NumberPrototype->put(&m_globalExec, constructorPropertyName, m_Number, DontEnum | DontDelete | ReadOnly);
- m_DatePrototype->put(&m_globalExec, constructorPropertyName, m_Date, DontEnum | DontDelete | ReadOnly);
- m_RegExpPrototype->put(&m_globalExec, constructorPropertyName, m_RegExp, DontEnum | DontDelete | ReadOnly);
- m_ErrorPrototype->put(&m_globalExec, constructorPropertyName, m_Error, DontEnum | DontDelete | ReadOnly);
- m_EvalErrorPrototype->put(&m_globalExec, constructorPropertyName, m_EvalError, DontEnum | DontDelete | ReadOnly);
- m_RangeErrorPrototype->put(&m_globalExec, constructorPropertyName, m_RangeError, DontEnum | DontDelete | ReadOnly);
- m_ReferenceErrorPrototype->put(&m_globalExec, constructorPropertyName, m_ReferenceError, DontEnum | DontDelete | ReadOnly);
- m_SyntaxErrorPrototype->put(&m_globalExec, constructorPropertyName, m_SyntaxError, DontEnum | DontDelete | ReadOnly);
- m_TypeErrorPrototype->put(&m_globalExec, constructorPropertyName, m_TypeError, DontEnum | DontDelete | ReadOnly);
- m_UriErrorPrototype->put(&m_globalExec, constructorPropertyName, m_UriError, DontEnum | DontDelete | ReadOnly);
+ m_FunctionPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Function, DontEnum);
+ m_ObjectPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Object, DontEnum | DontDelete | ReadOnly);
+ m_FunctionPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Function, DontEnum | DontDelete | ReadOnly);
+ m_ArrayPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Array, DontEnum | DontDelete | ReadOnly);
+ m_BooleanPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Boolean, DontEnum | DontDelete | ReadOnly);
+ m_StringPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_String, DontEnum | DontDelete | ReadOnly);
+ m_NumberPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Number, DontEnum | DontDelete | ReadOnly);
+ m_DatePrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Date, DontEnum | DontDelete | ReadOnly);
+ m_RegExpPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_RegExp, DontEnum | DontDelete | ReadOnly);
+ m_ErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Error, DontEnum | DontDelete | ReadOnly);
+ m_EvalErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_EvalError, DontEnum | DontDelete | ReadOnly);
+ m_RangeErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_RangeError, DontEnum | DontDelete | ReadOnly);
+ m_ReferenceErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_ReferenceError, DontEnum | DontDelete | ReadOnly);
+ m_SyntaxErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_SyntaxError, DontEnum | DontDelete | ReadOnly);
+ m_TypeErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_TypeError, DontEnum | DontDelete | ReadOnly);
+ m_UriErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_UriError, DontEnum | DontDelete | ReadOnly);
// Set global object prototype
JSObject* o = m_globalObject;
*/
virtual bool isSafeScript(const Interpreter*) { return true; }
- // This is a workaround to avoid accessing the global variables for these identifiers in
- // important property lookup functions, to avoid taking PIC branches in Mach-O binaries
- const Identifier& argumentsIdentifier() { return *m_argumentsPropertyName; }
- const Identifier& specialPrototypeIdentifier() { return *m_specialPrototypePropertyName; }
-
// Chained list of interpreters (ring)
static Interpreter* firstInterpreter() { return s_hook; }
Interpreter* nextInterpreter() const { return next; }
ExecState m_globalExec;
- const Identifier *m_argumentsPropertyName;
- const Identifier *m_specialPrototypePropertyName;
-
// Chained list of interpreters (ring) - for collector
static Interpreter* s_hook;
Interpreter *next, *prev;
: InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name) \
, id(i) \
{ \
- put(exec, lengthPropertyName, jsNumber(len), DontDelete|ReadOnly|DontEnum); \
+ put(exec, exec->propertyNames().length, jsNumber(len), DontDelete|ReadOnly|DontEnum); \
} \
/* Macro user needs to implement the callAsFunction function. */ \
virtual JSValue* callAsFunction(ExecState* exec, JSObject* thisObj, const List& args); \
: InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
, id(i)
{
- putDirect(lengthPropertyName, l, DontDelete|ReadOnly|DontEnum);
+ putDirect(exec->propertyNames().length, l, DontDelete|ReadOnly|DontEnum);
}
JSValue *MathFuncImp::callAsFunction(ExecState *exec, JSObject* /*thisObj*/, const List &args)
if (element) {
array = static_cast<JSObject*>(element->evaluate(exec));
KJS_CHECKEXCEPTIONVALUE
- length = opt ? array->get(exec,lengthPropertyName)->toInt32(exec) : 0;
+ length = opt ? array->get(exec, exec->propertyNames().length)->toInt32(exec) : 0;
} else {
JSValue *newArr = exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty());
array = static_cast<JSObject*>(newArr);
}
if (opt)
- array->put(exec,lengthPropertyName, jsNumber(elision + length), DontEnum | DontDelete);
+ array->put(exec, exec->propertyNames().length, jsNumber(elision + length), DontEnum | DontDelete);
return array;
}
FunctionImp *func = new DeclaredFunctionImp(exec, ident, body.get(), context->scopeChain());
JSObject *proto = exec->lexicalInterpreter()->builtinObject()->construct(exec, List::empty());
- proto->put(exec, constructorPropertyName, func, ReadOnly|DontDelete|DontEnum);
- func->put(exec, prototypePropertyName, proto, Internal|DontDelete);
+ proto->put(exec, exec->propertyNames().constructor, func, ReadOnly | DontDelete | DontEnum);
+ func->put(exec, exec->propertyNames().prototype, proto, Internal|DontDelete);
int plen = 0;
for(ParameterNode *p = param.get(); p != 0L; p = p->nextParam(), plen++)
func->addParameter(p->ident());
- func->put(exec, lengthPropertyName, jsNumber(plen), ReadOnly|DontDelete|DontEnum);
+ func->put(exec, exec->propertyNames().length, jsNumber(plen), ReadOnly|DontDelete|DontEnum);
// ECMA 10.2.2
context->variableObject()->put(exec, ident, func, Internal | (context->codeType() == EvalCode ? 0 : DontDelete));
context->pushScope(functionScopeObject);
}
- FunctionImp *func = new DeclaredFunctionImp(exec, ident, body.get(), context->scopeChain());
- JSObject *proto = exec->lexicalInterpreter()->builtinObject()->construct(exec, List::empty());
- proto->put(exec, constructorPropertyName, func, ReadOnly|DontDelete|DontEnum);
- func->put(exec, prototypePropertyName, proto, Internal|DontDelete);
+ FunctionImp* func = new DeclaredFunctionImp(exec, ident, body.get(), context->scopeChain());
+ JSObject* proto = exec->lexicalInterpreter()->builtinObject()->construct(exec, List::empty());
+ proto->put(exec, exec->propertyNames().constructor, func, ReadOnly | DontDelete | DontEnum);
+ func->put(exec, exec->propertyNames().prototype, proto, Internal | DontDelete);
int plen = 0;
for(ParameterNode *p = param.get(); p != 0L; p = p->nextParam(), plen++)
// The constructor will be added later, after NumberObjectImp has been constructed
- putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToString, 1, toStringPropertyName), DontEnum);
- putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToLocaleString, 0, toLocaleStringPropertyName), DontEnum);
- putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ValueOf, 0, valueOfPropertyName), DontEnum);
- putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToFixed, 1, toFixedPropertyName), DontEnum);
- putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToExponential, 1, toExponentialPropertyName), DontEnum);
- putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToPrecision, 1, toPrecisionPropertyName), DontEnum);
+ putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToString, 1, exec->propertyNames().toString), DontEnum);
+ putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToLocaleString, 0, exec->propertyNames().toLocaleString), DontEnum);
+ putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ValueOf, 0, exec->propertyNames().valueOf), DontEnum);
+ putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToFixed, 1, exec->propertyNames().toFixed), DontEnum);
+ putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToExponential, 1, exec->propertyNames().toExponential), DontEnum);
+ putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToPrecision, 1, exec->propertyNames().toPrecision), DontEnum);
}
// ------------------------------ NumberProtoFunc ---------------------------
-NumberProtoFunc::NumberProtoFunc(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
+NumberProtoFunc::NumberProtoFunc(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
: InternalFunctionImp(funcProto, name)
, id(i)
{
- putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
+ putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum);
}
static UString integer_part_noexp(double d)
MIN_VALUE NumberObjectImp::MinValue DontEnum|DontDelete|ReadOnly
@end
*/
-NumberObjectImp::NumberObjectImp(ExecState*, FunctionPrototype* funcProto, NumberPrototype* numberProto)
+NumberObjectImp::NumberObjectImp(ExecState* exec, FunctionPrototype* funcProto, NumberPrototype* numberProto)
: InternalFunctionImp(funcProto)
{
// Number.Prototype
- putDirect(prototypePropertyName, numberProto,DontEnum|DontDelete|ReadOnly);
+ putDirect(exec->propertyNames().prototype, numberProto,DontEnum|DontDelete|ReadOnly);
// no. of arguments for constructor
- putDirect(lengthPropertyName, jsNumber(1), ReadOnly|DontDelete|DontEnum);
+ putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
}
bool NumberObjectImp::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
}
// ECMA 8.6.2.2
-void JSObject::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
+void JSObject::put(ExecState* exec, const Identifier &propertyName, JSValue *value, int attr)
{
assert(value);
// non-standard netscape extension
- if (propertyName == exec->dynamicInterpreter()->specialPrototypeIdentifier()) {
+ if (propertyName == exec->propertyNames().underscoreProto) {
setPrototype(value);
return;
}
}
// ECMA 8.6.2.6
-JSValue *JSObject::defaultValue(ExecState *exec, JSType hint) const
+JSValue* JSObject::defaultValue(ExecState* exec, JSType hint) const
{
Identifier firstPropertyName;
Identifier secondPropertyName;
/* Prefer String for Date objects */
if ((hint == StringType) || (hint != StringType) && (hint != NumberType) && (_proto == exec->lexicalInterpreter()->builtinDatePrototype())) {
- firstPropertyName = toStringPropertyName;
- secondPropertyName = valueOfPropertyName;
+ firstPropertyName = exec->propertyNames().toString;
+ secondPropertyName = exec->propertyNames().valueOf;
} else {
- firstPropertyName = valueOfPropertyName;
- secondPropertyName = toStringPropertyName;
+ firstPropertyName = exec->propertyNames().valueOf;
+ secondPropertyName = exec->propertyNames().toString;
}
JSValue *v;
bool JSObject::hasInstance(ExecState* exec, JSValue* value)
{
- JSValue* proto = get(exec, prototypePropertyName);
+ JSValue* proto = get(exec, exec->propertyNames().prototype);
if (!proto->isObject()) {
throwError(exec, TypeError, "intanceof called on an object with an invalid prototype property.");
return false;
#define KJS_OBJECT_H
#include "JSType.h"
+#include "CommonIdentifiers.h"
#include "interpreter.h"
#include "property_map.h"
#include "property_slot.h"
* @param propertyName The name of the property to set
* @param propertyValue The value to set
*/
- virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
- virtual void put(ExecState *exec, unsigned propertyName, JSValue *value, int attr = None);
+ virtual void put(ExecState* exec, const Identifier &propertyName, JSValue* value, int attr = None);
+ virtual void put(ExecState* exec, unsigned propertyName, JSValue* value, int attr = None);
/**
* Used to check whether or not a particular property is allowed to be set
// It may seem crazy to inline a function this large, especially a virtual function,
// but it makes a big difference to property lookup that derived classes can inline their
// base class call to this.
-ALWAYS_INLINE bool JSObject::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
+ALWAYS_INLINE bool JSObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
if (JSValue **location = getDirectLocation(propertyName)) {
if (_prop.hasGetterSetterProperties() && location[0]->type() == GetterSetterType)
}
// non-standard Netscape extension
- if (propertyName == exec->dynamicInterpreter()->specialPrototypeIdentifier()) {
+ if (propertyName == exec->propertyNames().underscoreProto) {
slot.setValueSlot(this, &_proto);
return true;
}
static const Identifier* lookupGetterPropertyName = new Identifier("__lookupGetter__");
static const Identifier* lookupSetterPropertyName = new Identifier("__lookupSetter__");
- putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::ToString, 0, toStringPropertyName), DontEnum);
- putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::ToLocaleString, 0, toLocaleStringPropertyName), DontEnum);
- putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::ValueOf, 0, valueOfPropertyName), DontEnum);
+ putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::ToString, 0, exec->propertyNames().toString), DontEnum);
+ putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::ToLocaleString, 0, exec->propertyNames().toLocaleString), DontEnum);
+ putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::ValueOf, 0, exec->propertyNames().valueOf), DontEnum);
putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::HasOwnProperty, 1, *hasOwnPropertyPropertyName), DontEnum);
putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::PropertyIsEnumerable, 1, *propertyIsEnumerablePropertyName), DontEnum);
putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::IsPrototypeOf, 1, *isPrototypeOfPropertyName), DontEnum);
// ------------------------------ ObjectProtoFunc --------------------------------
-ObjectProtoFunc::ObjectProtoFunc(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
+ObjectProtoFunc::ObjectProtoFunc(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
: InternalFunctionImp(funcProto, name)
, id(i)
{
- putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
+ putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum);
}
// ------------------------------ ObjectObjectImp --------------------------------
-ObjectObjectImp::ObjectObjectImp(ExecState*, ObjectPrototype* objProto, FunctionPrototype* funcProto)
+ObjectObjectImp::ObjectObjectImp(ExecState* exec, ObjectPrototype* objProto, FunctionPrototype* funcProto)
: InternalFunctionImp(funcProto)
{
// ECMA 15.2.3.1
- putDirect(prototypePropertyName, objProto, DontEnum|DontDelete|ReadOnly);
+ putDirect(exec->propertyNames().prototype, objProto, DontEnum|DontDelete|ReadOnly);
// no. of arguments for constructor
- putDirect(lengthPropertyName, jsNumber(1), ReadOnly|DontDelete|DontEnum);
+ putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
}
putDirectFunction(new RegExpProtoFunc(exec, funcProto, RegExpProtoFunc::Exec, 0, *execPropertyName), DontEnum);
putDirectFunction(new RegExpProtoFunc(exec, funcProto, RegExpProtoFunc::Test, 0, *testPropertyName), DontEnum);
- putDirectFunction(new RegExpProtoFunc(exec, funcProto, RegExpProtoFunc::ToString, 0, toStringPropertyName), DontEnum);
+ putDirectFunction(new RegExpProtoFunc(exec, funcProto, RegExpProtoFunc::ToString, 0, exec->propertyNames().toString), DontEnum);
}
// ------------------------------ RegExpProtoFunc ---------------------------
-RegExpProtoFunc::RegExpProtoFunc(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
+RegExpProtoFunc::RegExpProtoFunc(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
: InternalFunctionImp(funcProto, name), id(i)
{
- putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
+ putDirect(exec->propertyNames().length, len, DontDelete | ReadOnly | DontEnum);
}
JSValue *RegExpProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
@end
*/
-RegExpObjectImp::RegExpObjectImp(ExecState*, FunctionPrototype* funcProto, RegExpPrototype* regProto)
+RegExpObjectImp::RegExpObjectImp(ExecState* exec, FunctionPrototype* funcProto, RegExpPrototype* regProto)
: InternalFunctionImp(funcProto), lastInput(""), lastNumSubPatterns(0), multiline(false)
{
// ECMA 15.10.5.1 RegExp.prototype
- putDirect(prototypePropertyName, regProto, DontEnum|DontDelete|ReadOnly);
+ putDirect(exec->propertyNames().prototype, regProto, DontEnum | DontDelete | ReadOnly);
// no. of arguments for constructor
- putDirect(lengthPropertyName, jsNumber(2), ReadOnly|DontDelete|DontEnum);
+ putDirect(exec->propertyNames().length, jsNumber(2), ReadOnly | DontDelete | DontEnum);
}
/*
bool StringInstance::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot)
{
- if (propertyName == lengthPropertyName) {
+ if (propertyName == exec->propertyNames().length) {
slot.setCustom(this, lengthGetter);
return true;
}
void StringInstance::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
{
- if (propertyName == lengthPropertyName)
+ if (propertyName == exec->propertyNames().length)
return;
JSObject::put(exec, propertyName, value, attr);
}
bool StringInstance::deleteProperty(ExecState *exec, const Identifier &propertyName)
{
- if (propertyName == lengthPropertyName)
+ if (propertyName == exec->propertyNames().length)
return false;
return JSObject::deleteProperty(exec, propertyName);
}
@end
*/
// ECMA 15.5.4
-StringPrototype::StringPrototype(ExecState*, ObjectPrototype* objProto)
+StringPrototype::StringPrototype(ExecState* exec, ObjectPrototype* objProto)
: StringInstance(objProto)
{
// The constructor will be added later, after StringObjectImp has been built
- putDirect(lengthPropertyName, jsNumber(0), DontDelete|ReadOnly|DontEnum);
+ putDirect(exec->propertyNames().length, jsNumber(0), DontDelete | ReadOnly | DontEnum);
}
bool StringPrototype::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot)
// ------------------------------ StringProtoFunc ---------------------------
-StringProtoFunc::StringProtoFunc(ExecState *exec, int i, int len, const Identifier& name)
+StringProtoFunc::StringProtoFunc(ExecState* exec, int i, int len, const Identifier& name)
: InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
, id(i)
{
- putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
+ putDirect(exec->propertyNames().length, len, DontDelete | ReadOnly | DontEnum);
}
static inline void expandSourceRanges(UString::Range * & array, int& count, int& capacity)
}
// ECMA 15.5.4.2 - 15.5.4.20
-JSValue *StringProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
+JSValue* StringProtoFunc::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
{
- JSValue *result = NULL;
+ JSValue* result = NULL;
// toString and valueOf are no generic function.
if (id == ToString || id == ValueOf) {
RegExp *reg = static_cast<RegExpImp *>(a0)->regExp();
if (u.isEmpty() && !reg->match(u, 0).isNull()) {
// empty string matched by regexp -> empty array
- res->put(exec,lengthPropertyName, jsNumber(0));
+ res->put(exec, exec->propertyNames().length, jsNumber(0));
break;
}
pos = 0;
if (u2.isEmpty()) {
if (u.isEmpty()) {
// empty separator matches empty string -> empty array
- put(exec,lengthPropertyName, jsNumber(0));
+ put(exec, exec->propertyNames().length, jsNumber(0));
break;
} else {
while (static_cast<uint32_t>(i) != limit && i < u.size()-1)
// add remaining string, if any
if (static_cast<uint32_t>(i) != limit)
res->put(exec, i++, jsString(u.substr(p0)));
- res->put(exec,lengthPropertyName, jsNumber(i));
+ res->put(exec, exec->propertyNames().length, jsNumber(i));
}
break;
case Substr: {
// ------------------------------ StringObjectImp ------------------------------
-StringObjectImp::StringObjectImp(ExecState *exec,
- FunctionPrototype *funcProto,
- StringPrototype *stringProto)
+StringObjectImp::StringObjectImp(ExecState* exec,
+ FunctionPrototype* funcProto,
+ StringPrototype* stringProto)
: InternalFunctionImp(funcProto)
{
// ECMA 15.5.3.1 String.prototype
- putDirect(prototypePropertyName, stringProto, DontEnum|DontDelete|ReadOnly);
+ putDirect(exec->propertyNames().prototype, stringProto, DontEnum|DontDelete|ReadOnly);
- putDirectFunction(new StringObjectFuncImp(exec, funcProto, fromCharCodePropertyName), DontEnum);
+ putDirectFunction(new StringObjectFuncImp(exec, funcProto, exec->propertyNames().fromCharCode), DontEnum);
// no. of arguments for constructor
- putDirect(lengthPropertyName, jsNumber(1), ReadOnly|DontDelete|DontEnum);
+ putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
}
// ------------------------------ StringObjectFuncImp --------------------------
// ECMA 15.5.3.2 fromCharCode()
-StringObjectFuncImp::StringObjectFuncImp(ExecState*, FunctionPrototype* funcProto, const Identifier& name)
+StringObjectFuncImp::StringObjectFuncImp(ExecState* exec, FunctionPrototype* funcProto, const Identifier& name)
: InternalFunctionImp(funcProto, name)
{
- putDirect(lengthPropertyName, jsNumber(1), DontDelete|ReadOnly|DontEnum);
+ putDirect(exec->propertyNames().length, jsNumber(1), DontDelete|ReadOnly|DontEnum);
}
JSValue *StringObjectFuncImp::callAsFunction(ExecState *exec, JSObject* /*thisObj*/, const List &args)
TestFunctionImp::TestFunctionImp(int i, int length) : JSObject(), id(i)
{
- putDirect(lengthPropertyName,length,DontDelete|ReadOnly|DontEnum);
+ putDirect(Identifier("length"), length, DontDelete | ReadOnly | DontEnum);
}
JSValue* TestFunctionImp::callAsFunction(ExecState* exec, JSObject*, const List &args)
+2007-03-18 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Mark.
+
+ - avoid static construction (and global variable access) in a smarter, more portable way,
+ to later enable MUTLI_THREAD mode to work on other platforms and compilers.
+
+ * bindings/js/JSCustomXPathNSResolver.cpp:
+ (WebCore::JSCustomXPathNSResolver::lookupNamespaceURI):
+ * bindings/js/JSHTMLInputElementBase.cpp:
+ (WebCore::JSHTMLInputElementBaseFunction::JSHTMLInputElementBaseFunction):
+ * bindings/js/JSHTMLOptionElementConstructor.cpp:
+ (WebCore::JSHTMLOptionElementConstructor::JSHTMLOptionElementConstructor):
+ * bindings/js/JSXMLHttpRequest.cpp:
+ (KJS::JSXMLHttpRequestConstructorImp::JSXMLHttpRequestConstructorImp):
+ * bindings/js/JSXSLTProcessor.cpp:
+ (KJS::XSLTProcessorConstructorImp::XSLTProcessorConstructorImp):
+ * bindings/js/kjs_dom.cpp:
+ (KJS::DOMNamedNodeMap::getOwnPropertySlot):
+ (KJS::DOMNamedNodesCollection::getOwnPropertySlot):
+ * bindings/js/kjs_events.cpp:
+ (KJS::JSAbstractEventListener::handleEvent):
+ * bindings/js/kjs_html.cpp:
+ (KJS::HTMLElementFunction::HTMLElementFunction):
+ (KJS::JSHTMLCollection::getOwnPropertySlot):
+ * bindings/js/kjs_window.cpp:
+ (KJS::ScheduledAction::execute):
+ * bindings/objc/WebScriptObject.mm:
+ * bindings/scripts/CodeGeneratorJS.pm:
+
2007-03-18 Andrew Wellington <proton@wiretapped.net>
Reviewed by Mark Rowe
if (exec->hadException()) {
JSObject* exception = exec->exception()->toObject(exec);
- String message = exception->get(exec, messagePropertyName)->toString(exec);
+ String message = exception->get(exec, exec->propertyNames().message)->toString(exec);
int lineNumber = exception->get(exec, "line")->toInt32(exec);
String sourceURL = exception->get(exec, "sourceURL")->toString(exec);
if (Interpreter::shouldPrintExceptions())
: InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
, m_id(i)
{
- put(exec, lengthPropertyName, jsNumber(len), DontDelete|ReadOnly|DontEnum);
+ put(exec, exec->propertyNames().length, jsNumber(len), DontDelete|ReadOnly|DontEnum);
}
JSValue* JSHTMLInputElementBaseFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
: m_doc(d)
{
setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype());
- put(exec, lengthPropertyName, jsNumber(4), ReadOnly|DontDelete|DontEnum);
+ put(exec, exec->propertyNames().length, jsNumber(4), ReadOnly|DontDelete|DontEnum);
}
bool JSHTMLOptionElementConstructor::implementsConstruct() const
: doc(d)
{
setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype());
- putDirect(prototypePropertyName, JSXMLHttpRequestPrototype::self(exec), None);
+ putDirect(exec->propertyNames().prototype, JSXMLHttpRequestPrototype::self(exec), None);
}
bool JSXMLHttpRequestConstructorImp::implementsConstruct() const
XSLTProcessorConstructorImp::XSLTProcessorConstructorImp(ExecState *exec)
{
setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype());
- putDirect(prototypePropertyName, XSLTProcessorPrototype::self(exec), None);
+ putDirect(exec->propertyNames().prototype, XSLTProcessorPrototype::self(exec), None);
}
}
bool DOMNamedNodeMap::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
- if (propertyName == lengthPropertyName) {
+ if (propertyName == exec->propertyNames().length) {
slot.setCustom(this, lengthGetter);
return true;
} else {
bool DOMNamedNodesCollection::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
- if (propertyName == lengthPropertyName) {
+ if (propertyName == exec->propertyNames().length) {
slot.setCustom(this, lengthGetter);
return true;
}
if (exec->hadException()) {
JSObject* exception = exec->exception()->toObject(exec);
- String message = exception->get(exec, messagePropertyName)->toString(exec);
+ String message = exception->get(exec, exec->propertyNames().message)->toString(exec);
int lineNumber = exception->get(exec, "line")->toInt32(exec);
String sourceURL = exception->get(exec, "sourceURL")->toString(exec);
if (Interpreter::shouldPrintExceptions())
: InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
, id(i)
{
- put(exec,lengthPropertyName,jsNumber(len),DontDelete|ReadOnly|DontEnum);
+ put(exec, exec->propertyNames().length, jsNumber(len), DontDelete | ReadOnly | DontEnum);
}
JSValue *HTMLElementFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List &args)
bool JSHTMLCollection::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
- if (propertyName == lengthPropertyName) {
+ if (propertyName == exec->propertyNames().length) {
slot.setCustom(this, lengthGetter);
return true;
} else {
if (exec->hadException()) {
JSObject* exception = exec->exception()->toObject(exec);
exec->clearException();
- String message = exception->get(exec, messagePropertyName)->toString(exec);
+ String message = exception->get(exec, exec->propertyNames().message)->toString(exec);
int lineNumber = exception->get(exec, "line")->toInt32(exec);
if (Interpreter::shouldPrintExceptions())
printf("(timer):%s\n", message.utf8().data());
#define LOG_EXCEPTION(exec) \
if (Interpreter::shouldPrintExceptions()) \
- printf("%s:%d:[%d] JavaScript exception: %s\n", __FILE__, __LINE__, getpid(), exec->exception()->toObject(exec)->get(exec, messagePropertyName)->toString(exec).ascii());
+ printf("%s:%d:[%d] JavaScript exception: %s\n", __FILE__, __LINE__, getpid(), exec->exception()->toObject(exec)->get(exec, exec->propertyNames().message)->toString(exec).ascii());
@implementation WebScriptObjectPrivate
${className}Constructor(ExecState* exec)
{
setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype());
- putDirect(prototypePropertyName, ${protoClassName}::self(exec), None);
+ putDirect(exec->propertyNames().prototype, ${protoClassName}::self(exec), None);
}
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
JSValue* getValueProperty(ExecState*, int token) const;
: InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
, id(i)
{
- put(exec, lengthPropertyName, jsNumber(len), DontDelete|ReadOnly|DontEnum);
+ put(exec, exec->propertyNames().length, jsNumber(len), DontDelete|ReadOnly|DontEnum);
}
virtual JSValue* callAsFunction(ExecState* exec, JSObject* thisObj, const List& args);
private: