Changeset 34754 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Jun 23, 2008, 10:23:17 PM (17 years ago)
Author:
Darin Adler
Message:

JavaScriptCore:

2008-06-23 Darin Adler <Darin Adler>

Reviewed by Geoff.

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:

JavaScriptGlue:

2008-06-23 Darin Adler <Darin Adler>

Reviewed by Geoff.

  • JSValueWrapper.cpp: (JSValueWrapper::JSObjectCallFunction): Updated to use getCallData and call instead of the old callAsFunction.

WebCore:

2008-06-23 Darin Adler <Darin Adler>

Reviewed by Geoff.

Update for JavaScript changes.

  • Use CallData and ConstructData instead of the obsolete implementsCall, callAsFunction, and construct functions.
  • Updated native function arguments, specifically to allow a JSValue rather than a JSObject for the this argument, and to call toThisObject as needed when treating it as an object.
  • Made some more class members private and protected, including virtual function overrides.
  • Eliminated the use of getCallData in the JavaScript bridging code as a way to check if an instance supports invokeDefaultMethod.
  • Eliminated unnecessary polymorphism in the NodeIterator and TreeWalker classes. They were using virtual functions simply to share an instance of the RefCounted template, which was not helpful.
  • bindings/js/JSAudioConstructor.cpp: (WebCore::constructAudio): (WebCore::JSAudioConstructor::getConstructData):
  • bindings/js/JSAudioConstructor.h: (WebCore::JSAudioConstructor::document): (WebCore::JSAudioConstructor::classInfo):
  • bindings/js/JSClipboardCustom.cpp: (WebCore::JSClipboard::types):
  • bindings/js/JSCustomSQLStatementCallback.cpp: (WebCore::JSCustomSQLStatementCallback::handleEvent):
  • bindings/js/JSCustomSQLStatementErrorCallback.cpp: (WebCore::JSCustomSQLStatementErrorCallback::handleEvent):
  • bindings/js/JSCustomSQLTransactionCallback.cpp: (WebCore::JSCustomSQLTransactionCallback::handleEvent):
  • bindings/js/JSCustomSQLTransactionErrorCallback.cpp: (WebCore::JSCustomSQLTransactionErrorCallback::handleEvent):
  • bindings/js/JSCustomVoidCallback.cpp: (WebCore::JSCustomVoidCallback::handleEvent):
  • bindings/js/JSCustomXPathNSResolver.cpp: (WebCore::JSCustomXPathNSResolver::lookupNamespaceURI):
  • bindings/js/JSDOMBinding.h: (WebCore::DOMObject::DOMObject):
  • bindings/js/JSDOMWindowBase.cpp: (WebCore::windowProtoFuncAToB): (WebCore::windowProtoFuncBToA): (WebCore::windowProtoFuncOpen): (WebCore::windowProtoFuncSetTimeout): (WebCore::windowProtoFuncClearTimeout): (WebCore::windowProtoFuncSetInterval): (WebCore::windowProtoFuncAddEventListener): (WebCore::windowProtoFuncRemoveEventListener): (WebCore::windowProtoFuncShowModalDialog): (WebCore::windowProtoFuncNotImplemented): (WebCore::toJSDOMWindow):
  • bindings/js/JSDOMWindowBase.h:
  • bindings/js/JSDOMWindowShell.h: (WebCore::JSDOMWindowShell::classInfo):
  • bindings/js/JSEventListener.cpp: (WebCore::JSAbstractEventListener::handleEvent): (WebCore::JSLazyEventListener::parseCode):
  • bindings/js/JSEventTargetBase.cpp: (WebCore::retrieveEventTargetAndCorrespondingNode): (WebCore::jsEventTargetAddEventListener): (WebCore::jsEventTargetRemoveEventListener): (WebCore::jsEventTargetDispatchEvent):
  • bindings/js/JSEventTargetBase.h:
  • bindings/js/JSHTMLAppletElementCustom.cpp: (WebCore::JSHTMLAppletElement::customGetOwnPropertySlot): (WebCore::JSHTMLAppletElement::customPut): (WebCore::JSHTMLAppletElement::getCallData):
  • bindings/js/JSHTMLCollectionCustom.cpp: (WebCore::callHTMLCollection): (WebCore::JSHTMLCollection::getCallData):
  • bindings/js/JSHTMLDocumentCustom.cpp: (WebCore::JSHTMLDocument::open):
  • bindings/js/JSHTMLEmbedElementCustom.cpp: (WebCore::JSHTMLEmbedElement::customGetOwnPropertySlot): (WebCore::JSHTMLEmbedElement::customPut): (WebCore::JSHTMLEmbedElement::getCallData):
  • bindings/js/JSHTMLInputElementBase.cpp: (WebCore::jsHTMLInputElementBaseFunctionSetSelectionRange):
  • bindings/js/JSHTMLInputElementBase.h:
  • bindings/js/JSHTMLObjectElementCustom.cpp: (WebCore::JSHTMLObjectElement::customGetOwnPropertySlot): (WebCore::JSHTMLObjectElement::customPut): (WebCore::JSHTMLObjectElement::getCallData):
  • bindings/js/JSHTMLOptionElementConstructor.cpp: (WebCore::constructHTMLOptionElement): (WebCore::JSHTMLOptionElementConstructor::getConstructData):
  • bindings/js/JSHTMLOptionElementConstructor.h: (WebCore::JSHTMLOptionElementConstructor::document): (WebCore::JSHTMLOptionElementConstructor::classInfo):
  • bindings/js/JSImageConstructor.cpp: (WebCore::constructImage): (WebCore::JSImageConstructor::getConstructData):
  • bindings/js/JSImageConstructor.h: (WebCore::JSImageConstructor::document): (WebCore::JSImageConstructor::classInfo):
  • bindings/js/JSInspectedObjectWrapper.h: (WebCore::JSInspectedObjectWrapper::classInfo):
  • bindings/js/JSInspectorCallbackWrapper.cpp: (WebCore::JSInspectorCallbackWrapper::prepareIncomingValue):
  • bindings/js/JSJavaScriptCallFrameCustom.cpp: (WebCore::JSJavaScriptCallFrame::scopeChain):
  • bindings/js/JSNodeFilterCondition.cpp: (WebCore::JSNodeFilterCondition::JSNodeFilterCondition): (WebCore::JSNodeFilterCondition::mark): (WebCore::JSNodeFilterCondition::acceptNode):
  • bindings/js/JSNodeFilterCondition.h: (WebCore::JSNodeFilterCondition::create):
  • bindings/js/JSNodeFilterCustom.cpp: (WebCore::toNodeFilter):
  • bindings/js/JSNodeListCustom.cpp: (WebCore::callNodeList): (WebCore::JSNodeList::getCallData): (WebCore::JSNodeList::canGetItemsForName): (WebCore::JSNodeList::nameGetter):
  • bindings/js/JSPluginElementFunctions.cpp: (WebCore::runtimeObjectGetter): (WebCore::runtimeObjectPropertyGetter): (WebCore::runtimeObjectCustomGetOwnPropertySlot): (WebCore::runtimeObjectCustomPut): (WebCore::runtimeObjectGetCallData): (WebCore::pluginInstance): (WebCore::getRuntimeObject): (WebCore::callPlugin):
  • bindings/js/JSPluginElementFunctions.h:
  • bindings/js/JSQuarantinedObjectWrapper.cpp: (WebCore::JSQuarantinedObjectWrapper::put): (WebCore::JSQuarantinedObjectWrapper::construct): (WebCore::JSQuarantinedObjectWrapper::getConstructData): (WebCore::JSQuarantinedObjectWrapper::hasInstance): (WebCore::JSQuarantinedObjectWrapper::call): (WebCore::JSQuarantinedObjectWrapper::getCallData):
  • bindings/js/JSQuarantinedObjectWrapper.h: (WebCore::JSQuarantinedObjectWrapper::className):
  • bindings/js/JSRGBColor.cpp:
  • bindings/js/JSXMLHttpRequestConstructor.cpp: (WebCore::constructXMLHttpRequest): (WebCore::JSXMLHttpRequestConstructor::getConstructData):
  • bindings/js/JSXMLHttpRequestConstructor.h: (WebCore::JSXMLHttpRequestConstructor::document): (WebCore::JSXMLHttpRequestConstructor::classInfo):
  • bindings/js/JSXSLTProcessorConstructor.cpp: (WebCore::constructXSLTProcessor): (WebCore::JSXSLTProcessorConstructor::getConstructData):
  • bindings/js/JSXSLTProcessorConstructor.h: (WebCore::JSXSLTProcessorConstructor::classInfo):
  • bindings/js/ScheduledAction.cpp: (WebCore::ScheduledAction::ScheduledAction): (WebCore::ScheduledAction::execute):
  • bindings/js/ScheduledAction.h:
  • bindings/objc/WebScriptObject.mm: (-[WebScriptObject callWebScriptMethod:withArguments:]):
  • bindings/scripts/CodeGeneratorJS.pm:
  • bridge/NP_jsobject.cpp: (_NPN_InvokeDefault): (_NPN_Invoke):
  • bridge/c/c_instance.cpp: (KJS::Bindings::CInstance::supportsInvokeDefaultMethod):
  • bridge/c/c_instance.h:
  • bridge/jni/jni_jsobject.mm: (JavaJSObject::call):
  • bridge/objc/objc_instance.h:
  • bridge/objc/objc_instance.mm: (ObjcInstance::supportsInvokeDefaultMethod):
  • bridge/objc/objc_runtime.h: (KJS::Bindings::ObjcFallbackObjectImp::propertyName): (KJS::Bindings::ObjcFallbackObjectImp::classInfo):
  • bridge/objc/objc_runtime.mm: (Bindings::webScriptObjectClass): (Bindings::webUndefinedClass): (ObjcFallbackObjectImp::ObjcFallbackObjectImp): (callObjCFallbackObject): (ObjcFallbackObjectImp::getCallData):
  • bridge/qt/qt_instance.h:
  • bridge/runtime.cpp: (KJS::Bindings::Instance::createRuntimeObject): (KJS::Bindings::Instance::getInstance):
  • bridge/runtime.h: (KJS::Bindings::Field::~Field): (KJS::Bindings::Method::~Method): (KJS::Bindings::Class::~Class): (KJS::Bindings::Instance::supportsInvokeDefaultMethod):
  • bridge/runtime_method.cpp: (KJS::callRuntimeMethod): (KJS::RuntimeMethod::getCallData):
  • bridge/runtime_method.h: (KJS::RuntimeMethod::methods):
  • bridge/runtime_object.cpp: (RuntimeObjectImp::defaultValue): (callRuntimeObject): (RuntimeObjectImp::getCallData):
  • bridge/runtime_object.h: (KJS::RuntimeObjectImp::getInternalInstance): (KJS::RuntimeObjectImp::classInfo):
  • dom/NodeIterator.h:
  • dom/Traversal.cpp:
  • dom/Traversal.h:
  • dom/TreeWalker.h:
