// -*- mode: c++; c-basic-offset: 4 -*-
/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
return true;
}
-ConstructType JSCallbackConstructor::getConstructData(ConstructData&)
-{
- return ConstructTypeNative;
-}
-
-JSObject* JSCallbackConstructor::construct(ExecState* exec, const ArgList &args)
+static JSObject* constructJSCallback(ExecState* exec, JSObject* constructor, const ArgList& args)
{
JSContextRef ctx = toRef(exec);
- JSObjectRef thisRef = toRef(this);
+ JSObjectRef constructorRef = toRef(constructor);
- if (m_callback) {
+ JSObjectCallAsConstructorCallback callback = static_cast<JSCallbackConstructor*>(constructor)->callback();
+ if (callback) {
int argumentCount = static_cast<int>(args.size());
Vector<JSValueRef, 16> arguments(argumentCount);
for (int i = 0; i < argumentCount; i++)
arguments[i] = toRef(args[i]);
JSLock::DropAllLocks dropAllLocks;
- return toJS(m_callback(ctx, thisRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot())));
+ return toJS(callback(ctx, constructorRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot())));
}
- return toJS(JSObjectMake(ctx, m_class, 0));
+ return toJS(JSObjectMake(ctx, static_cast<JSCallbackConstructor*>(constructor)->classRef(), 0));
+}
+
+ConstructType JSCallbackConstructor::getConstructData(ConstructData& constructData)
+{
+ constructData.native.function = constructJSCallback;
+ return ConstructTypeNative;
}
} // namespace KJS
// -*- mode: c++; c-basic-offset: 4 -*-
/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
class JSCallbackConstructor : public JSObject {
public:
- JSCallbackConstructor(ExecState* exec, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback);
+ JSCallbackConstructor(ExecState*, JSClassRef, JSObjectCallAsConstructorCallback);
virtual ~JSCallbackConstructor();
-
- virtual bool implementsHasInstance() const;
-
- virtual ConstructType getConstructData(ConstructData&);
- virtual JSObject* construct(ExecState*, const ArgList& args);
-
- virtual const ClassInfo *classInfo() const { return &info; }
+ JSClassRef classRef() const { return m_class; }
+ JSObjectCallAsConstructorCallback callback() const { return m_callback; }
static const ClassInfo info;
private:
- JSCallbackConstructor(); // prevent default construction
- JSCallbackConstructor(const JSCallbackConstructor&);
+ virtual bool implementsHasInstance() const;
+ virtual ConstructType getConstructData(ConstructData&);
+ virtual const ClassInfo* classInfo() const { return &info; }
JSClassRef m_class;
JSObjectCallAsConstructorCallback m_callback;
// -*- mode: c++; c-basic-offset: 4 -*-
/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
// InternalFunction mish-mashes constructor and function behavior -- we should
// refactor the code so this override isn't necessary
-bool JSCallbackFunction::implementsHasInstance() const {
+bool JSCallbackFunction::implementsHasInstance() const
+{
return false;
}
-JSValue* JSCallbackFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const ArgList &args)
+JSValue* JSCallbackFunction::call(ExecState* exec, JSObject* functionObject, JSValue* thisValue, const ArgList& args)
{
JSContextRef execRef = toRef(exec);
- JSObjectRef thisRef = toRef(this);
- JSObjectRef thisObjRef = toRef(thisObj);
+ JSObjectRef functionRef = toRef(functionObject);
+ JSObjectRef thisObjRef = toRef(thisValue->toThisObject(exec));
int argumentCount = static_cast<int>(args.size());
Vector<JSValueRef, 16> arguments(argumentCount);
arguments[i] = toRef(args[i]);
JSLock::DropAllLocks dropAllLocks;
- return toJS(m_callback(execRef, thisRef, thisObjRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot())));
+ return toJS(static_cast<JSCallbackFunction*>(functionObject)->m_callback(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot())));
+}
+
+CallType JSCallbackFunction::getCallData(CallData& callData)
+{
+ callData.native.function = call;
+ return CallTypeNative;
}
} // namespace KJS
// -*- mode: c++; c-basic-offset: 4 -*-
/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#ifndef JSCallbackFunction_h
#define JSCallbackFunction_h
-#include "JSObjectRef.h"
#include "JSFunction.h"
-#include "JSObject.h"
+#include "JSObjectRef.h"
namespace KJS {
-class JSCallbackFunction : public InternalFunction
-{
+class JSCallbackFunction : public InternalFunction {
public:
- JSCallbackFunction(ExecState* exec, JSObjectCallAsFunctionCallback callback, const Identifier& name);
-
- virtual bool implementsHasInstance() const;
- virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const ArgList &args);
+ JSCallbackFunction(ExecState*, JSObjectCallAsFunctionCallback, const Identifier& name);
- virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
private:
- JSCallbackFunction(); // prevent default construction
- JSCallbackFunction(const JSCallbackFunction&);
-
+ virtual bool implementsHasInstance() const;
+ virtual CallType getCallData(CallData&);
+ virtual const ClassInfo* classInfo() const { return &info; }
+
+ static JSValue* call(ExecState*, JSObject*, JSValue*, const ArgList&);
+
JSObjectCallAsFunctionCallback m_callback;
};
// -*- mode: c++; c-basic-offset: 4 -*-
/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2007 Eric Seidel <eric@webkit.org>
*
* Redistribution and use in source and binary forms, with or without
namespace KJS {
template <class Base>
-class JSCallbackObject : public Base
-{
+class JSCallbackObject : public Base {
public:
JSCallbackObject(ExecState*, JSClassRef, JSValue* prototype, void* data);
JSCallbackObject(JSClassRef);
virtual ~JSCallbackObject();
+ void setPrivate(void* data);
+ void* getPrivate();
+
+ static const ClassInfo info;
+
+ JSClassRef classRef() const { return m_class; }
+ bool inherits(JSClassRef) const;
+
+private:
virtual UString className() const;
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
virtual bool deleteProperty(ExecState*, const Identifier&);
virtual bool deleteProperty(ExecState*, unsigned);
- virtual ConstructType getConstructData(ConstructData&);
- virtual JSObject* construct(ExecState*, const ArgList& args);
-
virtual bool implementsHasInstance() const;
virtual bool hasInstance(ExecState *exec, JSValue *value);
- virtual CallType getCallData(CallData&);
- virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const ArgList &args);
-
virtual void getPropertyNames(ExecState*, PropertyNameArray&);
virtual double toNumber(ExecState*) const;
virtual UString toString(ExecState*) const;
- void setPrivate(void* data);
- void* getPrivate();
-
- virtual const ClassInfo *classInfo() const { return &info; }
- static const ClassInfo info;
+ virtual ConstructType getConstructData(ConstructData&);
+ virtual CallType getCallData(CallData&);
+ virtual const ClassInfo* classInfo() const { return &info; }
- bool inherits(JSClassRef) const;
-
-private:
void init(ExecState*);
-
+
+ static JSValue* call(ExecState*, JSObject* functionObject, JSValue* thisValue, const ArgList&);
+ static JSObject* construct(ExecState*, JSObject* constructor, const ArgList&);
+
static JSValue* cachedValueGetter(ExecState*, const Identifier&, const PropertySlot&);
static JSValue* staticValueGetter(ExecState*, const Identifier&, const PropertySlot&);
static JSValue* staticFunctionGetter(ExecState*, const Identifier&, const PropertySlot&);
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <wtf/Platform.h>
#include "APICast.h"
#include "JSCallbackFunction.h"
#include "JSClassRef.h"
-#include "JSObjectRef.h"
#include "JSGlobalObject.h"
+#include "JSObjectRef.h"
+#include "JSString.h"
#include "JSStringRef.h"
#include "PropertyNameArray.h"
-#include "JSString.h"
#include <wtf/Vector.h>
namespace KJS {
init(exec);
}
-// Global object constructor. FIXME: Move this into a JSGlobalCallbackObject subclass.
+// Global object constructor.
+// FIXME: Move this into a separate JSGlobalCallbackObject class derived from this one.
template <class Base>
JSCallbackObject<Base>::JSCallbackObject(JSClassRef jsClass)
: m_privateData(0)
}
template <class Base>
-ConstructType JSCallbackObject<Base>::getConstructData(ConstructData&)
+ConstructType JSCallbackObject<Base>::getConstructData(ConstructData& constructData)
{
- for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
- if (jsClass->callAsConstructor)
+ for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
+ if (jsClass->callAsConstructor) {
+ constructData.native.function = construct;
return ConstructTypeNative;
-
+ }
+ }
return ConstructTypeNone;
}
template <class Base>
-JSObject* JSCallbackObject<Base>::construct(ExecState* exec, const ArgList& args)
+JSObject* JSCallbackObject<Base>::construct(ExecState* exec, JSObject* constructor, const ArgList& args)
{
JSContextRef execRef = toRef(exec);
- JSObjectRef thisRef = toRef(this);
+ JSObjectRef constructorRef = toRef(constructor);
- for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
+ for (JSClassRef jsClass = static_cast<JSCallbackObject<Base>*>(constructor)->classRef(); jsClass; jsClass = jsClass->parentClass) {
if (JSObjectCallAsConstructorCallback callAsConstructor = jsClass->callAsConstructor) {
int argumentCount = static_cast<int>(args.size());
Vector<JSValueRef, 16> arguments(argumentCount);
for (int i = 0; i < argumentCount; i++)
arguments[i] = toRef(args[i]);
JSLock::DropAllLocks dropAllLocks;
- return toJS(callAsConstructor(execRef, thisRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot())));
+ return toJS(callAsConstructor(execRef, constructorRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot())));
}
}
- ASSERT(0); // getConstructData should prevent us from reaching here
+ ASSERT_NOT_REACHED(); // getConstructData should prevent us from reaching here
return 0;
}
}
template <class Base>
-CallType JSCallbackObject<Base>::getCallData(CallData&)
+CallType JSCallbackObject<Base>::getCallData(CallData& callData)
{
- for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
- if (jsClass->callAsFunction)
+ for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
+ if (jsClass->callAsFunction) {
+ callData.native.function = call;
return CallTypeNative;
-
+ }
+ }
return CallTypeNone;
}
template <class Base>
-JSValue* JSCallbackObject<Base>::callAsFunction(ExecState* exec, JSObject* thisObj, const ArgList &args)
+JSValue* JSCallbackObject<Base>::call(ExecState* exec, JSObject* functionObject, JSValue* thisValue, const ArgList& args)
{
JSContextRef execRef = toRef(exec);
- JSObjectRef thisRef = toRef(this);
- JSObjectRef thisObjRef = toRef(thisObj);
+ JSObjectRef functionRef = toRef(functionObject);
+ JSObjectRef thisObjRef = toRef(thisValue->toThisObject(exec));
- for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
+ for (JSClassRef jsClass = static_cast<JSCallbackObject<Base>*>(functionObject)->m_class; jsClass; jsClass = jsClass->parentClass) {
if (JSObjectCallAsFunctionCallback callAsFunction = jsClass->callAsFunction) {
int argumentCount = static_cast<int>(args.size());
Vector<JSValueRef, 16> arguments(argumentCount);
for (int i = 0; i < argumentCount; i++)
arguments[i] = toRef(args[i]);
JSLock::DropAllLocks dropAllLocks;
- return toJS(callAsFunction(execRef, thisRef, thisObjRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot())));
+ return toJS(callAsFunction(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot())));
}
}
args.append(jsString(exec, UString(toJS(parameterNames[i]))));
args.append(jsString(exec, UString(bodyRep)));
- JSObject* result = exec->dynamicGlobalObject()->functionConstructor()->construct(exec, args, nameID, UString(sourceURLRep), startingLineNumber);
+ JSObject* result = constructFunction(exec, args, nameID, UString(sourceURLRep), startingLineNumber);
if (exec->hadException()) {
if (exception)
*exception = toRef(exec->exception());
bool JSObjectIsFunction(JSContextRef, JSObjectRef object)
{
- JSObject* jsObject = toJS(object);
- return jsObject->implementsCall();
+ CallData callData;
+ return toJS(object)->getCallData(callData) != CallTypeNone;
}
JSValueRef JSObjectCallAsFunction(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
for (size_t i = 0; i < argumentCount; i++)
argList.append(toJS(arguments[i]));
- JSValueRef result = toRef(jsObject->callAsFunction(exec, jsThisObject, argList)); // returns NULL if object->implementsCall() is false
+ CallData callData;
+ CallType callType = jsObject->getCallData(callData);
+ if (callType == CallTypeNone)
+ return 0;
+
+ JSValueRef result = toRef(call(exec, jsObject, callType, callData, jsThisObject, argList));
if (exec->hadException()) {
if (exception)
*exception = toRef(exec->exception());
JSLock lock;
ExecState* exec = toJS(ctx);
JSObject* jsObject = toJS(object);
-
+
+ ConstructData constructData;
+ ConstructType constructType = jsObject->getConstructData(constructData);
+ if (constructType == ConstructTypeNone)
+ return 0;
+
ArgList argList;
for (size_t i = 0; i < argumentCount; i++)
argList.append(toJS(arguments[i]));
-
- JSObjectRef result = toRef(jsObject->construct(exec, argList)); // returns NULL if object->implementsCall() is false
+ JSObjectRef result = toRef(construct(exec, jsObject, constructType, constructData, argList));
if (exec->hadException()) {
if (exception)
*exception = toRef(exec->exception());
+2008-06-23 Darin Adler <darin@apple.com>
+
+ Reviewed by Geoff.
+
+ - work toward https://bugs.webkit.org/show_bug.cgi?id=19721
+
+ More preparation toward making functions work on primitive types without
+ creating wrapper objects. No speedup this time, but prepares for a future
+ speedup without slowing things down.
+
+ SunSpider reports no change.
+
+ - Eliminated the implementsCall, callAsFunction and construct virtual
+ functions from JSObject. Instead, the CallData and ConstructData for
+ a native function includes a function pointer that the caller can use
+ directly. Changed all call sites to use CallData and ConstructData.
+
+ - Changed the "this" argument to native functions to be a JSValue rather
+ than a JSObject. This prepares us for passing primitives into these
+ functions. The conversion to an object now must be done inside the
+ function. Critically, if it's a function that can be called on a DOM
+ window object, then we have to be sure to call toThisObject on the
+ argument before we use it for anything even if it's already an object.
+
+ - Eliminated the practice of using constructor objects in the global
+ object to make objects of the various basic types. Since these
+ constructors can't be replaced by script, there's no reason to involve
+ a constructor object at all. Added functions to do the construction
+ directly.
+
+ - Made some more class members private and protected, including virtual
+ function overrides. This can catch code using unnecessarily slow virtual
+ function code paths when the type of an object is known statically. If we
+ later find a new reason use the members outside the class it's easy to
+ make them public again.
+
+ - Moved the declarations of the native implementations for functions out
+ of header files. These can have internal linkage and be declared inside
+ the source file.
+
+ - Changed PrototypeFunction to take function pointers with the right
+ arguments to be put directly into CallData. This eliminates the
+ need to have a separate PrototypeReflexiveFunction, and reveals that the
+ real purpose of that class included something else specific to eval --
+ storage of a cached global object. So renamed PrototypeReflexiveFunction
+ to GlobalEvalFunction.
+
+ * API/JSCallbackConstructor.cpp:
+ (KJS::constructJSCallback):
+ (KJS::JSCallbackConstructor::getConstructData):
+ * API/JSCallbackConstructor.h:
+ * API/JSCallbackFunction.cpp:
+ (KJS::JSCallbackFunction::implementsHasInstance):
+ (KJS::JSCallbackFunction::call):
+ (KJS::JSCallbackFunction::getCallData):
+ * API/JSCallbackFunction.h:
+ (KJS::JSCallbackFunction::classInfo):
+ * API/JSCallbackObject.h:
+ (KJS::JSCallbackObject::classRef):
+ (KJS::JSCallbackObject::classInfo):
+ * API/JSCallbackObjectFunctions.h:
+ (KJS::::getConstructData):
+ (KJS::::construct):
+ (KJS::::getCallData):
+ (KJS::::call):
+ * API/JSObjectRef.cpp:
+ (JSObjectMakeFunction):
+ (JSObjectIsFunction):
+ (JSObjectCallAsFunction):
+ (JSObjectCallAsConstructor):
+ * JavaScriptCore.exp:
+ * VM/Machine.cpp:
+ (KJS::jsTypeStringForValue):
+ (KJS::Machine::privateExecute):
+ * kjs/ArrayPrototype.cpp:
+ (KJS::arrayProtoFuncToString):
+ (KJS::arrayProtoFuncToLocaleString):
+ (KJS::arrayProtoFuncJoin):
+ (KJS::arrayProtoFuncConcat):
+ (KJS::arrayProtoFuncPop):
+ (KJS::arrayProtoFuncPush):
+ (KJS::arrayProtoFuncReverse):
+ (KJS::arrayProtoFuncShift):
+ (KJS::arrayProtoFuncSlice):
+ (KJS::arrayProtoFuncSort):
+ (KJS::arrayProtoFuncSplice):
+ (KJS::arrayProtoFuncUnShift):
+ (KJS::arrayProtoFuncFilter):
+ (KJS::arrayProtoFuncMap):
+ (KJS::arrayProtoFuncEvery):
+ (KJS::arrayProtoFuncForEach):
+ (KJS::arrayProtoFuncSome):
+ (KJS::arrayProtoFuncIndexOf):
+ (KJS::arrayProtoFuncLastIndexOf):
+ (KJS::ArrayConstructor::ArrayConstructor):
+ (KJS::constructArrayWithSizeQuirk):
+ (KJS::constructWithArrayConstructor):
+ (KJS::ArrayConstructor::getConstructData):
+ (KJS::callArrayConstructor):
+ (KJS::ArrayConstructor::getCallData):
+ * kjs/ArrayPrototype.h:
+ * kjs/BooleanObject.cpp:
+ (KJS::booleanProtoFuncToString):
+ (KJS::booleanProtoFuncValueOf):
+ (KJS::constructBoolean):
+ (KJS::constructWithBooleanConstructor):
+ (KJS::BooleanConstructor::getConstructData):
+ (KJS::callBooleanConstructor):
+ (KJS::BooleanConstructor::getCallData):
+ (KJS::constructBooleanFromImmediateBoolean):
+ * kjs/BooleanObject.h:
+ * kjs/CallData.h:
+ (KJS::):
+ * kjs/ConstructData.h:
+ (KJS::):
+ * kjs/FunctionPrototype.cpp:
+ (KJS::callFunctionPrototype):
+ (KJS::FunctionPrototype::getCallData):
+ (KJS::functionProtoFuncToString):
+ (KJS::functionProtoFuncApply):
+ (KJS::functionProtoFuncCall):
+ (KJS::constructWithFunctionConstructor):
+ (KJS::FunctionConstructor::getConstructData):
+ (KJS::callFunctionConstructor):
+ (KJS::FunctionConstructor::getCallData):
+ (KJS::constructFunction):
+ * kjs/FunctionPrototype.h:
+ * kjs/JSArray.cpp:
+ (KJS::AVLTreeAbstractorForArrayCompare::compare_key_key):
+ (KJS::JSArray::sort):
+ (KJS::constructEmptyArray):
+ (KJS::constructArray):
+ * kjs/JSArray.h:
+ (KJS::JSArray::classInfo):
+ * kjs/JSFunction.cpp:
+ (KJS::JSFunction::call):
+ (KJS::globalFuncEval):
+ (KJS::globalFuncParseInt):
+ (KJS::globalFuncParseFloat):
+ (KJS::globalFuncIsNaN):
+ (KJS::globalFuncIsFinite):
+ (KJS::globalFuncDecodeURI):
+ (KJS::globalFuncDecodeURIComponent):
+ (KJS::globalFuncEncodeURI):
+ (KJS::globalFuncEncodeURIComponent):
+ (KJS::globalFuncEscape):
+ (KJS::globalFuncUnescape):
+ (KJS::globalFuncKJSPrint):
+ (KJS::PrototypeFunction::PrototypeFunction):
+ (KJS::PrototypeFunction::getCallData):
+ (KJS::GlobalEvalFunction::GlobalEvalFunction):
+ (KJS::GlobalEvalFunction::mark):
+ * kjs/JSFunction.h:
+ (KJS::InternalFunction::classInfo):
+ (KJS::InternalFunction::functionName):
+ (KJS::JSFunction::classInfo):
+ (KJS::GlobalEvalFunction::cachedGlobalObject):
+ * kjs/JSGlobalObject.cpp:
+ (KJS::JSGlobalObject::reset):
+ (KJS::JSGlobalObject::mark):
+ * kjs/JSGlobalObject.h:
+ (KJS::JSGlobalObject::JSGlobalObject):
+ (KJS::JSGlobalObject::evalFunction):
+ * kjs/JSImmediate.cpp:
+ (KJS::JSImmediate::toObject):
+ * kjs/JSNotAnObject.cpp:
+ * kjs/JSNotAnObject.h:
+ * kjs/JSObject.cpp:
+ (KJS::JSObject::put):
+ (KJS::callDefaultValueFunction):
+ (KJS::JSObject::defaultValue):
+ (KJS::JSObject::lookupGetter):
+ (KJS::JSObject::lookupSetter):
+ (KJS::JSObject::hasInstance):
+ (KJS::JSObject::fillGetterPropertySlot):
+ (KJS::Error::create):
+ (KJS::constructEmptyObject):
+ * kjs/JSObject.h:
+ (KJS::GetterSetter::GetterSetter):
+ (KJS::GetterSetter::getter):
+ (KJS::GetterSetter::setGetter):
+ (KJS::GetterSetter::setter):
+ (KJS::GetterSetter::setSetter):
+ * kjs/JSValue.cpp:
+ (KJS::JSCell::deleteProperty):
+ (KJS::call):
+ (KJS::construct):
+ * kjs/JSValue.h:
+ * kjs/MathObject.cpp:
+ (KJS::mathProtoFuncAbs):
+ (KJS::mathProtoFuncACos):
+ (KJS::mathProtoFuncASin):
+ (KJS::mathProtoFuncATan):
+ (KJS::mathProtoFuncATan2):
+ (KJS::mathProtoFuncCeil):
+ (KJS::mathProtoFuncCos):
+ (KJS::mathProtoFuncExp):
+ (KJS::mathProtoFuncFloor):
+ (KJS::mathProtoFuncLog):
+ (KJS::mathProtoFuncMax):
+ (KJS::mathProtoFuncMin):
+ (KJS::mathProtoFuncPow):
+ (KJS::mathProtoFuncRandom):
+ (KJS::mathProtoFuncRound):
+ (KJS::mathProtoFuncSin):
+ (KJS::mathProtoFuncSqrt):
+ (KJS::mathProtoFuncTan):
+ * kjs/MathObject.h:
+ * kjs/NumberObject.cpp:
+ (KJS::numberProtoFuncToString):
+ (KJS::numberProtoFuncToLocaleString):
+ (KJS::numberProtoFuncValueOf):
+ (KJS::numberProtoFuncToFixed):
+ (KJS::numberProtoFuncToExponential):
+ (KJS::numberProtoFuncToPrecision):
+ (KJS::NumberConstructor::NumberConstructor):
+ (KJS::constructWithNumberConstructor):
+ (KJS::NumberConstructor::getConstructData):
+ (KJS::callNumberConstructor):
+ (KJS::NumberConstructor::getCallData):
+ (KJS::constructNumber):
+ (KJS::constructNumberFromImmediateNumber):
+ * kjs/NumberObject.h:
+ (KJS::NumberObject::classInfo):
+ (KJS::NumberConstructor::classInfo):
+ * kjs/PropertySlot.cpp:
+ (KJS::PropertySlot::functionGetter):
+ * kjs/RegExpObject.cpp:
+ (KJS::regExpProtoFuncTest):
+ (KJS::regExpProtoFuncExec):
+ (KJS::regExpProtoFuncCompile):
+ (KJS::regExpProtoFuncToString):
+ (KJS::callRegExpObject):
+ (KJS::RegExpObject::getCallData):
+ (KJS::constructRegExp):
+ (KJS::constructWithRegExpConstructor):
+ (KJS::RegExpConstructor::getConstructData):
+ (KJS::callRegExpConstructor):
+ (KJS::RegExpConstructor::getCallData):
+ * kjs/RegExpObject.h:
+ (KJS::RegExpConstructor::classInfo):
+ * kjs/Shell.cpp:
+ (GlobalObject::GlobalObject):
+ (functionPrint):
+ (functionDebug):
+ (functionGC):
+ (functionVersion):
+ (functionRun):
+ (functionLoad):
+ (functionReadline):
+ (functionQuit):
+ * kjs/date_object.cpp:
+ (KJS::gmtoffset):
+ (KJS::formatLocaleDate):
+ (KJS::fillStructuresUsingDateArgs):
+ (KJS::DateInstance::getTime):
+ (KJS::DateInstance::getUTCTime):
+ (KJS::DateConstructor::DateConstructor):
+ (KJS::constructDate):
+ (KJS::DateConstructor::getConstructData):
+ (KJS::callDate):
+ (KJS::DateConstructor::getCallData):
+ (KJS::dateParse):
+ (KJS::dateNow):
+ (KJS::dateUTC):
+ (KJS::dateProtoFuncToString):
+ (KJS::dateProtoFuncToUTCString):
+ (KJS::dateProtoFuncToDateString):
+ (KJS::dateProtoFuncToTimeString):
+ (KJS::dateProtoFuncToLocaleString):
+ (KJS::dateProtoFuncToLocaleDateString):
+ (KJS::dateProtoFuncToLocaleTimeString):
+ (KJS::dateProtoFuncValueOf):
+ (KJS::dateProtoFuncGetTime):
+ (KJS::dateProtoFuncGetFullYear):
+ (KJS::dateProtoFuncGetUTCFullYear):
+ (KJS::dateProtoFuncToGMTString):
+ (KJS::dateProtoFuncGetMonth):
+ (KJS::dateProtoFuncGetUTCMonth):
+ (KJS::dateProtoFuncGetDate):
+ (KJS::dateProtoFuncGetUTCDate):
+ (KJS::dateProtoFuncGetDay):
+ (KJS::dateProtoFuncGetUTCDay):
+ (KJS::dateProtoFuncGetHours):
+ (KJS::dateProtoFuncGetUTCHours):
+ (KJS::dateProtoFuncGetMinutes):
+ (KJS::dateProtoFuncGetUTCMinutes):
+ (KJS::dateProtoFuncGetSeconds):
+ (KJS::dateProtoFuncGetUTCSeconds):
+ (KJS::dateProtoFuncGetMilliSeconds):
+ (KJS::dateProtoFuncGetUTCMilliseconds):
+ (KJS::dateProtoFuncGetTimezoneOffset):
+ (KJS::dateProtoFuncSetTime):
+ (KJS::setNewValueFromTimeArgs):
+ (KJS::setNewValueFromDateArgs):
+ (KJS::dateProtoFuncSetMilliSeconds):
+ (KJS::dateProtoFuncSetUTCMilliseconds):
+ (KJS::dateProtoFuncSetSeconds):
+ (KJS::dateProtoFuncSetUTCSeconds):
+ (KJS::dateProtoFuncSetMinutes):
+ (KJS::dateProtoFuncSetUTCMinutes):
+ (KJS::dateProtoFuncSetHours):
+ (KJS::dateProtoFuncSetUTCHours):
+ (KJS::dateProtoFuncSetDate):
+ (KJS::dateProtoFuncSetUTCDate):
+ (KJS::dateProtoFuncSetMonth):
+ (KJS::dateProtoFuncSetUTCMonth):
+ (KJS::dateProtoFuncSetFullYear):
+ (KJS::dateProtoFuncSetUTCFullYear):
+ (KJS::dateProtoFuncSetYear):
+ (KJS::dateProtoFuncGetYear):
+ * kjs/date_object.h:
+ (KJS::DateInstance::internalNumber):
+ (KJS::DateInstance::classInfo):
+ * kjs/error_object.cpp:
+ (KJS::errorProtoFuncToString):
+ (KJS::constructError):
+ (KJS::constructWithErrorConstructor):
+ (KJS::ErrorConstructor::getConstructData):
+ (KJS::callErrorConstructor):
+ (KJS::ErrorConstructor::getCallData):
+ (KJS::NativeErrorConstructor::construct):
+ (KJS::constructWithNativeErrorConstructor):
+ (KJS::NativeErrorConstructor::getConstructData):
+ (KJS::callNativeErrorConstructor):
+ (KJS::NativeErrorConstructor::getCallData):
+ * kjs/error_object.h:
+ (KJS::NativeErrorConstructor::classInfo):
+ * kjs/internal.cpp:
+ (KJS::JSNumberCell::toObject):
+ (KJS::JSNumberCell::toThisObject):
+ (KJS::GetterSetter::mark):
+ (KJS::GetterSetter::toPrimitive):
+ (KJS::GetterSetter::toBoolean):
+ (KJS::GetterSetter::toNumber):
+ (KJS::GetterSetter::toString):
+ (KJS::GetterSetter::toObject):
+ (KJS::InternalFunction::InternalFunction):
+ (KJS::InternalFunction::implementsHasInstance):
+ * kjs/lookup.h:
+ (KJS::HashEntry::):
+ * kjs/nodes.cpp:
+ (KJS::FuncDeclNode::makeFunction):
+ (KJS::FuncExprNode::makeFunction):
+ * kjs/object_object.cpp:
+ (KJS::objectProtoFuncValueOf):
+ (KJS::objectProtoFuncHasOwnProperty):
+ (KJS::objectProtoFuncIsPrototypeOf):
+ (KJS::objectProtoFuncDefineGetter):
+ (KJS::objectProtoFuncDefineSetter):
+ (KJS::objectProtoFuncLookupGetter):
+ (KJS::objectProtoFuncLookupSetter):
+ (KJS::objectProtoFuncPropertyIsEnumerable):
+ (KJS::objectProtoFuncToLocaleString):
+ (KJS::objectProtoFuncToString):
+ (KJS::ObjectConstructor::ObjectConstructor):
+ (KJS::constructObject):
+ (KJS::constructWithObjectConstructor):
+ (KJS::ObjectConstructor::getConstructData):
+ (KJS::callObjectConstructor):
+ (KJS::ObjectConstructor::getCallData):
+ * kjs/object_object.h:
+ * kjs/string_object.cpp:
+ (KJS::replace):
+ (KJS::stringProtoFuncToString):
+ (KJS::stringProtoFuncValueOf):
+ (KJS::stringProtoFuncCharAt):
+ (KJS::stringProtoFuncCharCodeAt):
+ (KJS::stringProtoFuncConcat):
+ (KJS::stringProtoFuncIndexOf):
+ (KJS::stringProtoFuncLastIndexOf):
+ (KJS::stringProtoFuncMatch):
+ (KJS::stringProtoFuncSearch):
+ (KJS::stringProtoFuncReplace):
+ (KJS::stringProtoFuncSlice):
+ (KJS::stringProtoFuncSplit):
+ (KJS::stringProtoFuncSubstr):
+ (KJS::stringProtoFuncSubstring):
+ (KJS::stringProtoFuncToLowerCase):
+ (KJS::stringProtoFuncToUpperCase):
+ (KJS::stringProtoFuncToLocaleLowerCase):
+ (KJS::stringProtoFuncToLocaleUpperCase):
+ (KJS::stringProtoFuncLocaleCompare):
+ (KJS::stringProtoFuncBig):
+ (KJS::stringProtoFuncSmall):
+ (KJS::stringProtoFuncBlink):
+ (KJS::stringProtoFuncBold):
+ (KJS::stringProtoFuncFixed):
+ (KJS::stringProtoFuncItalics):
+ (KJS::stringProtoFuncStrike):
+ (KJS::stringProtoFuncSub):
+ (KJS::stringProtoFuncSup):
+ (KJS::stringProtoFuncFontcolor):
+ (KJS::stringProtoFuncFontsize):
+ (KJS::stringProtoFuncAnchor):
+ (KJS::stringProtoFuncLink):
+ (KJS::stringFromCharCode):
+ (KJS::StringConstructor::StringConstructor):
+ (KJS::constructWithStringConstructor):
+ (KJS::StringConstructor::getConstructData):
+ (KJS::callStringConstructor):
+ (KJS::StringConstructor::getCallData):
+ * kjs/string_object.h:
+
2008-06-23 Cameron Zwarich <cwzwarich@uwaterloo.ca>
Reviewed by Oliver.
__ZN3KJS14JSGlobalObjectD2Ev
__ZN3KJS14JSGlobalObjectnwEm
__ZN3KJS14JSGlobalObjectnwEmNS0_9SharedTagE
+__ZN3KJS14constructArrayEPNS_9ExecStateERKNS_7ArgListE
__ZN3KJS15JSWrapperObject4markEv
-__ZN3KJS16InternalFunction11getCallDataERNS_8CallDataE
__ZN3KJS16InternalFunction4infoE
__ZN3KJS16InternalFunctionC2EPNS_17FunctionPrototypeERKNS_10IdentifierE
__ZN3KJS16JSVariableObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
__ZN3KJS16ParserRefCounted3refEv
__ZN3KJS16ParserRefCounted5derefEv
__ZN3KJS17PropertyNameArray3addEPNS_7UString3RepE
-__ZN3KJS17PrototypeFunctionC1EPNS_9ExecStateEPNS_17FunctionPrototypeEiRKNS_10IdentifierEPFPNS_7JSValueES2_PNS_8JSObjectERKNS_7ArgListEE
-__ZN3KJS17PrototypeFunctionC1EPNS_9ExecStateEiRKNS_10IdentifierEPFPNS_7JSValueES2_PNS_8JSObjectERKNS_7ArgListEE
+__ZN3KJS17PrototypeFunctionC1EPNS_9ExecStateEPNS_17FunctionPrototypeEiRKNS_10IdentifierEPFPNS_7JSValueES2_PNS_8JSObjectES9_RKNS_7ArgListEE
+__ZN3KJS17PrototypeFunctionC1EPNS_9ExecStateEiRKNS_10IdentifierEPFPNS_7JSValueES2_PNS_8JSObjectES7_RKNS_7ArgListEE
__ZN3KJS17RegisterFileStack20allocateRegisterFileEmPS0_
+__ZN3KJS17constructFunctionEPNS_9ExecStateERKNS_7ArgListERKNS_10IdentifierERKNS_7UStringEi
+__ZN3KJS19constructEmptyArrayEPNS_9ExecStateE
__ZN3KJS19initializeThreadingEv
-__ZN3KJS23objectProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectERKNS_7ArgListE
+__ZN3KJS23objectProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectEPNS_7JSValueERKNS_7ArgListE
__ZN3KJS4Heap14allocateNumberEm
__ZN3KJS4Heap15recordExtraCostEm
__ZN3KJS4Heap17globalObjectCountEv
__ZN3KJS4Heap7protectEPNS_7JSValueE
__ZN3KJS4Heap8allocateEm
__ZN3KJS4Heap9unprotectEPNS_7JSValueE
+__ZN3KJS4callEPNS_9ExecStateEPNS_7JSValueENS_8CallTypeERKNS_8CallDataES3_RKNS_7ArgListE
__ZN3KJS5equalEPKNS_7UString3RepES3_
__ZN3KJS6JSCell11getCallDataERNS_8CallDataE
+__ZN3KJS6JSCell14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
+__ZN3KJS6JSCell14deletePropertyEPNS_9ExecStateEj
__ZN3KJS6JSCell16getConstructDataERNS_13ConstructDataE
__ZN3KJS6JSCell18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
__ZN3KJS6JSCell18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
__ZN3KJS8JSObject12defineSetterEPNS_9ExecStateERKNS_10IdentifierEPS0_
__ZN3KJS8JSObject12lookupGetterEPNS_9ExecStateERKNS_10IdentifierE
__ZN3KJS8JSObject12lookupSetterEPNS_9ExecStateERKNS_10IdentifierE
-__ZN3KJS8JSObject14callAsFunctionEPNS_9ExecStateEPS0_RKNS_7ArgListE
__ZN3KJS8JSObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
__ZN3KJS8JSObject14deletePropertyEPNS_9ExecStateEj
-__ZN3KJS8JSObject14implementsCallEv
__ZN3KJS8JSObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
__ZN3KJS8JSObject17putDirectFunctionEPNS_16InternalFunctionEi
__ZN3KJS8JSObject17putWithAttributesEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEj
__ZN3KJS8JSObject3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueE
__ZN3KJS8JSObject3putEPNS_9ExecStateEjPNS_7JSValueE
__ZN3KJS8JSObject4markEv
-__ZN3KJS8JSObject9constructEPNS_9ExecStateERKNS_7ArgListE
-__ZN3KJS8JSObject9constructEPNS_9ExecStateERKNS_7ArgListERKNS_10IdentifierERKNS_7UStringEi
__ZN3KJS8Profiler13stopProfilingEPNS_9ExecStateERKNS_7UStringE
__ZN3KJS8Profiler14startProfilingEPNS_9ExecStateERKNS_7UStringEPNS_14ProfilerClientE
__ZN3KJS8Profiler8profilerEv
__ZN3KJS8jsStringEPNS_9ExecStateEPKc
__ZN3KJS8jsStringEPNS_9ExecStateERKNS_7UStringE
+__ZN3KJS9constructEPNS_9ExecStateEPNS_7JSValueENS_13ConstructTypeERKNS_13ConstructDataERKNS_7ArgListE
__ZN3KJSeqERKNS_7UStringEPKc
__ZN3KJSgtERKNS_7UStringES2_
__ZN3KJSltERKNS_7UStringES2_
__ZNK3KJS6JSCell12toThisObjectEPNS_9ExecStateE
__ZNK3KJS6JSCell17getTruncatedInt32ERi
__ZNK3KJS6JSCell18getTruncatedUInt32ERj
+__ZNK3KJS6JSCell9classInfoEv
__ZNK3KJS6JSCell9getNumberEv
__ZNK3KJS6JSCell9getStringERNS_7UStringE
__ZNK3KJS6JSCell9getStringEv
__ZNK3KJS8JSObject8toNumberEPNS_9ExecStateE
__ZNK3KJS8JSObject8toObjectEPNS_9ExecStateE
__ZNK3KJS8JSObject8toStringEPNS_9ExecStateE
-__ZNK3KJS8JSObject9classInfoEv
__ZNK3KJS8JSObject9classNameEv
__ZNK3KJS8JSObject9toBooleanEPNS_9ExecStateE
__ZNK3KJS9HashTable11createTableEPNS_12JSGlobalDataE
// as null when doing comparisons.
if (static_cast<JSObject*>(v)->masqueradeAsUndefined())
return jsString(exec, "undefined");
- else if (static_cast<JSObject*>(v)->implementsCall())
+ CallData callData;
+ if (static_cast<JSObject*>(v)->getCallData(callData) != CallTypeNone)
return jsString(exec, "function");
}
constructor, and puts the result in register dst.
*/
int dst = (++vPC)->u.operand;
- r[dst].u.jsValue = scopeChain->globalObject()->objectConstructor()->construct(exec, exec->emptyList());
+ r[dst].u.jsValue = constructEmptyObject(exec);
++vPC;
NEXT_OPCODE;
constructor, and puts the result in register dst.
*/
int dst = (++vPC)->u.operand;
- r[dst].u.jsValue = scopeChain->globalObject()->arrayConstructor()->construct(exec, exec->emptyList());
+ r[dst].u.jsValue = constructEmptyArray(exec);
++vPC;
NEXT_OPCODE;
int registerOffset = r - (*registerBase);
r[firstArg].u.jsValue = thisVal == missingThisObjectMarker() ? exec->globalThisValue() : (r[thisVal].u.jsValue)->toObject(exec);
- JSObject* thisObj = static_cast<JSObject*>(r[firstArg].u.jsValue);
+ JSValue* thisValue = r[firstArg].u.jsValue;
ArgList args(reinterpret_cast<JSValue***>(registerBase), registerOffset + firstArg + 1, argCount - 1);
registerFile->setSafeForReentry(true);
- JSValue* returnValue = static_cast<JSObject*>(v)->callAsFunction(exec, thisObj, args);
+ JSValue* returnValue = callData.native.function(exec, static_cast<JSObject*>(v), thisValue, args);
registerFile->setSafeForReentry(false);
r = (*registerBase) + registerOffset;
ArgList args(reinterpret_cast<JSValue***>(registerBase), registerOffset + firstArg + 1, argCount - 1);
registerFile->setSafeForReentry(true);
- JSValue* returnValue = constructor->construct(exec, args);
+ JSValue* returnValue = constructData.native.function(exec, constructor, args);
registerFile->setSafeForReentry(false);
r = (*registerBase) + registerOffset;
#include "config.h"
#include "ArrayPrototype.h"
-#include "ArrayPrototype.lut.h"
#include "Machine.h"
#include "error_object.h"
namespace KJS {
+static JSValue* arrayProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* arrayProtoFuncToLocaleString(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* arrayProtoFuncConcat(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* arrayProtoFuncJoin(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* arrayProtoFuncPop(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* arrayProtoFuncPush(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* arrayProtoFuncReverse(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* arrayProtoFuncShift(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* arrayProtoFuncSlice(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* arrayProtoFuncSort(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* arrayProtoFuncSplice(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* arrayProtoFuncUnShift(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* arrayProtoFuncEvery(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* arrayProtoFuncForEach(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* arrayProtoFuncSome(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* arrayProtoFuncIndexOf(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* arrayProtoFuncFilter(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* arrayProtoFuncMap(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* arrayProtoFuncLastIndexOf(ExecState*, JSObject*, JSValue*, const ArgList&);
+
+}
+
+#include "ArrayPrototype.lut.h"
+
+namespace KJS {
+
// ------------------------------ ArrayPrototype ----------------------------
const ClassInfo ArrayPrototype::info = {"Array", &JSArray::info, 0, ExecState::arrayTable};
return slot.getValue(exec, index);
}
-JSValue* arrayProtoFuncToString(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* arrayProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&JSArray::info))
+ if (!thisValue->isObject(&JSArray::info))
return throwError(exec, TypeError);
+ JSObject* thisObj = static_cast<JSArray*>(thisValue);
HashSet<JSObject*>& arrayVisitedElements = exec->dynamicGlobalObject()->arrayVisitedElements();
if (arrayVisitedElements.size() > MaxReentryDepth)
return jsString(exec, UString(strBuffer.data(), strBuffer.data() ? strBuffer.size() : 0));
}
-JSValue* arrayProtoFuncToLocaleString(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* arrayProtoFuncToLocaleString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&JSArray::info))
+ if (!thisValue->isObject(&JSArray::info))
return throwError(exec, TypeError);
+ JSObject* thisObj = static_cast<JSArray*>(thisValue);
HashSet<JSObject*>& arrayVisitedElements = exec->dynamicGlobalObject()->arrayVisitedElements();
if (arrayVisitedElements.size() > MaxReentryDepth)
JSObject* o = element->toObject(exec);
JSValue* conversionFunction = o->get(exec, exec->propertyNames().toLocaleString);
UString str;
- if (conversionFunction->isObject() && static_cast<JSObject*>(conversionFunction)->implementsCall())
- str = static_cast<JSObject*>(conversionFunction)->callAsFunction(exec, o, exec->emptyList())->toString(exec);
+ CallData callData;
+ CallType callType = conversionFunction->getCallData(callData);
+ if (callType != CallTypeNone)
+ str = call(exec, conversionFunction, callType, callData, element, exec->emptyList())->toString(exec);
else
str = element->toString(exec);
strBuffer.append(str.data(), str.size());
return jsString(exec, UString(strBuffer.data(), strBuffer.data() ? strBuffer.size() : 0));
}
-JSValue* arrayProtoFuncJoin(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* arrayProtoFuncJoin(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
+ JSObject* thisObj = thisValue->toThisObject(exec);
+
HashSet<JSObject*>& arrayVisitedElements = exec->dynamicGlobalObject()->arrayVisitedElements();
if (arrayVisitedElements.size() > MaxReentryDepth)
return throwError(exec, RangeError, "Maximum call stack size exceeded.");
return jsString(exec, UString(strBuffer.data(), strBuffer.data() ? strBuffer.size() : 0));
}
-JSValue* arrayProtoFuncConcat(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* arrayProtoFuncConcat(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- JSObject* arr = static_cast<JSObject*>(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList()));
+ JSArray* arr = constructEmptyArray(exec);
int n = 0;
- JSValue* curArg = thisObj;
- JSObject* curObj = static_cast<JSObject* >(thisObj);
+ JSValue* curArg = thisValue->toThisObject(exec);
ArgList::const_iterator it = args.begin();
ArgList::const_iterator end = args.end();
while (1) {
- if (curArg->isObject() && curObj->inherits(&JSArray::info)) {
- unsigned 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.
- unsigned length = curObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
- while (k < length) {
- if (JSValue* v = getProperty(exec, curObj, k))
+ if (curArg->isObject(&JSArray::info)) {
+ JSArray* curArray = static_cast<JSArray*>(curArg);
+ unsigned length = curArray->getLength();
+ for (unsigned k = 0; k < length; ++k) {
+ if (JSValue* v = curArray->getItem(k))
arr->put(exec, n, v);
n++;
- k++;
}
} else {
arr->put(exec, n, curArg);
if (it == end)
break;
curArg = *it;
- curObj = static_cast<JSObject*>(curArg); // may be 0
++it;
}
- arr->put(exec, exec->propertyNames().length, jsNumber(exec, n));
+ arr->setLength(n);
return arr;
}
-JSValue* arrayProtoFuncPop(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* arrayProtoFuncPop(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
+ JSObject* thisObj = thisValue->toThisObject(exec);
JSValue* result = 0;
unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
if (length == 0) {
return result;
}
-JSValue* arrayProtoFuncPush(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* arrayProtoFuncPush(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
+ JSObject* thisObj = thisValue->toThisObject(exec);
unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
for (unsigned n = 0; n < args.size(); n++)
thisObj->put(exec, length + n, args[n]);
return jsNumber(exec, length);
}
-JSValue* arrayProtoFuncReverse(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* arrayProtoFuncReverse(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
+ JSObject* thisObj = thisValue->toThisObject(exec);
unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
unsigned middle = length / 2;
return thisObj;
}
-JSValue* arrayProtoFuncShift(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* arrayProtoFuncShift(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
+ JSObject* thisObj = thisValue->toThisObject(exec);
JSValue* result = 0;
unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
return result;
}
-JSValue* arrayProtoFuncSlice(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* arrayProtoFuncSlice(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
// http://developer.netscape.com/docs/manuals/js/client/jsref/array.htm#1193713 or 15.4.4.10
+ JSObject* thisObj = thisValue->toThisObject(exec);
+
// We return a new array
- JSObject* resObj = static_cast<JSObject* >(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList()));
+ JSArray* resObj = constructEmptyArray(exec);
JSValue* result = resObj;
double begin = args[0]->toInteger(exec);
unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
if (JSValue* v = getProperty(exec, thisObj, k))
resObj->put(exec, n, v);
}
- resObj->put(exec, exec->propertyNames().length, jsNumber(exec, n));
+ resObj->setLength(n);
return result;
}
-JSValue* arrayProtoFuncSort(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* arrayProtoFuncSort(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- JSObject* sortFunction = 0;
- if (!args[0]->isUndefined()) {
- sortFunction = args[0]->toObject(exec);
- if (!sortFunction->implementsCall())
- sortFunction = 0;
- }
+ JSObject* thisObj = thisValue->toThisObject(exec);
+
+ JSValue* function = args[0];
+ CallData callData;
+ CallType callType = function->getCallData(callData);
if (thisObj->classInfo() == &JSArray::info) {
- if (sortFunction)
- static_cast<JSArray*>(thisObj)->sort(exec, sortFunction);
+ if (callType != CallTypeNone)
+ static_cast<JSArray*>(thisObj)->sort(exec, function, callType, callData);
else
static_cast<JSArray*>(thisObj)->sort(exec);
return thisObj;
compareResult = 1; // don't check minObj because there's no need to differentiate == (0) from > (1)
else if (minObj->isUndefined())
compareResult = -1;
- else if (sortFunction) {
+ else if (callType != CallTypeNone) {
ArgList l;
l.append(jObj);
l.append(minObj);
- compareResult = sortFunction->callAsFunction(exec, exec->globalThisValue(), l)->toNumber(exec);
+ compareResult = call(exec, function, callType, callData, exec->globalThisValue(), l)->toNumber(exec);
} else
compareResult = (jObj->toString(exec) < minObj->toString(exec)) ? -1 : 1;
return thisObj;
}
-JSValue* arrayProtoFuncSplice(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* arrayProtoFuncSplice(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
+ JSObject* thisObj = thisValue->toThisObject(exec);
+
// 15.4.4.12
- JSObject* resObj = static_cast<JSObject* >(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList()));
+ JSArray* resObj = constructEmptyArray(exec);
JSValue* result = resObj;
unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
if (!args.size())
if (JSValue* v = getProperty(exec, thisObj, k + begin))
resObj->put(exec, k, v);
}
- resObj->put(exec, exec->propertyNames().length, jsNumber(exec, deleteCount));
+ resObj->setLength(deleteCount);
unsigned additionalArgs = std::max<int>(args.size() - 2, 0);
if (additionalArgs != deleteCount) {
return result;
}
-JSValue* arrayProtoFuncUnShift(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* arrayProtoFuncUnShift(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
+ JSObject* thisObj = thisValue->toThisObject(exec);
+
// 15.4.4.13
unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
unsigned nrArgs = args.size();
return result;
}
-JSValue* arrayProtoFuncFilter(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* arrayProtoFuncFilter(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- JSObject* eachFunction = args[0]->toObject(exec);
+ JSObject* thisObj = thisValue->toThisObject(exec);
- if (!eachFunction->implementsCall())
+ JSValue* function = args[0];
+ CallData callData;
+ CallType callType = function->getCallData(callData);
+ if (callType == CallTypeNone)
return throwError(exec, TypeError);
- JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() : args[1]->toObject(exec);
- JSObject* resultArray = static_cast<JSObject*>(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList()));
+ JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() : args[1]->toObject(exec);
+ JSArray* resultArray = constructEmptyArray(exec);
unsigned filterIndex = 0;
unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
eachArguments.append(jsNumber(exec, k));
eachArguments.append(thisObj);
- JSValue* result = eachFunction->callAsFunction(exec, applyThis, eachArguments);
+ JSValue* result = call(exec, function, callType, callData, applyThis, eachArguments);
if (result->toBoolean(exec))
resultArray->put(exec, filterIndex++, v);
return resultArray;
}
-JSValue* arrayProtoFuncMap(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* arrayProtoFuncMap(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- JSObject* eachFunction = args[0]->toObject(exec);
- if (!eachFunction->implementsCall())
+ JSObject* thisObj = thisValue->toThisObject(exec);
+
+ JSValue* function = args[0];
+ CallData callData;
+ CallType callType = function->getCallData(callData);
+ if (callType == CallTypeNone)
return throwError(exec, TypeError);
- JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() : args[1]->toObject(exec);
+ JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() : args[1]->toObject(exec);
unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
- ArgList mapArgs;
- mapArgs.append(jsNumber(exec, length));
- JSObject* resultArray = static_cast<JSObject*>(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, mapArgs));
+ JSArray* resultArray = constructEmptyArray(exec, length);
for (unsigned k = 0; k < length && !exec->hadException(); ++k) {
PropertySlot slot(thisObj);
eachArguments.append(jsNumber(exec, k));
eachArguments.append(thisObj);
- JSValue* result = eachFunction->callAsFunction(exec, applyThis, eachArguments);
+ JSValue* result = call(exec, function, callType, callData, applyThis, eachArguments);
resultArray->put(exec, k, result);
}
// http://developer-test.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:forEach
// http://developer-test.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:some
-JSValue* arrayProtoFuncEvery(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* arrayProtoFuncEvery(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- JSObject* eachFunction = args[0]->toObject(exec);
+ JSObject* thisObj = thisValue->toThisObject(exec);
- if (!eachFunction->implementsCall())
+ JSValue* function = args[0];
+ CallData callData;
+ CallType callType = function->getCallData(callData);
+ if (callType == CallTypeNone)
return throwError(exec, TypeError);
- JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() : args[1]->toObject(exec);
+ JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() : args[1]->toObject(exec);
JSValue* result = jsBoolean(true);
eachArguments.append(jsNumber(exec, k));
eachArguments.append(thisObj);
- bool predicateResult = eachFunction->callAsFunction(exec, applyThis, eachArguments)->toBoolean(exec);
+ bool predicateResult = call(exec, function, callType, callData, applyThis, eachArguments)->toBoolean(exec);
if (!predicateResult) {
result = jsBoolean(false);
return result;
}
-JSValue* arrayProtoFuncForEach(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* arrayProtoFuncForEach(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- JSObject* eachFunction = args[0]->toObject(exec);
+ JSObject* thisObj = thisValue->toThisObject(exec);
- if (!eachFunction->implementsCall())
+ JSValue* function = args[0];
+ CallData callData;
+ CallType callType = function->getCallData(callData);
+ if (callType == CallTypeNone)
return throwError(exec, TypeError);
- JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() : args[1]->toObject(exec);
+ JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() : args[1]->toObject(exec);
unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
for (unsigned k = 0; k < length && !exec->hadException(); ++k) {
eachArguments.append(jsNumber(exec, k));
eachArguments.append(thisObj);
- eachFunction->callAsFunction(exec, applyThis, eachArguments);
+ call(exec, function, callType, callData, applyThis, eachArguments);
}
return jsUndefined();
}
-JSValue* arrayProtoFuncSome(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* arrayProtoFuncSome(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- JSObject* eachFunction = args[0]->toObject(exec);
+ JSObject* thisObj = thisValue->toThisObject(exec);
- if (!eachFunction->implementsCall())
+ JSValue* function = args[0];
+ CallData callData;
+ CallType callType = function->getCallData(callData);
+ if (callType == CallTypeNone)
return throwError(exec, TypeError);
- JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() : args[1]->toObject(exec);
+ JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() : args[1]->toObject(exec);
JSValue* result = jsBoolean(false);
eachArguments.append(jsNumber(exec, k));
eachArguments.append(thisObj);
- bool predicateResult = eachFunction->callAsFunction(exec, applyThis, eachArguments)->toBoolean(exec);
+ bool predicateResult = call(exec, function, callType, callData, applyThis, eachArguments)->toBoolean(exec);
if (predicateResult) {
result = jsBoolean(true);
return result;
}
-JSValue* arrayProtoFuncIndexOf(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* arrayProtoFuncIndexOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
// JavaScript 1.5 Extension by Mozilla
// Documentation: http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:indexOf
+ JSObject* thisObj = thisValue->toThisObject(exec);
+
unsigned index = 0;
double d = args[1]->toInteger(exec);
unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
return jsNumber(exec, -1);
}
-JSValue* arrayProtoFuncLastIndexOf(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* arrayProtoFuncLastIndexOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
// JavaScript 1.6 Extension by Mozilla
// Documentation: http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:lastIndexOf
+ JSObject* thisObj = thisValue->toThisObject(exec);
+
unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
int index = length - 1;
double d = args[1]->toIntegerPreserveNaN(exec);
putDirect(exec->propertyNames().prototype, arrayProto, DontEnum|DontDelete|ReadOnly);
// no. of arguments for constructor
- putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly|DontDelete|DontEnum);
+ putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontEnum | DontDelete);
}
-ConstructType ArrayConstructor::getConstructData(ConstructData&)
-{
- return ConstructTypeNative;
-}
-
-// ECMA 15.4.2
-JSObject* ArrayConstructor::construct(ExecState* exec, const ArgList& args)
+static JSObject* constructArrayWithSizeQuirk(ExecState* exec, const ArgList& args)
{
// a single numeric argument denotes the array size (!)
if (args.size() == 1 && args[0]->isNumber()) {
return new (exec) JSArray(exec->lexicalGlobalObject()->arrayPrototype(), args);
}
+static JSObject* constructWithArrayConstructor(ExecState* exec, JSObject*, const ArgList& args)
+{
+ return constructArrayWithSizeQuirk(exec, args);
+}
+
+// ECMA 15.4.2
+ConstructType ArrayConstructor::getConstructData(ConstructData& constructData)
+{
+ constructData.native.function = constructWithArrayConstructor;
+ return ConstructTypeNative;
+}
+
+static JSValue* callArrayConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
+{
+ return constructArrayWithSizeQuirk(exec, args);
+}
+
// ECMA 15.6.1
-JSValue* ArrayConstructor::callAsFunction(ExecState* exec, JSObject*, const ArgList& args)
+CallType ArrayConstructor::getCallData(CallData& callData)
{
// equivalent to 'new Array(....)'
- return construct(exec, args);
+ callData.native.function = callArrayConstructor;
+ return CallTypeNative;
}
}
class ArrayConstructor : public InternalFunction {
public:
ArrayConstructor(ExecState*, FunctionPrototype*, ArrayPrototype*);
-
virtual ConstructType getConstructData(ConstructData&);
- virtual JSObject* construct(ExecState*, const ArgList&);
-
- virtual JSValue* callAsFunction(ExecState*, JSObject*, const ArgList&);
-
+ virtual CallType getCallData(CallData&);
};
- JSValue* arrayProtoFuncToString(ExecState*, JSObject*, const ArgList&);
- JSValue* arrayProtoFuncToLocaleString(ExecState*, JSObject*, const ArgList&);
- JSValue* arrayProtoFuncConcat(ExecState*, JSObject*, const ArgList&);
- JSValue* arrayProtoFuncJoin(ExecState*, JSObject*, const ArgList&);
- JSValue* arrayProtoFuncPop(ExecState*, JSObject*, const ArgList&);
- JSValue* arrayProtoFuncPush(ExecState*, JSObject*, const ArgList&);
- JSValue* arrayProtoFuncReverse(ExecState*, JSObject*, const ArgList&);
- JSValue* arrayProtoFuncShift(ExecState*, JSObject*, const ArgList&);
- JSValue* arrayProtoFuncSlice(ExecState*, JSObject*, const ArgList&);
- JSValue* arrayProtoFuncSort(ExecState*, JSObject*, const ArgList&);
- JSValue* arrayProtoFuncSplice(ExecState*, JSObject*, const ArgList&);
- JSValue* arrayProtoFuncUnShift(ExecState*, JSObject*, const ArgList&);
- JSValue* arrayProtoFuncEvery(ExecState*, JSObject*, const ArgList&);
- JSValue* arrayProtoFuncForEach(ExecState*, JSObject*, const ArgList&);
- JSValue* arrayProtoFuncSome(ExecState*, JSObject*, const ArgList&);
- JSValue* arrayProtoFuncIndexOf(ExecState*, JSObject*, const ArgList&);
- JSValue* arrayProtoFuncFilter(ExecState*, JSObject*, const ArgList&);
- JSValue* arrayProtoFuncMap(ExecState*, JSObject*, const ArgList&);
- JSValue* arrayProtoFuncLastIndexOf(ExecState*, JSObject*, const ArgList&);
-
} // namespace KJS
#endif // ArrayPrototype_h
// ------------------------------ BooleanPrototype --------------------------
// Functions
-static JSValue* booleanProtoFuncToString(ExecState*, JSObject*, const ArgList&);
-static JSValue* booleanProtoFuncValueOf(ExecState*, JSObject*, const ArgList&);
+static JSValue* booleanProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* booleanProtoFuncValueOf(ExecState*, JSObject*, JSValue*, const ArgList&);
// ECMA 15.6.4
// ECMA 15.6.4.2 + 15.6.4.3
-JSValue* booleanProtoFuncToString(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* booleanProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&BooleanObject::info))
- return throwError(exec, TypeError);
+ if (JSImmediate::isBoolean(thisValue))
+ return jsString(exec, JSImmediate::toString(thisValue));
- JSValue* v = static_cast<BooleanObject*>(thisObj)->internalValue();
- ASSERT(v);
+ if (!thisValue->isObject(&BooleanObject::info))
+ return throwError(exec, TypeError);
- return jsString(exec, v->toString(exec));
+ return jsString(exec, JSImmediate::toString(static_cast<BooleanObject*>(thisValue)->internalValue()));
}
-JSValue* booleanProtoFuncValueOf(ExecState* exec, JSObject* thisObj, const ArgList&)
+
+JSValue* booleanProtoFuncValueOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&BooleanObject::info))
- return throwError(exec, TypeError);
+ if (JSImmediate::isBoolean(thisValue))
+ return thisValue;
- JSValue* v = static_cast<BooleanObject*>(thisObj)->internalValue();
- ASSERT(v);
+ if (!thisValue->isObject(&BooleanObject::info))
+ return throwError(exec, TypeError);
- // TODO: optimize for bool case
- return jsBoolean(v->toBoolean(exec));
+ return static_cast<BooleanObject*>(thisValue)->internalValue();
}
// ------------------------------ BooleanConstructor -----------------------------
putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontDelete | DontEnum);
}
-ConstructType BooleanConstructor::getConstructData(ConstructData&)
-{
- return ConstructTypeNative;
-}
-
// ECMA 15.6.2
-JSObject* BooleanConstructor::construct(ExecState* exec, const ArgList& args)
+JSObject* constructBoolean(ExecState* exec, const ArgList& args)
{
- BooleanObject* obj(new (exec) BooleanObject(exec->lexicalGlobalObject()->booleanPrototype()));
+ BooleanObject* obj = new (exec) BooleanObject(exec->lexicalGlobalObject()->booleanPrototype());
obj->setInternalValue(jsBoolean(args[0]->toBoolean(exec)));
return obj;
}
+static JSObject* constructWithBooleanConstructor(ExecState* exec, JSObject*, const ArgList& args)
+{
+ return constructBoolean(exec, args);
+}
+
+ConstructType BooleanConstructor::getConstructData(ConstructData& constructData)
+{
+ constructData.native.function = constructWithBooleanConstructor;
+ return ConstructTypeNative;
+}
+
// ECMA 15.6.1
-JSValue* BooleanConstructor::callAsFunction(ExecState* exec, JSObject*, const ArgList& args)
+static JSValue* callBooleanConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
- // TODO: optimize for bool case
return jsBoolean(args[0]->toBoolean(exec));
}
+CallType BooleanConstructor::getCallData(CallData& callData)
+{
+ callData.native.function = callBooleanConstructor;
+ return CallTypeNative;
+}
+
+JSObject* constructBooleanFromImmediateBoolean(ExecState* exec, JSValue* immediateBooleanValue)
+{
+ BooleanObject* obj = new (exec) BooleanObject(exec->lexicalGlobalObject()->booleanPrototype());
+ obj->setInternalValue(immediateBooleanValue);
+ return obj;
+}
+
} // namespace KJS
class BooleanConstructor : public InternalFunction {
public:
BooleanConstructor(ExecState*, FunctionPrototype*, BooleanPrototype*);
-
+ private:
virtual ConstructType getConstructData(ConstructData&);
- virtual JSObject* construct(ExecState*, const ArgList&);
-
- virtual JSValue* callAsFunction(ExecState*, JSObject*, const ArgList&);
+ virtual CallType getCallData(CallData&);
};
+ JSObject* constructBooleanFromImmediateBoolean(ExecState*, JSValue*);
+ JSObject* constructBoolean(ExecState*, const ArgList&);
+
} // namespace KJS
#endif // BooleanObject_h
namespace KJS {
+ class ArgList;
+ class ExecState;
class FunctionBodyNode;
+ class JSObject;
+ class JSValue;
class ScopeChainNode;
enum CallType {
CallTypeJS
};
+ typedef JSValue* (*NativeFunction)(ExecState*, JSObject*, JSValue* thisValue, const ArgList&);
+
union CallData {
+ struct {
+ NativeFunction function;
+ } native;
struct {
FunctionBodyNode* functionBody;
ScopeChainNode* scopeChain;
} js;
};
+ JSValue* call(ExecState*, JSValue* functionObject, CallType, const CallData&, JSValue* thisValue, const ArgList&);
+
} // namespace KJS
#endif // CallData_h
namespace KJS {
+ class ArgList;
+ class ExecState;
class FunctionBodyNode;
- class ScopeChain;
+ class JSObject;
+ class JSValue;
+ class ScopeChainNode;
enum ConstructType {
ConstructTypeNone,
ConstructTypeJS
};
+ typedef JSObject* (*NativeConstructor)(ExecState*, JSObject*, const ArgList&);
+
union ConstructData {
+ struct {
+ NativeConstructor function;
+ } native;
struct {
FunctionBodyNode* functionBody;
ScopeChainNode* scopeChain;
} js;
};
+ JSObject* construct(ExecState*, JSValue* constructor, ConstructType, const ConstructData&, const ArgList&);
+
} // namespace KJS
#endif // ConstructData_h
// ------------------------------ FunctionPrototype -------------------------
-static JSValue* functionProtoFuncToString(ExecState*, JSObject*, const ArgList&);
-static JSValue* functionProtoFuncApply(ExecState*, JSObject*, const ArgList&);
-static JSValue* functionProtoFuncCall(ExecState*, JSObject*, const ArgList&);
+static JSValue* functionProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* functionProtoFuncApply(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* functionProtoFuncCall(ExecState*, JSObject*, JSValue*, const ArgList&);
FunctionPrototype::FunctionPrototype(ExecState* exec)
{
putDirectFunction(new (exec) PrototypeFunction(exec, this, 1, exec->propertyNames().call, functionProtoFuncCall), DontEnum);
}
-// ECMA 15.3.4
-JSValue* FunctionPrototype::callAsFunction(ExecState*, JSObject*, const ArgList&)
+static JSValue* callFunctionPrototype(ExecState*, JSObject*, JSValue*, const ArgList&)
{
return jsUndefined();
}
+// ECMA 15.3.4
+CallType FunctionPrototype::getCallData(CallData& callData)
+{
+ callData.native.function = callFunctionPrototype;
+ return CallTypeNative;
+}
+
// Functions
-JSValue* functionProtoFuncToString(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* functionProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj || !thisObj->inherits(&InternalFunction::info)) {
-#ifndef NDEBUG
- fprintf(stderr,"attempted toString() call on null or non-function object\n");
-#endif
+ if (!thisValue->isObject(&InternalFunction::info))
return throwError(exec, TypeError);
- }
- if (thisObj->inherits(&JSFunction::info)) {
- JSFunction* fi = static_cast<JSFunction*>(thisObj);
+ InternalFunction* function = static_cast<InternalFunction*>(thisValue);
+
+ if (function->inherits(&JSFunction::info)) {
+ JSFunction* fi = static_cast<JSFunction*>(thisValue);
return jsString(exec, "function " + fi->functionName().ustring() + "(" + fi->body->paramString() + ") " + fi->body->toSourceString());
}
- return jsString(exec, "function " + static_cast<InternalFunction*>(thisObj)->functionName().ustring() + "() {\n [native code]\n}");
+ return jsString(exec, "function " + function->functionName().ustring() + "() {\n [native code]\n}");
}
-JSValue* functionProtoFuncApply(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* functionProtoFuncApply(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- if (!thisObj->implementsCall())
+ CallData callData;
+ CallType callType = thisValue->getCallData(callData);
+ if (callType == CallTypeNone)
return throwError(exec, TypeError);
JSValue* thisArg = args[0];
JSValue* argArray = args[1];
- JSObject* applyThis;
+ JSValue* applyThis;
if (thisArg->isUndefinedOrNull())
applyThis = exec->globalThisValue();
else
return throwError(exec, TypeError);
}
- return thisObj->callAsFunction(exec, applyThis, applyArgs);
+ return call(exec, thisValue, callType, callData, applyThis, applyArgs);
}
-JSValue* functionProtoFuncCall(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* functionProtoFuncCall(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- if (!thisObj->implementsCall())
+ CallData callData;
+ CallType callType = thisValue->getCallData(callData);
+ if (callType == CallTypeNone)
return throwError(exec, TypeError);
JSValue* thisArg = args[0];
ArgList argsTail;
args.getSlice(1, argsTail);
- return thisObj->callAsFunction(exec, callThis, argsTail);
+ return call(exec, thisValue, callType, callData, callThis, argsTail);
}
// ------------------------------ FunctionConstructor ----------------------------
putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontDelete | DontEnum);
}
-ConstructType FunctionConstructor::getConstructData(ConstructData&)
+static JSObject* constructWithFunctionConstructor(ExecState* exec, JSObject*, const ArgList& args)
{
+ return constructFunction(exec, args);
+}
+
+ConstructType FunctionConstructor::getConstructData(ConstructData& constructData)
+{
+ constructData.native.function = constructWithFunctionConstructor;
return ConstructTypeNative;
}
+static JSValue* callFunctionConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
+{
+ return constructFunction(exec, args);
+}
+
+// ECMA 15.3.1 The Function Constructor Called as a Function
+CallType FunctionConstructor::getCallData(CallData& callData)
+{
+ callData.native.function = callFunctionConstructor;
+ return CallTypeNative;
+}
+
// ECMA 15.3.2 The Function Constructor
-JSObject* FunctionConstructor::construct(ExecState* exec, const ArgList& args, const Identifier& functionName, const UString& sourceURL, int lineNumber)
+JSObject* constructFunction(ExecState* exec, const ArgList& args, const Identifier& functionName, const UString& sourceURL, int lineNumber)
{
UString p("");
UString body;
functionBody->setSource(SourceRange(source, 0, source->length()));
ScopeChain scopeChain(exec->lexicalGlobalObject(), exec->globalThisValue());
- JSFunction* fimp = new (exec) JSFunction(exec, functionName, functionBody.get(), scopeChain.node());
+ JSFunction* function = new (exec) JSFunction(exec, functionName, functionBody.get(), scopeChain.node());
// parse parameter list. throw syntax error on illegal identifiers
int len = p.size();
return throwError(exec, SyntaxError, "Syntax error in parameter list");
}
- JSObject* objCons = exec->lexicalGlobalObject()->objectConstructor();
- JSObject* prototype = objCons->construct(exec, exec->emptyList());
- prototype->putDirect(exec->propertyNames().constructor, fimp, DontEnum);
- fimp->putDirect(exec->propertyNames().prototype, prototype, DontDelete);
- return fimp;
+ JSObject* prototype = constructEmptyObject(exec);
+ prototype->putDirect(exec->propertyNames().constructor, function, DontEnum);
+ function->putDirect(exec->propertyNames().prototype, prototype, DontDelete);
+ return function;
}
// ECMA 15.3.2 The Function Constructor
-JSObject* FunctionConstructor::construct(ExecState* exec, const ArgList& args)
-{
- return construct(exec, args, Identifier(exec, "anonymous"), UString(), 1);
-}
-
-// ECMA 15.3.1 The Function Constructor Called as a Function
-JSValue* FunctionConstructor::callAsFunction(ExecState* exec, JSObject*, const ArgList& args)
+JSObject* constructFunction(ExecState* exec, const ArgList& args)
{
- return construct(exec, args);
+ return constructFunction(exec, args, Identifier(exec, "anonymous"), UString(), 1);
}
} // namespace KJS
class FunctionPrototype : public InternalFunction {
public:
FunctionPrototype(ExecState*);
-
- virtual JSValue* callAsFunction(ExecState*, JSObject*, const ArgList&);
+ private:
+ virtual CallType getCallData(CallData&);
};
/**
class FunctionConstructor : public InternalFunction {
public:
FunctionConstructor(ExecState*, FunctionPrototype*);
-
+ private:
virtual ConstructType getConstructData(ConstructData&);
- virtual JSObject* construct(ExecState*, const ArgList&);
- virtual JSObject* construct(ExecState*, const ArgList&, const Identifier& functionName, const UString& sourceURL, int lineNumber);
-
- virtual JSValue* callAsFunction(ExecState*, JSObject*, const ArgList&);
+ virtual CallType getCallData(CallData&);
};
+ JSObject* constructFunction(ExecState*, const ArgList&, const Identifier& functionName, const UString& sourceURL, int lineNumber);
+ JSObject* constructFunction(ExecState*, const ArgList&);
+
} // namespace KJS
#endif // _FUNCTION_OBJECT_H_
#include "config.h"
#include "JSArray.h"
+#include "ArrayPrototype.h"
#include "PropertyNameArray.h"
#include <wtf/Assertions.h>
#include <wtf/AVLTree.h>
Vector<AVLTreeNodeForArrayCompare> m_nodes;
ExecState* m_exec;
- JSObject* m_compareFunction;
- JSObject* m_globalThisValue;
+ JSValue* m_compareFunction;
+ CallType m_compareCallType;
+ const CallData* m_compareCallData;
+ JSValue* m_globalThisValue;
handle get_less(handle h) { return m_nodes[h].lt & 0x7FFFFFFF; }
void set_less(handle h, handle lh) { m_nodes[h].lt &= 0x80000000; m_nodes[h].lt |= lh; }
ArgList arguments;
arguments.append(va);
arguments.append(vb);
- double compareResult = m_compareFunction->callAsFunction(m_exec, m_globalThisValue, arguments)->toNumber(m_exec);
+ double compareResult = call(m_exec, m_compareFunction, m_compareCallType, *m_compareCallData, m_globalThisValue, arguments)->toNumber(m_exec);
return (compareResult < 0) ? -1 : 1; // Not passing equality through, because we need to store all values, even if equivalent.
}
static handle null() { return 0x7FFFFFFF; }
};
-void JSArray::sort(ExecState* exec, JSObject* compareFunction)
+void JSArray::sort(ExecState* exec, JSValue* compareFunction, CallType callType, const CallData& callData)
{
checkConsistency();
AVLTree<AVLTreeAbstractorForArrayCompare, 44> tree; // Depth 44 is enough for 2^31 items
tree.abstractor().m_exec = exec;
tree.abstractor().m_compareFunction = compareFunction;
+ tree.abstractor().m_compareCallType = callType;
+ tree.abstractor().m_compareCallData = &callData;
tree.abstractor().m_globalThisValue = exec->globalThisValue();
tree.abstractor().m_nodes.resize(usedVectorLength + (m_storage->m_sparseValueMap ? m_storage->m_sparseValueMap->size() : 0));
#endif
+JSArray* constructEmptyArray(ExecState* exec)
+{
+ return new (exec) JSArray(exec->lexicalGlobalObject()->arrayPrototype(), 0);
+}
+
+JSArray* constructEmptyArray(ExecState* exec, unsigned initialLength)
+{
+ return new (exec) JSArray(exec->lexicalGlobalObject()->arrayPrototype(), initialLength);
+}
+
+JSArray* constructArray(ExecState* exec, JSValue* singleItemValue)
+{
+ ArgList values;
+ values.append(singleItemValue);
+ return new (exec) JSArray(exec->lexicalGlobalObject()->arrayPrototype(), values);
+}
+
+JSArray* constructArray(ExecState* exec, const ArgList& values)
+{
+ return new (exec) JSArray(exec->lexicalGlobalObject()->arrayPrototype(), values);
+}
+
}
public:
JSArray(JSObject* prototype, unsigned initialLength);
JSArray(JSObject* prototype, const ArgList& initialValues);
- ~JSArray();
+ virtual ~JSArray();
virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
- virtual void put(ExecState*, const Identifier& propertyName, JSValue*);
- virtual void put(ExecState*, unsigned propertyName, JSValue*);
- virtual bool deleteProperty(ExecState *, const Identifier& propertyName);
- virtual bool deleteProperty(ExecState *, unsigned propertyName);
- virtual void getPropertyNames(ExecState*, PropertyNameArray&);
-
- virtual void mark();
+ virtual void put(ExecState*, unsigned propertyName, JSValue*); // FIXME: Make protected and add setItem.
- virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
unsigned getLength() const { return m_length; }
+ void setLength(unsigned); // OK to use on new arrays, but not if it might be a RegExpMatchArray.
JSValue* getItem(unsigned) const;
void sort(ExecState*);
- void sort(ExecState*, JSObject* compareFunction);
+ void sort(ExecState*, JSValue* compareFunction, CallType, const CallData&);
protected:
+ virtual void put(ExecState*, const Identifier& propertyName, JSValue*);
+ virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
+ virtual bool deleteProperty(ExecState*, unsigned propertyName);
+ virtual void getPropertyNames(ExecState*, PropertyNameArray&);
+ virtual void mark();
+
void* lazyCreationData();
void setLazyCreationData(void*);
private:
+ using JSObject::get;
+
+ virtual const ClassInfo* classInfo() const { return &info; }
+
static JSValue* lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
bool inlineGetOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
- void setLength(unsigned);
bool increaseVectorLength(unsigned newLength);
unsigned compactForSorting();
ArrayStorage* m_storage;
};
+ JSArray* constructEmptyArray(ExecState*);
+ JSArray* constructEmptyArray(ExecState*, unsigned initialLength);
+ JSArray* constructArray(ExecState*, JSValue* singleItemValue);
+ JSArray* constructArray(ExecState*, const ArgList& values);
+
} // namespace KJS
#endif
return CallTypeJS;
}
-JSValue* JSFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* JSFunction::call(ExecState* exec, JSValue* thisValue, const ArgList& args)
{
JSValue* exception = 0;
RegisterFileStack* stack = &exec->dynamicGlobalObject()->registerFileStack();
RegisterFile* current = stack->current();
if (!current->safeForReentry()) {
stack->pushFunctionRegisterFile();
- JSValue* result = exec->machine()->execute(body.get(), exec, this, thisObj, args, stack, _scope.node(), &exception);
+ JSValue* result = exec->machine()->execute(body.get(), exec, this, thisValue->toThisObject(exec), args, stack, _scope.node(), &exception);
stack->popFunctionRegisterFile();
exec->setException(exception);
return result;
} else {
- JSValue* result = exec->machine()->execute(body.get(), exec, this, thisObj, args, stack, _scope.node(), &exception);
+ JSValue* result = exec->machine()->execute(body.get(), exec, this, thisValue->toThisObject(exec), args, stack, _scope.node(), &exception);
current->setSafeForReentry(true);
exec->setException(exception);
return result;
* it appears associates with it. eg:
* function f2(x, x): getParameterName(0) --> null
*/
-Identifier JSFunction::getParameterName(int index)
+const Identifier& JSFunction::getParameterName(int index)
{
Vector<Identifier>& parameters = body->parameters();
if (static_cast<size_t>(index) >= body->parameters().size())
return JSGlobalData::threadInstance().propertyNames->nullIdentifier;
- Identifier name = parameters[index];
+ const Identifier& name = parameters[index];
// Are there any subsequent parameters with the same name?
size_t size = parameters.size();
return s.toDouble( true /*tolerant*/, false /* NaN for empty string */ );
}
-JSValue* globalFuncEval(ExecState* exec, PrototypeReflexiveFunction* function, JSObject* thisObj, const ArgList& args)
+JSValue* globalFuncEval(ExecState* exec, JSObject* function, JSValue* thisValue, const ArgList& args)
{
- JSGlobalObject* globalObject = thisObj->toGlobalObject(exec);
-
+ JSObject* thisObject = thisValue->toThisObject(exec);
+ JSGlobalObject* globalObject = thisObject->toGlobalObject(exec);
if (!globalObject || globalObject->evalFunction() != function)
return throwError(exec, EvalError, "The \"this\" value passed to eval must be the global object from which eval originated");
return throwError(exec, SyntaxError, errMsg, errLine, sourceId, NULL);
JSValue* exception = 0;
- JSValue* value = exec->machine()->execute(evalNode.get(), exec, thisObj, &exec->dynamicGlobalObject()->registerFileStack(), globalObject->globalScopeChain().node(), &exception);
+ JSValue* value = exec->machine()->execute(evalNode.get(), exec, thisObject, &exec->dynamicGlobalObject()->registerFileStack(), globalObject->globalScopeChain().node(), &exception);
if (exception) {
exec->setException(exception);
return value ? value : jsUndefined();
}
-JSValue* globalFuncParseInt(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* globalFuncParseInt(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
return jsNumber(exec, parseInt(args[0]->toString(exec), args[1]->toInt32(exec)));
}
-JSValue* globalFuncParseFloat(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* globalFuncParseFloat(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
return jsNumber(exec, parseFloat(args[0]->toString(exec)));
}
-JSValue* globalFuncIsNaN(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* globalFuncIsNaN(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
return jsBoolean(isnan(args[0]->toNumber(exec)));
}
-JSValue* globalFuncIsFinite(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* globalFuncIsFinite(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
double n = args[0]->toNumber(exec);
return jsBoolean(!isnan(n) && !isinf(n));
}
-JSValue* globalFuncDecodeURI(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* globalFuncDecodeURI(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
static const char do_not_unescape_when_decoding_URI[] =
"#$&+,/:;=?@";
return decode(exec, args, do_not_unescape_when_decoding_URI, true);
}
-JSValue* globalFuncDecodeURIComponent(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* globalFuncDecodeURIComponent(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
return decode(exec, args, "", true);
}
-JSValue* globalFuncEncodeURI(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* globalFuncEncodeURI(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
static const char do_not_escape_when_encoding_URI[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
return encode(exec, args, do_not_escape_when_encoding_URI);
}
-JSValue* globalFuncEncodeURIComponent(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* globalFuncEncodeURIComponent(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
static const char do_not_escape_when_encoding_URI_component[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
return encode(exec, args, do_not_escape_when_encoding_URI_component);
}
-JSValue* globalFuncEscape(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* globalFuncEscape(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
static const char do_not_escape[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
return jsString(exec, r);
}
-JSValue* globalFuncUnescape(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* globalFuncUnescape(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
UString s = "", str = args[0]->toString(exec);
int k = 0, len = str.size();
}
#ifndef NDEBUG
-JSValue* globalFuncKJSPrint(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* globalFuncKJSPrint(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
CStringBuffer string;
args[0]->toString(exec).getCString(string);
// ------------------------------ PrototypeFunction -------------------------------
-PrototypeFunction::PrototypeFunction(ExecState* exec, int len, const Identifier& name, JSMemberFunction function)
+PrototypeFunction::PrototypeFunction(ExecState* exec, int len, const Identifier& name, NativeFunction function)
: InternalFunction(exec->lexicalGlobalObject()->functionPrototype(), name)
, m_function(function)
{
putDirect(exec->propertyNames().length, jsNumber(exec, len), DontDelete | ReadOnly | DontEnum);
}
-PrototypeFunction::PrototypeFunction(ExecState* exec, FunctionPrototype* functionPrototype, int len, const Identifier& name, JSMemberFunction function)
+PrototypeFunction::PrototypeFunction(ExecState* exec, FunctionPrototype* functionPrototype, int len, const Identifier& name, NativeFunction function)
: InternalFunction(functionPrototype, name)
, m_function(function)
{
putDirect(exec->propertyNames().length, jsNumber(exec, len), DontDelete | ReadOnly | DontEnum);
}
-JSValue* PrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const ArgList& args)
+CallType PrototypeFunction::getCallData(CallData& callData)
{
- return m_function(exec, thisObj, args);
+ callData.native.function = m_function;
+ return CallTypeNative;
}
// ------------------------------ PrototypeReflexiveFunction -------------------------------
-PrototypeReflexiveFunction::PrototypeReflexiveFunction(ExecState* exec, FunctionPrototype* functionPrototype, int len, const Identifier& name, JSMemberFunction function, JSGlobalObject* cachedGlobalObject)
- : InternalFunction(functionPrototype, name)
- , m_function(function)
+GlobalEvalFunction::GlobalEvalFunction(ExecState* exec, FunctionPrototype* functionPrototype, int len, const Identifier& name, NativeFunction function, JSGlobalObject* cachedGlobalObject)
+ : PrototypeFunction(exec, functionPrototype, len, name, function)
, m_cachedGlobalObject(cachedGlobalObject)
{
- ASSERT_ARG(function, function);
ASSERT_ARG(cachedGlobalObject, cachedGlobalObject);
- putDirect(exec->propertyNames().length, jsNumber(exec, len), DontDelete | ReadOnly | DontEnum);
}
-JSValue* PrototypeReflexiveFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const ArgList& args)
+void GlobalEvalFunction::mark()
{
- return m_function(exec, this, thisObj, args);
-}
-
-void PrototypeReflexiveFunction::mark()
-{
- InternalFunction::mark();
+ PrototypeFunction::mark();
if (!m_cachedGlobalObject->marked())
m_cachedGlobalObject->mark();
}
class InternalFunction : public JSObject {
public:
+ static const ClassInfo info;
+ virtual const ClassInfo* classInfo() const { return &info; }
+ const Identifier& functionName() const { return m_name; }
+
+ protected:
InternalFunction();
InternalFunction(FunctionPrototype*, const Identifier&);
- virtual CallType getCallData(CallData&);
-
- virtual JSValue* callAsFunction(ExecState*, JSObject* thisObjec, const ArgList& args) = 0;
+ private:
+ virtual CallType getCallData(CallData&) = 0;
virtual bool implementsHasInstance() const;
- virtual const ClassInfo* classInfo() const { return &info; }
- static const ClassInfo info;
- const Identifier& functionName() const { return m_name; }
-
- private:
Identifier m_name;
};
virtual void put(ExecState*, const Identifier& propertyName, JSValue*);
virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
- virtual ConstructType getConstructData(ConstructData&);
- virtual JSObject* construct(ExecState*, const ArgList& args);
-
- virtual CallType getCallData(CallData&);
- virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const ArgList& args);
+ JSObject* construct(ExecState*, const ArgList&);
+ JSValue* call(ExecState*, JSValue* thisValue, const ArgList&);
- // Note: unlike body->paramName, this returns Identifier::null for parameters
- // that will never get set, due to later param having the same name
- Identifier getParameterName(int index);
+ // Note: Returns a null identifier for any parameters that will never get set
+ // due to a later parameter with the same name.
+ const Identifier& getParameterName(int index);
- virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
RefPtr<FunctionBodyNode> body;
virtual void mark();
private:
+ virtual const ClassInfo* classInfo() const { return &info; }
+ virtual ConstructType getConstructData(ConstructData&);
+ virtual CallType getCallData(CallData&);
+
ScopeChain _scope;
static JSValue* argumentsGetter(ExecState*, const Identifier&, const PropertySlot&);
class IndexToNameMap {
public:
- IndexToNameMap(JSFunction*, const ArgList& args);
+ IndexToNameMap(JSFunction*, const ArgList&);
~IndexToNameMap();
Identifier& operator[](const Identifier& index);
class PrototypeFunction : public InternalFunction {
public:
- typedef JSValue* (*JSMemberFunction)(ExecState*, JSObject* thisObj, const ArgList&);
-
- PrototypeFunction(ExecState*, int len, const Identifier&, JSMemberFunction);
- PrototypeFunction(ExecState*, FunctionPrototype*, int len, const Identifier&, JSMemberFunction);
-
- virtual JSValue* callAsFunction(ExecState* exec, JSObject* thisObj, const ArgList&);
+ PrototypeFunction(ExecState*, int len, const Identifier&, NativeFunction);
+ PrototypeFunction(ExecState*, FunctionPrototype*, int len, const Identifier&, NativeFunction);
private:
- const JSMemberFunction m_function;
- };
-
+ virtual CallType getCallData(CallData&);
- // Just like PrototypeFunction, but callbacks also get passed the JS function object.
- class PrototypeReflexiveFunction : public InternalFunction {
- public:
- typedef JSValue* (*JSMemberFunction)(ExecState*, PrototypeReflexiveFunction*, JSObject* thisObj, const ArgList&);
+ const NativeFunction m_function;
+ };
- PrototypeReflexiveFunction(ExecState*, FunctionPrototype*, int len, const Identifier&, JSMemberFunction, JSGlobalObject* expectedThisObject);
+ class GlobalEvalFunction : public PrototypeFunction {
+ public:
+ GlobalEvalFunction(ExecState*, FunctionPrototype*, int len, const Identifier&, NativeFunction, JSGlobalObject* expectedThisObject);
+ JSGlobalObject* cachedGlobalObject() const { return m_cachedGlobalObject; }
- virtual void mark();
- virtual JSValue* callAsFunction(ExecState* exec, JSObject* thisObj, const ArgList&);
+ private:
+ virtual void mark();
- JSGlobalObject* cachedGlobalObject() const { return m_cachedGlobalObject; }
-
- private:
- const JSMemberFunction m_function;
- JSGlobalObject* m_cachedGlobalObject;
- };
+ JSGlobalObject* m_cachedGlobalObject;
+ };
// Global Functions
- JSValue* globalFuncEval(ExecState*, PrototypeReflexiveFunction*, JSObject*, const ArgList&);
- JSValue* globalFuncParseInt(ExecState*, JSObject*, const ArgList&);
- JSValue* globalFuncParseFloat(ExecState*, JSObject*, const ArgList&);
- JSValue* globalFuncIsNaN(ExecState*, JSObject*, const ArgList&);
- JSValue* globalFuncIsFinite(ExecState*, JSObject*, const ArgList&);
- JSValue* globalFuncDecodeURI(ExecState*, JSObject*, const ArgList&);
- JSValue* globalFuncDecodeURIComponent(ExecState*, JSObject*, const ArgList&);
- JSValue* globalFuncEncodeURI(ExecState*, JSObject*, const ArgList&);
- JSValue* globalFuncEncodeURIComponent(ExecState*, JSObject*, const ArgList&);
- JSValue* globalFuncEscape(ExecState*, JSObject*, const ArgList&);
- JSValue* globalFuncUnescape(ExecState*, JSObject*, const ArgList&);
+ JSValue* globalFuncEval(ExecState*, JSObject*, JSValue*, const ArgList&);
+ JSValue* globalFuncParseInt(ExecState*, JSObject*, JSValue*, const ArgList&);
+ JSValue* globalFuncParseFloat(ExecState*, JSObject*, JSValue*, const ArgList&);
+ JSValue* globalFuncIsNaN(ExecState*, JSObject*, JSValue*, const ArgList&);
+ JSValue* globalFuncIsFinite(ExecState*, JSObject*, JSValue*, const ArgList&);
+ JSValue* globalFuncDecodeURI(ExecState*, JSObject*, JSValue*, const ArgList&);
+ JSValue* globalFuncDecodeURIComponent(ExecState*, JSObject*, JSValue*, const ArgList&);
+ JSValue* globalFuncEncodeURI(ExecState*, JSObject*, JSValue*, const ArgList&);
+ JSValue* globalFuncEncodeURIComponent(ExecState*, JSObject*, JSValue*, const ArgList&);
+ JSValue* globalFuncEscape(ExecState*, JSObject*, JSValue*, const ArgList&);
+ JSValue* globalFuncUnescape(ExecState*, JSObject*, JSValue*, const ArgList&);
#ifndef NDEBUG
- JSValue* globalFuncKJSPrint(ExecState*, JSObject*, const ArgList&);
+ JSValue* globalFuncKJSPrint(ExecState*, JSObject*, JSValue*, const ArgList&);
#endif
static const double mantissaOverflowLowerBound = 9007199254740992.0;
d()->URIErrorPrototype = 0;
// Constructors
- d()->objectConstructor = 0;
- d()->functionConstructor = 0;
- d()->arrayConstructor = 0;
- d()->stringConstructor = 0;
- d()->booleanConstructor = 0;
- d()->numberConstructor = 0;
- d()->dateConstructor = 0;
d()->regExpConstructor = 0;
d()->errorConstructor = 0;
ExecState* exec = d()->globalExec.get();
// Prototypes
+
d()->functionPrototype = new (exec) FunctionPrototype(exec);
d()->objectPrototype = new (exec) ObjectPrototype(exec, d()->functionPrototype);
d()->functionPrototype->setPrototype(d()->objectPrototype);
d()->URIErrorPrototype = new (exec) NativeErrorPrototype(exec, d()->errorPrototype, "URIError", "URIError");
// Constructors
- d()->objectConstructor = new (exec) ObjectConstructor(exec, d()->objectPrototype, d()->functionPrototype);
- d()->functionConstructor = new (exec) FunctionConstructor(exec, d()->functionPrototype);
- d()->arrayConstructor = new (exec) ArrayConstructor(exec, d()->functionPrototype, d()->arrayPrototype);
- d()->stringConstructor = new (exec) StringConstructor(exec, d()->functionPrototype, d()->stringPrototype);
- d()->booleanConstructor = new (exec) BooleanConstructor(exec, d()->functionPrototype, d()->booleanPrototype);
- d()->numberConstructor = new (exec) NumberConstructor(exec, d()->functionPrototype, d()->numberPrototype);
- d()->dateConstructor = new (exec) DateConstructor(exec, d()->functionPrototype, d()->datePrototype);
+
+ JSValue* objectConstructor = new (exec) ObjectConstructor(exec, d()->objectPrototype, d()->functionPrototype);
+ JSValue* functionConstructor = new (exec) FunctionConstructor(exec, d()->functionPrototype);
+ JSValue* arrayConstructor = new (exec) ArrayConstructor(exec, d()->functionPrototype, d()->arrayPrototype);
+ JSValue* stringConstructor = new (exec) StringConstructor(exec, d()->functionPrototype, d()->stringPrototype);
+ JSValue* booleanConstructor = new (exec) BooleanConstructor(exec, d()->functionPrototype, d()->booleanPrototype);
+ JSValue* numberConstructor = new (exec) NumberConstructor(exec, d()->functionPrototype, d()->numberPrototype);
+ JSValue* dateConstructor = new (exec) DateConstructor(exec, d()->functionPrototype, d()->datePrototype);
+
d()->regExpConstructor = new (exec) RegExpConstructor(exec, d()->functionPrototype, d()->regExpPrototype);
+
d()->errorConstructor = new (exec) ErrorConstructor(exec, d()->functionPrototype, d()->errorPrototype);
d()->evalErrorConstructor = new (exec) NativeErrorConstructor(exec, d()->functionPrototype, d()->evalErrorPrototype);
d()->typeErrorConstructor = new (exec) NativeErrorConstructor(exec, d()->functionPrototype, d()->typeErrorPrototype);
d()->URIErrorConstructor = new (exec) NativeErrorConstructor(exec, d()->functionPrototype, d()->URIErrorPrototype);
- d()->functionPrototype->putDirect(exec->propertyNames().constructor, d()->functionConstructor, DontEnum);
-
- d()->objectPrototype->putDirect(exec->propertyNames().constructor, d()->objectConstructor, DontEnum);
- d()->functionPrototype->putDirect(exec->propertyNames().constructor, d()->functionConstructor, DontEnum);
- d()->arrayPrototype->putDirect(exec->propertyNames().constructor, d()->arrayConstructor, DontEnum);
- d()->booleanPrototype->putDirect(exec->propertyNames().constructor, d()->booleanConstructor, DontEnum);
- d()->stringPrototype->putDirect(exec->propertyNames().constructor, d()->stringConstructor, DontEnum);
- d()->numberPrototype->putDirect(exec->propertyNames().constructor, d()->numberConstructor, DontEnum);
- d()->datePrototype->putDirect(exec->propertyNames().constructor, d()->dateConstructor, DontEnum);
+ d()->functionPrototype->putDirect(exec->propertyNames().constructor, functionConstructor, DontEnum);
+
+ d()->objectPrototype->putDirect(exec->propertyNames().constructor, objectConstructor, DontEnum);
+ d()->functionPrototype->putDirect(exec->propertyNames().constructor, functionConstructor, DontEnum);
+ d()->arrayPrototype->putDirect(exec->propertyNames().constructor, arrayConstructor, DontEnum);
+ d()->booleanPrototype->putDirect(exec->propertyNames().constructor, booleanConstructor, DontEnum);
+ d()->stringPrototype->putDirect(exec->propertyNames().constructor, stringConstructor, DontEnum);
+ d()->numberPrototype->putDirect(exec->propertyNames().constructor, numberConstructor, DontEnum);
+ d()->datePrototype->putDirect(exec->propertyNames().constructor, dateConstructor, DontEnum);
d()->regExpPrototype->putDirect(exec->propertyNames().constructor, d()->regExpConstructor, DontEnum);
d()->errorPrototype->putDirect(exec->propertyNames().constructor, d()->errorConstructor, DontEnum);
d()->evalErrorPrototype->putDirect(exec->propertyNames().constructor, d()->evalErrorConstructor, DontEnum);
// FIXME: These properties could be handled by a static hash table.
- putDirect(Identifier(exec, "Object"), d()->objectConstructor, DontEnum);
- putDirect(Identifier(exec, "Function"), d()->functionConstructor, DontEnum);
- putDirect(Identifier(exec, "Array"), d()->arrayConstructor, DontEnum);
- putDirect(Identifier(exec, "Boolean"), d()->booleanConstructor, DontEnum);
- putDirect(Identifier(exec, "String"), d()->stringConstructor, DontEnum);
- putDirect(Identifier(exec, "Number"), d()->numberConstructor, DontEnum);
- putDirect(Identifier(exec, "Date"), d()->dateConstructor, DontEnum);
+ putDirect(Identifier(exec, "Object"), objectConstructor, DontEnum);
+ putDirect(Identifier(exec, "Function"), functionConstructor, DontEnum);
+ putDirect(Identifier(exec, "Array"), arrayConstructor, DontEnum);
+ putDirect(Identifier(exec, "Boolean"), booleanConstructor, DontEnum);
+ putDirect(Identifier(exec, "String"), stringConstructor, DontEnum);
+ putDirect(Identifier(exec, "Number"), numberConstructor, DontEnum);
+ putDirect(Identifier(exec, "Date"), dateConstructor, DontEnum);
putDirect(Identifier(exec, "RegExp"), d()->regExpConstructor, DontEnum);
putDirect(Identifier(exec, "Error"), d()->errorConstructor, DontEnum);
putDirect(Identifier(exec, "EvalError"), d()->evalErrorConstructor);
// Set global functions.
- d()->evalFunction = new (exec) PrototypeReflexiveFunction(exec, d()->functionPrototype, 1, exec->propertyNames().eval, globalFuncEval, this);
+ d()->evalFunction = new (exec) GlobalEvalFunction(exec, d()->functionPrototype, 1, exec->propertyNames().eval, globalFuncEval, this);
putDirectFunction(d()->evalFunction, DontEnum);
putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 2, Identifier(exec, "parseInt"), globalFuncParseInt), DontEnum);
putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "parseFloat"), globalFuncParseFloat), DontEnum);
markIfNeeded(d()->globalExec->exception());
- markIfNeeded(d()->objectConstructor);
- markIfNeeded(d()->functionConstructor);
- markIfNeeded(d()->arrayConstructor);
- markIfNeeded(d()->booleanConstructor);
- markIfNeeded(d()->stringConstructor);
- markIfNeeded(d()->numberConstructor);
- markIfNeeded(d()->dateConstructor);
markIfNeeded(d()->regExpConstructor);
markIfNeeded(d()->errorConstructor);
markIfNeeded(d()->evalErrorConstructor);
namespace KJS {
- class ArrayConstructor;
class ArrayPrototype;
- class BooleanConstructor;
class BooleanPrototype;
- class DateConstructor;
class DatePrototype;
class Debugger;
class ErrorConstructor;
class ErrorPrototype;
class EvalError;
class EvalErrorPrototype;
- class FunctionConstructor;
class FunctionPrototype;
- struct HashTable;
+ class GlobalEvalFunction;
class JSGlobalObject;
class NativeErrorConstructor;
class NativeErrorPrototype;
- class NumberConstructor;
class NumberPrototype;
- class ObjectConstructor;
class ObjectPrototype;
class ProgramCodeBlock;
- class PrototypeReflexiveFunction;
class RangeError;
class RangeErrorPrototype;
class ReferenceError;
class RegExpPrototype;
class RuntimeMethod;
class ScopeChain;
- class StringConstructor;
class StringPrototype;
class SyntaxErrorPrototype;
class TypeError;
class TypeErrorPrototype;
class UriError;
class UriErrorPrototype;
+
struct ActivationStackNode;
+ struct HashTable;
typedef Vector<ExecState*, 16> ExecStateStack;
unsigned tickCount;
unsigned ticksUntilNextTimeoutCheck;
- ObjectConstructor* objectConstructor;
- FunctionConstructor* functionConstructor;
- ArrayConstructor* arrayConstructor;
- BooleanConstructor* booleanConstructor;
- StringConstructor* stringConstructor;
- NumberConstructor* numberConstructor;
- DateConstructor* dateConstructor;
RegExpConstructor* regExpConstructor;
ErrorConstructor* errorConstructor;
NativeErrorConstructor* evalErrorConstructor;
NativeErrorConstructor* typeErrorConstructor;
NativeErrorConstructor* URIErrorConstructor;
- PrototypeReflexiveFunction* evalFunction;
+ GlobalEvalFunction* evalFunction;
ObjectPrototype* objectPrototype;
FunctionPrototype* functionPrototype;
}
protected:
- JSGlobalObject(JSValue* proto, JSObject* globalThisValue)
- : JSVariableObject(proto, new JSGlobalObjectData(this, globalThisValue))
+ JSGlobalObject(JSValue* prototype, JSObject* globalThisValue)
+ : JSVariableObject(prototype, new JSGlobalObjectData(this, globalThisValue))
{
init(globalThisValue);
}
// The following accessors return pristine values, even if a script
// replaces the global object's associated property.
- ObjectConstructor* objectConstructor() const { return d()->objectConstructor; }
- FunctionConstructor* functionConstructor() const { return d()->functionConstructor; }
- ArrayConstructor* arrayConstructor() const { return d()->arrayConstructor; }
- BooleanConstructor* booleanConstructor() const { return d()->booleanConstructor; }
- StringConstructor* stringConstructor() const{ return d()->stringConstructor; }
- NumberConstructor* numberConstructor() const{ return d()->numberConstructor; }
- DateConstructor* dateConstructor() const{ return d()->dateConstructor; }
RegExpConstructor* regExpConstructor() const { return d()->regExpConstructor; }
+
ErrorConstructor* errorConstructor() const { return d()->errorConstructor; }
NativeErrorConstructor* evalErrorConstructor() const { return d()->evalErrorConstructor; }
NativeErrorConstructor* rangeErrorConstructor() const { return d()->rangeErrorConstructor; }
NativeErrorConstructor* typeErrorConstructor() const { return d()->typeErrorConstructor; }
NativeErrorConstructor* URIErrorConstructor() const { return d()->URIErrorConstructor; }
- PrototypeReflexiveFunction* evalFunction() const { return d()->evalFunction; }
+ GlobalEvalFunction* evalFunction() const { return d()->evalFunction; }
ObjectPrototype* objectPrototype() const { return d()->objectPrototype; }
FunctionPrototype* functionPrototype() const { return d()->functionPrototype; }
namespace KJS {
-JSObject *JSImmediate::toObject(const JSValue *v, ExecState *exec)
+JSObject* JSImmediate::toObject(const JSValue *v, ExecState *exec)
{
ASSERT(isImmediate(v));
if (v == jsNull())
return new (exec) JSNotAnObject(throwError(exec, TypeError, "Null value"));
- else if (v == jsUndefined())
+ if (v == jsUndefined())
return new (exec) JSNotAnObject(throwError(exec, TypeError, "Undefined value"));
- else if (isBoolean(v)) {
- ArgList args;
- args.append(const_cast<JSValue *>(v));
- return exec->lexicalGlobalObject()->booleanConstructor()->construct(exec, args);
- } else {
- ASSERT(isNumber(v));
- ArgList args;
- args.append(const_cast<JSValue *>(v));
- return exec->lexicalGlobalObject()->numberConstructor()->construct(exec, args);
- }
+ if (isBoolean(v))
+ return constructBooleanFromImmediateBoolean(exec, const_cast<JSValue*>(v));
+ ASSERT(isNumber(v));
+ return constructNumberFromImmediateNumber(exec, const_cast<JSValue*>(v));
}
UString JSImmediate::toString(const JSValue* v)
return false;
}
-JSValue* JSNotAnObject::defaultValue(ExecState* exec, JSType) const
-{
- UNUSED_PARAM(exec);
- ASSERT(exec->hadException() && exec->exception() == m_exception);
- return m_exception;
-}
-
-JSObject* JSNotAnObject::construct(ExecState* exec, const ArgList&)
-{
- UNUSED_PARAM(exec);
- ASSERT(exec->hadException() && exec->exception() == m_exception);
- return m_exception;
-}
-
-JSObject* JSNotAnObject::construct(ExecState* exec, const ArgList&, const Identifier&, const UString&, int)
-{
- UNUSED_PARAM(exec);
- ASSERT(exec->hadException() && exec->exception() == m_exception);
- return m_exception;
-}
-
-JSValue* JSNotAnObject::callAsFunction(ExecState* exec, JSObject*, const ArgList&)
-{
- UNUSED_PARAM(exec);
- ASSERT(exec->hadException() && exec->exception() == m_exception);
- return m_exception;
-}
-
void JSNotAnObject::getPropertyNames(ExecState* exec, PropertyNameArray&)
{
UNUSED_PARAM(exec);
{
}
- // JSValue methods
+ private:
+ // JSValue methods
virtual JSValue* toPrimitive(ExecState*, JSType preferredType = UnspecifiedType) const;
virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*&);
virtual bool toBoolean(ExecState*) const;
virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
virtual bool deleteProperty(ExecState*, unsigned propertyName);
- virtual JSValue* defaultValue(ExecState*, JSType hint) const;
-
- virtual JSObject* construct(ExecState*, const ArgList&);
- virtual JSObject* construct(ExecState*, const ArgList&, const Identifier& functionName, const UString& sourceURL, int lineNumber);
-
- virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const ArgList&);
-
virtual void getPropertyNames(ExecState*, PropertyNameArray&);
- private:
JSObject* m_exception;
};
return ObjectType;
}
-const ClassInfo *JSObject::classInfo() const
-{
- return 0;
-}
-
UString JSObject::className() const
{
const ClassInfo *ci = classInfo();
}
// ECMA 8.6.2.2
-void JSObject::put(ExecState* exec, const Identifier &propertyName, JSValue *value)
+void JSObject::put(ExecState* exec, const Identifier& propertyName, JSValue* value)
{
ASSERT(value);
ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
if (propertyName == exec->propertyNames().underscoreProto) {
JSObject* proto = value->getObject();
- // Setting __proto__ to a non-object, non-null value is silently ignored to match Mozilla
+ // Setting __proto__ to a non-object, non-null value is silently ignored to match Mozilla.
if (!proto && value != jsNull())
return;
}
proto = proto->prototype() ? proto->prototype()->getObject() : 0;
}
-
+
setPrototype(value);
return;
}
// Check if there are any setters or getters in the prototype chain
- JSObject *obj = this;
- bool hasGettersOrSetters = false;
- while (true) {
- if (obj->_prop.hasGetterSetterProperties()) {
- hasGettersOrSetters = true;
- break;
+ JSObject* obj;
+ JSValue* prototype;
+ for (obj = this; !obj->_prop.hasGetterSetterProperties(); obj = static_cast<JSObject*>(prototype)) {
+ prototype = obj->_proto;
+ if (prototype == jsNull()) {
+ _prop.put(propertyName, value, 0, true);
+ return;
}
-
- if (obj->_proto == jsNull())
- break;
-
- obj = static_cast<JSObject *>(obj->_proto);
}
-
- if (hasGettersOrSetters) {
- unsigned attributes;
- if (_prop.get(propertyName, attributes) && attributes & ReadOnly)
- return;
- obj = this;
- while (true) {
- if (JSValue *gs = obj->_prop.get(propertyName, attributes)) {
- if (attributes & IsGetterSetter) {
- JSObject *setterFunc = static_cast<GetterSetter *>(gs)->getSetter();
-
- if (!setterFunc) {
- throwSetterError(exec);
- return;
- }
-
- ArgList args;
- args.append(value);
-
- setterFunc->callAsFunction(exec, this->toThisObject(exec), args);
+ unsigned attributes;
+ if (_prop.get(propertyName, attributes) && attributes & ReadOnly)
+ return;
+
+ for (; ; obj = static_cast<JSObject*>(prototype)) {
+ if (JSValue* gs = obj->_prop.get(propertyName, attributes)) {
+ if (attributes & IsGetterSetter) {
+ JSObject* setterFunc = static_cast<GetterSetter*>(gs)->setter();
+ if (!setterFunc) {
+ throwSetterError(exec);
return;
- } else {
- // If there's an existing property on the object or one of its
- // prototype it should be replaced, so we just break here.
- break;
}
+
+ CallData callData;
+ CallType callType = setterFunc->getCallData(callData);
+ ArgList args;
+ args.append(value);
+ call(exec, setterFunc, callType, callData, this, args);
+ return;
}
-
- if (!obj->_proto->isObject())
- break;
-
- obj = static_cast<JSObject *>(obj->_proto);
+
+ // If there's an existing property on the object or one of its
+ // prototypes it should be replaced, so break here.
+ break;
}
+
+ prototype = obj->_proto;
+ if (prototype == jsNull())
+ break;
}
-
+
_prop.put(propertyName, value, 0, true);
}
return deleteProperty(exec, Identifier::from(exec, propertyName));
}
-static ALWAYS_INLINE JSValue *tryGetAndCallProperty(ExecState *exec, const JSObject *object, const Identifier &propertyName) {
- JSValue* v = object->get(exec, propertyName);
- if (v->isObject()) {
- JSObject* o = static_cast<JSObject*>(v);
- CallData data;
- CallType callType = o->getCallData(data);
- // spec says "not primitive type" but ...
- if (callType != CallTypeNone) {
- JSObject* thisObj = const_cast<JSObject*>(object);
- JSValue* def = o->callAsFunction(exec, thisObj->toThisObject(exec), exec->emptyList());
- JSType defType = def->type();
- ASSERT(defType != GetterSetterType);
- if (defType != ObjectType)
- return def;
- }
- }
- return NULL;
+static ALWAYS_INLINE JSValue* callDefaultValueFunction(ExecState* exec, const JSObject* object, const Identifier& propertyName)
+{
+ JSValue* function = object->get(exec, propertyName);
+ CallData callData;
+ CallType callType = function->getCallData(callData);
+ if (callType == CallTypeNone)
+ return 0;
+ JSValue* result = call(exec, function, callType, callData, const_cast<JSObject*>(object), exec->emptyList());
+ ASSERT(result->type() != GetterSetterType);
+ if (exec->hadException())
+ return exec->exception();
+ if (result->isObject())
+ return 0;
+ return result;
}
bool JSObject::getPrimitiveNumber(ExecState* exec, double& number, JSValue*& result)
// ECMA 8.6.2.6
JSValue* JSObject::defaultValue(ExecState* exec, JSType hint) const
{
- // We need this check to guard against the case where this object is rhs of
- // a binary expression where lhs threw an exception in its conversion to
- // primitive
- if (exec->hadException())
- return exec->exception();
- /* Prefer String for Date objects */
- if ((hint == StringType) || (hint != NumberType && _proto == exec->lexicalGlobalObject()->datePrototype())) {
- if (JSValue* v = tryGetAndCallProperty(exec, this, exec->propertyNames().toString))
- return v;
- if (JSValue* v = tryGetAndCallProperty(exec, this, exec->propertyNames().valueOf))
- return v;
- } else {
- if (JSValue* v = tryGetAndCallProperty(exec, this, exec->propertyNames().valueOf))
- return v;
- if (JSValue* v = tryGetAndCallProperty(exec, this, exec->propertyNames().toString))
- return v;
- }
+ // We need this check to guard against the case where this object is rhs of
+ // a binary expression where lhs threw an exception in its conversion to
+ // primitive.
+ if (exec->hadException())
+ return exec->exception();
+
+ // Must call toString first for Date objects.
+ if ((hint == StringType) || (hint != NumberType && _proto == exec->lexicalGlobalObject()->datePrototype())) {
+ if (JSValue* value = callDefaultValueFunction(exec, this, exec->propertyNames().toString))
+ return value;
+ if (JSValue* value = callDefaultValueFunction(exec, this, exec->propertyNames().valueOf))
+ return value;
+ } else {
+ if (JSValue* value = callDefaultValueFunction(exec, this, exec->propertyNames().valueOf))
+ return value;
+ if (JSValue* value = callDefaultValueFunction(exec, this, exec->propertyNames().toString))
+ return value;
+ }
- if (exec->hadException())
- return exec->exception();
+ ASSERT(!exec->hadException());
- return throwError(exec, TypeError, "No default value");
+ return throwError(exec, TypeError, "No default value");
}
const HashEntry* JSObject::findPropertyHashEntry(ExecState* exec, const Identifier& propertyName) const
if (v) {
if (v->type() != GetterSetterType)
return jsUndefined();
- JSObject* funcObj = static_cast<GetterSetter*>(v)->getGetter();
+ JSObject* funcObj = static_cast<GetterSetter*>(v)->getter();
if (!funcObj)
return jsUndefined();
return funcObj;
if (v) {
if (v->type() != GetterSetterType)
return jsUndefined();
- JSObject* funcObj = static_cast<GetterSetter*>(v)->getSetter();
+ JSObject* funcObj = static_cast<GetterSetter*>(v)->setter();
if (!funcObj)
return jsUndefined();
return funcObj;
}
}
-JSObject* JSObject::construct(ExecState*, const ArgList& /*args*/)
-{
- ASSERT(false);
- return NULL;
-}
-
-JSObject* JSObject::construct(ExecState* exec, const ArgList& args, const Identifier& /*functionName*/, const UString& /*sourceURL*/, int /*lineNumber*/)
-{
- return construct(exec, args);
-}
-
-bool JSObject::implementsCall()
-{
- CallData callData;
- return getCallData(callData) != CallTypeNone;
-}
-
-JSValue *JSObject::callAsFunction(ExecState* /*exec*/, JSObject* /*thisObj*/, const ArgList &/*args*/)
-{
- ASSERT(false);
- return NULL;
-}
-
bool JSObject::implementsHasInstance() const
{
return false;
{
JSValue* proto = get(exec, exec->propertyNames().prototype);
if (!proto->isObject()) {
- throwError(exec, TypeError, "intanceof called on an object with an invalid prototype property.");
+ throwError(exec, TypeError, "instanceof called on an object with an invalid prototype property.");
return false;
}
putDirect(func->functionName(), func, attr);
}
-void JSObject::fillGetterPropertySlot(PropertySlot& slot, JSValue **location)
+void JSObject::fillGetterPropertySlot(PropertySlot& slot, JSValue** location)
{
- GetterSetter *gs = static_cast<GetterSetter *>(*location);
- JSObject *getterFunc = gs->getGetter();
- if (getterFunc)
+ if (JSObject* getterFunc = static_cast<GetterSetter*>(*location)->getter())
slot.setGetterSlot(getterFunc);
else
slot.setUndefined();
args.append(jsString(exec, name));
else
args.append(jsString(exec, message));
- JSObject *err = static_cast<JSObject *>(cons->construct(exec,args));
+ ConstructData constructData;
+ ConstructType constructType = cons->getConstructData(constructData);
+ JSObject* err = construct(exec, cons, constructType, constructData, args);
if (lineno != -1)
err->put(exec, Identifier(exec, "line"), jsNumber(exec, lineno));
return error;
}
+JSObject* constructEmptyObject(ExecState* exec)
+{
+ return new (exec) JSObject(exec->lexicalGlobalObject()->objectPrototype());
+}
+
} // namespace KJS
public:
JSType type() const { return GetterSetterType; }
- GetterSetter() : getter(0), setter(0) { }
-
- virtual JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const;
- virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
- virtual bool toBoolean(ExecState *exec) const;
- virtual double toNumber(ExecState *exec) const;
- virtual UString toString(ExecState *exec) const;
- virtual JSObject *toObject(ExecState *exec) const;
+ GetterSetter() : m_getter(0), m_setter(0) { }
virtual void mark();
- JSObject *getGetter() { return getter; }
- void setGetter(JSObject *g) { getter = g; }
- JSObject *getSetter() { return setter; }
- void setSetter(JSObject *s) { setter = s; }
+ JSObject* getter() const { return m_getter; }
+ void setGetter(JSObject* getter) { m_getter = getter; }
+ JSObject* setter() const { return m_setter; }
+ void setSetter(JSObject* setter) { m_setter = setter; }
private:
- // Object operations, with the toObject operation included.
- virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
- virtual bool getOwnPropertySlot(ExecState*, unsigned index, PropertySlot&);
- virtual void put(ExecState*, const Identifier& propertyName, JSValue*);
- virtual void put(ExecState*, unsigned propertyName, JSValue*);
- virtual JSObject* toThisObject(ExecState*) const;
+ virtual JSValue* toPrimitive(ExecState*, JSType preferred) const;
+ virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
+ virtual bool toBoolean(ExecState*) const;
+ virtual double toNumber(ExecState*) const;
+ virtual UString toString(ExecState*) const;
+ virtual JSObject* toObject(ExecState*) const;
- JSObject *getter;
- JSObject *setter;
+ JSObject* m_getter;
+ JSObject* m_setter;
};
class JSObject : public JSCell {
*
* @see inherits()
*/
- virtual const ClassInfo *classInfo() const;
/**
* Checks whether this object inherits from the class with the specified
* @return true if this object's class inherits from class with the
* ClassInfo pointer specified in cinfo
*/
- bool inherits(const ClassInfo *cinfo) const;
+ bool inherits(const ClassInfo* classInfo) const { return isObject(classInfo); } // FIXME: Merge with isObject.
// internal properties (ECMA 262-3 8.6.2)
/**
* Retrieves the specified property from the object. If neither the object
- * or any other object in it's prototype chain have the property, this
+ * or any other object in its prototype chain have the property, this
* function will return Undefined.
*
* See ECMA 8.6.2.1
bool propertyIsEnumerable(ExecState *exec, const Identifier &propertyName) const;
/**
- * Checks to see whether the object (or any object in it's prototype chain)
+ * Checks to see whether the object (or any object in its prototype chain)
* has a property with the specified name.
*
* See ECMA 8.6.2.4
* Implementation of the [[DefaultValue]] internal property (implemented by
* all Objects)
*/
- virtual JSValue *defaultValue(ExecState *exec, JSType hint) const;
-
- /**
- * Creates a new object based on this object. Typically this means the
- * following:
- * 1. A new object is created
- * 2. The prototype of the new object is set to the value of this object's
- * "prototype" property
- * 3. The call() method of this object is called, with the new object
- * passed as the this value
- * 4. The new object is returned
- *
- * In some cases, Host objects may differ from these semantics, although
- * this is discouraged.
- *
- * If an error occurs during construction, the execution state's exception
- * will be set. This can be tested for with ExecState::hadException().
- * Under some circumstances, the exception object may also be returned.
- *
- * Note: This function should not be called if getConstructData() returns
- * ConstructTypeNone, in which case it will result in an assertion failure.
- *
- * @param exec The current execution state
- * @param args The arguments to be passed to call() once the new object has
- * been created
- * @return The newly created & initialized object
- */
- /**
- * Implementation of the [[Construct]] internal property
- */
- virtual JSObject* construct(ExecState* exec, const ArgList& args);
- virtual JSObject* construct(ExecState* exec, const ArgList& args, const Identifier& functionName, const UString& sourceURL, int lineNumber);
-
- /**
- * Calls this object as if it is a function.
- *
- * Note: This function should not be called if implementsCall() returns
- * false, in which case it will result in an assertion failure.
- *
- * See ECMA 8.6.2.3
- *
- * @param exec The current execution state
- * @param thisObj The obj to be used as "this" within function execution.
- * Note that in most cases this will be different from the C++ "this"
- * object. For example, if the ECMAScript code "window.location->toString()"
- * is executed, call() will be invoked on the C++ object which implements
- * the toString method, with the thisObj being window.location
- * @param args ArgList of arguments to be passed to the function
- * @return The return value from the function
- */
- bool implementsCall();
- virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const ArgList &args);
+ virtual JSValue* defaultValue(ExecState*, JSType hint) const;
/**
* Whether or not the object implements the hasInstance() method. If this
JSValue *_proto;
};
+ JSObject* constructEmptyObject(ExecState*);
+
/**
* Types of Native Errors available. For custom errors, GeneralError
* should be used.
_proto = proto;
}
-inline bool JSObject::inherits(const ClassInfo *info) const
+inline bool JSCell::isObject(const ClassInfo* info) const
{
- for (const ClassInfo *ci = classInfo(); ci; ci = ci->parentClass)
+ for (const ClassInfo* ci = classInfo(); ci; ci = ci->parentClass) {
if (ci == info)
return true;
+ }
return false;
}
-// this method is here to be after the inline declaration of JSObject::inherits
-inline bool JSCell::isObject(const ClassInfo *info) const
-{
- return isObject() && static_cast<const JSObject *>(this)->inherits(info);
-}
-
// this method is here to be after the inline declaration of JSCell::isObject
-inline bool JSValue::isObject(const ClassInfo *c) const
+inline bool JSValue::isObject(const ClassInfo* classInfo) const
{
- return !JSImmediate::isImmediate(this) && asCell()->isObject(c);
+ return !JSImmediate::isImmediate(this) && asCell()->isObject(classInfo);
}
inline JSValue *JSObject::get(ExecState *exec, const Identifier &propertyName) const
toObject(exec)->put(exec, identifier, value);
}
+bool JSCell::deleteProperty(ExecState* exec, const Identifier& identifier)
+{
+ return toObject(exec)->deleteProperty(exec, identifier);
+}
+
+bool JSCell::deleteProperty(ExecState* exec, unsigned identifier)
+{
+ return toObject(exec)->deleteProperty(exec, identifier);
+}
+
JSObject* JSCell::toThisObject(ExecState* exec) const
{
return toObject(exec);
}
+const ClassInfo* JSCell::classInfo() const
+{
+ return 0;
+}
+
JSCell* jsString(ExecState* exec, const char* s)
{
return new (exec) JSString(s ? s : "");
return s.isNull() ? new (exec) JSString("", JSString::HasOtherOwner) : new (exec) JSString(s, JSString::HasOtherOwner);
}
+JSValue* call(ExecState* exec, JSValue* functionObject, CallType callType, const CallData& callData, JSValue* thisValue, const ArgList& args)
+{
+ if (callType == CallTypeNative)
+ return callData.native.function(exec, static_cast<JSObject*>(functionObject), thisValue, args);
+ ASSERT(callType == CallTypeJS);
+ // FIXME: This can be done more efficiently using the callData.
+ return static_cast<JSFunction*>(functionObject)->call(exec, thisValue, args);
+}
+
+JSObject* construct(ExecState* exec, JSValue* object, ConstructType constructType, const ConstructData& constructData, const ArgList& args)
+{
+ if (constructType == ConstructTypeNative)
+ return constructData.native.function(exec, static_cast<JSObject*>(object), args);
+ ASSERT(constructType == ConstructTypeJS);
+ // FIXME: This can be done more efficiently using the constructData.
+ return static_cast<JSFunction*>(object)->construct(exec, args);
+}
+
} // namespace KJS
bool isNumber() const;
bool isString() const;
bool isObject() const;
- bool isObject(const ClassInfo*) const;
+ bool isObject(const ClassInfo*) const; // FIXME: Merge with inherits.
// Extracting the value.
bool getBoolean(bool&) const;
JSValue* get(ExecState*, unsigned propertyName) const;
void put(ExecState*, const Identifier& propertyName, JSValue*);
void put(ExecState*, unsigned propertyName, JSValue*);
+ bool deleteProperty(ExecState*, const Identifier& propertyName);
+ bool deleteProperty(ExecState*, unsigned propertyName);
JSObject* toThisObject(ExecState*) const;
private:
bool isNumber() const;
bool isString() const;
bool isObject() const;
- bool isObject(const ClassInfo*) const;
+ bool isObject(const ClassInfo*) const; // FIXME: Merge with inherits.
// Extracting the value.
bool getNumber(double&) const;
bool marked() const;
// Object operations, with the toObject operation included.
+ virtual const ClassInfo* classInfo() const;
virtual void put(ExecState*, const Identifier& propertyName, JSValue*);
virtual void put(ExecState*, unsigned propertyName, JSValue*);
+ virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
+ virtual bool deleteProperty(ExecState*, unsigned propertyName);
virtual JSObject* toThisObject(ExecState*) const;
private:
#include "config.h"
#include "MathObject.h"
-#include "MathObject.lut.h"
#include "operations.h"
#include <time.h>
namespace KJS {
+static JSValue* mathProtoFuncAbs(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* mathProtoFuncACos(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* mathProtoFuncASin(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* mathProtoFuncATan(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* mathProtoFuncATan2(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* mathProtoFuncCeil(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* mathProtoFuncCos(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* mathProtoFuncExp(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* mathProtoFuncFloor(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* mathProtoFuncLog(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* mathProtoFuncMax(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* mathProtoFuncMin(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* mathProtoFuncPow(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* mathProtoFuncRandom(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* mathProtoFuncRound(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* mathProtoFuncSin(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* mathProtoFuncSqrt(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* mathProtoFuncTan(ExecState*, JSObject*, JSValue*, const ArgList&);
+
+}
+
+#include "MathObject.lut.h"
+
+namespace KJS {
+
// ------------------------------ MathObject --------------------------------
const ClassInfo MathObject::info = { "Math", 0, 0, ExecState::mathTable };
/* Source for MathObject.lut.h
-@begin mathTable 21
+@begin mathTable
E MathObject::Euler DontEnum|DontDelete|ReadOnly
LN2 MathObject::Ln2 DontEnum|DontDelete|ReadOnly
LN10 MathObject::Ln10 DontEnum|DontDelete|ReadOnly
// ------------------------------ Functions --------------------------------
-JSValue* mathProtoFuncAbs(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* mathProtoFuncAbs(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
double arg = args[0]->toNumber(exec);
return signbit(arg) ? jsNumber(exec, -arg) : jsNumber(exec, arg);
}
-JSValue* mathProtoFuncACos(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* mathProtoFuncACos(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
return jsNumber(exec, acos(args[0]->toNumber(exec)));
}
-JSValue* mathProtoFuncASin(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* mathProtoFuncASin(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
return jsNumber(exec, asin(args[0]->toNumber(exec)));
}
-JSValue* mathProtoFuncATan(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* mathProtoFuncATan(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
return jsNumber(exec, atan(args[0]->toNumber(exec)));
}
-JSValue* mathProtoFuncATan2(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* mathProtoFuncATan2(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
return jsNumber(exec, atan2(args[0]->toNumber(exec), args[1]->toNumber(exec)));
}
-JSValue* mathProtoFuncCeil(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* mathProtoFuncCeil(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
double arg = args[0]->toNumber(exec);
if (signbit(arg) && arg > -1.0)
return jsNumber(exec, ceil(arg));
}
-JSValue* mathProtoFuncCos(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* mathProtoFuncCos(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
return jsNumber(exec, cos(args[0]->toNumber(exec)));
}
-JSValue* mathProtoFuncExp(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* mathProtoFuncExp(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
return jsNumber(exec, exp(args[0]->toNumber(exec)));
}
-JSValue* mathProtoFuncFloor(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* mathProtoFuncFloor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
double arg = args[0]->toNumber(exec);
if (signbit(arg) && arg == 0.0)
return jsNumber(exec, floor(arg));
}
-JSValue* mathProtoFuncLog(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* mathProtoFuncLog(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
return jsNumber(exec, log(args[0]->toNumber(exec)));
}
-JSValue* mathProtoFuncMax(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* mathProtoFuncMax(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
unsigned argsCount = args.size();
double result = -Inf;
return jsNumber(exec, result);
}
-JSValue* mathProtoFuncMin(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* mathProtoFuncMin(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
unsigned argsCount = args.size();
double result = +Inf;
return jsNumber(exec, result);
}
-JSValue* mathProtoFuncPow(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* mathProtoFuncPow(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
// ECMA 15.8.2.1.13
return jsNumber(exec, pow(arg, arg2));
}
-JSValue* mathProtoFuncRandom(ExecState* exec, JSObject*, const ArgList&)
+JSValue* mathProtoFuncRandom(ExecState* exec, JSObject*, JSValue*, const ArgList&)
{
#if !USE(MULTIPLE_THREADS)
static bool didInitRandom;
return jsNumber(exec, wtf_random());
}
-JSValue* mathProtoFuncRound(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* mathProtoFuncRound(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
double arg = args[0]->toNumber(exec);
if (signbit(arg) && arg >= -0.5)
return jsNumber(exec, floor(arg + 0.5));
}
-JSValue* mathProtoFuncSin(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* mathProtoFuncSin(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
return jsNumber(exec, sin(args[0]->toNumber(exec)));
}
-JSValue* mathProtoFuncSqrt(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* mathProtoFuncSqrt(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
return jsNumber(exec, sqrt(args[0]->toNumber(exec)));
}
-JSValue* mathProtoFuncTan(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* mathProtoFuncTan(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
return jsNumber(exec, tan(args[0]->toNumber(exec)));
}
-// -*- c-basic-offset: 2 -*-
/*
- * This file is part of the KDE libraries
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
*
* This library is free software; you can redistribute it and/or
enum { Euler, Ln2, Ln10, Log2E, Log10E, Pi, Sqrt1_2, Sqrt2 };
};
- // Functions
- JSValue* mathProtoFuncAbs(ExecState*, JSObject*, const ArgList&);
- JSValue* mathProtoFuncACos(ExecState*, JSObject*, const ArgList&);
- JSValue* mathProtoFuncASin(ExecState*, JSObject*, const ArgList&);
- JSValue* mathProtoFuncATan(ExecState*, JSObject*, const ArgList&);
- JSValue* mathProtoFuncATan2(ExecState*, JSObject*, const ArgList&);
- JSValue* mathProtoFuncCeil(ExecState*, JSObject*, const ArgList&);
- JSValue* mathProtoFuncCos(ExecState*, JSObject*, const ArgList&);
- JSValue* mathProtoFuncExp(ExecState*, JSObject*, const ArgList&);
- JSValue* mathProtoFuncFloor(ExecState*, JSObject*, const ArgList&);
- JSValue* mathProtoFuncLog(ExecState*, JSObject*, const ArgList&);
- JSValue* mathProtoFuncMax(ExecState*, JSObject*, const ArgList&);
- JSValue* mathProtoFuncMin(ExecState*, JSObject*, const ArgList&);
- JSValue* mathProtoFuncPow(ExecState*, JSObject*, const ArgList&);
- JSValue* mathProtoFuncRandom(ExecState*, JSObject*, const ArgList&);
- JSValue* mathProtoFuncRound(ExecState*, JSObject*, const ArgList&);
- JSValue* mathProtoFuncSin(ExecState*, JSObject*, const ArgList&);
- JSValue* mathProtoFuncSqrt(ExecState*, JSObject*, const ArgList&);
- JSValue* mathProtoFuncTan(ExecState*, JSObject*, const ArgList&);
-
} // namespace KJS
#endif // MathObject_h
// ------------------------------ NumberPrototype ---------------------------
-static JSValue* numberProtoFuncToString(ExecState*, JSObject*, const ArgList&);
-static JSValue* numberProtoFuncToLocaleString(ExecState*, JSObject*, const ArgList&);
-static JSValue* numberProtoFuncValueOf(ExecState*, JSObject*, const ArgList&);
-static JSValue* numberProtoFuncToFixed(ExecState*, JSObject*, const ArgList&);
-static JSValue* numberProtoFuncToExponential(ExecState*, JSObject*, const ArgList&);
-static JSValue* numberProtoFuncToPrecision(ExecState*, JSObject*, const ArgList&);
+static JSValue* numberProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* numberProtoFuncToLocaleString(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* numberProtoFuncValueOf(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* numberProtoFuncToFixed(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* numberProtoFuncToExponential(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* numberProtoFuncToPrecision(ExecState*, JSObject*, JSValue*, const ArgList&);
// ECMA 15.7.4
}
-JSValue* numberProtoFuncToString(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* numberProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- if (!thisObj->inherits(&NumberObject::info))
+ if (!thisValue->isObject(&NumberObject::info))
return throwError(exec, TypeError);
- JSValue* v = static_cast<NumberObject*>(thisObj)->internalValue();
+ JSValue* v = static_cast<NumberObject*>(thisValue)->internalValue();
double radixAsDouble = args[0]->toInteger(exec); // nan -> 0
if (radixAsDouble == 10 || args[0]->isUndefined())
// unless someone finds a precise rule.
char s[2048 + 3];
const char* lastCharInString = s + sizeof(s) - 1;
- double x = v->toNumber(exec);
+ double x = v->uncheckedGetNumber();
if (isnan(x) || isinf(x))
return jsString(exec, UString::from(x));
return jsString(exec, startOfResultString);
}
-JSValue* numberProtoFuncToLocaleString(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* numberProtoFuncToLocaleString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&NumberObject::info))
+ if (!thisValue->isObject(&NumberObject::info))
return throwError(exec, TypeError);
// TODO
- return jsString(exec, static_cast<NumberObject*>(thisObj)->internalValue()->toString(exec));
+ return jsString(exec, static_cast<NumberObject*>(thisValue)->internalValue()->toString(exec));
}
-JSValue* numberProtoFuncValueOf(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* numberProtoFuncValueOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&NumberObject::info))
+ if (!thisValue->isObject(&NumberObject::info))
return throwError(exec, TypeError);
- return static_cast<NumberObject*>(thisObj)->internalValue()->toJSNumber(exec);
+ return static_cast<NumberObject*>(thisValue)->internalValue();
}
-JSValue* numberProtoFuncToFixed(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* numberProtoFuncToFixed(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- if (!thisObj->inherits(&NumberObject::info))
+ if (!thisValue->isObject(&NumberObject::info))
return throwError(exec, TypeError);
- JSValue* v = static_cast<NumberObject*>(thisObj)->internalValue();
+ JSValue* v = static_cast<NumberObject*>(thisValue)->internalValue();
JSValue* fractionDigits = args[0];
double df = fractionDigits->toInteger(exec);
return throwError(exec, RangeError, "toFixed() digits argument must be between 0 and 20");
int f = (int)df;
- double x = v->toNumber(exec);
+ double x = v->uncheckedGetNumber();
if (isnan(x))
return jsString(exec, "NaN");
buf[i++] = static_cast<char>('0' + exponential % 10);
}
-JSValue* numberProtoFuncToExponential(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* numberProtoFuncToExponential(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- if (!thisObj->inherits(&NumberObject::info))
+ if (!thisValue->isObject(&NumberObject::info))
return throwError(exec, TypeError);
- JSValue* v = static_cast<NumberObject*>(thisObj)->internalValue();
-
- double x = v->toNumber(exec);
+ double x = static_cast<NumberObject*>(thisValue)->internalValue()->uncheckedGetNumber();
if (isnan(x) || isinf(x))
return jsString(exec, UString::from(x));
return jsString(exec, buf);
}
-JSValue* numberProtoFuncToPrecision(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* numberProtoFuncToPrecision(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- if (!thisObj->inherits(&NumberObject::info))
+ if (!thisValue->isObject(&NumberObject::info))
return throwError(exec, TypeError);
- JSValue* v = static_cast<NumberObject*>(thisObj)->internalValue();
+ JSValue* v = static_cast<NumberObject*>(thisValue)->internalValue();
double doublePrecision = args[0]->toIntegerPreserveNaN(exec);
- double x = v->toNumber(exec);
+ double x = v->uncheckedGetNumber();
if (args[0]->isUndefined() || isnan(x) || isinf(x))
return jsString(exec, v->toString(exec));
const ClassInfo NumberConstructor::info = { "Function", &InternalFunction::info, 0, ExecState::numberTable };
/* Source for NumberObject.lut.h
-@begin numberTable 5
+@begin numberTable
NaN NumberConstructor::NaNValue DontEnum|DontDelete|ReadOnly
NEGATIVE_INFINITY NumberConstructor::NegInfinity DontEnum|DontDelete|ReadOnly
POSITIVE_INFINITY NumberConstructor::PosInfinity DontEnum|DontDelete|ReadOnly
@end
*/
NumberConstructor::NumberConstructor(ExecState* exec, FunctionPrototype* funcProto, NumberPrototype* numberProto)
- : InternalFunction(funcProto, Identifier(exec, numberProto->classInfo()->className))
+ : InternalFunction(funcProto, Identifier(exec, numberProto->info.className))
{
// Number.Prototype
putDirect(exec->propertyNames().prototype, numberProto, DontEnum|DontDelete|ReadOnly);
// no. of arguments for constructor
- putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly|DontDelete|DontEnum);
+ putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontEnum | DontDelete);
}
bool NumberConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
return jsNull();
}
-ConstructType NumberConstructor::getConstructData(ConstructData&)
-{
- return ConstructTypeNative;
-}
-
// ECMA 15.7.1
-JSObject* NumberConstructor::construct(ExecState* exec, const ArgList& args)
+static JSObject* constructWithNumberConstructor(ExecState* exec, JSObject*, const ArgList& args)
{
- JSObject* proto = exec->lexicalGlobalObject()->numberPrototype();
- NumberObject* obj = new (exec) NumberObject(proto);
-
- // FIXME: Check args[0]->isUndefined() instead of args.isEmpty()?
+ NumberObject* obj = new (exec) NumberObject(exec->lexicalGlobalObject()->numberPrototype());
double n = args.isEmpty() ? 0 : args[0]->toNumber(exec);
obj->setInternalValue(jsNumber(exec, n));
return obj;
}
+ConstructType NumberConstructor::getConstructData(ConstructData& constructData)
+{
+ constructData.native.function = constructWithNumberConstructor;
+ return ConstructTypeNative;
+}
+
// ECMA 15.7.2
-JSValue* NumberConstructor::callAsFunction(ExecState* exec, JSObject*, const ArgList& args)
+static JSValue* callNumberConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
- // FIXME: Check args[0]->isUndefined() instead of args.isEmpty()?
return jsNumber(exec, args.isEmpty() ? 0 : args[0]->toNumber(exec));
}
+CallType NumberConstructor::getCallData(CallData& callData)
+{
+ callData.native.function = callNumberConstructor;
+ return CallTypeNative;
+}
+
+NumberObject* constructNumber(ExecState* exec, JSNumberCell* number)
+{
+ NumberObject* obj = new (exec) NumberObject(exec->lexicalGlobalObject()->numberPrototype());
+ obj->setInternalValue(number);
+ return obj;
+}
+
+NumberObject* constructNumberFromImmediateNumber(ExecState* exec, JSValue* value)
+{
+ NumberObject* obj = new (exec) NumberObject(exec->lexicalGlobalObject()->numberPrototype());
+ obj->setInternalValue(value);
+ return obj;
+}
+
} // namespace KJS
namespace KJS {
+ class JSNumberCell;
+
class NumberObject : public JSWrapperObject {
public:
NumberObject(JSObject* prototype);
+ static const ClassInfo info;
+ private:
virtual const ClassInfo* classInfo() const { return &info; }
- static const ClassInfo info;
};
+ NumberObject* constructNumber(ExecState*, JSNumberCell*);
+ NumberObject* constructNumberFromImmediateNumber(ExecState*, JSValue*);
+
/**
* @internal
*
public:
NumberConstructor(ExecState*, FunctionPrototype*, NumberPrototype*);
- virtual ConstructType getConstructData(ConstructData&);
- virtual JSObject* construct(ExecState*, const ArgList&);
-
- virtual JSValue* callAsFunction(ExecState*, JSObject*, const ArgList&);
-
bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
JSValue* getValueProperty(ExecState*, int token) const;
- virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { NaNValue, NegInfinity, PosInfinity, MaxValue, MinValue };
- JSObject* construct(const ArgList&);
+ private:
+ virtual ConstructType getConstructData(ConstructData&);
+ virtual CallType getCallData(CallData&);
+ virtual const ClassInfo* classInfo() const { return &info; }
};
} // namespace KJS
JSValue* PropertySlot::functionGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
- CallData data;
- CallType callType = slot.m_data.getterFunc->getCallData(data);
+ CallData callData;
+ CallType callType = slot.m_data.getterFunc->getCallData(callData);
if (callType == CallTypeNative)
- return slot.m_data.getterFunc->callAsFunction(exec, static_cast<JSObject*>(slot.slotBase()), exec->emptyList());
+ return callData.native.function(exec, slot.m_data.getterFunc, slot.slotBase(), exec->emptyList());
ASSERT(callType == CallTypeJS);
RegisterFileStack* stack = &exec->dynamicGlobalObject()->registerFileStack();
stack->pushFunctionRegisterFile();
- JSValue* result = slot.m_data.getterFunc->callAsFunction(exec, static_cast<JSObject*>(slot.slotBase()), exec->emptyList());
+ // FIXME: This can be done more efficiently using the callData.
+ JSValue* result = static_cast<JSFunction*>(slot.m_data.getterFunc)->call(exec, slot.slotBase(), exec->emptyList());
stack->popFunctionRegisterFile();
- return result;
+ return result;
}
}
// ------------------------------ RegExpPrototype ---------------------------
-static JSValue* regExpProtoFuncTest(ExecState*, JSObject*, const ArgList&);
-static JSValue* regExpProtoFuncExec(ExecState*, JSObject*, const ArgList&);
-static JSValue* regExpProtoFuncCompile(ExecState*, JSObject*, const ArgList&);
-static JSValue* regExpProtoFuncToString(ExecState*, JSObject*, const ArgList&);
+static JSValue* regExpProtoFuncTest(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* regExpProtoFuncExec(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* regExpProtoFuncCompile(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* regExpProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
// ECMA 15.10.5
// ------------------------------ Functions ---------------------------
-JSValue* regExpProtoFuncTest(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* regExpProtoFuncTest(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- if (!thisObj->inherits(&RegExpObject::info))
+ if (!thisValue->isObject(&RegExpObject::info))
return throwError(exec, TypeError);
-
- return static_cast<RegExpObject*>(thisObj)->test(exec, args);
+ return static_cast<RegExpObject*>(thisValue)->test(exec, args);
}
-JSValue* regExpProtoFuncExec(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* regExpProtoFuncExec(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- if (!thisObj->inherits(&RegExpObject::info))
+ if (!thisValue->isObject(&RegExpObject::info))
return throwError(exec, TypeError);
-
- return static_cast<RegExpObject*>(thisObj)->exec(exec, args);
+ return static_cast<RegExpObject*>(thisValue)->exec(exec, args);
}
-JSValue* regExpProtoFuncCompile(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* regExpProtoFuncCompile(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- if (!thisObj->inherits(&RegExpObject::info))
+ if (!thisValue->isObject(&RegExpObject::info))
return throwError(exec, TypeError);
RefPtr<RegExp> regExp;
if (!regExp->isValid())
return throwError(exec, SyntaxError, UString("Invalid regular expression: ").append(regExp->errorMessage()));
- static_cast<RegExpObject*>(thisObj)->setRegExp(regExp.release());
- static_cast<RegExpObject*>(thisObj)->setLastIndex(0);
+ static_cast<RegExpObject*>(thisValue)->setRegExp(regExp.release());
+ static_cast<RegExpObject*>(thisValue)->setLastIndex(0);
return jsUndefined();
}
-JSValue* regExpProtoFuncToString(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* regExpProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&RegExpObject::info)) {
- if (thisObj->inherits(&RegExpPrototype::info))
+ if (!thisValue->isObject(&RegExpObject::info)) {
+ if (thisValue->isObject(&RegExpPrototype::info))
return jsString(exec, "//");
return throwError(exec, TypeError);
}
- UString result = "/" + thisObj->get(exec, exec->propertyNames().source)->toString(exec) + "/";
- if (thisObj->get(exec, exec->propertyNames().global)->toBoolean(exec))
+ UString result = "/" + static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().source)->toString(exec) + "/";
+ if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().global)->toBoolean(exec))
result += "g";
- if (thisObj->get(exec, exec->propertyNames().ignoreCase)->toBoolean(exec))
+ if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().ignoreCase)->toBoolean(exec))
result += "i";
- if (thisObj->get(exec, exec->propertyNames().multiline)->toBoolean(exec))
+ if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().multiline)->toBoolean(exec))
result += "m";
return jsString(exec, result);
}
const ClassInfo RegExpObject::info = { "RegExp", 0, 0, ExecState::regExpTable };
/* Source for RegExpObject.lut.h
-@begin regExpTable 5
+@begin regExpTable
global RegExpObject::Global DontDelete|ReadOnly|DontEnum
ignoreCase RegExpObject::IgnoreCase DontDelete|ReadOnly|DontEnum
multiline RegExpObject::Multiline DontDelete|ReadOnly|DontEnum
: jsNull();
}
-CallType RegExpObject::getCallData(CallData&)
+static JSValue* callRegExpObject(ExecState* exec, JSObject* function, JSValue*, const ArgList& args)
{
- return CallTypeNative;
+ return static_cast<RegExpObject*>(function)->exec(exec, args);
}
-JSValue* RegExpObject::callAsFunction(ExecState* exec, JSObject*, const ArgList& args)
+CallType RegExpObject::getCallData(CallData& callData)
{
- return RegExpObject::exec(exec, args);
+ callData.native.function = callRegExpObject;
+ return CallTypeNative;
}
// ------------------------------ RegExpConstructor ------------------------------
const ClassInfo RegExpConstructor::info = { "Function", &InternalFunction::info, 0, ExecState::regExpConstructorTable };
/* Source for RegExpObject.lut.h
-@begin regExpConstructorTable 21
+@begin regExpConstructorTable
input RegExpConstructor::Input None
$_ RegExpConstructor::Input DontEnum
multiline RegExpConstructor::Multiline None
class RegExpMatchesArray : public JSArray {
public:
RegExpMatchesArray(ExecState*, RegExpConstructorPrivate*);
-
virtual ~RegExpMatchesArray();
+private:
virtual bool getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { if (lazyCreationData()) fillArrayInstance(exec); return JSArray::getOwnPropertySlot(exec, propertyName, slot); }
virtual bool getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot) { if (lazyCreationData()) fillArrayInstance(exec); return JSArray::getOwnPropertySlot(exec, propertyName, slot); }
virtual void put(ExecState* exec, const Identifier& propertyName, JSValue* v) { if (lazyCreationData()) fillArrayInstance(exec); JSArray::put(exec, propertyName, v); }
virtual bool deleteProperty(ExecState* exec, unsigned propertyName) { if (lazyCreationData()) fillArrayInstance(exec); return JSArray::deleteProperty(exec, propertyName); }
virtual void getPropertyNames(ExecState* exec, PropertyNameArray& arr) { if (lazyCreationData()) fillArrayInstance(exec); JSArray::getPropertyNames(exec, arr); }
-private:
void fillArrayInstance(ExecState*);
};
}
}
-ConstructType RegExpConstructor::getConstructData(ConstructData&)
-{
- return ConstructTypeNative;
-}
-
// ECMA 15.10.4
-JSObject *RegExpConstructor::construct(ExecState *exec, const ArgList &args)
+static JSObject* constructRegExp(ExecState* exec, const ArgList& args)
{
JSValue* arg0 = args[0];
JSValue* arg1 = args[1];
: throwError(exec, SyntaxError, UString("Invalid regular expression: ").append(regExp->errorMessage()));
}
+static JSObject* constructWithRegExpConstructor(ExecState* exec, JSObject*, const ArgList& args)
+{
+ return constructRegExp(exec, args);
+}
+
+ConstructType RegExpConstructor::getConstructData(ConstructData& constructData)
+{
+ constructData.native.function = constructWithRegExpConstructor;
+ return ConstructTypeNative;
+}
+
// ECMA 15.10.3
-JSValue *RegExpConstructor::callAsFunction(ExecState *exec, JSObject * /*thisObj*/, const ArgList &args)
+static JSValue* callRegExpConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
- return construct(exec, args);
+ return constructRegExp(exec, args);
+}
+
+CallType RegExpConstructor::getCallData(CallData& callData)
+{
+ callData.native.function = callRegExpConstructor;
+ return CallTypeNative;
}
const UString& RegExpConstructor::input() const
void setRegExp(PassRefPtr<RegExp> r) { m_regExp = r; }
RegExp* regExp() const { return m_regExp.get(); }
- JSValue* test(ExecState*, const ArgList& args);
- JSValue* exec(ExecState*, const ArgList& args);
-
- virtual CallType getCallData(CallData&);
- virtual JSValue* callAsFunction(ExecState*, JSObject*, const ArgList&);
+ JSValue* test(ExecState*, const ArgList&);
+ JSValue* exec(ExecState*, const ArgList&);
bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
JSValue* getValueProperty(ExecState*, int token) const;
void setLastIndex(double lastIndex) { m_lastIndex = lastIndex; }
private:
- bool match(ExecState*, const ArgList& args);
+ bool match(ExecState*, const ArgList&);
+
+ virtual CallType getCallData(CallData&);
RefPtr<RegExp> m_regExp;
double m_lastIndex;
RegExpConstructor(ExecState*, FunctionPrototype*, RegExpPrototype*);
- virtual ConstructType getConstructData(ConstructData&);
- virtual JSObject* construct(ExecState*, const ArgList&);
-
- virtual JSValue* callAsFunction(ExecState*, JSObject*, const ArgList&);
-
virtual void put(ExecState*, const Identifier&, JSValue*);
void putValueProperty(ExecState*, int token, JSValue*);
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
JSValue* getValueProperty(ExecState*, int token) const;
- virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
void performMatch(RegExp*, const UString&, int startOffset, int& position, int& length, int** ovector = 0);
const UString& input() const;
private:
+ virtual ConstructType getConstructData(ConstructData&);
+ virtual CallType getCallData(CallData&);
+ virtual const ClassInfo* classInfo() const { return &info; }
+
JSValue* getBackref(ExecState*, unsigned) const;
JSValue* getLastParen(ExecState*) const;
JSValue* getLeftContext(ExecState*) const;
static bool fillBufferWithContentsOfFile(const UString& fileName, Vector<char>& buffer);
-static JSValue* functionPrint(ExecState*, JSObject*, const ArgList&);
-static JSValue* functionDebug(ExecState*, JSObject*, const ArgList&);
-static JSValue* functionGC(ExecState*, JSObject*, const ArgList&);
-static JSValue* functionVersion(ExecState*, JSObject*, const ArgList&);
-static JSValue* functionRun(ExecState*, JSObject*, const ArgList&);
-static JSValue* functionLoad(ExecState*, JSObject*, const ArgList&);
-static JSValue* functionReadline(ExecState*, JSObject*, const ArgList&);
-static JSValue* functionQuit(ExecState*, JSObject*, const ArgList&);
+static JSValue* functionPrint(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* functionDebug(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* functionGC(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* functionVersion(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* functionRun(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* functionLoad(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* functionReadline(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* functionQuit(ExecState*, JSObject*, JSValue*, const ArgList&);
struct Options {
Options()
putDirectFunction(new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "load"), functionLoad));
putDirectFunction(new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 0, Identifier(globalExec(), "readline"), functionReadline));
- JSObject* array = arrayConstructor()->construct(globalExec(), globalExec()->emptyList());
+ JSObject* array = constructEmptyArray(globalExec());
for (size_t i = 0; i < arguments.size(); ++i)
array->put(globalExec(), i, jsString(globalExec(), arguments[i]));
putDirect(Identifier(globalExec(), "arguments"), array);
Interpreter::setShouldPrintExceptions(true);
}
-JSValue* functionPrint(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* functionPrint(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
for (unsigned i = 0; i < args.size(); ++i) {
if (i != 0)
return jsUndefined();
}
-JSValue* functionDebug(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* functionDebug(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
fprintf(stderr, "--> %s\n", args[0]->toString(exec).UTF8String().c_str());
return jsUndefined();
}
-JSValue* functionGC(ExecState* exec, JSObject*, const ArgList&)
+JSValue* functionGC(ExecState* exec, JSObject*, JSValue*, const ArgList&)
{
JSLock lock;
exec->heap()->collect();
return jsUndefined();
}
-JSValue* functionVersion(ExecState*, JSObject*, const ArgList&)
+JSValue* functionVersion(ExecState*, JSObject*, JSValue*, const ArgList&)
{
// We need this function for compatibility with the Mozilla JS tests but for now
// we don't actually do any version-specific handling
return jsUndefined();
}
-JSValue* functionRun(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* functionRun(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
StopWatch stopWatch;
UString fileName = args[0]->toString(exec);
return jsNumber(globalObject->globalExec(), stopWatch.getElapsedMS());
}
-JSValue* functionLoad(ExecState* exec, JSObject*, const ArgList& args)
+JSValue* functionLoad(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
UString fileName = args[0]->toString(exec);
Vector<char> script;
return jsUndefined();
}
-JSValue* functionReadline(ExecState* exec, JSObject*, const ArgList&)
+JSValue* functionReadline(ExecState* exec, JSObject*, JSValue*, const ArgList&)
{
Vector<char, 256> line;
int c;
return jsString(exec, line.data());
}
-JSValue* functionQuit(ExecState*, JSObject*, const ArgList&)
+JSValue* functionQuit(ExecState*, JSObject*, JSValue*, const ArgList&)
{
exit(0);
#if !COMPILER(MSVC)
#include "config.h"
#include "date_object.h"
-#include "date_object.lut.h"
+
+#include "DateMath.h"
#include "JSString.h"
+#include "error_object.h"
+#include "operations.h"
+#include <float.h>
+#include <limits.h>
+#include <locale.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <wtf/ASCIICType.h>
+#include <wtf/Assertions.h>
+#include <wtf/MathExtras.h>
+#include <wtf/StringExtras.h>
+#include <wtf/UnusedParam.h>
#if HAVE(ERRNO_H)
#include <errno.h>
#include <sys/timeb.h>
#endif
-#include <float.h>
-#include <limits.h>
-#include <locale.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-
-#include "error_object.h"
-#include "operations.h"
-#include "DateMath.h"
-
-#include <wtf/ASCIICType.h>
-#include <wtf/Assertions.h>
-#include <wtf/MathExtras.h>
-#include <wtf/StringExtras.h>
-#include <wtf/UnusedParam.h>
-
#if PLATFORM(MAC)
- #include <CoreFoundation/CoreFoundation.h>
+#include <CoreFoundation/CoreFoundation.h>
#endif
using namespace WTF;
namespace KJS {
-static double parseDate(const UString&);
-static double timeClip(double);
+static JSValue* dateProtoFuncGetDate(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncGetDay(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncGetFullYear(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncGetHours(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncGetMilliSeconds(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncGetMinutes(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncGetMonth(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncGetSeconds(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncGetTime(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncGetTimezoneOffset(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncGetUTCDate(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncGetUTCDay(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncGetUTCFullYear(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncGetUTCHours(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncGetUTCMilliseconds(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncGetUTCMinutes(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncGetUTCMonth(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncGetUTCSeconds(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncGetYear(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncSetDate(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncSetFullYear(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncSetHours(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncSetMilliSeconds(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncSetMinutes(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncSetMonth(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncSetSeconds(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncSetTime(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncSetUTCDate(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncSetUTCFullYear(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncSetUTCHours(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncSetUTCMilliseconds(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncSetUTCMinutes(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncSetUTCMonth(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncSetUTCSeconds(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncSetYear(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncToDateString(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncToGMTString(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncToLocaleDateString(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncToLocaleString(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncToLocaleTimeString(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncToTimeString(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncToUTCString(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateProtoFuncValueOf(ExecState*, JSObject*, JSValue*, const ArgList&);
-inline int gmtoffset(const GregorianDateTime& t)
-{
- return t.utcOffset;
}
+#include "date_object.lut.h"
-/**
- * @internal
- *
- * Class to implement all methods that are properties of the
- * Date object
- */
-class DateFunction : public InternalFunction {
-public:
- DateFunction(ExecState *, FunctionPrototype *, int i, int len, const Identifier& );
-
- virtual JSValue *callAsFunction(ExecState *, JSObject *thisObj, const ArgList &args);
+namespace KJS {
- enum { Parse, UTC, Now };
+static double parseDate(const UString&);
+static double timeClip(double);
-private:
- int id;
-};
+static inline int gmtoffset(const GregorianDateTime& t)
+{
+ return t.utcOffset;
+}
struct DateInstance::Cache {
double m_gregorianDateTimeCachedForMS;
return defaultStyle;
}
-static UString formatLocaleDate(ExecState *exec, double time, bool includeDate, bool includeTime, const ArgList &args)
+static UString formatLocaleDate(ExecState *exec, double time, bool includeDate, bool includeTime, const ArgList& args)
{
CFDateFormatterStyle dateStyle = (includeDate ? kCFDateFormatterLongStyle : kCFDateFormatterNoStyle);
CFDateFormatterStyle timeStyle = (includeTime ? kCFDateFormatterLongStyle : kCFDateFormatterNoStyle);
// ms (representing milliseconds) and t (representing the rest of the date structure) appropriately.
//
// Format of member function: f([years,] [months,] [days])
-static bool fillStructuresUsingDateArgs(ExecState *exec, const ArgList &args, int maxArgs, double *ms, GregorianDateTime *t)
+static bool fillStructuresUsingDateArgs(ExecState *exec, const ArgList& args, int maxArgs, double *ms, GregorianDateTime *t)
{
int idx = 0;
bool ok = true;
bool DateInstance::getTime(GregorianDateTime &t, int &offset) const
{
- double milli = internalValue()->getNumber();
+ double milli = internalNumber();
if (isnan(milli))
return false;
bool DateInstance::getUTCTime(GregorianDateTime &t) const
{
- double milli = internalValue()->getNumber();
+ double milli = internalNumber();
if (isnan(milli))
return false;
bool DateInstance::getTime(double &milli, int &offset) const
{
- milli = internalValue()->getNumber();
+ milli = internalNumber();
if (isnan(milli))
return false;
bool DateInstance::getUTCTime(double &milli) const
{
- milli = internalValue()->getNumber();
+ milli = internalNumber();
if (isnan(milli))
return false;
const ClassInfo DatePrototype::info = {"Date", &DateInstance::info, 0, ExecState::dateTable};
/* Source for date_object.lut.h
- FIXMEL We could use templates to simplify the UTC variants.
-@begin dateTable 61
+ FIXME: We could use templates to simplify the UTC variants.
+@begin dateTable
toString dateProtoFuncToString DontEnum|Function 0
toUTCString dateProtoFuncToUTCString DontEnum|Function 0
toDateString dateProtoFuncToDateString DontEnum|Function 0
// TODO: MakeTime (15.9.11.1) etc. ?
+static JSValue* dateParse(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateNow(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* dateUTC(ExecState*, JSObject*, JSValue*, const ArgList&);
+
DateConstructor::DateConstructor(ExecState* exec, FunctionPrototype* funcProto, DatePrototype* dateProto)
: InternalFunction(funcProto, Identifier(exec, dateProto->classInfo()->className))
{
putDirect(exec->propertyNames().prototype, dateProto, DontEnum|DontDelete|ReadOnly);
- putDirectFunction(new (exec) DateFunction(exec, funcProto, DateFunction::Parse, 1, exec->propertyNames().parse), DontEnum);
- putDirectFunction(new (exec) DateFunction(exec, funcProto, DateFunction::UTC, 7, exec->propertyNames().UTC), DontEnum);
- putDirectFunction(new (exec) DateFunction(exec, funcProto, DateFunction::Now, 0, exec->propertyNames().now), DontEnum);
- putDirect(exec, exec->propertyNames().length, 7, ReadOnly|DontDelete|DontEnum);
-}
-
-ConstructType DateConstructor::getConstructData(ConstructData&)
-{
- return ConstructTypeNative;
+ putDirectFunction(new (exec) PrototypeFunction(exec, funcProto, 1, exec->propertyNames().parse, dateParse), DontEnum);
+ putDirectFunction(new (exec) PrototypeFunction(exec, funcProto, 7, exec->propertyNames().UTC, dateUTC), DontEnum);
+ putDirectFunction(new (exec) PrototypeFunction(exec, funcProto, 0, exec->propertyNames().now, dateNow), DontEnum);
+ putDirect(exec, exec->propertyNames().length, 7, ReadOnly | DontEnum | DontDelete);
}
// ECMA 15.9.3
-JSObject *DateConstructor::construct(ExecState *exec, const ArgList &args)
+static JSObject* constructDate(ExecState* exec, JSObject*, const ArgList& args)
{
int numArgs = args.size();
value = getCurrentUTCTime();
} else if (numArgs == 1) {
if (args[0]->isObject(&DateInstance::info))
- value = static_cast<DateInstance*>(args[0])->internalValue()->toNumber(exec);
+ value = static_cast<DateInstance*>(args[0])->internalNumber();
else {
JSValue* primitive = args[0]->toPrimitive(exec);
if (primitive->isString())
return ret;
}
+ConstructType DateConstructor::getConstructData(ConstructData& constructData)
+{
+ constructData.native.function = constructDate;
+ return ConstructTypeNative;
+}
+
// ECMA 15.9.2
-JSValue* DateConstructor::callAsFunction(ExecState* exec, JSObject * /*thisObj*/, const ArgList &/*args*/)
+static JSValue* callDate(ExecState* exec, JSObject*, JSValue*, const ArgList&)
{
time_t localTime = time(0);
tm localTM;
return jsString(exec, formatDate(ts) + " " + formatTime(ts, false));
}
-// ------------------------------ DateFunction ----------------------------
-
-DateFunction::DateFunction(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
- : InternalFunction(funcProto, name), id(i)
+CallType DateConstructor::getCallData(CallData& callData)
{
- putDirect(exec, exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum);
+ callData.native.function = callDate;
+ return CallTypeNative;
}
-// ECMA 15.9.4.2 - 3
-JSValue *DateFunction::callAsFunction(ExecState* exec, JSObject*, const ArgList& args)
+static JSValue* dateParse(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
- if (id == Parse)
return jsNumber(exec, parseDate(args[0]->toString(exec)));
- else if (id == Now)
+}
+
+static JSValue* dateNow(ExecState* exec, JSObject*, JSValue*, const ArgList&)
+{
return jsNumber(exec, getCurrentUTCTime());
- else { // UTC
+}
+
+static JSValue* dateUTC(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
+{
int n = args.size();
if (isnan(args[0]->toNumber(exec))
- || isnan(args[1]->toNumber(exec))
- || (n >= 3 && isnan(args[2]->toNumber(exec)))
- || (n >= 4 && isnan(args[3]->toNumber(exec)))
- || (n >= 5 && isnan(args[4]->toNumber(exec)))
- || (n >= 6 && isnan(args[5]->toNumber(exec)))
- || (n >= 7 && isnan(args[6]->toNumber(exec)))) {
- return jsNaN(exec);
+ || isnan(args[1]->toNumber(exec))
+ || (n >= 3 && isnan(args[2]->toNumber(exec)))
+ || (n >= 4 && isnan(args[3]->toNumber(exec)))
+ || (n >= 5 && isnan(args[4]->toNumber(exec)))
+ || (n >= 6 && isnan(args[5]->toNumber(exec)))
+ || (n >= 7 && isnan(args[6]->toNumber(exec)))) {
+ return jsNaN(exec);
}
GregorianDateTime t;
t.second = args[5]->toInt32(exec);
double ms = (n >= 7) ? args[6]->toNumber(exec) : 0;
return jsNumber(exec, gregorianDateTimeToMS(t, ms, true));
- }
}
// -----------------------------------------------------------------------------
// Functions
-JSValue* dateProtoFuncToString(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* dateProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
const bool utc = false;
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsString(exec, "Invalid Date");
return jsString(exec, formatDate(t) + " " + formatTime(t, utc));
}
-JSValue* dateProtoFuncToUTCString(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* dateProtoFuncToUTCString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
const bool utc = true;
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsString(exec, "Invalid Date");
return jsString(exec, formatDateUTCVariant(t) + " " + formatTime(t, utc));
}
-JSValue* dateProtoFuncToDateString(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* dateProtoFuncToDateString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
const bool utc = false;
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsString(exec, "Invalid Date");
return jsString(exec, formatDate(t));
}
-JSValue* dateProtoFuncToTimeString(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* dateProtoFuncToTimeString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
const bool utc = false;
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsString(exec, "Invalid Date");
return jsString(exec, formatTime(t, utc));
}
-JSValue* dateProtoFuncToLocaleString(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* dateProtoFuncToLocaleString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsString(exec, "Invalid Date");
#endif
}
-JSValue* dateProtoFuncToLocaleDateString(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* dateProtoFuncToLocaleDateString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsString(exec, "Invalid Date");
#endif
}
-JSValue* dateProtoFuncToLocaleTimeString(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* dateProtoFuncToLocaleTimeString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsString(exec, "Invalid Date");
#endif
}
-JSValue* dateProtoFuncValueOf(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* dateProtoFuncValueOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsNaN(exec);
return jsNumber(exec, milli);
}
-JSValue* dateProtoFuncGetTime(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* dateProtoFuncGetTime(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsNaN(exec);
return jsNumber(exec, milli);
}
-JSValue* dateProtoFuncGetFullYear(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* dateProtoFuncGetFullYear(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
const bool utc = false;
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsNaN(exec);
return jsNumber(exec, 1900 + t.year);
}
-JSValue* dateProtoFuncGetUTCFullYear(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* dateProtoFuncGetUTCFullYear(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
const bool utc = true;
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsNaN(exec);
return jsNumber(exec, 1900 + t.year);
}
-JSValue* dateProtoFuncToGMTString(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* dateProtoFuncToGMTString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
const bool utc = true;
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsString(exec, "Invalid Date");
return jsString(exec, formatDateUTCVariant(t) + " " + formatTime(t, utc));
}
-JSValue* dateProtoFuncGetMonth(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* dateProtoFuncGetMonth(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
const bool utc = false;
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsNaN(exec);
return jsNumber(exec, t.month);
}
-JSValue* dateProtoFuncGetUTCMonth(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* dateProtoFuncGetUTCMonth(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
const bool utc = true;
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsNaN(exec);
return jsNumber(exec, t.month);
}
-JSValue* dateProtoFuncGetDate(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* dateProtoFuncGetDate(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
const bool utc = false;
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsNaN(exec);
return jsNumber(exec, t.monthDay);
}
-JSValue* dateProtoFuncGetUTCDate(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* dateProtoFuncGetUTCDate(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
const bool utc = true;
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsNaN(exec);
return jsNumber(exec, t.monthDay);
}
-JSValue* dateProtoFuncGetDay(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* dateProtoFuncGetDay(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
const bool utc = false;
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsNaN(exec);
return jsNumber(exec, t.weekDay);
}
-JSValue* dateProtoFuncGetUTCDay(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* dateProtoFuncGetUTCDay(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
const bool utc = true;
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsNaN(exec);
return jsNumber(exec, t.weekDay);
}
-JSValue* dateProtoFuncGetHours(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* dateProtoFuncGetHours(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
const bool utc = false;
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsNaN(exec);
return jsNumber(exec, t.hour);
}
-JSValue* dateProtoFuncGetUTCHours(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* dateProtoFuncGetUTCHours(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
const bool utc = true;
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsNaN(exec);
return jsNumber(exec, t.hour);
}
-JSValue* dateProtoFuncGetMinutes(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* dateProtoFuncGetMinutes(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
const bool utc = false;
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsNaN(exec);
return jsNumber(exec, t.minute);
}
-JSValue* dateProtoFuncGetUTCMinutes(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* dateProtoFuncGetUTCMinutes(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
const bool utc = true;
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsNaN(exec);
return jsNumber(exec, t.minute);
}
-JSValue* dateProtoFuncGetSeconds(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* dateProtoFuncGetSeconds(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
const bool utc = false;
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsNaN(exec);
return jsNumber(exec, t.second);
}
-JSValue* dateProtoFuncGetUTCSeconds(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* dateProtoFuncGetUTCSeconds(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
const bool utc = true;
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsNaN(exec);
return jsNumber(exec, t.second);
}
-JSValue* dateProtoFuncGetMilliSeconds(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* dateProtoFuncGetMilliSeconds(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsNaN(exec);
return jsNumber(exec, ms);
}
-JSValue* dateProtoFuncGetUTCMilliseconds(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* dateProtoFuncGetUTCMilliseconds(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsNaN(exec);
return jsNumber(exec, ms);
}
-JSValue* dateProtoFuncGetTimezoneOffset(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* dateProtoFuncGetTimezoneOffset(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
const bool utc = false;
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsNaN(exec);
return jsNumber(exec, -gmtoffset(t) / minutesPerHour);
}
-JSValue* dateProtoFuncSetTime(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* dateProtoFuncSetTime(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
double milli = timeClip(args[0]->toNumber(exec));
JSValue* result = jsNumber(exec, milli);
return result;
}
-static JSValue* setNewValueFromTimeArgs(ExecState* exec, JSObject* thisObj, const ArgList& args, int numArgsToUse, bool inputIsUTC)
+static JSValue* setNewValueFromTimeArgs(ExecState* exec, JSValue* thisValue, const ArgList& args, int numArgsToUse, bool inputIsUTC)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (args.isEmpty() || isnan(milli)) {
JSValue* result = jsNaN(exec);
return result;
}
-static JSValue* setNewValueFromDateArgs(ExecState* exec, JSObject* thisObj, const ArgList& args, int numArgsToUse, bool inputIsUTC)
+static JSValue* setNewValueFromDateArgs(ExecState* exec, JSValue* thisValue, const ArgList& args, int numArgsToUse, bool inputIsUTC)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
if (args.isEmpty()) {
JSValue* result = jsNaN(exec);
thisDateObj->setInternalValue(result);
return result;
}
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ double milli = thisDateObj->internalNumber();
double ms = 0;
GregorianDateTime t;
return result;
}
-JSValue* dateProtoFuncSetMilliSeconds(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* dateProtoFuncSetMilliSeconds(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
const bool inputIsUTC = false;
- return setNewValueFromTimeArgs(exec, thisObj, args, 1, inputIsUTC);
+ return setNewValueFromTimeArgs(exec, thisValue, args, 1, inputIsUTC);
}
-JSValue* dateProtoFuncSetUTCMilliseconds(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* dateProtoFuncSetUTCMilliseconds(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
const bool inputIsUTC = true;
- return setNewValueFromTimeArgs(exec, thisObj, args, 1, inputIsUTC);
+ return setNewValueFromTimeArgs(exec, thisValue, args, 1, inputIsUTC);
}
-JSValue* dateProtoFuncSetSeconds(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* dateProtoFuncSetSeconds(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
const bool inputIsUTC = false;
- return setNewValueFromTimeArgs(exec, thisObj, args, 2, inputIsUTC);
+ return setNewValueFromTimeArgs(exec, thisValue, args, 2, inputIsUTC);
}
-JSValue* dateProtoFuncSetUTCSeconds(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* dateProtoFuncSetUTCSeconds(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
const bool inputIsUTC = true;
- return setNewValueFromTimeArgs(exec, thisObj, args, 2, inputIsUTC);
+ return setNewValueFromTimeArgs(exec, thisValue, args, 2, inputIsUTC);
}
-JSValue* dateProtoFuncSetMinutes(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* dateProtoFuncSetMinutes(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
const bool inputIsUTC = false;
- return setNewValueFromTimeArgs(exec, thisObj, args, 3, inputIsUTC);
+ return setNewValueFromTimeArgs(exec, thisValue, args, 3, inputIsUTC);
}
-JSValue* dateProtoFuncSetUTCMinutes(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* dateProtoFuncSetUTCMinutes(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
const bool inputIsUTC = true;
- return setNewValueFromTimeArgs(exec, thisObj, args, 3, inputIsUTC);
+ return setNewValueFromTimeArgs(exec, thisValue, args, 3, inputIsUTC);
}
-JSValue* dateProtoFuncSetHours(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* dateProtoFuncSetHours(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
const bool inputIsUTC = false;
- return setNewValueFromTimeArgs(exec, thisObj, args, 4, inputIsUTC);
+ return setNewValueFromTimeArgs(exec, thisValue, args, 4, inputIsUTC);
}
-JSValue* dateProtoFuncSetUTCHours(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* dateProtoFuncSetUTCHours(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
const bool inputIsUTC = true;
- return setNewValueFromTimeArgs(exec, thisObj, args, 4, inputIsUTC);
+ return setNewValueFromTimeArgs(exec, thisValue, args, 4, inputIsUTC);
}
-JSValue* dateProtoFuncSetDate(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* dateProtoFuncSetDate(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
const bool inputIsUTC = false;
- return setNewValueFromDateArgs(exec, thisObj, args, 1, inputIsUTC);
+ return setNewValueFromDateArgs(exec, thisValue, args, 1, inputIsUTC);
}
-JSValue* dateProtoFuncSetUTCDate(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* dateProtoFuncSetUTCDate(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
const bool inputIsUTC = true;
- return setNewValueFromDateArgs(exec, thisObj, args, 1, inputIsUTC);
+ return setNewValueFromDateArgs(exec, thisValue, args, 1, inputIsUTC);
}
-JSValue* dateProtoFuncSetMonth(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* dateProtoFuncSetMonth(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
const bool inputIsUTC = false;
- return setNewValueFromDateArgs(exec, thisObj, args, 2, inputIsUTC);
+ return setNewValueFromDateArgs(exec, thisValue, args, 2, inputIsUTC);
}
-JSValue* dateProtoFuncSetUTCMonth(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* dateProtoFuncSetUTCMonth(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
const bool inputIsUTC = true;
- return setNewValueFromDateArgs(exec, thisObj, args, 2, inputIsUTC);
+ return setNewValueFromDateArgs(exec, thisValue, args, 2, inputIsUTC);
}
-JSValue* dateProtoFuncSetFullYear(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* dateProtoFuncSetFullYear(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
const bool inputIsUTC = false;
- return setNewValueFromDateArgs(exec, thisObj, args, 3, inputIsUTC);
+ return setNewValueFromDateArgs(exec, thisValue, args, 3, inputIsUTC);
}
-JSValue* dateProtoFuncSetUTCFullYear(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* dateProtoFuncSetUTCFullYear(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
const bool inputIsUTC = true;
- return setNewValueFromDateArgs(exec, thisObj, args, 3, inputIsUTC);
+ return setNewValueFromDateArgs(exec, thisValue, args, 3, inputIsUTC);
}
-JSValue* dateProtoFuncSetYear(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* dateProtoFuncSetYear(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
const bool utc = false;
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
if (args.isEmpty()) {
JSValue* result = jsNaN(exec);
thisDateObj->setInternalValue(result);
return result;
}
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ double milli = thisDateObj->internalNumber();
double ms = 0;
GregorianDateTime t;
return result;
}
-JSValue* dateProtoFuncGetYear(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* dateProtoFuncGetYear(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&DateInstance::info))
+ if (!thisValue->isObject(&DateInstance::info))
return throwError(exec, TypeError);
const bool utc = false;
- DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
- JSValue* v = thisDateObj->internalValue();
- double milli = v->toNumber(exec);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
+ double milli = thisDateObj->internalNumber();
if (isnan(milli))
return jsNaN(exec);
class DateInstance : public JSWrapperObject {
public:
- DateInstance(JSObject *proto);
+ DateInstance(JSObject* prototype);
virtual ~DateInstance();
-
+
+ double internalNumber() const { return internalValue()->uncheckedGetNumber(); }
+
bool getTime(GregorianDateTime&, int& offset) const;
bool getUTCTime(GregorianDateTime&) const;
- bool getTime(double& milli, int& offset) const;
- bool getUTCTime(double& milli) const;
+ bool getTime(double& milliseconds, int& offset) const;
+ bool getUTCTime(double& milliseconds) const;
- virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
void msToGregorianDateTime(double, bool outputIsUTC, GregorianDateTime&) const;
private:
+ virtual const ClassInfo* classInfo() const { return &info; }
+
+ using JSWrapperObject::internalValue;
+
struct Cache;
mutable Cache* m_cache;
};
static const ClassInfo info;
};
- /**
- * @internal
- *
- * Functions to implement all methods that are properties of the
- * Date.prototype object
- */
-
- // Non-normative properties (Appendix B)
- // GetYear, SetYear, ToGMTString
-
- JSValue* dateProtoFuncToString(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncToUTCString(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncToDateString(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncToTimeString(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncToLocaleString(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncToLocaleDateString(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncToLocaleTimeString(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncValueOf(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncGetTime(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncGetFullYear(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncGetUTCFullYear(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncToGMTString(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncGetMonth(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncGetUTCMonth(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncGetDate(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncGetUTCDate(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncGetDay(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncGetUTCDay(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncGetHours(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncGetUTCHours(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncGetMinutes(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncGetUTCMinutes(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncGetSeconds(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncGetUTCSeconds(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncGetMilliSeconds(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncGetUTCMilliseconds(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncGetTimezoneOffset(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncSetTime(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncSetMilliSeconds(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncSetUTCMilliseconds(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncSetSeconds(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncSetUTCSeconds(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncSetMinutes(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncSetUTCMinutes(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncSetHours(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncSetUTCHours(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncSetDate(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncSetUTCDate(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncSetMonth(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncSetUTCMonth(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncSetFullYear(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncSetUTCFullYear(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncSetYear(ExecState*, JSObject*, const ArgList&);
- JSValue* dateProtoFuncGetYear(ExecState*, JSObject*, const ArgList&);
-
/**
* @internal
*
class DateConstructor : public InternalFunction {
public:
DateConstructor(ExecState*, FunctionPrototype*, DatePrototype*);
-
+ private:
virtual ConstructType getConstructData(ConstructData&);
- virtual JSObject* construct(ExecState*, const ArgList& args);
-
- virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const ArgList& args);
-
- JSObject* construct(const ArgList&);
+ virtual CallType getCallData(CallData&);
};
} // namespace
// ------------------------------ ErrorPrototype ----------------------------
+static JSValue* errorProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
+
// ECMA 15.9.4
ErrorPrototype::ErrorPrototype(ExecState* exec, ObjectPrototype* objectPrototype, FunctionPrototype* functionPrototype)
: ErrorInstance(objectPrototype)
putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, errorProtoFuncToString), DontEnum);
}
-JSValue* errorProtoFuncToString(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* errorProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
+ JSObject* thisObj = thisValue->toThisObject(exec);
+
UString s = "Error";
JSValue* v = thisObj->get(exec, exec->propertyNames().name);
s = v->toString(exec);
v = thisObj->get(exec, exec->propertyNames().message);
- if (!v->isUndefined())
- // Mozilla compatible format
- s += ": " + v->toString(exec);
+ if (!v->isUndefined()) {
+ // Mozilla-compatible format.
+ s += ": ";
+ s += v->toString(exec);
+ }
return jsString(exec, s);
}
putDirect(exec->propertyNames().length, jsNumber(exec, 1), DontDelete|ReadOnly|DontEnum);
}
-ConstructType ErrorConstructor::getConstructData(ConstructData&)
+// ECMA 15.9.3
+static ErrorInstance* constructError(ExecState* exec, const ArgList& args)
{
- return ConstructTypeNative;
+ ErrorInstance* obj = new (exec) ErrorInstance(exec->lexicalGlobalObject()->errorPrototype());
+ if (!args[0]->isUndefined())
+ obj->putDirect(exec->propertyNames().message, jsString(exec, args[0]->toString(exec)));
+ return obj;
}
-// ECMA 15.9.3
-JSObject* ErrorConstructor::construct(ExecState* exec, const ArgList& args)
+static JSObject* constructWithErrorConstructor(ExecState* exec, JSObject*, const ArgList& args)
{
- JSObject* proto = static_cast<JSObject*>(exec->lexicalGlobalObject()->errorPrototype());
- JSObject* imp = new (exec) ErrorInstance(proto);
- JSObject* obj(imp);
-
- if (!args[0]->isUndefined())
- imp->putDirect(exec->propertyNames().message, jsString(exec, args[0]->toString(exec)));
+ return constructError(exec, args);
+}
- return obj;
+ConstructType ErrorConstructor::getConstructData(ConstructData& constructData)
+{
+ constructData.native.function = constructWithErrorConstructor;
+ return ConstructTypeNative;
}
// ECMA 15.9.2
-JSValue* ErrorConstructor::callAsFunction(ExecState* exec, JSObject* /*thisObj*/, const ArgList& args)
+static JSValue* callErrorConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
// "Error()" gives the sames result as "new Error()"
- return construct(exec, args);
+ return constructError(exec, args);
+}
+
+CallType ErrorConstructor::getCallData(CallData& callData)
+{
+ callData.native.function = callErrorConstructor;
+ return CallTypeNative;
}
// ------------------------------ NativeErrorPrototype ----------------------
putDirect(exec->propertyNames().prototype, proto, DontDelete|ReadOnly|DontEnum);
}
-ConstructType NativeErrorConstructor::getConstructData(ConstructData&)
+ErrorInstance* NativeErrorConstructor::construct(ExecState* exec, const ArgList& args)
{
+ ErrorInstance* object = new (exec) ErrorInstance(proto);
+ if (!args[0]->isUndefined())
+ object->putDirect(exec->propertyNames().message, jsString(exec, args[0]->toString(exec)));
+ return object;
+}
+
+static JSObject* constructWithNativeErrorConstructor(ExecState* exec, JSObject* constructor, const ArgList& args)
+{
+ return static_cast<NativeErrorConstructor*>(constructor)->construct(exec, args);
+}
+
+ConstructType NativeErrorConstructor::getConstructData(ConstructData& constructData)
+{
+ constructData.native.function = constructWithNativeErrorConstructor;
return ConstructTypeNative;
}
-JSObject* NativeErrorConstructor::construct(ExecState* exec, const ArgList& args)
+static JSValue* callNativeErrorConstructor(ExecState* exec, JSObject* constructor, JSValue*, const ArgList& args)
{
- JSObject* imp = new (exec) ErrorInstance(proto);
- JSObject* obj(imp);
- if (!args[0]->isUndefined())
- imp->putDirect(exec->propertyNames().message, jsString(exec, args[0]->toString(exec)));
- return obj;
+ return static_cast<NativeErrorConstructor*>(constructor)->construct(exec, args);
}
-JSValue* NativeErrorConstructor::callAsFunction(ExecState* exec, JSObject*, const ArgList& args)
+CallType NativeErrorConstructor::getCallData(CallData& callData)
{
- return construct(exec, args);
+ callData.native.function = callNativeErrorConstructor;
+ return CallTypeNative;
}
void NativeErrorConstructor::mark()
ErrorPrototype(ExecState*, ObjectPrototype*, FunctionPrototype*);
};
- JSValue* errorProtoFuncToString(ExecState*, JSObject*, const ArgList&);
-
class ErrorConstructor : public InternalFunction {
public:
ErrorConstructor(ExecState*, FunctionPrototype*, ErrorPrototype*);
+ private:
virtual ConstructType getConstructData(ConstructData&);
- virtual JSObject* construct(ExecState*, const ArgList&);
-
- virtual JSValue* callAsFunction(ExecState*, JSObject*, const ArgList&);
+ virtual CallType getCallData(CallData&);
};
class NativeErrorPrototype : public JSObject {
class NativeErrorConstructor : public InternalFunction {
public:
NativeErrorConstructor(ExecState*, FunctionPrototype*, NativeErrorPrototype*);
-
- virtual ConstructType getConstructData(ConstructData&);
- virtual JSObject* construct(ExecState*, const ArgList&);
-
- virtual JSValue* callAsFunction(ExecState*, JSObject*, const ArgList&);
-
virtual void mark();
-
- virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
+ ErrorInstance* construct(ExecState*, const ArgList&);
private:
- JSObject* proto;
+ virtual const ClassInfo* classInfo() const { return &info; }
+ virtual ConstructType getConstructData(ConstructData&);
+ virtual CallType getCallData(CallData&);
+
+ NativeErrorPrototype* proto;
};
} // namespace KJS
return UString::from(val);
}
-JSObject *JSNumberCell::toObject(ExecState *exec) const
+JSObject* JSNumberCell::toObject(ExecState* exec) const
{
- ArgList args;
- args.append(const_cast<JSNumberCell*>(this));
- return static_cast<JSObject *>(exec->lexicalGlobalObject()->numberConstructor()->construct(exec,args));
+ return constructNumber(exec, const_cast<JSNumberCell*>(this));
}
JSObject* JSNumberCell::toThisObject(ExecState* exec) const
{
- ArgList args;
- args.append(const_cast<JSNumberCell*>(this));
- return static_cast<JSObject*>(exec->lexicalGlobalObject()->numberConstructor()->construct(exec, args));
+ return constructNumber(exec, const_cast<JSNumberCell*>(this));
}
bool JSNumberCell::getUInt32(uint32_t& uint32) const
}
// --------------------------- GetterSetter ---------------------------------
+
void GetterSetter::mark()
{
JSCell::mark();
-
- if (getter && !getter->marked())
- getter->mark();
- if (setter && !setter->marked())
- setter->mark();
+
+ if (m_getter && !m_getter->marked())
+ m_getter->mark();
+ if (m_setter && !m_setter->marked())
+ m_setter->mark();
}
JSValue* GetterSetter::toPrimitive(ExecState*, JSType) const
{
- ASSERT(false);
+ ASSERT_NOT_REACHED();
return jsNull();
}
}
bool GetterSetter::toBoolean(ExecState*) const
-{
- ASSERT(false);
- return false;
-}
-
-double GetterSetter::toNumber(ExecState *) const
-{
- ASSERT(false);
- return 0.0;
-}
-
-UString GetterSetter::toString(ExecState *) const
-{
- ASSERT(false);
- return UString::null();
-}
-
-JSObject *GetterSetter::toObject(ExecState *exec) const
-{
- ASSERT(false);
- return jsNull()->toObject(exec);
-}
-
-bool GetterSetter::getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&)
-{
- ASSERT_NOT_REACHED();
- return false;
-}
-
-bool GetterSetter::getOwnPropertySlot(ExecState*, unsigned, PropertySlot&)
{
ASSERT_NOT_REACHED();
return false;
}
-void GetterSetter::put(ExecState*, const Identifier&, JSValue*)
+double GetterSetter::toNumber(ExecState*) const
{
ASSERT_NOT_REACHED();
+ return 0.0;
}
-void GetterSetter::put(ExecState*, unsigned, JSValue*)
+UString GetterSetter::toString(ExecState*) const
{
ASSERT_NOT_REACHED();
+ return UString::null();
}
-JSObject* GetterSetter::toThisObject(ExecState*) const
+JSObject* GetterSetter::toObject(ExecState* exec) const
{
ASSERT_NOT_REACHED();
- return 0;
+ return jsNull()->toObject(exec);
}
// ------------------------------ LabelStack -----------------------------------
{
}
-InternalFunction::InternalFunction(FunctionPrototype* funcProto, const Identifier& name)
- : JSObject(funcProto)
- , m_name(name)
-{
-}
-
-CallType InternalFunction::getCallData(CallData&)
+InternalFunction::InternalFunction(FunctionPrototype* prototype, const Identifier& name)
+ : JSObject(prototype)
+ , m_name(name)
{
- return CallTypeNative;
}
bool InternalFunction::implementsHasInstance() const
{
- return true;
+ return true;
}
}
UString::Rep* key;
union {
intptr_t integerValue;
- PrototypeFunction::JSMemberFunction functionValue;
+ NativeFunction functionValue;
};
unsigned char attributes; // JSObject attributes
unsigned char length; // number of arguments for function
{
JSFunction* func = new (exec) JSFunction(exec, m_ident, m_body.get(), scopeChain);
- JSObject* proto = exec->lexicalGlobalObject()->objectConstructor()->construct(exec, exec->emptyList());
+ JSObject* proto = constructEmptyObject(exec);
proto->putDirect(exec->propertyNames().constructor, func, DontEnum);
func->putDirect(exec->propertyNames().prototype, proto, DontDelete);
func->putDirect(exec->propertyNames().length, jsNumber(exec, m_body->parameters().size()), ReadOnly | DontDelete | DontEnum);
JSFunction* FuncExprNode::makeFunction(ExecState* exec, ScopeChainNode* scopeChain)
{
JSFunction* func = new (exec) JSFunction(exec, m_ident, m_body.get(), scopeChain);
- JSObject* proto = exec->lexicalGlobalObject()->objectConstructor()->construct(exec, exec->emptyList());
+ JSObject* proto = constructEmptyObject(exec);
proto->putDirect(exec->propertyNames().constructor, func, DontEnum);
func->putDirect(exec->propertyNames().prototype, proto, DontDelete);
// ------------------------------ ObjectPrototype --------------------------------
-static JSValue* objectProtoFuncValueOf(ExecState*, JSObject*, const ArgList&);
-static JSValue* objectProtoFuncHasOwnProperty(ExecState*, JSObject*, const ArgList&);
-static JSValue* objectProtoFuncIsPrototypeOf(ExecState*, JSObject*, const ArgList&);
-static JSValue* objectProtoFuncDefineGetter(ExecState*, JSObject*, const ArgList&);
-static JSValue* objectProtoFuncDefineSetter(ExecState*, JSObject*, const ArgList&);
-static JSValue* objectProtoFuncLookupGetter(ExecState*, JSObject*, const ArgList&);
-static JSValue* objectProtoFuncLookupSetter(ExecState*, JSObject*, const ArgList&);
-static JSValue* objectProtoFuncPropertyIsEnumerable(ExecState*, JSObject*, const ArgList&);
-static JSValue* objectProtoFuncToLocaleString(ExecState*, JSObject*, const ArgList&);
+static JSValue* objectProtoFuncValueOf(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* objectProtoFuncHasOwnProperty(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* objectProtoFuncIsPrototypeOf(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* objectProtoFuncDefineGetter(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* objectProtoFuncDefineSetter(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* objectProtoFuncLookupGetter(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* objectProtoFuncLookupSetter(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* objectProtoFuncPropertyIsEnumerable(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* objectProtoFuncToLocaleString(ExecState*, JSObject*, JSValue*, const ArgList&);
ObjectPrototype::ObjectPrototype(ExecState* exec, FunctionPrototype* functionPrototype)
: JSObject() // [[Prototype]] is null
// ECMA 15.2.4.2, 15.2.4.4, 15.2.4.5, 15.2.4.7
-JSValue* objectProtoFuncValueOf(ExecState*, JSObject* thisObj, const ArgList&)
+JSValue* objectProtoFuncValueOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- return thisObj;
+ return thisValue->toThisObject(exec);
}
-JSValue* objectProtoFuncHasOwnProperty(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* objectProtoFuncHasOwnProperty(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- return jsBoolean(thisObj->hasOwnProperty(exec, Identifier(exec, args[0]->toString(exec))));
+ return jsBoolean(thisValue->toThisObject(exec)->hasOwnProperty(exec, Identifier(exec, args[0]->toString(exec))));
}
-JSValue* objectProtoFuncIsPrototypeOf(ExecState*, JSObject* thisObj, const ArgList& args)
+JSValue* objectProtoFuncIsPrototypeOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
+ JSObject* thisObj = thisValue->toThisObject(exec);
+
if (!args[0]->isObject())
return jsBoolean(false);
while (true) {
if (!v->isObject())
return jsBoolean(false);
- if (thisObj == static_cast<JSObject*>(v))\v
+ if (thisObj == v)\v
return jsBoolean(true);
v = static_cast<JSObject*>(v)->prototype();
}
}
-JSValue* objectProtoFuncDefineGetter(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* objectProtoFuncDefineGetter(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- if (!args[1]->isObject() || !static_cast<JSObject*>(args[1])->implementsCall())
+ CallData callData;
+ if (args[1]->getCallData(callData) == CallTypeNone)
return throwError(exec, SyntaxError, "invalid getter usage");
-
- thisObj->defineGetter(exec, Identifier(exec, args[0]->toString(exec)), static_cast<JSObject *>(args[1]));
+ thisValue->toThisObject(exec)->defineGetter(exec, Identifier(exec, args[0]->toString(exec)), static_cast<JSObject*>(args[1]));
return jsUndefined();
}
-JSValue* objectProtoFuncDefineSetter(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* objectProtoFuncDefineSetter(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- if (!args[1]->isObject() || !static_cast<JSObject*>(args[1])->implementsCall())
+ CallData callData;
+ if (args[1]->getCallData(callData) == CallTypeNone)
return throwError(exec, SyntaxError, "invalid setter usage");
-
- thisObj->defineSetter(exec, Identifier(exec, args[0]->toString(exec)), static_cast<JSObject *>(args[1]));
+ thisValue->toThisObject(exec)->defineSetter(exec, Identifier(exec, args[0]->toString(exec)), static_cast<JSObject*>(args[1]));
return jsUndefined();
}
-JSValue* objectProtoFuncLookupGetter(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* objectProtoFuncLookupGetter(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- return thisObj->lookupGetter(exec, Identifier(exec, args[0]->toString(exec)));
+ return thisValue->toThisObject(exec)->lookupGetter(exec, Identifier(exec, args[0]->toString(exec)));
}
-JSValue* objectProtoFuncLookupSetter(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* objectProtoFuncLookupSetter(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- return thisObj->lookupSetter(exec, Identifier(exec, args[0]->toString(exec)));
+ return thisValue->toThisObject(exec)->lookupSetter(exec, Identifier(exec, args[0]->toString(exec)));
}
-JSValue* objectProtoFuncPropertyIsEnumerable(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* objectProtoFuncPropertyIsEnumerable(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
- return jsBoolean(thisObj->propertyIsEnumerable(exec, Identifier(exec, args[0]->toString(exec))));
+ return jsBoolean(thisValue->toThisObject(exec)->propertyIsEnumerable(exec, Identifier(exec, args[0]->toString(exec))));
}
-JSValue* objectProtoFuncToLocaleString(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* objectProtoFuncToLocaleString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- return jsString(exec, thisObj->toString(exec));
+ return jsString(exec, thisValue->toThisObject(exec)->toString(exec));
}
-JSValue* objectProtoFuncToString(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* objectProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- return jsString(exec, "[object " + thisObj->className() + "]");
+ return jsString(exec, "[object " + thisValue->toThisObject(exec)->className() + "]");
}
// ------------------------------ ObjectConstructor --------------------------------
putDirect(exec->propertyNames().prototype, objProto, DontEnum|DontDelete|ReadOnly);
// no. of arguments for constructor
- putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly|DontDelete|DontEnum);
+ putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontEnum | DontDelete);
+}
+
+// ECMA 15.2.2
+static ALWAYS_INLINE JSObject* constructObject(ExecState* exec, const ArgList& args)
+{
+ JSValue* arg = args[0];
+ if (arg->isUndefinedOrNull())
+ return new (exec) JSObject(exec->lexicalGlobalObject()->objectPrototype());
+ return arg->toObject(exec);
}
-ConstructType ObjectConstructor::getConstructData(ConstructData&)
+static JSObject* constructWithObjectConstructor(ExecState* exec, JSObject*, const ArgList& args)
{
+ return constructObject(exec, args);
+}
+
+ConstructType ObjectConstructor::getConstructData(ConstructData& constructData)
+{
+ constructData.native.function = constructWithObjectConstructor;
return ConstructTypeNative;
}
-// ECMA 15.2.2
-JSObject* ObjectConstructor::construct(ExecState* exec, const ArgList& args)
-{
- JSValue* arg = args[0];
- switch (arg->type()) {
- case StringType:
- case BooleanType:
- case NumberType:
- case ObjectType:
- return arg->toObject(exec);
- case NullType:
- case UndefinedType:
- return new (exec) JSObject(exec->lexicalGlobalObject()->objectPrototype());
- default:
- ASSERT_NOT_REACHED();
- return 0;
- }
-}
-
-JSValue* ObjectConstructor::callAsFunction(ExecState* exec, JSObject* /*thisObj*/, const ArgList &args)
-{
- return construct(exec, args);
+static JSValue* callObjectConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
+{
+ return constructObject(exec, args);
+}
+
+CallType ObjectConstructor::getCallData(CallData& callData)
+{
+ callData.native.function = callObjectConstructor;
+ return CallTypeNative;
}
} // namespace KJS
ObjectPrototype(ExecState*, FunctionPrototype*);
};
- JSValue* objectProtoFuncToString(ExecState*, JSObject*, const ArgList&);
+ JSValue* objectProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
/**
* @internal
class ObjectConstructor : public InternalFunction {
public:
ObjectConstructor(ExecState*, ObjectPrototype*, FunctionPrototype*);
-
+ private:
virtual ConstructType getConstructData(ConstructData&);
- virtual JSObject* construct(ExecState*, const ArgList&);
-
- virtual JSValue* callAsFunction(ExecState*, JSObject*, const ArgList&);
+ virtual CallType getCallData(CallData&);
};
} // namespace KJS
#include "config.h"
#include "string_object.h"
-#include "string_object.lut.h"
#include "JSWrapperObject.h"
#include "PropertyNameArray.h"
namespace KJS {
+static JSValue* stringProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncValueOf(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncCharAt(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncCharCodeAt(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncConcat(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncIndexOf(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncLastIndexOf(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncMatch(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncReplace(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncSearch(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncSlice(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncSplit(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncSubstr(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncSubstring(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncToLowerCase(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncToUpperCase(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncToLocaleLowerCase(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncToLocaleUpperCase(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncLocaleCompare(ExecState*, JSObject*, JSValue*, const ArgList&);
+
+static JSValue* stringProtoFuncBig(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncSmall(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncBlink(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncBold(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncFixed(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncItalics(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncStrike(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncSub(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncSup(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncFontcolor(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncFontsize(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncAnchor(ExecState*, JSObject*, JSValue*, const ArgList&);
+static JSValue* stringProtoFuncLink(ExecState*, JSObject*, JSValue*, const ArgList&);
+
+}
+
+#include "string_object.lut.h"
+
+namespace KJS {
+
// ------------------------------ StringObject ----------------------------
const ClassInfo StringObject::info = { "String", 0, 0, 0 };
const ClassInfo StringPrototype::info = { "String", &StringObject::info, 0, ExecState::stringTable };
/* Source for string_object.lut.h
@begin stringTable 26
- toString &stringProtoFuncToString DontEnum|Function 0
- valueOf &stringProtoFuncValueOf DontEnum|Function 0
- charAt &stringProtoFuncCharAt DontEnum|Function 1
- charCodeAt &stringProtoFuncCharCodeAt DontEnum|Function 1
- concat &stringProtoFuncConcat DontEnum|Function 1
- indexOf &stringProtoFuncIndexOf DontEnum|Function 1
- lastIndexOf &stringProtoFuncLastIndexOf DontEnum|Function 1
- match &stringProtoFuncMatch DontEnum|Function 1
- replace &stringProtoFuncReplace DontEnum|Function 2
- search &stringProtoFuncSearch DontEnum|Function 1
- slice &stringProtoFuncSlice DontEnum|Function 2
- split &stringProtoFuncSplit DontEnum|Function 2
- substr &stringProtoFuncSubstr DontEnum|Function 2
- substring &stringProtoFuncSubstring DontEnum|Function 2
- toLowerCase &stringProtoFuncToLowerCase DontEnum|Function 0
- toUpperCase &stringProtoFuncToUpperCase DontEnum|Function 0
- toLocaleLowerCase &stringProtoFuncToLocaleLowerCase DontEnum|Function 0
- toLocaleUpperCase &stringProtoFuncToLocaleUpperCase DontEnum|Function 0
- localeCompare &stringProtoFuncLocaleCompare DontEnum|Function 1
-
- big &stringProtoFuncBig DontEnum|Function 0
- small &stringProtoFuncSmall DontEnum|Function 0
- blink &stringProtoFuncBlink DontEnum|Function 0
- bold &stringProtoFuncBold DontEnum|Function 0
- fixed &stringProtoFuncFixed DontEnum|Function 0
- italics &stringProtoFuncItalics DontEnum|Function 0
- strike &stringProtoFuncStrike DontEnum|Function 0
- sub &stringProtoFuncSub DontEnum|Function 0
- sup &stringProtoFuncSup DontEnum|Function 0
- fontcolor &stringProtoFuncFontcolor DontEnum|Function 1
- fontsize &stringProtoFuncFontsize DontEnum|Function 1
- anchor &stringProtoFuncAnchor DontEnum|Function 1
- link &stringProtoFuncLink DontEnum|Function 1
+ toString stringProtoFuncToString DontEnum|Function 0
+ valueOf stringProtoFuncValueOf DontEnum|Function 0
+ charAt stringProtoFuncCharAt DontEnum|Function 1
+ charCodeAt stringProtoFuncCharCodeAt DontEnum|Function 1
+ concat stringProtoFuncConcat DontEnum|Function 1
+ indexOf stringProtoFuncIndexOf DontEnum|Function 1
+ lastIndexOf stringProtoFuncLastIndexOf DontEnum|Function 1
+ match stringProtoFuncMatch DontEnum|Function 1
+ replace stringProtoFuncReplace DontEnum|Function 2
+ search stringProtoFuncSearch DontEnum|Function 1
+ slice stringProtoFuncSlice DontEnum|Function 2
+ split stringProtoFuncSplit DontEnum|Function 2
+ substr stringProtoFuncSubstr DontEnum|Function 2
+ substring stringProtoFuncSubstring DontEnum|Function 2
+ toLowerCase stringProtoFuncToLowerCase DontEnum|Function 0
+ toUpperCase stringProtoFuncToUpperCase DontEnum|Function 0
+ toLocaleLowerCase stringProtoFuncToLocaleLowerCase DontEnum|Function 0
+ toLocaleUpperCase stringProtoFuncToLocaleUpperCase DontEnum|Function 0
+ localeCompare stringProtoFuncLocaleCompare DontEnum|Function 1
+
+ big stringProtoFuncBig DontEnum|Function 0
+ small stringProtoFuncSmall DontEnum|Function 0
+ blink stringProtoFuncBlink DontEnum|Function 0
+ bold stringProtoFuncBold DontEnum|Function 0
+ fixed stringProtoFuncFixed DontEnum|Function 0
+ italics stringProtoFuncItalics DontEnum|Function 0
+ strike stringProtoFuncStrike DontEnum|Function 0
+ sub stringProtoFuncSub DontEnum|Function 0
+ sup stringProtoFuncSup DontEnum|Function 0
+ fontcolor stringProtoFuncFontcolor DontEnum|Function 1
+ fontsize stringProtoFuncFontsize DontEnum|Function 1
+ anchor stringProtoFuncAnchor DontEnum|Function 1
+ link stringProtoFuncLink DontEnum|Function 1
@end
*/
// ECMA 15.5.4
static JSValue *replace(ExecState *exec, JSString* sourceVal, JSValue *pattern, JSValue *replacement)
{
UString source = sourceVal->value();
- JSObject *replacementFunction = 0;
+ CallData callData;
UString replacementString;
- if (replacement->isObject() && replacement->toObject(exec)->implementsCall())
- replacementFunction = replacement->toObject(exec);
- else
+ CallType callType = replacement->getCallData(callData);
+ if (callType == CallTypeNone)
replacementString = replacement->toString(exec);
if (pattern->isObject() && static_cast<JSObject *>(pattern)->inherits(&RegExpObject::info)) {
pushSourceRange(sourceRanges, sourceRangeCount, sourceRangeCapacity, UString::Range(lastIndex, matchIndex - lastIndex));
UString substitutedReplacement;
- if (replacementFunction) {
+ if (callType != CallTypeNone) {
int completeMatchStart = ovector[0];
ArgList args;
args.append(jsNumber(exec, completeMatchStart));
args.append(sourceVal);
- substitutedReplacement = replacementFunction->callAsFunction(exec, exec->globalThisValue(), args)->toString(exec);
+ substitutedReplacement = call(exec, replacement, callType, callData, exec->globalThisValue(), args)->toString(exec);
} else
substitutedReplacement = substituteBackreferences(replacementString, source, ovector, reg);
if (matchPos == -1)
return sourceVal;
- if (replacementFunction) {
+ if (callType != CallTypeNone) {
ArgList args;
args.append(jsString(exec, source.substr(matchPos, matchLen)));
args.append(jsNumber(exec, matchPos));
args.append(sourceVal);
- replacementString = replacementFunction->callAsFunction(exec, exec->globalThisValue(), args)->toString(exec);
+ replacementString = call(exec, replacement, callType, callData, exec->globalThisValue(), args)->toString(exec);
}
return jsString(exec, source.substr(0, matchPos) + replacementString + source.substr(matchPos + matchLen));
}
-JSValue* stringProtoFuncToString(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* stringProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&StringObject::info))
+ if (!thisValue->isObject(&StringObject::info))
return throwError(exec, TypeError);
- return static_cast<StringObject*>(thisObj)->internalValue();
+ return static_cast<StringObject*>(thisValue)->internalValue();
}
-JSValue* stringProtoFuncValueOf(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* stringProtoFuncValueOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
- if (!thisObj->inherits(&StringObject::info))
+ if (!thisValue->isObject(&StringObject::info))
return throwError(exec, TypeError);
- return static_cast<StringObject*>(thisObj)->internalValue();
+ return static_cast<StringObject*>(thisValue)->internalValue();
}
-JSValue* stringProtoFuncCharAt(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* stringProtoFuncCharAt(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
int len = s.size();
UString u;
return jsString(exec, u);
}
-JSValue* stringProtoFuncCharCodeAt(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* stringProtoFuncCharCodeAt(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
int len = s.size();
JSValue* result = 0;
return result;
}
-JSValue* stringProtoFuncConcat(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* stringProtoFuncConcat(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
ArgList::const_iterator end = args.end();
for (ArgList::const_iterator it = args.begin(); it != end; ++it) {
return jsString(exec, s);
}
-JSValue* stringProtoFuncIndexOf(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* stringProtoFuncIndexOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
int len = s.size();
JSValue* a0 = args[0];
return jsNumber(exec, s.find(u2, static_cast<int>(dpos)));
}
-JSValue* stringProtoFuncLastIndexOf(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* stringProtoFuncLastIndexOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
int len = s.size();
JSValue* a0 = args[0];
return jsNumber(exec, s.rfind(u2, static_cast<int>(dpos)));
}
-JSValue* stringProtoFuncMatch(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* stringProtoFuncMatch(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
JSValue* a0 = args[0];
// other browsers and because Null is a false value.
result = jsNull();
} else {
- result = exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, list);
+ result = constructArray(exec, list);
}
}
return result;
}
-JSValue* stringProtoFuncSearch(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* stringProtoFuncSearch(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
JSValue* a0 = args[0];
return jsNumber(exec, pos);
}
-JSValue* stringProtoFuncReplace(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* stringProtoFuncReplace(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
- JSString* sVal = thisObj->inherits(&StringObject::info) ?
- static_cast<StringObject*>(thisObj)->internalValue() :
+ JSString* sVal = thisValue->isObject(&StringObject::info) ?
+ static_cast<StringObject*>(thisValue)->internalValue() :
static_cast<JSString*>(jsString(exec, s));
JSValue* a0 = args[0];
return replace(exec, sVal, a0, a1);
}
-JSValue* stringProtoFuncSlice(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* stringProtoFuncSlice(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
int len = s.size();
JSValue* a0 = args[0];
return jsString(exec, "");
}
-JSValue* stringProtoFuncSplit(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* stringProtoFuncSplit(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
JSValue* a0 = args[0];
JSValue* a1 = args[1];
- JSObject *constructor = exec->lexicalGlobalObject()->arrayConstructor();
- JSObject* res = static_cast<JSObject*>(constructor->construct(exec, exec->emptyList()));
+ JSObject* res = constructEmptyArray(exec);
JSValue* result = res;
UString u = s;
int pos;
return result;
}
-JSValue* stringProtoFuncSubstr(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* stringProtoFuncSubstr(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
int len = s.size();
JSValue* a0 = args[0];
return jsString(exec, s.substr(static_cast<int>(start), static_cast<int>(length)));
}
-JSValue* stringProtoFuncSubstring(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* stringProtoFuncSubstring(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
int len = s.size();
JSValue* a0 = args[0];
return jsString(exec, s.substr((int)start, (int)end-(int)start));
}
-JSValue* stringProtoFuncToLowerCase(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* stringProtoFuncToLowerCase(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
- JSString* sVal = thisObj->inherits(&StringObject::info)
- ? static_cast<StringObject*>(thisObj)->internalValue()
+ JSString* sVal = thisValue->isObject(&StringObject::info)
+ ? static_cast<StringObject*>(thisValue)->internalValue()
: static_cast<JSString*>(jsString(exec, s));
int ssize = s.size();
if (!ssize)
return jsString(exec, UString(buffer.releaseBuffer(), length, false));
}
-JSValue* stringProtoFuncToUpperCase(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* stringProtoFuncToUpperCase(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
- JSString* sVal = thisObj->inherits(&StringObject::info)
- ? static_cast<StringObject*>(thisObj)->internalValue()
+ JSString* sVal = thisValue->isObject(&StringObject::info)
+ ? static_cast<StringObject*>(thisValue)->internalValue()
: static_cast<JSString*>(jsString(exec, s));
int ssize = s.size();
if (!ssize)
return jsString(exec, UString(buffer.releaseBuffer(), length, false));
}
-JSValue* stringProtoFuncToLocaleLowerCase(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* stringProtoFuncToLocaleLowerCase(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
// FIXME: See http://www.unicode.org/Public/UNIDATA/SpecialCasing.txt for locale-sensitive mappings that aren't implemented.
- JSString* sVal = thisObj->inherits(&StringObject::info)
- ? static_cast<StringObject*>(thisObj)->internalValue()
+ JSString* sVal = thisValue->isObject(&StringObject::info)
+ ? static_cast<StringObject*>(thisValue)->internalValue()
: static_cast<JSString*>(jsString(exec, s));
int ssize = s.size();
if (!ssize)
return jsString(exec, UString(buffer.releaseBuffer(), length, false));
}
-JSValue* stringProtoFuncToLocaleUpperCase(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* stringProtoFuncToLocaleUpperCase(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
- JSString* sVal = thisObj->inherits(&StringObject::info)
- ? static_cast<StringObject*>(thisObj)->internalValue()
+ JSString* sVal = thisValue->isObject(&StringObject::info)
+ ? static_cast<StringObject*>(thisValue)->internalValue()
: static_cast<JSString*>(jsString(exec, s));
int ssize = s.size();
if (!ssize)
return jsString(exec, UString(buffer.releaseBuffer(), length, false));
}
-JSValue* stringProtoFuncLocaleCompare(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* stringProtoFuncLocaleCompare(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
if (args.size() < 1)
return jsNumber(exec, 0);
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
JSValue* a0 = args[0];
return jsNumber(exec, localeCompare(s, a0->toString(exec)));
}
-JSValue* stringProtoFuncBig(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* stringProtoFuncBig(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
return jsString(exec, "<big>" + s + "</big>");
}
-JSValue* stringProtoFuncSmall(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* stringProtoFuncSmall(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
return jsString(exec, "<small>" + s + "</small>");
}
-JSValue* stringProtoFuncBlink(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* stringProtoFuncBlink(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
return jsString(exec, "<blink>" + s + "</blink>");
}
-JSValue* stringProtoFuncBold(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* stringProtoFuncBold(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
return jsString(exec, "<b>" + s + "</b>");
}
-JSValue* stringProtoFuncFixed(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* stringProtoFuncFixed(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
return jsString(exec, "<tt>" + s + "</tt>");
}
-JSValue* stringProtoFuncItalics(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* stringProtoFuncItalics(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
return jsString(exec, "<i>" + s + "</i>");
}
-JSValue* stringProtoFuncStrike(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* stringProtoFuncStrike(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
return jsString(exec, "<strike>" + s + "</strike>");
}
-JSValue* stringProtoFuncSub(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* stringProtoFuncSub(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
return jsString(exec, "<sub>" + s + "</sub>");
}
-JSValue* stringProtoFuncSup(ExecState* exec, JSObject* thisObj, const ArgList&)
+JSValue* stringProtoFuncSup(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
return jsString(exec, "<sup>" + s + "</sup>");
}
-JSValue* stringProtoFuncFontcolor(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* stringProtoFuncFontcolor(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
JSValue* a0 = args[0];
return jsString(exec, "<font color=\"" + a0->toString(exec) + "\">" + s + "</font>");
}
-JSValue* stringProtoFuncFontsize(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* stringProtoFuncFontsize(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
JSValue* a0 = args[0];
return jsString(exec, "<font size=\"" + a0->toString(exec) + "\">" + s + "</font>");
}
-JSValue* stringProtoFuncAnchor(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* stringProtoFuncAnchor(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
JSValue* a0 = args[0];
return jsString(exec, "<a name=\"" + a0->toString(exec) + "\">" + s + "</a>");
}
-JSValue* stringProtoFuncLink(ExecState* exec, JSObject* thisObj, const ArgList& args)
+JSValue* stringProtoFuncLink(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
// This optimizes the common case that thisObj is a StringObject
- UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
+ UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
JSValue* a0 = args[0];
return jsString(exec, "<a href=\"" + a0->toString(exec) + "\">" + s + "</a>");
}
// ------------------------------ StringConstructor ------------------------------
+static JSValue* stringFromCharCode(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
+{
+ UString s;
+ if (args.size()) {
+ UChar* buf = static_cast<UChar*>(fastMalloc(args.size() * sizeof(UChar)));
+ UChar* p = buf;
+ ArgList::const_iterator end = args.end();
+ for (ArgList::const_iterator it = args.begin(); it != end; ++it)
+ *p++ = static_cast<UChar>((*it)->toUInt32(exec));
+ s = UString(buf, args.size(), false);
+ } else
+ s = "";
+
+ return jsString(exec, s);
+}
+
StringConstructor::StringConstructor(ExecState* exec, FunctionPrototype* funcProto, StringPrototype* stringProto)
: InternalFunction(funcProto, Identifier(exec, stringProto->classInfo()->className))
{
// ECMA 15.5.3.1 String.prototype
- putDirect(exec->propertyNames().prototype, stringProto, DontEnum|DontDelete|ReadOnly);
+ putDirect(exec->propertyNames().prototype, stringProto, ReadOnly | DontEnum | DontDelete);
- putDirectFunction(new (exec) StringConstructorFunction(exec, funcProto, exec->propertyNames().fromCharCode), DontEnum);
+ // ECMA 15.5.3.2 fromCharCode()
+ putDirectFunction(new (exec) PrototypeFunction(exec, funcProto, 1, exec->propertyNames().fromCharCode, stringFromCharCode), DontEnum);
// no. of arguments for constructor
- putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly|DontDelete|DontEnum);
-}
-
-
-ConstructType StringConstructor::getConstructData(ConstructData&)
-{
- return ConstructTypeNative;
+ putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontEnum | DontDelete);
}
// ECMA 15.5.2
-JSObject* StringConstructor::construct(ExecState* exec, const ArgList& args)
+static JSObject* constructWithStringConstructor(ExecState* exec, JSObject*, const ArgList& args)
{
- JSObject* proto = exec->lexicalGlobalObject()->stringPrototype();
- if (!args.size())
- return new (exec) StringObject(exec, proto);
- return new (exec) StringObject(exec, proto, args[0]->toString(exec));
+ JSObject* prototype = exec->lexicalGlobalObject()->stringPrototype();
+ if (args.isEmpty())
+ return new (exec) StringObject(exec, prototype);
+ return new (exec) StringObject(exec, prototype, args[0]->toString(exec));
}
-// ECMA 15.5.1
-JSValue *StringConstructor::callAsFunction(ExecState *exec, JSObject* /*thisObj*/, const ArgList &args)
+ConstructType StringConstructor::getConstructData(ConstructData& constructData)
{
- if (args.isEmpty())
- return jsString(exec, "");
- else {
- JSValue *v = args[0];
- return jsString(exec, v->toString(exec));
- }
+ constructData.native.function = constructWithStringConstructor;
+ return ConstructTypeNative;
}
-// ------------------------------ StringConstructorFunction --------------------------
-
-// ECMA 15.5.3.2 fromCharCode()
-StringConstructorFunction::StringConstructorFunction(ExecState* exec, FunctionPrototype* funcProto, const Identifier& name)
- : InternalFunction(funcProto, name)
+// ECMA 15.5.1
+static JSValue* callStringConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
- putDirect(exec->propertyNames().length, jsNumber(exec, 1), DontDelete|ReadOnly|DontEnum);
+ if (args.isEmpty())
+ return jsString(exec, "");
+ return jsString(exec, args[0]->toString(exec));
}
-JSValue *StringConstructorFunction::callAsFunction(ExecState *exec, JSObject* /*thisObj*/, const ArgList &args)
+CallType StringConstructor::getCallData(CallData& callData)
{
- UString s;
- if (args.size()) {
- UChar *buf = static_cast<UChar *>(fastMalloc(args.size() * sizeof(UChar)));
- UChar *p = buf;
- ArgList::const_iterator end = args.end();
- for (ArgList::const_iterator it = args.begin(); it != end; ++it) {
- unsigned short u = static_cast<unsigned short>((*it)->toUInt32(exec));
- *p++ = UChar(u);
- }
- s = UString(buf, args.size(), false);
- } else
- s = "";
-
- return jsString(exec, s);
+ callData.native.function = callStringConstructor;
+ return CallTypeNative;
}
} // namespace KJS
static const ClassInfo info;
};
- /**
- * @internal
- *
- * Functions to implement all methods that are properties of the
- * String.prototype object
- */
-
- JSValue* stringProtoFuncToString(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncValueOf(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncCharAt(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncCharCodeAt(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncConcat(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncIndexOf(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncLastIndexOf(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncMatch(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncReplace(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncSearch(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncSlice(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncSplit(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncSubstr(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncSubstring(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncToLowerCase(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncToUpperCase(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncToLocaleLowerCase(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncToLocaleUpperCase(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncLocaleCompare(ExecState*, JSObject*, const ArgList&);
-
- JSValue* stringProtoFuncBig(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncSmall(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncBlink(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncBold(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncFixed(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncItalics(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncStrike(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncSub(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncSup(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncFontcolor(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncFontsize(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncAnchor(ExecState*, JSObject*, const ArgList&);
- JSValue* stringProtoFuncLink(ExecState*, JSObject*, const ArgList&);
-
/**
* @internal
*
class StringConstructor : public InternalFunction {
public:
StringConstructor(ExecState*, FunctionPrototype*, StringPrototype*);
-
virtual ConstructType getConstructData(ConstructData&);
- virtual JSObject* construct(ExecState*, const ArgList&);
-
- virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const ArgList& args);
+ virtual CallType getCallData(CallData&);
};
/**
class StringConstructorFunction : public InternalFunction {
public:
StringConstructorFunction(ExecState*, FunctionPrototype*, const Identifier&);
- virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const ArgList& args);
+ virtual CallType getCallData(CallData&);
};
} // namespace
+2008-06-23 Darin Adler <darin@apple.com>
+
+ Reviewed by Geoff.
+
+ * JSValueWrapper.cpp:
+ (JSValueWrapper::JSObjectCallFunction): Updated to use getCallData and call instead
+ of the old callAsFunction.
+
2008-06-17 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Darin.
listArgs.append(kgsArg);
}
- JSValue *resultValue = objValue->callAsFunction(exec, ksjThisObj, listArgs);
+ CallData callData;
+ CallType callType = objValue->getCallData(callData);
+ if (callType == CallTypeNone)
+ return 0;
+ JSValue* resultValue = call(exec, objValue, callType, callData, ksjThisObj, listArgs);
JSValueWrapper* wrapperValue = new JSValueWrapper(resultValue);
JSObjectCallBacks callBacks;
GetJSObectCallBacks(callBacks);
+2008-06-23 Darin Adler <darin@apple.com>
+
+ Reviewed by Geoff.
+