Location:
trunk/JavaScriptCore/kjs
Files:
40 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/ArrayPrototype.cpp

    r34659 r34754  
    2424#include "config.h"
    2525#include "ArrayPrototype.h"
    26 #include "ArrayPrototype.lut.h"
    2726
    2827#include "Machine.h"
     
    3534
    3635#include <algorithm> // for std::min
     36
     37namespace KJS {
     38
     39static JSValue* arrayProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
     40static JSValue* arrayProtoFuncToLocaleString(ExecState*, JSObject*, JSValue*, const ArgList&);
     41static JSValue* arrayProtoFuncConcat(ExecState*, JSObject*, JSValue*, const ArgList&);
     42static JSValue* arrayProtoFuncJoin(ExecState*, JSObject*, JSValue*, const ArgList&);
     43static JSValue* arrayProtoFuncPop(ExecState*, JSObject*, JSValue*, const ArgList&);
     44static JSValue* arrayProtoFuncPush(ExecState*, JSObject*, JSValue*, const ArgList&);
     45static JSValue* arrayProtoFuncReverse(ExecState*, JSObject*, JSValue*, const ArgList&);
     46static JSValue* arrayProtoFuncShift(ExecState*, JSObject*, JSValue*, const ArgList&);
     47static JSValue* arrayProtoFuncSlice(ExecState*, JSObject*, JSValue*, const ArgList&);
     48static JSValue* arrayProtoFuncSort(ExecState*, JSObject*, JSValue*, const ArgList&);
     49static JSValue* arrayProtoFuncSplice(ExecState*, JSObject*, JSValue*, const ArgList&);
     50static JSValue* arrayProtoFuncUnShift(ExecState*, JSObject*, JSValue*, const ArgList&);
     51static JSValue* arrayProtoFuncEvery(ExecState*, JSObject*, JSValue*, const ArgList&);
     52static JSValue* arrayProtoFuncForEach(ExecState*, JSObject*, JSValue*, const ArgList&);
     53static JSValue* arrayProtoFuncSome(ExecState*, JSObject*, JSValue*, const ArgList&);
     54static JSValue* arrayProtoFuncIndexOf(ExecState*, JSObject*, JSValue*, const ArgList&);
     55static JSValue* arrayProtoFuncFilter(ExecState*, JSObject*, JSValue*, const ArgList&);
     56static JSValue* arrayProtoFuncMap(ExecState*, JSObject*, JSValue*, const ArgList&);
     57static JSValue* arrayProtoFuncLastIndexOf(ExecState*, JSObject*, JSValue*, const ArgList&);
     58
     59}
     60
     61#include "ArrayPrototype.lut.h"
    3762
    3863namespace KJS {
     
    89114}
    90115
    91 JSValue* arrayProtoFuncToString(ExecState* exec, JSObject* thisObj, const ArgList&)
    92 {
    93     if (!thisObj->inherits(&JSArray::info))
     116JSValue* arrayProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     117{
     118    if (!thisValue->isObject(&JSArray::info))
    94119        return throwError(exec, TypeError);
     120    JSObject* thisObj = static_cast<JSArray*>(thisValue);
    95121
    96122    HashSet<JSObject*>& arrayVisitedElements = exec->dynamicGlobalObject()->arrayVisitedElements();
     
    132158}
    133159
    134 JSValue* arrayProtoFuncToLocaleString(ExecState* exec, JSObject* thisObj, const ArgList&)
    135 {
    136     if (!thisObj->inherits(&JSArray::info))
     160JSValue* arrayProtoFuncToLocaleString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     161{
     162    if (!thisValue->isObject(&JSArray::info))
    137163        return throwError(exec, TypeError);
     164    JSObject* thisObj = static_cast<JSArray*>(thisValue);
    138165
    139166    HashSet<JSObject*>& arrayVisitedElements = exec->dynamicGlobalObject()->arrayVisitedElements();
     
    163190        JSValue* conversionFunction = o->get(exec, exec->propertyNames().toLocaleString);
    164191        UString str;
    165         if (conversionFunction->isObject() && static_cast<JSObject*>(conversionFunction)->implementsCall())
    166             str = static_cast<JSObject*>(conversionFunction)->callAsFunction(exec, o, exec->emptyList())->toString(exec);
     192        CallData callData;
     193        CallType callType = conversionFunction->getCallData(callData);
     194        if (callType != CallTypeNone)
     195            str = call(exec, conversionFunction, callType, callData, element, exec->emptyList())->toString(exec);
    167196        else
    168197            str = element->toString(exec);
     
    181210}
    182211
    183 JSValue* arrayProtoFuncJoin(ExecState* exec, JSObject* thisObj, const ArgList& args)
    184 {
     212JSValue* arrayProtoFuncJoin(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     213{
     214    JSObject* thisObj = thisValue->toThisObject(exec);
     215
    185216    HashSet<JSObject*>& arrayVisitedElements = exec->dynamicGlobalObject()->arrayVisitedElements();
    186217    if (arrayVisitedElements.size() > MaxReentryDepth)
     
    224255}
    225256
    226 JSValue* arrayProtoFuncConcat(ExecState* exec, JSObject* thisObj, const ArgList& args)
    227 {
    228     JSObject* arr = static_cast<JSObject*>(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList()));
     257JSValue* arrayProtoFuncConcat(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     258{
     259    JSArray* arr = constructEmptyArray(exec);
    229260    int n = 0;
    230     JSValue* curArg = thisObj;
    231     JSObject* curObj = static_cast<JSObject* >(thisObj);
     261    JSValue* curArg = thisValue->toThisObject(exec);
    232262    ArgList::const_iterator it = args.begin();
    233263    ArgList::const_iterator end = args.end();
    234264    while (1) {
    235         if (curArg->isObject() && curObj->inherits(&JSArray::info)) {
    236             unsigned k = 0;
    237             // Older versions tried to optimize out getting the length of thisObj
    238             // by checking for n != 0, but that doesn't work if thisObj is an empty array.
    239             unsigned length = curObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
    240             while (k < length) {
    241                 if (JSValue* v = getProperty(exec, curObj, k))
     265        if (curArg->isObject(&JSArray::info)) {
     266            JSArray* curArray = static_cast<JSArray*>(curArg);
     267            unsigned length = curArray->getLength();
     268            for (unsigned k = 0; k < length; ++k) {
     269                if (JSValue* v = curArray->getItem(k))
    242270                    arr->put(exec, n, v);
    243271                n++;
    244                 k++;
    245272            }
    246273        } else {
     
    251278            break;
    252279        curArg = *it;
    253         curObj = static_cast<JSObject*>(curArg); // may be 0
    254280        ++it;
    255281    }
    256     arr->put(exec, exec->propertyNames().length, jsNumber(exec, n));
     282    arr->setLength(n);
    257283    return arr;
    258284}
    259285
    260 JSValue* arrayProtoFuncPop(ExecState* exec, JSObject* thisObj, const ArgList&)
    261 {
     286JSValue* arrayProtoFuncPop(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     287{
     288    JSObject* thisObj = thisValue->toThisObject(exec);
    262289    JSValue* result = 0;
    263290    unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
     
    273300}
    274301
    275 JSValue* arrayProtoFuncPush(ExecState* exec, JSObject* thisObj, const ArgList& args)
    276 {
     302JSValue* arrayProtoFuncPush(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     303{
     304    JSObject* thisObj = thisValue->toThisObject(exec);
    277305    unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
    278306    for (unsigned n = 0; n < args.size(); n++)
     
    283311}
    284312
    285 JSValue* arrayProtoFuncReverse(ExecState* exec, JSObject* thisObj, const ArgList&)
    286 {
     313JSValue* arrayProtoFuncReverse(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     314{
     315    JSObject* thisObj = thisValue->toThisObject(exec);
    287316    unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
    288317    unsigned middle = length / 2;
     
    306335}
    307336
    308 JSValue* arrayProtoFuncShift(ExecState* exec, JSObject* thisObj, const ArgList&)
    309 {
     337JSValue* arrayProtoFuncShift(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     338{
     339    JSObject* thisObj = thisValue->toThisObject(exec);
    310340    JSValue* result = 0;
    311341
     
    328358}
    329359
    330 JSValue* arrayProtoFuncSlice(ExecState* exec, JSObject* thisObj, const ArgList& args)
     360JSValue* arrayProtoFuncSlice(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
    331361{
    332362    // http://developer.netscape.com/docs/manuals/js/client/jsref/array.htm#1193713 or 15.4.4.10
    333363
     364    JSObject* thisObj = thisValue->toThisObject(exec);
     365
    334366    // We return a new array
    335     JSObject* resObj = static_cast<JSObject* >(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList()));
     367    JSArray* resObj = constructEmptyArray(exec);
    336368    JSValue* result = resObj;
    337369    double begin = args[0]->toInteger(exec);
     
    367399            resObj->put(exec, n, v);
    368400    }
    369     resObj->put(exec, exec->propertyNames().length, jsNumber(exec, n));
     401    resObj->setLength(n);
    370402    return result;
    371403}
    372404
    373 JSValue* arrayProtoFuncSort(ExecState* exec, JSObject* thisObj, const ArgList& args)
    374 {
    375     JSObject* sortFunction = 0;
    376     if (!args[0]->isUndefined()) {
    377         sortFunction = args[0]->toObject(exec);
    378         if (!sortFunction->implementsCall())
    379             sortFunction = 0;
    380     }
     405JSValue* arrayProtoFuncSort(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     406{
     407    JSObject* thisObj = thisValue->toThisObject(exec);
     408
     409    JSValue* function = args[0];
     410    CallData callData;
     411    CallType callType = function->getCallData(callData);
    381412
    382413    if (thisObj->classInfo() == &JSArray::info) {
    383         if (sortFunction)
    384             static_cast<JSArray*>(thisObj)->sort(exec, sortFunction);
     414        if (callType != CallTypeNone)
     415            static_cast<JSArray*>(thisObj)->sort(exec, function, callType, callData);
    385416        else
    386417            static_cast<JSArray*>(thisObj)->sort(exec);
     
    406437            else if (minObj->isUndefined())
    407438                compareResult = -1;
    408             else if (sortFunction) {
     439            else if (callType != CallTypeNone) {
    409440                ArgList l;
    410441                l.append(jObj);
    411442                l.append(minObj);
    412                 compareResult = sortFunction->callAsFunction(exec, exec->globalThisValue(), l)->toNumber(exec);
     443                compareResult = call(exec, function, callType, callData, exec->globalThisValue(), l)->toNumber(exec);
    413444            } else
    414445                compareResult = (jObj->toString(exec) < minObj->toString(exec)) ? -1 : 1;
     
    428459}
    429460
    430 JSValue* arrayProtoFuncSplice(ExecState* exec, JSObject* thisObj, const ArgList& args)
    431 {
     461JSValue* arrayProtoFuncSplice(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     462{
     463    JSObject* thisObj = thisValue->toThisObject(exec);
     464
    432465    // 15.4.4.12
    433     JSObject* resObj = static_cast<JSObject* >(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList()));
     466    JSArray* resObj = constructEmptyArray(exec);
    434467    JSValue* result = resObj;
    435468    unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
     
    452485            resObj->put(exec, k, v);
    453486    }
    454     resObj->put(exec, exec->propertyNames().length, jsNumber(exec, deleteCount));
     487    resObj->setLength(deleteCount);
    455488
    456489    unsigned additionalArgs = std::max<int>(args.size() - 2, 0);
     
    481514}
    482515
    483 JSValue* arrayProtoFuncUnShift(ExecState* exec, JSObject* thisObj, const ArgList& args)
    484 {
     516JSValue* arrayProtoFuncUnShift(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     517{
     518    JSObject* thisObj = thisValue->toThisObject(exec);
     519
    485520    // 15.4.4.13
    486521    unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
     
    501536}
    502537
    503 JSValue* arrayProtoFuncFilter(ExecState* exec, JSObject* thisObj, const ArgList& args)
    504 {
    505     JSObject* eachFunction = args[0]->toObject(exec);
    506 
    507     if (!eachFunction->implementsCall())
     538JSValue* arrayProtoFuncFilter(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     539{
     540    JSObject* thisObj = thisValue->toThisObject(exec);
     541
     542    JSValue* function = args[0];
     543    CallData callData;
     544    CallType callType = function->getCallData(callData);
     545    if (callType == CallTypeNone)
    508546        return throwError(exec, TypeError);
    509547
    510     JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() :  args[1]->toObject(exec);
    511     JSObject* resultArray = static_cast<JSObject*>(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList()));
     548    JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() : args[1]->toObject(exec);
     549    JSArray* resultArray = constructEmptyArray(exec);
    512550
    513551    unsigned filterIndex = 0;
     
    527565        eachArguments.append(thisObj);
    528566
    529         JSValue* result = eachFunction->callAsFunction(exec, applyThis, eachArguments);
     567        JSValue* result = call(exec, function, callType, callData, applyThis, eachArguments);
    530568
    531569        if (result->toBoolean(exec))
     
    535573}
    536574
    537 JSValue* arrayProtoFuncMap(ExecState* exec, JSObject* thisObj, const ArgList& args)
    538 {
    539     JSObject* eachFunction = args[0]->toObject(exec);
    540     if (!eachFunction->implementsCall())
     575JSValue* arrayProtoFuncMap(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     576{
     577    JSObject* thisObj = thisValue->toThisObject(exec);
     578
     579    JSValue* function = args[0];
     580    CallData callData;
     581    CallType callType = function->getCallData(callData);
     582    if (callType == CallTypeNone)
    541583        return throwError(exec, TypeError);
    542584
    543     JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() :  args[1]->toObject(exec);
    544 
    545     unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
    546 
    547     ArgList mapArgs;
    548     mapArgs.append(jsNumber(exec, length));
    549     JSObject* resultArray = static_cast<JSObject*>(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, mapArgs));
     585    JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() : args[1]->toObject(exec);
     586
     587    unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
     588
     589    JSArray* resultArray = constructEmptyArray(exec, length);
    550590
    551591    for (unsigned k = 0; k < length && !exec->hadException(); ++k) {
     
    562602        eachArguments.append(thisObj);
    563603
    564         JSValue* result = eachFunction->callAsFunction(exec, applyThis, eachArguments);
     604        JSValue* result = call(exec, function, callType, callData, applyThis, eachArguments);
    565605        resultArray->put(exec, k, result);
    566606    }
     
    574614// http://developer-test.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:some
    575615
    576 JSValue* arrayProtoFuncEvery(ExecState* exec, JSObject* thisObj, const ArgList& args)
    577 {
    578     JSObject* eachFunction = args[0]->toObject(exec);
    579 
    580     if (!eachFunction->implementsCall())
     616JSValue* arrayProtoFuncEvery(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     617{
     618    JSObject* thisObj = thisValue->toThisObject(exec);
     619
     620    JSValue* function = args[0];
     621    CallData callData;
     622    CallType callType = function->getCallData(callData);
     623    if (callType == CallTypeNone)
    581624        return throwError(exec, TypeError);
    582625
    583     JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() :  args[1]->toObject(exec);
     626    JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() : args[1]->toObject(exec);
    584627
    585628    JSValue* result = jsBoolean(true);
     
    598641        eachArguments.append(thisObj);
    599642
    600         bool predicateResult = eachFunction->callAsFunction(exec, applyThis, eachArguments)->toBoolean(exec);
     643        bool predicateResult = call(exec, function, callType, callData, applyThis, eachArguments)->toBoolean(exec);
    601644
    602645        if (!predicateResult) {
     
    609652}
    610653
    611 JSValue* arrayProtoFuncForEach(ExecState* exec, JSObject* thisObj, const ArgList& args)
    612 {
    613     JSObject* eachFunction = args[0]->toObject(exec);
    614 
    615     if (!eachFunction->implementsCall())
     654JSValue* arrayProtoFuncForEach(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     655{
     656    JSObject* thisObj = thisValue->toThisObject(exec);
     657
     658    JSValue* function = args[0];
     659    CallData callData;
     660    CallType callType = function->getCallData(callData);
     661    if (callType == CallTypeNone)
    616662        return throwError(exec, TypeError);
    617663
    618     JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() :  args[1]->toObject(exec);
     664    JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() : args[1]->toObject(exec);
    619665
    620666    unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
     
    629675        eachArguments.append(thisObj);
    630676
    631         eachFunction->callAsFunction(exec, applyThis, eachArguments);
     677        call(exec, function, callType, callData, applyThis, eachArguments);
    632678    }
    633679    return jsUndefined();
    634680}
    635681
    636 JSValue* arrayProtoFuncSome(ExecState* exec, JSObject* thisObj, const ArgList& args)
    637 {
    638     JSObject* eachFunction = args[0]->toObject(exec);
    639 
    640     if (!eachFunction->implementsCall())
     682JSValue* arrayProtoFuncSome(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     683{
     684    JSObject* thisObj = thisValue->toThisObject(exec);
     685
     686    JSValue* function = args[0];
     687    CallData callData;
     688    CallType callType = function->getCallData(callData);
     689    if (callType == CallTypeNone)
    641690        return throwError(exec, TypeError);
    642691
    643     JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() :  args[1]->toObject(exec);
     692    JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->globalThisValue() : args[1]->toObject(exec);
    644693
    645694    JSValue* result = jsBoolean(false);
     
    656705        eachArguments.append(thisObj);
    657706
    658         bool predicateResult = eachFunction->callAsFunction(exec, applyThis, eachArguments)->toBoolean(exec);
     707        bool predicateResult = call(exec, function, callType, callData, applyThis, eachArguments)->toBoolean(exec);
    659708
    660709        if (predicateResult) {
     
    666715}
    667716
    668 JSValue* arrayProtoFuncIndexOf(ExecState* exec, JSObject* thisObj, const ArgList& args)
     717JSValue* arrayProtoFuncIndexOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
    669718{
    670719    // JavaScript 1.5 Extension by Mozilla
    671720    // Documentation: http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:indexOf
     721
     722    JSObject* thisObj = thisValue->toThisObject(exec);
    672723
    673724    unsigned index = 0;
     
    695746}
    696747
    697 JSValue* arrayProtoFuncLastIndexOf(ExecState* exec, JSObject* thisObj, const ArgList& args)
     748JSValue* arrayProtoFuncLastIndexOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
    698749{
    699750    // JavaScript 1.6 Extension by Mozilla
    700751    // Documentation: http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:lastIndexOf
     752
     753    JSObject* thisObj = thisValue->toThisObject(exec);
    701754
    702755    unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
     
    733786
    734787    // no. of arguments for constructor
    735     putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly|DontDelete|DontEnum);
    736 }
    737 
    738 ConstructType ArrayConstructor::getConstructData(ConstructData&)
    739 {
    740     return ConstructTypeNative;
    741 }
    742 
    743 // ECMA 15.4.2
    744 JSObject* ArrayConstructor::construct(ExecState* exec, const ArgList& args)
     788    putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontEnum | DontDelete);
     789}
     790
     791static JSObject* constructArrayWithSizeQuirk(ExecState* exec, const ArgList& args)
    745792{
    746793    // a single numeric argument denotes the array size (!)
     
    756803}
    757804
     805static JSObject* constructWithArrayConstructor(ExecState* exec, JSObject*, const ArgList& args)
     806{
     807    return constructArrayWithSizeQuirk(exec, args);
     808}
     809
     810// ECMA 15.4.2
     811ConstructType ArrayConstructor::getConstructData(ConstructData& constructData)
     812{
     813    constructData.native.function = constructWithArrayConstructor;
     814    return ConstructTypeNative;
     815}
     816
     817static JSValue* callArrayConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
     818{
     819    return constructArrayWithSizeQuirk(exec, args);
     820}
     821
    758822// ECMA 15.6.1
    759 JSValue* ArrayConstructor::callAsFunction(ExecState* exec, JSObject*, const ArgList& args)
     823CallType ArrayConstructor::getCallData(CallData& callData)
    760824{
    761825    // equivalent to 'new Array(....)'
    762     return construct(exec, args);
    763 }
    764 
    765 }
     826    callData.native.function = callArrayConstructor;
     827    return CallTypeNative;
     828}
     829
     830}
  • trunk/JavaScriptCore/kjs/ArrayPrototype.h

    r34587 r34754  
    4040  public:
    4141    ArrayConstructor(ExecState*, FunctionPrototype*, ArrayPrototype*);
    42 
    4342    virtual ConstructType getConstructData(ConstructData&);
    44     virtual JSObject* construct(ExecState*, const ArgList&);
    45 
    46     virtual JSValue* callAsFunction(ExecState*, JSObject*, const ArgList&);
    47 
     43    virtual CallType getCallData(CallData&);
    4844  };
    49 
    50   JSValue* arrayProtoFuncToString(ExecState*, JSObject*, const ArgList&);
    51   JSValue* arrayProtoFuncToLocaleString(ExecState*, JSObject*, const ArgList&);
    52   JSValue* arrayProtoFuncConcat(ExecState*, JSObject*, const ArgList&);
    53   JSValue* arrayProtoFuncJoin(ExecState*, JSObject*, const ArgList&);
    54   JSValue* arrayProtoFuncPop(ExecState*, JSObject*, const ArgList&);
    55   JSValue* arrayProtoFuncPush(ExecState*, JSObject*, const ArgList&);
    56   JSValue* arrayProtoFuncReverse(ExecState*, JSObject*, const ArgList&);
    57   JSValue* arrayProtoFuncShift(ExecState*, JSObject*, const ArgList&);
    58   JSValue* arrayProtoFuncSlice(ExecState*, JSObject*, const ArgList&);
    59   JSValue* arrayProtoFuncSort(ExecState*, JSObject*, const ArgList&);
    60   JSValue* arrayProtoFuncSplice(ExecState*, JSObject*, const ArgList&);
    61   JSValue* arrayProtoFuncUnShift(ExecState*, JSObject*, const ArgList&);
    62   JSValue* arrayProtoFuncEvery(ExecState*, JSObject*, const ArgList&);
    63   JSValue* arrayProtoFuncForEach(ExecState*, JSObject*, const ArgList&);
    64   JSValue* arrayProtoFuncSome(ExecState*, JSObject*, const ArgList&);
    65   JSValue* arrayProtoFuncIndexOf(ExecState*, JSObject*, const ArgList&);
    66   JSValue* arrayProtoFuncFilter(ExecState*, JSObject*, const ArgList&);
    67   JSValue* arrayProtoFuncMap(ExecState*, JSObject*, const ArgList&);
    68   JSValue* arrayProtoFuncLastIndexOf(ExecState*, JSObject*, const ArgList&);
    6945
    7046} // namespace KJS
  • trunk/JavaScriptCore/kjs/BooleanObject.cpp

    r34659 r34754  
    4141
    4242// Functions
    43 static JSValue* booleanProtoFuncToString(ExecState*, JSObject*, const ArgList&);
    44 static JSValue* booleanProtoFuncValueOf(ExecState*, JSObject*, const ArgList&);
     43static JSValue* booleanProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
     44static JSValue* booleanProtoFuncValueOf(ExecState*, JSObject*, JSValue*, const ArgList&);
    4545
    4646// ECMA 15.6.4
     
    6060// ECMA 15.6.4.2 + 15.6.4.3
    6161
    62 JSValue* booleanProtoFuncToString(ExecState* exec, JSObject* thisObj, const ArgList&)
     62JSValue* booleanProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
    6363{
    64     if (!thisObj->inherits(&BooleanObject::info))
     64    if (JSImmediate::isBoolean(thisValue))
     65        return jsString(exec, JSImmediate::toString(thisValue));
     66
     67    if (!thisValue->isObject(&BooleanObject::info))
    6568        return throwError(exec, TypeError);
    6669
    67     JSValue* v = static_cast<BooleanObject*>(thisObj)->internalValue();
    68     ASSERT(v);
     70    return jsString(exec, JSImmediate::toString(static_cast<BooleanObject*>(thisValue)->internalValue()));
     71}
    6972
    70     return jsString(exec, v->toString(exec));
    71 }
    72 JSValue* booleanProtoFuncValueOf(ExecState* exec, JSObject* thisObj, const ArgList&)
     73JSValue* booleanProtoFuncValueOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
    7374{
    74     if (!thisObj->inherits(&BooleanObject::info))
     75    if (JSImmediate::isBoolean(thisValue))
     76        return thisValue;
     77
     78    if (!thisValue->isObject(&BooleanObject::info))
    7579        return throwError(exec, TypeError);
    7680
    77     JSValue* v = static_cast<BooleanObject*>(thisObj)->internalValue();
    78     ASSERT(v);
    79 
    80     // TODO: optimize for bool case
    81     return jsBoolean(v->toBoolean(exec));
     81    return static_cast<BooleanObject*>(thisValue)->internalValue();
    8282}
    8383
     
    9494}
    9595
    96 ConstructType BooleanConstructor::getConstructData(ConstructData&)
     96// ECMA 15.6.2
     97JSObject* constructBoolean(ExecState* exec, const ArgList& args)
    9798{
    98     return ConstructTypeNative;
    99 }
    100 
    101 // ECMA 15.6.2
    102 JSObject* BooleanConstructor::construct(ExecState* exec, const ArgList& args)
    103 {
    104     BooleanObject* obj(new (exec) BooleanObject(exec->lexicalGlobalObject()->booleanPrototype()));
     99    BooleanObject* obj = new (exec) BooleanObject(exec->lexicalGlobalObject()->booleanPrototype());
    105100    obj->setInternalValue(jsBoolean(args[0]->toBoolean(exec)));
    106101    return obj;
    107102}
    108103
     104static JSObject* constructWithBooleanConstructor(ExecState* exec, JSObject*, const ArgList& args)
     105{
     106    return constructBoolean(exec, args);
     107}
     108
     109ConstructType BooleanConstructor::getConstructData(ConstructData& constructData)
     110{
     111    constructData.native.function = constructWithBooleanConstructor;
     112    return ConstructTypeNative;
     113}
     114
    109115// ECMA 15.6.1
    110 JSValue* BooleanConstructor::callAsFunction(ExecState* exec, JSObject*, const ArgList& args)
     116static JSValue* callBooleanConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    111117{
    112     // TODO: optimize for bool case
    113118    return jsBoolean(args[0]->toBoolean(exec));
    114119}
    115120
     121CallType BooleanConstructor::getCallData(CallData& callData)
     122{
     123    callData.native.function = callBooleanConstructor;
     124    return CallTypeNative;
     125}
     126
     127JSObject* constructBooleanFromImmediateBoolean(ExecState* exec, JSValue* immediateBooleanValue)
     128{
     129    BooleanObject* obj = new (exec) BooleanObject(exec->lexicalGlobalObject()->booleanPrototype());
     130    obj->setInternalValue(immediateBooleanValue);
     131    return obj;
     132}
     133
    116134} // namespace KJS
  • trunk/JavaScriptCore/kjs/BooleanObject.h

    r34587 r34754  
    5454    public:
    5555        BooleanConstructor(ExecState*, FunctionPrototype*, BooleanPrototype*);
     56    private:
     57        virtual ConstructType getConstructData(ConstructData&);
     58        virtual CallType getCallData(CallData&);
     59    };
    5660
    57         virtual ConstructType getConstructData(ConstructData&);
    58         virtual JSObject* construct(ExecState*, const ArgList&);
    59 
    60         virtual JSValue* callAsFunction(ExecState*, JSObject*, const ArgList&);
    61     };
     61    JSObject* constructBooleanFromImmediateBoolean(ExecState*, JSValue*);
     62    JSObject* constructBoolean(ExecState*, const ArgList&);
    6263
    6364} // namespace KJS
  • trunk/JavaScriptCore/kjs/CallData.h

    r34372 r34754  
    3232namespace KJS {
    3333
     34    class ArgList;
     35    class ExecState;
    3436    class FunctionBodyNode;
     37    class JSObject;
     38    class JSValue;
    3539    class ScopeChainNode;
    3640
     
    4145    };
    4246
     47    typedef JSValue* (*NativeFunction)(ExecState*, JSObject*, JSValue* thisValue, const ArgList&);
     48
    4349    union CallData {
     50        struct {
     51            NativeFunction function;
     52        } native;
    4453        struct {
    4554            FunctionBodyNode* functionBody;
     
    4857    };
    4958
     59    JSValue* call(ExecState*, JSValue* functionObject, CallType, const CallData&, JSValue* thisValue, const ArgList&);
     60
    5061} // namespace KJS
    5162
  • trunk/JavaScriptCore/kjs/ConstructData.h

    r33979 r34754  
    3232namespace KJS {
    3333
     34    class ArgList;
     35    class ExecState;
    3436    class FunctionBodyNode;
    35     class ScopeChain;
     37    class JSObject;
     38    class JSValue;
     39    class ScopeChainNode;
    3640
    3741    enum ConstructType {
     
    4145    };
    4246
     47    typedef JSObject* (*NativeConstructor)(ExecState*, JSObject*, const ArgList&);
     48
    4349    union ConstructData {
     50        struct {
     51            NativeConstructor function;
     52        } native;
    4453        struct {
    4554            FunctionBodyNode* functionBody;
     
    4857    };
    4958
     59    JSObject* construct(ExecState*, JSValue* constructor, ConstructType, const ConstructData&, const ArgList&);
     60
    5061} // namespace KJS
    5162
  • trunk/JavaScriptCore/kjs/FunctionPrototype.cpp

    r34659 r34754  
    3939// ------------------------------ FunctionPrototype -------------------------
    4040
    41 static JSValue* functionProtoFuncToString(ExecState*, JSObject*, const ArgList&);
    42 static JSValue* functionProtoFuncApply(ExecState*, JSObject*, const ArgList&);
    43 static JSValue* functionProtoFuncCall(ExecState*, JSObject*, const ArgList&);
     41static JSValue* functionProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
     42static JSValue* functionProtoFuncApply(ExecState*, JSObject*, JSValue*, const ArgList&);
     43static JSValue* functionProtoFuncCall(ExecState*, JSObject*, JSValue*, const ArgList&);
    4444
    4545FunctionPrototype::FunctionPrototype(ExecState* exec)
     
    5252}
    5353
     54static JSValue* callFunctionPrototype(ExecState*, JSObject*, JSValue*, const ArgList&)
     55{
     56    return jsUndefined();
     57}
     58
    5459// ECMA 15.3.4
    55 JSValue* FunctionPrototype::callAsFunction(ExecState*, JSObject*, const ArgList&)
    56 {
    57     return jsUndefined();
     60CallType FunctionPrototype::getCallData(CallData& callData)
     61{
     62    callData.native.function = callFunctionPrototype;
     63    return CallTypeNative;
    5864}
    5965
    6066// Functions
    6167
    62 JSValue* functionProtoFuncToString(ExecState* exec, JSObject* thisObj, const ArgList&)
    63 {
    64     if (!thisObj || !thisObj->inherits(&InternalFunction::info)) {
    65 #ifndef NDEBUG
    66         fprintf(stderr,"attempted toString() call on null or non-function object\n");
    67 #endif
     68JSValue* functionProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     69{
     70    if (!thisValue->isObject(&InternalFunction::info))
    6871        return throwError(exec, TypeError);
    69     }
    70 
    71     if (thisObj->inherits(&JSFunction::info)) {
    72         JSFunction* fi = static_cast<JSFunction*>(thisObj);
     72
     73    InternalFunction* function = static_cast<InternalFunction*>(thisValue);
     74
     75    if (function->inherits(&JSFunction::info)) {
     76        JSFunction* fi = static_cast<JSFunction*>(thisValue);
    7377        return jsString(exec, "function " + fi->functionName().ustring() + "(" + fi->body->paramString() + ") " + fi->body->toSourceString());
    7478    }
    7579
    76     return jsString(exec, "function " + static_cast<InternalFunction*>(thisObj)->functionName().ustring() + "() {\n    [native code]\n}");
    77 }
    78 
    79 JSValue* functionProtoFuncApply(ExecState* exec, JSObject* thisObj, const ArgList& args)
    80 {
    81     if (!thisObj->implementsCall())
     80    return jsString(exec, "function " + function->functionName().ustring() + "() {\n    [native code]\n}");
     81}
     82
     83JSValue* functionProtoFuncApply(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     84{
     85    CallData callData;
     86    CallType callType = thisValue->getCallData(callData);
     87    if (callType == CallTypeNone)
    8288        return throwError(exec, TypeError);
    8389
     
    8591    JSValue* argArray = args[1];
    8692
    87     JSObject* applyThis;
     93    JSValue* applyThis;
    8894    if (thisArg->isUndefinedOrNull())
    8995        applyThis = exec->globalThisValue();
     
    105111    }
    106112
    107     return thisObj->callAsFunction(exec, applyThis, applyArgs);
    108 }
    109 
    110 JSValue* functionProtoFuncCall(ExecState* exec, JSObject* thisObj, const ArgList& args)
    111 {
    112     if (!thisObj->implementsCall())
     113    return call(exec, thisValue, callType, callData, applyThis, applyArgs);
     114}
     115
     116JSValue* functionProtoFuncCall(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     117{
     118    CallData callData;
     119    CallType callType = thisValue->getCallData(callData);
     120    if (callType == CallTypeNone)
    113121        return throwError(exec, TypeError);
    114122
     
    123131    ArgList argsTail;
    124132    args.getSlice(1, argsTail);
    125     return thisObj->callAsFunction(exec, callThis, argsTail);
     133    return call(exec, thisValue, callType, callData, callThis, argsTail);
    126134}
    127135
     
    137145}
    138146
    139 ConstructType FunctionConstructor::getConstructData(ConstructData&)
    140 {
     147static JSObject* constructWithFunctionConstructor(ExecState* exec, JSObject*, const ArgList& args)
     148{
     149    return constructFunction(exec, args);
     150}
     151
     152ConstructType FunctionConstructor::getConstructData(ConstructData& constructData)
     153{
     154    constructData.native.function = constructWithFunctionConstructor;
    141155    return ConstructTypeNative;
    142156}
    143157
     158static JSValue* callFunctionConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
     159{
     160    return constructFunction(exec, args);
     161}
     162
     163// ECMA 15.3.1 The Function Constructor Called as a Function
     164CallType FunctionConstructor::getCallData(CallData& callData)
     165{
     166    callData.native.function = callFunctionConstructor;
     167    return CallTypeNative;
     168}
     169
    144170// ECMA 15.3.2 The Function Constructor
    145 JSObject* FunctionConstructor::construct(ExecState* exec, const ArgList& args, const Identifier& functionName, const UString& sourceURL, int lineNumber)
     171JSObject* constructFunction(ExecState* exec, const ArgList& args, const Identifier& functionName, const UString& sourceURL, int lineNumber)
    146172{
    147173    UString p("");
     
    175201    ScopeChain scopeChain(exec->lexicalGlobalObject(), exec->globalThisValue());
    176202
    177     JSFunction* fimp = new (exec) JSFunction(exec, functionName, functionBody.get(), scopeChain.node());
     203    JSFunction* function = new (exec) JSFunction(exec, functionName, functionBody.get(), scopeChain.node());
    178204
    179205    // parse parameter list. throw syntax error on illegal identifiers
     
    208234    }
    209235 
    210     JSObject* objCons = exec->lexicalGlobalObject()->objectConstructor();
    211     JSObject* prototype = objCons->construct(exec, exec->emptyList());
    212     prototype->putDirect(exec->propertyNames().constructor, fimp, DontEnum);
    213     fimp->putDirect(exec->propertyNames().prototype, prototype, DontDelete);
    214     return fimp;
     236    JSObject* prototype = constructEmptyObject(exec);
     237    prototype->putDirect(exec->propertyNames().constructor, function, DontEnum);
     238    function->putDirect(exec->propertyNames().prototype, prototype, DontDelete);
     239    return function;
    215240}
    216241
    217242// ECMA 15.3.2 The Function Constructor
    218 JSObject* FunctionConstructor::construct(ExecState* exec, const ArgList& args)
    219 {
    220     return construct(exec, args, Identifier(exec, "anonymous"), UString(), 1);
    221 }
    222 
    223 // ECMA 15.3.1 The Function Constructor Called as a Function
    224 JSValue* FunctionConstructor::callAsFunction(ExecState* exec, JSObject*, const ArgList& args)
    225 {
    226     return construct(exec, args);
     243JSObject* constructFunction(ExecState* exec, const ArgList& args)
     244{
     245    return constructFunction(exec, args, Identifier(exec, "anonymous"), UString(), 1);
    227246}
    228247
  • trunk/JavaScriptCore/kjs/FunctionPrototype.h

    r34587 r34754  
    3838    public:
    3939        FunctionPrototype(ExecState*);
    40 
    41         virtual JSValue* callAsFunction(ExecState*, JSObject*, const ArgList&);
     40    private:
     41        virtual CallType getCallData(CallData&);
    4242    };
    4343
     
    5050    public:
    5151        FunctionConstructor(ExecState*, FunctionPrototype*);
     52    private:
     53        virtual ConstructType getConstructData(ConstructData&);
     54        virtual CallType getCallData(CallData&);
     55    };
    5256
    53         virtual ConstructType getConstructData(ConstructData&);
    54         virtual JSObject* construct(ExecState*, const ArgList&);
    55         virtual JSObject* construct(ExecState*, const ArgList&, const Identifier& functionName, const UString& sourceURL, int lineNumber);
    56 
    57         virtual JSValue* callAsFunction(ExecState*, JSObject*, const ArgList&);
    58     };
     57    JSObject* constructFunction(ExecState*, const ArgList&, const Identifier& functionName, const UString& sourceURL, int lineNumber);
     58    JSObject* constructFunction(ExecState*, const ArgList&);
    5959
    6060} // namespace KJS
  • trunk/JavaScriptCore/kjs/JSArray.cpp

    r34659 r34754  
    2424#include "JSArray.h"
    2525
     26#include "ArrayPrototype.h"
    2627#include "PropertyNameArray.h"
    2728#include <wtf/Assertions.h>
     
    558559    Vector<AVLTreeNodeForArrayCompare> m_nodes;
    559560    ExecState* m_exec;
    560     JSObject* m_compareFunction;
    561     JSObject* m_globalThisValue;
     561    JSValue* m_compareFunction;
     562    CallType m_compareCallType;
     563    const CallData* m_compareCallData;
     564    JSValue* m_globalThisValue;
    562565
    563566    handle get_less(handle h) { return m_nodes[h].lt & 0x7FFFFFFF; }
     
    596599        arguments.append(va);
    597600        arguments.append(vb);
    598         double compareResult = m_compareFunction->callAsFunction(m_exec, m_globalThisValue, arguments)->toNumber(m_exec);
     601        double compareResult = call(m_exec, m_compareFunction, m_compareCallType, *m_compareCallData, m_globalThisValue, arguments)->toNumber(m_exec);
    599602        return (compareResult < 0) ? -1 : 1; // Not passing equality through, because we need to store all values, even if equivalent.
    600603    }
     
    606609};
    607610
    608 void JSArray::sort(ExecState* exec, JSObject* compareFunction)
     611void JSArray::sort(ExecState* exec, JSValue* compareFunction, CallType callType, const CallData& callData)
    609612{
    610613    checkConsistency();
     
    626629    tree.abstractor().m_exec = exec;
    627630    tree.abstractor().m_compareFunction = compareFunction;
     631    tree.abstractor().m_compareCallType = callType;
     632    tree.abstractor().m_compareCallData = &callData;
    628633    tree.abstractor().m_globalThisValue = exec->globalThisValue();
    629634    tree.abstractor().m_nodes.resize(usedVectorLength + (m_storage->m_sparseValueMap ? m_storage->m_sparseValueMap->size() : 0));
     
    811816#endif
    812817
    813 }
     818JSArray* constructEmptyArray(ExecState* exec)
     819{
     820    return new (exec) JSArray(exec->lexicalGlobalObject()->arrayPrototype(), 0);
     821}
     822
     823JSArray* constructEmptyArray(ExecState* exec, unsigned initialLength)
     824{
     825    return new (exec) JSArray(exec->lexicalGlobalObject()->arrayPrototype(), initialLength);
     826}
     827
     828JSArray* constructArray(ExecState* exec, JSValue* singleItemValue)
     829{
     830    ArgList values;
     831    values.append(singleItemValue);
     832    return new (exec) JSArray(exec->lexicalGlobalObject()->arrayPrototype(), values);
     833}
     834
     835JSArray* constructArray(ExecState* exec, const ArgList& values)
     836{
     837    return new (exec) JSArray(exec->lexicalGlobalObject()->arrayPrototype(), values);
     838}
     839
     840}
  • trunk/JavaScriptCore/kjs/JSArray.h

    r34587 r34754  
    3333    JSArray(JSObject* prototype, unsigned initialLength);
    3434    JSArray(JSObject* prototype, const ArgList& initialValues);
    35     ~JSArray();
     35    virtual ~JSArray();
    3636
    3737    virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
    3838    virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
    39     virtual void put(ExecState*, const Identifier& propertyName, JSValue*);
    40     virtual void put(ExecState*, unsigned propertyName, JSValue*);
    41     virtual bool deleteProperty(ExecState *, const Identifier& propertyName);
    42     virtual bool deleteProperty(ExecState *, unsigned propertyName);
    43     virtual void getPropertyNames(ExecState*, PropertyNameArray&);
     39    virtual void put(ExecState*, unsigned propertyName, JSValue*); // FIXME: Make protected and add setItem.
    4440
    45     virtual void mark();
    46 
    47     virtual const ClassInfo* classInfo() const { return &info; }
    4841    static const ClassInfo info;
    4942
    5043    unsigned getLength() const { return m_length; }
     44    void setLength(unsigned); // OK to use on new arrays, but not if it might be a RegExpMatchArray.
    5145    JSValue* getItem(unsigned) const;
    5246
    5347    void sort(ExecState*);
    54     void sort(ExecState*, JSObject* compareFunction);
     48    void sort(ExecState*, JSValue* compareFunction, CallType, const CallData&);
    5549
    5650  protected:
     51    virtual void put(ExecState*, const Identifier& propertyName, JSValue*);
     52    virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
     53    virtual bool deleteProperty(ExecState*, unsigned propertyName);
     54    virtual void getPropertyNames(ExecState*, PropertyNameArray&);
     55    virtual void mark();
     56
    5757    void* lazyCreationData();
    5858    void setLazyCreationData(void*);
    5959
    6060  private:
     61    using JSObject::get;
     62
     63    virtual const ClassInfo* classInfo() const { return &info; }
     64
    6165    static JSValue* lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
    6266    bool inlineGetOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
    6367
    64     void setLength(unsigned);
    6568    bool increaseVectorLength(unsigned newLength);
    6669   
     
    7578  };
    7679
     80  JSArray* constructEmptyArray(ExecState*);
     81  JSArray* constructEmptyArray(ExecState*, unsigned initialLength);
     82  JSArray* constructArray(ExecState*, JSValue* singleItemValue);
     83  JSArray* constructArray(ExecState*, const ArgList& values);
     84
    7785} // namespace KJS
    7886
  • trunk/JavaScriptCore/kjs/JSFunction.cpp

    r34684 r34754  
    8181}
    8282
    83 JSValue* JSFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const ArgList& args)
     83JSValue* JSFunction::call(ExecState* exec, JSValue* thisValue, const ArgList& args)
    8484{
    8585    JSValue* exception = 0;
     
    8888    if (!current->safeForReentry()) {
    8989        stack->pushFunctionRegisterFile();
    90         JSValue* result = exec->machine()->execute(body.get(), exec, this, thisObj, args, stack, _scope.node(), &exception);
     90        JSValue* result = exec->machine()->execute(body.get(), exec, this, thisValue->toThisObject(exec), args, stack, _scope.node(), &exception);
    9191        stack->popFunctionRegisterFile();
    9292        exec->setException(exception);
    9393        return result;
    9494    } else {
    95         JSValue* result = exec->machine()->execute(body.get(), exec, this, thisObj, args, stack, _scope.node(), &exception);
     95        JSValue* result = exec->machine()->execute(body.get(), exec, this, thisValue->toThisObject(exec), args, stack, _scope.node(), &exception);
    9696        current->setSafeForReentry(true);
    9797        exec->setException(exception);
     
    159159 * function f2(x, x): getParameterName(0) --> null
    160160 */
    161 Identifier JSFunction::getParameterName(int index)
     161const Identifier& JSFunction::getParameterName(int index)
    162162{
    163163    Vector<Identifier>& parameters = body->parameters();
     
    166166        return JSGlobalData::threadInstance().propertyNames->nullIdentifier;
    167167 
    168     Identifier name = parameters[index];
     168    const Identifier& name = parameters[index];
    169169
    170170    // Are there any subsequent parameters with the same name?
     
    556556}
    557557
    558 JSValue* globalFuncEval(ExecState* exec, PrototypeReflexiveFunction* function, JSObject* thisObj, const ArgList& args)
    559 {
    560     JSGlobalObject* globalObject = thisObj->toGlobalObject(exec);
    561 
     558JSValue* globalFuncEval(ExecState* exec, JSObject* function, JSValue* thisValue, const ArgList& args)
     559{
     560    JSObject* thisObject = thisValue->toThisObject(exec);
     561    JSGlobalObject* globalObject = thisObject->toGlobalObject(exec);
    562562    if (!globalObject || globalObject->evalFunction() != function)
    563563        return throwError(exec, EvalError, "The \"this\" value passed to eval must be the global object from which eval originated");
     
    579579
    580580    JSValue* exception = 0;
    581     JSValue* value = exec->machine()->execute(evalNode.get(), exec, thisObj, &exec->dynamicGlobalObject()->registerFileStack(), globalObject->globalScopeChain().node(), &exception);
     581    JSValue* value = exec->machine()->execute(evalNode.get(), exec, thisObject, &exec->dynamicGlobalObject()->registerFileStack(), globalObject->globalScopeChain().node(), &exception);
    582582
    583583    if (exception) {
     
    589589}
    590590
    591 JSValue* globalFuncParseInt(ExecState* exec, JSObject*, const ArgList& args)
     591JSValue* globalFuncParseInt(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    592592{
    593593    return jsNumber(exec, parseInt(args[0]->toString(exec), args[1]->toInt32(exec)));
    594594}
    595595
    596 JSValue* globalFuncParseFloat(ExecState* exec, JSObject*, const ArgList& args)
     596JSValue* globalFuncParseFloat(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    597597{
    598598    return jsNumber(exec, parseFloat(args[0]->toString(exec)));
    599599}
    600600
    601 JSValue* globalFuncIsNaN(ExecState* exec, JSObject*, const ArgList& args)
     601JSValue* globalFuncIsNaN(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    602602{
    603603    return jsBoolean(isnan(args[0]->toNumber(exec)));
    604604}
    605605
    606 JSValue* globalFuncIsFinite(ExecState* exec, JSObject*, const ArgList& args)
     606JSValue* globalFuncIsFinite(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    607607{
    608608    double n = args[0]->toNumber(exec);
     
    610610}
    611611
    612 JSValue* globalFuncDecodeURI(ExecState* exec, JSObject*, const ArgList& args)
     612JSValue* globalFuncDecodeURI(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    613613{
    614614    static const char do_not_unescape_when_decoding_URI[] =
     
    618618}
    619619
    620 JSValue* globalFuncDecodeURIComponent(ExecState* exec, JSObject*, const ArgList& args)
     620JSValue* globalFuncDecodeURIComponent(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    621621{
    622622    return decode(exec, args, "", true);
    623623}
    624624
    625 JSValue* globalFuncEncodeURI(ExecState* exec, JSObject*, const ArgList& args)
     625JSValue* globalFuncEncodeURI(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    626626{
    627627    static const char do_not_escape_when_encoding_URI[] =
     
    634634}
    635635
    636 JSValue* globalFuncEncodeURIComponent(ExecState* exec, JSObject*, const ArgList& args)
     636JSValue* globalFuncEncodeURIComponent(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    637637{
    638638    static const char do_not_escape_when_encoding_URI_component[] =
     
    645645}
    646646
    647 JSValue* globalFuncEscape(ExecState* exec, JSObject*, const ArgList& args)
     647JSValue* globalFuncEscape(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    648648{
    649649    static const char do_not_escape[] =
     
    674674}
    675675
    676 JSValue* globalFuncUnescape(ExecState* exec, JSObject*, const ArgList& args)
     676JSValue* globalFuncUnescape(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    677677{
    678678    UString s = "", str = args[0]->toString(exec);
     
    700700
    701701#ifndef NDEBUG
    702 JSValue* globalFuncKJSPrint(ExecState* exec, JSObject*, const ArgList& args)
     702JSValue* globalFuncKJSPrint(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    703703{
    704704    CStringBuffer string;
     
    711711// ------------------------------ PrototypeFunction -------------------------------
    712712
    713 PrototypeFunction::PrototypeFunction(ExecState* exec, int len, const Identifier& name, JSMemberFunction function)
     713PrototypeFunction::PrototypeFunction(ExecState* exec, int len, const Identifier& name, NativeFunction function)
    714714    : InternalFunction(exec->lexicalGlobalObject()->functionPrototype(), name)
    715715    , m_function(function)
     
    719719}
    720720
    721 PrototypeFunction::PrototypeFunction(ExecState* exec, FunctionPrototype* functionPrototype, int len, const Identifier& name, JSMemberFunction function)
     721PrototypeFunction::PrototypeFunction(ExecState* exec, FunctionPrototype* functionPrototype, int len, const Identifier& name, NativeFunction function)
    722722    : InternalFunction(functionPrototype, name)
    723723    , m_function(function)
     
    727727}
    728728
    729 JSValue* PrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const ArgList& args)
    730 {
    731     return m_function(exec, thisObj, args);
     729CallType PrototypeFunction::getCallData(CallData& callData)
     730{
     731    callData.native.function = m_function;
     732    return CallTypeNative;
    732733}
    733734
    734735// ------------------------------ PrototypeReflexiveFunction -------------------------------
    735736
    736 PrototypeReflexiveFunction::PrototypeReflexiveFunction(ExecState* exec, FunctionPrototype* functionPrototype, int len, const Identifier& name, JSMemberFunction function, JSGlobalObject* cachedGlobalObject)
    737     : InternalFunction(functionPrototype, name)
    738     , m_function(function)
     737GlobalEvalFunction::GlobalEvalFunction(ExecState* exec, FunctionPrototype* functionPrototype, int len, const Identifier& name, NativeFunction function, JSGlobalObject* cachedGlobalObject)
     738    : PrototypeFunction(exec, functionPrototype, len, name, function)
    739739    , m_cachedGlobalObject(cachedGlobalObject)
    740740{
    741     ASSERT_ARG(function, function);
    742741    ASSERT_ARG(cachedGlobalObject, cachedGlobalObject);
    743     putDirect(exec->propertyNames().length, jsNumber(exec, len), DontDelete | ReadOnly | DontEnum);
    744 }
    745 
    746 JSValue* PrototypeReflexiveFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const ArgList& args)
    747 {
    748     return m_function(exec, this, thisObj, args);
    749 }
    750 
    751 void PrototypeReflexiveFunction::mark()
    752 {
    753     InternalFunction::mark();
     742}
     743
     744void GlobalEvalFunction::mark()
     745{
     746    PrototypeFunction::mark();
    754747    if (!m_cachedGlobalObject->marked())
    755748        m_cachedGlobalObject->mark();
  • trunk/JavaScriptCore/kjs/JSFunction.h

    r34587 r34754  
    4040  class InternalFunction : public JSObject {
    4141  public:
     42    static const ClassInfo info;
     43    virtual const ClassInfo* classInfo() const { return &info; }
     44    const Identifier& functionName() const { return m_name; }
     45
     46  protected:
    4247    InternalFunction();
    4348    InternalFunction(FunctionPrototype*, const Identifier&);
    4449
    45     virtual CallType getCallData(CallData&);
    46 
    47     virtual JSValue* callAsFunction(ExecState*, JSObject* thisObjec, const ArgList& args) = 0;
     50  private:
     51    virtual CallType getCallData(CallData&) = 0;
    4852    virtual bool implementsHasInstance() const;
    4953
    50     virtual const ClassInfo* classInfo() const { return &info; }
    51     static const ClassInfo info;
    52     const Identifier& functionName() const { return m_name; }
    53 
    54   private:
    5554    Identifier m_name;
    5655  };
     
    6463    virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
    6564
    66     virtual ConstructType getConstructData(ConstructData&);
    67     virtual JSObject* construct(ExecState*, const ArgList& args);
     65    JSObject* construct(ExecState*, const ArgList&);
     66    JSValue* call(ExecState*, JSValue* thisValue, const ArgList&);
    6867
    69     virtual CallType getCallData(CallData&);
    70     virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const ArgList& args);
     68    // Note: Returns a null identifier for any parameters that will never get set
     69    // due to a later parameter with the same name.
     70    const Identifier& getParameterName(int index);
    7171
    72     // Note: unlike body->paramName, this returns Identifier::null for parameters
    73     // that will never get set, due to later param having the same name
    74     Identifier getParameterName(int index);
    75 
    76     virtual const ClassInfo* classInfo() const { return &info; }
    7772    static const ClassInfo info;
    7873
     
    8580
    8681  private:
     82    virtual const ClassInfo* classInfo() const { return &info; }
     83    virtual ConstructType getConstructData(ConstructData&);
     84    virtual CallType getCallData(CallData&);
     85
    8786    ScopeChain _scope;
    8887
     
    9493  class IndexToNameMap {
    9594  public:
    96     IndexToNameMap(JSFunction*, const ArgList& args);
     95    IndexToNameMap(JSFunction*, const ArgList&);
    9796    ~IndexToNameMap();
    9897   
     
    124123  class PrototypeFunction : public InternalFunction {
    125124  public:
    126     typedef JSValue* (*JSMemberFunction)(ExecState*, JSObject* thisObj, const ArgList&);
    127 
    128     PrototypeFunction(ExecState*, int len, const Identifier&, JSMemberFunction);
    129     PrototypeFunction(ExecState*, FunctionPrototype*, int len, const Identifier&, JSMemberFunction);
    130 
    131     virtual JSValue* callAsFunction(ExecState* exec, JSObject* thisObj, const ArgList&);
     125    PrototypeFunction(ExecState*, int len, const Identifier&, NativeFunction);
     126    PrototypeFunction(ExecState*, FunctionPrototype*, int len, const Identifier&, NativeFunction);
    132127
    133128  private:
    134     const JSMemberFunction m_function;
     129    virtual CallType getCallData(CallData&);
     130
     131    const NativeFunction m_function;
    135132  };
    136133
     134    class GlobalEvalFunction : public PrototypeFunction {
     135    public:
     136        GlobalEvalFunction(ExecState*, FunctionPrototype*, int len, const Identifier&, NativeFunction, JSGlobalObject* expectedThisObject);
     137        JSGlobalObject* cachedGlobalObject() const { return m_cachedGlobalObject; }
    137138
    138   // Just like PrototypeFunction, but callbacks also get passed the JS function object.
    139   class PrototypeReflexiveFunction : public InternalFunction {
    140   public:
    141     typedef JSValue* (*JSMemberFunction)(ExecState*, PrototypeReflexiveFunction*, JSObject* thisObj, const ArgList&);
     139    private:
     140        virtual void mark();
    142141
    143     PrototypeReflexiveFunction(ExecState*, FunctionPrototype*, int len, const Identifier&, JSMemberFunction, JSGlobalObject* expectedThisObject);
    144 
    145     virtual void mark();
    146     virtual JSValue* callAsFunction(ExecState* exec, JSObject* thisObj, const ArgList&);
    147 
    148     JSGlobalObject* cachedGlobalObject() const { return m_cachedGlobalObject; }
    149 
    150   private:
    151     const JSMemberFunction m_function;
    152     JSGlobalObject* m_cachedGlobalObject;
    153   };
     142        JSGlobalObject* m_cachedGlobalObject;
     143    };
    154144
    155145    // Global Functions
    156     JSValue* globalFuncEval(ExecState*, PrototypeReflexiveFunction*, JSObject*, const ArgList&);
    157     JSValue* globalFuncParseInt(ExecState*, JSObject*, const ArgList&);
    158     JSValue* globalFuncParseFloat(ExecState*, JSObject*, const ArgList&);
    159     JSValue* globalFuncIsNaN(ExecState*, JSObject*, const ArgList&);
    160     JSValue* globalFuncIsFinite(ExecState*, JSObject*, const ArgList&);
    161     JSValue* globalFuncDecodeURI(ExecState*, JSObject*, const ArgList&);
    162     JSValue* globalFuncDecodeURIComponent(ExecState*, JSObject*, const ArgList&);
    163     JSValue* globalFuncEncodeURI(ExecState*, JSObject*, const ArgList&);
    164     JSValue* globalFuncEncodeURIComponent(ExecState*, JSObject*, const ArgList&);
    165     JSValue* globalFuncEscape(ExecState*, JSObject*, const ArgList&);
    166     JSValue* globalFuncUnescape(ExecState*, JSObject*, const ArgList&);
     146    JSValue* globalFuncEval(ExecState*, JSObject*, JSValue*, const ArgList&);
     147    JSValue* globalFuncParseInt(ExecState*, JSObject*, JSValue*, const ArgList&);
     148    JSValue* globalFuncParseFloat(ExecState*, JSObject*, JSValue*, const ArgList&);
     149    JSValue* globalFuncIsNaN(ExecState*, JSObject*, JSValue*, const ArgList&);
     150    JSValue* globalFuncIsFinite(ExecState*, JSObject*, JSValue*, const ArgList&);
     151    JSValue* globalFuncDecodeURI(ExecState*, JSObject*, JSValue*, const ArgList&);
     152    JSValue* globalFuncDecodeURIComponent(ExecState*, JSObject*, JSValue*, const ArgList&);
     153    JSValue* globalFuncEncodeURI(ExecState*, JSObject*, JSValue*, const ArgList&);
     154    JSValue* globalFuncEncodeURIComponent(ExecState*, JSObject*, JSValue*, const ArgList&);
     155    JSValue* globalFuncEscape(ExecState*, JSObject*, JSValue*, const ArgList&);
     156    JSValue* globalFuncUnescape(ExecState*, JSObject*, JSValue*, const ArgList&);
    167157#ifndef NDEBUG
    168     JSValue* globalFuncKJSPrint(ExecState*, JSObject*, const ArgList&);
     158    JSValue* globalFuncKJSPrint(ExecState*, JSObject*, JSValue*, const ArgList&);
    169159#endif
    170160
  • trunk/JavaScriptCore/kjs/JSGlobalObject.cpp

    r34673 r34754  
    213213
    214214    // Constructors
    215     d()->objectConstructor = 0;
    216     d()->functionConstructor = 0;
    217     d()->arrayConstructor = 0;
    218     d()->stringConstructor = 0;
    219     d()->booleanConstructor = 0;
    220     d()->numberConstructor = 0;
    221     d()->dateConstructor = 0;
    222215    d()->regExpConstructor = 0;
    223216    d()->errorConstructor = 0;
     
    235228
    236229    // Prototypes
     230
    237231    d()->functionPrototype = new (exec) FunctionPrototype(exec);
    238232    d()->objectPrototype = new (exec) ObjectPrototype(exec, d()->functionPrototype);
     
    255249
    256250    // Constructors
    257     d()->objectConstructor = new (exec) ObjectConstructor(exec, d()->objectPrototype, d()->functionPrototype);
    258     d()->functionConstructor = new (exec) FunctionConstructor(exec, d()->functionPrototype);
    259     d()->arrayConstructor = new (exec) ArrayConstructor(exec, d()->functionPrototype, d()->arrayPrototype);
    260     d()->stringConstructor = new (exec) StringConstructor(exec, d()->functionPrototype, d()->stringPrototype);
    261     d()->booleanConstructor = new (exec) BooleanConstructor(exec, d()->functionPrototype, d()->booleanPrototype);
    262     d()->numberConstructor = new (exec) NumberConstructor(exec, d()->functionPrototype, d()->numberPrototype);
    263     d()->dateConstructor = new (exec) DateConstructor(exec, d()->functionPrototype, d()->datePrototype);
     251
     252    JSValue* objectConstructor = new (exec) ObjectConstructor(exec, d()->objectPrototype, d()->functionPrototype);
     253    JSValue* functionConstructor = new (exec) FunctionConstructor(exec, d()->functionPrototype);
     254    JSValue* arrayConstructor = new (exec) ArrayConstructor(exec, d()->functionPrototype, d()->arrayPrototype);
     255    JSValue* stringConstructor = new (exec) StringConstructor(exec, d()->functionPrototype, d()->stringPrototype);
     256    JSValue* booleanConstructor = new (exec) BooleanConstructor(exec, d()->functionPrototype, d()->booleanPrototype);
     257    JSValue* numberConstructor = new (exec) NumberConstructor(exec, d()->functionPrototype, d()->numberPrototype);
     258    JSValue* dateConstructor = new (exec) DateConstructor(exec, d()->functionPrototype, d()->datePrototype);
     259
    264260    d()->regExpConstructor = new (exec) RegExpConstructor(exec, d()->functionPrototype, d()->regExpPrototype);
     261
    265262    d()->errorConstructor = new (exec) ErrorConstructor(exec, d()->functionPrototype, d()->errorPrototype);
    266263   
     
    272269    d()->URIErrorConstructor = new (exec) NativeErrorConstructor(exec, d()->functionPrototype, d()->URIErrorPrototype);
    273270   
    274     d()->functionPrototype->putDirect(exec->propertyNames().constructor, d()->functionConstructor, DontEnum);
    275 
    276     d()->objectPrototype->putDirect(exec->propertyNames().constructor, d()->objectConstructor, DontEnum);
    277     d()->functionPrototype->putDirect(exec->propertyNames().constructor, d()->functionConstructor, DontEnum);
    278     d()->arrayPrototype->putDirect(exec->propertyNames().constructor, d()->arrayConstructor, DontEnum);
    279     d()->booleanPrototype->putDirect(exec->propertyNames().constructor, d()->booleanConstructor, DontEnum);
    280     d()->stringPrototype->putDirect(exec->propertyNames().constructor, d()->stringConstructor, DontEnum);
    281     d()->numberPrototype->putDirect(exec->propertyNames().constructor, d()->numberConstructor, DontEnum);
    282     d()->datePrototype->putDirect(exec->propertyNames().constructor, d()->dateConstructor, DontEnum);
     271    d()->functionPrototype->putDirect(exec->propertyNames().constructor, functionConstructor, DontEnum);
     272
     273    d()->objectPrototype->putDirect(exec->propertyNames().constructor, objectConstructor, DontEnum);
     274    d()->functionPrototype->putDirect(exec->propertyNames().constructor, functionConstructor, DontEnum);
     275    d()->arrayPrototype->putDirect(exec->propertyNames().constructor, arrayConstructor, DontEnum);
     276    d()->booleanPrototype->putDirect(exec->propertyNames().constructor, booleanConstructor, DontEnum);
     277    d()->stringPrototype->putDirect(exec->propertyNames().constructor, stringConstructor, DontEnum);
     278    d()->numberPrototype->putDirect(exec->propertyNames().constructor, numberConstructor, DontEnum);
     279    d()->datePrototype->putDirect(exec->propertyNames().constructor, dateConstructor, DontEnum);
    283280    d()->regExpPrototype->putDirect(exec->propertyNames().constructor, d()->regExpConstructor, DontEnum);
    284281    d()->errorPrototype->putDirect(exec->propertyNames().constructor, d()->errorConstructor, DontEnum);
     
    294291    // FIXME: These properties could be handled by a static hash table.
    295292
    296     putDirect(Identifier(exec, "Object"), d()->objectConstructor, DontEnum);
    297     putDirect(Identifier(exec, "Function"), d()->functionConstructor, DontEnum);
    298     putDirect(Identifier(exec, "Array"), d()->arrayConstructor, DontEnum);
    299     putDirect(Identifier(exec, "Boolean"), d()->booleanConstructor, DontEnum);
    300     putDirect(Identifier(exec, "String"), d()->stringConstructor, DontEnum);
    301     putDirect(Identifier(exec, "Number"), d()->numberConstructor, DontEnum);
    302     putDirect(Identifier(exec, "Date"), d()->dateConstructor, DontEnum);
     293    putDirect(Identifier(exec, "Object"), objectConstructor, DontEnum);
     294    putDirect(Identifier(exec, "Function"), functionConstructor, DontEnum);
     295    putDirect(Identifier(exec, "Array"), arrayConstructor, DontEnum);
     296    putDirect(Identifier(exec, "Boolean"), booleanConstructor, DontEnum);
     297    putDirect(Identifier(exec, "String"), stringConstructor, DontEnum);
     298    putDirect(Identifier(exec, "Number"), numberConstructor, DontEnum);
     299    putDirect(Identifier(exec, "Date"), dateConstructor, DontEnum);
    303300    putDirect(Identifier(exec, "RegExp"), d()->regExpConstructor, DontEnum);
    304301    putDirect(Identifier(exec, "Error"), d()->errorConstructor, DontEnum);
     
    322319    // Set global functions.
    323320
    324     d()->evalFunction = new (exec) PrototypeReflexiveFunction(exec, d()->functionPrototype, 1, exec->propertyNames().eval, globalFuncEval, this);
     321    d()->evalFunction = new (exec) GlobalEvalFunction(exec, d()->functionPrototype, 1, exec->propertyNames().eval, globalFuncEval, this);
    325322    putDirectFunction(d()->evalFunction, DontEnum);
    326323    putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 2, Identifier(exec, "parseInt"), globalFuncParseInt), DontEnum);
     
    416413    markIfNeeded(d()->globalExec->exception());
    417414
    418     markIfNeeded(d()->objectConstructor);
    419     markIfNeeded(d()->functionConstructor);
    420     markIfNeeded(d()->arrayConstructor);
    421     markIfNeeded(d()->booleanConstructor);
    422     markIfNeeded(d()->stringConstructor);
    423     markIfNeeded(d()->numberConstructor);
    424     markIfNeeded(d()->dateConstructor);
    425415    markIfNeeded(d()->regExpConstructor);
    426416    markIfNeeded(d()->errorConstructor);
  • trunk/JavaScriptCore/kjs/JSGlobalObject.h

    r34659 r34754  
    3333namespace KJS {
    3434
    35     class ArrayConstructor;
    3635    class ArrayPrototype;
    37     class BooleanConstructor;
    3836    class BooleanPrototype;
    39     class DateConstructor;
    4037    class DatePrototype;
    4138    class Debugger;
     
    4441    class EvalError;
    4542    class EvalErrorPrototype;
    46     class FunctionConstructor;
    4743    class FunctionPrototype;
    48     struct HashTable;
     44    class GlobalEvalFunction;
    4945    class JSGlobalObject;
    5046    class NativeErrorConstructor;
    5147    class NativeErrorPrototype;
    52     class NumberConstructor;
    5348    class NumberPrototype;
    54     class ObjectConstructor;
    5549    class ObjectPrototype;
    5650    class ProgramCodeBlock;
    57     class PrototypeReflexiveFunction;
    5851    class RangeError;
    5952    class RangeErrorPrototype;
     
    6558    class RuntimeMethod;
    6659    class ScopeChain;
    67     class StringConstructor;
    6860    class StringPrototype;
    6961    class SyntaxErrorPrototype;
     
    7264    class UriError;
    7365    class UriErrorPrototype;
     66
    7467    struct ActivationStackNode;
     68    struct HashTable;
    7569
    7670    typedef Vector<ExecState*, 16> ExecStateStack;
     
    10599            unsigned ticksUntilNextTimeoutCheck;
    106100
    107             ObjectConstructor* objectConstructor;
    108             FunctionConstructor* functionConstructor;
    109             ArrayConstructor* arrayConstructor;
    110             BooleanConstructor* booleanConstructor;
    111             StringConstructor* stringConstructor;
    112             NumberConstructor* numberConstructor;
    113             DateConstructor* dateConstructor;
    114101            RegExpConstructor* regExpConstructor;
    115102            ErrorConstructor* errorConstructor;
     
    121108            NativeErrorConstructor* URIErrorConstructor;
    122109
    123             PrototypeReflexiveFunction* evalFunction;
     110            GlobalEvalFunction* evalFunction;
    124111
    125112            ObjectPrototype* objectPrototype;
     
    157144
    158145    protected:
    159         JSGlobalObject(JSValue* proto, JSObject* globalThisValue)
    160             : JSVariableObject(proto, new JSGlobalObjectData(this, globalThisValue))
     146        JSGlobalObject(JSValue* prototype, JSObject* globalThisValue)
     147            : JSVariableObject(prototype, new JSGlobalObjectData(this, globalThisValue))
    161148        {
    162149            init(globalThisValue);
     
    187174        // replaces the global object's associated property.
    188175
    189         ObjectConstructor* objectConstructor() const { return d()->objectConstructor; }
    190         FunctionConstructor* functionConstructor() const { return d()->functionConstructor; }
    191         ArrayConstructor* arrayConstructor() const { return d()->arrayConstructor; }
    192         BooleanConstructor* booleanConstructor() const { return d()->booleanConstructor; }
    193         StringConstructor* stringConstructor() const{ return d()->stringConstructor; }
    194         NumberConstructor* numberConstructor() const{ return d()->numberConstructor; }
    195         DateConstructor* dateConstructor() const{ return d()->dateConstructor; }
    196176        RegExpConstructor* regExpConstructor() const { return d()->regExpConstructor; }
     177
    197178        ErrorConstructor* errorConstructor() const { return d()->errorConstructor; }
    198179        NativeErrorConstructor* evalErrorConstructor() const { return d()->evalErrorConstructor; }
     
    203184        NativeErrorConstructor* URIErrorConstructor() const { return d()->URIErrorConstructor; }
    204185
    205         PrototypeReflexiveFunction* evalFunction() const { return d()->evalFunction; }
     186        GlobalEvalFunction* evalFunction() const { return d()->evalFunction; }
    206187
    207188        ObjectPrototype* objectPrototype() const { return d()->objectPrototype; }
  • trunk/JavaScriptCore/kjs/JSImmediate.cpp

    r34659 r34754  
    3030namespace KJS {
    3131
    32 JSObject *JSImmediate::toObject(const JSValue *v, ExecState *exec)
     32JSObject* JSImmediate::toObject(const JSValue *v, ExecState *exec)
    3333{
    3434    ASSERT(isImmediate(v));
    3535    if (v == jsNull())
    3636        return new (exec) JSNotAnObject(throwError(exec, TypeError, "Null value"));
    37     else if (v == jsUndefined())
     37    if (v == jsUndefined())
    3838        return new (exec) JSNotAnObject(throwError(exec, TypeError, "Undefined value"));
    39     else if (isBoolean(v)) {
    40         ArgList args;
    41         args.append(const_cast<JSValue *>(v));
    42         return exec->lexicalGlobalObject()->booleanConstructor()->construct(exec, args);
    43     } else {
    44         ASSERT(isNumber(v));
    45         ArgList args;
    46         args.append(const_cast<JSValue *>(v));
    47         return exec->lexicalGlobalObject()->numberConstructor()->construct(exec, args);
    48     }
     39    if (isBoolean(v))
     40        return constructBooleanFromImmediateBoolean(exec, const_cast<JSValue*>(v));
     41    ASSERT(isNumber(v));
     42    return constructNumberFromImmediateNumber(exec, const_cast<JSValue*>(v));
    4943}
    5044
  • trunk/JavaScriptCore/kjs/JSNotAnObject.cpp

    r34587 r34754  
    127127}
    128128
    129 JSValue* JSNotAnObject::defaultValue(ExecState* exec, JSType) const
    130 {
    131     UNUSED_PARAM(exec);
    132     ASSERT(exec->hadException() && exec->exception() == m_exception);
    133     return m_exception;
    134 }
    135 
    136 JSObject* JSNotAnObject::construct(ExecState* exec, const ArgList&)
    137 {
    138     UNUSED_PARAM(exec);
    139     ASSERT(exec->hadException() && exec->exception() == m_exception);
    140     return m_exception;
    141 }
    142 
    143 JSObject* JSNotAnObject::construct(ExecState* exec, const ArgList&, const Identifier&, const UString&, int)
    144 {
    145     UNUSED_PARAM(exec);
    146     ASSERT(exec->hadException() && exec->exception() == m_exception);
    147     return m_exception;
    148 }
    149 
    150 JSValue* JSNotAnObject::callAsFunction(ExecState* exec, JSObject*, const ArgList&)
    151 {
    152     UNUSED_PARAM(exec);
    153     ASSERT(exec->hadException() && exec->exception() == m_exception);
    154     return m_exception;
    155 }
    156 
    157129void JSNotAnObject::getPropertyNames(ExecState* exec, PropertyNameArray&)
    158130{
  • trunk/JavaScriptCore/kjs/JSNotAnObject.h

    r34587 r34754  
    4444        }
    4545
    46         // JSValue methods
     46     private:
     47       // JSValue methods
    4748        virtual JSValue* toPrimitive(ExecState*, JSType preferredType = UnspecifiedType) const;
    4849        virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*&);
     
    6566        virtual bool deleteProperty(ExecState*, unsigned propertyName);
    6667
    67         virtual JSValue* defaultValue(ExecState*, JSType hint) const;
    68 
    69         virtual JSObject* construct(ExecState*, const ArgList&);
    70         virtual JSObject* construct(ExecState*, const ArgList&, const Identifier& functionName, const UString& sourceURL, int lineNumber);
    71 
    72         virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const ArgList&);
    73 
    7468        virtual void getPropertyNames(ExecState*, PropertyNameArray&);
    7569
    76     private:
    7770        JSObject* m_exception;
    7871    };
  • trunk/JavaScriptCore/kjs/JSObject.cpp

    r34659 r34754  
    7070}
    7171
    72 const ClassInfo *JSObject::classInfo() const
    73 {
    74   return 0;
    75 }
    76 
    7772UString JSObject::className() const
    7873{
     
    9489
    9590// ECMA 8.6.2.2
    96 void JSObject::put(ExecState* exec, const Identifier &propertyName, JSValue *value)
     91void JSObject::put(ExecState* exec, const Identifier& propertyName, JSValue* value)
    9792{
    9893  ASSERT(value);
     
    10297    JSObject* proto = value->getObject();
    10398
    104     // Setting __proto__ to a non-object, non-null value is silently ignored to match Mozilla
     99    // Setting __proto__ to a non-object, non-null value is silently ignored to match Mozilla.
    105100    if (!proto && value != jsNull())
    106101      return;
     
    113108      proto = proto->prototype() ? proto->prototype()->getObject() : 0;
    114109    }
    115    
     110
    116111    setPrototype(value);
    117112    return;
     
    119114
    120115  // Check if there are any setters or getters in the prototype chain
    121   JSObject *obj = this;
    122   bool hasGettersOrSetters = false;
    123   while (true) {
    124     if (obj->_prop.hasGetterSetterProperties()) {
    125       hasGettersOrSetters = true;
     116  JSObject* obj;
     117  JSValue* prototype;
     118  for (obj = this; !obj->_prop.hasGetterSetterProperties(); obj = static_cast<JSObject*>(prototype)) {
     119    prototype = obj->_proto;
     120    if (prototype == jsNull()) {
     121      _prop.put(propertyName, value, 0, true);
     122      return;
     123    }
     124  }
     125
     126  unsigned attributes;
     127  if (_prop.get(propertyName, attributes) && attributes & ReadOnly)
     128    return;
     129
     130  for (; ; obj = static_cast<JSObject*>(prototype)) {
     131    if (JSValue* gs = obj->_prop.get(propertyName, attributes)) {
     132      if (attributes & IsGetterSetter) {
     133        JSObject* setterFunc = static_cast<GetterSetter*>(gs)->setter();       
     134        if (!setterFunc) {
     135          throwSetterError(exec);
     136          return;
     137        }
     138
     139        CallData callData;
     140        CallType callType = setterFunc->getCallData(callData);
     141        ArgList args;
     142        args.append(value);
     143        call(exec, setterFunc, callType, callData, this, args);
     144        return;
     145      }
     146
     147      // If there's an existing property on the object or one of its
     148      // prototypes it should be replaced, so break here.
    126149      break;
    127150    }
    128      
    129     if (obj->_proto == jsNull())
     151
     152    prototype = obj->_proto;
     153    if (prototype == jsNull())
    130154      break;
    131      
    132     obj = static_cast<JSObject *>(obj->_proto);
    133155  }
    134  
    135   if (hasGettersOrSetters) {
    136     unsigned attributes;
    137     if (_prop.get(propertyName, attributes) && attributes & ReadOnly)
    138         return;
    139 
    140     obj = this;
    141     while (true) {
    142       if (JSValue *gs = obj->_prop.get(propertyName, attributes)) {
    143         if (attributes & IsGetterSetter) {
    144           JSObject *setterFunc = static_cast<GetterSetter *>(gs)->getSetter();
    145        
    146           if (!setterFunc) {
    147             throwSetterError(exec);
    148             return;
    149           }
    150            
    151           ArgList args;
    152           args.append(value);
    153        
    154           setterFunc->callAsFunction(exec, this->toThisObject(exec), args);
    155           return;
    156         } else {
    157           // If there's an existing property on the object or one of its
    158           // prototype it should be replaced, so we just break here.
    159           break;
    160         }
    161       }
    162      
    163       if (!obj->_proto->isObject())
    164         break;
    165        
    166       obj = static_cast<JSObject *>(obj->_proto);
    167     }
    168   }
    169  
     156
    170157  _prop.put(propertyName, value, 0, true);
    171158}
     
    231218}
    232219
    233 static ALWAYS_INLINE JSValue *tryGetAndCallProperty(ExecState *exec, const JSObject *object, const Identifier &propertyName) {
    234   JSValue* v = object->get(exec, propertyName);
    235   if (v->isObject()) {
    236       JSObject* o = static_cast<JSObject*>(v);
    237       CallData data;
    238       CallType callType = o->getCallData(data);
    239       // spec says "not primitive type" but ...
    240       if (callType != CallTypeNone) {
    241           JSObject* thisObj = const_cast<JSObject*>(object);
    242           JSValue* def = o->callAsFunction(exec, thisObj->toThisObject(exec), exec->emptyList());
    243           JSType defType = def->type();
    244           ASSERT(defType != GetterSetterType);
    245           if (defType != ObjectType)
    246               return def;
    247     }
    248   }
    249   return NULL;
     220static ALWAYS_INLINE JSValue* callDefaultValueFunction(ExecState* exec, const JSObject* object, const Identifier& propertyName)
     221{
     222    JSValue* function = object->get(exec, propertyName);
     223    CallData callData;
     224    CallType callType = function->getCallData(callData);
     225    if (callType == CallTypeNone)
     226        return 0;
     227    JSValue* result = call(exec, function, callType, callData, const_cast<JSObject*>(object), exec->emptyList());
     228    ASSERT(result->type() != GetterSetterType);
     229    if (exec->hadException())
     230        return exec->exception();
     231    if (result->isObject())
     232        return 0;
     233    return result;
    250234}
    251235
     
    260244JSValue* JSObject::defaultValue(ExecState* exec, JSType hint) const
    261245{
    262   // We need this check to guard against the case where this object is rhs of
    263   // a binary expression where lhs threw an exception in its conversion to
    264   // primitive
    265   if (exec->hadException())
    266     return exec->exception();
    267   /* Prefer String for Date objects */
    268   if ((hint == StringType) || (hint != NumberType && _proto == exec->lexicalGlobalObject()->datePrototype())) {
    269     if (JSValue* v = tryGetAndCallProperty(exec, this, exec->propertyNames().toString))
    270       return v;
    271     if (JSValue* v = tryGetAndCallProperty(exec, this, exec->propertyNames().valueOf))
    272       return v;
    273   } else {
    274     if (JSValue* v = tryGetAndCallProperty(exec, this, exec->propertyNames().valueOf))
    275       return v;
    276     if (JSValue* v = tryGetAndCallProperty(exec, this, exec->propertyNames().toString))
    277       return v;
    278   }
    279 
    280   if (exec->hadException())
    281     return exec->exception();
    282 
    283   return throwError(exec, TypeError, "No default value");
     246    // We need this check to guard against the case where this object is rhs of
     247    // a binary expression where lhs threw an exception in its conversion to
     248    // primitive.
     249    if (exec->hadException())
     250        return exec->exception();
     251
     252    // Must call toString first for Date objects.
     253    if ((hint == StringType) || (hint != NumberType && _proto == exec->lexicalGlobalObject()->datePrototype())) {
     254        if (JSValue* value = callDefaultValueFunction(exec, this, exec->propertyNames().toString))
     255            return value;
     256        if (JSValue* value = callDefaultValueFunction(exec, this, exec->propertyNames().valueOf))
     257            return value;
     258    } else {
     259        if (JSValue* value = callDefaultValueFunction(exec, this, exec->propertyNames().valueOf))
     260            return value;
     261        if (JSValue* value = callDefaultValueFunction(exec, this, exec->propertyNames().toString))
     262            return value;
     263    }
     264
     265    ASSERT(!exec->hadException());
     266
     267    return throwError(exec, TypeError, "No default value");
    284268}
    285269
     
    335319            if (v->type() != GetterSetterType)
    336320                return jsUndefined();
    337             JSObject* funcObj = static_cast<GetterSetter*>(v)->getGetter();
     321            JSObject* funcObj = static_cast<GetterSetter*>(v)->getter();
    338322            if (!funcObj)
    339323                return jsUndefined();
     
    355339            if (v->type() != GetterSetterType)
    356340                return jsUndefined();
    357             JSObject* funcObj = static_cast<GetterSetter*>(v)->getSetter();
     341            JSObject* funcObj = static_cast<GetterSetter*>(v)->setter();
    358342            if (!funcObj)
    359343                return jsUndefined();
     
    367351}
    368352
    369 JSObject* JSObject::construct(ExecState*, const ArgList& /*args*/)
    370 {
    371   ASSERT(false);
    372   return NULL;
    373 }
    374 
    375 JSObject* JSObject::construct(ExecState* exec, const ArgList& args, const Identifier& /*functionName*/, const UString& /*sourceURL*/, int /*lineNumber*/)
    376 {
    377   return construct(exec, args);
    378 }
    379 
    380 bool JSObject::implementsCall()
    381 {
    382     CallData callData;
    383     return getCallData(callData) != CallTypeNone;
    384 }
    385 
    386 JSValue *JSObject::callAsFunction(ExecState* /*exec*/, JSObject* /*thisObj*/, const ArgList &/*args*/)
    387 {
    388   ASSERT(false);
    389   return NULL;
    390 }
    391 
    392353bool JSObject::implementsHasInstance() const
    393354{
     
    399360    JSValue* proto = get(exec, exec->propertyNames().prototype);
    400361    if (!proto->isObject()) {
    401         throwError(exec, TypeError, "intanceof called on an object with an invalid prototype property.");
     362        throwError(exec, TypeError, "instanceof called on an object with an invalid prototype property.");
    402363        return false;
    403364    }
     
    508469}
    509470
    510 void JSObject::fillGetterPropertySlot(PropertySlot& slot, JSValue **location)
    511 {
    512     GetterSetter *gs = static_cast<GetterSetter *>(*location);
    513     JSObject *getterFunc = gs->getGetter();
    514     if (getterFunc)
     471void JSObject::fillGetterPropertySlot(PropertySlot& slot, JSValue** location)
     472{
     473    if (JSObject* getterFunc = static_cast<GetterSetter*>(*location)->getter())
    515474        slot.setGetterSlot(getterFunc);
    516475    else
     
    561520  else
    562521    args.append(jsString(exec, message));
    563   JSObject *err = static_cast<JSObject *>(cons->construct(exec,args));
     522  ConstructData constructData;
     523  ConstructType constructType = cons->getConstructData(constructData);
     524  JSObject* err = construct(exec, cons, constructType, constructData, args);
    564525
    565526  if (lineno != -1)
     
    607568}
    608569
     570JSObject* constructEmptyObject(ExecState* exec)
     571{
     572    return new (exec) JSObject(exec->lexicalGlobalObject()->objectPrototype());
     573}
     574
    609575} // namespace KJS
  • trunk/JavaScriptCore/kjs/JSObject.h

    r34664 r34754  
    8585    JSType type() const { return GetterSetterType; }
    8686     
    87     GetterSetter() : getter(0), setter(0) { }
    88      
    89     virtual JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const;
    90     virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
    91     virtual bool toBoolean(ExecState *exec) const;
    92     virtual double toNumber(ExecState *exec) const;
    93     virtual UString toString(ExecState *exec) const;
    94     virtual JSObject *toObject(ExecState *exec) const;
     87    GetterSetter() : m_getter(0), m_setter(0) { }
    9588     
    9689    virtual void mark();
    9790     
    98     JSObject *getGetter() { return getter; }
    99     void setGetter(JSObject *g) { getter = g; }
    100     JSObject *getSetter() { return setter; }
    101     void setSetter(JSObject *s) { setter = s; }
     91    JSObject* getter() const { return m_getter; }
     92    void setGetter(JSObject* getter) { m_getter = getter; }
     93    JSObject* setter() const { return m_setter; }
     94    void setSetter(JSObject* setter) { m_setter = setter; }
    10295     
    10396  private:
    104     // Object operations, with the toObject operation included.
    105     virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
    106     virtual bool getOwnPropertySlot(ExecState*, unsigned index, PropertySlot&);
    107     virtual void put(ExecState*, const Identifier& propertyName, JSValue*);
    108     virtual void put(ExecState*, unsigned propertyName, JSValue*);
    109     virtual JSObject* toThisObject(ExecState*) const;
    110 
    111     JSObject *getter;
    112     JSObject *setter; 
     97    virtual JSValue* toPrimitive(ExecState*, JSType preferred) const;
     98    virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
     99    virtual bool toBoolean(ExecState*) const;
     100    virtual double toNumber(ExecState*) const;
     101    virtual UString toString(ExecState*) const;
     102    virtual JSObject* toObject(ExecState*) const;
     103
     104    JSObject* m_getter;
     105    JSObject* m_setter; 
    113106  };
    114107 
     
    168161     * @see inherits()
    169162     */
    170     virtual const ClassInfo *classInfo() const;
    171163
    172164    /**
     
    196188     * ClassInfo pointer specified in cinfo
    197189     */
    198     bool inherits(const ClassInfo *cinfo) const;
     190    bool inherits(const ClassInfo* classInfo) const { return isObject(classInfo); } // FIXME: Merge with isObject.
    199191
    200192    // internal properties (ECMA 262-3 8.6.2)
     
    231223    /**
    232224     * Retrieves the specified property from the object. If neither the object
    233      * or any other object in it's prototype chain have the property, this
     225     * or any other object in its prototype chain have the property, this
    234226     * function will return Undefined.
    235227     *
     
    277269
    278270    /**
    279      * Checks to see whether the object (or any object in it's prototype chain)
     271     * Checks to see whether the object (or any object in its prototype chain)
    280272     * has a property with the specified name.
    281273     *
     
    320312     * all Objects)
    321313     */
    322     virtual JSValue *defaultValue(ExecState *exec, JSType hint) const;
    323 
    324     /**
    325      * Creates a new object based on this object. Typically this means the
    326      * following:
    327      * 1. A new object is created
    328      * 2. The prototype of the new object is set to the value of this object's
    329      *    "prototype" property
    330      * 3. The call() method of this object is called, with the new object
    331      *    passed as the this value
    332      * 4. The new object is returned
    333      *
    334      * In some cases, Host objects may differ from these semantics, although
    335      * this is discouraged.
    336      *
    337      * If an error occurs during construction, the execution state's exception
    338      * will be set. This can be tested for with ExecState::hadException().
    339      * Under some circumstances, the exception object may also be returned.
    340      *
    341      * Note: This function should not be called if getConstructData() returns
    342      * ConstructTypeNone, in which case it will result in an assertion failure.
    343      *
    344      * @param exec The current execution state
    345      * @param args The arguments to be passed to call() once the new object has
    346      * been created
    347      * @return The newly created &amp; initialized object
    348      */
    349     /**
    350      * Implementation of the [[Construct]] internal property
    351      */
    352     virtual JSObject* construct(ExecState* exec, const ArgList& args);
    353     virtual JSObject* construct(ExecState* exec, const ArgList& args, const Identifier& functionName, const UString& sourceURL, int lineNumber);
    354 
    355     /**
    356      * Calls this object as if it is a function.
    357      *
    358      * Note: This function should not be called if implementsCall() returns
    359      * false, in which case it will result in an assertion failure.
    360      *
    361      * See ECMA 8.6.2.3
    362      *
    363      * @param exec The current execution state
    364      * @param thisObj The obj to be used as "this" within function execution.
    365      * Note that in most cases this will be different from the C++ "this"
    366      * object. For example, if the ECMAScript code "window.location->toString()"
    367      * is executed, call() will be invoked on the C++ object which implements
    368      * the toString method, with the thisObj being window.location
    369      * @param args ArgList of arguments to be passed to the function
    370      * @return The return value from the function
    371      */
    372     bool implementsCall();
    373     virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const ArgList &args);
     314    virtual JSValue* defaultValue(ExecState*, JSType hint) const;
    374315
    375316    /**
     
    447388  };
    448389
     390    JSObject* constructEmptyObject(ExecState*);
     391
    449392  /**
    450393   * Types of Native Errors available. For custom errors, GeneralError
     
    506449}
    507450
    508 inline bool JSObject::inherits(const ClassInfo *info) const
    509 {
    510     for (const ClassInfo *ci = classInfo(); ci; ci = ci->parentClass)
     451inline bool JSCell::isObject(const ClassInfo* info) const
     452{
     453    for (const ClassInfo* ci = classInfo(); ci; ci = ci->parentClass) {
    511454        if (ci == info)
    512455            return true;
     456    }
    513457    return false;
    514458}
    515459
    516 // this method is here to be after the inline declaration of JSObject::inherits
    517 inline bool JSCell::isObject(const ClassInfo *info) const
    518 {
    519     return isObject() && static_cast<const JSObject *>(this)->inherits(info);
    520 }
    521 
    522460// this method is here to be after the inline declaration of JSCell::isObject
    523 inline bool JSValue::isObject(const ClassInfo *c) const
    524 {
    525     return !JSImmediate::isImmediate(this) && asCell()->isObject(c);
     461inline bool JSValue::isObject(const ClassInfo* classInfo) const
     462{
     463    return !JSImmediate::isImmediate(this) && asCell()->isObject(classInfo);
    526464}
    527465
  • trunk/JavaScriptCore/kjs/JSValue.cpp

    r34659 r34754  
    256256}
    257257
     258bool JSCell::deleteProperty(ExecState* exec, const Identifier& identifier)
     259{
     260    return toObject(exec)->deleteProperty(exec, identifier);
     261}
     262
     263bool JSCell::deleteProperty(ExecState* exec, unsigned identifier)
     264{
     265    return toObject(exec)->deleteProperty(exec, identifier);
     266}
     267
    258268JSObject* JSCell::toThisObject(ExecState* exec) const
    259269{
     
    261271}
    262272
     273const ClassInfo* JSCell::classInfo() const
     274{
     275    return 0;
     276}
     277
    263278JSCell* jsString(ExecState* exec, const char* s)
    264279{
     
    276291}
    277292
     293JSValue* call(ExecState* exec, JSValue* functionObject, CallType callType, const CallData& callData, JSValue* thisValue, const ArgList& args)
     294{
     295    if (callType == CallTypeNative)
     296        return callData.native.function(exec, static_cast<JSObject*>(functionObject), thisValue, args);
     297    ASSERT(callType == CallTypeJS);
     298    // FIXME: This can be done more efficiently using the callData.
     299    return static_cast<JSFunction*>(functionObject)->call(exec, thisValue, args);
     300}
     301
     302JSObject* construct(ExecState* exec, JSValue* object, ConstructType constructType, const ConstructData& constructData, const ArgList& args)
     303{
     304    if (constructType == ConstructTypeNative)
     305        return constructData.native.function(exec, static_cast<JSObject*>(object), args);
     306    ASSERT(constructType == ConstructTypeJS);
     307    // FIXME: This can be done more efficiently using the constructData.
     308    return static_cast<JSFunction*>(object)->construct(exec, args);
     309}
     310
    278311} // namespace KJS
  • trunk/JavaScriptCore/kjs/JSValue.h

    r34659 r34754  
    6868    bool isString() const;
    6969    bool isObject() const;
    70     bool isObject(const ClassInfo*) const;
     70    bool isObject(const ClassInfo*) const; // FIXME: Merge with inherits.
    7171
    7272    // Extracting the value.
     
    129129    void put(ExecState*, const Identifier& propertyName, JSValue*);
    130130    void put(ExecState*, unsigned propertyName, JSValue*);
     131    bool deleteProperty(ExecState*, const Identifier& propertyName);
     132    bool deleteProperty(ExecState*, unsigned propertyName);
    131133    JSObject* toThisObject(ExecState*) const;
    132134
     
    160162    bool isString() const;
    161163    bool isObject() const;
    162     bool isObject(const ClassInfo*) const;
     164    bool isObject(const ClassInfo*) const; // FIXME: Merge with inherits.
    163165
    164166    // Extracting the value.
     
    192194
    193195    // Object operations, with the toObject operation included.
     196    virtual const ClassInfo* classInfo() const;
    194197    virtual void put(ExecState*, const Identifier& propertyName, JSValue*);
    195198    virtual void put(ExecState*, unsigned propertyName, JSValue*);
     199    virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
     200    virtual bool deleteProperty(ExecState*, unsigned propertyName);
    196201    virtual JSObject* toThisObject(ExecState*) const;
    197202
  • trunk/JavaScriptCore/kjs/MathObject.cpp

    r34659 r34754  
    2121#include "config.h"
    2222#include "MathObject.h"
    23 #include "MathObject.lut.h"
    2423
    2524#include "operations.h"
     
    3029namespace KJS {
    3130
     31static JSValue* mathProtoFuncAbs(ExecState*, JSObject*, JSValue*, const ArgList&);
     32static JSValue* mathProtoFuncACos(ExecState*, JSObject*, JSValue*, const ArgList&);
     33static JSValue* mathProtoFuncASin(ExecState*, JSObject*, JSValue*, const ArgList&);
     34static JSValue* mathProtoFuncATan(ExecState*, JSObject*, JSValue*, const ArgList&);
     35static JSValue* mathProtoFuncATan2(ExecState*, JSObject*, JSValue*, const ArgList&);
     36static JSValue* mathProtoFuncCeil(ExecState*, JSObject*, JSValue*, const ArgList&);
     37static JSValue* mathProtoFuncCos(ExecState*, JSObject*, JSValue*, const ArgList&);
     38static JSValue* mathProtoFuncExp(ExecState*, JSObject*, JSValue*, const ArgList&);
     39static JSValue* mathProtoFuncFloor(ExecState*, JSObject*, JSValue*, const ArgList&);
     40static JSValue* mathProtoFuncLog(ExecState*, JSObject*, JSValue*, const ArgList&);
     41static JSValue* mathProtoFuncMax(ExecState*, JSObject*, JSValue*, const ArgList&);
     42static JSValue* mathProtoFuncMin(ExecState*, JSObject*, JSValue*, const ArgList&);
     43static JSValue* mathProtoFuncPow(ExecState*, JSObject*, JSValue*, const ArgList&);
     44static JSValue* mathProtoFuncRandom(ExecState*, JSObject*, JSValue*, const ArgList&);
     45static JSValue* mathProtoFuncRound(ExecState*, JSObject*, JSValue*, const ArgList&);
     46static JSValue* mathProtoFuncSin(ExecState*, JSObject*, JSValue*, const ArgList&);
     47static JSValue* mathProtoFuncSqrt(ExecState*, JSObject*, JSValue*, const ArgList&);
     48static JSValue* mathProtoFuncTan(ExecState*, JSObject*, JSValue*, const ArgList&);
     49
     50}
     51
     52#include "MathObject.lut.h"
     53
     54namespace KJS {
     55
    3256// ------------------------------ MathObject --------------------------------
    3357
     
    3559
    3660/* Source for MathObject.lut.h
    37 @begin mathTable 21
     61@begin mathTable
    3862  E             MathObject::Euler           DontEnum|DontDelete|ReadOnly
    3963  LN2           MathObject::Ln2             DontEnum|DontDelete|ReadOnly
     
    104128// ------------------------------ Functions --------------------------------
    105129
    106 JSValue* mathProtoFuncAbs(ExecState* exec, JSObject*, const ArgList& args)
     130JSValue* mathProtoFuncAbs(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    107131{
    108132    double arg = args[0]->toNumber(exec);
     
    110134}
    111135
    112 JSValue* mathProtoFuncACos(ExecState* exec, JSObject*, const ArgList& args)
     136JSValue* mathProtoFuncACos(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    113137{
    114138    return jsNumber(exec, acos(args[0]->toNumber(exec)));
    115139}
    116140
    117 JSValue* mathProtoFuncASin(ExecState* exec, JSObject*, const ArgList& args)
     141JSValue* mathProtoFuncASin(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    118142{
    119143    return jsNumber(exec, asin(args[0]->toNumber(exec)));
    120144}
    121145
    122 JSValue* mathProtoFuncATan(ExecState* exec, JSObject*, const ArgList& args)
     146JSValue* mathProtoFuncATan(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    123147{
    124148    return jsNumber(exec, atan(args[0]->toNumber(exec)));
    125149}
    126150
    127 JSValue* mathProtoFuncATan2(ExecState* exec, JSObject*, const ArgList& args)
     151JSValue* mathProtoFuncATan2(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    128152{
    129153    return jsNumber(exec, atan2(args[0]->toNumber(exec), args[1]->toNumber(exec)));
    130154}
    131155
    132 JSValue* mathProtoFuncCeil(ExecState* exec, JSObject*, const ArgList& args)
     156JSValue* mathProtoFuncCeil(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    133157{
    134158    double arg = args[0]->toNumber(exec);
     
    138162}
    139163
    140 JSValue* mathProtoFuncCos(ExecState* exec, JSObject*, const ArgList& args)
     164JSValue* mathProtoFuncCos(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    141165{
    142166    return jsNumber(exec, cos(args[0]->toNumber(exec)));
    143167}
    144168
    145 JSValue* mathProtoFuncExp(ExecState* exec, JSObject*, const ArgList& args)
     169JSValue* mathProtoFuncExp(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    146170{
    147171    return jsNumber(exec, exp(args[0]->toNumber(exec)));
    148172}
    149173
    150 JSValue* mathProtoFuncFloor(ExecState* exec, JSObject*, const ArgList& args)
     174JSValue* mathProtoFuncFloor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    151175{
    152176    double arg = args[0]->toNumber(exec);
     
    156180}
    157181
    158 JSValue* mathProtoFuncLog(ExecState* exec, JSObject*, const ArgList& args)
     182JSValue* mathProtoFuncLog(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    159183{
    160184    return jsNumber(exec, log(args[0]->toNumber(exec)));
    161185}
    162186
    163 JSValue* mathProtoFuncMax(ExecState* exec, JSObject*, const ArgList& args)
     187JSValue* mathProtoFuncMax(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    164188{
    165189    unsigned argsCount = args.size();
     
    177201}
    178202
    179 JSValue* mathProtoFuncMin(ExecState* exec, JSObject*, const ArgList& args)
     203JSValue* mathProtoFuncMin(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    180204{
    181205    unsigned argsCount = args.size();
     
    193217}
    194218
    195 JSValue* mathProtoFuncPow(ExecState* exec, JSObject*, const ArgList& args)
     219JSValue* mathProtoFuncPow(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    196220{
    197221    // ECMA 15.8.2.1.13
     
    207231}
    208232
    209 JSValue* mathProtoFuncRandom(ExecState* exec, JSObject*, const ArgList&)
     233JSValue* mathProtoFuncRandom(ExecState* exec, JSObject*, JSValue*, const ArgList&)
    210234{
    211235#if !USE(MULTIPLE_THREADS)
     
    220244}
    221245
    222 JSValue* mathProtoFuncRound(ExecState* exec, JSObject*, const ArgList& args)
     246JSValue* mathProtoFuncRound(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    223247{
    224248    double arg = args[0]->toNumber(exec);
     
    228252}
    229253
    230 JSValue* mathProtoFuncSin(ExecState* exec, JSObject*, const ArgList& args)
     254JSValue* mathProtoFuncSin(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    231255{
    232256    return jsNumber(exec, sin(args[0]->toNumber(exec)));
    233257}
    234258
    235 JSValue* mathProtoFuncSqrt(ExecState* exec, JSObject*, const ArgList& args)
     259JSValue* mathProtoFuncSqrt(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    236260{
    237261    return jsNumber(exec, sqrt(args[0]->toNumber(exec)));
    238262}
    239263
    240 JSValue* mathProtoFuncTan(ExecState* exec, JSObject*, const ArgList& args)
     264JSValue* mathProtoFuncTan(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    241265{
    242266    return jsNumber(exec, tan(args[0]->toNumber(exec)));
  • trunk/JavaScriptCore/kjs/MathObject.h

    r34587 r34754  
    1 // -*- c-basic-offset: 2 -*-
    21/*
    3  *  This file is part of the KDE libraries
    42 *  Copyright (C) 1999-2000 Harri Porten ([email protected])
    53 *
     
    4139    };
    4240
    43     // Functions
    44     JSValue* mathProtoFuncAbs(ExecState*, JSObject*, const ArgList&);
    45     JSValue* mathProtoFuncACos(ExecState*, JSObject*, const ArgList&);
    46     JSValue* mathProtoFuncASin(ExecState*, JSObject*, const ArgList&);
    47     JSValue* mathProtoFuncATan(ExecState*, JSObject*, const ArgList&);
    48     JSValue* mathProtoFuncATan2(ExecState*, JSObject*, const ArgList&);
    49     JSValue* mathProtoFuncCeil(ExecState*, JSObject*, const ArgList&);
    50     JSValue* mathProtoFuncCos(ExecState*, JSObject*, const ArgList&);
    51     JSValue* mathProtoFuncExp(ExecState*, JSObject*, const ArgList&);
    52     JSValue* mathProtoFuncFloor(ExecState*, JSObject*, const ArgList&);
    53     JSValue* mathProtoFuncLog(ExecState*, JSObject*, const ArgList&);
    54     JSValue* mathProtoFuncMax(ExecState*, JSObject*, const ArgList&);
    55     JSValue* mathProtoFuncMin(ExecState*, JSObject*, const ArgList&);
    56     JSValue* mathProtoFuncPow(ExecState*, JSObject*, const ArgList&);
    57     JSValue* mathProtoFuncRandom(ExecState*, JSObject*, const ArgList&);
    58     JSValue* mathProtoFuncRound(ExecState*, JSObject*, const ArgList&);
    59     JSValue* mathProtoFuncSin(ExecState*, JSObject*, const ArgList&);
    60     JSValue* mathProtoFuncSqrt(ExecState*, JSObject*, const ArgList&);
    61     JSValue* mathProtoFuncTan(ExecState*, JSObject*, const ArgList&);
    62 
    6341} // namespace KJS
    6442
  • trunk/JavaScriptCore/kjs/NumberObject.cpp

    r34659 r34754  
    4444// ------------------------------ NumberPrototype ---------------------------
    4545
    46 static JSValue* numberProtoFuncToString(ExecState*, JSObject*, const ArgList&);
    47 static JSValue* numberProtoFuncToLocaleString(ExecState*, JSObject*, const ArgList&);
    48 static JSValue* numberProtoFuncValueOf(ExecState*, JSObject*, const ArgList&);
    49 static JSValue* numberProtoFuncToFixed(ExecState*, JSObject*, const ArgList&);
    50 static JSValue* numberProtoFuncToExponential(ExecState*, JSObject*, const ArgList&);
    51 static JSValue* numberProtoFuncToPrecision(ExecState*, JSObject*, const ArgList&);
     46static JSValue* numberProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
     47static JSValue* numberProtoFuncToLocaleString(ExecState*, JSObject*, JSValue*, const ArgList&);
     48static JSValue* numberProtoFuncValueOf(ExecState*, JSObject*, JSValue*, const ArgList&);
     49static JSValue* numberProtoFuncToFixed(ExecState*, JSObject*, JSValue*, const ArgList&);
     50static JSValue* numberProtoFuncToExponential(ExecState*, JSObject*, JSValue*, const ArgList&);
     51static JSValue* numberProtoFuncToPrecision(ExecState*, JSObject*, JSValue*, const ArgList&);
    5252
    5353// ECMA 15.7.4
     
    143143
    144144
    145 JSValue* numberProtoFuncToString(ExecState* exec, JSObject* thisObj, const ArgList& args)
    146 {
    147     if (!thisObj->inherits(&NumberObject::info))
     145JSValue* numberProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     146{
     147    if (!thisValue->isObject(&NumberObject::info))
    148148        return throwError(exec, TypeError);
    149149
    150     JSValue* v = static_cast<NumberObject*>(thisObj)->internalValue();
     150    JSValue* v = static_cast<NumberObject*>(thisValue)->internalValue();
    151151
    152152    double radixAsDouble = args[0]->toInteger(exec); // nan -> 0
     
    164164    char s[2048 + 3];
    165165    const char* lastCharInString = s + sizeof(s) - 1;
    166     double x = v->toNumber(exec);
     166    double x = v->uncheckedGetNumber();
    167167    if (isnan(x) || isinf(x))
    168168        return jsString(exec, UString::from(x));
     
    208208}
    209209
    210 JSValue* numberProtoFuncToLocaleString(ExecState* exec, JSObject* thisObj, const ArgList&)
    211 {
    212     if (!thisObj->inherits(&NumberObject::info))
     210JSValue* numberProtoFuncToLocaleString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     211{
     212    if (!thisValue->isObject(&NumberObject::info))
    213213        return throwError(exec, TypeError);
    214214
    215215    // TODO
    216     return jsString(exec, static_cast<NumberObject*>(thisObj)->internalValue()->toString(exec));
    217 }
    218 
    219 JSValue* numberProtoFuncValueOf(ExecState* exec, JSObject* thisObj, const ArgList&)
    220 {
    221     if (!thisObj->inherits(&NumberObject::info))
     216    return jsString(exec, static_cast<NumberObject*>(thisValue)->internalValue()->toString(exec));
     217}
     218
     219JSValue* numberProtoFuncValueOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     220{
     221    if (!thisValue->isObject(&NumberObject::info))
    222222        return throwError(exec, TypeError);
    223223
    224     return static_cast<NumberObject*>(thisObj)->internalValue()->toJSNumber(exec);
    225 }
    226 
    227 JSValue* numberProtoFuncToFixed(ExecState* exec, JSObject* thisObj, const ArgList& args)
    228 {
    229     if (!thisObj->inherits(&NumberObject::info))
     224    return static_cast<NumberObject*>(thisValue)->internalValue();
     225}
     226
     227JSValue* numberProtoFuncToFixed(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     228{
     229    if (!thisValue->isObject(&NumberObject::info))
    230230        return throwError(exec, TypeError);
    231231
    232     JSValue* v = static_cast<NumberObject*>(thisObj)->internalValue();
     232    JSValue* v = static_cast<NumberObject*>(thisValue)->internalValue();
    233233
    234234    JSValue* fractionDigits = args[0];
     
    238238    int f = (int)df;
    239239
    240     double x = v->toNumber(exec);
     240    double x = v->uncheckedGetNumber();
    241241    if (isnan(x))
    242242        return jsString(exec, "NaN");
     
    311311}
    312312
    313 JSValue* numberProtoFuncToExponential(ExecState* exec, JSObject* thisObj, const ArgList& args)
    314 {
    315     if (!thisObj->inherits(&NumberObject::info))
     313JSValue* numberProtoFuncToExponential(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     314{
     315    if (!thisValue->isObject(&NumberObject::info))
    316316        return throwError(exec, TypeError);
    317317
    318     JSValue* v = static_cast<NumberObject*>(thisObj)->internalValue();
    319 
    320     double x = v->toNumber(exec);
     318    double x = static_cast<NumberObject*>(thisValue)->internalValue()->uncheckedGetNumber();
    321319
    322320    if (isnan(x) || isinf(x))
     
    382380}
    383381
    384 JSValue* numberProtoFuncToPrecision(ExecState* exec, JSObject* thisObj, const ArgList& args)
    385 {
    386     if (!thisObj->inherits(&NumberObject::info))
     382JSValue* numberProtoFuncToPrecision(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     383{
     384    if (!thisValue->isObject(&NumberObject::info))
    387385        return throwError(exec, TypeError);
    388386
    389     JSValue* v = static_cast<NumberObject*>(thisObj)->internalValue();
     387    JSValue* v = static_cast<NumberObject*>(thisValue)->internalValue();
    390388
    391389    double doublePrecision = args[0]->toIntegerPreserveNaN(exec);
    392     double x = v->toNumber(exec);
     390    double x = v->uncheckedGetNumber();
    393391    if (args[0]->isUndefined() || isnan(x) || isinf(x))
    394392        return jsString(exec, v->toString(exec));
     
    454452
    455453/* Source for NumberObject.lut.h
    456 @begin numberTable 5
     454@begin numberTable
    457455  NaN                   NumberConstructor::NaNValue       DontEnum|DontDelete|ReadOnly
    458456  NEGATIVE_INFINITY     NumberConstructor::NegInfinity    DontEnum|DontDelete|ReadOnly
     
    463461*/
    464462NumberConstructor::NumberConstructor(ExecState* exec, FunctionPrototype* funcProto, NumberPrototype* numberProto)
    465     : InternalFunction(funcProto, Identifier(exec, numberProto->classInfo()->className))
     463    : InternalFunction(funcProto, Identifier(exec, numberProto->info.className))
    466464{
    467465    // Number.Prototype
     
    469467
    470468    // no. of arguments for constructor
    471     putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly|DontDelete|DontEnum);
     469    putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontEnum | DontDelete);
    472470}
    473471
     
    496494}
    497495
    498 ConstructType NumberConstructor::getConstructData(ConstructData&)
    499 {
    500     return ConstructTypeNative;
    501 }
    502 
    503496// ECMA 15.7.1
    504 JSObject* NumberConstructor::construct(ExecState* exec, const ArgList& args)
    505 {
    506     JSObject* proto = exec->lexicalGlobalObject()->numberPrototype();
    507     NumberObject* obj = new (exec) NumberObject(proto);
    508 
    509     // FIXME: Check args[0]->isUndefined() instead of args.isEmpty()?
     497static JSObject* constructWithNumberConstructor(ExecState* exec, JSObject*, const ArgList& args)
     498{
     499    NumberObject* obj = new (exec) NumberObject(exec->lexicalGlobalObject()->numberPrototype());
    510500    double n = args.isEmpty() ? 0 : args[0]->toNumber(exec);
    511501    obj->setInternalValue(jsNumber(exec, n));
     
    513503}
    514504
     505ConstructType NumberConstructor::getConstructData(ConstructData& constructData)
     506{
     507    constructData.native.function = constructWithNumberConstructor;
     508    return ConstructTypeNative;
     509}
     510
    515511// ECMA 15.7.2
    516 JSValue* NumberConstructor::callAsFunction(ExecState* exec, JSObject*, const ArgList& args)
    517 {
    518     // FIXME: Check args[0]->isUndefined() instead of args.isEmpty()?
     512static JSValue* callNumberConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
     513{
    519514    return jsNumber(exec, args.isEmpty() ? 0 : args[0]->toNumber(exec));
    520515}
    521516
     517CallType NumberConstructor::getCallData(CallData& callData)
     518{
     519    callData.native.function = callNumberConstructor;
     520    return CallTypeNative;
     521}
     522
     523NumberObject* constructNumber(ExecState* exec, JSNumberCell* number)
     524{
     525    NumberObject* obj = new (exec) NumberObject(exec->lexicalGlobalObject()->numberPrototype());
     526    obj->setInternalValue(number);
     527    return obj;
     528}
     529
     530NumberObject* constructNumberFromImmediateNumber(ExecState* exec, JSValue* value)
     531{
     532    NumberObject* obj = new (exec) NumberObject(exec->lexicalGlobalObject()->numberPrototype());
     533    obj->setInternalValue(value);
     534    return obj;
     535}
     536
    522537} // namespace KJS
  • trunk/JavaScriptCore/kjs/NumberObject.h

    r34587 r34754  
    2828namespace KJS {
    2929
     30    class JSNumberCell;
     31
    3032    class NumberObject : public JSWrapperObject {
    3133    public:
    3234        NumberObject(JSObject* prototype);
     35        static const ClassInfo info;
    3336
     37    private:
    3438        virtual const ClassInfo* classInfo() const { return &info; }
    35         static const ClassInfo info;
    3639    };
     40
     41    NumberObject* constructNumber(ExecState*, JSNumberCell*);
     42    NumberObject* constructNumberFromImmediateNumber(ExecState*, JSValue*);
    3743
    3844    /**
     
    5662        NumberConstructor(ExecState*, FunctionPrototype*, NumberPrototype*);
    5763
    58         virtual ConstructType getConstructData(ConstructData&);
    59         virtual JSObject* construct(ExecState*, const ArgList&);
    60 
    61         virtual JSValue* callAsFunction(ExecState*, JSObject*, const ArgList&);
    62 
    6364        bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
    6465        JSValue* getValueProperty(ExecState*, int token) const;
    6566
    66         virtual const ClassInfo* classInfo() const { return &info; }
    6767        static const ClassInfo info;
    6868
    6969        enum { NaNValue, NegInfinity, PosInfinity, MaxValue, MinValue };
    7070
    71         JSObject* construct(const ArgList&);
     71    private:
     72        virtual ConstructType getConstructData(ConstructData&);
     73        virtual CallType getCallData(CallData&);
     74        virtual const ClassInfo* classInfo() const { return &info; }
    7275    };
    7376
  • trunk/JavaScriptCore/kjs/PropertySlot.cpp

    r34582 r34754  
    3737JSValue* PropertySlot::functionGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
    3838{
    39     CallData data;
    40     CallType callType = slot.m_data.getterFunc->getCallData(data);
     39    CallData callData;
     40    CallType callType = slot.m_data.getterFunc->getCallData(callData);
    4141    if (callType == CallTypeNative)
    42         return slot.m_data.getterFunc->callAsFunction(exec, static_cast<JSObject*>(slot.slotBase()), exec->emptyList());
     42        return callData.native.function(exec, slot.m_data.getterFunc, slot.slotBase(), exec->emptyList());
    4343    ASSERT(callType == CallTypeJS);
    4444    RegisterFileStack* stack = &exec->dynamicGlobalObject()->registerFileStack();
    4545    stack->pushFunctionRegisterFile();
    46     JSValue* result = slot.m_data.getterFunc->callAsFunction(exec, static_cast<JSObject*>(slot.slotBase()), exec->emptyList());
     46    // FIXME: This can be done more efficiently using the callData.
     47    JSValue* result = static_cast<JSFunction*>(slot.m_data.getterFunc)->call(exec, slot.slotBase(), exec->emptyList());
    4748    stack->popFunctionRegisterFile();
    48     return result;   
     49    return result;
    4950}
    5051
  • trunk/JavaScriptCore/kjs/RegExpObject.cpp

    r34659 r34754  
    3939// ------------------------------ RegExpPrototype ---------------------------
    4040
    41 static JSValue* regExpProtoFuncTest(ExecState*, JSObject*, const ArgList&);
    42 static JSValue* regExpProtoFuncExec(ExecState*, JSObject*, const ArgList&);
    43 static JSValue* regExpProtoFuncCompile(ExecState*, JSObject*, const ArgList&);
    44 static JSValue* regExpProtoFuncToString(ExecState*, JSObject*, const ArgList&);
     41static JSValue* regExpProtoFuncTest(ExecState*, JSObject*, JSValue*, const ArgList&);
     42static JSValue* regExpProtoFuncExec(ExecState*, JSObject*, JSValue*, const ArgList&);
     43static JSValue* regExpProtoFuncCompile(ExecState*, JSObject*, JSValue*, const ArgList&);
     44static JSValue* regExpProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
    4545
    4646// ECMA 15.10.5
     
    5959// ------------------------------ Functions ---------------------------
    6060   
    61 JSValue* regExpProtoFuncTest(ExecState* exec, JSObject* thisObj, const ArgList& args)
    62 {
    63     if (!thisObj->inherits(&RegExpObject::info))
     61JSValue* regExpProtoFuncTest(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     62{
     63    if (!thisValue->isObject(&RegExpObject::info))
    6464        return throwError(exec, TypeError);
    65 
    66     return static_cast<RegExpObject*>(thisObj)->test(exec, args);
    67 }
    68 
    69 JSValue* regExpProtoFuncExec(ExecState* exec, JSObject* thisObj, const ArgList& args)
    70 {
    71     if (!thisObj->inherits(&RegExpObject::info))
     65    return static_cast<RegExpObject*>(thisValue)->test(exec, args);
     66}
     67
     68JSValue* regExpProtoFuncExec(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     69{
     70    if (!thisValue->isObject(&RegExpObject::info))
    7271        return throwError(exec, TypeError);
    73 
    74     return static_cast<RegExpObject*>(thisObj)->exec(exec, args);
    75 }
    76 
    77 JSValue* regExpProtoFuncCompile(ExecState* exec, JSObject* thisObj, const ArgList& args)
    78 {
    79     if (!thisObj->inherits(&RegExpObject::info))
     72    return static_cast<RegExpObject*>(thisValue)->exec(exec, args);
     73}
     74
     75JSValue* regExpProtoFuncCompile(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     76{
     77    if (!thisValue->isObject(&RegExpObject::info))
    8078        return throwError(exec, TypeError);
    8179
     
    9795        return throwError(exec, SyntaxError, UString("Invalid regular expression: ").append(regExp->errorMessage()));
    9896
    99     static_cast<RegExpObject*>(thisObj)->setRegExp(regExp.release());
    100     static_cast<RegExpObject*>(thisObj)->setLastIndex(0);
     97    static_cast<RegExpObject*>(thisValue)->setRegExp(regExp.release());
     98    static_cast<RegExpObject*>(thisValue)->setLastIndex(0);
    10199    return jsUndefined();
    102100}
    103101
    104 JSValue* regExpProtoFuncToString(ExecState* exec, JSObject* thisObj, const ArgList&)
    105 {
    106     if (!thisObj->inherits(&RegExpObject::info)) {
    107         if (thisObj->inherits(&RegExpPrototype::info))
     102JSValue* regExpProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     103{
     104    if (!thisValue->isObject(&RegExpObject::info)) {
     105        if (thisValue->isObject(&RegExpPrototype::info))
    108106            return jsString(exec, "//");
    109107        return throwError(exec, TypeError);
    110108    }
    111109
    112     UString result = "/" + thisObj->get(exec, exec->propertyNames().source)->toString(exec) + "/";
    113     if (thisObj->get(exec, exec->propertyNames().global)->toBoolean(exec))
     110    UString result = "/" + static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().source)->toString(exec) + "/";
     111    if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().global)->toBoolean(exec))
    114112        result += "g";
    115     if (thisObj->get(exec, exec->propertyNames().ignoreCase)->toBoolean(exec))
     113    if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().ignoreCase)->toBoolean(exec))
    116114        result += "i";
    117     if (thisObj->get(exec, exec->propertyNames().multiline)->toBoolean(exec))
     115    if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().multiline)->toBoolean(exec))
    118116        result += "m";
    119117    return jsString(exec, result);
     
    125123
    126124/* Source for RegExpObject.lut.h
    127 @begin regExpTable 5
     125@begin regExpTable
    128126    global        RegExpObject::Global       DontDelete|ReadOnly|DontEnum
    129127    ignoreCase    RegExpObject::IgnoreCase   DontDelete|ReadOnly|DontEnum
     
    230228}
    231229
    232 CallType RegExpObject::getCallData(CallData&)
    233 {
     230static JSValue* callRegExpObject(ExecState* exec, JSObject* function, JSValue*, const ArgList& args)
     231{
     232    return static_cast<RegExpObject*>(function)->exec(exec, args);
     233}
     234
     235CallType RegExpObject::getCallData(CallData& callData)
     236{
     237    callData.native.function = callRegExpObject;
    234238    return CallTypeNative;
    235239}
    236240
    237 JSValue* RegExpObject::callAsFunction(ExecState* exec, JSObject*, const ArgList& args)
    238 {
    239     return RegExpObject::exec(exec, args);
    240 }
    241 
    242241// ------------------------------ RegExpConstructor ------------------------------
    243242
     
    245244
    246245/* Source for RegExpObject.lut.h
    247 @begin regExpConstructorTable 21
     246@begin regExpConstructorTable
    248247  input           RegExpConstructor::Input          None
    249248  $_              RegExpConstructor::Input          DontEnum
     
    317316public:
    318317    RegExpMatchesArray(ExecState*, RegExpConstructorPrivate*);
    319 
    320318    virtual ~RegExpMatchesArray();
    321319
     320private:
    322321    virtual bool getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { if (lazyCreationData()) fillArrayInstance(exec); return JSArray::getOwnPropertySlot(exec, propertyName, slot); }
    323322    virtual bool getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot) { if (lazyCreationData()) fillArrayInstance(exec); return JSArray::getOwnPropertySlot(exec, propertyName, slot); }
     
    328327    virtual void getPropertyNames(ExecState* exec, PropertyNameArray& arr) { if (lazyCreationData()) fillArrayInstance(exec); JSArray::getPropertyNames(exec, arr); }
    329328
    330 private:
    331329    void fillArrayInstance(ExecState*);
    332330};
     
    472470}
    473471 
    474 ConstructType RegExpConstructor::getConstructData(ConstructData&)
    475 {
    476     return ConstructTypeNative;
    477 }
    478 
    479472// ECMA 15.10.4
    480 JSObject *RegExpConstructor::construct(ExecState *exec, const ArgList &args)
     473static JSObject* constructRegExp(ExecState* exec, const ArgList& args)
    481474{
    482475  JSValue* arg0 = args[0];
     
    498491}
    499492
     493static JSObject* constructWithRegExpConstructor(ExecState* exec, JSObject*, const ArgList& args)
     494{
     495    return constructRegExp(exec, args);
     496}
     497
     498ConstructType RegExpConstructor::getConstructData(ConstructData& constructData)
     499{
     500    constructData.native.function = constructWithRegExpConstructor;
     501    return ConstructTypeNative;
     502}
     503
    500504// ECMA 15.10.3
    501 JSValue *RegExpConstructor::callAsFunction(ExecState *exec, JSObject * /*thisObj*/, const ArgList &args)
    502 {
    503   return construct(exec, args);
     505static JSValue* callRegExpConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
     506{
     507    return constructRegExp(exec, args);
     508}
     509
     510CallType RegExpConstructor::getCallData(CallData& callData)
     511{
     512    callData.native.function = callRegExpConstructor;
     513    return CallTypeNative;
    504514}
    505515
  • trunk/JavaScriptCore/kjs/RegExpObject.h

    r34659 r34754  
    4747        RegExp* regExp() const { return m_regExp.get(); }
    4848
    49         JSValue* test(ExecState*, const ArgList& args);
    50         JSValue* exec(ExecState*, const ArgList& args);
    51 
    52         virtual CallType getCallData(CallData&);
    53         virtual JSValue* callAsFunction(ExecState*, JSObject*, const ArgList&);
     49        JSValue* test(ExecState*, const ArgList&);
     50        JSValue* exec(ExecState*, const ArgList&);
    5451
    5552        bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
     
    6461
    6562    private:
    66         bool match(ExecState*, const ArgList& args);
     63        bool match(ExecState*, const ArgList&);
     64
     65        virtual CallType getCallData(CallData&);
    6766
    6867        RefPtr<RegExp> m_regExp;
     
    7776        RegExpConstructor(ExecState*, FunctionPrototype*, RegExpPrototype*);
    7877
    79         virtual ConstructType getConstructData(ConstructData&);
    80         virtual JSObject* construct(ExecState*, const ArgList&);
    81 
    82         virtual JSValue* callAsFunction(ExecState*, JSObject*, const ArgList&);
    83 
    8478        virtual void put(ExecState*, const Identifier&, JSValue*);
    8579        void putValueProperty(ExecState*, int token, JSValue*);
     
    8781        JSValue* getValueProperty(ExecState*, int token) const;
    8882
    89         virtual const ClassInfo* classInfo() const { return &info; }
    9083        static const ClassInfo info;
    9184
     
    9588
    9689    private:
     90        virtual ConstructType getConstructData(ConstructData&);
     91        virtual CallType getCallData(CallData&);
     92        virtual const ClassInfo* classInfo() const { return &info; }
     93
    9794        JSValue* getBackref(ExecState*, unsigned) const;
    9895        JSValue* getLastParen(ExecState*) const;
  • trunk/JavaScriptCore/kjs/Shell.cpp

    r34728 r34754  
    7373static bool fillBufferWithContentsOfFile(const UString& fileName, Vector<char>& buffer);
    7474
    75 static JSValue* functionPrint(ExecState*, JSObject*, const ArgList&);
    76 static JSValue* functionDebug(ExecState*, JSObject*, const ArgList&);
    77 static JSValue* functionGC(ExecState*, JSObject*, const ArgList&);
    78 static JSValue* functionVersion(ExecState*, JSObject*, const ArgList&);
    79 static JSValue* functionRun(ExecState*, JSObject*, const ArgList&);
    80 static JSValue* functionLoad(ExecState*, JSObject*, const ArgList&);
    81 static JSValue* functionReadline(ExecState*, JSObject*, const ArgList&);
    82 static JSValue* functionQuit(ExecState*, JSObject*, const ArgList&);
     75static JSValue* functionPrint(ExecState*, JSObject*, JSValue*, const ArgList&);
     76static JSValue* functionDebug(ExecState*, JSObject*, JSValue*, const ArgList&);
     77static JSValue* functionGC(ExecState*, JSObject*, JSValue*, const ArgList&);
     78static JSValue* functionVersion(ExecState*, JSObject*, JSValue*, const ArgList&);
     79static JSValue* functionRun(ExecState*, JSObject*, JSValue*, const ArgList&);
     80static JSValue* functionLoad(ExecState*, JSObject*, JSValue*, const ArgList&);
     81static JSValue* functionReadline(ExecState*, JSObject*, JSValue*, const ArgList&);
     82static JSValue* functionQuit(ExecState*, JSObject*, JSValue*, const ArgList&);
    8383
    8484struct Options {
     
    174174    putDirectFunction(new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 0, Identifier(globalExec(), "readline"), functionReadline));
    175175
    176     JSObject* array = arrayConstructor()->construct(globalExec(), globalExec()->emptyList());
     176    JSObject* array = constructEmptyArray(globalExec());
    177177    for (size_t i = 0; i < arguments.size(); ++i)
    178178        array->put(globalExec(), i, jsString(globalExec(), arguments[i]));
     
    182182}
    183183
    184 JSValue* functionPrint(ExecState* exec, JSObject*, const ArgList& args)
     184JSValue* functionPrint(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    185185{
    186186    for (unsigned i = 0; i < args.size(); ++i) {
     
    196196}
    197197
    198 JSValue* functionDebug(ExecState* exec, JSObject*, const ArgList& args)
     198JSValue* functionDebug(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    199199{
    200200    fprintf(stderr, "--> %s\n", args[0]->toString(exec).UTF8String().c_str());
     
    202202}
    203203
    204 JSValue* functionGC(ExecState* exec, JSObject*, const ArgList&)
     204JSValue* functionGC(ExecState* exec, JSObject*, JSValue*, const ArgList&)
    205205{
    206206    JSLock lock;
     
    209209}
    210210
    211 JSValue* functionVersion(ExecState*, JSObject*, const ArgList&)
     211JSValue* functionVersion(ExecState*, JSObject*, JSValue*, const ArgList&)
    212212{
    213213    // We need this function for compatibility with the Mozilla JS tests but for now
     
    216216}
    217217
    218 JSValue* functionRun(ExecState* exec, JSObject*, const ArgList& args)
     218JSValue* functionRun(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    219219{
    220220    StopWatch stopWatch;
     
    233233}
    234234
    235 JSValue* functionLoad(ExecState* exec, JSObject*, const ArgList& args)
     235JSValue* functionLoad(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    236236{
    237237    UString fileName = args[0]->toString(exec);
     
    246246}
    247247
    248 JSValue* functionReadline(ExecState* exec, JSObject*, const ArgList&)
     248JSValue* functionReadline(ExecState* exec, JSObject*, JSValue*, const ArgList&)
    249249{
    250250    Vector<char, 256> line;
     
    260260}
    261261
    262 JSValue* functionQuit(ExecState*, JSObject*, const ArgList&)
     262JSValue* functionQuit(ExecState*, JSObject*, JSValue*, const ArgList&)
    263263{
    264264    exit(0);
  • trunk/JavaScriptCore/kjs/date_object.cpp

    r34659 r34754  
    2222#include "config.h"
    2323#include "date_object.h"
    24 #include "date_object.lut.h"
     24
     25#include "DateMath.h"
    2526#include "JSString.h"
    26 
    27 #if HAVE(ERRNO_H)
    28 #include <errno.h>
    29 #endif
    30 
    31 #if HAVE(SYS_PARAM_H)
    32 #include <sys/param.h>
    33 #endif
    34 
    35 #if HAVE(SYS_TIME_H)
    36 #include <sys/time.h>
    37 #endif
    38 
    39 #if HAVE(SYS_TIMEB_H)
    40 #include <sys/timeb.h>
    41 #endif
    42 
     27#include "error_object.h"
     28#include "operations.h"
    4329#include <float.h>
    4430#include <limits.h>
     
    4935#include <string.h>
    5036#include <time.h>
    51 
    52 #include "error_object.h"
    53 #include "operations.h"
    54 #include "DateMath.h"
    55 
    5637#include <wtf/ASCIICType.h>
    5738#include <wtf/Assertions.h>
     
    6041#include <wtf/UnusedParam.h>
    6142
     43#if HAVE(ERRNO_H)
     44#include <errno.h>
     45#endif
     46
     47#if HAVE(SYS_PARAM_H)
     48#include <sys/param.h>
     49#endif
     50
     51#if HAVE(SYS_TIME_H)
     52#include <sys/time.h>
     53#endif
     54
     55#if HAVE(SYS_TIMEB_H)
     56#include <sys/timeb.h>
     57#endif
     58
    6259#if PLATFORM(MAC)
    63     #include <CoreFoundation/CoreFoundation.h>
     60#include <CoreFoundation/CoreFoundation.h>
    6461#endif
    6562
    6663using namespace WTF;
     64
     65namespace KJS {
     66
     67static JSValue* dateProtoFuncGetDate(ExecState*, JSObject*, JSValue*, const ArgList&);
     68static JSValue* dateProtoFuncGetDay(ExecState*, JSObject*, JSValue*, const ArgList&);
     69static JSValue* dateProtoFuncGetFullYear(ExecState*, JSObject*, JSValue*, const ArgList&);
     70static JSValue* dateProtoFuncGetHours(ExecState*, JSObject*, JSValue*, const ArgList&);
     71static JSValue* dateProtoFuncGetMilliSeconds(ExecState*, JSObject*, JSValue*, const ArgList&);
     72static JSValue* dateProtoFuncGetMinutes(ExecState*, JSObject*, JSValue*, const ArgList&);
     73static JSValue* dateProtoFuncGetMonth(ExecState*, JSObject*, JSValue*, const ArgList&);
     74static JSValue* dateProtoFuncGetSeconds(ExecState*, JSObject*, JSValue*, const ArgList&);
     75static JSValue* dateProtoFuncGetTime(ExecState*, JSObject*, JSValue*, const ArgList&);
     76static JSValue* dateProtoFuncGetTimezoneOffset(ExecState*, JSObject*, JSValue*, const ArgList&);
     77static JSValue* dateProtoFuncGetUTCDate(ExecState*, JSObject*, JSValue*, const ArgList&);
     78static JSValue* dateProtoFuncGetUTCDay(ExecState*, JSObject*, JSValue*, const ArgList&);
     79static JSValue* dateProtoFuncGetUTCFullYear(ExecState*, JSObject*, JSValue*, const ArgList&);
     80static JSValue* dateProtoFuncGetUTCHours(ExecState*, JSObject*, JSValue*, const ArgList&);
     81static JSValue* dateProtoFuncGetUTCMilliseconds(ExecState*, JSObject*, JSValue*, const ArgList&);
     82static JSValue* dateProtoFuncGetUTCMinutes(ExecState*, JSObject*, JSValue*, const ArgList&);
     83static JSValue* dateProtoFuncGetUTCMonth(ExecState*, JSObject*, JSValue*, const ArgList&);
     84static JSValue* dateProtoFuncGetUTCSeconds(ExecState*, JSObject*, JSValue*, const ArgList&);
     85static JSValue* dateProtoFuncGetYear(ExecState*, JSObject*, JSValue*, const ArgList&);
     86static JSValue* dateProtoFuncSetDate(ExecState*, JSObject*, JSValue*, const ArgList&);
     87static JSValue* dateProtoFuncSetFullYear(ExecState*, JSObject*, JSValue*, const ArgList&);
     88static JSValue* dateProtoFuncSetHours(ExecState*, JSObject*, JSValue*, const ArgList&);
     89static JSValue* dateProtoFuncSetMilliSeconds(ExecState*, JSObject*, JSValue*, const ArgList&);
     90static JSValue* dateProtoFuncSetMinutes(ExecState*, JSObject*, JSValue*, const ArgList&);
     91static JSValue* dateProtoFuncSetMonth(ExecState*, JSObject*, JSValue*, const ArgList&);
     92static JSValue* dateProtoFuncSetSeconds(ExecState*, JSObject*, JSValue*, const ArgList&);
     93static JSValue* dateProtoFuncSetTime(ExecState*, JSObject*, JSValue*, const ArgList&);
     94static JSValue* dateProtoFuncSetUTCDate(ExecState*, JSObject*, JSValue*, const ArgList&);
     95static JSValue* dateProtoFuncSetUTCFullYear(ExecState*, JSObject*, JSValue*, const ArgList&);
     96static JSValue* dateProtoFuncSetUTCHours(ExecState*, JSObject*, JSValue*, const ArgList&);
     97static JSValue* dateProtoFuncSetUTCMilliseconds(ExecState*, JSObject*, JSValue*, const ArgList&);
     98static JSValue* dateProtoFuncSetUTCMinutes(ExecState*, JSObject*, JSValue*, const ArgList&);
     99static JSValue* dateProtoFuncSetUTCMonth(ExecState*, JSObject*, JSValue*, const ArgList&);
     100static JSValue* dateProtoFuncSetUTCSeconds(ExecState*, JSObject*, JSValue*, const ArgList&);
     101static JSValue* dateProtoFuncSetYear(ExecState*, JSObject*, JSValue*, const ArgList&);
     102static JSValue* dateProtoFuncToDateString(ExecState*, JSObject*, JSValue*, const ArgList&);
     103static JSValue* dateProtoFuncToGMTString(ExecState*, JSObject*, JSValue*, const ArgList&);
     104static JSValue* dateProtoFuncToLocaleDateString(ExecState*, JSObject*, JSValue*, const ArgList&);
     105static JSValue* dateProtoFuncToLocaleString(ExecState*, JSObject*, JSValue*, const ArgList&);
     106static JSValue* dateProtoFuncToLocaleTimeString(ExecState*, JSObject*, JSValue*, const ArgList&);
     107static JSValue* dateProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
     108static JSValue* dateProtoFuncToTimeString(ExecState*, JSObject*, JSValue*, const ArgList&);
     109static JSValue* dateProtoFuncToUTCString(ExecState*, JSObject*, JSValue*, const ArgList&);
     110static JSValue* dateProtoFuncValueOf(ExecState*, JSObject*, JSValue*, const ArgList&);
     111
     112}
     113
     114#include "date_object.lut.h"
    67115
    68116namespace KJS {
     
    71119static double timeClip(double);
    72120
    73 inline int gmtoffset(const GregorianDateTime& t)
     121static inline int gmtoffset(const GregorianDateTime& t)
    74122{
    75123    return t.utcOffset;
    76124}
    77 
    78 
    79 /**
    80  * @internal
    81  *
    82  * Class to implement all methods that are properties of the
    83  * Date object
    84  */
    85 class DateFunction : public InternalFunction {
    86 public:
    87     DateFunction(ExecState *, FunctionPrototype *, int i, int len, const Identifier& );
    88 
    89     virtual JSValue *callAsFunction(ExecState *, JSObject *thisObj, const ArgList &args);
    90 
    91     enum { Parse, UTC, Now };
    92 
    93 private:
    94     int id;
    95 };
    96125
    97126struct DateInstance::Cache {
     
    117146}
    118147
    119 static UString formatLocaleDate(ExecState *exec, double time, bool includeDate, bool includeTime, const ArgList &args)
     148static UString formatLocaleDate(ExecState *exec, double time, bool includeDate, bool includeTime, const ArgList& args)
    120149{
    121150    CFDateFormatterStyle dateStyle = (includeDate ? kCFDateFormatterLongStyle : kCFDateFormatterNoStyle);
     
    302331//
    303332// Format of member function: f([years,] [months,] [days])
    304 static bool fillStructuresUsingDateArgs(ExecState *exec, const ArgList &args, int maxArgs, double *ms, GregorianDateTime *t)
     333static bool fillStructuresUsingDateArgs(ExecState *exec, const ArgList& args, int maxArgs, double *ms, GregorianDateTime *t)
    305334{
    306335    int idx = 0;
     
    369398bool DateInstance::getTime(GregorianDateTime &t, int &offset) const
    370399{
    371     double milli = internalValue()->getNumber();
     400    double milli = internalNumber();
    372401    if (isnan(milli))
    373402        return false;
     
    380409bool DateInstance::getUTCTime(GregorianDateTime &t) const
    381410{
    382     double milli = internalValue()->getNumber();
     411    double milli = internalNumber();
    383412    if (isnan(milli))
    384413        return false;
     
    390419bool DateInstance::getTime(double &milli, int &offset) const
    391420{
    392     milli = internalValue()->getNumber();
     421    milli = internalNumber();
    393422    if (isnan(milli))
    394423        return false;
     
    402431bool DateInstance::getUTCTime(double &milli) const
    403432{
    404     milli = internalValue()->getNumber();
     433    milli = internalNumber();
    405434    if (isnan(milli))
    406435        return false;
     
    420449
    421450/* Source for date_object.lut.h
    422    FIXMEL We could use templates to simplify the UTC variants.
    423 @begin dateTable 61
     451   FIXME: We could use templates to simplify the UTC variants.
     452@begin dateTable
    424453  toString              dateProtoFuncToString                DontEnum|Function       0
    425454  toUTCString           dateProtoFuncToUTCString             DontEnum|Function       0
     
    486515// TODO: MakeTime (15.9.11.1) etc. ?
    487516
     517static JSValue* dateParse(ExecState*, JSObject*, JSValue*, const ArgList&);
     518static JSValue* dateNow(ExecState*, JSObject*, JSValue*, const ArgList&);
     519static JSValue* dateUTC(ExecState*, JSObject*, JSValue*, const ArgList&);
     520
    488521DateConstructor::DateConstructor(ExecState* exec, FunctionPrototype* funcProto, DatePrototype* dateProto)
    489522  : InternalFunction(funcProto, Identifier(exec, dateProto->classInfo()->className))
    490523{
    491524  putDirect(exec->propertyNames().prototype, dateProto, DontEnum|DontDelete|ReadOnly);
    492   putDirectFunction(new (exec) DateFunction(exec, funcProto, DateFunction::Parse, 1, exec->propertyNames().parse), DontEnum);
    493   putDirectFunction(new (exec) DateFunction(exec, funcProto, DateFunction::UTC, 7, exec->propertyNames().UTC), DontEnum);
    494   putDirectFunction(new (exec) DateFunction(exec, funcProto, DateFunction::Now, 0, exec->propertyNames().now), DontEnum);
    495   putDirect(exec, exec->propertyNames().length, 7, ReadOnly|DontDelete|DontEnum);
    496 }
    497 
    498 ConstructType DateConstructor::getConstructData(ConstructData&)
    499 {
    500     return ConstructTypeNative;
     525  putDirectFunction(new (exec) PrototypeFunction(exec, funcProto, 1, exec->propertyNames().parse, dateParse), DontEnum);
     526  putDirectFunction(new (exec) PrototypeFunction(exec, funcProto, 7, exec->propertyNames().UTC, dateUTC), DontEnum);
     527  putDirectFunction(new (exec) PrototypeFunction(exec, funcProto, 0, exec->propertyNames().now, dateNow), DontEnum);
     528  putDirect(exec, exec->propertyNames().length, 7, ReadOnly | DontEnum | DontDelete);
    501529}
    502530
    503531// ECMA 15.9.3
    504 JSObject *DateConstructor::construct(ExecState *exec, const ArgList &args)
     532static JSObject* constructDate(ExecState* exec, JSObject*, const ArgList& args)
    505533{
    506534  int numArgs = args.size();
     
    512540  } else if (numArgs == 1) {
    513541    if (args[0]->isObject(&DateInstance::info))
    514       value = static_cast<DateInstance*>(args[0])->internalValue()->toNumber(exec);
     542      value = static_cast<DateInstance*>(args[0])->internalNumber();
    515543    else {
    516544      JSValue* primitive = args[0]->toPrimitive(exec);
     
    549577}
    550578
     579ConstructType DateConstructor::getConstructData(ConstructData& constructData)
     580{
     581    constructData.native.function = constructDate;
     582    return ConstructTypeNative;
     583}
     584
    551585// ECMA 15.9.2
    552 JSValue* DateConstructor::callAsFunction(ExecState* exec, JSObject * /*thisObj*/, const ArgList &/*args*/)
     586static JSValue* callDate(ExecState* exec, JSObject*, JSValue*, const ArgList&)
    553587{
    554588    time_t localTime = time(0);
     
    559593}
    560594
    561 // ------------------------------ DateFunction ----------------------------
    562 
    563 DateFunction::DateFunction(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
    564     : InternalFunction(funcProto, name), id(i)
    565 {
    566     putDirect(exec, exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum);
    567 }
    568 
    569 // ECMA 15.9.4.2 - 3
    570 JSValue *DateFunction::callAsFunction(ExecState* exec, JSObject*, const ArgList& args)
    571 {
    572   if (id == Parse)
     595CallType DateConstructor::getCallData(CallData& callData)
     596{
     597    callData.native.function = callDate;
     598    return CallTypeNative;
     599}
     600
     601static JSValue* dateParse(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
     602{
    573603    return jsNumber(exec, parseDate(args[0]->toString(exec)));
    574   else if (id == Now)
     604}
     605
     606static JSValue* dateNow(ExecState* exec, JSObject*, JSValue*, const ArgList&)
     607{
    575608    return jsNumber(exec, getCurrentUTCTime());
    576   else { // UTC
     609}
     610
     611static JSValue* dateUTC(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
     612{
    577613    int n = args.size();
    578614    if (isnan(args[0]->toNumber(exec))
    579         || isnan(args[1]->toNumber(exec))
    580         || (n >= 3 && isnan(args[2]->toNumber(exec)))
    581         || (n >= 4 && isnan(args[3]->toNumber(exec)))
    582         || (n >= 5 && isnan(args[4]->toNumber(exec)))
    583         || (n >= 6 && isnan(args[5]->toNumber(exec)))
    584         || (n >= 7 && isnan(args[6]->toNumber(exec)))) {
    585       return jsNaN(exec);
     615            || isnan(args[1]->toNumber(exec))
     616            || (n >= 3 && isnan(args[2]->toNumber(exec)))
     617            || (n >= 4 && isnan(args[3]->toNumber(exec)))
     618            || (n >= 5 && isnan(args[4]->toNumber(exec)))
     619            || (n >= 6 && isnan(args[5]->toNumber(exec)))
     620            || (n >= 7 && isnan(args[6]->toNumber(exec)))) {
     621        return jsNaN(exec);
    586622    }
    587623
     
    596632    double ms = (n >= 7) ? args[6]->toNumber(exec) : 0;
    597633    return jsNumber(exec, gregorianDateTimeToMS(t, ms, true));
    598   }
    599634}
    600635
     
    9791014// Functions
    9801015
    981 JSValue* dateProtoFuncToString(ExecState* exec, JSObject* thisObj, const ArgList&)
    982 {
    983     if (!thisObj->inherits(&DateInstance::info))
     1016JSValue* dateProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     1017{
     1018    if (!thisValue->isObject(&DateInstance::info))
    9841019        return throwError(exec, TypeError);
    9851020
    9861021    const bool utc = false;
    9871022
    988     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    989     JSValue* v = thisDateObj->internalValue();
    990     double milli = v->toNumber(exec);
     1023    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1024    double milli = thisDateObj->internalNumber();
    9911025    if (isnan(milli))
    9921026        return jsString(exec, "Invalid Date");
     
    9971031}
    9981032
    999 JSValue* dateProtoFuncToUTCString(ExecState* exec, JSObject* thisObj, const ArgList&)
    1000 {
    1001     if (!thisObj->inherits(&DateInstance::info))
     1033JSValue* dateProtoFuncToUTCString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     1034{
     1035    if (!thisValue->isObject(&DateInstance::info))
    10021036        return throwError(exec, TypeError);
    10031037
    10041038    const bool utc = true;
    10051039
    1006     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1007     JSValue* v = thisDateObj->internalValue();
    1008     double milli = v->toNumber(exec);
     1040    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1041    double milli = thisDateObj->internalNumber();
    10091042    if (isnan(milli))
    10101043        return jsString(exec, "Invalid Date");
     
    10151048}
    10161049
    1017 JSValue* dateProtoFuncToDateString(ExecState* exec, JSObject* thisObj, const ArgList&)
    1018 {
    1019     if (!thisObj->inherits(&DateInstance::info))
     1050JSValue* dateProtoFuncToDateString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     1051{
     1052    if (!thisValue->isObject(&DateInstance::info))
    10201053        return throwError(exec, TypeError);
    10211054
    10221055    const bool utc = false;
    10231056
    1024     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1025     JSValue* v = thisDateObj->internalValue();
    1026     double milli = v->toNumber(exec);
     1057    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1058    double milli = thisDateObj->internalNumber();
    10271059    if (isnan(milli))
    10281060        return jsString(exec, "Invalid Date");
     
    10331065}
    10341066
    1035 JSValue* dateProtoFuncToTimeString(ExecState* exec, JSObject* thisObj, const ArgList&)
    1036 {
    1037     if (!thisObj->inherits(&DateInstance::info))
     1067JSValue* dateProtoFuncToTimeString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     1068{
     1069    if (!thisValue->isObject(&DateInstance::info))
    10381070        return throwError(exec, TypeError);
    10391071
    10401072    const bool utc = false;
    10411073
    1042     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1043     JSValue* v = thisDateObj->internalValue();
    1044     double milli = v->toNumber(exec);
     1074    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1075    double milli = thisDateObj->internalNumber();
    10451076    if (isnan(milli))
    10461077        return jsString(exec, "Invalid Date");
     
    10511082}
    10521083
    1053 JSValue* dateProtoFuncToLocaleString(ExecState* exec, JSObject* thisObj, const ArgList& args)
    1054 {
    1055     if (!thisObj->inherits(&DateInstance::info))
    1056         return throwError(exec, TypeError);
    1057 
    1058     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1059     JSValue* v = thisDateObj->internalValue();
    1060     double milli = v->toNumber(exec);
     1084JSValue* dateProtoFuncToLocaleString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     1085{
     1086    if (!thisValue->isObject(&DateInstance::info))
     1087        return throwError(exec, TypeError);
     1088
     1089    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1090    double milli = thisDateObj->internalNumber();
    10611091    if (isnan(milli))
    10621092        return jsString(exec, "Invalid Date");
     
    10761106}
    10771107
    1078 JSValue* dateProtoFuncToLocaleDateString(ExecState* exec, JSObject* thisObj, const ArgList& args)
    1079 {
    1080     if (!thisObj->inherits(&DateInstance::info))
    1081         return throwError(exec, TypeError);
    1082 
    1083     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1084     JSValue* v = thisDateObj->internalValue();
    1085     double milli = v->toNumber(exec);
     1108JSValue* dateProtoFuncToLocaleDateString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     1109{
     1110    if (!thisValue->isObject(&DateInstance::info))
     1111        return throwError(exec, TypeError);
     1112
     1113    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1114    double milli = thisDateObj->internalNumber();
    10861115    if (isnan(milli))
    10871116        return jsString(exec, "Invalid Date");
     
    11011130}
    11021131
    1103 JSValue* dateProtoFuncToLocaleTimeString(ExecState* exec, JSObject* thisObj, const ArgList& args)
    1104 {
    1105     if (!thisObj->inherits(&DateInstance::info))
    1106         return throwError(exec, TypeError);
    1107 
    1108     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1109     JSValue* v = thisDateObj->internalValue();
    1110     double milli = v->toNumber(exec);
     1132JSValue* dateProtoFuncToLocaleTimeString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     1133{
     1134    if (!thisValue->isObject(&DateInstance::info))
     1135        return throwError(exec, TypeError);
     1136
     1137    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1138    double milli = thisDateObj->internalNumber();
    11111139    if (isnan(milli))
    11121140        return jsString(exec, "Invalid Date");
     
    11261154}
    11271155
    1128 JSValue* dateProtoFuncValueOf(ExecState* exec, JSObject* thisObj, const ArgList&)
    1129 {
    1130     if (!thisObj->inherits(&DateInstance::info))
    1131         return throwError(exec, TypeError);
    1132 
    1133     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1134     JSValue* v = thisDateObj->internalValue();
    1135     double milli = v->toNumber(exec);
     1156JSValue* dateProtoFuncValueOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     1157{
     1158    if (!thisValue->isObject(&DateInstance::info))
     1159        return throwError(exec, TypeError);
     1160
     1161    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1162    double milli = thisDateObj->internalNumber();
    11361163    if (isnan(milli))
    11371164        return jsNaN(exec);
     
    11401167}
    11411168
    1142 JSValue* dateProtoFuncGetTime(ExecState* exec, JSObject* thisObj, const ArgList&)
    1143 {
    1144     if (!thisObj->inherits(&DateInstance::info))
    1145         return throwError(exec, TypeError);
    1146 
    1147     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1148     JSValue* v = thisDateObj->internalValue();
    1149     double milli = v->toNumber(exec);
     1169JSValue* dateProtoFuncGetTime(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     1170{
     1171    if (!thisValue->isObject(&DateInstance::info))
     1172        return throwError(exec, TypeError);
     1173
     1174    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1175    double milli = thisDateObj->internalNumber();
    11501176    if (isnan(milli))
    11511177        return jsNaN(exec);
     
    11541180}
    11551181
    1156 JSValue* dateProtoFuncGetFullYear(ExecState* exec, JSObject* thisObj, const ArgList&)
    1157 {
    1158     if (!thisObj->inherits(&DateInstance::info))
     1182JSValue* dateProtoFuncGetFullYear(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     1183{
     1184    if (!thisValue->isObject(&DateInstance::info))
    11591185        return throwError(exec, TypeError);
    11601186
    11611187    const bool utc = false;
    11621188
    1163     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1164     JSValue* v = thisDateObj->internalValue();
    1165     double milli = v->toNumber(exec);
     1189    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1190    double milli = thisDateObj->internalNumber();
    11661191    if (isnan(milli))
    11671192        return jsNaN(exec);
     
    11721197}
    11731198
    1174 JSValue* dateProtoFuncGetUTCFullYear(ExecState* exec, JSObject* thisObj, const ArgList&)
    1175 {
    1176     if (!thisObj->inherits(&DateInstance::info))
     1199JSValue* dateProtoFuncGetUTCFullYear(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     1200{
     1201    if (!thisValue->isObject(&DateInstance::info))
    11771202        return throwError(exec, TypeError);
    11781203
    11791204    const bool utc = true;
    11801205
    1181     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1182     JSValue* v = thisDateObj->internalValue();
    1183     double milli = v->toNumber(exec);
     1206    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1207    double milli = thisDateObj->internalNumber();
    11841208    if (isnan(milli))
    11851209        return jsNaN(exec);
     
    11901214}
    11911215
    1192 JSValue* dateProtoFuncToGMTString(ExecState* exec, JSObject* thisObj, const ArgList&)
    1193 {
    1194     if (!thisObj->inherits(&DateInstance::info))
     1216JSValue* dateProtoFuncToGMTString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     1217{
     1218    if (!thisValue->isObject(&DateInstance::info))
    11951219        return throwError(exec, TypeError);
    11961220
    11971221    const bool utc = true;
    11981222
    1199     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1200     JSValue* v = thisDateObj->internalValue();
    1201     double milli = v->toNumber(exec);
     1223    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1224    double milli = thisDateObj->internalNumber();
    12021225    if (isnan(milli))
    12031226        return jsString(exec, "Invalid Date");
     
    12081231}
    12091232
    1210 JSValue* dateProtoFuncGetMonth(ExecState* exec, JSObject* thisObj, const ArgList&)
    1211 {
    1212     if (!thisObj->inherits(&DateInstance::info))
     1233JSValue* dateProtoFuncGetMonth(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     1234{
     1235    if (!thisValue->isObject(&DateInstance::info))
    12131236        return throwError(exec, TypeError);
    12141237
    12151238    const bool utc = false;
    12161239
    1217     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1218     JSValue* v = thisDateObj->internalValue();
    1219     double milli = v->toNumber(exec);
     1240    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1241    double milli = thisDateObj->internalNumber();
    12201242    if (isnan(milli))
    12211243        return jsNaN(exec);
     
    12261248}
    12271249
    1228 JSValue* dateProtoFuncGetUTCMonth(ExecState* exec, JSObject* thisObj, const ArgList&)
    1229 {
    1230     if (!thisObj->inherits(&DateInstance::info))
     1250JSValue* dateProtoFuncGetUTCMonth(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     1251{
     1252    if (!thisValue->isObject(&DateInstance::info))
    12311253        return throwError(exec, TypeError);
    12321254
    12331255    const bool utc = true;
    12341256
    1235     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1236     JSValue* v = thisDateObj->internalValue();
    1237     double milli = v->toNumber(exec);
     1257    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1258    double milli = thisDateObj->internalNumber();
    12381259    if (isnan(milli))
    12391260        return jsNaN(exec);
     
    12441265}
    12451266
    1246 JSValue* dateProtoFuncGetDate(ExecState* exec, JSObject* thisObj, const ArgList&)
    1247 {
    1248     if (!thisObj->inherits(&DateInstance::info))
     1267JSValue* dateProtoFuncGetDate(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     1268{
     1269    if (!thisValue->isObject(&DateInstance::info))
    12491270        return throwError(exec, TypeError);
    12501271
    12511272    const bool utc = false;
    12521273
    1253     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1254     JSValue* v = thisDateObj->internalValue();
    1255     double milli = v->toNumber(exec);
     1274    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1275    double milli = thisDateObj->internalNumber();
    12561276    if (isnan(milli))
    12571277        return jsNaN(exec);
     
    12621282}
    12631283
    1264 JSValue* dateProtoFuncGetUTCDate(ExecState* exec, JSObject* thisObj, const ArgList&)
    1265 {
    1266     if (!thisObj->inherits(&DateInstance::info))
     1284JSValue* dateProtoFuncGetUTCDate(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     1285{
     1286    if (!thisValue->isObject(&DateInstance::info))
    12671287        return throwError(exec, TypeError);
    12681288
    12691289    const bool utc = true;
    12701290
    1271     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1272     JSValue* v = thisDateObj->internalValue();
    1273     double milli = v->toNumber(exec);
     1291    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1292    double milli = thisDateObj->internalNumber();
    12741293    if (isnan(milli))
    12751294        return jsNaN(exec);
     
    12801299}
    12811300
    1282 JSValue* dateProtoFuncGetDay(ExecState* exec, JSObject* thisObj, const ArgList&)
    1283 {
    1284     if (!thisObj->inherits(&DateInstance::info))
     1301JSValue* dateProtoFuncGetDay(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     1302{
     1303    if (!thisValue->isObject(&DateInstance::info))
    12851304        return throwError(exec, TypeError);
    12861305
    12871306    const bool utc = false;
    12881307
    1289     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1290     JSValue* v = thisDateObj->internalValue();
    1291     double milli = v->toNumber(exec);
     1308    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1309    double milli = thisDateObj->internalNumber();
    12921310    if (isnan(milli))
    12931311        return jsNaN(exec);
     
    12981316}
    12991317
    1300 JSValue* dateProtoFuncGetUTCDay(ExecState* exec, JSObject* thisObj, const ArgList&)
    1301 {
    1302     if (!thisObj->inherits(&DateInstance::info))
     1318JSValue* dateProtoFuncGetUTCDay(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     1319{
     1320    if (!thisValue->isObject(&DateInstance::info))
    13031321        return throwError(exec, TypeError);
    13041322
    13051323    const bool utc = true;
    13061324
    1307     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1308     JSValue* v = thisDateObj->internalValue();
    1309     double milli = v->toNumber(exec);
     1325    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1326    double milli = thisDateObj->internalNumber();
    13101327    if (isnan(milli))
    13111328        return jsNaN(exec);
     
    13161333}
    13171334
    1318 JSValue* dateProtoFuncGetHours(ExecState* exec, JSObject* thisObj, const ArgList&)
    1319 {
    1320     if (!thisObj->inherits(&DateInstance::info))
     1335JSValue* dateProtoFuncGetHours(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     1336{
     1337    if (!thisValue->isObject(&DateInstance::info))
    13211338        return throwError(exec, TypeError);
    13221339
    13231340    const bool utc = false;
    13241341
    1325     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1326     JSValue* v = thisDateObj->internalValue();
    1327     double milli = v->toNumber(exec);
     1342    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1343    double milli = thisDateObj->internalNumber();
    13281344    if (isnan(milli))
    13291345        return jsNaN(exec);
     
    13341350}
    13351351
    1336 JSValue* dateProtoFuncGetUTCHours(ExecState* exec, JSObject* thisObj, const ArgList&)
    1337 {
    1338     if (!thisObj->inherits(&DateInstance::info))
     1352JSValue* dateProtoFuncGetUTCHours(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     1353{
     1354    if (!thisValue->isObject(&DateInstance::info))
    13391355        return throwError(exec, TypeError);
    13401356
    13411357    const bool utc = true;
    13421358
    1343     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1344     JSValue* v = thisDateObj->internalValue();
    1345     double milli = v->toNumber(exec);
     1359    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1360    double milli = thisDateObj->internalNumber();
    13461361    if (isnan(milli))
    13471362        return jsNaN(exec);
     
    13521367}
    13531368
    1354 JSValue* dateProtoFuncGetMinutes(ExecState* exec, JSObject* thisObj, const ArgList&)
    1355 {
    1356     if (!thisObj->inherits(&DateInstance::info))
     1369JSValue* dateProtoFuncGetMinutes(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     1370{
     1371    if (!thisValue->isObject(&DateInstance::info))
    13571372        return throwError(exec, TypeError);
    13581373
    13591374    const bool utc = false;
    13601375
    1361     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1362     JSValue* v = thisDateObj->internalValue();
    1363     double milli = v->toNumber(exec);
     1376    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1377    double milli = thisDateObj->internalNumber();
    13641378    if (isnan(milli))
    13651379        return jsNaN(exec);
     
    13701384}
    13711385
    1372 JSValue* dateProtoFuncGetUTCMinutes(ExecState* exec, JSObject* thisObj, const ArgList&)
    1373 {
    1374     if (!thisObj->inherits(&DateInstance::info))
     1386JSValue* dateProtoFuncGetUTCMinutes(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     1387{
     1388    if (!thisValue->isObject(&DateInstance::info))
    13751389        return throwError(exec, TypeError);
    13761390
    13771391    const bool utc = true;
    13781392
    1379     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1380     JSValue* v = thisDateObj->internalValue();
    1381     double milli = v->toNumber(exec);
     1393    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1394    double milli = thisDateObj->internalNumber();
    13821395    if (isnan(milli))
    13831396        return jsNaN(exec);
     
    13881401}
    13891402
    1390 JSValue* dateProtoFuncGetSeconds(ExecState* exec, JSObject* thisObj, const ArgList&)
    1391 {
    1392     if (!thisObj->inherits(&DateInstance::info))
     1403JSValue* dateProtoFuncGetSeconds(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     1404{
     1405    if (!thisValue->isObject(&DateInstance::info))
    13931406        return throwError(exec, TypeError);
    13941407
    13951408    const bool utc = false;
    13961409
    1397     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1398     JSValue* v = thisDateObj->internalValue();
    1399     double milli = v->toNumber(exec);
     1410    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1411    double milli = thisDateObj->internalNumber();
    14001412    if (isnan(milli))
    14011413        return jsNaN(exec);
     
    14061418}
    14071419
    1408 JSValue* dateProtoFuncGetUTCSeconds(ExecState* exec, JSObject* thisObj, const ArgList&)
    1409 {
    1410     if (!thisObj->inherits(&DateInstance::info))
     1420JSValue* dateProtoFuncGetUTCSeconds(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     1421{
     1422    if (!thisValue->isObject(&DateInstance::info))
    14111423        return throwError(exec, TypeError);
    14121424
    14131425    const bool utc = true;
    14141426
    1415     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1416     JSValue* v = thisDateObj->internalValue();
    1417     double milli = v->toNumber(exec);
     1427    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1428    double milli = thisDateObj->internalNumber();
    14181429    if (isnan(milli))
    14191430        return jsNaN(exec);
     
    14241435}
    14251436
    1426 JSValue* dateProtoFuncGetMilliSeconds(ExecState* exec, JSObject* thisObj, const ArgList&)
    1427 {
    1428     if (!thisObj->inherits(&DateInstance::info))
    1429         return throwError(exec, TypeError);
    1430 
    1431     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1432     JSValue* v = thisDateObj->internalValue();
    1433     double milli = v->toNumber(exec);
     1437JSValue* dateProtoFuncGetMilliSeconds(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     1438{
     1439    if (!thisValue->isObject(&DateInstance::info))
     1440        return throwError(exec, TypeError);
     1441
     1442    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1443    double milli = thisDateObj->internalNumber();
    14341444    if (isnan(milli))
    14351445        return jsNaN(exec);
     
    14401450}
    14411451
    1442 JSValue* dateProtoFuncGetUTCMilliseconds(ExecState* exec, JSObject* thisObj, const ArgList&)
    1443 {
    1444     if (!thisObj->inherits(&DateInstance::info))
    1445         return throwError(exec, TypeError);
    1446 
    1447     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1448     JSValue* v = thisDateObj->internalValue();
    1449     double milli = v->toNumber(exec);
     1452JSValue* dateProtoFuncGetUTCMilliseconds(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     1453{
     1454    if (!thisValue->isObject(&DateInstance::info))
     1455        return throwError(exec, TypeError);
     1456
     1457    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1458    double milli = thisDateObj->internalNumber();
    14501459    if (isnan(milli))
    14511460        return jsNaN(exec);
     
    14561465}
    14571466
    1458 JSValue* dateProtoFuncGetTimezoneOffset(ExecState* exec, JSObject* thisObj, const ArgList&)
    1459 {
    1460     if (!thisObj->inherits(&DateInstance::info))
     1467JSValue* dateProtoFuncGetTimezoneOffset(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     1468{
     1469    if (!thisValue->isObject(&DateInstance::info))
    14611470        return throwError(exec, TypeError);
    14621471
    14631472    const bool utc = false;
    14641473
    1465     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1466     JSValue* v = thisDateObj->internalValue();
    1467     double milli = v->toNumber(exec);
     1474    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1475    double milli = thisDateObj->internalNumber();
    14681476    if (isnan(milli))
    14691477        return jsNaN(exec);
     
    14741482}
    14751483
    1476 JSValue* dateProtoFuncSetTime(ExecState* exec, JSObject* thisObj, const ArgList& args)
    1477 {
    1478     if (!thisObj->inherits(&DateInstance::info))
    1479         return throwError(exec, TypeError);
    1480 
    1481     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
     1484JSValue* dateProtoFuncSetTime(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     1485{
     1486    if (!thisValue->isObject(&DateInstance::info))
     1487        return throwError(exec, TypeError);
     1488
     1489    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
    14821490
    14831491    double milli = timeClip(args[0]->toNumber(exec));
     
    14871495}
    14881496
    1489 static JSValue* setNewValueFromTimeArgs(ExecState* exec, JSObject* thisObj, const ArgList& args, int numArgsToUse, bool inputIsUTC)
    1490 {
    1491     if (!thisObj->inherits(&DateInstance::info))
    1492         return throwError(exec, TypeError);
    1493 
    1494     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1495     JSValue* v = thisDateObj->internalValue();
    1496     double milli = v->toNumber(exec);
     1497static JSValue* setNewValueFromTimeArgs(ExecState* exec, JSValue* thisValue, const ArgList& args, int numArgsToUse, bool inputIsUTC)
     1498{
     1499    if (!thisValue->isObject(&DateInstance::info))
     1500        return throwError(exec, TypeError);
     1501
     1502    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1503    double milli = thisDateObj->internalNumber();
    14971504   
    14981505    if (args.isEmpty() || isnan(milli)) {
     
    15191526}
    15201527
    1521 static JSValue* setNewValueFromDateArgs(ExecState* exec, JSObject* thisObj, const ArgList& args, int numArgsToUse, bool inputIsUTC)
    1522 {
    1523     if (!thisObj->inherits(&DateInstance::info))
    1524         return throwError(exec, TypeError);
    1525 
    1526     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
     1528static JSValue* setNewValueFromDateArgs(ExecState* exec, JSValue* thisValue, const ArgList& args, int numArgsToUse, bool inputIsUTC)
     1529{
     1530    if (!thisValue->isObject(&DateInstance::info))
     1531        return throwError(exec, TypeError);
     1532
     1533    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
    15271534    if (args.isEmpty()) {
    15281535        JSValue* result = jsNaN(exec);
     
    15311538    }     
    15321539   
    1533     JSValue* v = thisDateObj->internalValue();
    1534     double milli = v->toNumber(exec);
     1540    double milli = thisDateObj->internalNumber();
    15351541    double ms = 0;
    15361542
     
    15571563}
    15581564
    1559 JSValue* dateProtoFuncSetMilliSeconds(ExecState* exec, JSObject* thisObj, const ArgList& args)
     1565JSValue* dateProtoFuncSetMilliSeconds(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
    15601566{
    15611567    const bool inputIsUTC = false;
    1562     return setNewValueFromTimeArgs(exec, thisObj, args, 1, inputIsUTC);
    1563 }
    1564 
    1565 JSValue* dateProtoFuncSetUTCMilliseconds(ExecState* exec, JSObject* thisObj, const ArgList& args)
     1568    return setNewValueFromTimeArgs(exec, thisValue, args, 1, inputIsUTC);
     1569}
     1570
     1571JSValue* dateProtoFuncSetUTCMilliseconds(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
    15661572{
    15671573    const bool inputIsUTC = true;
    1568     return setNewValueFromTimeArgs(exec, thisObj, args, 1, inputIsUTC);
    1569 }
    1570 
    1571 JSValue* dateProtoFuncSetSeconds(ExecState* exec, JSObject* thisObj, const ArgList& args)
     1574    return setNewValueFromTimeArgs(exec, thisValue, args, 1, inputIsUTC);
     1575}
     1576
     1577JSValue* dateProtoFuncSetSeconds(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
    15721578{
    15731579    const bool inputIsUTC = false;
    1574     return setNewValueFromTimeArgs(exec, thisObj, args, 2, inputIsUTC);
    1575 }
    1576 
    1577 JSValue* dateProtoFuncSetUTCSeconds(ExecState* exec, JSObject* thisObj, const ArgList& args)
     1580    return setNewValueFromTimeArgs(exec, thisValue, args, 2, inputIsUTC);
     1581}
     1582
     1583JSValue* dateProtoFuncSetUTCSeconds(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
    15781584{
    15791585    const bool inputIsUTC = true;
    1580     return setNewValueFromTimeArgs(exec, thisObj, args, 2, inputIsUTC);
    1581 }
    1582 
    1583 JSValue* dateProtoFuncSetMinutes(ExecState* exec, JSObject* thisObj, const ArgList& args)
     1586    return setNewValueFromTimeArgs(exec, thisValue, args, 2, inputIsUTC);
     1587}
     1588
     1589JSValue* dateProtoFuncSetMinutes(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
    15841590{
    15851591    const bool inputIsUTC = false;
    1586     return setNewValueFromTimeArgs(exec, thisObj, args, 3, inputIsUTC);
    1587 }
    1588 
    1589 JSValue* dateProtoFuncSetUTCMinutes(ExecState* exec, JSObject* thisObj, const ArgList& args)
     1592    return setNewValueFromTimeArgs(exec, thisValue, args, 3, inputIsUTC);
     1593}
     1594
     1595JSValue* dateProtoFuncSetUTCMinutes(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
    15901596{
    15911597    const bool inputIsUTC = true;
    1592     return setNewValueFromTimeArgs(exec, thisObj, args, 3, inputIsUTC);
    1593 }
    1594 
    1595 JSValue* dateProtoFuncSetHours(ExecState* exec, JSObject* thisObj, const ArgList& args)
     1598    return setNewValueFromTimeArgs(exec, thisValue, args, 3, inputIsUTC);
     1599}
     1600
     1601JSValue* dateProtoFuncSetHours(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
    15961602{
    15971603    const bool inputIsUTC = false;
    1598     return setNewValueFromTimeArgs(exec, thisObj, args, 4, inputIsUTC);
    1599 }
    1600 
    1601 JSValue* dateProtoFuncSetUTCHours(ExecState* exec, JSObject* thisObj, const ArgList& args)
     1604    return setNewValueFromTimeArgs(exec, thisValue, args, 4, inputIsUTC);
     1605}
     1606
     1607JSValue* dateProtoFuncSetUTCHours(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
    16021608{
    16031609    const bool inputIsUTC = true;
    1604     return setNewValueFromTimeArgs(exec, thisObj, args, 4, inputIsUTC);
    1605 }
    1606 
    1607 JSValue* dateProtoFuncSetDate(ExecState* exec, JSObject* thisObj, const ArgList& args)
     1610    return setNewValueFromTimeArgs(exec, thisValue, args, 4, inputIsUTC);
     1611}
     1612
     1613JSValue* dateProtoFuncSetDate(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
    16081614{
    16091615    const bool inputIsUTC = false;
    1610     return setNewValueFromDateArgs(exec, thisObj, args, 1, inputIsUTC);
    1611 }
    1612 
    1613 JSValue* dateProtoFuncSetUTCDate(ExecState* exec, JSObject* thisObj, const ArgList& args)
     1616    return setNewValueFromDateArgs(exec, thisValue, args, 1, inputIsUTC);
     1617}
     1618
     1619JSValue* dateProtoFuncSetUTCDate(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
    16141620{
    16151621    const bool inputIsUTC = true;
    1616     return setNewValueFromDateArgs(exec, thisObj, args, 1, inputIsUTC);
    1617 }
    1618 
    1619 JSValue* dateProtoFuncSetMonth(ExecState* exec, JSObject* thisObj, const ArgList& args)
     1622    return setNewValueFromDateArgs(exec, thisValue, args, 1, inputIsUTC);
     1623}
     1624
     1625JSValue* dateProtoFuncSetMonth(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
    16201626{
    16211627    const bool inputIsUTC = false;
    1622     return setNewValueFromDateArgs(exec, thisObj, args, 2, inputIsUTC);
    1623 }
    1624 
    1625 JSValue* dateProtoFuncSetUTCMonth(ExecState* exec, JSObject* thisObj, const ArgList& args)
     1628    return setNewValueFromDateArgs(exec, thisValue, args, 2, inputIsUTC);
     1629}
     1630
     1631JSValue* dateProtoFuncSetUTCMonth(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
    16261632{
    16271633    const bool inputIsUTC = true;
    1628     return setNewValueFromDateArgs(exec, thisObj, args, 2, inputIsUTC);
    1629 }
    1630 
    1631 JSValue* dateProtoFuncSetFullYear(ExecState* exec, JSObject* thisObj, const ArgList& args)
     1634    return setNewValueFromDateArgs(exec, thisValue, args, 2, inputIsUTC);
     1635}
     1636
     1637JSValue* dateProtoFuncSetFullYear(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
    16321638{
    16331639    const bool inputIsUTC = false;
    1634     return setNewValueFromDateArgs(exec, thisObj, args, 3, inputIsUTC);
    1635 }
    1636 
    1637 JSValue* dateProtoFuncSetUTCFullYear(ExecState* exec, JSObject* thisObj, const ArgList& args)
     1640    return setNewValueFromDateArgs(exec, thisValue, args, 3, inputIsUTC);
     1641}
     1642
     1643JSValue* dateProtoFuncSetUTCFullYear(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
    16381644{
    16391645    const bool inputIsUTC = true;
    1640     return setNewValueFromDateArgs(exec, thisObj, args, 3, inputIsUTC);
    1641 }
    1642 
    1643 JSValue* dateProtoFuncSetYear(ExecState* exec, JSObject* thisObj, const ArgList& args)
    1644 {
    1645     if (!thisObj->inherits(&DateInstance::info))
     1646    return setNewValueFromDateArgs(exec, thisValue, args, 3, inputIsUTC);
     1647}
     1648
     1649JSValue* dateProtoFuncSetYear(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     1650{
     1651    if (!thisValue->isObject(&DateInstance::info))
    16461652        return throwError(exec, TypeError);
    16471653
    16481654    const bool utc = false;
    16491655
    1650     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);     
     1656    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);     
    16511657    if (args.isEmpty()) {
    16521658        JSValue* result = jsNaN(exec);
     
    16551661    }
    16561662   
    1657     JSValue* v = thisDateObj->internalValue();
    1658     double milli = v->toNumber(exec);
     1663    double milli = thisDateObj->internalNumber();
    16591664    double ms = 0;
    16601665
     
    16841689}
    16851690
    1686 JSValue* dateProtoFuncGetYear(ExecState* exec, JSObject* thisObj, const ArgList&)
    1687 {
    1688     if (!thisObj->inherits(&DateInstance::info))
     1691JSValue* dateProtoFuncGetYear(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     1692{
     1693    if (!thisValue->isObject(&DateInstance::info))
    16891694        return throwError(exec, TypeError);
    16901695
    16911696    const bool utc = false;
    16921697
    1693     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1694     JSValue* v = thisDateObj->internalValue();
    1695     double milli = v->toNumber(exec);
     1698    DateInstance* thisDateObj = static_cast<DateInstance*>(thisValue);
     1699    double milli = thisDateObj->internalNumber();
    16961700    if (isnan(milli))
    16971701        return jsNaN(exec);
  • trunk/JavaScriptCore/kjs/date_object.h

    r34587 r34754  
    3434    class DateInstance : public JSWrapperObject {
    3535    public:
    36         DateInstance(JSObject *proto);
     36        DateInstance(JSObject* prototype);
    3737        virtual ~DateInstance();
    38        
     38
     39        double internalNumber() const { return internalValue()->uncheckedGetNumber(); }
     40
    3941        bool getTime(GregorianDateTime&, int& offset) const;
    4042        bool getUTCTime(GregorianDateTime&) const;
    41         bool getTime(double& milli, int& offset) const;
    42         bool getUTCTime(double& milli) const;
     43        bool getTime(double& milliseconds, int& offset) const;
     44        bool getUTCTime(double& milliseconds) const;
    4345       
    44         virtual const ClassInfo *classInfo() const { return &info; }
    4546        static const ClassInfo info;
    4647
     
    4849
    4950    private:
     51        virtual const ClassInfo* classInfo() const { return &info; }
     52
     53        using JSWrapperObject::internalValue;
     54
    5055        struct Cache;
    5156        mutable Cache* m_cache;
     
    6974     * @internal
    7075     *
    71      * Functions to implement all methods that are properties of the
    72      * Date.prototype object
    73      */
    74    
    75     // Non-normative properties (Appendix B)
    76     // GetYear, SetYear, ToGMTString
    77 
    78     JSValue* dateProtoFuncToString(ExecState*, JSObject*, const ArgList&);
    79     JSValue* dateProtoFuncToUTCString(ExecState*, JSObject*, const ArgList&);
    80     JSValue* dateProtoFuncToDateString(ExecState*, JSObject*, const ArgList&);
    81     JSValue* dateProtoFuncToTimeString(ExecState*, JSObject*, const ArgList&);
    82     JSValue* dateProtoFuncToLocaleString(ExecState*, JSObject*, const ArgList&);
    83     JSValue* dateProtoFuncToLocaleDateString(ExecState*, JSObject*, const ArgList&);
    84     JSValue* dateProtoFuncToLocaleTimeString(ExecState*, JSObject*, const ArgList&);
    85     JSValue* dateProtoFuncValueOf(ExecState*, JSObject*, const ArgList&);
    86     JSValue* dateProtoFuncGetTime(ExecState*, JSObject*, const ArgList&);
    87     JSValue* dateProtoFuncGetFullYear(ExecState*, JSObject*, const ArgList&);
    88     JSValue* dateProtoFuncGetUTCFullYear(ExecState*, JSObject*, const ArgList&);
    89     JSValue* dateProtoFuncToGMTString(ExecState*, JSObject*, const ArgList&);
    90     JSValue* dateProtoFuncGetMonth(ExecState*, JSObject*, const ArgList&);
    91     JSValue* dateProtoFuncGetUTCMonth(ExecState*, JSObject*, const ArgList&);
    92     JSValue* dateProtoFuncGetDate(ExecState*, JSObject*, const ArgList&);
    93     JSValue* dateProtoFuncGetUTCDate(ExecState*, JSObject*, const ArgList&);
    94     JSValue* dateProtoFuncGetDay(ExecState*, JSObject*, const ArgList&);
    95     JSValue* dateProtoFuncGetUTCDay(ExecState*, JSObject*, const ArgList&);
    96     JSValue* dateProtoFuncGetHours(ExecState*, JSObject*, const ArgList&);
    97     JSValue* dateProtoFuncGetUTCHours(ExecState*, JSObject*, const ArgList&);
    98     JSValue* dateProtoFuncGetMinutes(ExecState*, JSObject*, const ArgList&);
    99     JSValue* dateProtoFuncGetUTCMinutes(ExecState*, JSObject*, const ArgList&);
    100     JSValue* dateProtoFuncGetSeconds(ExecState*, JSObject*, const ArgList&);
    101     JSValue* dateProtoFuncGetUTCSeconds(ExecState*, JSObject*, const ArgList&);
    102     JSValue* dateProtoFuncGetMilliSeconds(ExecState*, JSObject*, const ArgList&);
    103     JSValue* dateProtoFuncGetUTCMilliseconds(ExecState*, JSObject*, const ArgList&);
    104     JSValue* dateProtoFuncGetTimezoneOffset(ExecState*, JSObject*, const ArgList&);
    105     JSValue* dateProtoFuncSetTime(ExecState*, JSObject*, const ArgList&);
    106     JSValue* dateProtoFuncSetMilliSeconds(ExecState*, JSObject*, const ArgList&);
    107     JSValue* dateProtoFuncSetUTCMilliseconds(ExecState*, JSObject*, const ArgList&);
    108     JSValue* dateProtoFuncSetSeconds(ExecState*, JSObject*, const ArgList&);
    109     JSValue* dateProtoFuncSetUTCSeconds(ExecState*, JSObject*, const ArgList&);
    110     JSValue* dateProtoFuncSetMinutes(ExecState*, JSObject*, const ArgList&);
    111     JSValue* dateProtoFuncSetUTCMinutes(ExecState*, JSObject*, const ArgList&);
    112     JSValue* dateProtoFuncSetHours(ExecState*, JSObject*, const ArgList&);
    113     JSValue* dateProtoFuncSetUTCHours(ExecState*, JSObject*, const ArgList&);
    114     JSValue* dateProtoFuncSetDate(ExecState*, JSObject*, const ArgList&);
    115     JSValue* dateProtoFuncSetUTCDate(ExecState*, JSObject*, const ArgList&);
    116     JSValue* dateProtoFuncSetMonth(ExecState*, JSObject*, const ArgList&);
    117     JSValue* dateProtoFuncSetUTCMonth(ExecState*, JSObject*, const ArgList&);
    118     JSValue* dateProtoFuncSetFullYear(ExecState*, JSObject*, const ArgList&);
    119     JSValue* dateProtoFuncSetUTCFullYear(ExecState*, JSObject*, const ArgList&);
    120     JSValue* dateProtoFuncSetYear(ExecState*, JSObject*, const ArgList&);
    121     JSValue* dateProtoFuncGetYear(ExecState*, JSObject*, const ArgList&);
    122 
    123     /**
    124      * @internal
    125      *
    12676     * The initial value of the the global variable's "Date" property
    12777     */
     
    12979    public:
    13080        DateConstructor(ExecState*, FunctionPrototype*, DatePrototype*);
    131 
     81    private:
    13282        virtual ConstructType getConstructData(ConstructData&);
    133         virtual JSObject* construct(ExecState*, const ArgList& args);
    134 
    135         virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const ArgList& args);
    136 
    137         JSObject* construct(const ArgList&);
     83        virtual CallType getCallData(CallData&);
    13884    };
    13985
  • trunk/JavaScriptCore/kjs/error_object.cpp

    r34659 r34754  
    4040// ------------------------------ ErrorPrototype ----------------------------
    4141
     42static JSValue* errorProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
     43
    4244// ECMA 15.9.4
    4345ErrorPrototype::ErrorPrototype(ExecState* exec, ObjectPrototype* objectPrototype, FunctionPrototype* functionPrototype)
     
    5254}
    5355
    54 JSValue* errorProtoFuncToString(ExecState* exec, JSObject* thisObj, const ArgList&)
     56JSValue* errorProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
    5557{
     58    JSObject* thisObj = thisValue->toThisObject(exec);
     59
    5660    UString s = "Error";
    5761
     
    6165
    6266    v = thisObj->get(exec, exec->propertyNames().message);
    63     if (!v->isUndefined())
    64         // Mozilla compatible format
    65         s += ": " + v->toString(exec);
     67    if (!v->isUndefined()) {
     68        // Mozilla-compatible format.
     69        s += ": ";
     70        s += v->toString(exec);
     71    }
    6672
    6773    return jsString(exec, s);
     
    7884}
    7985
    80 ConstructType ErrorConstructor::getConstructData(ConstructData&)
     86// ECMA 15.9.3
     87static ErrorInstance* constructError(ExecState* exec, const ArgList& args)
    8188{
     89    ErrorInstance* obj = new (exec) ErrorInstance(exec->lexicalGlobalObject()->errorPrototype());
     90    if (!args[0]->isUndefined())
     91        obj->putDirect(exec->propertyNames().message, jsString(exec, args[0]->toString(exec)));
     92    return obj;
     93}
     94
     95static JSObject* constructWithErrorConstructor(ExecState* exec, JSObject*, const ArgList& args)
     96{
     97    return constructError(exec, args);
     98}
     99
     100ConstructType ErrorConstructor::getConstructData(ConstructData& constructData)
     101{
     102    constructData.native.function = constructWithErrorConstructor;
    82103    return ConstructTypeNative;
    83104}
    84105
    85 // ECMA 15.9.3
    86 JSObject* ErrorConstructor::construct(ExecState* exec, const ArgList& args)
     106// ECMA 15.9.2
     107static JSValue* callErrorConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    87108{
    88     JSObject* proto = static_cast<JSObject*>(exec->lexicalGlobalObject()->errorPrototype());
    89     JSObject* imp = new (exec) ErrorInstance(proto);
    90     JSObject* obj(imp);
    91 
    92     if (!args[0]->isUndefined())
    93         imp->putDirect(exec->propertyNames().message, jsString(exec, args[0]->toString(exec)));
    94 
    95     return obj;
     109    // "Error()" gives the sames result as "new Error()"
     110    return constructError(exec, args);
    96111}
    97112
    98 // ECMA 15.9.2
    99 JSValue* ErrorConstructor::callAsFunction(ExecState* exec, JSObject* /*thisObj*/, const ArgList& args)
     113CallType ErrorConstructor::getCallData(CallData& callData)
    100114{
    101     // "Error()" gives the sames result as "new Error()"
    102     return construct(exec, args);
     115    callData.native.function = callErrorConstructor;
     116    return CallTypeNative;
    103117}
    104118
     
    124138}
    125139
    126 ConstructType NativeErrorConstructor::getConstructData(ConstructData&)
     140ErrorInstance* NativeErrorConstructor::construct(ExecState* exec, const ArgList& args)
    127141{
     142    ErrorInstance* object = new (exec) ErrorInstance(proto);
     143    if (!args[0]->isUndefined())
     144        object->putDirect(exec->propertyNames().message, jsString(exec, args[0]->toString(exec)));
     145    return object;
     146}
     147
     148static JSObject* constructWithNativeErrorConstructor(ExecState* exec, JSObject* constructor, const ArgList& args)
     149{
     150    return static_cast<NativeErrorConstructor*>(constructor)->construct(exec, args);
     151}
     152
     153ConstructType NativeErrorConstructor::getConstructData(ConstructData& constructData)
     154{
     155    constructData.native.function = constructWithNativeErrorConstructor;
    128156    return ConstructTypeNative;
    129157}
    130158
    131 JSObject* NativeErrorConstructor::construct(ExecState* exec, const ArgList& args)
     159static JSValue* callNativeErrorConstructor(ExecState* exec, JSObject* constructor, JSValue*, const ArgList& args)
    132160{
    133     JSObject* imp = new (exec) ErrorInstance(proto);
    134     JSObject* obj(imp);
    135     if (!args[0]->isUndefined())
    136         imp->putDirect(exec->propertyNames().message, jsString(exec, args[0]->toString(exec)));
    137     return obj;
     161    return static_cast<NativeErrorConstructor*>(constructor)->construct(exec, args);
    138162}
    139163
    140 JSValue* NativeErrorConstructor::callAsFunction(ExecState* exec, JSObject*, const ArgList& args)
     164CallType NativeErrorConstructor::getCallData(CallData& callData)
    141165{
    142     return construct(exec, args);
     166    callData.native.function = callNativeErrorConstructor;
     167    return CallTypeNative;
    143168}
    144169
  • trunk/JavaScriptCore/kjs/error_object.h

    r34587 r34754  
    3939    };
    4040
    41     JSValue* errorProtoFuncToString(ExecState*, JSObject*, const ArgList&);
    42 
    4341    class ErrorConstructor : public InternalFunction {
    4442    public:
    4543        ErrorConstructor(ExecState*, FunctionPrototype*, ErrorPrototype*);
    4644
     45    private:
    4746        virtual ConstructType getConstructData(ConstructData&);
    48         virtual JSObject* construct(ExecState*, const ArgList&);
    49 
    50         virtual JSValue* callAsFunction(ExecState*, JSObject*, const ArgList&);
     47        virtual CallType getCallData(CallData&);
    5148    };
    5249
     
    5956    public:
    6057        NativeErrorConstructor(ExecState*, FunctionPrototype*, NativeErrorPrototype*);
    61 
    62         virtual ConstructType getConstructData(ConstructData&);
    63         virtual JSObject* construct(ExecState*, const ArgList&);
    64 
    65         virtual JSValue* callAsFunction(ExecState*, JSObject*, const ArgList&);
    66 
    6758        virtual void mark();
    68 
    69         virtual const ClassInfo* classInfo() const { return &info; }
    7059        static const ClassInfo info;
     60        ErrorInstance* construct(ExecState*, const ArgList&);
    7161
    7262    private:
    73         JSObject* proto;
     63        virtual const ClassInfo* classInfo() const { return &info; }
     64        virtual ConstructType getConstructData(ConstructData&);
     65        virtual CallType getCallData(CallData&);
     66
     67        NativeErrorPrototype* proto;
    7468    };
    7569
  • trunk/JavaScriptCore/kjs/internal.cpp

    r34659 r34754  
    176176}
    177177
    178 JSObject *JSNumberCell::toObject(ExecState *exec) const
    179 {
    180   ArgList args;
    181   args.append(const_cast<JSNumberCell*>(this));
    182   return static_cast<JSObject *>(exec->lexicalGlobalObject()->numberConstructor()->construct(exec,args));
     178JSObject* JSNumberCell::toObject(ExecState* exec) const
     179{
     180    return constructNumber(exec, const_cast<JSNumberCell*>(this));
    183181}
    184182
    185183JSObject* JSNumberCell::toThisObject(ExecState* exec) const
    186184{
    187     ArgList args;
    188     args.append(const_cast<JSNumberCell*>(this));
    189     return static_cast<JSObject*>(exec->lexicalGlobalObject()->numberConstructor()->construct(exec, args));
     185    return constructNumber(exec, const_cast<JSNumberCell*>(this));
    190186}
    191187
     
    213209
    214210// --------------------------- GetterSetter ---------------------------------
     211
    215212void GetterSetter::mark()
    216213{
    217214    JSCell::mark();
    218    
    219     if (getter && !getter->marked())
    220         getter->mark();
    221     if (setter && !setter->marked())
    222         setter->mark();
     215
     216    if (m_getter && !m_getter->marked())
     217        m_getter->mark();
     218    if (m_setter && !m_setter->marked())
     219        m_setter->mark();
    223220}
    224221
    225222JSValue* GetterSetter::toPrimitive(ExecState*, JSType) const
    226223{
    227     ASSERT(false);
     224    ASSERT_NOT_REACHED();
    228225    return jsNull();
    229226}
     
    239236bool GetterSetter::toBoolean(ExecState*) const
    240237{
    241     ASSERT(false);
     238    ASSERT_NOT_REACHED();
    242239    return false;
    243240}
    244241
    245 double GetterSetter::toNumber(ExecState *) const
    246 {
    247     ASSERT(false);
     242double GetterSetter::toNumber(ExecState*) const
     243{
     244    ASSERT_NOT_REACHED();
    248245    return 0.0;
    249246}
    250247
    251 UString GetterSetter::toString(ExecState *) const
    252 {
    253     ASSERT(false);
     248UString GetterSetter::toString(ExecState*) const
     249{
     250    ASSERT_NOT_REACHED();
    254251    return UString::null();
    255252}
    256253
    257 JSObject *GetterSetter::toObject(ExecState *exec) const
    258 {
    259     ASSERT(false);
     254JSObject* GetterSetter::toObject(ExecState* exec) const
     255{
     256    ASSERT_NOT_REACHED();
    260257    return jsNull()->toObject(exec);
    261 }
    262 
    263 bool GetterSetter::getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&)
    264 {
    265     ASSERT_NOT_REACHED();
    266     return false;
    267 }
    268 
    269 bool GetterSetter::getOwnPropertySlot(ExecState*, unsigned, PropertySlot&)
    270 {
    271     ASSERT_NOT_REACHED();
    272     return false;
    273 }
    274 
    275 void GetterSetter::put(ExecState*, const Identifier&, JSValue*)
    276 {
    277     ASSERT_NOT_REACHED();
    278 }
    279 
    280 void GetterSetter::put(ExecState*, unsigned, JSValue*)
    281 {
    282     ASSERT_NOT_REACHED();
    283 }
    284 
    285 JSObject* GetterSetter::toThisObject(ExecState*) const
    286 {
    287     ASSERT_NOT_REACHED();
    288     return 0;
    289258}
    290259
     
    323292}
    324293
    325 InternalFunction::InternalFunction(FunctionPrototype* funcProto, const Identifier& name)
    326   : JSObject(funcProto)
    327   , m_name(name)
    328 {
    329 }
    330 
    331 CallType InternalFunction::getCallData(CallData&)
    332 {
    333     return CallTypeNative;
     294InternalFunction::InternalFunction(FunctionPrototype* prototype, const Identifier& name)
     295    : JSObject(prototype)
     296    , m_name(name)
     297{
    334298}
    335299
    336300bool InternalFunction::implementsHasInstance() const
    337301{
    338   return true;
    339 }
    340 
    341 }
     302    return true;
     303}
     304
     305}
  • trunk/JavaScriptCore/kjs/lookup.h

    r34659 r34754  
    4646        union {
    4747            intptr_t integerValue;
    48             PrototypeFunction::JSMemberFunction functionValue;
     48            NativeFunction functionValue;
    4949        };
    5050        unsigned char attributes; // JSObject attributes
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r34711 r34754  
    16831683    JSFunction* func = new (exec) JSFunction(exec, m_ident, m_body.get(), scopeChain);
    16841684
    1685     JSObject* proto = exec->lexicalGlobalObject()->objectConstructor()->construct(exec, exec->emptyList());
     1685    JSObject* proto = constructEmptyObject(exec);
    16861686    proto->putDirect(exec->propertyNames().constructor, func, DontEnum);
    16871687    func->putDirect(exec->propertyNames().prototype, proto, DontDelete);
     
    17051705{
    17061706    JSFunction* func = new (exec) JSFunction(exec, m_ident, m_body.get(), scopeChain);
    1707     JSObject* proto = exec->lexicalGlobalObject()->objectConstructor()->construct(exec, exec->emptyList());
     1707    JSObject* proto = constructEmptyObject(exec);
    17081708    proto->putDirect(exec->propertyNames().constructor, func, DontEnum);
    17091709    func->putDirect(exec->propertyNames().prototype, proto, DontDelete);
  • trunk/JavaScriptCore/kjs/object_object.cpp

    r34659 r34754  
    3131// ------------------------------ ObjectPrototype --------------------------------
    3232
    33 static JSValue* objectProtoFuncValueOf(ExecState*, JSObject*, const ArgList&);
    34 static JSValue* objectProtoFuncHasOwnProperty(ExecState*, JSObject*, const ArgList&);
    35 static JSValue* objectProtoFuncIsPrototypeOf(ExecState*, JSObject*, const ArgList&);
    36 static JSValue* objectProtoFuncDefineGetter(ExecState*, JSObject*, const ArgList&);
    37 static JSValue* objectProtoFuncDefineSetter(ExecState*, JSObject*, const ArgList&);
    38 static JSValue* objectProtoFuncLookupGetter(ExecState*, JSObject*, const ArgList&);
    39 static JSValue* objectProtoFuncLookupSetter(ExecState*, JSObject*, const ArgList&);
    40 static JSValue* objectProtoFuncPropertyIsEnumerable(ExecState*, JSObject*, const ArgList&);
    41 static JSValue* objectProtoFuncToLocaleString(ExecState*, JSObject*, const ArgList&);
     33static JSValue* objectProtoFuncValueOf(ExecState*, JSObject*, JSValue*, const ArgList&);
     34static JSValue* objectProtoFuncHasOwnProperty(ExecState*, JSObject*, JSValue*, const ArgList&);
     35static JSValue* objectProtoFuncIsPrototypeOf(ExecState*, JSObject*, JSValue*, const ArgList&);
     36static JSValue* objectProtoFuncDefineGetter(ExecState*, JSObject*, JSValue*, const ArgList&);
     37static JSValue* objectProtoFuncDefineSetter(ExecState*, JSObject*, JSValue*, const ArgList&);
     38static JSValue* objectProtoFuncLookupGetter(ExecState*, JSObject*, JSValue*, const ArgList&);
     39static JSValue* objectProtoFuncLookupSetter(ExecState*, JSObject*, JSValue*, const ArgList&);
     40static JSValue* objectProtoFuncPropertyIsEnumerable(ExecState*, JSObject*, JSValue*, const ArgList&);
     41static JSValue* objectProtoFuncToLocaleString(ExecState*, JSObject*, JSValue*, const ArgList&);
    4242
    4343ObjectPrototype::ObjectPrototype(ExecState* exec, FunctionPrototype* functionPrototype)
     
    6363// ECMA 15.2.4.2, 15.2.4.4, 15.2.4.5, 15.2.4.7
    6464
    65 JSValue* objectProtoFuncValueOf(ExecState*, JSObject* thisObj, const ArgList&)
     65JSValue* objectProtoFuncValueOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
    6666{
    67     return thisObj;
     67    return thisValue->toThisObject(exec);
    6868}
    6969
    70 JSValue* objectProtoFuncHasOwnProperty(ExecState* exec, JSObject* thisObj, const ArgList& args)
     70JSValue* objectProtoFuncHasOwnProperty(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
    7171{
    72     return jsBoolean(thisObj->hasOwnProperty(exec, Identifier(exec, args[0]->toString(exec))));
     72    return jsBoolean(thisValue->toThisObject(exec)->hasOwnProperty(exec, Identifier(exec, args[0]->toString(exec))));
    7373}
    7474
    75 JSValue* objectProtoFuncIsPrototypeOf(ExecState*, JSObject* thisObj, const ArgList& args)
     75JSValue* objectProtoFuncIsPrototypeOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
    7676{
     77    JSObject* thisObj = thisValue->toThisObject(exec);
     78
    7779    if (!args[0]->isObject())
    7880        return jsBoolean(false);
     
    8385        if (!v->isObject())
    8486            return jsBoolean(false);
    85         if (thisObj == static_cast<JSObject*>(v))
     87        if (thisObj == v)
    8688
    8789            return jsBoolean(true);
     
    9092}
    9193
    92 JSValue* objectProtoFuncDefineGetter(ExecState* exec, JSObject* thisObj, const ArgList& args)
     94JSValue* objectProtoFuncDefineGetter(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
    9395{
    94     if (!args[1]->isObject() || !static_cast<JSObject*>(args[1])->implementsCall())
     96    CallData callData;
     97    if (args[1]->getCallData(callData) == CallTypeNone)
    9598        return throwError(exec, SyntaxError, "invalid getter usage");
    96 
    97     thisObj->defineGetter(exec, Identifier(exec, args[0]->toString(exec)), static_cast<JSObject *>(args[1]));
     99    thisValue->toThisObject(exec)->defineGetter(exec, Identifier(exec, args[0]->toString(exec)), static_cast<JSObject*>(args[1]));
    98100    return jsUndefined();
    99101}
    100102
    101 JSValue* objectProtoFuncDefineSetter(ExecState* exec, JSObject* thisObj, const ArgList& args)
     103JSValue* objectProtoFuncDefineSetter(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
    102104{
    103     if (!args[1]->isObject() || !static_cast<JSObject*>(args[1])->implementsCall())
     105    CallData callData;
     106    if (args[1]->getCallData(callData) == CallTypeNone)
    104107        return throwError(exec, SyntaxError, "invalid setter usage");
    105 
    106     thisObj->defineSetter(exec, Identifier(exec, args[0]->toString(exec)), static_cast<JSObject *>(args[1]));
     108    thisValue->toThisObject(exec)->defineSetter(exec, Identifier(exec, args[0]->toString(exec)), static_cast<JSObject*>(args[1]));
    107109    return jsUndefined();
    108110}
    109111
    110 JSValue* objectProtoFuncLookupGetter(ExecState* exec, JSObject* thisObj, const ArgList& args)
     112JSValue* objectProtoFuncLookupGetter(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
    111113{
    112     return thisObj->lookupGetter(exec, Identifier(exec, args[0]->toString(exec)));
     114    return thisValue->toThisObject(exec)->lookupGetter(exec, Identifier(exec, args[0]->toString(exec)));
    113115}
    114116
    115 JSValue* objectProtoFuncLookupSetter(ExecState* exec, JSObject* thisObj, const ArgList& args)
     117JSValue* objectProtoFuncLookupSetter(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
    116118{
    117     return thisObj->lookupSetter(exec, Identifier(exec, args[0]->toString(exec)));
     119    return thisValue->toThisObject(exec)->lookupSetter(exec, Identifier(exec, args[0]->toString(exec)));
    118120}
    119121
    120 JSValue* objectProtoFuncPropertyIsEnumerable(ExecState* exec, JSObject* thisObj, const ArgList& args)
     122JSValue* objectProtoFuncPropertyIsEnumerable(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
    121123{
    122     return jsBoolean(thisObj->propertyIsEnumerable(exec, Identifier(exec, args[0]->toString(exec))));
     124    return jsBoolean(thisValue->toThisObject(exec)->propertyIsEnumerable(exec, Identifier(exec, args[0]->toString(exec))));
    123125}
    124126
    125 JSValue* objectProtoFuncToLocaleString(ExecState* exec, JSObject* thisObj, const ArgList&)
     127JSValue* objectProtoFuncToLocaleString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
    126128{
    127     return jsString(exec, thisObj->toString(exec));
     129    return jsString(exec, thisValue->toThisObject(exec)->toString(exec));
    128130}
    129131
    130 JSValue* objectProtoFuncToString(ExecState* exec, JSObject* thisObj, const ArgList&)
     132JSValue* objectProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
    131133{
    132     return jsString(exec, "[object " + thisObj->className() + "]");
     134    return jsString(exec, "[object " + thisValue->toThisObject(exec)->className() + "]");
    133135}
    134136
     
    142144
    143145  // no. of arguments for constructor
    144   putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly|DontDelete|DontEnum);
     146  putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontEnum | DontDelete);
    145147}
    146148
    147 ConstructType ObjectConstructor::getConstructData(ConstructData&)
     149// ECMA 15.2.2
     150static ALWAYS_INLINE JSObject* constructObject(ExecState* exec, const ArgList& args)
    148151{
     152    JSValue* arg = args[0];
     153    if (arg->isUndefinedOrNull())
     154        return new (exec) JSObject(exec->lexicalGlobalObject()->objectPrototype());
     155    return arg->toObject(exec);
     156}
     157
     158static JSObject* constructWithObjectConstructor(ExecState* exec, JSObject*, const ArgList& args)
     159{
     160    return constructObject(exec, args);
     161}
     162
     163ConstructType ObjectConstructor::getConstructData(ConstructData& constructData)
     164{
     165    constructData.native.function = constructWithObjectConstructor;
    149166    return ConstructTypeNative;
    150167}
    151168
    152 // ECMA 15.2.2
    153 JSObject* ObjectConstructor::construct(ExecState* exec, const ArgList& args)
     169static JSValue* callObjectConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    154170{
    155   JSValue* arg = args[0];
    156   switch (arg->type()) {
    157   case StringType:
    158   case BooleanType:
    159   case NumberType:
    160   case ObjectType:
    161       return arg->toObject(exec);
    162   case NullType:
    163   case UndefinedType:
    164       return new (exec) JSObject(exec->lexicalGlobalObject()->objectPrototype());
    165   default:
    166       ASSERT_NOT_REACHED();
    167       return 0;
    168   }
     171    return constructObject(exec, args);
    169172}
    170173
    171 JSValue* ObjectConstructor::callAsFunction(ExecState* exec, JSObject* /*thisObj*/, const ArgList &args)
     174CallType ObjectConstructor::getCallData(CallData& callData)
    172175{
    173     return construct(exec, args);
     176    callData.native.function = callObjectConstructor;
     177    return CallTypeNative;
    174178}
    175179
  • trunk/JavaScriptCore/kjs/object_object.h

    r34587 r34754  
    3737    };
    3838
    39     JSValue* objectProtoFuncToString(ExecState*, JSObject*, const ArgList&);
     39    JSValue* objectProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
    4040
    4141    /**
     
    4747    public:
    4848        ObjectConstructor(ExecState*, ObjectPrototype*, FunctionPrototype*);
    49 
     49    private:
    5050        virtual ConstructType getConstructData(ConstructData&);
    51         virtual JSObject* construct(ExecState*, const ArgList&);
    52 
    53         virtual JSValue* callAsFunction(ExecState*, JSObject*, const ArgList&);
     51        virtual CallType getCallData(CallData&);
    5452    };
    5553
  • trunk/JavaScriptCore/kjs/string_object.cpp

    r34659 r34754  
    2222#include "config.h"
    2323#include "string_object.h"
    24 #include "string_object.lut.h"
    2524
    2625#include "JSWrapperObject.h"
     
    3736namespace KJS {
    3837
     38static JSValue* stringProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
     39static JSValue* stringProtoFuncValueOf(ExecState*, JSObject*, JSValue*, const ArgList&);
     40static JSValue* stringProtoFuncCharAt(ExecState*, JSObject*, JSValue*, const ArgList&);
     41static JSValue* stringProtoFuncCharCodeAt(ExecState*, JSObject*, JSValue*, const ArgList&);
     42static JSValue* stringProtoFuncConcat(ExecState*, JSObject*, JSValue*, const ArgList&);
     43static JSValue* stringProtoFuncIndexOf(ExecState*, JSObject*, JSValue*, const ArgList&);
     44static JSValue* stringProtoFuncLastIndexOf(ExecState*, JSObject*, JSValue*, const ArgList&);
     45static JSValue* stringProtoFuncMatch(ExecState*, JSObject*, JSValue*, const ArgList&);
     46static JSValue* stringProtoFuncReplace(ExecState*, JSObject*, JSValue*, const ArgList&);
     47static JSValue* stringProtoFuncSearch(ExecState*, JSObject*, JSValue*, const ArgList&);
     48static JSValue* stringProtoFuncSlice(ExecState*, JSObject*, JSValue*, const ArgList&);
     49static JSValue* stringProtoFuncSplit(ExecState*, JSObject*, JSValue*, const ArgList&);
     50static JSValue* stringProtoFuncSubstr(ExecState*, JSObject*, JSValue*, const ArgList&);
     51static JSValue* stringProtoFuncSubstring(ExecState*, JSObject*, JSValue*, const ArgList&);
     52static JSValue* stringProtoFuncToLowerCase(ExecState*, JSObject*, JSValue*, const ArgList&);
     53static JSValue* stringProtoFuncToUpperCase(ExecState*, JSObject*, JSValue*, const ArgList&);
     54static JSValue* stringProtoFuncToLocaleLowerCase(ExecState*, JSObject*, JSValue*, const ArgList&);
     55static JSValue* stringProtoFuncToLocaleUpperCase(ExecState*, JSObject*, JSValue*, const ArgList&);
     56static JSValue* stringProtoFuncLocaleCompare(ExecState*, JSObject*, JSValue*, const ArgList&);
     57
     58static JSValue* stringProtoFuncBig(ExecState*, JSObject*, JSValue*, const ArgList&);
     59static JSValue* stringProtoFuncSmall(ExecState*, JSObject*, JSValue*, const ArgList&);
     60static JSValue* stringProtoFuncBlink(ExecState*, JSObject*, JSValue*, const ArgList&);
     61static JSValue* stringProtoFuncBold(ExecState*, JSObject*, JSValue*, const ArgList&);
     62static JSValue* stringProtoFuncFixed(ExecState*, JSObject*, JSValue*, const ArgList&);
     63static JSValue* stringProtoFuncItalics(ExecState*, JSObject*, JSValue*, const ArgList&);
     64static JSValue* stringProtoFuncStrike(ExecState*, JSObject*, JSValue*, const ArgList&);
     65static JSValue* stringProtoFuncSub(ExecState*, JSObject*, JSValue*, const ArgList&);
     66static JSValue* stringProtoFuncSup(ExecState*, JSObject*, JSValue*, const ArgList&);
     67static JSValue* stringProtoFuncFontcolor(ExecState*, JSObject*, JSValue*, const ArgList&);
     68static JSValue* stringProtoFuncFontsize(ExecState*, JSObject*, JSValue*, const ArgList&);
     69static JSValue* stringProtoFuncAnchor(ExecState*, JSObject*, JSValue*, const ArgList&);
     70static JSValue* stringProtoFuncLink(ExecState*, JSObject*, JSValue*, const ArgList&);
     71
     72}
     73
     74#include "string_object.lut.h"
     75
     76namespace KJS {
     77
    3978// ------------------------------ StringObject ----------------------------
    4079
     
    99138/* Source for string_object.lut.h
    100139@begin stringTable 26
    101   toString              &stringProtoFuncToString          DontEnum|Function       0
    102   valueOf               &stringProtoFuncValueOf           DontEnum|Function       0
    103   charAt                &stringProtoFuncCharAt            DontEnum|Function       1
    104   charCodeAt            &stringProtoFuncCharCodeAt        DontEnum|Function       1
    105   concat                &stringProtoFuncConcat            DontEnum|Function       1
    106   indexOf               &stringProtoFuncIndexOf           DontEnum|Function       1
    107   lastIndexOf           &stringProtoFuncLastIndexOf       DontEnum|Function       1
    108   match                 &stringProtoFuncMatch             DontEnum|Function       1
    109   replace               &stringProtoFuncReplace           DontEnum|Function       2
    110   search                &stringProtoFuncSearch            DontEnum|Function       1
    111   slice                 &stringProtoFuncSlice             DontEnum|Function       2
    112   split                 &stringProtoFuncSplit             DontEnum|Function       2
    113   substr                &stringProtoFuncSubstr            DontEnum|Function       2
    114   substring             &stringProtoFuncSubstring         DontEnum|Function       2
    115   toLowerCase           &stringProtoFuncToLowerCase       DontEnum|Function       0
    116   toUpperCase           &stringProtoFuncToUpperCase       DontEnum|Function       0
    117   toLocaleLowerCase     &stringProtoFuncToLocaleLowerCase DontEnum|Function       0
    118   toLocaleUpperCase     &stringProtoFuncToLocaleUpperCase DontEnum|Function       0
    119   localeCompare         &stringProtoFuncLocaleCompare     DontEnum|Function       1
    120 
    121   big                   &stringProtoFuncBig               DontEnum|Function       0
    122   small                 &stringProtoFuncSmall             DontEnum|Function       0
    123   blink                 &stringProtoFuncBlink             DontEnum|Function       0
    124   bold                  &stringProtoFuncBold              DontEnum|Function       0
    125   fixed                 &stringProtoFuncFixed             DontEnum|Function       0
    126   italics               &stringProtoFuncItalics           DontEnum|Function       0
    127   strike                &stringProtoFuncStrike            DontEnum|Function       0
    128   sub                   &stringProtoFuncSub               DontEnum|Function       0
    129   sup                   &stringProtoFuncSup               DontEnum|Function       0
    130   fontcolor             &stringProtoFuncFontcolor         DontEnum|Function       1
    131   fontsize              &stringProtoFuncFontsize          DontEnum|Function       1
    132   anchor                &stringProtoFuncAnchor            DontEnum|Function       1
    133   link                  &stringProtoFuncLink              DontEnum|Function       1
     140  toString              stringProtoFuncToString          DontEnum|Function       0
     141  valueOf               stringProtoFuncValueOf           DontEnum|Function       0
     142  charAt                stringProtoFuncCharAt            DontEnum|Function       1
     143  charCodeAt            stringProtoFuncCharCodeAt        DontEnum|Function       1
     144  concat                stringProtoFuncConcat            DontEnum|Function       1
     145  indexOf               stringProtoFuncIndexOf           DontEnum|Function       1
     146  lastIndexOf           stringProtoFuncLastIndexOf       DontEnum|Function       1
     147  match                 stringProtoFuncMatch             DontEnum|Function       1
     148  replace               stringProtoFuncReplace           DontEnum|Function       2
     149  search                stringProtoFuncSearch            DontEnum|Function       1
     150  slice                 stringProtoFuncSlice             DontEnum|Function       2
     151  split                 stringProtoFuncSplit             DontEnum|Function       2
     152  substr                stringProtoFuncSubstr            DontEnum|Function       2
     153  substring             stringProtoFuncSubstring         DontEnum|Function       2
     154  toLowerCase           stringProtoFuncToLowerCase       DontEnum|Function       0
     155  toUpperCase           stringProtoFuncToUpperCase       DontEnum|Function       0
     156  toLocaleLowerCase     stringProtoFuncToLocaleLowerCase DontEnum|Function       0
     157  toLocaleUpperCase     stringProtoFuncToLocaleUpperCase DontEnum|Function       0
     158  localeCompare         stringProtoFuncLocaleCompare     DontEnum|Function       1
     159
     160  big                   stringProtoFuncBig               DontEnum|Function       0
     161  small                 stringProtoFuncSmall             DontEnum|Function       0
     162  blink                 stringProtoFuncBlink             DontEnum|Function       0
     163  bold                  stringProtoFuncBold              DontEnum|Function       0
     164  fixed                 stringProtoFuncFixed             DontEnum|Function       0
     165  italics               stringProtoFuncItalics           DontEnum|Function       0
     166  strike                stringProtoFuncStrike            DontEnum|Function       0
     167  sub                   stringProtoFuncSub               DontEnum|Function       0
     168  sup                   stringProtoFuncSup               DontEnum|Function       0
     169  fontcolor             stringProtoFuncFontcolor         DontEnum|Function       1
     170  fontsize              stringProtoFuncFontsize          DontEnum|Function       1
     171  anchor                stringProtoFuncAnchor            DontEnum|Function       1
     172  link                  stringProtoFuncLink              DontEnum|Function       1
    134173@end
    135174*/
     
    268307{
    269308  UString source = sourceVal->value();
    270   JSObject *replacementFunction = 0;
     309  CallData callData;
    271310  UString replacementString;
    272311
    273   if (replacement->isObject() && replacement->toObject(exec)->implementsCall())
    274     replacementFunction = replacement->toObject(exec);
    275   else
     312  CallType callType = replacement->getCallData(callData);
     313  if (callType == CallTypeNone)
    276314    replacementString = replacement->toString(exec);
    277315
     
    304342
    305343      UString substitutedReplacement;
    306       if (replacementFunction) {
     344      if (callType != CallTypeNone) {
    307345          int completeMatchStart = ovector[0];
    308346          ArgList args;
     
    321359          args.append(sourceVal);
    322360
    323           substitutedReplacement = replacementFunction->callAsFunction(exec, exec->globalThisValue(), args)->toString(exec);
     361          substitutedReplacement = call(exec, replacement, callType, callData, exec->globalThisValue(), args)->toString(exec);
    324362      } else
    325363          substitutedReplacement = substituteBackreferences(replacementString, source, ovector, reg);
     
    363401    return sourceVal;
    364402 
    365   if (replacementFunction) {
     403  if (callType != CallTypeNone) {
    366404      ArgList args;
    367405     
     
    370408      args.append(sourceVal);
    371409     
    372       replacementString = replacementFunction->callAsFunction(exec, exec->globalThisValue(), args)->toString(exec);
     410      replacementString = call(exec, replacement, callType, callData, exec->globalThisValue(), args)->toString(exec);
    373411  }
    374412
     
    376414}
    377415
    378 JSValue* stringProtoFuncToString(ExecState* exec, JSObject* thisObj, const ArgList&)
    379 {
    380     if (!thisObj->inherits(&StringObject::info))
     416JSValue* stringProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     417{
     418    if (!thisValue->isObject(&StringObject::info))
    381419        return throwError(exec, TypeError);
    382420
    383     return static_cast<StringObject*>(thisObj)->internalValue();
    384 }
    385 
    386 JSValue* stringProtoFuncValueOf(ExecState* exec, JSObject* thisObj, const ArgList&)
    387 {
    388     if (!thisObj->inherits(&StringObject::info))
     421    return static_cast<StringObject*>(thisValue)->internalValue();
     422}
     423
     424JSValue* stringProtoFuncValueOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     425{
     426    if (!thisValue->isObject(&StringObject::info))
    389427        return throwError(exec, TypeError);
    390428
    391     return static_cast<StringObject*>(thisObj)->internalValue();
    392 }
    393 
    394 JSValue* stringProtoFuncCharAt(ExecState* exec, JSObject* thisObj, const ArgList& args)
    395 {
    396     // This optimizes the common case that thisObj is a StringObject
    397     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     429    return static_cast<StringObject*>(thisValue)->internalValue();
     430}
     431
     432JSValue* stringProtoFuncCharAt(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     433{
     434    // This optimizes the common case that thisObj is a StringObject
     435    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    398436    int len = s.size();
    399437
     
    408446}
    409447
    410 JSValue* stringProtoFuncCharCodeAt(ExecState* exec, JSObject* thisObj, const ArgList& args)
    411 {
    412     // This optimizes the common case that thisObj is a StringObject
    413     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     448JSValue* stringProtoFuncCharCodeAt(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     449{
     450    // This optimizes the common case that thisObj is a StringObject
     451    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    414452    int len = s.size();
    415453
     
    425463}
    426464
    427 JSValue* stringProtoFuncConcat(ExecState* exec, JSObject* thisObj, const ArgList& args)
    428 {
    429     // This optimizes the common case that thisObj is a StringObject
    430     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     465JSValue* stringProtoFuncConcat(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     466{
     467    // This optimizes the common case that thisObj is a StringObject
     468    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    431469
    432470    ArgList::const_iterator end = args.end();
     
    437475}
    438476
    439 JSValue* stringProtoFuncIndexOf(ExecState* exec, JSObject* thisObj, const ArgList& args)
    440 {
    441     // This optimizes the common case that thisObj is a StringObject
    442     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     477JSValue* stringProtoFuncIndexOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     478{
     479    // This optimizes the common case that thisObj is a StringObject
     480    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    443481    int len = s.size();
    444482
     
    454492}
    455493
    456 JSValue* stringProtoFuncLastIndexOf(ExecState* exec, JSObject* thisObj, const ArgList& args)
    457 {
    458     // This optimizes the common case that thisObj is a StringObject
    459     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     494JSValue* stringProtoFuncLastIndexOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     495{
     496    // This optimizes the common case that thisObj is a StringObject
     497    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    460498    int len = s.size();
    461499
     
    472510}
    473511
    474 JSValue* stringProtoFuncMatch(ExecState* exec, JSObject* thisObj, const ArgList& args)
    475 {
    476     // This optimizes the common case that thisObj is a StringObject
    477     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     512JSValue* stringProtoFuncMatch(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     513{
     514    // This optimizes the common case that thisObj is a StringObject
     515    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    478516
    479517    JSValue* a0 = args[0];
     
    521559        result = jsNull();
    522560      } else {
    523         result = exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, list);
     561        result = constructArray(exec, list);
    524562      }
    525563    }
     
    527565}
    528566
    529 JSValue* stringProtoFuncSearch(ExecState* exec, JSObject* thisObj, const ArgList& args)
    530 {
    531     // This optimizes the common case that thisObj is a StringObject
    532     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     567JSValue* stringProtoFuncSearch(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     568{
     569    // This optimizes the common case that thisObj is a StringObject
     570    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    533571
    534572    JSValue* a0 = args[0];
     
    553591}
    554592
    555 JSValue* stringProtoFuncReplace(ExecState* exec, JSObject* thisObj, const ArgList& args)
    556 {
    557     // This optimizes the common case that thisObj is a StringObject
    558     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
    559 
    560     JSString* sVal = thisObj->inherits(&StringObject::info) ?
    561       static_cast<StringObject*>(thisObj)->internalValue() :
     593JSValue* stringProtoFuncReplace(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     594{
     595    // This optimizes the common case that thisObj is a StringObject
     596    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
     597
     598    JSString* sVal = thisValue->isObject(&StringObject::info) ?
     599      static_cast<StringObject*>(thisValue)->internalValue() :
    562600      static_cast<JSString*>(jsString(exec, s));
    563601
     
    568606}
    569607
    570 JSValue* stringProtoFuncSlice(ExecState* exec, JSObject* thisObj, const ArgList& args)
    571 {
    572     // This optimizes the common case that thisObj is a StringObject
    573     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     608JSValue* stringProtoFuncSlice(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     609{
     610    // This optimizes the common case that thisObj is a StringObject
     611    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    574612    int len = s.size();
    575613
     
    593631}
    594632
    595 JSValue* stringProtoFuncSplit(ExecState* exec, JSObject* thisObj, const ArgList& args)
    596 {
    597     // This optimizes the common case that thisObj is a StringObject
    598     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     633JSValue* stringProtoFuncSplit(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     634{
     635    // This optimizes the common case that thisObj is a StringObject
     636    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    599637
    600638    JSValue* a0 = args[0];
    601639    JSValue* a1 = args[1];
    602640
    603     JSObject *constructor = exec->lexicalGlobalObject()->arrayConstructor();
    604     JSObject* res = static_cast<JSObject*>(constructor->construct(exec, exec->emptyList()));
     641    JSObject* res = constructEmptyArray(exec);
    605642    JSValue* result = res;
    606643    UString u = s;
     
    663700}
    664701
    665 JSValue* stringProtoFuncSubstr(ExecState* exec, JSObject* thisObj, const ArgList& args)
    666 {
    667     // This optimizes the common case that thisObj is a StringObject
    668     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     702JSValue* stringProtoFuncSubstr(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     703{
     704    // This optimizes the common case that thisObj is a StringObject
     705    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    669706    int len = s.size();
    670707
     
    688725}
    689726
    690 JSValue* stringProtoFuncSubstring(ExecState* exec, JSObject* thisObj, const ArgList& args)
    691 {
    692     // This optimizes the common case that thisObj is a StringObject
    693     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     727JSValue* stringProtoFuncSubstring(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     728{
     729    // This optimizes the common case that thisObj is a StringObject
     730    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    694731    int len = s.size();
    695732
     
    721758}
    722759
    723 JSValue* stringProtoFuncToLowerCase(ExecState* exec, JSObject* thisObj, const ArgList&)
    724 {
    725     // This optimizes the common case that thisObj is a StringObject
    726     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     760JSValue* stringProtoFuncToLowerCase(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     761{
     762    // This optimizes the common case that thisObj is a StringObject
     763    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    727764   
    728     JSString* sVal = thisObj->inherits(&StringObject::info)
    729         ? static_cast<StringObject*>(thisObj)->internalValue()
     765    JSString* sVal = thisValue->isObject(&StringObject::info)
     766        ? static_cast<StringObject*>(thisValue)->internalValue()
    730767        : static_cast<JSString*>(jsString(exec, s));
    731768    int ssize = s.size();
     
    746783}
    747784
    748 JSValue* stringProtoFuncToUpperCase(ExecState* exec, JSObject* thisObj, const ArgList&)
    749 {
    750     // This optimizes the common case that thisObj is a StringObject
    751     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
    752 
    753     JSString* sVal = thisObj->inherits(&StringObject::info)
    754         ? static_cast<StringObject*>(thisObj)->internalValue()
     785JSValue* stringProtoFuncToUpperCase(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     786{
     787    // This optimizes the common case that thisObj is a StringObject
     788    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
     789
     790    JSString* sVal = thisValue->isObject(&StringObject::info)
     791        ? static_cast<StringObject*>(thisValue)->internalValue()
    755792        : static_cast<JSString*>(jsString(exec, s));
    756793    int ssize = s.size();
     
    771808}
    772809
    773 JSValue* stringProtoFuncToLocaleLowerCase(ExecState* exec, JSObject* thisObj, const ArgList&)
    774 {
    775     // This optimizes the common case that thisObj is a StringObject
    776     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     810JSValue* stringProtoFuncToLocaleLowerCase(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     811{
     812    // This optimizes the common case that thisObj is a StringObject
     813    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    777814   
    778815    // FIXME: See http://www.unicode.org/Public/UNIDATA/SpecialCasing.txt for locale-sensitive mappings that aren't implemented.
    779     JSString* sVal = thisObj->inherits(&StringObject::info)
    780         ? static_cast<StringObject*>(thisObj)->internalValue()
     816    JSString* sVal = thisValue->isObject(&StringObject::info)
     817        ? static_cast<StringObject*>(thisValue)->internalValue()
    781818        : static_cast<JSString*>(jsString(exec, s));
    782819    int ssize = s.size();
     
    797834}
    798835
    799 JSValue* stringProtoFuncToLocaleUpperCase(ExecState* exec, JSObject* thisObj, const ArgList&)
    800 {
    801     // This optimizes the common case that thisObj is a StringObject
    802     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
    803 
    804     JSString* sVal = thisObj->inherits(&StringObject::info)
    805         ? static_cast<StringObject*>(thisObj)->internalValue()
     836JSValue* stringProtoFuncToLocaleUpperCase(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     837{
     838    // This optimizes the common case that thisObj is a StringObject
     839    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
     840
     841    JSString* sVal = thisValue->isObject(&StringObject::info)
     842        ? static_cast<StringObject*>(thisValue)->internalValue()
    806843        : static_cast<JSString*>(jsString(exec, s));
    807844    int ssize = s.size();
     
    822859}
    823860
    824 JSValue* stringProtoFuncLocaleCompare(ExecState* exec, JSObject* thisObj, const ArgList& args)
     861JSValue* stringProtoFuncLocaleCompare(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
    825862{
    826863    if (args.size() < 1)
     
    828865
    829866    // This optimizes the common case that thisObj is a StringObject
    830     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     867    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    831868    JSValue* a0 = args[0];
    832869    return jsNumber(exec, localeCompare(s, a0->toString(exec)));
    833870}
    834871
    835 JSValue* stringProtoFuncBig(ExecState* exec, JSObject* thisObj, const ArgList&)
    836 {
    837     // This optimizes the common case that thisObj is a StringObject
    838     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     872JSValue* stringProtoFuncBig(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     873{
     874    // This optimizes the common case that thisObj is a StringObject
     875    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    839876    return jsString(exec, "<big>" + s + "</big>");
    840877}
    841878
    842 JSValue* stringProtoFuncSmall(ExecState* exec, JSObject* thisObj, const ArgList&)
    843 {
    844     // This optimizes the common case that thisObj is a StringObject
    845     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     879JSValue* stringProtoFuncSmall(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     880{
     881    // This optimizes the common case that thisObj is a StringObject
     882    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    846883    return jsString(exec, "<small>" + s + "</small>");
    847884}
    848885
    849 JSValue* stringProtoFuncBlink(ExecState* exec, JSObject* thisObj, const ArgList&)
    850 {
    851     // This optimizes the common case that thisObj is a StringObject
    852     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     886JSValue* stringProtoFuncBlink(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     887{
     888    // This optimizes the common case that thisObj is a StringObject
     889    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    853890    return jsString(exec, "<blink>" + s + "</blink>");
    854891}
    855892
    856 JSValue* stringProtoFuncBold(ExecState* exec, JSObject* thisObj, const ArgList&)
    857 {
    858     // This optimizes the common case that thisObj is a StringObject
    859     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     893JSValue* stringProtoFuncBold(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     894{
     895    // This optimizes the common case that thisObj is a StringObject
     896    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    860897    return jsString(exec, "<b>" + s + "</b>");
    861898}
    862899
    863 JSValue* stringProtoFuncFixed(ExecState* exec, JSObject* thisObj, const ArgList&)
    864 {
    865     // This optimizes the common case that thisObj is a StringObject
    866     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     900JSValue* stringProtoFuncFixed(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     901{
     902    // This optimizes the common case that thisObj is a StringObject
     903    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    867904    return jsString(exec, "<tt>" + s + "</tt>");
    868905}
    869906
    870 JSValue* stringProtoFuncItalics(ExecState* exec, JSObject* thisObj, const ArgList&)
    871 {
    872     // This optimizes the common case that thisObj is a StringObject
    873     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     907JSValue* stringProtoFuncItalics(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     908{
     909    // This optimizes the common case that thisObj is a StringObject
     910    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    874911    return jsString(exec, "<i>" + s + "</i>");
    875912}
    876913
    877 JSValue* stringProtoFuncStrike(ExecState* exec, JSObject* thisObj, const ArgList&)
    878 {
    879     // This optimizes the common case that thisObj is a StringObject
    880     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     914JSValue* stringProtoFuncStrike(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     915{
     916    // This optimizes the common case that thisObj is a StringObject
     917    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    881918    return jsString(exec, "<strike>" + s + "</strike>");
    882919}
    883920
    884 JSValue* stringProtoFuncSub(ExecState* exec, JSObject* thisObj, const ArgList&)
    885 {
    886     // This optimizes the common case that thisObj is a StringObject
    887     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     921JSValue* stringProtoFuncSub(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     922{
     923    // This optimizes the common case that thisObj is a StringObject
     924    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    888925    return jsString(exec, "<sub>" + s + "</sub>");
    889926}
    890927
    891 JSValue* stringProtoFuncSup(ExecState* exec, JSObject* thisObj, const ArgList&)
    892 {
    893     // This optimizes the common case that thisObj is a StringObject
    894     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     928JSValue* stringProtoFuncSup(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
     929{
     930    // This optimizes the common case that thisObj is a StringObject
     931    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    895932    return jsString(exec, "<sup>" + s + "</sup>");
    896933}
    897934
    898 JSValue* stringProtoFuncFontcolor(ExecState* exec, JSObject* thisObj, const ArgList& args)
    899 {
    900     // This optimizes the common case that thisObj is a StringObject
    901     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     935JSValue* stringProtoFuncFontcolor(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     936{
     937    // This optimizes the common case that thisObj is a StringObject
     938    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    902939    JSValue* a0 = args[0];
    903940    return jsString(exec, "<font color=\"" + a0->toString(exec) + "\">" + s + "</font>");
    904941}
    905942
    906 JSValue* stringProtoFuncFontsize(ExecState* exec, JSObject* thisObj, const ArgList& args)
    907 {
    908     // This optimizes the common case that thisObj is a StringObject
    909     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     943JSValue* stringProtoFuncFontsize(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     944{
     945    // This optimizes the common case that thisObj is a StringObject
     946    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    910947    JSValue* a0 = args[0];
    911948    return jsString(exec, "<font size=\"" + a0->toString(exec) + "\">" + s + "</font>");
    912949}
    913950
    914 JSValue* stringProtoFuncAnchor(ExecState* exec, JSObject* thisObj, const ArgList& args)
    915 {
    916     // This optimizes the common case that thisObj is a StringObject
    917     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     951JSValue* stringProtoFuncAnchor(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     952{
     953    // This optimizes the common case that thisObj is a StringObject
     954    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    918955    JSValue* a0 = args[0];
    919956    return jsString(exec, "<a name=\"" + a0->toString(exec) + "\">" + s + "</a>");
    920957}
    921958
    922 JSValue* stringProtoFuncLink(ExecState* exec, JSObject* thisObj, const ArgList& args)
    923 {
    924     // This optimizes the common case that thisObj is a StringObject
    925     UString s = thisObj->inherits(&StringObject::info) ? static_cast<StringObject*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     959JSValue* stringProtoFuncLink(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
     960{
     961    // This optimizes the common case that thisObj is a StringObject
     962    UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);
    926963    JSValue* a0 = args[0];
    927964    return jsString(exec, "<a href=\"" + a0->toString(exec) + "\">" + s + "</a>");
     
    929966
    930967// ------------------------------ StringConstructor ------------------------------
     968
     969static JSValue* stringFromCharCode(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
     970{
     971    UString s;
     972    if (args.size()) {
     973        UChar* buf = static_cast<UChar*>(fastMalloc(args.size() * sizeof(UChar)));
     974        UChar* p = buf;
     975        ArgList::const_iterator end = args.end();
     976        for (ArgList::const_iterator it = args.begin(); it != end; ++it)
     977          *p++ = static_cast<UChar>((*it)->toUInt32(exec));
     978        s = UString(buf, args.size(), false);
     979    } else
     980        s = "";
     981
     982    return jsString(exec, s);
     983}
    931984
    932985StringConstructor::StringConstructor(ExecState* exec, FunctionPrototype* funcProto, StringPrototype* stringProto)
     
    934987{
    935988  // ECMA 15.5.3.1 String.prototype
    936   putDirect(exec->propertyNames().prototype, stringProto, DontEnum|DontDelete|ReadOnly);
    937 
    938   putDirectFunction(new (exec) StringConstructorFunction(exec, funcProto, exec->propertyNames().fromCharCode), DontEnum);
     989  putDirect(exec->propertyNames().prototype, stringProto, ReadOnly | DontEnum | DontDelete);
     990
     991  // ECMA 15.5.3.2 fromCharCode()
     992  putDirectFunction(new (exec) PrototypeFunction(exec, funcProto, 1, exec->propertyNames().fromCharCode, stringFromCharCode), DontEnum);
    939993
    940994  // no. of arguments for constructor
    941   putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly|DontDelete|DontEnum);
    942 }
    943 
    944 
    945 ConstructType StringConstructor::getConstructData(ConstructData&)
    946 {
     995  putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontEnum | DontDelete);
     996}
     997
     998// ECMA 15.5.2
     999static JSObject* constructWithStringConstructor(ExecState* exec, JSObject*, const ArgList& args)
     1000{
     1001    JSObject* prototype = exec->lexicalGlobalObject()->stringPrototype();
     1002    if (args.isEmpty())
     1003        return new (exec) StringObject(exec, prototype);
     1004    return new (exec) StringObject(exec, prototype, args[0]->toString(exec));
     1005}
     1006
     1007ConstructType StringConstructor::getConstructData(ConstructData& constructData)
     1008{
     1009    constructData.native.function = constructWithStringConstructor;
    9471010    return ConstructTypeNative;
    9481011}
    9491012
    950 // ECMA 15.5.2
    951 JSObject* StringConstructor::construct(ExecState* exec, const ArgList& args)
    952 {
    953   JSObject* proto = exec->lexicalGlobalObject()->stringPrototype();
    954   if (!args.size())
    955     return new (exec) StringObject(exec, proto);
    956   return new (exec) StringObject(exec, proto, args[0]->toString(exec));
    957 }
    958 
    9591013// ECMA 15.5.1
    960 JSValue *StringConstructor::callAsFunction(ExecState *exec, JSObject* /*thisObj*/, const ArgList &args)
    961 {
    962   if (args.isEmpty())
    963     return jsString(exec, "");
    964   else {
    965     JSValue *v = args[0];
    966     return jsString(exec, v->toString(exec));
    967   }
    968 }
    969 
    970 // ------------------------------ StringConstructorFunction --------------------------
    971 
    972 // ECMA 15.5.3.2 fromCharCode()
    973 StringConstructorFunction::StringConstructorFunction(ExecState* exec, FunctionPrototype* funcProto, const Identifier& name)
    974   : InternalFunction(funcProto, name)
    975 {
    976   putDirect(exec->propertyNames().length, jsNumber(exec, 1), DontDelete|ReadOnly|DontEnum);
    977 }
    978 
    979 JSValue *StringConstructorFunction::callAsFunction(ExecState *exec, JSObject* /*thisObj*/, const ArgList &args)
    980 {
    981   UString s;
    982   if (args.size()) {
    983     UChar *buf = static_cast<UChar *>(fastMalloc(args.size() * sizeof(UChar)));
    984     UChar *p = buf;
    985     ArgList::const_iterator end = args.end();
    986     for (ArgList::const_iterator it = args.begin(); it != end; ++it) {
    987       unsigned short u = static_cast<unsigned short>((*it)->toUInt32(exec));
    988       *p++ = UChar(u);
    989     }
    990     s = UString(buf, args.size(), false);
    991   } else
    992     s = "";
    993 
    994   return jsString(exec, s);
     1014static JSValue* callStringConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
     1015{
     1016    if (args.isEmpty())
     1017        return jsString(exec, "");
     1018    return jsString(exec, args[0]->toString(exec));
     1019}
     1020
     1021CallType StringConstructor::getCallData(CallData& callData)
     1022{
     1023    callData.native.function = callStringConstructor;
     1024    return CallTypeNative;
    9951025}
    9961026
  • trunk/JavaScriptCore/kjs/string_object.h

    r34659 r34754  
    8080   * @internal
    8181   *
    82    * Functions to implement all methods that are properties of the
    83    * String.prototype object
    84    */
    85 
    86   JSValue* stringProtoFuncToString(ExecState*, JSObject*, const ArgList&);
    87   JSValue* stringProtoFuncValueOf(ExecState*, JSObject*, const ArgList&);
    88   JSValue* stringProtoFuncCharAt(ExecState*, JSObject*, const ArgList&);
    89   JSValue* stringProtoFuncCharCodeAt(ExecState*, JSObject*, const ArgList&);
    90   JSValue* stringProtoFuncConcat(ExecState*, JSObject*, const ArgList&);
    91   JSValue* stringProtoFuncIndexOf(ExecState*, JSObject*, const ArgList&);
    92   JSValue* stringProtoFuncLastIndexOf(ExecState*, JSObject*, const ArgList&);
    93   JSValue* stringProtoFuncMatch(ExecState*, JSObject*, const ArgList&);
    94   JSValue* stringProtoFuncReplace(ExecState*, JSObject*, const ArgList&);
    95   JSValue* stringProtoFuncSearch(ExecState*, JSObject*, const ArgList&);
    96   JSValue* stringProtoFuncSlice(ExecState*, JSObject*, const ArgList&);
    97   JSValue* stringProtoFuncSplit(ExecState*, JSObject*, const ArgList&);
    98   JSValue* stringProtoFuncSubstr(ExecState*, JSObject*, const ArgList&);
    99   JSValue* stringProtoFuncSubstring(ExecState*, JSObject*, const ArgList&);
    100   JSValue* stringProtoFuncToLowerCase(ExecState*, JSObject*, const ArgList&);
    101   JSValue* stringProtoFuncToUpperCase(ExecState*, JSObject*, const ArgList&);
    102   JSValue* stringProtoFuncToLocaleLowerCase(ExecState*, JSObject*, const ArgList&);
    103   JSValue* stringProtoFuncToLocaleUpperCase(ExecState*, JSObject*, const ArgList&);
    104   JSValue* stringProtoFuncLocaleCompare(ExecState*, JSObject*, const ArgList&);
    105 
    106   JSValue* stringProtoFuncBig(ExecState*, JSObject*, const ArgList&);
    107   JSValue* stringProtoFuncSmall(ExecState*, JSObject*, const ArgList&);
    108   JSValue* stringProtoFuncBlink(ExecState*, JSObject*, const ArgList&);
    109   JSValue* stringProtoFuncBold(ExecState*, JSObject*, const ArgList&);
    110   JSValue* stringProtoFuncFixed(ExecState*, JSObject*, const ArgList&);
    111   JSValue* stringProtoFuncItalics(ExecState*, JSObject*, const ArgList&);
    112   JSValue* stringProtoFuncStrike(ExecState*, JSObject*, const ArgList&);
    113   JSValue* stringProtoFuncSub(ExecState*, JSObject*, const ArgList&);
    114   JSValue* stringProtoFuncSup(ExecState*, JSObject*, const ArgList&);
    115   JSValue* stringProtoFuncFontcolor(ExecState*, JSObject*, const ArgList&);
    116   JSValue* stringProtoFuncFontsize(ExecState*, JSObject*, const ArgList&);
    117   JSValue* stringProtoFuncAnchor(ExecState*, JSObject*, const ArgList&);
    118   JSValue* stringProtoFuncLink(ExecState*, JSObject*, const ArgList&);
    119 
    120   /**
    121    * @internal
    122    *
    12382   * The initial value of the the global variable's "String" property
    12483   */
     
    12685  public:
    12786    StringConstructor(ExecState*, FunctionPrototype*, StringPrototype*);
    128 
    12987    virtual ConstructType getConstructData(ConstructData&);
    130     virtual JSObject* construct(ExecState*, const ArgList&);
    131 
    132     virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const ArgList& args);
     88    virtual CallType getCallData(CallData&);
    13389  };
    13490
     
    14298  public:
    14399    StringConstructorFunction(ExecState*, FunctionPrototype*, const Identifier&);
    144     virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const ArgList& args);
     100    virtual CallType getCallData(CallData&);
    145101  };
    146102
Note: See TracChangeset for help on using the changeset viewer.