JavaScriptCore:
Rubber stamped by Maciej.
- fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4313
eliminate KJS::Value and KJS::Object smart pointer wrappers (for simplicity and speed)
* JavaScriptCore.xcodeproj/project.pbxproj: Removed object_wrapper.h.
Global replaces and other wonderful stuff.
* bindings/NP_jsobject.cpp:
(_NPN_Invoke):
(_NPN_Evaluate):
(_NPN_GetProperty):
(_NPN_SetProperty):
(_NPN_HasMethod):
(_NPN_SetException):
* bindings/c/c_instance.cpp:
(KJS::Bindings::CInstance::CInstance):
(KJS::Bindings::CInstance::invokeMethod):
(KJS::Bindings::CInstance::invokeDefaultMethod):
(KJS::Bindings::CInstance::defaultValue):
(KJS::Bindings::CInstance::stringValue):
(KJS::Bindings::CInstance::numberValue):
(KJS::Bindings::CInstance::booleanValue):
(KJS::Bindings::CInstance::valueOf):
* bindings/c/c_instance.h:
* bindings/c/c_runtime.cpp:
(CField::valueFromInstance):
(CField::setValueToInstance):
* bindings/c/c_runtime.h:
* bindings/c/c_utility.cpp:
(convertNPStringToUTF16):
(convertUTF8ToUTF16):
(coerceValueToNPVariantStringType):
(convertValueToNPVariant):
(convertNPVariantToValue):
* bindings/c/c_utility.h:
* bindings/jni/jni_instance.cpp:
(JavaInstance::stringValue):
(JavaInstance::numberValue):
(JavaInstance::booleanValue):
(JavaInstance::invokeMethod):
(JavaInstance::invokeDefaultMethod):
(JavaInstance::defaultValue):
(JavaInstance::valueOf):
* bindings/jni/jni_instance.h:
* bindings/jni/jni_jsobject.cpp:
(JSObject::invoke):
(JSObject::call):
(JSObject::eval):
(JSObject::getMember):
(JSObject::getSlot):
(JSObject::toString):
(JSObject::convertValueToJObject):
(JSObject::convertJObjectToValue):
(JSObject::listFromJArray):
* bindings/jni/jni_jsobject.h:
* bindings/jni/jni_objc.mm:
(KJS::Bindings::dispatchJNICall):
* bindings/jni/jni_runtime.cpp:
(JavaArray::convertJObjectToArray):
(JavaField::dispatchValueFromInstance):
(JavaField::valueFromInstance):
(JavaField::dispatchSetValueToInstance):
(JavaField::setValueToInstance):
(JavaArray::setValueAt):
(JavaArray::valueAt):
* bindings/jni/jni_runtime.h:
(KJS::Bindings::JavaString::ustring):
* bindings/jni/jni_utility.cpp:
(KJS::Bindings::getJavaVM):
(KJS::Bindings::getJNIEnv):
(KJS::Bindings::getMethodID):
(KJS::Bindings::callJNIVoidMethod):
(KJS::Bindings::callJNIObjectMethod):
(KJS::Bindings::callJNIBooleanMethod):
(KJS::Bindings::callJNIStaticBooleanMethod):
(KJS::Bindings::callJNIByteMethod):
(KJS::Bindings::callJNICharMethod):
(KJS::Bindings::callJNIShortMethod):
(KJS::Bindings::callJNIIntMethod):
(KJS::Bindings::callJNILongMethod):
(KJS::Bindings::callJNIFloatMethod):
(KJS::Bindings::callJNIDoubleMethod):
(KJS::Bindings::callJNIVoidMethodA):
(KJS::Bindings::callJNIObjectMethodA):
(KJS::Bindings::callJNIByteMethodA):
(KJS::Bindings::callJNICharMethodA):
(KJS::Bindings::callJNIShortMethodA):
(KJS::Bindings::callJNIIntMethodA):
(KJS::Bindings::callJNILongMethodA):
(KJS::Bindings::callJNIFloatMethodA):
(KJS::Bindings::callJNIDoubleMethodA):
(KJS::Bindings::callJNIBooleanMethodA):
(KJS::Bindings::callJNIVoidMethodIDA):
(KJS::Bindings::callJNIObjectMethodIDA):
(KJS::Bindings::callJNIByteMethodIDA):
(KJS::Bindings::callJNICharMethodIDA):
(KJS::Bindings::callJNIShortMethodIDA):
(KJS::Bindings::callJNIIntMethodIDA):
(KJS::Bindings::callJNILongMethodIDA):
(KJS::Bindings::callJNIFloatMethodIDA):
(KJS::Bindings::callJNIDoubleMethodIDA):
(KJS::Bindings::callJNIBooleanMethodIDA):
(KJS::Bindings::getCharactersFromJString):
(KJS::Bindings::releaseCharactersForJString):
(KJS::Bindings::getCharactersFromJStringInEnv):
(KJS::Bindings::releaseCharactersForJStringInEnv):
(KJS::Bindings::getUCharactersFromJStringInEnv):
(KJS::Bindings::releaseUCharactersForJStringInEnv):
(KJS::Bindings::JNITypeFromClassName):
(KJS::Bindings::signatureFromPrimitiveType):
(KJS::Bindings::JNITypeFromPrimitiveType):
(KJS::Bindings::getJNIField):
(KJS::Bindings::convertValueToJValue):
* bindings/jni/jni_utility.h:
* bindings/objc/WebScriptObject.mm:
(_didExecute):
(-[WebScriptObject _initializeWithObjectImp:originExecutionContext:Bindings::executionContext:Bindings::]):
(-[WebScriptObject _initWithObjectImp:originExecutionContext:Bindings::executionContext:Bindings::]):
(-[WebScriptObject _imp]):
(-[WebScriptObject _executionContext]):
(-[WebScriptObject _setExecutionContext:]):
(-[WebScriptObject _originExecutionContext]):
(-[WebScriptObject _setOriginExecutionContext:]):
(+[WebScriptObject throwException:]):
(listFromNSArray):
(-[WebScriptObject callWebScriptMethod:withArguments:]):
(-[WebScriptObject evaluateWebScript:]):
(-[WebScriptObject setValue:forKey:]):
(-[WebScriptObject valueForKey:]):
(-[WebScriptObject removeWebScriptKey:]):
(-[WebScriptObject stringRepresentation]):
(-[WebScriptObject webScriptValueAtIndex:]):
(-[WebScriptObject setException:]):
(+[WebScriptObject _convertValueToObjcValue:originExecutionContext:executionContext:Bindings::]):
* bindings/objc/WebScriptObjectPrivate.h:
* bindings/objc/objc_class.h:
* bindings/objc/objc_class.mm:
(KJS::Bindings::ObjcClass::fallbackObject):
* bindings/objc/objc_instance.h:
* bindings/objc/objc_instance.mm:
(ObjcInstance::invokeMethod):
(ObjcInstance::invokeDefaultMethod):
(ObjcInstance::setValueOfField):
(ObjcInstance::setValueOfUndefinedField):
(ObjcInstance::getValueOfField):
(ObjcInstance::getValueOfUndefinedField):
(ObjcInstance::defaultValue):
(ObjcInstance::stringValue):
(ObjcInstance::numberValue):
(ObjcInstance::booleanValue):
(ObjcInstance::valueOf):
* bindings/objc/objc_runtime.h:
* bindings/objc/objc_runtime.mm:
(ObjcField::valueFromInstance):
(convertValueToObjcObject):
(ObjcField::setValueToInstance):
(ObjcArray::setValueAt):
(ObjcArray::valueAt):
(ObjcFallbackObjectImp::put):
(ObjcFallbackObjectImp::callAsFunction):
(ObjcFallbackObjectImp::defaultValue):
* bindings/objc/objc_utility.h:
* bindings/objc/objc_utility.mm:
(Bindings::JSMethodNameToObjCMethodName):
(Bindings::convertValueToObjcValue):
(Bindings::convertNSStringToString):
(Bindings::convertObjcValueToValue):
(Bindings::objcValueTypeForType):
(Bindings::createObjcInstanceForValue):
* bindings/runtime.cpp:
(Instance::getValueOfField):
(Instance::setValueOfField):
(Instance::createRuntimeObject):
(Instance::createLanguageInstanceForValue):
* bindings/runtime.h:
(KJS::Bindings::Constructor::~Constructor):
(KJS::Bindings::Field::~Field):
(KJS::Bindings::MethodList::MethodList):
(KJS::Bindings::Class::fallbackObject):
(KJS::Bindings::Class::~Class):
(KJS::Bindings::Instance::Instance):
(KJS::Bindings::Instance::getValueOfUndefinedField):
(KJS::Bindings::Instance::supportsSetValueOfUndefinedField):
(KJS::Bindings::Instance::setValueOfUndefinedField):
(KJS::Bindings::Instance::valueOf):
(KJS::Bindings::Instance::setExecutionContext):
(KJS::Bindings::Instance::~Instance):
(KJS::Bindings::Array::~Array):
* bindings/runtime_array.cpp:
(RuntimeArrayImp::RuntimeArrayImp):
(RuntimeArrayImp::lengthGetter):
(RuntimeArrayImp::indexGetter):
(RuntimeArrayImp::put):
* bindings/runtime_array.h:
* bindings/runtime_method.cpp:
(RuntimeMethodImp::lengthGetter):
(RuntimeMethodImp::callAsFunction):
* bindings/runtime_method.h:
* bindings/runtime_object.cpp:
(RuntimeObjectImp::fallbackObjectGetter):
(RuntimeObjectImp::fieldGetter):
(RuntimeObjectImp::methodGetter):
(RuntimeObjectImp::getOwnPropertySlot):
(RuntimeObjectImp::put):
(RuntimeObjectImp::defaultValue):
(RuntimeObjectImp::callAsFunction):
* bindings/runtime_object.h:
* kjs/array_instance.h:
* kjs/array_object.cpp:
(ArrayInstanceImp::ArrayInstanceImp):
(ArrayInstanceImp::lengthGetter):
(ArrayInstanceImp::getOwnPropertySlot):
(ArrayInstanceImp::put):
(ArrayInstanceImp::propList):
(ArrayInstanceImp::setLength):
(compareByStringForQSort):
(compareWithCompareFunctionForQSort):
(ArrayInstanceImp::sort):
(ArrayInstanceImp::pushUndefinedObjectsToEnd):
(ArrayPrototypeImp::ArrayPrototypeImp):
(ArrayProtoFuncImp::ArrayProtoFuncImp):
(ArrayProtoFuncImp::callAsFunction):
(ArrayObjectImp::ArrayObjectImp):
(ArrayObjectImp::construct):
(ArrayObjectImp::callAsFunction):
* kjs/array_object.h:
* kjs/bool_object.cpp:
(BooleanPrototypeImp::BooleanPrototypeImp):
(BooleanProtoFuncImp::BooleanProtoFuncImp):
(BooleanProtoFuncImp::callAsFunction):
(BooleanObjectImp::BooleanObjectImp):
(BooleanObjectImp::construct):
(BooleanObjectImp::callAsFunction):
* kjs/bool_object.h:
* kjs/collector.cpp:
(KJS::Collector::markStackObjectsConservatively):
(KJS::Collector::collect):
(KJS::className):
* kjs/completion.h:
(KJS::Completion::Completion):
(KJS::Completion::value):
(KJS::Completion::isValueCompletion):
* kjs/context.h:
(KJS::ContextImp::variableObject):
(KJS::ContextImp::setVariableObject):
(KJS::ContextImp::thisValue):
(KJS::ContextImp::activationObject):
(KJS::ContextImp::pushScope):
* kjs/date_object.cpp:
(formatLocaleDate):
(KJS::timeFromArgs):
(KJS::DatePrototypeImp::DatePrototypeImp):
(KJS::DateProtoFuncImp::DateProtoFuncImp):
(KJS::DateProtoFuncImp::callAsFunction):
(KJS::DateObjectImp::DateObjectImp):
(KJS::DateObjectImp::construct):
(KJS::DateObjectImp::callAsFunction):
(KJS::DateObjectFuncImp::DateObjectFuncImp):
(KJS::DateObjectFuncImp::callAsFunction):
(KJS::parseDate):
(KJS::KRFCDate_parseDate):
(KJS::timeClip):
* kjs/date_object.h:
* kjs/debugger.cpp:
(Debugger::exception):
(Debugger::callEvent):
(Debugger::returnEvent):
* kjs/debugger.h:
* kjs/error_object.cpp:
(ErrorPrototypeImp::ErrorPrototypeImp):
(ErrorProtoFuncImp::ErrorProtoFuncImp):
(ErrorProtoFuncImp::callAsFunction):
(ErrorObjectImp::ErrorObjectImp):
(ErrorObjectImp::construct):
(ErrorObjectImp::callAsFunction):
(NativeErrorPrototypeImp::NativeErrorPrototypeImp):
(NativeErrorImp::NativeErrorImp):
(NativeErrorImp::construct):
(NativeErrorImp::callAsFunction):
* kjs/error_object.h:
* kjs/function.cpp:
(KJS::FunctionImp::FunctionImp):
(KJS::FunctionImp::callAsFunction):
(KJS::FunctionImp::processParameters):
(KJS::FunctionImp::argumentsGetter):
(KJS::FunctionImp::lengthGetter):
(KJS::FunctionImp::put):
(KJS::DeclaredFunctionImp::DeclaredFunctionImp):
(KJS::DeclaredFunctionImp::construct):
(KJS::ArgumentsImp::ArgumentsImp):
(KJS::ArgumentsImp::mappedIndexGetter):
(KJS::ArgumentsImp::put):
(KJS::ActivationImp::argumentsGetter):
(KJS::GlobalFuncImp::GlobalFuncImp):
(KJS::encode):
(KJS::decode):
(KJS::GlobalFuncImp::callAsFunction):
* kjs/function.h:
* kjs/function_object.cpp:
(FunctionPrototypeImp::FunctionPrototypeImp):
(FunctionPrototypeImp::callAsFunction):
(FunctionProtoFuncImp::FunctionProtoFuncImp):
(FunctionProtoFuncImp::callAsFunction):
(FunctionObjectImp::FunctionObjectImp):
(FunctionObjectImp::construct):
(FunctionObjectImp::callAsFunction):
* kjs/function_object.h:
* kjs/internal.cpp:
(KJS::UndefinedImp::toPrimitive):
(KJS::UndefinedImp::toObject):
(KJS::NullImp::toPrimitive):
(KJS::NullImp::toObject):
(KJS::BooleanImp::toPrimitive):
(KJS::BooleanImp::toObject):
(KJS::StringImp::toPrimitive):
(KJS::StringImp::toObject):
(KJS::NumberImp::toPrimitive):
(KJS::NumberImp::toObject):
(KJS::NumberImp::getUInt32):
(KJS::LabelStack::push):
(KJS::ContextImp::ContextImp):
(KJS::InterpreterImp::globalInit):
(KJS::InterpreterImp::globalClear):
(KJS::InterpreterImp::InterpreterImp):
(KJS::InterpreterImp::initGlobalObject):
(KJS::InterpreterImp::clear):
(KJS::InterpreterImp::mark):
(KJS::InterpreterImp::evaluate):
(KJS::InternalFunctionImp::hasInstance):
(KJS::roundValue):
(KJS::printInfo):
* kjs/internal.h:
(KJS::InterpreterImp::builtinObject):
(KJS::InterpreterImp::builtinFunction):
(KJS::InterpreterImp::builtinArray):
(KJS::InterpreterImp::builtinBoolean):
(KJS::InterpreterImp::builtinString):
(KJS::InterpreterImp::builtinNumber):
(KJS::InterpreterImp::builtinDate):
(KJS::InterpreterImp::builtinRegExp):
(KJS::InterpreterImp::builtinError):
(KJS::InterpreterImp::builtinObjectPrototype):
(KJS::InterpreterImp::builtinFunctionPrototype):
(KJS::InterpreterImp::builtinArrayPrototype):
(KJS::InterpreterImp::builtinBooleanPrototype):
(KJS::InterpreterImp::builtinStringPrototype):
(KJS::InterpreterImp::builtinNumberPrototype):
(KJS::InterpreterImp::builtinDatePrototype):
(KJS::InterpreterImp::builtinRegExpPrototype):
(KJS::InterpreterImp::builtinErrorPrototype):
(KJS::InterpreterImp::builtinEvalError):
(KJS::InterpreterImp::builtinRangeError):
(KJS::InterpreterImp::builtinReferenceError):
(KJS::InterpreterImp::builtinSyntaxError):
(KJS::InterpreterImp::builtinTypeError):
(KJS::InterpreterImp::builtinURIError):
(KJS::InterpreterImp::builtinEvalErrorPrototype):
(KJS::InterpreterImp::builtinRangeErrorPrototype):
(KJS::InterpreterImp::builtinReferenceErrorPrototype):
(KJS::InterpreterImp::builtinSyntaxErrorPrototype):
(KJS::InterpreterImp::builtinTypeErrorPrototype):
(KJS::InterpreterImp::builtinURIErrorPrototype):
* kjs/interpreter.cpp:
(Context::variableObject):
(Context::thisValue):
(Interpreter::Interpreter):
(Interpreter::globalObject):
(Interpreter::evaluate):
(Interpreter::builtinObject):
(Interpreter::builtinFunction):
(Interpreter::builtinArray):
(Interpreter::builtinBoolean):
(Interpreter::builtinString):
(Interpreter::builtinNumber):
(Interpreter::builtinDate):
(Interpreter::builtinRegExp):
(Interpreter::builtinError):
(Interpreter::builtinObjectPrototype):
(Interpreter::builtinFunctionPrototype):
(Interpreter::builtinArrayPrototype):
(Interpreter::builtinBooleanPrototype):
(Interpreter::builtinStringPrototype):
(Interpreter::builtinNumberPrototype):
(Interpreter::builtinDatePrototype):
(Interpreter::builtinRegExpPrototype):
(Interpreter::builtinErrorPrototype):
(Interpreter::builtinEvalError):
(Interpreter::builtinRangeError):
(Interpreter::builtinReferenceError):
(Interpreter::builtinSyntaxError):
(Interpreter::builtinTypeError):
(Interpreter::builtinURIError):
(Interpreter::builtinEvalErrorPrototype):
(Interpreter::builtinRangeErrorPrototype):
(Interpreter::builtinReferenceErrorPrototype):
(Interpreter::builtinSyntaxErrorPrototype):
(Interpreter::builtinTypeErrorPrototype):
(Interpreter::builtinURIErrorPrototype):
(Interpreter::createLanguageInstanceForValue):
* kjs/interpreter.h:
(KJS::Interpreter::isGlobalObject):
(KJS::ExecState::setException):
(KJS::ExecState::clearException):
(KJS::ExecState::exception):
(KJS::ExecState::hadException):
(KJS::ExecState::ExecState):
* kjs/list.cpp:
(KJS::List::at):
* kjs/list.h:
(KJS::List::operator[]):
(KJS::ListIterator::operator->):
(KJS::ListIterator::operator*):
(KJS::ListIterator::operator++):
(KJS::ListIterator::operator--):
* kjs/lookup.h:
(KJS::staticFunctionGetter):
(KJS::staticValueGetter):
(KJS::lookupPut):
(KJS::cacheGlobalObject):
* kjs/math_object.cpp:
(MathObjectImp::getValueProperty):
(MathFuncImp::MathFuncImp):
(MathFuncImp::callAsFunction):
* kjs/math_object.h:
* kjs/nodes.cpp:
(Node::evaluateReference):
(Node::throwError):
(Node::setExceptionDetailsIfNeeded):
(NullNode::evaluate):
(BooleanNode::evaluate):
(NumberNode::evaluate):
(StringNode::evaluate):
(RegExpNode::evaluate):
(ThisNode::evaluate):
(ResolveNode::evaluate):
(ResolveNode::evaluateReference):
(GroupNode::evaluate):
(ElementNode::evaluate):
(ArrayNode::evaluate):
(ObjectLiteralNode::evaluate):
(PropertyValueNode::evaluate):
(PropertyNode::evaluate):
(AccessorNode1::evaluate):
(AccessorNode1::evaluateReference):
(AccessorNode2::evaluate):
(AccessorNode2::evaluateReference):
(ArgumentListNode::evaluate):
(ArgumentListNode::evaluateList):
(ArgumentsNode::evaluate):
(NewExprNode::evaluate):
(FunctionCallNode::evaluate):
(PostfixNode::evaluate):
(DeleteNode::evaluate):
(VoidNode::evaluate):
(TypeOfNode::evaluate):
(PrefixNode::evaluate):
(UnaryPlusNode::evaluate):
(NegateNode::evaluate):
(BitwiseNotNode::evaluate):
(LogicalNotNode::evaluate):
(MultNode::evaluate):
(AddNode::evaluate):
(ShiftNode::evaluate):
(RelationalNode::evaluate):
(EqualNode::evaluate):
(BitOperNode::evaluate):
(BinaryLogicalNode::evaluate):
(ConditionalNode::evaluate):
(AssignNode::evaluate):
(CommaNode::evaluate):
(StatListNode::execute):
(AssignExprNode::evaluate):
(VarDeclNode::evaluate):
(VarDeclNode::processVarDecls):
(VarDeclListNode::evaluate):
(ExprStatementNode::execute):
(IfNode::execute):
(DoWhileNode::execute):
(WhileNode::execute):
(ForNode::execute):
(ForInNode::execute):
(ContinueNode::execute):
(BreakNode::execute):
(ReturnNode::execute):
(WithNode::execute):
(CaseClauseNode::evaluate):
(ClauseListNode::evaluate):
(CaseBlockNode::evaluate):
(CaseBlockNode::evalBlock):
(SwitchNode::execute):
(ThrowNode::execute):
(CatchNode::execute):
(TryNode::execute):
(ParameterNode::evaluate):
(FuncDeclNode::processFuncDecl):
(FuncExprNode::evaluate):
(SourceElementsNode::execute):
* kjs/nodes.h:
(KJS::StatementNode::evaluate):
* kjs/number_object.cpp:
(NumberPrototypeImp::NumberPrototypeImp):
(NumberProtoFuncImp::NumberProtoFuncImp):
(NumberProtoFuncImp::callAsFunction):
(NumberObjectImp::NumberObjectImp):
(NumberObjectImp::getValueProperty):
(NumberObjectImp::construct):
(NumberObjectImp::callAsFunction):
* kjs/number_object.h:
* kjs/object.cpp:
(KJS::ObjectImp::call):
(KJS::ObjectImp::mark):
(KJS::ObjectImp::classInfo):
(KJS::ObjectImp::get):
(KJS::ObjectImp::getProperty):
(KJS::ObjectImp::getPropertySlot):
(KJS::ObjectImp::put):
(KJS::ObjectImp::hasOwnProperty):
(KJS::ObjectImp::defaultValue):
(KJS::ObjectImp::findPropertyHashEntry):
(KJS::ObjectImp::construct):
(KJS::ObjectImp::callAsFunction):
(KJS::ObjectImp::hasInstance):
(KJS::ObjectImp::propList):
(KJS::ObjectImp::toPrimitive):
(KJS::ObjectImp::toNumber):
(KJS::ObjectImp::toString):
(KJS::ObjectImp::toObject):
(KJS::ObjectImp::putDirect):
(KJS::Error::create):
(KJS::error):
* kjs/object.h:
(KJS::):
(KJS::ObjectImp::getPropertySlot):
(KJS::AllocatedValueImp::isObject):
(KJS::ObjectImp::ObjectImp):
(KJS::ObjectImp::internalValue):
(KJS::ObjectImp::setInternalValue):
(KJS::ObjectImp::prototype):
(KJS::ObjectImp::setPrototype):
(KJS::ObjectImp::inherits):
* kjs/object_object.cpp:
(ObjectPrototypeImp::ObjectPrototypeImp):
(ObjectProtoFuncImp::ObjectProtoFuncImp):
(ObjectProtoFuncImp::callAsFunction):
(ObjectObjectImp::ObjectObjectImp):
(ObjectObjectImp::construct):
(ObjectObjectImp::callAsFunction):
* kjs/object_object.h:
* kjs/operations.cpp:
(KJS::equal):
(KJS::strictEqual):
(KJS::relation):
(KJS::add):
(KJS::mult):
* kjs/operations.h:
* kjs/property_map.cpp:
(KJS::PropertyMap::mark):
(KJS::PropertyMap::addEnumerablesToReferenceList):
(KJS::PropertyMap::addSparseArrayPropertiesToReferenceList):
(KJS::PropertyMap::save):
(KJS::PropertyMap::restore):
* kjs/property_map.h:
* kjs/property_slot.cpp:
(KJS::PropertySlot::undefinedGetter):
* kjs/property_slot.h:
(KJS::PropertySlot::getValue):
* kjs/protect.h:
(KJS::gcUnprotectNullTolerant):
(KJS::ProtectedValue::ProtectedValue):
(KJS::ProtectedValue::~ProtectedValue):
(KJS::ProtectedValue::operator=):
(KJS::ProtectedValue::operator ValueImp *):
(KJS::ProtectedValue::operator->):
* kjs/protected_object.h:
(KJS::ProtectedObject::ProtectedObject):
(KJS::ProtectedObject::operator=):
(KJS::ProtectedObject::operator ValueImp *):
(KJS::ProtectedObject::operator ObjectImp *):
(KJS::ProtectedObject::operator->):
(KJS::ProtectedReference::ProtectedReference):
(KJS::ProtectedReference::~ProtectedReference):
(KJS::ProtectedReference::operator=):
* kjs/protected_values.cpp:
(KJS::ProtectedValues::getProtectCount):
(KJS::ProtectedValues::increaseProtectCount):
(KJS::ProtectedValues::insert):
(KJS::ProtectedValues::decreaseProtectCount):
* kjs/protected_values.h:
* kjs/reference.cpp:
(KJS::Reference::Reference):
(KJS::Reference::makeValueReference):
(KJS::Reference::getBase):
(KJS::Reference::getValue):
(KJS::Reference::putValue):
(KJS::Reference::deleteValue):
* kjs/reference.h:
(KJS::Reference::baseIfMutable):
* kjs/regexp_object.cpp:
(RegExpPrototypeImp::RegExpPrototypeImp):
(RegExpProtoFuncImp::RegExpProtoFuncImp):
(RegExpProtoFuncImp::callAsFunction):
(RegExpObjectImp::RegExpObjectImp):
(RegExpObjectImp::arrayOfMatches):
(RegExpObjectImp::backrefGetter):
(RegExpObjectImp::construct):
(RegExpObjectImp::callAsFunction):
* kjs/regexp_object.h:
* kjs/string_object.cpp:
(StringInstanceImp::lengthGetter):
(StringInstanceImp::indexGetter):
(StringInstanceImp::getOwnPropertySlot):
(StringInstanceImp::put):
(StringPrototypeImp::StringPrototypeImp):
(StringProtoFuncImp::StringProtoFuncImp):
(regExpIsGlobal):
(replace):
(StringProtoFuncImp::callAsFunction):
(StringObjectImp::StringObjectImp):
(StringObjectImp::construct):
(StringObjectImp::callAsFunction):
(StringObjectFuncImp::StringObjectFuncImp):
(StringObjectFuncImp::callAsFunction):
* kjs/string_object.h:
* kjs/testkjs.cpp:
(TestFunctionImp::callAsFunction):
(VersionFunctionImp::callAsFunction):
(main):
* kjs/value.cpp:
(KJS::AllocatedValueImp::operator new):
(KJS::AllocatedValueImp::getUInt32):
(KJS::ValueImp::toInteger):
(KJS::ValueImp::toInt32):
(KJS::ValueImp::toUInt32):
(KJS::ValueImp::toUInt16):
(KJS::ValueImp::toObject):
(KJS::AllocatedValueImp::getBoolean):
(KJS::AllocatedValueImp::getNumber):
(KJS::AllocatedValueImp::getString):
(KJS::AllocatedValueImp::getObject):
(KJS::jsString):
(KJS::jsNumber):
(KJS::ConstantValues::init):
(KJS::ConstantValues::clear):
(KJS::ConstantValues::mark):
* kjs/value.h:
(KJS::):
(KJS::jsUndefined):
(KJS::jsNull):
(KJS::jsBoolean):
(KJS::jsNaN):
(KJS::ValueImp::ValueImp):
(KJS::ValueImp::~ValueImp):
(KJS::AllocatedValueImp::AllocatedValueImp):
(KJS::AllocatedValueImp::~AllocatedValueImp):
(KJS::AllocatedValueImp::isBoolean):
(KJS::AllocatedValueImp::isNumber):
(KJS::AllocatedValueImp::isString):
(KJS::AllocatedValueImp::isObject):
(KJS::AllocatedValueImp::marked):
(KJS::AllocatedValueImp::mark):
(KJS::ValueImp::downcast):
(KJS::ValueImp::isUndefined):
(KJS::ValueImp::isNull):
(KJS::ValueImp::isUndefinedOrNull):
(KJS::ValueImp::isBoolean):
(KJS::ValueImp::isNumber):
(KJS::ValueImp::isString):
(KJS::ValueImp::isObject):
(KJS::ValueImp::getBoolean):
(KJS::ValueImp::getNumber):
(KJS::ValueImp::getString):
(KJS::ValueImp::getObject):
(KJS::ValueImp::getUInt32):
(KJS::ValueImp::mark):
(KJS::ValueImp::marked):
(KJS::ValueImp::type):
(KJS::ValueImp::toPrimitive):
(KJS::ValueImp::toBoolean):
(KJS::ValueImp::toNumber):
(KJS::ValueImp::toString):
(KJS::jsZero):
(KJS::jsOne):
(KJS::jsTwo):
(KJS::Undefined):
(KJS::Null):
(KJS::Boolean):
(KJS::Number):
(KJS::String):
WebCore:
Rubber stamped by Maciej.
- fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4313
eliminate KJS::Value and KJS::Object smart pointer wrappers (for simplicity and speed)
* khtml/ecma/domparser.cpp:
(KJS::DOMParserConstructorImp::construct):
(KJS::DOMParserProtoFunc::callAsFunction):
* khtml/ecma/domparser.h:
* khtml/ecma/kjs_binding.cpp:
(KJS::ScriptInterpreter::ScriptInterpreter):
(KJS::ScriptInterpreter::isGlobalObject):
(KJS::ScriptInterpreter::createLanguageInstanceForValue):
(KJS::getStringOrNull):
(KJS::ValueToVariant):
(KJS::setDOMException):
* khtml/ecma/kjs_binding.h:
(KJS::DOMFunction::toPrimitive):
(KJS::cacheDOMObject):
* khtml/ecma/kjs_css.cpp:
(KJS::DOMCSSStyleDeclaration::indexGetter):
(KJS::DOMCSSStyleDeclaration::cssPropertyGetter):
(KJS::DOMCSSStyleDeclaration::getValueProperty):
(KJS::DOMCSSStyleDeclaration::put):
(KJS::DOMCSSStyleDeclarationProtoFunc::callAsFunction):
(KJS::DOMStyleSheet::getValueProperty):
(KJS::DOMStyleSheet::put):
(KJS::DOMStyleSheetList::getValueProperty):
(KJS::DOMStyleSheetList::indexGetter):
(KJS::DOMStyleSheetList::nameGetter):
(KJS::DOMStyleSheetListFunc::callAsFunction):
(KJS::DOMMediaList::getValueProperty):
(KJS::DOMMediaList::indexGetter):
(KJS::DOMMediaList::put):
(KJS::KJS::DOMMediaListProtoFunc::callAsFunction):
(KJS::DOMCSSStyleSheet::getValueProperty):
(KJS::DOMCSSStyleSheetProtoFunc::callAsFunction):
(KJS::DOMCSSRuleList::getValueProperty):
(KJS::DOMCSSRuleList::indexGetter):
(KJS::DOMCSSRuleListFunc::callAsFunction):
(KJS::DOMCSSRule::getValueProperty):
(KJS::DOMCSSRule::put):
(KJS::DOMCSSRule::putValueProperty):
(KJS::DOMCSSRuleFunc::callAsFunction):
(KJS::CSSRuleConstructor::getValueProperty):
(KJS::getCSSRuleConstructor):
(KJS::DOMCSSValue::getValueProperty):
(KJS::DOMCSSValue::put):
(KJS::getDOMCSSValue):
(KJS::CSSValueConstructor::getValueProperty):
(KJS::getCSSValueConstructor):
(KJS::DOMCSSPrimitiveValue::getValueProperty):
(KJS::DOMCSSPrimitiveValueProtoFunc::callAsFunction):
(KJS::CSSPrimitiveValueConstructor::getValueProperty):
(KJS::getCSSPrimitiveValueConstructor):
(KJS::DOMCSSValueList::getValueProperty):
(KJS::DOMCSSValueList::indexGetter):
(KJS::DOMCSSValueListFunc::callAsFunction):
(KJS::DOMRGBColor::getValueProperty):
(KJS::DOMRect::getValueProperty):
(KJS::DOMCounter::getValueProperty):
* khtml/ecma/kjs_css.h:
* khtml/ecma/kjs_dom.cpp:
(KJS::DOMNode::getValueProperty):
(KJS::DOMNode::put):
(KJS::DOMNode::putValueProperty):
(KJS::DOMNode::toPrimitive):
(KJS::DOMNode::getListener):
(KJS::DOMNodeProtoFunc::callAsFunction):
(KJS::DOMNodeList::toPrimitive):
(KJS::DOMNodeList::getValueProperty):
(KJS::DOMNodeList::indexGetter):
(KJS::DOMNodeList::nameGetter):
(KJS::DOMNodeList::callAsFunction):
(KJS::DOMNodeListFunc::DOMNodeListFunc):
(KJS::DOMNodeListFunc::callAsFunction):
(KJS::DOMAttr::getValueProperty):
(KJS::DOMAttr::put):
(KJS::DOMAttr::putValueProperty):
(KJS::DOMDocument::getValueProperty):
(KJS::DOMDocument::put):
(KJS::DOMDocument::putValueProperty):
(KJS::DOMDocumentProtoFunc::callAsFunction):
(KJS::DOMElement::getValueProperty):
(KJS::DOMElement::attributeGetter):
(KJS::DOMElement::getOwnPropertySlot):
(KJS::DOMElementProtoFunc::callAsFunction):
(KJS::DOMDOMImplementationProtoFunc::callAsFunction):
(KJS::DOMDocumentType::getValueProperty):
(KJS::DOMNamedNodeMap::lengthGetter):
(KJS::DOMNamedNodeMap::indexGetter):
(KJS::DOMNamedNodeMapProtoFunc::callAsFunction):
(KJS::DOMProcessingInstruction::getValueProperty):
(KJS::DOMProcessingInstruction::put):
(KJS::DOMNotation::getValueProperty):
(KJS::DOMEntity::getValueProperty):
(KJS::NodeConstructor::getValueProperty):
(KJS::DOMExceptionConstructor::getValueProperty):
(KJS::DOMNamedNodesCollection::lengthGetter):
(KJS::DOMNamedNodesCollection::indexGetter):
(KJS::DOMCharacterData::getValueProperty):
(KJS::DOMCharacterData::put):
(KJS::DOMCharacterDataProtoFunc::callAsFunction):
(KJS::DOMTextProtoFunc::callAsFunction):
* khtml/ecma/kjs_dom.h:
* khtml/ecma/kjs_events.cpp:
(KJS::JSAbstractEventListener::handleEvent):
(KJS::JSUnprotectedEventListener::JSUnprotectedEventListener):
(KJS::JSUnprotectedEventListener::~JSUnprotectedEventListener):
(KJS::JSUnprotectedEventListener::listenerObj):
(KJS::JSUnprotectedEventListener::windowObj):
(KJS::JSUnprotectedEventListener::mark):
(KJS::JSEventListener::JSEventListener):
(KJS::JSEventListener::~JSEventListener):
(KJS::JSEventListener::listenerObj):
(KJS::JSEventListener::windowObj):
(KJS::JSLazyEventListener::JSLazyEventListener):
(KJS::JSLazyEventListener::handleEvent):
(KJS::JSLazyEventListener::listenerObj):
(KJS::JSLazyEventListener::parseCode):
(KJS::getNodeEventListener):
(KJS::EventConstructor::getValueProperty):
(KJS::getEventConstructor):
(KJS::DOMEvent::getValueProperty):
(KJS::DOMEvent::put):
(KJS::DOMEvent::putValueProperty):
(KJS::DOMEventProtoFunc::callAsFunction):
(KJS::getDOMEvent):
(KJS::EventExceptionConstructor::getValueProperty):
(KJS::getEventExceptionConstructor):
(KJS::DOMUIEvent::getValueProperty):
(KJS::DOMUIEventProtoFunc::callAsFunction):
(KJS::DOMMouseEvent::getValueProperty):
(KJS::DOMMouseEventProtoFunc::callAsFunction):
(KJS::DOMKeyboardEvent::getValueProperty):
(KJS::DOMKeyboardEventProtoFunc::callAsFunction):
(KJS::MutationEventConstructor::getValueProperty):
(KJS::getMutationEventConstructor):
(KJS::DOMMutationEvent::getValueProperty):
(KJS::DOMMutationEventProtoFunc::callAsFunction):
(KJS::DOMWheelEvent::getValueProperty):
(KJS::DOMWheelEventProtoFunc::callAsFunction):
(KJS::stringOrUndefined):
(KJS::Clipboard::getValueProperty):
(KJS::Clipboard::put):
(KJS::Clipboard::putValueProperty):
(KJS::ClipboardProtoFunc::callAsFunction):
* khtml/ecma/kjs_events.h:
(KJS::JSAbstractEventListener::listenerObjImp):
* khtml/ecma/kjs_html.cpp:
(KJS::KJS::HTMLDocFunction::callAsFunction):
(KJS::HTMLDocument::namedItemGetter):
(KJS::HTMLDocument::getValueProperty):
(KJS::KJS::HTMLDocument::put):
(KJS::KJS::HTMLDocument::putValueProperty):
(KJS::HTMLElement::formIndexGetter):
(KJS::HTMLElement::formNameGetter):
(KJS::HTMLElement::selectIndexGetter):
(KJS::HTMLElement::framesetNameGetter):
(KJS::HTMLElement::frameWindowPropertyGetter):
(KJS::HTMLElement::runtimeObjectGetter):
(KJS::HTMLElement::runtimeObjectPropertyGetter):
(KJS::HTMLElement::getOwnPropertySlot):
(KJS::KJS::HTMLElement::implementsCall):
(KJS::KJS::HTMLElement::callAsFunction):
(KJS::HTMLElement::htmlGetter):
(KJS::HTMLElement::headGetter):
(KJS::HTMLElement::linkGetter):
(KJS::HTMLElement::titleGetter):
(KJS::HTMLElement::metaGetter):
(KJS::HTMLElement::baseGetter):
(KJS::HTMLElement::isIndexGetter):
(KJS::HTMLElement::styleGetter):
(KJS::HTMLElement::bodyGetter):
(KJS::HTMLElement::formGetter):
(KJS::HTMLElement::selectGetter):
(KJS::HTMLElement::optGroupGetter):
(KJS::HTMLElement::optionGetter):
(KJS::getInputSelectionStart):
(KJS::getInputSelectionEnd):
(KJS::HTMLElement::inputGetter):
(KJS::HTMLElement::textAreaGetter):
(KJS::HTMLElement::buttonGetter):
(KJS::HTMLElement::labelGetter):
(KJS::HTMLElement::fieldSetGetter):
(KJS::HTMLElement::legendGetter):
(KJS::HTMLElement::uListGetter):
(KJS::HTMLElement::oListGetter):
(KJS::HTMLElement::dListGetter):
(KJS::HTMLElement::dirGetter):
(KJS::HTMLElement::menuGetter):
(KJS::HTMLElement::liGetter):
(KJS::HTMLElement::divGetter):
(KJS::HTMLElement::paragraphGetter):
(KJS::HTMLElement::headingGetter):
(KJS::HTMLElement::blockQuoteGetter):
(KJS::HTMLElement::quoteGetter):
(KJS::HTMLElement::preGetter):
(KJS::HTMLElement::brGetter):
(KJS::HTMLElement::baseFontGetter):
(KJS::HTMLElement::fontGetter):
(KJS::HTMLElement::hrGetter):
(KJS::HTMLElement::modGetter):
(KJS::HTMLElement::anchorGetter):
(KJS::HTMLElement::imageGetter):
(KJS::HTMLElement::objectGetter):
(KJS::HTMLElement::paramGetter):
(KJS::HTMLElement::appletGetter):
(KJS::HTMLElement::mapGetter):
(KJS::HTMLElement::areaGetter):
(KJS::HTMLElement::scriptGetter):
(KJS::HTMLElement::tableGetter):
(KJS::HTMLElement::tableCaptionGetter):
(KJS::HTMLElement::tableColGetter):
(KJS::HTMLElement::tableSectionGetter):
(KJS::HTMLElement::tableRowGetter):
(KJS::HTMLElement::tableCellGetter):
(KJS::HTMLElement::frameSetGetter):
(KJS::HTMLElement::frameGetter):
(KJS::HTMLElement::iFrameGetter):
(KJS::HTMLElement::marqueeGetter):
(KJS::HTMLElement::getValueProperty):
(KJS::HTMLElementFunction::HTMLElementFunction):
(KJS::KJS::HTMLElementFunction::callAsFunction):
(KJS::KJS::HTMLElement::put):
(KJS::HTMLElement::htmlSetter):
(KJS::HTMLElement::headSetter):
(KJS::HTMLElement::linkSetter):
(KJS::HTMLElement::titleSetter):
(KJS::HTMLElement::metaSetter):
(KJS::HTMLElement::baseSetter):
(KJS::HTMLElement::isIndexSetter):
(KJS::HTMLElement::styleSetter):
(KJS::HTMLElement::bodySetter):
(KJS::HTMLElement::formSetter):
(KJS::HTMLElement::selectSetter):
(KJS::HTMLElement::optGroupSetter):
(KJS::HTMLElement::optionSetter):
(KJS::HTMLElement::inputSetter):
(KJS::HTMLElement::textAreaSetter):
(KJS::HTMLElement::buttonSetter):
(KJS::HTMLElement::labelSetter):
(KJS::HTMLElement::fieldSetSetter):
(KJS::HTMLElement::legendSetter):
(KJS::HTMLElement::uListSetter):
(KJS::HTMLElement::oListSetter):
(KJS::HTMLElement::dListSetter):
(KJS::HTMLElement::dirSetter):
(KJS::HTMLElement::menuSetter):
(KJS::HTMLElement::liSetter):
(KJS::HTMLElement::divSetter):
(KJS::HTMLElement::paragraphSetter):
(KJS::HTMLElement::headingSetter):
(KJS::HTMLElement::blockQuoteSetter):
(KJS::HTMLElement::quoteSetter):
(KJS::HTMLElement::preSetter):
(KJS::HTMLElement::brSetter):
(KJS::HTMLElement::baseFontSetter):
(KJS::HTMLElement::fontSetter):
(KJS::HTMLElement::hrSetter):
(KJS::HTMLElement::modSetter):
(KJS::HTMLElement::anchorSetter):
(KJS::HTMLElement::imageSetter):
(KJS::HTMLElement::objectSetter):
(KJS::HTMLElement::paramSetter):
(KJS::HTMLElement::appletSetter):
(KJS::HTMLElement::mapSetter):
(KJS::HTMLElement::areaSetter):
(KJS::HTMLElement::scriptSetter):
(KJS::HTMLElement::tableSetter):
(KJS::HTMLElement::tableCaptionSetter):
(KJS::HTMLElement::tableColSetter):
(KJS::HTMLElement::tableSectionSetter):
(KJS::HTMLElement::tableRowSetter):
(KJS::HTMLElement::tableCellSetter):
(KJS::HTMLElement::frameSetSetter):
(KJS::HTMLElement::frameSetter):
(KJS::HTMLElement::iFrameSetter):
(KJS::HTMLElement::marqueeSetter):
(KJS::HTMLElement::putValueProperty):
(KJS::HTMLCollection::lengthGetter):
(KJS::HTMLCollection::indexGetter):
(KJS::HTMLCollection::nameGetter):
(KJS::HTMLCollection::getOwnPropertySlot):
(KJS::KJS::HTMLCollection::callAsFunction):
(KJS::KJS::HTMLCollection::getNamedItems):
(KJS::KJS::HTMLCollectionProtoFunc::callAsFunction):
(KJS::HTMLSelectCollection::selectedIndexGetter):
(KJS::KJS::HTMLSelectCollection::put):
(KJS::OptionConstructorImp::construct):
(KJS::ImageConstructorImp::construct):
(KJS::Image::getValueProperty):
(KJS::Image::put):
(KJS::Image::putValueProperty):
(KJS::isGradient):
(KJS::isImagePattern):
(KJS::KJS::Context2DFunction::callAsFunction):
(KJS::Context2D::getValueProperty):
(KJS::Context2D::put):
(KJS::colorRefFromValue):
(KJS::colorFromValue):
(KJS::Context2D::setShadow):
(KJS::Context2D::updateFillImagePattern):
(KJS::Context2D::updateStrokeImagePattern):
(KJS::Context2D::putValueProperty):
(KJS::Context2D::Context2D):
(KJS::Context2D::mark):
(KJS::GradientFunction::callAsFunction):
(KJS::Gradient::getValueProperty):
(KJS::Gradient::put):
(KJS::Gradient::putValueProperty):
(KJS::ImagePattern::getValueProperty):
(KJS::ImagePattern::put):
(KJS::ImagePattern::putValueProperty):
* khtml/ecma/kjs_html.h:
* khtml/ecma/kjs_navigator.cpp:
(KJS::Navigator::getValueProperty):
(KJS::Plugins::getValueProperty):
(KJS::Plugins::indexGetter):
(KJS::Plugins::nameGetter):
(KJS::MimeTypes::getValueProperty):
(KJS::MimeTypes::indexGetter):
(KJS::MimeTypes::nameGetter):
(KJS::Plugin::getValueProperty):
(KJS::Plugin::indexGetter):
(KJS::Plugin::nameGetter):
(KJS::MimeType::getValueProperty):
(KJS::PluginsFunc::callAsFunction):
(KJS::NavigatorFunc::callAsFunction):
* khtml/ecma/kjs_navigator.h:
* khtml/ecma/kjs_proxy.cpp:
(KJSProxyImpl::evaluate):
(TestFunctionImp::callAsFunction):
(KJSProxyImpl::initScript):
(KJSProxy::proxy):
* khtml/ecma/kjs_range.cpp:
(KJS::DOMRange::getValueProperty):
(KJS::DOMRangeProtoFunc::callAsFunction):
(KJS::RangeConstructor::getValueProperty):
* khtml/ecma/kjs_range.h:
* khtml/ecma/kjs_traversal.cpp:
(KJS::DOMNodeIterator::getValueProperty):
(KJS::DOMNodeIteratorProtoFunc::callAsFunction):
(KJS::NodeFilterConstructor::getValueProperty):
(KJS::getNodeFilterConstructor):
(KJS::DOMNodeFilterProtoFunc::callAsFunction):
(KJS::DOMTreeWalker::getValueProperty):
(KJS::DOMTreeWalker::put):
(KJS::DOMTreeWalkerProtoFunc::callAsFunction):
(KJS::JSNodeFilterCondition::JSNodeFilterCondition):
(KJS::JSNodeFilterCondition::acceptNode):
* khtml/ecma/kjs_traversal.h:
* khtml/ecma/kjs_views.cpp:
(KJS::DOMAbstractView::getValueProperty):
(KJS::DOMAbstractViewFunc::callAsFunction):
* khtml/ecma/kjs_views.h:
* khtml/ecma/kjs_window.cpp:
(KJS::Screen::getValueProperty):
(KJS::Window::retrieveWindow):
(KJS::Window::retrieveActive):
(KJS::Window::retrieve):
(KJS::parseFeatures):
(KJS::showModalDialog):
(KJS::Window::getValueProperty):
(KJS::Window::childFrameGetter):
(KJS::Window::namedFrameGetter):
(KJS::Window::indexGetter):
(KJS::Window::namedItemGetter):
(KJS::Window::put):
(KJS::Window::installTimeout):
(KJS::Window::setListener):
(KJS::Window::getListener):
(KJS::Window::getJSEventListener):
(KJS::Window::getJSUnprotectedEventListener):
(KJS::Window::getJSLazyEventListener):
(KJS::WindowFunc::callAsFunction):
(KJS::ScheduledAction::ScheduledAction):
(KJS::ScheduledAction::execute):
(KJS::WindowQObject::installTimeout):
(KJS::FrameArray::getValueProperty):
(KJS::FrameArray::indexGetter):
(KJS::FrameArray::nameGetter):
(KJS::Location::getValueProperty):
(KJS::Location::put):
(KJS::Location::toPrimitive):
(KJS::LocationFunc::callAsFunction):
(KJS::Selection::getValueProperty):
(KJS::Selection::toPrimitive):
(KJS::SelectionFunc::callAsFunction):
(KJS::BarInfo::getValueProperty):
(KJS::History::getValueProperty):
(KJS::HistoryFunc::callAsFunction):
(KJS::Konqueror::get):
(KJS::KonquerorFunc::callAsFunction):
* khtml/ecma/kjs_window.h:
* khtml/ecma/xmlhttprequest.cpp:
(KJS::XMLHttpRequestConstructorImp::construct):
(KJS::XMLHttpRequest::getValueProperty):
(KJS::XMLHttpRequest::put):
(KJS::XMLHttpRequest::putValueProperty):
(KJS::XMLHttpRequest::getAllResponseHeaders):
(KJS::XMLHttpRequest::getResponseHeader):
(KJS::XMLHttpRequest::getStatus):
(KJS::XMLHttpRequest::getStatusText):
(KJS::XMLHttpRequestProtoFunc::callAsFunction):
* khtml/ecma/xmlhttprequest.h:
* khtml/ecma/xmlserializer.cpp:
(KJS::XMLSerializerConstructorImp::construct):
(KJS::XMLSerializerProtoFunc::callAsFunction):
* khtml/ecma/xmlserializer.h:
* kwq/DOMUtility.mm:
(KJS::ScriptInterpreter::createObjcInstanceForValue):
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::bindingRootObject):
(KWQKHTMLPart::windowScriptObject):
(KWQKHTMLPart::windowScriptNPObject):
* kwq/WebCoreBridge.mm:
(-[WebCoreBridge executionContextForView:]):
* kwq/WebCoreScriptDebugger.mm:
(WebCoreScriptDebuggerImp::callEvent):
(WebCoreScriptDebuggerImp::returnEvent):
(-[WebCoreScriptDebugger finalize]):
(-[WebCoreScriptCallFrame _convertValueToObjcValue:]):
(-[WebCoreScriptCallFrame scopeChain]):
(-[WebCoreScriptCallFrame evaluateWebScript:]):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@10084 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/kjs/array_instance.h b/JavaScriptCore/kjs/array_instance.h
index b185d39..afdeb56 100644
--- a/JavaScriptCore/kjs/array_instance.h
+++ b/JavaScriptCore/kjs/array_instance.h
@@ -35,8 +35,8 @@
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
virtual bool getOwnPropertySlot(ExecState *, unsigned, PropertySlot&);
- virtual void put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr = None);
- virtual void put(ExecState *exec, unsigned propertyName, const Value &value, int attr = None);
+ virtual void put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr = None);
+ virtual void put(ExecState *exec, unsigned propertyName, ValueImp *value, int attr = None);
virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
virtual bool deleteProperty(ExecState *exec, unsigned propertyName);
virtual ReferenceList propList(ExecState *exec, bool recursive);
@@ -49,10 +49,10 @@
unsigned getLength() const { return length; }
void sort(ExecState *exec);
- void sort(ExecState *exec, Object &compareFunction);
+ void sort(ExecState *exec, ObjectImp *compareFunction);
private:
- static Value lengthGetter(ExecState *, const Identifier&, const PropertySlot&);
+ static ValueImp *lengthGetter(ExecState *, const Identifier&, const PropertySlot&);
void setLength(unsigned newLength, ExecState *exec);
diff --git a/JavaScriptCore/kjs/array_object.cpp b/JavaScriptCore/kjs/array_object.cpp
index 50b783c..184480b 100644
--- a/JavaScriptCore/kjs/array_object.cpp
+++ b/JavaScriptCore/kjs/array_object.cpp
@@ -20,14 +20,16 @@
*
*/
-#include "value.h"
-#include "object.h"
-#include "types.h"
-#include "interpreter.h"
-#include "operations.h"
#include "array_object.h"
-#include "internal.h"
+
#include "error_object.h"
+#include "internal.h"
+#include "interpreter.h"
+#include "object.h"
+#include "operations.h"
+#include "reference_list.h"
+#include "types.h"
+#include "value.h"
#include "array_object.lut.h"
@@ -61,7 +63,7 @@
ListIterator it = list.begin();
unsigned l = length;
for (unsigned i = 0; i < l; ++i) {
- storage[i] = (it++).imp();
+ storage[i] = it++;
}
}
@@ -70,7 +72,7 @@
free(storage);
}
-Value ArrayInstanceImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
+ValueImp *ArrayInstanceImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
{
return Number(static_cast<ArrayInstanceImp *>(slot.slotBase())->length);
}
@@ -89,9 +91,8 @@
return false;
if (index < storageLength) {
ValueImp *v = storage[index];
- if (!v || v == UndefinedImp::staticUndefined)
- return false;
-
+ if (!v || v->isUndefined())
+ return false;
slot.setValueSlot(this, &storage[index]);
return true;
}
@@ -106,9 +107,8 @@
return false;
if (index < storageLength) {
ValueImp *v = storage[index];
- if (!v || v == UndefinedImp::staticUndefined)
+ if (!v || v->isUndefined())
return false;
-
slot.setValueSlot(this, &storage[index]);
return true;
}
@@ -117,10 +117,10 @@
}
// Special implementation of [[Put]] - see ECMA 15.4.5.1
-void ArrayInstanceImp::put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr)
+void ArrayInstanceImp::put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr)
{
if (propertyName == lengthPropertyName) {
- setLength(value.toUInt32(exec), exec);
+ setLength(value->toUInt32(exec), exec);
return;
}
@@ -134,7 +134,7 @@
ObjectImp::put(exec, propertyName, value, attr);
}
-void ArrayInstanceImp::put(ExecState *exec, unsigned index, const Value &value, int attr)
+void ArrayInstanceImp::put(ExecState *exec, unsigned index, ValueImp *value, int attr)
{
if (index < sparseArrayCutoff && index >= storageLength) {
resizeStorage(index + 1);
@@ -145,7 +145,7 @@
}
if (index < storageLength) {
- storage[index] = value.imp();
+ storage[index] = value;
return;
}
@@ -189,7 +189,7 @@
ReferenceList properties = ObjectImp::propList(exec,recursive);
// avoid fetching this every time through the loop
- ValueImp *undefined = UndefinedImp::staticUndefined;
+ ValueImp *undefined = jsUndefined();
for (unsigned i = 0; i < storageLength; ++i) {
ValueImp *imp = storage[i];
@@ -231,7 +231,7 @@
if (newLength < length) {
ReferenceList sparseProperties;
- _prop.addSparseArrayPropertiesToReferenceList(sparseProperties, Object(this));
+ _prop.addSparseArrayPropertiesToReferenceList(sparseProperties, this);
ReferenceListIterator it = sparseProperties.begin();
while (it != sparseProperties.end()) {
@@ -265,13 +265,13 @@
ExecState *exec = execForCompareByStringForQSort;
ValueImp *va = *(ValueImp **)a;
ValueImp *vb = *(ValueImp **)b;
- if (va->dispatchType() == UndefinedType) {
- return vb->dispatchType() == UndefinedType ? 0 : 1;
+ if (va->isUndefined()) {
+ return vb->isUndefined() ? 0 : 1;
}
- if (vb->dispatchType() == UndefinedType) {
+ if (vb->isUndefined()) {
return -1;
}
- return compare(va->dispatchToString(exec), vb->dispatchToString(exec));
+ return compare(va->toString(exec), vb->toString(exec));
}
void ArrayInstanceImp::sort(ExecState *exec)
@@ -296,7 +296,7 @@
ExecState *exec;
ObjectImp *compareFunction;
List arguments;
- Object globalObject;
+ ObjectImp *globalObject;
};
static CompareWithCompareFunctionArguments *compareWithCompareFunctionArguments;
@@ -307,10 +307,10 @@
ValueImp *va = *(ValueImp **)a;
ValueImp *vb = *(ValueImp **)b;
- if (va->dispatchType() == UndefinedType) {
- return vb->dispatchType() == UndefinedType ? 0 : 1;
+ if (va->isUndefined()) {
+ return vb->isUndefined() ? 0 : 1;
}
- if (vb->dispatchType() == UndefinedType) {
+ if (vb->isUndefined()) {
return -1;
}
@@ -318,15 +318,15 @@
args->arguments.append(va);
args->arguments.append(vb);
double compareResult = args->compareFunction->call
- (args->exec, args->globalObject, args->arguments).toNumber(args->exec);
+ (args->exec, args->globalObject, args->arguments)->toNumber(args->exec);
return compareResult < 0 ? -1 : compareResult > 0 ? 1 : 0;
}
-void ArrayInstanceImp::sort(ExecState *exec, Object &compareFunction)
+void ArrayInstanceImp::sort(ExecState *exec, ObjectImp *compareFunction)
{
int lengthNotIncludingUndefined = pushUndefinedObjectsToEnd(exec);
- CompareWithCompareFunctionArguments args(exec, compareFunction.imp());
+ CompareWithCompareFunctionArguments args(exec, compareFunction);
compareWithCompareFunctionArguments = &args;
qsort(storage, lengthNotIncludingUndefined, sizeof(ValueImp *), compareWithCompareFunctionForQSort);
compareWithCompareFunctionArguments = 0;
@@ -334,7 +334,7 @@
unsigned ArrayInstanceImp::pushUndefinedObjectsToEnd(ExecState *exec)
{
- ValueImp *undefined = UndefinedImp::staticUndefined;
+ ValueImp *undefined = jsUndefined();
unsigned o = 0;
@@ -348,7 +348,7 @@
}
ReferenceList sparseProperties;
- _prop.addSparseArrayPropertiesToReferenceList(sparseProperties, Object(this));
+ _prop.addSparseArrayPropertiesToReferenceList(sparseProperties, this);
unsigned newLength = o + sparseProperties.length();
if (newLength > storageLength) {
@@ -358,7 +358,7 @@
ReferenceListIterator it = sparseProperties.begin();
while (it != sparseProperties.end()) {
Reference ref = it++;
- storage[o] = ref.getValue(exec).imp();
+ storage[o] = ref.getValue(exec);
ObjectImp::deleteProperty(exec, ref.getPropertyName(exec));
o++;
}
@@ -398,7 +398,6 @@
ObjectPrototypeImp *objProto)
: ArrayInstanceImp(objProto, 0)
{
- Value protect(this);
setInternalValue(Null());
}
@@ -411,10 +410,9 @@
ArrayProtoFuncImp::ArrayProtoFuncImp(ExecState *exec, int i, int len)
: InternalFunctionImp(
- static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype().imp())
+ static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype())
), id(i)
{
- Value protect(this);
put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
}
@@ -424,19 +422,18 @@
}
// ECMA 15.4.4
-Value ArrayProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &args)
+ValueImp *ArrayProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- unsigned int length = thisObj.get(exec,lengthPropertyName).toUInt32(exec);
- ObjectImp *thisImp = thisObj.imp();
+ unsigned length = thisObj->get(exec,lengthPropertyName)->toUInt32(exec);
- Value result;
+ ValueImp *result;
switch (id) {
case ToLocaleString:
case ToString:
- if (!thisObj.inherits(&ArrayInstanceImp::info)) {
- Object err = Error::create(exec,TypeError);
+ if (!thisObj->inherits(&ArrayInstanceImp::info)) {
+ ObjectImp *err = Error::create(exec,TypeError);
exec->setException(err);
return err;
}
@@ -446,24 +443,22 @@
UString separator = ",";
UString str = "";
- if (args[0].type() != UndefinedType)
- separator = args[0].toString(exec);
+ if (!args[0]->isUndefined())
+ separator = args[0]->toString(exec);
for (unsigned int k = 0; k < length; k++) {
if (k >= 1)
str += separator;
- Value element = thisObj.get(exec, k);
- if (element.type() == UndefinedType || element.type() == NullType)
+ ValueImp *element = thisObj->get(exec, k);
+ if (element->isUndefinedOrNull())
continue;
bool fallback = false;
if (id == ToLocaleString) {
- Object o = element.toObject(exec);
- Object conversionFunction =
- Object::dynamicCast(o.get(exec, toLocaleStringPropertyName));
- if (conversionFunction.isValid() &&
- conversionFunction.implementsCall()) {
- str += conversionFunction.call(exec, o, List()).toString(exec);
+ ObjectImp *o = element->toObject(exec);
+ ValueImp *conversionFunction = o->get(exec, toLocaleStringPropertyName);
+ if (conversionFunction->isObject() && static_cast<ObjectImp *>(conversionFunction)->implementsCall()) {
+ str += static_cast<ObjectImp *>(conversionFunction)->call(exec, o, List())->toString(exec);
} else {
// try toString() fallback
fallback = true;
@@ -471,23 +466,19 @@
}
if (id == ToString || id == Join || fallback) {
- if (element.type() == ObjectType) {
- Object o = Object::dynamicCast(element);
- Object conversionFunction =
- Object::dynamicCast(o.get(exec, toStringPropertyName));
- if (conversionFunction.isValid() &&
- conversionFunction.implementsCall()) {
- str += conversionFunction.call(exec, o, List()).toString(exec);
+ if (element->isObject()) {
+ ObjectImp *o = static_cast<ObjectImp *>(element);
+ ValueImp *conversionFunction = o->get(exec, toStringPropertyName);
+ if (conversionFunction->isObject() && static_cast<ObjectImp *>(conversionFunction)->implementsCall()) {
+ str += static_cast<ObjectImp *>(conversionFunction)->call(exec, o, List())->toString(exec);
} else {
- UString msg = "Can't convert " + o.className() +
- " object to string";
- Object error = Error::create(exec, RangeError,
- msg.cstring().c_str());
+ UString msg = "Can't convert " + o->className() + " object to string";
+ ObjectImp *error = Error::create(exec, RangeError, msg.cstring().c_str());
exec->setException(error);
return error;
}
} else {
- str += element.toString(exec);
+ str += element->toString(exec);
}
}
@@ -498,54 +489,54 @@
break;
}
case Concat: {
- Object arr = Object::dynamicCast(exec->lexicalInterpreter()->builtinArray().construct(exec,List::empty()));
+ ObjectImp *arr = static_cast<ObjectImp *>(exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty()));
int n = 0;
- Value curArg = thisObj;
- Object curObj = Object::dynamicCast(thisObj);
+ ValueImp *curArg = thisObj;
+ ObjectImp *curObj = static_cast<ObjectImp *>(thisObj);
ListIterator it = args.begin();
for (;;) {
- if (curArg.type() == ObjectType &&
- curObj.inherits(&ArrayInstanceImp::info)) {
+ if (curArg->isObject() &&
+ curObj->inherits(&ArrayInstanceImp::info)) {
unsigned int k = 0;
// Older versions tried to optimize out getting the length of thisObj
// by checking for n != 0, but that doesn't work if thisObj is an empty array.
- length = curObj.get(exec,lengthPropertyName).toUInt32(exec);
+ length = curObj->get(exec,lengthPropertyName)->toUInt32(exec);
while (k < length) {
- Value v;
- if (curObj.imp()->getProperty(exec, k, v))
- arr.put(exec, n, v);
+ ValueImp *v;
+ if (curObj->getProperty(exec, k, v))
+ arr->put(exec, n, v);
n++;
k++;
}
} else {
- arr.put(exec, n, curArg);
+ arr->put(exec, n, curArg);
n++;
}
if (it == args.end())
break;
curArg = *it;
- curObj = Object::dynamicCast(it++); // may be 0
+ curObj = static_cast<ObjectImp *>(it++); // may be 0
}
- arr.put(exec,lengthPropertyName, Number(n), DontEnum | DontDelete);
+ arr->put(exec,lengthPropertyName, Number(n), DontEnum | DontDelete);
result = arr;
break;
}
case Pop:{
if (length == 0) {
- thisObj.put(exec, lengthPropertyName, Number(length), DontEnum | DontDelete);
+ thisObj->put(exec, lengthPropertyName, Number(length), DontEnum | DontDelete);
result = Undefined();
} else {
- result = thisObj.get(exec, length - 1);
- thisObj.put(exec, lengthPropertyName, Number(length - 1), DontEnum | DontDelete);
+ result = thisObj->get(exec, length - 1);
+ thisObj->put(exec, lengthPropertyName, Number(length - 1), DontEnum | DontDelete);
}
break;
}
case Push: {
for (int n = 0; n < args.size(); n++)
- thisObj.put(exec, length + n, args[n]);
+ thisObj->put(exec, length + n, args[n]);
length += args.size();
- thisObj.put(exec,lengthPropertyName, Number(length), DontEnum | DontDelete);
+ thisObj->put(exec,lengthPropertyName, Number(length), DontEnum | DontDelete);
result = Number(length);
break;
}
@@ -555,39 +546,39 @@
for (unsigned int k = 0; k < middle; k++) {
unsigned lk1 = length - k - 1;
- Value obj;
- Value obj2;
- bool has2 = thisImp->getProperty(exec, lk1, obj2);
- bool has1 = thisImp->getProperty(exec, k, obj);
+ ValueImp *obj;
+ ValueImp *obj2;
+ bool has2 = thisObj->getProperty(exec, lk1, obj2);
+ bool has1 = thisObj->getProperty(exec, k, obj);
if (has2)
- thisObj.put(exec, k, obj2);
+ thisObj->put(exec, k, obj2);
else
- thisObj.deleteProperty(exec, k);
+ thisObj->deleteProperty(exec, k);
if (has1)
- thisObj.put(exec, lk1, obj);
+ thisObj->put(exec, lk1, obj);
else
- thisObj.deleteProperty(exec, lk1);
+ thisObj->deleteProperty(exec, lk1);
}
result = thisObj;
break;
}
case Shift: {
if (length == 0) {
- thisObj.put(exec, lengthPropertyName, Number(length), DontEnum | DontDelete);
+ thisObj->put(exec, lengthPropertyName, Number(length), DontEnum | DontDelete);
result = Undefined();
} else {
- result = thisObj.get(exec, 0);
+ result = thisObj->get(exec, 0);
for(unsigned int k = 1; k < length; k++) {
- Value obj;
- if (thisImp->getProperty(exec, k, obj))
- thisObj.put(exec, k-1, obj);
+ ValueImp *obj;
+ if (thisObj->getProperty(exec, k, obj))
+ thisObj->put(exec, k-1, obj);
else
- thisObj.deleteProperty(exec, k-1);
+ thisObj->deleteProperty(exec, k-1);
}
- thisObj.deleteProperty(exec, length - 1);
- thisObj.put(exec, lengthPropertyName, Number(length - 1), DontEnum | DontDelete);
+ thisObj->deleteProperty(exec, length - 1);
+ thisObj->put(exec, lengthPropertyName, Number(length - 1), DontEnum | DontDelete);
}
break;
}
@@ -595,11 +586,11 @@
// http://developer.netscape.com/docs/manuals/js/client/jsref/array.htm#1193713 or 15.4.4.10
// We return a new array
- Object resObj = Object::dynamicCast(exec->lexicalInterpreter()->builtinArray().construct(exec,List::empty()));
+ ObjectImp *resObj = static_cast<ObjectImp *>(exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty()));
result = resObj;
double begin = 0;
- if (args[0].type() != UndefinedType) {
- begin = args[0].toInteger(exec);
+ if (!args[0]->isUndefined()) {
+ begin = args[0]->toInteger(exec);
if (begin >= 0) { // false for NaN
if (begin > length)
begin = length;
@@ -610,8 +601,8 @@
}
}
double end = length;
- if (args[1].type() != UndefinedType) {
- end = args[1].toInteger(exec);
+ if (!args[1]->isUndefined()) {
+ end = args[1]->toInteger(exec);
if (end < 0) { // false for NaN
end += length;
if (end < 0)
@@ -627,39 +618,38 @@
int b = static_cast<int>(begin);
int e = static_cast<int>(end);
for(int k = b; k < e; k++, n++) {
- Value obj;
- if (thisImp->getProperty(exec, k, obj))
- resObj.put(exec, n, obj);
+ ValueImp *obj;
+ if (thisObj->getProperty(exec, k, obj))
+ resObj->put(exec, n, obj);
}
- resObj.put(exec, lengthPropertyName, Number(n), DontEnum | DontDelete);
+ resObj->put(exec, lengthPropertyName, Number(n), DontEnum | DontDelete);
break;
}
case Sort:{
#if 0
printf("KJS Array::Sort length=%d\n", length);
for ( unsigned int i = 0 ; i<length ; ++i )
- printf("KJS Array::Sort: %d: %s\n", i, thisObj.get(exec, i).toString(exec).ascii() );
+ printf("KJS Array::Sort: %d: %s\n", i, thisObj->get(exec, i)->toString(exec).ascii() );
#endif
- Object sortFunction;
- bool useSortFunction = (args[0].type() != UndefinedType);
- if (useSortFunction)
+ ObjectImp *sortFunction = NULL;
+ if (!args[0]->isUndefined())
{
- sortFunction = args[0].toObject(exec);
- if (!sortFunction.implementsCall())
- useSortFunction = false;
+ sortFunction = args[0]->toObject(exec);
+ if (!sortFunction->implementsCall())
+ sortFunction = NULL;
}
- if (thisImp->classInfo() == &ArrayInstanceImp::info) {
- if (useSortFunction)
- ((ArrayInstanceImp *)thisImp)->sort(exec, sortFunction);
+ if (thisObj->classInfo() == &ArrayInstanceImp::info) {
+ if (sortFunction)
+ ((ArrayInstanceImp *)thisObj)->sort(exec, sortFunction);
else
- ((ArrayInstanceImp *)thisImp)->sort(exec);
+ ((ArrayInstanceImp *)thisObj)->sort(exec);
result = thisObj;
break;
}
if (length == 0) {
- thisObj.put(exec, lengthPropertyName, Number(0), DontEnum | DontDelete);
+ thisObj->put(exec, lengthPropertyName, Number(0), DontEnum | DontDelete);
result = thisObj;
break;
}
@@ -668,24 +658,24 @@
// or quicksort, and much less swapping than bubblesort/insertionsort.
for ( unsigned int i = 0 ; i<length-1 ; ++i )
{
- Value iObj = thisObj.get(exec,i);
+ ValueImp *iObj = thisObj->get(exec,i);
unsigned int themin = i;
- Value minObj = iObj;
+ ValueImp *minObj = iObj;
for ( unsigned int j = i+1 ; j<length ; ++j )
{
- Value jObj = thisObj.get(exec,j);
+ ValueImp *jObj = thisObj->get(exec,j);
double cmp;
- if (jObj.type() == UndefinedType) {
+ if (jObj->isUndefined()) {
cmp = 1; // don't check minObj because there's no need to differentiate == (0) from > (1)
- } else if (minObj.type() == UndefinedType) {
+ } else if (minObj->isUndefined()) {
cmp = -1;
- } else if (useSortFunction) {
+ } else if (sortFunction) {
List l;
l.append(jObj);
l.append(minObj);
- cmp = sortFunction.call(exec, exec->dynamicInterpreter()->globalObject(), l).toNumber(exec);
+ cmp = sortFunction->call(exec, exec->dynamicInterpreter()->globalObject(), l)->toNumber(exec);
} else {
- cmp = (jObj.toString(exec) < minObj.toString(exec)) ? -1 : 1;
+ cmp = (jObj->toString(exec) < minObj->toString(exec)) ? -1 : 1;
}
if ( cmp < 0 )
{
@@ -697,36 +687,36 @@
if ( themin > i )
{
//printf("KJS Array::Sort: swapping %d and %d\n", i, themin );
- thisObj.put( exec, i, minObj );
- thisObj.put( exec, themin, iObj );
+ thisObj->put( exec, i, minObj );
+ thisObj->put( exec, themin, iObj );
}
}
#if 0
printf("KJS Array::Sort -- Resulting array:\n");
for ( unsigned int i = 0 ; i<length ; ++i )
- printf("KJS Array::Sort: %d: %s\n", i, thisObj.get(exec, i).toString(exec).ascii() );
+ printf("KJS Array::Sort: %d: %s\n", i, thisObj->get(exec, i)->toString(exec).ascii() );
#endif
result = thisObj;
break;
}
case Splice: {
// 15.4.4.12 - oh boy this is huge
- Object resObj = Object::dynamicCast(exec->lexicalInterpreter()->builtinArray().construct(exec,List::empty()));
+ ObjectImp *resObj = static_cast<ObjectImp *>(exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty()));
result = resObj;
- int begin = args[0].toUInt32(exec);
+ int begin = args[0]->toUInt32(exec);
if ( begin < 0 )
begin = maxInt( begin + length, 0 );
else
begin = minInt( begin, length );
- unsigned int deleteCount = minInt( maxInt( args[1].toUInt32(exec), 0 ), length - begin );
+ unsigned int deleteCount = minInt( maxInt( args[1]->toUInt32(exec), 0 ), length - begin );
//printf( "Splicing from %d, deleteCount=%d \n", begin, deleteCount );
for(unsigned int k = 0; k < deleteCount; k++) {
- Value obj;
- if (thisImp->getProperty(exec, k+begin, obj))
- resObj.put(exec, k, obj);
+ ValueImp *obj;
+ if (thisObj->getProperty(exec, k+begin, obj))
+ resObj->put(exec, k, obj);
}
- resObj.put(exec, lengthPropertyName, Number(deleteCount), DontEnum | DontDelete);
+ resObj->put(exec, lengthPropertyName, Number(deleteCount), DontEnum | DontDelete);
unsigned int additionalArgs = maxInt( args.size() - 2, 0 );
if ( additionalArgs != deleteCount )
@@ -735,48 +725,48 @@
{
for ( unsigned int k = begin; k < length - deleteCount; ++k )
{
- Value obj;
- if (thisImp->getProperty(exec, k+deleteCount, obj))
- thisObj.put(exec, k+additionalArgs, obj);
+ ValueImp *obj;
+ if (thisObj->getProperty(exec, k+deleteCount, obj))
+ thisObj->put(exec, k+additionalArgs, obj);
else
- thisObj.deleteProperty(exec, k+additionalArgs);
+ thisObj->deleteProperty(exec, k+additionalArgs);
}
for ( unsigned int k = length ; k > length - deleteCount + additionalArgs; --k )
- thisObj.deleteProperty(exec, k-1);
+ thisObj->deleteProperty(exec, k-1);
}
else
{
for ( unsigned int k = length - deleteCount; (int)k > begin; --k )
{
- Value obj;
- if (thisImp->getProperty(exec, k + deleteCount - 1, obj))
- thisObj.put(exec, k + additionalArgs - 1, obj);
+ ValueImp *obj;
+ if (thisObj->getProperty(exec, k + deleteCount - 1, obj))
+ thisObj->put(exec, k + additionalArgs - 1, obj);
else
- thisObj.deleteProperty(exec, k+additionalArgs-1);
+ thisObj->deleteProperty(exec, k+additionalArgs-1);
}
}
}
for ( unsigned int k = 0; k < additionalArgs; ++k )
{
- thisObj.put(exec, k+begin, args[k+2]);
+ thisObj->put(exec, k+begin, args[k+2]);
}
- thisObj.put(exec, lengthPropertyName, Number(length - deleteCount + additionalArgs), DontEnum | DontDelete);
+ thisObj->put(exec, lengthPropertyName, Number(length - deleteCount + additionalArgs), DontEnum | DontDelete);
break;
}
case UnShift: { // 15.4.4.13
unsigned int nrArgs = args.size();
for ( unsigned int k = length; k > 0; --k )
{
- Value obj;
- if (thisImp->getProperty(exec, k - 1, obj))
- thisObj.put(exec, k+nrArgs-1, obj);
+ ValueImp *obj;
+ if (thisObj->getProperty(exec, k - 1, obj))
+ thisObj->put(exec, k+nrArgs-1, obj);
else
- thisObj.deleteProperty(exec, k+nrArgs-1);
+ thisObj->deleteProperty(exec, k+nrArgs-1);
}
for ( unsigned int k = 0; k < nrArgs; ++k )
- thisObj.put(exec, k, args[k]);
+ thisObj->put(exec, k, args[k]);
result = Number(length + nrArgs);
- thisObj.put(exec, lengthPropertyName, result, DontEnum | DontDelete);
+ thisObj->put(exec, lengthPropertyName, result, DontEnum | DontDelete);
break;
}
case Every:
@@ -787,15 +777,15 @@
//http://developer-test.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:forEach
//http://developer-test.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:some
- Object eachFunction = args[0].toObject(exec);
+ ObjectImp *eachFunction = args[0]->toObject(exec);
- if (!eachFunction.implementsCall()) {
- Object err = Error::create(exec,TypeError);
+ if (!eachFunction->implementsCall()) {
+ ObjectImp *err = Error::create(exec,TypeError);
exec->setException(err);
return err;
}
- Object applyThis = args[1].imp()->isUndefinedOrNull() ? exec->dynamicInterpreter()->globalObject() : args[1].toObject(exec);
+ ObjectImp *applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicInterpreter()->globalObject() : args[1]->toObject(exec);
if (id == Some || id == Every)
result = Boolean(id == Every);
@@ -806,11 +796,11 @@
List eachArguments;
- eachArguments.append(thisObj.get(exec, k));
+ eachArguments.append(thisObj->get(exec, k));
eachArguments.append(Number(k));
eachArguments.append(thisObj);
- bool predicateResult = eachFunction.call(exec, applyThis, eachArguments).toBoolean(exec);
+ bool predicateResult = eachFunction->call(exec, applyThis, eachArguments)->toBoolean(exec);
if (id == Every && !predicateResult) {
result = Boolean(false);
@@ -826,6 +816,7 @@
default:
assert(0);
+ result = 0;
break;
}
return result;
@@ -838,9 +829,8 @@
ArrayPrototypeImp *arrayProto)
: InternalFunctionImp(funcProto)
{
- Value protect(this);
// ECMA 15.4.3.1 Array.prototype
- put(exec,prototypePropertyName, Object(arrayProto), DontEnum|DontDelete|ReadOnly);
+ put(exec,prototypePropertyName, arrayProto, DontEnum|DontDelete|ReadOnly);
// no. of arguments for constructor
put(exec,lengthPropertyName, Number(1), ReadOnly|DontDelete|DontEnum);
@@ -852,21 +842,21 @@
}
// ECMA 15.4.2
-Object ArrayObjectImp::construct(ExecState *exec, const List &args)
+ObjectImp *ArrayObjectImp::construct(ExecState *exec, const List &args)
{
// a single numeric argument denotes the array size (!)
- if (args.size() == 1 && args[0].type() == NumberType) {
- uint32_t n = args[0].toUInt32(exec);
- if (n != args[0].toNumber(exec)) {
- Object error = Error::create(exec, RangeError, "Array size is not a small enough positive integer.");
+ if (args.size() == 1 && args[0]->isNumber()) {
+ uint32_t n = args[0]->toUInt32(exec);
+ if (n != args[0]->toNumber(exec)) {
+ ObjectImp *error = Error::create(exec, RangeError, "Array size is not a small enough positive integer.");
exec->setException(error);
return error;
}
- return Object(new ArrayInstanceImp(exec->lexicalInterpreter()->builtinArrayPrototype().imp(), n));
+ return new ArrayInstanceImp(exec->lexicalInterpreter()->builtinArrayPrototype(), n);
}
// otherwise the array is constructed with the arguments in it
- return Object(new ArrayInstanceImp(exec->lexicalInterpreter()->builtinArrayPrototype().imp(), args));
+ return new ArrayInstanceImp(exec->lexicalInterpreter()->builtinArrayPrototype(), args);
}
bool ArrayObjectImp::implementsCall() const
@@ -875,7 +865,7 @@
}
// ECMA 15.6.1
-Value ArrayObjectImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
+ValueImp *ArrayObjectImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
{
// equivalent to 'new Array(....)'
return construct(exec,args);
diff --git a/JavaScriptCore/kjs/array_object.h b/JavaScriptCore/kjs/array_object.h
index a54db94..802e913 100644
--- a/JavaScriptCore/kjs/array_object.h
+++ b/JavaScriptCore/kjs/array_object.h
@@ -41,7 +41,7 @@
ArrayProtoFuncImp(ExecState *exec, int i, int len);
virtual bool implementsCall() const;
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
enum { ToString, ToLocaleString, Concat, Join, Pop, Push,
Reverse, Shift, Slice, Sort, Splice, UnShift,
@@ -57,9 +57,9 @@
ArrayPrototypeImp *arrayProto);
virtual bool implementsConstruct() const;
- virtual Object construct(ExecState *exec, const List &args);
+ virtual ObjectImp *construct(ExecState *exec, const List &args);
virtual bool implementsCall() const;
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
};
diff --git a/JavaScriptCore/kjs/bool_object.cpp b/JavaScriptCore/kjs/bool_object.cpp
index 1cfe7a88..908bc72 100644
--- a/JavaScriptCore/kjs/bool_object.cpp
+++ b/JavaScriptCore/kjs/bool_object.cpp
@@ -50,7 +50,6 @@
FunctionPrototypeImp *funcProto)
: BooleanInstanceImp(objectProto)
{
- Value protect(this);
// The constructor will be added later by InterpreterImp::InterpreterImp()
putDirect(toStringPropertyName, new BooleanProtoFuncImp(exec,funcProto,BooleanProtoFuncImp::ToString,0), DontEnum);
@@ -65,7 +64,6 @@
FunctionPrototypeImp *funcProto, int i, int len)
: InternalFunctionImp(funcProto), id(i)
{
- Value protect(this);
putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
}
@@ -77,23 +75,23 @@
// ECMA 15.6.4.2 + 15.6.4.3
-Value BooleanProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &/*args*/)
+ValueImp *BooleanProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &/*args*/)
{
// no generic function. "this" has to be a Boolean object
- if (!thisObj.inherits(&BooleanInstanceImp::info)) {
- Object err = Error::create(exec,TypeError);
+ if (!thisObj->inherits(&BooleanInstanceImp::info)) {
+ ObjectImp *err = Error::create(exec,TypeError);
exec->setException(err);
return err;
}
// execute "toString()" or "valueOf()", respectively
- Value v = thisObj.internalValue();
- assert(!v.isNull());
+ ValueImp *v = thisObj->internalValue();
+ assert(v);
if (id == ToString)
- return String(v.toString(exec));
- return Boolean(v.toBoolean(exec)); /* TODO: optimize for bool case */
+ return String(v->toString(exec));
+ return Boolean(v->toBoolean(exec)); /* TODO: optimize for bool case */
}
// ------------------------------ BooleanObjectImp -----------------------------
@@ -103,11 +101,10 @@
BooleanPrototypeImp *booleanProto)
: InternalFunctionImp(funcProto)
{
- Value protect(this);
putDirect(prototypePropertyName, booleanProto, DontEnum|DontDelete|ReadOnly);
// no. of arguments for constructor
- putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum);
+ putDirect(lengthPropertyName, jsOne(), ReadOnly|DontDelete|DontEnum);
}
@@ -117,17 +114,17 @@
}
// ECMA 15.6.2
-Object BooleanObjectImp::construct(ExecState *exec, const List &args)
+ObjectImp *BooleanObjectImp::construct(ExecState *exec, const List &args)
{
- Object obj(new BooleanInstanceImp(exec->lexicalInterpreter()->builtinBooleanPrototype().imp()));
+ ObjectImp *obj(new BooleanInstanceImp(exec->lexicalInterpreter()->builtinBooleanPrototype()));
- Boolean b;
+ bool b;
if (args.size() > 0)
- b = args.begin()->dispatchToBoolean(exec);
+ b = args.begin()->toBoolean(exec);
else
- b = Boolean(false);
+ b = false;
- obj.setInternalValue(b);
+ obj->setInternalValue(jsBoolean(b));
return obj;
}
@@ -138,11 +135,11 @@
}
// ECMA 15.6.1
-Value BooleanObjectImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
+ValueImp *BooleanObjectImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
{
if (args.isEmpty())
return Boolean(false);
else
- return Boolean(args[0].toBoolean(exec)); /* TODO: optimize for bool case */
+ return Boolean(args[0]->toBoolean(exec)); /* TODO: optimize for bool case */
}
diff --git a/JavaScriptCore/kjs/bool_object.h b/JavaScriptCore/kjs/bool_object.h
index f32aef3..bda471f 100644
--- a/JavaScriptCore/kjs/bool_object.h
+++ b/JavaScriptCore/kjs/bool_object.h
@@ -60,7 +60,7 @@
FunctionPrototypeImp *funcProto, int i, int len);
virtual bool implementsCall() const;
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
enum { ToString, ValueOf };
private:
@@ -79,10 +79,10 @@
BooleanPrototypeImp *booleanProto);
virtual bool implementsConstruct() const;
- virtual Object construct(ExecState *exec, const List &args);
+ virtual ObjectImp *construct(ExecState *exec, const List &args);
virtual bool implementsCall() const;
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
};
} // namespace
diff --git a/JavaScriptCore/kjs/collector.cpp b/JavaScriptCore/kjs/collector.cpp
index 23a37db..fbdeba7 100644
--- a/JavaScriptCore/kjs/collector.cpp
+++ b/JavaScriptCore/kjs/collector.cpp
@@ -251,7 +251,7 @@
}
if (good && ((CollectorCell *)x)->u.freeCell.zeroIfFree != 0) {
- ValueImp *imp = (ValueImp *)x;
+ AllocatedValueImp *imp = (AllocatedValueImp *)x;
if (!imp->marked())
imp->mark();
}
@@ -370,14 +370,14 @@
}
CollectorCell *cell = curBlock->cells + i;
- ValueImp *imp = reinterpret_cast<ValueImp *>(cell);
+ AllocatedValueImp *imp = reinterpret_cast<AllocatedValueImp *>(cell);
if (cell->u.freeCell.zeroIfFree != 0) {
- if (!imp->_marked)
+ if (!imp->m_marked)
{
- //fprintf(stderr, "Collector::deleting ValueImp %p (%s)\n", imp, className(imp));
+ //fprintf(stderr, "Collector::deleting AllocatedValueImp %p (%s)\n", imp, className(imp));
// emulate destructing part of 'operator delete()'
- imp->~ValueImp();
+ imp->~AllocatedValueImp();
curBlock->usedCells--;
numLiveObjects--;
deleted = true;
@@ -388,7 +388,7 @@
curBlock->freeList = cell;
} else {
- imp->_marked = false;
+ imp->m_marked = false;
}
} else {
minimumCellsToProcess++;
@@ -422,10 +422,10 @@
int cell = 0;
while (cell < heap.usedOversizeCells) {
- ValueImp *imp = (ValueImp *)heap.oversizeCells[cell];
+ AllocatedValueImp *imp = (AllocatedValueImp *)heap.oversizeCells[cell];
- if (!imp->_marked) {
- imp->~ValueImp();
+ if (!imp->m_marked) {
+ imp->~AllocatedValueImp();
#if DEBUG_COLLECTOR
heap.oversizeCells[cell]->u.freeCell.zeroIfFree = 0;
#else
@@ -445,7 +445,7 @@
}
} else {
- imp->_marked = false;
+ imp->m_marked = false;
cell++;
}
}
@@ -508,7 +508,7 @@
static const char *className(ValueImp *val)
{
const char *name = "???";
- switch (val->dispatchType()) {
+ switch (val->type()) {
case UnspecifiedType:
break;
case UndefinedType:
diff --git a/JavaScriptCore/kjs/completion.h b/JavaScriptCore/kjs/completion.h
index f4bfe99..3856004 100644
--- a/JavaScriptCore/kjs/completion.h
+++ b/JavaScriptCore/kjs/completion.h
@@ -47,17 +47,16 @@
*/
class Completion {
public:
- Completion(ComplType c = Normal, const Value& v = Value(),
- const Identifier &t = Identifier::null())
+ Completion(ComplType c = Normal, ValueImp *v = NULL, const Identifier &t = Identifier::null())
: comp(c), val(v), tar(t) { }
ComplType complType() const { return comp; }
- Value value() const { return val; }
+ ValueImp *value() const { return val; }
Identifier target() const { return tar; }
- bool isValueCompletion() const { return !val.isNull(); }
+ bool isValueCompletion() const { return val; }
private:
ComplType comp;
- Value val;
+ ValueImp *val;
Identifier tar;
};
diff --git a/JavaScriptCore/kjs/context.h b/JavaScriptCore/kjs/context.h
index b45f11d..c99b3be 100644
--- a/JavaScriptCore/kjs/context.h
+++ b/JavaScriptCore/kjs/context.h
@@ -35,21 +35,21 @@
*/
class ContextImp {
public:
- ContextImp(Object &glob, InterpreterImp *, Object &thisV, CodeType type = GlobalCode,
+ ContextImp(ObjectImp *glob, InterpreterImp *, ObjectImp *thisV, CodeType type = GlobalCode,
ContextImp *callingContext = 0, FunctionImp *functiion = 0, const List *args = 0);
~ContextImp();
const ScopeChain &scopeChain() const { return scope; }
CodeType codeType() { return m_codeType; }
- Object variableObject() const { return variable; }
- void setVariableObject(const Object &v) { variable = v; }
- Object thisValue() const { return thisVal; }
+ ObjectImp *variableObject() const { return variable; }
+ void setVariableObject(ObjectImp *v) { variable = v; }
+ ObjectImp *thisValue() const { return thisVal; }
ContextImp *callingContext() { return _callingContext; }
- ObjectImp *activationObject() { return activation.imp(); }
+ ObjectImp *activationObject() { return activation; }
FunctionImp *function() const { return _function; }
const List *arguments() const { return _arguments; }
- void pushScope(const Object &s) { scope.push(s.imp()); }
+ void pushScope(ObjectImp *s) { scope.push(s); }
void popScope() { scope.pop(); }
LabelStack *seenLabels() { return &ls; }
@@ -63,11 +63,11 @@
// because ContextImp is always allocated on the stack,
// there is no need to protect various pointers from conservative
// GC since they will be caught by the conservative sweep anyway!
- Object activation;
+ ObjectImp *activation;
ScopeChain scope;
- Object variable;
- Object thisVal;
+ ObjectImp *variable;
+ ObjectImp *thisVal;
LabelStack ls;
CodeType m_codeType;
diff --git a/JavaScriptCore/kjs/date_object.cpp b/JavaScriptCore/kjs/date_object.cpp
index 454cd93..cf0a4f1 100644
--- a/JavaScriptCore/kjs/date_object.cpp
+++ b/JavaScriptCore/kjs/date_object.cpp
@@ -269,12 +269,12 @@
UString arg1String;
bool useCustomFormat = false;
UString customFormatString;
- arg0String = args[0].toString(exec);
+ arg0String = args[0]->toString(exec);
if ((arg0String == "custom") && (argCount >= 2)) {
useCustomFormat = true;
- customFormatString = args[1].toString(exec);
+ customFormatString = args[1]->toString(exec);
} else if (includeDate && includeTime && (argCount >= 2)) {
- arg1String = args[1].toString(exec);
+ arg1String = args[1]->toString(exec);
dateStyle = styleFromArgString(arg0String,dateStyle);
timeStyle = styleFromArgString(arg1String,timeStyle);
} else if (includeDate && (argCount >= 1)) {
@@ -308,7 +308,7 @@
#endif // APPLE_CHANGES
-using namespace KJS;
+namespace KJS {
static int day(double t)
{
@@ -399,17 +399,17 @@
// hours
if (maxArgs >= 4 && idx < numArgs) {
t->tm_hour = 0;
- result = args[idx++].toInt32(exec) * msPerHour;
+ result = args[idx++]->toInt32(exec) * msPerHour;
}
// minutes
if (maxArgs >= 3 && idx < numArgs) {
t->tm_min = 0;
- result += args[idx++].toInt32(exec) * msPerMinute;
+ result += args[idx++]->toInt32(exec) * msPerMinute;
}
// seconds
if (maxArgs >= 2 && idx < numArgs) {
t->tm_sec = 0;
- result += args[idx++].toInt32(exec) * msPerSecond;
+ result += args[idx++]->toInt32(exec) * msPerSecond;
}
// read ms from args if present or add the old value
result += idx < numArgs ? roundValue(exec, args[idx]) : ms;
@@ -485,8 +485,7 @@
ObjectPrototypeImp *objectProto)
: DateInstanceImp(objectProto)
{
- Value protect(this);
- setInternalValue(NumberImp::create(NaN));
+ setInternalValue(jsNaN());
// The constructor will be added later, after DateObjectImp has been built
}
@@ -499,11 +498,10 @@
DateProtoFuncImp::DateProtoFuncImp(ExecState *exec, int i, int len)
: InternalFunctionImp(
- static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype().imp())
+ static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype())
), id(abs(i)), utc(i<0)
// We use a negative ID to denote the "UTC" variant.
{
- Value protect(this);
putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
}
@@ -512,21 +510,21 @@
return true;
}
-Value DateProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &args)
+ValueImp *DateProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
if ((id == ToString || id == ValueOf || id == GetTime || id == SetTime) &&
- !thisObj.inherits(&DateInstanceImp::info)) {
+ !thisObj->inherits(&DateInstanceImp::info)) {
// non-generic function called on non-date object
// ToString and ValueOf are generic according to the spec, but the mozilla
// tests suggest otherwise...
- Object err = Error::create(exec,TypeError);
+ ObjectImp *err = Error::create(exec,TypeError);
exec->setException(err);
return err;
}
- Value result;
+ ValueImp *result = NULL;
UString s;
#if !APPLE_CHANGES
const int bufsize=100;
@@ -535,8 +533,8 @@
if (!oldlocale.c_str())
oldlocale = setlocale(LC_ALL, NULL);
#endif
- Value v = thisObj.internalValue();
- double milli = v.toNumber(exec);
+ ValueImp *v = thisObj->internalValue();
+ double milli = v->toNumber(exec);
if (isNaN(milli)) {
switch (id) {
@@ -561,7 +559,7 @@
case GetSeconds:
case GetMilliSeconds:
case GetTimezoneOffset:
- return Number(NaN);
+ return jsNaN();
}
}
@@ -707,7 +705,7 @@
case SetTime:
milli = roundValue(exec, args[0]);
result = Number(milli);
- thisObj.setInternalValue(result);
+ thisObj->setInternalValue(result);
break;
case SetMilliSeconds:
ms = roundValue(exec, args[0]);
@@ -723,22 +721,22 @@
break;
case SetDate:
t->tm_mday = 0;
- ms += args[0].toInt32(exec) * msPerDay;
+ ms += args[0]->toInt32(exec) * msPerDay;
break;
case SetMonth:
- t->tm_mon = args[0].toInt32(exec);
+ t->tm_mon = args[0]->toInt32(exec);
if (args.size() >= 2)
- t->tm_mday = args[1].toInt32(exec);
+ t->tm_mday = args[1]->toInt32(exec);
break;
case SetFullYear:
- t->tm_year = args[0].toInt32(exec) - 1900;
+ t->tm_year = args[0]->toInt32(exec) - 1900;
if (args.size() >= 2)
- t->tm_mon = args[1].toInt32(exec);
+ t->tm_mon = args[1]->toInt32(exec);
if (args.size() >= 3)
- t->tm_mday = args[2].toInt32(exec);
+ t->tm_mday = args[2]->toInt32(exec);
break;
case SetYear:
- t->tm_year = args[0].toInt32(exec) >= 1900 ? args[0].toInt32(exec) - 1900 : args[0].toInt32(exec);
+ t->tm_year = args[0]->toInt32(exec) >= 1900 ? args[0]->toInt32(exec) - 1900 : args[0]->toInt32(exec);
break;
}
@@ -746,7 +744,7 @@
id == SetMinutes || id == SetHours || id == SetDate ||
id == SetMonth || id == SetFullYear ) {
result = Number(makeTime(t, ms, utc));
- thisObj.setInternalValue(result);
+ thisObj->setInternalValue(result);
}
return result;
@@ -761,8 +759,6 @@
DatePrototypeImp *dateProto)
: InternalFunctionImp(funcProto)
{
- Value protect(this);
-
// ECMA 15.9.4.1 Date.prototype
putDirect(prototypePropertyName, dateProto, DontEnum|DontDelete|ReadOnly);
@@ -781,7 +777,7 @@
}
// ECMA 15.9.3
-Object DateObjectImp::construct(ExecState *exec, const List &args)
+ObjectImp *DateObjectImp::construct(ExecState *exec, const List &args)
{
int numArgs = args.size();
@@ -807,38 +803,37 @@
#endif
value = utc;
} else if (numArgs == 1) {
- if (args[0].type() == StringType)
- value = parseDate(args[0].toString(exec));
+ if (args[0]->isString())
+ value = parseDate(args[0]->toString(exec));
else
- value = args[0].toPrimitive(exec).toNumber(exec);
+ value = args[0]->toPrimitive(exec)->toNumber(exec);
} else {
struct tm t;
memset(&t, 0, sizeof(t));
- if (isNaN(args[0].toNumber(exec))
- || isNaN(args[1].toNumber(exec))
- || (numArgs >= 3 && isNaN(args[2].toNumber(exec)))
- || (numArgs >= 4 && isNaN(args[3].toNumber(exec)))
- || (numArgs >= 5 && isNaN(args[4].toNumber(exec)))
- || (numArgs >= 6 && isNaN(args[5].toNumber(exec)))
- || (numArgs >= 7 && isNaN(args[6].toNumber(exec)))) {
+ if (isNaN(args[0]->toNumber(exec))
+ || isNaN(args[1]->toNumber(exec))
+ || (numArgs >= 3 && isNaN(args[2]->toNumber(exec)))
+ || (numArgs >= 4 && isNaN(args[3]->toNumber(exec)))
+ || (numArgs >= 5 && isNaN(args[4]->toNumber(exec)))
+ || (numArgs >= 6 && isNaN(args[5]->toNumber(exec)))
+ || (numArgs >= 7 && isNaN(args[6]->toNumber(exec)))) {
value = NaN;
} else {
- int year = args[0].toInt32(exec);
+ int year = args[0]->toInt32(exec);
t.tm_year = (year >= 0 && year <= 99) ? year : year - 1900;
- t.tm_mon = args[1].toInt32(exec);
- t.tm_mday = (numArgs >= 3) ? args[2].toInt32(exec) : 1;
- t.tm_hour = (numArgs >= 4) ? args[3].toInt32(exec) : 0;
- t.tm_min = (numArgs >= 5) ? args[4].toInt32(exec) : 0;
- t.tm_sec = (numArgs >= 6) ? args[5].toInt32(exec) : 0;
+ t.tm_mon = args[1]->toInt32(exec);
+ t.tm_mday = (numArgs >= 3) ? args[2]->toInt32(exec) : 1;
+ t.tm_hour = (numArgs >= 4) ? args[3]->toInt32(exec) : 0;
+ t.tm_min = (numArgs >= 5) ? args[4]->toInt32(exec) : 0;
+ t.tm_sec = (numArgs >= 6) ? args[5]->toInt32(exec) : 0;
t.tm_isdst = -1;
double ms = (numArgs >= 7) ? roundValue(exec, args[6]) : 0;
value = makeTime(&t, ms, false);
}
}
- Object proto = exec->lexicalInterpreter()->builtinDatePrototype();
- Object ret(new DateInstanceImp(proto.imp()));
- ret.setInternalValue(Number(timeClip(value)));
+ DateInstanceImp *ret = new DateInstanceImp(exec->lexicalInterpreter()->builtinDatePrototype());
+ ret->setInternalValue(Number(timeClip(value)));
return ret;
}
@@ -848,11 +843,8 @@
}
// ECMA 15.9.2
-Value DateObjectImp::call(ExecState */*exec*/, Object &/*thisObj*/, const List &/*args*/)
+ValueImp *DateObjectImp::callAsFunction(ExecState */*exec*/, ObjectImp */*thisObj*/, const List &/*args*/)
{
-#ifdef KJS_VERBOSE
- fprintf(stderr,"DateObjectImp::call - current time\n");
-#endif
time_t t = time(0L);
#if APPLE_CHANGES
struct tm *tm = localtime(&t);
@@ -871,7 +863,6 @@
int i, int len)
: InternalFunctionImp(funcProto), id(i)
{
- Value protect(this);
putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
}
@@ -881,31 +872,31 @@
}
// ECMA 15.9.4.2 - 3
-Value DateObjectFuncImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
+ValueImp *DateObjectFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
if (id == Parse) {
- return Number(parseDate(args[0].toString(exec)));
+ return Number(parseDate(args[0]->toString(exec)));
}
else { // UTC
struct tm t;
memset(&t, 0, sizeof(t));
int n = args.size();
- if (isNaN(args[0].toNumber(exec))
- || isNaN(args[1].toNumber(exec))
- || (n >= 3 && isNaN(args[2].toNumber(exec)))
- || (n >= 4 && isNaN(args[3].toNumber(exec)))
- || (n >= 5 && isNaN(args[4].toNumber(exec)))
- || (n >= 6 && isNaN(args[5].toNumber(exec)))
- || (n >= 7 && isNaN(args[6].toNumber(exec)))) {
+ if (isNaN(args[0]->toNumber(exec))
+ || isNaN(args[1]->toNumber(exec))
+ || (n >= 3 && isNaN(args[2]->toNumber(exec)))
+ || (n >= 4 && isNaN(args[3]->toNumber(exec)))
+ || (n >= 5 && isNaN(args[4]->toNumber(exec)))
+ || (n >= 6 && isNaN(args[5]->toNumber(exec)))
+ || (n >= 7 && isNaN(args[6]->toNumber(exec)))) {
return Number(NaN);
}
- int year = args[0].toInt32(exec);
+ int year = args[0]->toInt32(exec);
t.tm_year = (year >= 0 && year <= 99) ? year : year - 1900;
- t.tm_mon = args[1].toInt32(exec);
- t.tm_mday = (n >= 3) ? args[2].toInt32(exec) : 1;
- t.tm_hour = (n >= 4) ? args[3].toInt32(exec) : 0;
- t.tm_min = (n >= 5) ? args[4].toInt32(exec) : 0;
- t.tm_sec = (n >= 6) ? args[5].toInt32(exec) : 0;
+ t.tm_mon = args[1]->toInt32(exec);
+ t.tm_mday = (n >= 3) ? args[2]->toInt32(exec) : 1;
+ t.tm_hour = (n >= 4) ? args[3]->toInt32(exec) : 0;
+ t.tm_min = (n >= 5) ? args[4]->toInt32(exec) : 0;
+ t.tm_sec = (n >= 6) ? args[5]->toInt32(exec) : 0;
double ms = (n >= 7) ? roundValue(exec, args[6]) : 0;
return Number(makeTime(&t, ms, true));
}
@@ -914,7 +905,7 @@
// -----------------------------------------------------------------------------
-double KJS::parseDate(const UString &u)
+double parseDate(const UString &u)
{
#ifdef KJS_VERBOSE
fprintf(stderr,"KJS::parseDate %s\n",u.ascii());
@@ -1027,7 +1018,7 @@
return -1;
}
-double KJS::KRFCDate_parseDate(const UString &_date)
+double KRFCDate_parseDate(const UString &_date)
{
// This parse a date in the form:
// Tuesday, 09-Nov-99 23:12:40 GMT
@@ -1344,7 +1335,7 @@
}
-double KJS::timeClip(double t)
+double timeClip(double t)
{
if (!isfinite(t))
return NaN;
@@ -1353,3 +1344,5 @@
return NaN;
return copysign(floor(at), t);
}
+
+}
diff --git a/JavaScriptCore/kjs/date_object.h b/JavaScriptCore/kjs/date_object.h
index dfe8a78..6058cd9 100644
--- a/JavaScriptCore/kjs/date_object.h
+++ b/JavaScriptCore/kjs/date_object.h
@@ -62,7 +62,7 @@
DateProtoFuncImp(ExecState *exec, int i, int len);
virtual bool implementsCall() const;
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
Completion execute(const List &);
@@ -91,12 +91,12 @@
DatePrototypeImp *dateProto);
virtual bool implementsConstruct() const;
- virtual Object construct(ExecState *exec, const List &args);
+ virtual ObjectImp *construct(ExecState *exec, const List &args);
virtual bool implementsCall() const;
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
Completion execute(const List &);
- Object construct(const List &);
+ ObjectImp *construct(const List &);
};
/**
@@ -111,7 +111,7 @@
int i, int len);
virtual bool implementsCall() const;
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
enum { Parse, UTC };
private:
diff --git a/JavaScriptCore/kjs/debugger.cpp b/JavaScriptCore/kjs/debugger.cpp
index b18da37..89e467f 100644
--- a/JavaScriptCore/kjs/debugger.cpp
+++ b/JavaScriptCore/kjs/debugger.cpp
@@ -99,7 +99,7 @@
}
bool Debugger::exception(ExecState */*exec*/, int /*sourceId*/, int /*lineno*/,
- Object &/*exceptionObj*/)
+ ObjectImp */*exceptionObj*/)
{
return true;
}
@@ -111,13 +111,13 @@
}
bool Debugger::callEvent(ExecState */*exec*/, int /*sourceId*/, int /*lineno*/,
- Object &/*function*/, const List &/*args*/)
+ ObjectImp */*function*/, const List &/*args*/)
{
return true;
}
bool Debugger::returnEvent(ExecState */*exec*/, int /*sourceId*/, int /*lineno*/,
- Object &/*function*/)
+ ObjectImp */*function*/)
{
return true;
}
diff --git a/JavaScriptCore/kjs/debugger.h b/JavaScriptCore/kjs/debugger.h
index 2992bd3..04d89b0 100644
--- a/JavaScriptCore/kjs/debugger.h
+++ b/JavaScriptCore/kjs/debugger.h
@@ -28,7 +28,7 @@
class DebuggerImp;
class Interpreter;
class ExecState;
- class Object;
+ class ObjectImp;
class UString;
class List;
@@ -141,7 +141,7 @@
* be aborted
*/
virtual bool exception(ExecState *exec, int sourceId, int lineno,
- Object &exceptionObj);
+ ObjectImp *exceptionObj);
/**
* Called when a line of the script is reached (before it is executed)
@@ -181,7 +181,7 @@
* be aborted
*/
virtual bool callEvent(ExecState *exec, int sourceId, int lineno,
- Object &function, const List &args);
+ ObjectImp *function, const List &args);
/**
* Called on each function exit. The function being returned from is that
@@ -202,7 +202,7 @@
* be aborted
*/
virtual bool returnEvent(ExecState *exec, int sourceId, int lineno,
- Object &function);
+ ObjectImp *function);
private:
DebuggerImp *rep;
diff --git a/JavaScriptCore/kjs/error_object.cpp b/JavaScriptCore/kjs/error_object.cpp
index a77e523..377db2d 100644
--- a/JavaScriptCore/kjs/error_object.cpp
+++ b/JavaScriptCore/kjs/error_object.cpp
@@ -47,7 +47,6 @@
FunctionPrototypeImp *funcProto)
: ObjectImp(objectProto)
{
- Value protect(this);
setInternalValue(Undefined());
// The constructor will be added later in ErrorObjectImp's constructor
@@ -61,8 +60,7 @@
ErrorProtoFuncImp::ErrorProtoFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto)
: InternalFunctionImp(funcProto)
{
- Value protect(this);
- putDirect(lengthPropertyName, NumberImp::zero(), DontDelete|ReadOnly|DontEnum);
+ putDirect(lengthPropertyName, jsZero(), DontDelete|ReadOnly|DontEnum);
}
bool ErrorProtoFuncImp::implementsCall() const
@@ -70,19 +68,19 @@
return true;
}
-Value ErrorProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &/*args*/)
+ValueImp *ErrorProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &/*args*/)
{
// toString()
UString s = "Error";
- Value v = thisObj.get(exec, namePropertyName);
- if (v.type() != UndefinedType) {
- s = v.toString(exec);
+ ValueImp *v = thisObj->get(exec, namePropertyName);
+ if (!v->isUndefined()) {
+ s = v->toString(exec);
}
- v = thisObj.get(exec, messagePropertyName);
- if (v.type() != UndefinedType) {
- s += ": " + v.toString(exec); // Mozilla compatible format
+ v = thisObj->get(exec, messagePropertyName);
+ if (!v->isUndefined()) {
+ s += ": " + v->toString(exec); // Mozilla compatible format
}
return String(s);
@@ -94,10 +92,9 @@
ErrorPrototypeImp *errorProto)
: InternalFunctionImp(funcProto)
{
- Value protect(this);
// ECMA 15.11.3.1 Error.prototype
putDirect(prototypePropertyName, errorProto, DontEnum|DontDelete|ReadOnly);
- putDirect(lengthPropertyName, NumberImp::one(), DontDelete|ReadOnly|DontEnum);
+ putDirect(lengthPropertyName, jsOne(), DontDelete|ReadOnly|DontEnum);
//putDirect(namePropertyName, String(n));
}
@@ -107,15 +104,14 @@
}
// ECMA 15.9.3
-Object ErrorObjectImp::construct(ExecState *exec, const List &args)
+ObjectImp *ErrorObjectImp::construct(ExecState *exec, const List &args)
{
- Object proto = Object::dynamicCast(exec->lexicalInterpreter()->builtinErrorPrototype());
- ObjectImp *imp = new ErrorInstanceImp(proto.imp());
- Object obj(imp);
+ ObjectImp *proto = static_cast<ObjectImp *>(exec->lexicalInterpreter()->builtinErrorPrototype());
+ ObjectImp *imp = new ErrorInstanceImp(proto);
+ ObjectImp *obj(imp);
- if (!args.isEmpty() && args[0].type() != UndefinedType) {
- imp->putDirect(messagePropertyName, new StringImp(args[0].toString(exec)));
- }
+ if (!args[0]->isUndefined())
+ imp->putDirect(messagePropertyName, jsString(args[0]->toString(exec)));
return obj;
}
@@ -126,7 +122,7 @@
}
// ECMA 15.9.2
-Value ErrorObjectImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
+ValueImp *ErrorObjectImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
{
// "Error()" gives the sames result as "new Error()"
return construct(exec,args);
@@ -138,10 +134,9 @@
ErrorType et, UString name, UString message)
: ObjectImp(errorProto)
{
- Value protect(this);
errType = et;
- putDirect(namePropertyName, new StringImp(name), 0);
- putDirect(messagePropertyName, new StringImp(message), 0);
+ putDirect(namePropertyName, jsString(name), 0);
+ putDirect(messagePropertyName, jsString(message), 0);
}
// ------------------------------ NativeErrorImp -------------------------------
@@ -149,13 +144,12 @@
const ClassInfo NativeErrorImp::info = {"Function", &InternalFunctionImp::info, 0, 0};
NativeErrorImp::NativeErrorImp(ExecState *exec, FunctionPrototypeImp *funcProto,
- const Object &prot)
+ ObjectImp *prot)
: InternalFunctionImp(funcProto), proto(0)
{
- Value protect(this);
- proto = static_cast<ObjectImp*>(prot.imp());
+ proto = static_cast<ObjectImp*>(prot);
- putDirect(lengthPropertyName, NumberImp::one(), DontDelete|ReadOnly|DontEnum); // ECMA 15.11.7.5
+ putDirect(lengthPropertyName, jsOne(), DontDelete|ReadOnly|DontEnum); // ECMA 15.11.7.5
putDirect(prototypePropertyName, proto, DontDelete|ReadOnly|DontEnum);
}
@@ -164,12 +158,12 @@
return true;
}
-Object NativeErrorImp::construct(ExecState *exec, const List &args)
+ObjectImp *NativeErrorImp::construct(ExecState *exec, const List &args)
{
ObjectImp *imp = new ErrorInstanceImp(proto);
- Object obj(imp);
- if (args[0].type() != UndefinedType)
- imp->putDirect(messagePropertyName, new StringImp(args[0].toString(exec)));
+ ObjectImp *obj(imp);
+ if (!args[0]->isUndefined())
+ imp->putDirect(messagePropertyName, jsString(args[0]->toString(exec)));
return obj;
}
@@ -178,7 +172,7 @@
return true;
}
-Value NativeErrorImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
+ValueImp *NativeErrorImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
{
return construct(exec,args);
}
diff --git a/JavaScriptCore/kjs/error_object.h b/JavaScriptCore/kjs/error_object.h
index ca1cab0..973603e 100644
--- a/JavaScriptCore/kjs/error_object.h
+++ b/JavaScriptCore/kjs/error_object.h
@@ -46,7 +46,7 @@
public:
ErrorProtoFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto);
virtual bool implementsCall() const;
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
};
class ErrorObjectImp : public InternalFunctionImp {
@@ -55,10 +55,10 @@
ErrorPrototypeImp *errorProto);
virtual bool implementsConstruct() const;
- virtual Object construct(ExecState *exec, const List &args);
+ virtual ObjectImp *construct(ExecState *exec, const List &args);
virtual bool implementsCall() const;
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
};
class NativeErrorPrototypeImp : public ObjectImp {
@@ -72,12 +72,12 @@
class NativeErrorImp : public InternalFunctionImp {
public:
NativeErrorImp(ExecState *exec, FunctionPrototypeImp *funcProto,
- const Object &prot);
+ ObjectImp *prot);
virtual bool implementsConstruct() const;
- virtual Object construct(ExecState *exec, const List &args);
+ virtual ObjectImp *construct(ExecState *exec, const List &args);
virtual bool implementsCall() const;
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
virtual void mark();
diff --git a/JavaScriptCore/kjs/function.cpp b/JavaScriptCore/kjs/function.cpp
index 0075871..e4e4427 100644
--- a/JavaScriptCore/kjs/function.cpp
+++ b/JavaScriptCore/kjs/function.cpp
@@ -58,7 +58,7 @@
FunctionImp::FunctionImp(ExecState *exec, const Identifier &n)
: InternalFunctionImp(
- static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype().imp())
+ static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype())
), param(0L), ident(n)
{
}
@@ -73,9 +73,9 @@
return true;
}
-Value FunctionImp::call(ExecState *exec, Object &thisObj, const List &args)
+ValueImp *FunctionImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- Object &globalObj = exec->dynamicInterpreter()->globalObject();
+ ObjectImp *globalObj = exec->dynamicInterpreter()->globalObject();
// enter a new execution context
ContextImp ctx(globalObj, exec->dynamicInterpreter()->imp(), thisObj, codeType(),
@@ -97,8 +97,7 @@
lineno = static_cast<DeclaredFunctionImp*>(this)->body->firstLine();
}
- Object func(this);
- bool cont = dbg->callEvent(&newExec,sid,lineno,func,args);
+ bool cont = dbg->callEvent(&newExec,sid,lineno,this,args);
if (!cont) {
dbg->imp()->abort();
return Undefined();
@@ -127,8 +126,7 @@
if (comp.complType() == Throw)
newExec.setException(comp.value());
- Object func(this);
- int cont = dbg->returnEvent(&newExec,sid,lineno,func);
+ int cont = dbg->returnEvent(&newExec,sid,lineno,this);
if (!cont) {
dbg->imp()->abort();
return Undefined();
@@ -172,7 +170,7 @@
// ECMA 10.1.3q
void FunctionImp::processParameters(ExecState *exec, const List &args)
{
- Object variable = exec->context().imp()->variableObject();
+ ObjectImp *variable = exec->context().imp()->variableObject();
#ifdef KJS_VERBOSE
fprintf(stderr, "---------------------------------------------------\n"
@@ -189,10 +187,10 @@
fprintf(stderr, "setting parameter %s ", p->name.ascii());
printInfo(exec,"to", *it);
#endif
- variable.put(exec, p->name, *it);
+ variable->put(exec, p->name, *it);
it++;
} else
- variable.put(exec, p->name, Undefined());
+ variable->put(exec, p->name, Undefined());
p = p->next;
}
}
@@ -208,7 +206,7 @@
{
}
-Value FunctionImp::argumentsGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
+ValueImp *FunctionImp::argumentsGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
{
FunctionImp *thisObj = static_cast<FunctionImp *>(slot.slotBase());
ContextImp *context = exec->_context;
@@ -221,7 +219,7 @@
return Null();
}
-Value FunctionImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
+ValueImp *FunctionImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
{
FunctionImp *thisObj = static_cast<FunctionImp *>(slot.slotBase());
const Parameter *p = thisObj->param;
@@ -250,7 +248,7 @@
return InternalFunctionImp::getOwnPropertySlot(exec, propertyName, slot);
}
-void FunctionImp::put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr)
+void FunctionImp::put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr)
{
if (propertyName == exec->dynamicInterpreter()->argumentsIdentifier() || propertyName == lengthPropertyName)
return;
@@ -305,7 +303,6 @@
FunctionBodyNode *b, const ScopeChain &sc)
: FunctionImp(exec,n), body(b)
{
- Value protect(this);
body->ref();
setScope(sc);
}
@@ -322,21 +319,21 @@
}
// ECMA 13.2.2 [[Construct]]
-Object DeclaredFunctionImp::construct(ExecState *exec, const List &args)
+ObjectImp *DeclaredFunctionImp::construct(ExecState *exec, const List &args)
{
- Object proto;
- Value p = get(exec,prototypePropertyName);
- if (p.type() == ObjectType)
- proto = Object(static_cast<ObjectImp*>(p.imp()));
+ ObjectImp *proto;
+ ValueImp *p = get(exec,prototypePropertyName);
+ if (p->isObject())
+ proto = static_cast<ObjectImp*>(p);
else
proto = exec->lexicalInterpreter()->builtinObjectPrototype();
- Object obj(new ObjectImp(proto));
+ ObjectImp *obj(new ObjectImp(proto));
- Value res = call(exec,obj,args);
+ ValueImp *res = call(exec,obj,args);
- if (res.type() == ObjectType)
- return Object::dynamicCast(res);
+ if (res->isObject())
+ return static_cast<ObjectImp *>(res);
else
return obj;
}
@@ -433,7 +430,6 @@
_activationObject(act),
indexToNameMap(func, args)
{
- Value protect(this);
putDirect(calleePropertyName, func, DontEnum);
putDirect(lengthPropertyName, args.size(), DontEnum);
@@ -453,7 +449,7 @@
_activationObject->mark();
}
-Value ArgumentsImp::mappedIndexGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
+ValueImp *ArgumentsImp::mappedIndexGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
{
ArgumentsImp *thisObj = static_cast<ArgumentsImp *>(slot.slotBase());
return thisObj->_activationObject->get(exec, thisObj->indexToNameMap[propertyName]);
@@ -469,7 +465,7 @@
return ObjectImp::getOwnPropertySlot(exec, propertyName, slot);
}
-void ArgumentsImp::put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr)
+void ArgumentsImp::put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr)
{
if (indexToNameMap.isMapped(propertyName)) {
_activationObject->put(exec, indexToNameMap[propertyName], value, attr);
@@ -500,7 +496,7 @@
// FIXME: Do we need to support enumerating the arguments property?
}
-Value ActivationImp::argumentsGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
+ValueImp *ActivationImp::argumentsGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
{
ActivationImp *thisObj = static_cast<ActivationImp *>(slot.slotBase());
@@ -508,7 +504,7 @@
if (!thisObj->_argumentsObject)
thisObj->createArgumentsObject(exec);
- return Value(thisObj->_argumentsObject);
+ return thisObj->_argumentsObject;
}
PropertySlot::GetValueFunc ActivationImp::getArgumentsGetter()
@@ -558,7 +554,6 @@
GlobalFuncImp::GlobalFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto, int i, int len)
: InternalFunctionImp(funcProto), id(i)
{
- Value protect(this);
putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
}
@@ -572,9 +567,9 @@
return true;
}
-static Value encode(ExecState *exec, const List &args, const char *do_not_escape)
+static ValueImp *encode(ExecState *exec, const List &args, const char *do_not_escape)
{
- UString r = "", s, str = args[0].toString(exec);
+ UString r = "", s, str = args[0]->toString(exec);
CString cstr = str.UTF8String();
const char *p = cstr.c_str();
for (int k = 0; k < cstr.size(); k++, p++) {
@@ -590,9 +585,9 @@
return String(r);
}
-static Value decode(ExecState *exec, const List &args, const char *do_not_unescape, bool strict)
+static ValueImp *decode(ExecState *exec, const List &args, const char *do_not_unescape, bool strict)
{
- UString s = "", str = args[0].toString(exec);
+ UString s = "", str = args[0]->toString(exec);
int k = 0, len = str.size();
const UChar *d = str.data();
UChar u;
@@ -634,7 +629,7 @@
}
if (charLen == 0) {
if (strict) {
- Object error = Error::create(exec, URIError);
+ ObjectImp *error = Error::create(exec, URIError);
exec->setException(error);
return error;
}
@@ -767,9 +762,9 @@
return s.toDouble( true /*tolerant*/, false /* NaN for empty string */ );
}
-Value GlobalFuncImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
+ValueImp *GlobalFuncImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
{
- Value res;
+ ValueImp *res = jsUndefined();
static const char do_not_escape[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
@@ -792,11 +787,11 @@
switch (id) {
case Eval: { // eval()
- Value x = args[0];
- if (x.type() != StringType)
+ ValueImp *x = args[0];
+ if (!x->isString())
return x;
else {
- UString s = x.toString(exec);
+ UString s = x->toString(exec);
int sid;
int errLine;
@@ -812,8 +807,8 @@
// no program node means a syntax occurred
if (!progNode) {
- Object err = Error::create(exec,SyntaxError,errMsg.ascii(),errLine);
- err.put(exec,"sid",Number(sid));
+ ObjectImp *err = Error::create(exec,SyntaxError,errMsg.ascii(),errLine);
+ err->put(exec,"sid",Number(sid));
exec->setException(err);
return err;
}
@@ -821,7 +816,7 @@
progNode->ref();
// enter a new execution context
- Object thisVal(Object::dynamicCast(exec->context().thisValue()));
+ ObjectImp *thisVal = static_cast<ObjectImp *>(exec->context().thisValue());
ContextImp ctx(exec->dynamicInterpreter()->globalObject(),
exec->dynamicInterpreter()->imp(),
thisVal,
@@ -851,16 +846,16 @@
break;
}
case ParseInt:
- res = Number(parseInt(args[0].toString(exec), args[1].toInt32(exec)));
+ res = Number(parseInt(args[0]->toString(exec), args[1]->toInt32(exec)));
break;
case ParseFloat:
- res = Number(parseFloat(args[0].toString(exec)));
+ res = Number(parseFloat(args[0]->toString(exec)));
break;
case IsNaN:
- res = Boolean(isNaN(args[0].toNumber(exec)));
+ res = Boolean(isNaN(args[0]->toNumber(exec)));
break;
case IsFinite: {
- double n = args[0].toNumber(exec);
+ double n = args[0]->toNumber(exec);
res = Boolean(!isNaN(n) && !isInf(n));
break;
}
@@ -878,7 +873,7 @@
break;
case Escape:
{
- UString r = "", s, str = args[0].toString(exec);
+ UString r = "", s, str = args[0]->toString(exec);
const UChar *c = str.data();
for (int k = 0; k < str.size(); k++, c++) {
int u = c->uc;
@@ -900,7 +895,7 @@
}
case UnEscape:
{
- UString s = "", str = args[0].toString(exec);
+ UString s = "", str = args[0]->toString(exec);
int k = 0, len = str.size();
while (k < len) {
const UChar *c = str.data() + k;
@@ -927,7 +922,7 @@
}
#ifndef NDEBUG
case KJSPrint:
- puts(args[0].toString(exec).ascii());
+ puts(args[0]->toString(exec).ascii());
break;
#endif
}
diff --git a/JavaScriptCore/kjs/function.h b/JavaScriptCore/kjs/function.h
index 299c4b2..2e84c87 100644
--- a/JavaScriptCore/kjs/function.h
+++ b/JavaScriptCore/kjs/function.h
@@ -43,11 +43,11 @@
virtual ~FunctionImp();
virtual bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot&);
- virtual void put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr = None);
+ virtual void put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr = None);
virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
virtual bool implementsCall() const;
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
void addParameter(const Identifier &n);
Identifier getParameterName(int index);
@@ -65,8 +65,8 @@
Identifier ident;
private:
- static Value argumentsGetter(ExecState *, const Identifier &, const PropertySlot&);
- static Value lengthGetter(ExecState *, const Identifier &, const PropertySlot&);
+ static ValueImp *argumentsGetter(ExecState *, const Identifier &, const PropertySlot&);
+ static ValueImp *lengthGetter(ExecState *, const Identifier &, const PropertySlot&);
void processParameters(ExecState *exec, const List &);
virtual void processVarDecls(ExecState *exec);
@@ -79,7 +79,7 @@
~DeclaredFunctionImp();
bool implementsConstruct() const;
- Object construct(ExecState *exec, const List &args);
+ ObjectImp *construct(ExecState *exec, const List &args);
virtual Completion execute(ExecState *exec);
CodeType codeType() const { return FunctionCode; }
@@ -112,13 +112,12 @@
ArgumentsImp(ExecState *exec, FunctionImp *func, const List &args, ActivationImp *act);
virtual void mark();
virtual bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot&);
- virtual void put(ExecState *exec, const Identifier &propertyName,
- const Value &value, int attr = None);
+ virtual void put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr = None);
virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
private:
- static Value mappedIndexGetter(ExecState *exec, const Identifier &, const PropertySlot& slot);
+ static ValueImp *mappedIndexGetter(ExecState *exec, const Identifier &, const PropertySlot& slot);
ActivationImp *_activationObject;
mutable IndexToNameMap indexToNameMap;
@@ -138,7 +137,7 @@
private:
static PropertySlot::GetValueFunc getArgumentsGetter();
- static Value argumentsGetter(ExecState *exec, const Identifier &, const PropertySlot& slot);
+ static ValueImp *argumentsGetter(ExecState *exec, const Identifier &, const PropertySlot& slot);
void createArgumentsObject(ExecState *exec) const;
FunctionImp *_function;
@@ -150,7 +149,7 @@
public:
GlobalFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto, int i, int len);
virtual bool implementsCall() const;
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
virtual CodeType codeType() const;
enum { Eval, ParseInt, ParseFloat, IsNaN, IsFinite, Escape, UnEscape,
DecodeURI, DecodeURIComponent, EncodeURI, EncodeURIComponent
diff --git a/JavaScriptCore/kjs/function_object.cpp b/JavaScriptCore/kjs/function_object.cpp
index d25ac9f..231ea29 100644
--- a/JavaScriptCore/kjs/function_object.cpp
+++ b/JavaScriptCore/kjs/function_object.cpp
@@ -40,8 +40,7 @@
FunctionPrototypeImp::FunctionPrototypeImp(ExecState *exec)
: InternalFunctionImp(0)
{
- Value protect(this);
- putDirect(lengthPropertyName, NumberImp::zero(), DontDelete|ReadOnly|DontEnum);
+ putDirect(lengthPropertyName, jsZero(), DontDelete|ReadOnly|DontEnum);
putDirect(toStringPropertyName, new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::ToString, 0), DontEnum);
static const Identifier applyPropertyName("apply");
putDirect(applyPropertyName, new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::Apply, 2), DontEnum);
@@ -59,7 +58,7 @@
}
// ECMA 15.3.4
-Value FunctionPrototypeImp::call(ExecState */*exec*/, Object &/*thisObj*/, const List &/*args*/)
+ValueImp *FunctionPrototypeImp::callAsFunction(ExecState */*exec*/, ObjectImp */*thisObj*/, const List &/*args*/)
{
return Undefined();
}
@@ -70,7 +69,6 @@
FunctionPrototypeImp *funcProto, int i, int len)
: InternalFunctionImp(funcProto), id(i)
{
- Value protect(this);
putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
}
@@ -80,29 +78,29 @@
return true;
}
-Value FunctionProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &args)
+ValueImp *FunctionProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- Value result;
+ ValueImp *result = NULL;
switch (id) {
case ToString: {
// ### also make this work for internal functions
- if (thisObj.isNull() || !thisObj.inherits(&InternalFunctionImp::info)) {
+ if (!thisObj || !thisObj->inherits(&InternalFunctionImp::info)) {
#ifndef NDEBUG
fprintf(stderr,"attempted toString() call on null or non-function object\n");
#endif
- Object err = Error::create(exec,TypeError);
+ ObjectImp *err = Error::create(exec,TypeError);
exec->setException(err);
return err;
}
- if (thisObj.inherits(&DeclaredFunctionImp::info)) {
+ if (thisObj->inherits(&DeclaredFunctionImp::info)) {
DeclaredFunctionImp *fi = static_cast<DeclaredFunctionImp*>
- (thisObj.imp());
+ (thisObj);
return String("function " + fi->name().ustring() + "(" +
fi->parameterString() + ") " + fi->body->toString());
- } else if (thisObj.inherits(&FunctionImp::info) &&
- !static_cast<FunctionImp*>(thisObj.imp())->name().isNull()) {
- result = String("function " + static_cast<FunctionImp*>(thisObj.imp())->name().ustring() + "()");
+ } else if (thisObj->inherits(&FunctionImp::info) &&
+ !static_cast<FunctionImp*>(thisObj)->name().isNull()) {
+ result = String("function " + static_cast<FunctionImp*>(thisObj)->name().ustring() + "()");
}
else {
result = String("(Internal Function)");
@@ -110,59 +108,59 @@
}
break;
case Apply: {
- Value thisArg = args[0];
- Value argArray = args[1];
- Object func = thisObj;
+ ValueImp *thisArg = args[0];
+ ValueImp *argArray = args[1];
+ ObjectImp *func = thisObj;
- if (!func.implementsCall()) {
- Object err = Error::create(exec,TypeError);
+ if (!func->implementsCall()) {
+ ObjectImp *err = Error::create(exec,TypeError);
exec->setException(err);
return err;
}
- Object applyThis;
- if (thisArg.isA(NullType) || thisArg.isA(UndefinedType))
+ ObjectImp *applyThis;
+ if (thisArg->isUndefinedOrNull())
applyThis = exec->dynamicInterpreter()->globalObject();
else
- applyThis = thisArg.toObject(exec);
+ applyThis = thisArg->toObject(exec);
List applyArgs;
- if (!argArray.isA(NullType) && !argArray.isA(UndefinedType)) {
- if (argArray.isA(ObjectType) &&
- (Object::dynamicCast(argArray).inherits(&ArrayInstanceImp::info) ||
- Object::dynamicCast(argArray).inherits(&ArgumentsImp::info))) {
+ if (!argArray->isUndefinedOrNull()) {
+ if (argArray->isObject() &&
+ (static_cast<ObjectImp *>(argArray)->inherits(&ArrayInstanceImp::info) ||
+ static_cast<ObjectImp *>(argArray)->inherits(&ArgumentsImp::info))) {
- Object argArrayObj = Object::dynamicCast(argArray);
- unsigned int length = argArrayObj.get(exec,lengthPropertyName).toUInt32(exec);
+ ObjectImp *argArrayObj = static_cast<ObjectImp *>(argArray);
+ unsigned int length = argArrayObj->get(exec,lengthPropertyName)->toUInt32(exec);
for (unsigned int i = 0; i < length; i++)
- applyArgs.append(argArrayObj.get(exec,i));
+ applyArgs.append(argArrayObj->get(exec,i));
}
else {
- Object err = Error::create(exec,TypeError);
+ ObjectImp *err = Error::create(exec,TypeError);
exec->setException(err);
return err;
}
}
- result = func.call(exec,applyThis,applyArgs);
+ result = func->call(exec,applyThis,applyArgs);
}
break;
case Call: {
- Value thisArg = args[0];
- Object func = thisObj;
+ ValueImp *thisArg = args[0];
+ ObjectImp *func = thisObj;
- if (!func.implementsCall()) {
- Object err = Error::create(exec,TypeError);
+ if (!func->implementsCall()) {
+ ObjectImp *err = Error::create(exec,TypeError);
exec->setException(err);
return err;
}
- Object callThis;
- if (thisArg.isA(NullType) || thisArg.isA(UndefinedType))
+ ObjectImp *callThis;
+ if (thisArg->isUndefinedOrNull())
callThis = exec->dynamicInterpreter()->globalObject();
else
- callThis = thisArg.toObject(exec);
+ callThis = thisArg->toObject(exec);
- result = func.call(exec,callThis,args.copyTail());
+ result = func->call(exec,callThis,args.copyTail());
}
break;
}
@@ -175,11 +173,10 @@
FunctionObjectImp::FunctionObjectImp(ExecState *exec, FunctionPrototypeImp *funcProto)
: InternalFunctionImp(funcProto)
{
- Value protect(this);
putDirect(prototypePropertyName, funcProto, DontEnum|DontDelete|ReadOnly);
// no. of arguments for constructor
- putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum);
+ putDirect(lengthPropertyName, jsOne(), ReadOnly|DontDelete|DontEnum);
}
FunctionObjectImp::~FunctionObjectImp()
@@ -192,7 +189,7 @@
}
// ECMA 15.3.2 The Function Constructor
-Object FunctionObjectImp::construct(ExecState *exec, const List &args, const UString &sourceURL, int lineNumber)
+ObjectImp *FunctionObjectImp::construct(ExecState *exec, const List &args, const UString &sourceURL, int lineNumber)
{
UString p("");
UString body;
@@ -200,12 +197,12 @@
if (argsSize == 0) {
body = "";
} else if (argsSize == 1) {
- body = args[0].toString(exec);
+ body = args[0]->toString(exec);
} else {
- p = args[0].toString(exec);
+ p = args[0]->toString(exec);
for (int k = 1; k < argsSize - 1; k++)
- p += "," + args[k].toString(exec);
- body = args[argsSize-1].toString(exec);
+ p += "," + args[k]->toString(exec);
+ body = args[argsSize-1]->toString(exec);
}
// parse the source code
@@ -221,13 +218,13 @@
bool cont = dbg->sourceParsed(exec,sid,UString(),body,errLine);
if (!cont) {
dbg->imp()->abort();
- return Object(new ObjectImp());
+ return new ObjectImp();
}
}
// no program node == syntax error - throw a syntax error
if (!progNode) {
- Object err = Error::create(exec,SyntaxError,errMsg.ascii(),errLine);
+ ObjectImp *err = Error::create(exec,SyntaxError,errMsg.ascii(),errLine);
// we can't return a Completion(Throw) here, so just set the exception
// and return it
exec->setException(err);
@@ -235,12 +232,11 @@
}
ScopeChain scopeChain;
- scopeChain.push(exec->dynamicInterpreter()->globalObject().imp());
+ scopeChain.push(exec->dynamicInterpreter()->globalObject());
FunctionBodyNode *bodyNode = progNode;
FunctionImp *fimp = new DeclaredFunctionImp(exec, Identifier::null(), bodyNode,
scopeChain);
- Object ret(fimp); // protect from GC
// parse parameter list. throw syntax error on illegal identifiers
int len = p.size();
@@ -271,7 +267,7 @@
continue;
} // else error
}
- Object err = Error::create(exec,SyntaxError,
+ ObjectImp *err = Error::create(exec,SyntaxError,
I18N_NOOP("Syntax error in parameter list"),
-1);
exec->setException(err);
@@ -280,15 +276,15 @@
List consArgs;
- Object objCons = exec->lexicalInterpreter()->builtinObject();
- Object prototype = objCons.construct(exec,List::empty());
- prototype.put(exec, constructorPropertyName, Value(fimp), DontEnum|DontDelete|ReadOnly);
+ ObjectImp *objCons = exec->lexicalInterpreter()->builtinObject();
+ ObjectImp *prototype = objCons->construct(exec,List::empty());
+ prototype->put(exec, constructorPropertyName, fimp, DontEnum|DontDelete|ReadOnly);
fimp->put(exec, prototypePropertyName, prototype, DontEnum|DontDelete|ReadOnly);
- return ret;
+ return fimp;
}
// ECMA 15.3.2 The Function Constructor
-Object FunctionObjectImp::construct(ExecState *exec, const List &args)
+ObjectImp *FunctionObjectImp::construct(ExecState *exec, const List &args)
{
return FunctionObjectImp::construct(exec, args, UString(), 0);
}
@@ -300,7 +296,7 @@
}
// ECMA 15.3.1 The Function Constructor Called as a Function
-Value FunctionObjectImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
+ValueImp *FunctionObjectImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
{
return construct(exec,args);
}
diff --git a/JavaScriptCore/kjs/function_object.h b/JavaScriptCore/kjs/function_object.h
index cb4a054..37b169b 100644
--- a/JavaScriptCore/kjs/function_object.h
+++ b/JavaScriptCore/kjs/function_object.h
@@ -40,7 +40,7 @@
virtual ~FunctionPrototypeImp();
virtual bool implementsCall() const;
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
};
/**
@@ -55,7 +55,7 @@
FunctionPrototypeImp *funcProto, int i, int len);
virtual bool implementsCall() const;
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
enum { ToString, Apply, Call };
private:
@@ -73,10 +73,10 @@
virtual ~FunctionObjectImp();
virtual bool implementsConstruct() const;
- virtual Object construct(ExecState *exec, const List &args, const UString &sourceURL, int lineNumber);
- virtual Object construct(ExecState *exec, const List &args);
+ virtual ObjectImp *construct(ExecState *exec, const List &args, const UString &sourceURL, int lineNumber);
+ virtual ObjectImp *construct(ExecState *exec, const List &args);
virtual bool implementsCall() const;
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
};
} // namespace
diff --git a/JavaScriptCore/kjs/internal.cpp b/JavaScriptCore/kjs/internal.cpp
index 22ba81d..44bc4e4 100644
--- a/JavaScriptCore/kjs/internal.cpp
+++ b/JavaScriptCore/kjs/internal.cpp
@@ -53,11 +53,10 @@
extern int kjsyyparse();
-using namespace KJS;
+namespace KJS {
#if !APPLE_CHANGES
-namespace KJS {
#ifdef WORDS_BIGENDIAN
const unsigned char NaN_Bytes[] = { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 };
const unsigned char Inf_Bytes[] = { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 };
@@ -71,7 +70,6 @@
const double NaN = *(const double*) NaN_Bytes;
const double Inf = *(const double*) Inf_Bytes;
-};
#endif // APPLE_CHANGES
@@ -107,11 +105,9 @@
// ------------------------------ UndefinedImp ---------------------------------
-UndefinedImp *UndefinedImp::staticUndefined = 0;
-
-Value UndefinedImp::toPrimitive(ExecState */*exec*/, Type) const
+ValueImp *UndefinedImp::toPrimitive(ExecState */*exec*/, Type) const
{
- return Value((ValueImp*)this);
+ return const_cast<UndefinedImp *>(this);
}
bool UndefinedImp::toBoolean(ExecState */*exec*/) const
@@ -129,20 +125,18 @@
return "undefined";
}
-Object UndefinedImp::toObject(ExecState *exec) const
+ObjectImp *UndefinedImp::toObject(ExecState *exec) const
{
- Object err = Error::create(exec, TypeError, I18N_NOOP("Undefined value"));
+ ObjectImp *err = Error::create(exec, TypeError, I18N_NOOP("Undefined value"));
exec->setException(err);
return err;
}
// ------------------------------ NullImp --------------------------------------
-NullImp *NullImp::staticNull = 0;
-
-Value NullImp::toPrimitive(ExecState */*exec*/, Type) const
+ValueImp *NullImp::toPrimitive(ExecState */*exec*/, Type) const
{
- return Value((ValueImp*)this);
+ return const_cast<NullImp *>(this);
}
bool NullImp::toBoolean(ExecState */*exec*/) const
@@ -160,21 +154,18 @@
return "null";
}
-Object NullImp::toObject(ExecState *exec) const
+ObjectImp *NullImp::toObject(ExecState *exec) const
{
- Object err = Error::create(exec, TypeError, I18N_NOOP("Null value"));
+ ObjectImp *err = Error::create(exec, TypeError, I18N_NOOP("Null value"));
exec->setException(err);
return err;
}
// ------------------------------ BooleanImp -----------------------------------
-BooleanImp* BooleanImp::staticTrue = 0;
-BooleanImp* BooleanImp::staticFalse = 0;
-
-Value BooleanImp::toPrimitive(ExecState */*exec*/, Type) const
+ValueImp *BooleanImp::toPrimitive(ExecState */*exec*/, Type) const
{
- return Value((ValueImp*)this);
+ return const_cast<BooleanImp *>(this);
}
bool BooleanImp::toBoolean(ExecState */*exec*/) const
@@ -192,18 +183,18 @@
return val ? "true" : "false";
}
-Object BooleanImp::toObject(ExecState *exec) const
+ObjectImp *BooleanImp::toObject(ExecState *exec) const
{
List args;
args.append(const_cast<BooleanImp*>(this));
- return Object::dynamicCast(exec->lexicalInterpreter()->builtinBoolean().construct(exec,args));
+ return static_cast<ObjectImp *>(exec->lexicalInterpreter()->builtinBoolean()->construct(exec,args));
}
// ------------------------------ StringImp ------------------------------------
-Value StringImp::toPrimitive(ExecState */*exec*/, Type) const
+ValueImp *StringImp::toPrimitive(ExecState */*exec*/, Type) const
{
- return Value((ValueImp*)this);
+ return const_cast<StringImp *>(this);
}
bool StringImp::toBoolean(ExecState */*exec*/) const
@@ -221,36 +212,18 @@
return val;
}
-Object StringImp::toObject(ExecState *exec) const
+ObjectImp *StringImp::toObject(ExecState *exec) const
{
List args;
args.append(const_cast<StringImp*>(this));
- return Object(static_cast<ObjectImp *>(exec->lexicalInterpreter()->builtinString().construct(exec, args).imp()));
+ return static_cast<ObjectImp *>(exec->lexicalInterpreter()->builtinString()->construct(exec, args));
}
// ------------------------------ NumberImp ------------------------------------
-NumberImp *NumberImp::staticNaN;
-
-ValueImp *NumberImp::create(int i)
+ValueImp *NumberImp::toPrimitive(ExecState *, Type) const
{
- if (SimpleNumber::fits(i))
- return SimpleNumber::make(i);
- return new NumberImp(static_cast<double>(i));
-}
-
-ValueImp *NumberImp::create(double d)
-{
- if (SimpleNumber::fits(d))
- return SimpleNumber::make((int)d);
- if (isNaN(d))
- return staticNaN;
- return new NumberImp(d);
-}
-
-Value NumberImp::toPrimitive(ExecState *, Type) const
-{
- return Number((NumberImp*)this);
+ return const_cast<NumberImp *>(this);
}
bool NumberImp::toBoolean(ExecState *) const
@@ -270,16 +243,16 @@
return UString::from(val);
}
-Object NumberImp::toObject(ExecState *exec) const
+ObjectImp *NumberImp::toObject(ExecState *exec) const
{
List args;
args.append(const_cast<NumberImp*>(this));
- return Object::dynamicCast(exec->lexicalInterpreter()->builtinNumber().construct(exec,args));
+ return static_cast<ObjectImp *>(exec->lexicalInterpreter()->builtinNumber()->construct(exec,args));
}
-bool NumberImp::toUInt32(unsigned& uint32) const
+bool NumberImp::getUInt32(uint32_t& uint32) const
{
- uint32 = (unsigned)val;
+ uint32 = (uint32_t)val;
return (double)uint32 == val;
}
@@ -315,7 +288,7 @@
bool LabelStack::push(const Identifier &id)
{
- if (id.isEmpty() || contains(id))
+ if (contains(id))
return false;
StackElem *newtos = new StackElem;
@@ -365,7 +338,7 @@
// ------------------------------ ContextImp -----------------------------------
// ECMA 10.2
-ContextImp::ContextImp(Object &glob, InterpreterImp *interpreter, Object &thisV, CodeType type,
+ContextImp::ContextImp(ObjectImp *glob, InterpreterImp *interpreter, ObjectImp *thisV, CodeType type,
ContextImp *callingCon, FunctionImp *func, const List *args)
: _interpreter(interpreter), _function(func), _arguments(args)
{
@@ -374,10 +347,10 @@
// create and initialize activation object (ECMA 10.1.6)
if (type == FunctionCode || type == AnonymousCode ) {
- activation = Object(new ActivationImp(func, *args));
+ activation = new ActivationImp(func, *args);
variable = activation;
} else {
- activation = Object();
+ activation = NULL;
variable = glob;
}
@@ -392,18 +365,18 @@
} // else same as GlobalCode
case GlobalCode:
scope.clear();
- scope.push(glob.imp());
- thisVal = Object(static_cast<ObjectImp*>(glob.imp()));
+ scope.push(glob);
+ thisVal = static_cast<ObjectImp*>(glob);
break;
case FunctionCode:
case AnonymousCode:
if (type == FunctionCode) {
scope = func->scope();
- scope.push(activation.imp());
+ scope.push(activation);
} else {
scope.clear();
- scope.push(glob.imp());
- scope.push(activation.imp());
+ scope.push(glob);
+ scope.push(activation);
}
variable = activation; // TODO: DontDelete ? (ECMA 10.2.3)
thisVal = thisV;
@@ -478,27 +451,17 @@
void InterpreterImp::globalInit()
{
- //fprintf( stderr, "InterpreterImp::globalInit()\n" );
- UndefinedImp::staticUndefined = new UndefinedImp();
- NullImp::staticNull = new NullImp();
- BooleanImp::staticTrue = new BooleanImp(true);
- BooleanImp::staticFalse = new BooleanImp(false);
- NumberImp::staticNaN = new NumberImp(NaN);
+ ConstantValues::init();
}
void InterpreterImp::globalClear()
{
- //fprintf( stderr, "InterpreterImp::globalClear()\n" );
- UndefinedImp::staticUndefined = 0;
- NullImp::staticNull = 0;
- BooleanImp::staticTrue = 0;
- BooleanImp::staticFalse = 0;
- NumberImp::staticNaN = 0;
+ ConstantValues::clear();
}
-InterpreterImp::InterpreterImp(Interpreter *interp, const Object &glob)
- : globExec(interp, 0)
- , _context(0)
+InterpreterImp::InterpreterImp(Interpreter *interp, ObjectImp *glob)
+ : globExec(interp, 0)
+ , _context(0)
{
// add this interpreter to the global chain
// as a root set for garbage collection
@@ -515,7 +478,7 @@
globalInit();
}
- InterpreterMap::setInterpreterForGlobalObject(this, glob.imp());
+ InterpreterMap::setInterpreterForGlobalObject(this, glob);
global = glob;
dbg = 0;
@@ -550,81 +513,75 @@
// Contructor prototype objects (Object.prototype, Array.prototype etc)
FunctionPrototypeImp *funcProto = new FunctionPrototypeImp(&globExec);
- b_FunctionPrototype = Object(funcProto);
+ b_FunctionPrototype = funcProto;
ObjectPrototypeImp *objProto = new ObjectPrototypeImp(&globExec, funcProto);
- b_ObjectPrototype = Object(objProto);
+ b_ObjectPrototype = objProto;
funcProto->setPrototype(b_ObjectPrototype);
ArrayPrototypeImp *arrayProto = new ArrayPrototypeImp(&globExec, objProto);
- b_ArrayPrototype = Object(arrayProto);
+ b_ArrayPrototype = arrayProto;
StringPrototypeImp *stringProto = new StringPrototypeImp(&globExec, objProto);
- b_StringPrototype = Object(stringProto);
+ b_StringPrototype = stringProto;
BooleanPrototypeImp *booleanProto = new BooleanPrototypeImp(&globExec, objProto, funcProto);
- b_BooleanPrototype = Object(booleanProto);
+ b_BooleanPrototype = booleanProto;
NumberPrototypeImp *numberProto = new NumberPrototypeImp(&globExec, objProto, funcProto);
- b_NumberPrototype = Object(numberProto);
+ b_NumberPrototype = numberProto;
DatePrototypeImp *dateProto = new DatePrototypeImp(&globExec, objProto);
- b_DatePrototype = Object(dateProto);
+ b_DatePrototype = dateProto;
RegExpPrototypeImp *regexpProto = new RegExpPrototypeImp(&globExec, objProto, funcProto);
- b_RegExpPrototype = Object(regexpProto);
+ b_RegExpPrototype = regexpProto;
ErrorPrototypeImp *errorProto = new ErrorPrototypeImp(&globExec, objProto, funcProto);
- b_ErrorPrototype = Object(errorProto);
+ b_ErrorPrototype = errorProto;
- static_cast<ObjectImp*>(global.imp())->setPrototype(b_ObjectPrototype);
+ static_cast<ObjectImp*>(global)->setPrototype(b_ObjectPrototype);
// Constructors (Object, Array, etc.)
- b_Object = Object(new ObjectObjectImp(&globExec, objProto, funcProto));
- b_Function = Object(new FunctionObjectImp(&globExec, funcProto));
- b_Array = Object(new ArrayObjectImp(&globExec, funcProto, arrayProto));
- b_String = Object(new StringObjectImp(&globExec, funcProto, stringProto));
- b_Boolean = Object(new BooleanObjectImp(&globExec, funcProto, booleanProto));
- b_Number = Object(new NumberObjectImp(&globExec, funcProto, numberProto));
- b_Date = Object(new DateObjectImp(&globExec, funcProto, dateProto));
- b_RegExp = Object(new RegExpObjectImp(&globExec, funcProto, regexpProto));
- b_Error = Object(new ErrorObjectImp(&globExec, funcProto, errorProto));
+ b_Object = new ObjectObjectImp(&globExec, objProto, funcProto);
+ b_Function = new FunctionObjectImp(&globExec, funcProto);
+ b_Array = new ArrayObjectImp(&globExec, funcProto, arrayProto);
+ b_String = new StringObjectImp(&globExec, funcProto, stringProto);
+ b_Boolean = new BooleanObjectImp(&globExec, funcProto, booleanProto);
+ b_Number = new NumberObjectImp(&globExec, funcProto, numberProto);
+ b_Date = new DateObjectImp(&globExec, funcProto, dateProto);
+ b_RegExp = new RegExpObjectImp(&globExec, funcProto, regexpProto);
+ b_Error = new ErrorObjectImp(&globExec, funcProto, errorProto);
// Error object prototypes
- b_evalErrorPrototype = Object(new NativeErrorPrototypeImp(&globExec, errorProto, EvalError,
- "EvalError", "EvalError"));
- b_rangeErrorPrototype = Object(new NativeErrorPrototypeImp(&globExec, errorProto, RangeError,
- "RangeError", "RangeError"));
- b_referenceErrorPrototype = Object(new NativeErrorPrototypeImp(&globExec, errorProto, ReferenceError,
- "ReferenceError", "ReferenceError"));
- b_syntaxErrorPrototype = Object(new NativeErrorPrototypeImp(&globExec, errorProto, SyntaxError,
- "SyntaxError", "SyntaxError"));
- b_typeErrorPrototype = Object(new NativeErrorPrototypeImp(&globExec, errorProto, TypeError,
- "TypeError", "TypeError"));
- b_uriErrorPrototype = Object(new NativeErrorPrototypeImp(&globExec, errorProto, URIError,
- "URIError", "URIError"));
+ b_evalErrorPrototype = new NativeErrorPrototypeImp(&globExec, errorProto, EvalError, "EvalError", "EvalError");
+ b_rangeErrorPrototype = new NativeErrorPrototypeImp(&globExec, errorProto, RangeError, "RangeError", "RangeError");
+ b_referenceErrorPrototype = new NativeErrorPrototypeImp(&globExec, errorProto, ReferenceError, "ReferenceError", "ReferenceError");
+ b_syntaxErrorPrototype = new NativeErrorPrototypeImp(&globExec, errorProto, SyntaxError, "SyntaxError", "SyntaxError");
+ b_typeErrorPrototype = new NativeErrorPrototypeImp(&globExec, errorProto, TypeError, "TypeError", "TypeError");
+ b_uriErrorPrototype = new NativeErrorPrototypeImp(&globExec, errorProto, URIError, "URIError", "URIError");
// Error objects
- b_evalError = Object(new NativeErrorImp(&globExec, funcProto, b_evalErrorPrototype));
- b_rangeError = Object(new NativeErrorImp(&globExec, funcProto, b_rangeErrorPrototype));
- b_referenceError = Object(new NativeErrorImp(&globExec, funcProto, b_referenceErrorPrototype));
- b_syntaxError = Object(new NativeErrorImp(&globExec, funcProto, b_syntaxErrorPrototype));
- b_typeError = Object(new NativeErrorImp(&globExec, funcProto, b_typeErrorPrototype));
- b_uriError = Object(new NativeErrorImp(&globExec, funcProto, b_uriErrorPrototype));
+ b_evalError = new NativeErrorImp(&globExec, funcProto, b_evalErrorPrototype);
+ b_rangeError = new NativeErrorImp(&globExec, funcProto, b_rangeErrorPrototype);
+ b_referenceError = new NativeErrorImp(&globExec, funcProto, b_referenceErrorPrototype);
+ b_syntaxError = new NativeErrorImp(&globExec, funcProto, b_syntaxErrorPrototype);
+ b_typeError = new NativeErrorImp(&globExec, funcProto, b_typeErrorPrototype);
+ b_uriError = new NativeErrorImp(&globExec, funcProto, b_uriErrorPrototype);
// ECMA 15.3.4.1
funcProto->put(&globExec, "constructor", b_Function, DontEnum);
- global.put(&globExec, "Object", b_Object, DontEnum);
- global.put(&globExec, "Function", b_Function, DontEnum);
- global.put(&globExec, "Array", b_Array, DontEnum);
- global.put(&globExec, "Boolean", b_Boolean, DontEnum);
- global.put(&globExec, "String", b_String, DontEnum);
- global.put(&globExec, "Number", b_Number, DontEnum);
- global.put(&globExec, "Date", b_Date, DontEnum);
- global.put(&globExec, "RegExp", b_RegExp, DontEnum);
- global.put(&globExec, "Error", b_Error, DontEnum);
+ global->put(&globExec, "Object", b_Object, DontEnum);
+ global->put(&globExec, "Function", b_Function, DontEnum);
+ global->put(&globExec, "Array", b_Array, DontEnum);
+ global->put(&globExec, "Boolean", b_Boolean, DontEnum);
+ global->put(&globExec, "String", b_String, DontEnum);
+ global->put(&globExec, "Number", b_Number, DontEnum);
+ global->put(&globExec, "Date", b_Date, DontEnum);
+ global->put(&globExec, "RegExp", b_RegExp, DontEnum);
+ global->put(&globExec, "Error", b_Error, DontEnum);
// Using Internal for those to have something != 0
// (see kjs_window). Maybe DontEnum would be ok too ?
- global.put(&globExec, "EvalError",b_evalError, Internal);
- global.put(&globExec, "RangeError",b_rangeError, Internal);
- global.put(&globExec, "ReferenceError",b_referenceError, Internal);
- global.put(&globExec, "SyntaxError",b_syntaxError, Internal);
- global.put(&globExec, "TypeError",b_typeError, Internal);
- global.put(&globExec, "URIError",b_uriError, Internal);
+ global->put(&globExec, "EvalError",b_evalError, Internal);
+ global->put(&globExec, "RangeError",b_rangeError, Internal);
+ global->put(&globExec, "ReferenceError",b_referenceError, Internal);
+ global->put(&globExec, "SyntaxError",b_syntaxError, Internal);
+ global->put(&globExec, "TypeError",b_typeError, Internal);
+ global->put(&globExec, "URIError",b_uriError, Internal);
// Set the "constructor" property of all builtin constructors
objProto->put(&globExec, "constructor", b_Object, DontEnum | DontDelete | ReadOnly);
@@ -636,36 +593,36 @@
dateProto->put(&globExec, "constructor", b_Date, DontEnum | DontDelete | ReadOnly);
regexpProto->put(&globExec, "constructor", b_RegExp, DontEnum | DontDelete | ReadOnly);
errorProto->put(&globExec, "constructor", b_Error, DontEnum | DontDelete | ReadOnly);
- b_evalErrorPrototype.put(&globExec, "constructor", b_evalError, DontEnum | DontDelete | ReadOnly);
- b_rangeErrorPrototype.put(&globExec, "constructor", b_rangeError, DontEnum | DontDelete | ReadOnly);
- b_referenceErrorPrototype.put(&globExec, "constructor", b_referenceError, DontEnum | DontDelete | ReadOnly);
- b_syntaxErrorPrototype.put(&globExec, "constructor", b_syntaxError, DontEnum | DontDelete | ReadOnly);
- b_typeErrorPrototype.put(&globExec, "constructor", b_typeError, DontEnum | DontDelete | ReadOnly);
- b_uriErrorPrototype.put(&globExec, "constructor", b_uriError, DontEnum | DontDelete | ReadOnly);
+ b_evalErrorPrototype->put(&globExec, "constructor", b_evalError, DontEnum | DontDelete | ReadOnly);
+ b_rangeErrorPrototype->put(&globExec, "constructor", b_rangeError, DontEnum | DontDelete | ReadOnly);
+ b_referenceErrorPrototype->put(&globExec, "constructor", b_referenceError, DontEnum | DontDelete | ReadOnly);
+ b_syntaxErrorPrototype->put(&globExec, "constructor", b_syntaxError, DontEnum | DontDelete | ReadOnly);
+ b_typeErrorPrototype->put(&globExec, "constructor", b_typeError, DontEnum | DontDelete | ReadOnly);
+ b_uriErrorPrototype->put(&globExec, "constructor", b_uriError, DontEnum | DontDelete | ReadOnly);
// built-in values
- global.put(&globExec, "NaN", Number(NaN), DontEnum|DontDelete);
- global.put(&globExec, "Infinity", Number(Inf), DontEnum|DontDelete);
- global.put(&globExec, "undefined", Undefined(), DontEnum|DontDelete);
+ global->put(&globExec, "NaN", jsNaN(), DontEnum|DontDelete);
+ global->put(&globExec, "Infinity", Number(Inf), DontEnum|DontDelete);
+ global->put(&globExec, "undefined", Undefined(), DontEnum|DontDelete);
// built-in functions
- global.put(&globExec, "eval", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::Eval, 1)), DontEnum);
- global.put(&globExec, "parseInt", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::ParseInt, 2)), DontEnum);
- global.put(&globExec, "parseFloat", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::ParseFloat, 1)), DontEnum);
- global.put(&globExec, "isNaN", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::IsNaN, 1)), DontEnum);
- global.put(&globExec, "isFinite", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::IsFinite, 1)), DontEnum);
- global.put(&globExec, "escape", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::Escape, 1)), DontEnum);
- global.put(&globExec, "unescape", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::UnEscape, 1)), DontEnum);
- global.put(&globExec, "decodeURI", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::DecodeURI, 1)), DontEnum);
- global.put(&globExec, "decodeURIComponent", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::DecodeURIComponent, 1)), DontEnum);
- global.put(&globExec, "encodeURI", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::EncodeURI, 1)), DontEnum);
- global.put(&globExec, "encodeURIComponent", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::EncodeURIComponent, 1)), DontEnum);
+ global->put(&globExec, "eval", new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::Eval, 1), DontEnum);
+ global->put(&globExec, "parseInt", new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::ParseInt, 2), DontEnum);
+ global->put(&globExec, "parseFloat", new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::ParseFloat, 1), DontEnum);
+ global->put(&globExec, "isNaN", new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::IsNaN, 1), DontEnum);
+ global->put(&globExec, "isFinite", new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::IsFinite, 1), DontEnum);
+ global->put(&globExec, "escape", new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::Escape, 1), DontEnum);
+ global->put(&globExec, "unescape", new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::UnEscape, 1), DontEnum);
+ global->put(&globExec, "decodeURI", new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::DecodeURI, 1), DontEnum);
+ global->put(&globExec, "decodeURIComponent", new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::DecodeURIComponent, 1), DontEnum);
+ global->put(&globExec, "encodeURI", new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::EncodeURI, 1), DontEnum);
+ global->put(&globExec, "encodeURIComponent", new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::EncodeURIComponent, 1), DontEnum);
#ifndef NDEBUG
- global.put(&globExec, "kjsprint", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::KJSPrint, 1)), DontEnum);
+ global->put(&globExec, "kjsprint", new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::KJSPrint, 1), DontEnum);
#endif
// built-in objects
- global.put(&globExec, "Math", Object(new MathObjectImp(&globExec, objProto)), DontEnum);
+ global->put(&globExec, "Math", new MathObjectImp(&globExec, objProto), DontEnum);
}
InterpreterImp::~InterpreterImp()
@@ -691,7 +648,7 @@
s_hook = 0L;
globalClear();
}
- InterpreterMap::removeInterpreterForGlobalObject(global.imp());
+ InterpreterMap::removeInterpreterForGlobalObject(global);
#if APPLE_CHANGES
unlockInterpreter();
@@ -700,21 +657,7 @@
void InterpreterImp::mark()
{
- //if (exVal && !exVal->marked())
- // exVal->mark();
- //if (retVal && !retVal->marked())
- // retVal->mark();
- if (UndefinedImp::staticUndefined && !UndefinedImp::staticUndefined->marked())
- UndefinedImp::staticUndefined->mark();
- if (NullImp::staticNull && !NullImp::staticNull->marked())
- NullImp::staticNull->mark();
- if (NumberImp::staticNaN && !NumberImp::staticNaN->marked())
- NumberImp::staticNaN->mark();
- if (BooleanImp::staticTrue && !BooleanImp::staticTrue->marked())
- BooleanImp::staticTrue->mark();
- if (BooleanImp::staticFalse && !BooleanImp::staticFalse->marked())
- BooleanImp::staticFalse->mark();
- //fprintf( stderr, "InterpreterImp::mark this=%p global.imp()=%p\n", this, global.imp() );
+ ConstantValues::mark();
if (m_interpreter)
m_interpreter->mark();
if (_context)
@@ -735,7 +678,7 @@
return ok;
}
-Completion InterpreterImp::evaluate(const UString &code, const Value &thisV, const UString &sourceURL, int startingLineNumber)
+Completion InterpreterImp::evaluate(const UString &code, ValueImp *thisV, const UString &sourceURL, int startingLineNumber)
{
#if APPLE_CHANGES
lockInterpreter();
@@ -773,8 +716,8 @@
// no program node means a syntax error occurred
if (!progNode) {
- Object err = Error::create(&globExec, SyntaxError, errMsg.ascii(), errLine, -1, &sourceURL);
- err.put(&globExec, "sid", Number(sid));
+ ObjectImp *err = Error::create(&globExec, SyntaxError, errMsg.ascii(), errLine, -1, &sourceURL);
+ err->put(&globExec, "sid", Number(sid));
#if APPLE_CHANGES
unlockInterpreter();
#endif
@@ -786,21 +729,21 @@
recursion++;
progNode->ref();
- Object &globalObj = globalObject();
- Object thisObj = globalObject();
+ ObjectImp *globalObj = globalObject();
+ ObjectImp *thisObj = globalObject();
- if (!thisV.isNull()) {
+ if (thisV) {
// "this" must be an object... use same rules as Function.prototype.apply()
- if (thisV.isA(NullType) || thisV.isA(UndefinedType))
+ if (thisV->isUndefinedOrNull())
thisObj = globalObject();
else {
- thisObj = thisV.toObject(&globExec);
+ thisObj = thisV->toObject(&globExec);
}
}
Completion res;
if (globExec.hadException()) {
- // the thisArg.toObject() conversion above might have thrown an exception - if so,
+ // the thisArg->toObject() conversion above might have thrown an exception - if so,
// propagate it back
res = Completion(Throw, globExec.exception());
}
@@ -924,33 +867,32 @@
return true;
}
-Boolean InternalFunctionImp::hasInstance(ExecState *exec, const Value &value)
+bool InternalFunctionImp::hasInstance(ExecState *exec, ValueImp *value)
{
- if (value.type() != ObjectType)
- return Boolean(false);
+ if (!value->isObject())
+ return false;
- Value prot = get(exec,prototypePropertyName);
- if (prot.type() != ObjectType && prot.type() != NullType) {
- Object err = Error::create(exec, TypeError, "Invalid prototype encountered "
+ ValueImp *prot = get(exec,prototypePropertyName);
+ if (!prot->isObject() && !prot->isNull()) {
+ ObjectImp *err = Error::create(exec, TypeError, "Invalid prototype encountered "
"in instanceof operation.");
exec->setException(err);
- return Boolean(false);
+ return false;
}
- Object v = Object(static_cast<ObjectImp*>(value.imp()));
- while ((v = Object::dynamicCast(v.prototype())).imp()) {
- if (v.imp() == prot.imp())
- return Boolean(true);
+ ObjectImp *v = static_cast<ObjectImp *>(value);
+ while ((v = v->prototype()->getObject())) {
+ if (v == prot)
+ return true;
}
- return Boolean(false);
+ return false;
}
// ------------------------------ global functions -----------------------------
-double KJS::roundValue(ExecState *exec, const Value &v)
+double roundValue(ExecState *exec, ValueImp *v)
{
- Number n = v.toNumber(exec);
- double d = n.value();
+ double d = v->toNumber(exec);
double ad = fabs(d);
if (ad == 0 || isNaN(d) || isInf(d))
return d;
@@ -959,15 +901,15 @@
#ifndef NDEBUG
#include <stdio.h>
-void KJS::printInfo(ExecState *exec, const char *s, const Value &o, int lineno)
+void printInfo(ExecState *exec, const char *s, ValueImp *o, int lineno)
{
- if (o.isNull())
+ if (!o)
fprintf(stderr, "KJS: %s: (null)", s);
else {
- Value v = o;
+ ValueImp *v = o;
UString name;
- switch ( v.type() ) {
+ switch (v->type()) {
case UnspecifiedType:
name = "Unspecified";
break;
@@ -987,19 +929,19 @@
name = "Number";
break;
case ObjectType:
- name = Object::dynamicCast(v).className();
+ name = static_cast<ObjectImp *>(v)->className();
if (name.isNull())
name = "(unknown class)";
break;
}
- UString vString = v.toString(exec);
+ UString vString = v->toString(exec);
if ( vString.size() > 50 )
vString = vString.substr( 0, 50 ) + "...";
// Can't use two UString::ascii() in the same fprintf call
CString tempString( vString.cstring() );
fprintf(stderr, "KJS: %s: %s : %s (%p)",
- s, tempString.c_str(), name.ascii(), (void*)v.imp());
+ s, tempString.c_str(), name.ascii(), (void*)v);
if (lineno >= 0)
fprintf(stderr, ", line %d\n",lineno);
@@ -1008,3 +950,5 @@
}
}
#endif
+
+}
diff --git a/JavaScriptCore/kjs/internal.h b/JavaScriptCore/kjs/internal.h
index d362267..fec5c67 100644
--- a/JavaScriptCore/kjs/internal.h
+++ b/JavaScriptCore/kjs/internal.h
@@ -22,8 +22,8 @@
*
*/
-#ifndef _INTERNAL_H_
-#define _INTERNAL_H_
+#ifndef INTERNAL_H
+#define INTERNAL_H
#include "ustring.h"
#include "value.h"
@@ -37,9 +37,6 @@
namespace KJS {
- static const double D16 = 65536.0;
- static const double D32 = 4294967296.0;
-
class ProgramNode;
class FunctionBodyNode;
class FunctionPrototypeImp;
@@ -50,115 +47,90 @@
// Primitive impls
// ---------------------------------------------------------------------------
- class UndefinedImp : public ValueImp {
+ class UndefinedImp : public AllocatedValueImp {
public:
Type type() const { return UndefinedType; }
- Value toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
+ ValueImp *toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
bool toBoolean(ExecState *exec) const;
double toNumber(ExecState *exec) const;
UString toString(ExecState *exec) const;
- Object toObject(ExecState *exec) const;
-
- static UndefinedImp *staticUndefined;
+ ObjectImp *toObject(ExecState *exec) const;
};
- inline Undefined::Undefined(UndefinedImp *imp) : Value(imp) { }
-
- class NullImp : public ValueImp {
+ class NullImp : public AllocatedValueImp {
public:
Type type() const { return NullType; }
- Value toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
+ ValueImp *toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
bool toBoolean(ExecState *exec) const;
double toNumber(ExecState *exec) const;
UString toString(ExecState *exec) const;
- Object toObject(ExecState *exec) const;
-
- static NullImp *staticNull;
+ ObjectImp *toObject(ExecState *exec) const;
};
- inline Null::Null(NullImp *imp) : Value(imp) { }
-
- class BooleanImp : public ValueImp {
+ class BooleanImp : public AllocatedValueImp {
public:
BooleanImp(bool v = false) : val(v) { }
bool value() const { return val; }
Type type() const { return BooleanType; }
- Value toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
+ ValueImp *toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
bool toBoolean(ExecState *exec) const;
double toNumber(ExecState *exec) const;
UString toString(ExecState *exec) const;
- Object toObject(ExecState *exec) const;
+ ObjectImp *toObject(ExecState *exec) const;
- static BooleanImp *staticTrue;
- static BooleanImp *staticFalse;
private:
bool val;
};
- inline Boolean::Boolean(BooleanImp *imp) : Value(imp) { }
-
- class StringImp : public ValueImp {
+ class StringImp : public AllocatedValueImp {
public:
StringImp(const UString& v) : val(v) { }
UString value() const { return val; }
Type type() const { return StringType; }
- Value toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
+ ValueImp *toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
bool toBoolean(ExecState *exec) const;
double toNumber(ExecState *exec) const;
UString toString(ExecState *exec) const;
- Object toObject(ExecState *exec) const;
+ ObjectImp *toObject(ExecState *exec) const;
private:
UString val;
};
- inline String::String(StringImp *imp) : Value(imp) { }
-
- class NumberImp : public ValueImp {
- friend class Value;
- friend class Number;
+ class NumberImp : public AllocatedValueImp {
+ friend class ConstantValues;
friend class InterpreterImp;
- friend ValueImp *number(int);
- friend ValueImp *number(unsigned);
- friend ValueImp *number(long);
- friend ValueImp *number(unsigned long);
- friend ValueImp *number(double);
- friend ValueImp *number(double, bool);
+ friend ValueImp *jsNumber(int);
+ friend ValueImp *jsNumber(unsigned);
+ friend ValueImp *jsNumber(long);
+ friend ValueImp *jsNumber(unsigned long);
+ friend ValueImp *jsNumber(double);
+ friend ValueImp *jsNumber(double, bool);
public:
- static ValueImp *create(int);
- static ValueImp *create(double);
- static ValueImp *zero() { return SimpleNumber::make(0); }
- static ValueImp *one() { return SimpleNumber::make(1); }
- static ValueImp *two() { return SimpleNumber::make(2); }
-
double value() const { return val; }
Type type() const { return NumberType; }
- Value toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
+ ValueImp *toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
bool toBoolean(ExecState *exec) const;
double toNumber(ExecState *exec) const;
UString toString(ExecState *exec) const;
- Object toObject(ExecState *exec) const;
-
- static NumberImp *staticNaN;
+ ObjectImp *toObject(ExecState *exec) const;
private:
NumberImp(double v) : val(v) { }
- virtual bool toUInt32(unsigned&) const;
+ virtual bool getUInt32(uint32_t&) const;
double val;
};
- inline Number::Number(NumberImp *imp) : Value(imp) { }
-
/**
* @short The "label set" in Ecma-262 spec
*/
@@ -206,7 +178,7 @@
// ---------------------------------------------------------------------------
- // Parsing & evaluateion
+ // Parsing & evaluation
// ---------------------------------------------------------------------------
enum CodeType { GlobalCode,
@@ -275,7 +247,7 @@
static void globalInit();
static void globalClear();
- InterpreterImp(Interpreter *interp, const Object &glob);
+ InterpreterImp(Interpreter *interp, ObjectImp *glob);
~InterpreterImp();
ProtectedObject &globalObject() const { return const_cast<ProtectedObject &>(global); }
@@ -290,43 +262,43 @@
ExecState *globalExec() { return &globExec; }
bool checkSyntax(const UString &code);
- Completion evaluate(const UString &code, const Value &thisV, const UString &sourceURL, int startingLineNumber);
+ Completion evaluate(const UString &code, ValueImp *thisV, const UString &sourceURL, int startingLineNumber);
Debugger *debugger() const { return dbg; }
void setDebugger(Debugger *d) { dbg = d; }
- Object builtinObject() const { return b_Object; }
- Object builtinFunction() const { return b_Function; }
- Object builtinArray() const { return b_Array; }
- Object builtinBoolean() const { return b_Boolean; }
- Object builtinString() const { return b_String; }
- Object builtinNumber() const { return b_Number; }
- Object builtinDate() const { return b_Date; }
- Object builtinRegExp() const { return b_RegExp; }
- Object builtinError() const { return b_Error; }
+ ObjectImp *builtinObject() const { return b_Object; }
+ ObjectImp *builtinFunction() const { return b_Function; }
+ ObjectImp *builtinArray() const { return b_Array; }
+ ObjectImp *builtinBoolean() const { return b_Boolean; }
+ ObjectImp *builtinString() const { return b_String; }
+ ObjectImp *builtinNumber() const { return b_Number; }
+ ObjectImp *builtinDate() const { return b_Date; }
+ ObjectImp *builtinRegExp() const { return b_RegExp; }
+ ObjectImp *builtinError() const { return b_Error; }
- Object builtinObjectPrototype() const { return b_ObjectPrototype; }
- Object builtinFunctionPrototype() const { return b_FunctionPrototype; }
- Object builtinArrayPrototype() const { return b_ArrayPrototype; }
- Object builtinBooleanPrototype() const { return b_BooleanPrototype; }
- Object builtinStringPrototype() const { return b_StringPrototype; }
- Object builtinNumberPrototype() const { return b_NumberPrototype; }
- Object builtinDatePrototype() const { return b_DatePrototype; }
- Object builtinRegExpPrototype() const { return b_RegExpPrototype; }
- Object builtinErrorPrototype() const { return b_ErrorPrototype; }
+ ObjectImp *builtinObjectPrototype() const { return b_ObjectPrototype; }
+ ObjectImp *builtinFunctionPrototype() const { return b_FunctionPrototype; }
+ ObjectImp *builtinArrayPrototype() const { return b_ArrayPrototype; }
+ ObjectImp *builtinBooleanPrototype() const { return b_BooleanPrototype; }
+ ObjectImp *builtinStringPrototype() const { return b_StringPrototype; }
+ ObjectImp *builtinNumberPrototype() const { return b_NumberPrototype; }
+ ObjectImp *builtinDatePrototype() const { return b_DatePrototype; }
+ ObjectImp *builtinRegExpPrototype() const { return b_RegExpPrototype; }
+ ObjectImp *builtinErrorPrototype() const { return b_ErrorPrototype; }
- Object builtinEvalError() const { return b_evalError; }
- Object builtinRangeError() const { return b_rangeError; }
- Object builtinReferenceError() const { return b_referenceError; }
- Object builtinSyntaxError() const { return b_syntaxError; }
- Object builtinTypeError() const { return b_typeError; }
- Object builtinURIError() const { return b_uriError; }
+ ObjectImp *builtinEvalError() const { return b_evalError; }
+ ObjectImp *builtinRangeError() const { return b_rangeError; }
+ ObjectImp *builtinReferenceError() const { return b_referenceError; }
+ ObjectImp *builtinSyntaxError() const { return b_syntaxError; }
+ ObjectImp *builtinTypeError() const { return b_typeError; }
+ ObjectImp *builtinURIError() const { return b_uriError; }
- Object builtinEvalErrorPrototype() const { return b_evalErrorPrototype; }
- Object builtinRangeErrorPrototype() const { return b_rangeErrorPrototype; }
- Object builtinReferenceErrorPrototype() const { return b_referenceErrorPrototype; }
- Object builtinSyntaxErrorPrototype() const { return b_syntaxErrorPrototype; }
- Object builtinTypeErrorPrototype() const { return b_typeErrorPrototype; }
- Object builtinURIErrorPrototype() const { return b_uriErrorPrototype; }
+ ObjectImp *builtinEvalErrorPrototype() const { return b_evalErrorPrototype; }
+ ObjectImp *builtinRangeErrorPrototype() const { return b_rangeErrorPrototype; }
+ ObjectImp *builtinReferenceErrorPrototype() const { return b_referenceErrorPrototype; }
+ ObjectImp *builtinSyntaxErrorPrototype() const { return b_syntaxErrorPrototype; }
+ ObjectImp *builtinTypeErrorPrototype() const { return b_typeErrorPrototype; }
+ ObjectImp *builtinURIErrorPrototype() const { return b_uriErrorPrototype; }
void setCompatMode(Interpreter::CompatMode mode) { m_compatMode = mode; }
Interpreter::CompatMode compatMode() const { return m_compatMode; }
@@ -422,20 +394,19 @@
public:
InternalFunctionImp(FunctionPrototypeImp *funcProto);
bool implementsHasInstance() const;
- Boolean hasInstance(ExecState *exec, const Value &value);
+ bool hasInstance(ExecState *exec, ValueImp *value);
virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
};
// helper function for toInteger, toInt32, toUInt32 and toUInt16
- double roundValue(ExecState *exec, const Value &v);
+ double roundValue(ExecState *, ValueImp *);
#ifndef NDEBUG
- void printInfo(ExecState *exec, const char *s, const Value &o, int lineno = -1);
+ void printInfo(ExecState *exec, const char *s, ValueImp *, int lineno = -1);
#endif
} // namespace
-
-#endif // _INTERNAL_H_
+#endif // INTERNAL_H
diff --git a/JavaScriptCore/kjs/interpreter.cpp b/JavaScriptCore/kjs/interpreter.cpp
index 3a5fa82..d8ba0a0 100644
--- a/JavaScriptCore/kjs/interpreter.cpp
+++ b/JavaScriptCore/kjs/interpreter.cpp
@@ -50,12 +50,12 @@
return rep->scopeChain();
}
-Object Context::variableObject() const
+ObjectImp *Context::variableObject() const
{
return rep->variableObject();
}
-Object Context::thisValue() const
+ObjectImp *Context::thisValue() const
{
return rep->thisValue();
}
@@ -67,12 +67,12 @@
// ------------------------------ Interpreter ----------------------------------
-Interpreter::Interpreter(const Object &global)
+Interpreter::Interpreter(ObjectImp *global)
: rep(0)
, m_argumentsPropertyName(&argumentsPropertyName)
, m_specialPrototypePropertyName(&specialPrototypePropertyName)
{
- rep = new InterpreterImp(this,global);
+ rep = new InterpreterImp(this, global);
}
Interpreter::Interpreter()
@@ -80,8 +80,7 @@
, m_argumentsPropertyName(&argumentsPropertyName)
, m_specialPrototypePropertyName(&specialPrototypePropertyName)
{
- Object global(new ObjectImp());
- rep = new InterpreterImp(this,global);
+ rep = new InterpreterImp(this, new ObjectImp);
}
Interpreter::~Interpreter()
@@ -89,7 +88,7 @@
delete rep;
}
-Object &Interpreter::globalObject() const
+ObjectImp *Interpreter::globalObject() const
{
return rep->globalObject();
}
@@ -124,12 +123,12 @@
return rep->checkSyntax(code);
}
-Completion Interpreter::evaluate(const UString &code, const Value &thisV, const UString &)
+Completion Interpreter::evaluate(const UString &code, ValueImp *thisV, const UString &)
{
return evaluate(UString(), 0, code, thisV);
}
-Completion Interpreter::evaluate(const UString &sourceURL, int startingLineNumber, const UString &code, const Value &thisV)
+Completion Interpreter::evaluate(const UString &sourceURL, int startingLineNumber, const UString &code, ValueImp *thisV)
{
Completion comp = rep->evaluate(code,thisV, sourceURL, startingLineNumber);
@@ -138,7 +137,7 @@
lock();
ExecState *exec = rep->globalExec();
char *f = strdup(sourceURL.ascii());
- const char *message = comp.value().toObject(exec).toString(exec).ascii();
+ const char *message = comp.value()->toObject(exec)->toString(exec).ascii();
printf("[%d] %s:%s\n", getpid(), f, message);
free(f);
@@ -149,152 +148,152 @@
return comp;
}
-Object Interpreter::builtinObject() const
+ObjectImp *Interpreter::builtinObject() const
{
return rep->builtinObject();
}
-Object Interpreter::builtinFunction() const
+ObjectImp *Interpreter::builtinFunction() const
{
return rep->builtinFunction();
}
-Object Interpreter::builtinArray() const
+ObjectImp *Interpreter::builtinArray() const
{
return rep->builtinArray();
}
-Object Interpreter::builtinBoolean() const
+ObjectImp *Interpreter::builtinBoolean() const
{
return rep->builtinBoolean();
}
-Object Interpreter::builtinString() const
+ObjectImp *Interpreter::builtinString() const
{
return rep->builtinString();
}
-Object Interpreter::builtinNumber() const
+ObjectImp *Interpreter::builtinNumber() const
{
return rep->builtinNumber();
}
-Object Interpreter::builtinDate() const
+ObjectImp *Interpreter::builtinDate() const
{
return rep->builtinDate();
}
-Object Interpreter::builtinRegExp() const
+ObjectImp *Interpreter::builtinRegExp() const
{
return rep->builtinRegExp();
}
-Object Interpreter::builtinError() const
+ObjectImp *Interpreter::builtinError() const
{
return rep->builtinError();
}
-Object Interpreter::builtinObjectPrototype() const
+ObjectImp *Interpreter::builtinObjectPrototype() const
{
return rep->builtinObjectPrototype();
}
-Object Interpreter::builtinFunctionPrototype() const
+ObjectImp *Interpreter::builtinFunctionPrototype() const
{
return rep->builtinFunctionPrototype();
}
-Object Interpreter::builtinArrayPrototype() const
+ObjectImp *Interpreter::builtinArrayPrototype() const
{
return rep->builtinArrayPrototype();
}
-Object Interpreter::builtinBooleanPrototype() const
+ObjectImp *Interpreter::builtinBooleanPrototype() const
{
return rep->builtinBooleanPrototype();
}
-Object Interpreter::builtinStringPrototype() const
+ObjectImp *Interpreter::builtinStringPrototype() const
{
return rep->builtinStringPrototype();
}
-Object Interpreter::builtinNumberPrototype() const
+ObjectImp *Interpreter::builtinNumberPrototype() const
{
return rep->builtinNumberPrototype();
}
-Object Interpreter::builtinDatePrototype() const
+ObjectImp *Interpreter::builtinDatePrototype() const
{
return rep->builtinDatePrototype();
}
-Object Interpreter::builtinRegExpPrototype() const
+ObjectImp *Interpreter::builtinRegExpPrototype() const
{
return rep->builtinRegExpPrototype();
}
-Object Interpreter::builtinErrorPrototype() const
+ObjectImp *Interpreter::builtinErrorPrototype() const
{
return rep->builtinErrorPrototype();
}
-Object Interpreter::builtinEvalError() const
+ObjectImp *Interpreter::builtinEvalError() const
{
return rep->builtinEvalError();
}
-Object Interpreter::builtinRangeError() const
+ObjectImp *Interpreter::builtinRangeError() const
{
return rep->builtinRangeError();
}
-Object Interpreter::builtinReferenceError() const
+ObjectImp *Interpreter::builtinReferenceError() const
{
return rep->builtinReferenceError();
}
-Object Interpreter::builtinSyntaxError() const
+ObjectImp *Interpreter::builtinSyntaxError() const
{
return rep->builtinSyntaxError();
}
-Object Interpreter::builtinTypeError() const
+ObjectImp *Interpreter::builtinTypeError() const
{
return rep->builtinTypeError();
}
-Object Interpreter::builtinURIError() const
+ObjectImp *Interpreter::builtinURIError() const
{
return rep->builtinURIError();
}
-Object Interpreter::builtinEvalErrorPrototype() const
+ObjectImp *Interpreter::builtinEvalErrorPrototype() const
{
return rep->builtinEvalErrorPrototype();
}
-Object Interpreter::builtinRangeErrorPrototype() const
+ObjectImp *Interpreter::builtinRangeErrorPrototype() const
{
return rep->builtinRangeErrorPrototype();
}
-Object Interpreter::builtinReferenceErrorPrototype() const
+ObjectImp *Interpreter::builtinReferenceErrorPrototype() const
{
return rep->builtinReferenceErrorPrototype();
}
-Object Interpreter::builtinSyntaxErrorPrototype() const
+ObjectImp *Interpreter::builtinSyntaxErrorPrototype() const
{
return rep->builtinSyntaxErrorPrototype();
}
-Object Interpreter::builtinTypeErrorPrototype() const
+ObjectImp *Interpreter::builtinTypeErrorPrototype() const
{
return rep->builtinTypeErrorPrototype();
}
-Object Interpreter::builtinURIErrorPrototype() const
+ObjectImp *Interpreter::builtinURIErrorPrototype() const
{
return rep->builtinURIErrorPrototype();
}
@@ -337,7 +336,7 @@
}
-void *Interpreter::createLanguageInstanceForValue (ExecState *exec, int language, const Object &value, const Bindings::RootObject *origin, const Bindings::RootObject *current)
+void *Interpreter::createLanguageInstanceForValue(ExecState *exec, int language, ObjectImp *value, const Bindings::RootObject *origin, const Bindings::RootObject *current)
{
return Bindings::Instance::createLanguageInstanceForValue (exec, (Bindings::Instance::BindingLanguage)language, value, origin, current);
}
diff --git a/JavaScriptCore/kjs/interpreter.h b/JavaScriptCore/kjs/interpreter.h
index 1c68bc1..3ae56ab 100644
--- a/JavaScriptCore/kjs/interpreter.h
+++ b/JavaScriptCore/kjs/interpreter.h
@@ -25,7 +25,6 @@
#ifndef _KJS_INTERPRETER_H_
#define _KJS_INTERPRETER_H_
-#include "object_wrapper.h"
#include "value.h"
#include "types.h"
@@ -34,6 +33,7 @@
class ContextImp;
class InterpreterImp;
class RuntimeMethodImp;
+ class ScopeChain;
namespace Bindings {
class RootObject;
@@ -78,7 +78,7 @@
*
* @return The execution context's variable object
*/
- Object variableObject() const;
+ ObjectImp *variableObject() const;
/**
* Returns the "this" value for the execution context. This is the value
@@ -95,7 +95,7 @@
*
* @return The execution context's "this" value
*/
- Object thisValue() const;
+ ObjectImp *thisValue() const;
/**
* Returns the context from which the current context was invoked. For
@@ -152,7 +152,7 @@
*
* @param global The object to use as the global object for this interpreter
*/
- Interpreter(const Object &global);
+ Interpreter(ObjectImp *global);
/**
* Creates a new interpreter. A global object will be created and
* initialized with the standard global properties.
@@ -164,7 +164,7 @@
* Returns the object that is used as the global object during all script
* execution performed by this interpreter
*/
- Object &globalObject() const;
+ ObjectImp *globalObject() const;
void initGlobalObject();
@@ -208,10 +208,10 @@
* execution. This should either be Null() or an Object.
* @return A completion object representing the result of the execution.
*/
- Completion evaluate(const UString &sourceURL, int startingLineNumber, const UString &code, const Value &thisV = Value());
+ Completion evaluate(const UString &sourceURL, int startingLineNumber, const UString &code, ValueImp *thisV = NULL);
// Overload of evaluate to keep JavaScriptGlue both source and binary compatible.
- Completion evaluate(const UString &code, const Value &thisV = Value(), const UString &sourceFilename = UString());
+ Completion evaluate(const UString &code, ValueImp *thisV = NULL, const UString &sourceFilename = UString());
/**
* @internal
@@ -229,109 +229,109 @@
*
* @return The builtin "Object" object
*/
- Object builtinObject() const;
+ ObjectImp *builtinObject() const;
/**
* Returns the builtin "Function" object.
*/
- Object builtinFunction() const;
+ ObjectImp *builtinFunction() const;
/**
* Returns the builtin "Array" object.
*/
- Object builtinArray() const;
+ ObjectImp *builtinArray() const;
/**
* Returns the builtin "Boolean" object.
*/
- Object builtinBoolean() const;
+ ObjectImp *builtinBoolean() const;
/**
* Returns the builtin "String" object.
*/
- Object builtinString() const;
+ ObjectImp *builtinString() const;
/**
* Returns the builtin "Number" object.
*/
- Object builtinNumber() const;
+ ObjectImp *builtinNumber() const;
/**
* Returns the builtin "Date" object.
*/
- Object builtinDate() const;
+ ObjectImp *builtinDate() const;
/**
* Returns the builtin "RegExp" object.
*/
- Object builtinRegExp() const;
+ ObjectImp *builtinRegExp() const;
/**
* Returns the builtin "Error" object.
*/
- Object builtinError() const;
+ ObjectImp *builtinError() const;
/**
* Returns the builtin "Object.prototype" object.
*/
- Object builtinObjectPrototype() const;
+ ObjectImp *builtinObjectPrototype() const;
/**
* Returns the builtin "Function.prototype" object.
*/
- Object builtinFunctionPrototype() const;
+ ObjectImp *builtinFunctionPrototype() const;
/**
* Returns the builtin "Array.prototype" object.
*/
- Object builtinArrayPrototype() const;
+ ObjectImp *builtinArrayPrototype() const;
/**
* Returns the builtin "Boolean.prototype" object.
*/
- Object builtinBooleanPrototype() const;
+ ObjectImp *builtinBooleanPrototype() const;
/**
* Returns the builtin "String.prototype" object.
*/
- Object builtinStringPrototype() const;
+ ObjectImp *builtinStringPrototype() const;
/**
* Returns the builtin "Number.prototype" object.
*/
- Object builtinNumberPrototype() const;
+ ObjectImp *builtinNumberPrototype() const;
/**
* Returns the builtin "Date.prototype" object.
*/
- Object builtinDatePrototype() const;
+ ObjectImp *builtinDatePrototype() const;
/**
* Returns the builtin "RegExp.prototype" object.
*/
- Object builtinRegExpPrototype() const;
+ ObjectImp *builtinRegExpPrototype() const;
/**
* Returns the builtin "Error.prototype" object.
*/
- Object builtinErrorPrototype() const;
+ ObjectImp *builtinErrorPrototype() const;
/**
* The initial value of "Error" global property
*/
- Object builtinEvalError() const;
- Object builtinRangeError() const;
- Object builtinReferenceError() const;
- Object builtinSyntaxError() const;
- Object builtinTypeError() const;
- Object builtinURIError() const;
+ ObjectImp *builtinEvalError() const;
+ ObjectImp *builtinRangeError() const;
+ ObjectImp *builtinReferenceError() const;
+ ObjectImp *builtinSyntaxError() const;
+ ObjectImp *builtinTypeError() const;
+ ObjectImp *builtinURIError() const;
- Object builtinEvalErrorPrototype() const;
- Object builtinRangeErrorPrototype() const;
- Object builtinReferenceErrorPrototype() const;
- Object builtinSyntaxErrorPrototype() const;
- Object builtinTypeErrorPrototype() const;
- Object builtinURIErrorPrototype() const;
+ ObjectImp *builtinEvalErrorPrototype() const;
+ ObjectImp *builtinRangeErrorPrototype() const;
+ ObjectImp *builtinReferenceErrorPrototype() const;
+ ObjectImp *builtinSyntaxErrorPrototype() const;
+ ObjectImp *builtinTypeErrorPrototype() const;
+ ObjectImp *builtinURIErrorPrototype() const;
enum CompatMode { NativeMode, IECompat, NetscapeCompat };
/**
@@ -380,7 +380,7 @@
* is used to determine if an object is the Window object so we can perform
* security checks.
*/
- virtual bool isGlobalObject(const Value &v) { return false; }
+ virtual bool isGlobalObject(ValueImp *v) { return false; }
/**
* Find the interpreter for a particular global object. This should really
@@ -399,7 +399,7 @@
*/
virtual bool isSafeScript (const Interpreter *target) { return true; }
- virtual void *createLanguageInstanceForValue (ExecState *exec, int language, const Object &value, const Bindings::RootObject *origin, const Bindings::RootObject *current);
+ virtual void *createLanguageInstanceForValue (ExecState *exec, int language, ObjectImp *value, const Bindings::RootObject *origin, const Bindings::RootObject *current);
#endif
// This is a workaround to avoid accessing the global variables for these identifiers in
@@ -470,17 +470,17 @@
*/
Context context() const { return _context; }
- void setException(const Value &e) { _exception = e; }
- void clearException() { _exception = Value(); }
- Value exception() const { return _exception; }
- bool hadException() const { return !_exception.isNull(); }
+ void setException(ValueImp *e) { _exception = e; }
+ void clearException() { _exception = NULL; }
+ ValueImp *exception() const { return _exception; }
+ bool hadException() const { return _exception; }
private:
ExecState(Interpreter *interp, ContextImp *con)
- : _interpreter(interp), _context(con) { }
+ : _interpreter(interp), _context(con), _exception(NULL) { }
Interpreter *_interpreter;
ContextImp *_context;
- Value _exception;
+ ValueImp *_exception;
};
} // namespace
diff --git a/JavaScriptCore/kjs/list.cpp b/JavaScriptCore/kjs/list.cpp
index 92ae019..5d7e252 100644
--- a/JavaScriptCore/kjs/list.cpp
+++ b/JavaScriptCore/kjs/list.cpp
@@ -233,11 +233,11 @@
deallocateListImp(imp);
}
-ValueImp *List::impAt(int i) const
+ValueImp *List::at(int i) const
{
ListImp *imp = static_cast<ListImp *>(_impBase);
if ((unsigned)i >= (unsigned)imp->size)
- return UndefinedImp::staticUndefined;
+ return jsUndefined();
if (i < inlineValuesSize)
return imp->values[i];
return imp->overflow[i - inlineValuesSize];
diff --git a/JavaScriptCore/kjs/list.h b/JavaScriptCore/kjs/list.h
index 0d28bc9..3f43acc 100644
--- a/JavaScriptCore/kjs/list.h
+++ b/JavaScriptCore/kjs/list.h
@@ -62,7 +62,6 @@
*
* @param val Pointer to object.
*/
- void append(const Value& val) { append(val.imp()); }
void append(ValueImp *val);
/**
* Remove all elements from the list.
@@ -104,13 +103,11 @@
* @return Return the element at position i. KJS::Undefined if the
* index is out of range.
*/
- Value at(int i) const { return Value(impAt(i)); }
+ ValueImp *at(int i) const;
/**
* Equivalent to at.
*/
- Value operator[](int i) const { return Value(impAt(i)); }
-
- ValueImp *impAt(int i) const;
+ ValueImp *operator[](int i) const { return at(i); }
/**
* Returns a pointer to a static instance of an empty list. Useful if a
@@ -146,25 +143,25 @@
* Dereference the iterator.
* @return A pointer to the element the iterator operates on.
*/
- ValueImp *operator->() const { return _list->impAt(_i); }
- Value operator*() const { return Value(_list->impAt(_i)); }
+ ValueImp *operator->() const { return _list->at(_i); }
+ ValueImp *operator*() const { return _list->at(_i); }
/**
* Prefix increment operator.
* @return The element after the increment.
*/
- Value operator++() { return Value(_list->impAt(++_i)); }
+ ValueImp *operator++() { return _list->at(++_i); }
/**
* Postfix increment operator.
*/
- Value operator++(int) { return Value(_list->impAt(_i++)); }
+ ValueImp *operator++(int) { return _list->at(_i++); }
/**
* Prefix decrement operator.
*/
- Value operator--() { return Value(_list->impAt(--_i)); }
+ ValueImp *operator--() { return _list->at(--_i); }
/**
* Postfix decrement operator.
*/
- Value operator--(int) { return Value(_list->impAt(_i--)); }
+ ValueImp *operator--(int) { return _list->at(_i--); }
/**
* Compare the iterator with another one.
* @return True if the two iterators operate on the same list element.
diff --git a/JavaScriptCore/kjs/lookup.h b/JavaScriptCore/kjs/lookup.h
index c1aabab..deb39f04 100644
--- a/JavaScriptCore/kjs/lookup.h
+++ b/JavaScriptCore/kjs/lookup.h
@@ -127,17 +127,17 @@
* Helper for getStaticFunctionSlot and getStaticPropertySlot
*/
template <class FuncImp>
- inline Value staticFunctionGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
+ inline ValueImp *staticFunctionGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
{
// Look for cached value in dynamic map of properties (in ObjectImp)
ObjectImp *thisObj = slot.slotBase();
ValueImp *cachedVal = thisObj->getDirect(propertyName);
if (cachedVal)
- return Value(cachedVal);
+ return cachedVal;
const HashEntry *entry = slot.staticEntry();
- Value val = Value(new FuncImp(exec, entry->value, entry->params));
- thisObj->putDirect(propertyName, val.imp(), entry->attr);
+ ValueImp *val = new FuncImp(exec, entry->value, entry->params);
+ thisObj->putDirect(propertyName, val, entry->attr);
return val;
}
@@ -146,7 +146,7 @@
* Helper for getStaticValueSlot and getStaticPropertySlot
*/
template <class ThisImp>
- inline Value staticValueGetter(ExecState *exec, const Identifier&, const PropertySlot& slot)
+ inline ValueImp *staticValueGetter(ExecState *exec, const Identifier&, const PropertySlot& slot)
{
ThisImp *thisObj = static_cast<ThisImp *>(slot.slotBase());
const HashEntry *entry = slot.staticEntry();
@@ -235,7 +235,7 @@
*/
template <class ThisImp, class ParentImp>
inline void lookupPut(ExecState *exec, const Identifier &propertyName,
- const Value& value, int attr,
+ ValueImp *value, int attr,
const HashTable* table, ThisImp* thisObj)
{
const HashEntry* entry = Lookup::findEntry(table, propertyName);
@@ -264,14 +264,14 @@
template <class ClassCtor>
inline ObjectImp *cacheGlobalObject(ExecState *exec, const Identifier &propertyName)
{
- ObjectImp *globalObject = static_cast<ObjectImp *>(exec->lexicalInterpreter()->globalObject().imp());
+ ObjectImp *globalObject = static_cast<ObjectImp *>(exec->lexicalInterpreter()->globalObject());
ValueImp *obj = globalObject->getDirect(propertyName);
if (obj) {
assert(obj->isObject());
return static_cast<ObjectImp *>(obj);
}
ObjectImp *newObject = new ClassCtor(exec);
- globalObject->put(exec, propertyName, Value(newObject), Internal);
+ globalObject->put(exec, propertyName, newObject, Internal);
return newObject;
}
@@ -297,7 +297,7 @@
public: \
static ObjectImp *self(ExecState *exec) \
{ \
- return cacheGlobalObject<ClassProto>( exec, "[[" ClassName ".prototype]]" ); \
+ return cacheGlobalObject<ClassProto>(exec, "[[" ClassName ".prototype]]"); \
} \
protected: \
ClassProto( ExecState *exec ) \
@@ -331,8 +331,8 @@
{ \
put(exec, lengthPropertyName, Number(len), DontDelete|ReadOnly|DontEnum); \
} \
- /* Macro user needs to implement the call function. */ \
- virtual Value call(ExecState *exec, Object &thisObj, const List &args); \
+ /* Macro user needs to implement the callAsFunction function. */ \
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args); \
private: \
int id; \
};
diff --git a/JavaScriptCore/kjs/math_object.cpp b/JavaScriptCore/kjs/math_object.cpp
index 6f457aa..00baf2e 100644
--- a/JavaScriptCore/kjs/math_object.cpp
+++ b/JavaScriptCore/kjs/math_object.cpp
@@ -86,7 +86,7 @@
return getStaticPropertySlot<MathFuncImp, MathObjectImp, ObjectImp>(exec, &mathTable, this, propertyName, slot);
}
-Value MathObjectImp::getValueProperty(ExecState *, int token) const
+ValueImp *MathObjectImp::getValueProperty(ExecState *, int token) const
{
double d = -42; // ;)
switch (token) {
@@ -125,10 +125,9 @@
MathFuncImp::MathFuncImp(ExecState *exec, int i, int l)
: InternalFunctionImp(
- static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype().imp())
+ static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype())
), id(i)
{
- Value protect(this);
putDirect(lengthPropertyName, l, DontDelete|ReadOnly|DontEnum);
}
@@ -137,10 +136,10 @@
return true;
}
-Value MathFuncImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
+ValueImp *MathFuncImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
{
- double arg = args[0].toNumber(exec);
- double arg2 = args[1].toNumber(exec);
+ double arg = args[0]->toNumber(exec);
+ double arg2 = args[1]->toNumber(exec);
double result;
switch (id) {
@@ -178,7 +177,7 @@
unsigned int argsCount = args.size();
result = -Inf;
for ( unsigned int k = 0 ; k < argsCount ; ++k ) {
- double val = args[k].toNumber(exec);
+ double val = args[k]->toNumber(exec);
if ( isNaN( val ) )
{
result = NaN;
@@ -193,7 +192,7 @@
unsigned int argsCount = args.size();
result = +Inf;
for ( unsigned int k = 0 ; k < argsCount ; ++k ) {
- double val = args[k].toNumber(exec);
+ double val = args[k]->toNumber(exec);
if ( isNaN( val ) )
{
result = NaN;
diff --git a/JavaScriptCore/kjs/math_object.h b/JavaScriptCore/kjs/math_object.h
index 6a92565..de2f5e7 100644
--- a/JavaScriptCore/kjs/math_object.h
+++ b/JavaScriptCore/kjs/math_object.h
@@ -32,7 +32,7 @@
MathObjectImp(ExecState *exec,
ObjectPrototypeImp *objProto);
bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
- Value getValueProperty(ExecState *exec, int token) const;
+ ValueImp *getValueProperty(ExecState *exec, int token) const;
virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
enum { Euler, Ln2, Ln10, Log2E, Log10E, Pi, Sqrt1_2, Sqrt2,
@@ -44,7 +44,7 @@
public:
MathFuncImp(ExecState *exec, int i, int l);
virtual bool implementsCall() const;
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
private:
int id;
};
diff --git a/JavaScriptCore/kjs/nodes.cpp b/JavaScriptCore/kjs/nodes.cpp
index ce83f3a..57d1c63 100644
--- a/JavaScriptCore/kjs/nodes.cpp
+++ b/JavaScriptCore/kjs/nodes.cpp
@@ -24,7 +24,6 @@
#include "nodes.h"
-//#include <iostream>
#include <math.h>
#include <assert.h>
#ifdef KJS_DEBUG_MEM
@@ -44,6 +43,7 @@
#include "lexer.h"
#include "operations.h"
#include "ustring.h"
+#include "reference_list.h"
using namespace KJS;
@@ -116,7 +116,7 @@
Reference Node::evaluateReference(ExecState *exec)
{
- Value v = evaluate(exec);
+ ValueImp *v = evaluate(exec);
KJS_CHECKEXCEPTIONREFERENCE
return Reference::makeValueReference(v);
}
@@ -133,16 +133,16 @@
}
#endif
-Value Node::throwError(ExecState *exec, ErrorType e, const char *msg)
+ValueImp *Node::throwError(ExecState *exec, ErrorType e, const char *msg)
{
- Object err = Error::create(exec, e, msg, lineNo(), sourceId(), &sourceURL);
+ ObjectImp *err = Error::create(exec, e, msg, lineNo(), sourceId(), &sourceURL);
exec->setException(err);
return err;
}
-Value Node::throwError(ExecState *exec, ErrorType e, const char *msg, Value v, Node *expr)
+ValueImp *Node::throwError(ExecState *exec, ErrorType e, const char *msg, ValueImp *v, Node *expr)
{
- char *vStr = strdup(v.toString(exec).ascii());
+ char *vStr = strdup(v->toString(exec).ascii());
char *exprStr = strdup(expr->toString().ascii());
int length = strlen(msg) - 4 /* two %s */ + strlen(vStr) + strlen(exprStr) + 1 /* null terminator */;
@@ -151,21 +151,21 @@
free(vStr);
free(exprStr);
- Value result = throwError(exec, e, str);
+ ValueImp *result = throwError(exec, e, str);
delete [] str;
return result;
}
-Value Node::throwError(ExecState *exec, ErrorType e, const char *msg, Identifier label)
+ValueImp *Node::throwError(ExecState *exec, ErrorType e, const char *msg, Identifier label)
{
const char *l = label.ascii();
int length = strlen(msg) - 2 /* %s */ + strlen(l) + 1 /* null terminator */;
char *message = new char[length];
sprintf(message, msg, l);
- Value result = throwError(exec, e, message);
+ ValueImp *result = throwError(exec, e, message);
delete [] message;
return result;
@@ -174,11 +174,11 @@
void Node::setExceptionDetailsIfNeeded(ExecState *exec)
{
if (exec->hadException()) {
- Object exception = exec->exception().toObject(exec);
- if (!exception.hasProperty(exec, "line") &&
- !exception.hasProperty(exec, "sourceURL")) {
- exception.put(exec, "line", Number(line));
- exception.put(exec, "sourceURL", String(sourceURL));
+ ObjectImp *exception = exec->exception()->toObject(exec);
+ if (!exception->hasProperty(exec, "line") &&
+ !exception->hasProperty(exec, "sourceURL")) {
+ exception->put(exec, "line", Number(line));
+ exception->put(exec, "sourceURL", String(sourceURL));
}
}
}
@@ -222,50 +222,48 @@
// ------------------------------ NullNode -------------------------------------
-Value NullNode::evaluate(ExecState */*exec*/)
+ValueImp *NullNode::evaluate(ExecState */*exec*/)
{
return Null();
}
// ------------------------------ BooleanNode ----------------------------------
-Value BooleanNode::evaluate(ExecState */*exec*/)
+ValueImp *BooleanNode::evaluate(ExecState */*exec*/)
{
- return Value(value);
+ return jsBoolean(value);
}
// ------------------------------ NumberNode -----------------------------------
-Value NumberNode::evaluate(ExecState */*exec*/)
+ValueImp *NumberNode::evaluate(ExecState */*exec*/)
{
- return Value(value);
+ return jsNumber(value);
}
// ------------------------------ StringNode -----------------------------------
-Value StringNode::evaluate(ExecState */*exec*/)
+ValueImp *StringNode::evaluate(ExecState */*exec*/)
{
- return value;
+ return jsString(value);
}
// ------------------------------ RegExpNode -----------------------------------
-Value RegExpNode::evaluate(ExecState *exec)
+ValueImp *RegExpNode::evaluate(ExecState *exec)
{
List list;
- String p(pattern);
- String f(flags);
- list.append(p);
- list.append(f);
+ list.append(jsString(pattern));
+ list.append(jsString(flags));
- Object reg = exec->lexicalInterpreter()->imp()->builtinRegExp();
- return reg.construct(exec,list);
+ ObjectImp *reg = exec->lexicalInterpreter()->imp()->builtinRegExp();
+ return reg->construct(exec,list);
}
// ------------------------------ ThisNode -------------------------------------
// ECMA 11.1.1
-Value ThisNode::evaluate(ExecState *exec)
+ValueImp *ThisNode::evaluate(ExecState *exec)
{
return exec->context().imp()->thisValue();
}
@@ -273,7 +271,7 @@
// ------------------------------ ResolveNode ----------------------------------
// ECMA 11.1.2 & 10.1.4
-Value ResolveNode::evaluate(ExecState *exec)
+ValueImp *ResolveNode::evaluate(ExecState *exec)
{
ScopeChain chain = exec->context().imp()->scopeChain();
@@ -282,13 +280,14 @@
PropertySlot slot;
do {
ObjectImp *o = chain.top();
+
if (o->getPropertySlot(exec, ident, slot))
return slot.getValue(exec, ident);
chain.pop();
} while (!chain.isEmpty());
- return Reference(Null(), ident).getValue(exec);
+ return Reference(ident).getValue(exec);
}
Reference ResolveNode::evaluateReference(ExecState *exec)
@@ -306,10 +305,9 @@
chain.pop();
} while (!chain.isEmpty());
- return Reference(Null(), ident);
+ return Reference(ident);
}
-
// ------------------------------ GroupNode ------------------------------------
void GroupNode::ref()
@@ -327,7 +325,7 @@
}
// ECMA 11.1.6
-Value GroupNode::evaluate(ExecState *exec)
+ValueImp *GroupNode::evaluate(ExecState *exec)
{
return group->evaluate(exec);
}
@@ -362,15 +360,15 @@
}
// ECMA 11.1.4
-Value ElementNode::evaluate(ExecState *exec)
+ValueImp *ElementNode::evaluate(ExecState *exec)
{
- Object array = exec->lexicalInterpreter()->builtinArray().construct(exec, List::empty());
+ ObjectImp *array = exec->lexicalInterpreter()->builtinArray()->construct(exec, List::empty());
int length = 0;
for (ElementNode *n = this; n; n = n->list) {
- Value val = n->node->evaluate(exec);
+ ValueImp *val = n->node->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
length += n->elision;
- array.put(exec, length++, val);
+ array->put(exec, length++, val);
}
return array;
}
@@ -392,23 +390,23 @@
}
// ECMA 11.1.4
-Value ArrayNode::evaluate(ExecState *exec)
+ValueImp *ArrayNode::evaluate(ExecState *exec)
{
- Object array;
+ ObjectImp *array;
int length;
if (element) {
- array = Object(static_cast<ObjectImp*>(element->evaluate(exec).imp()));
+ array = static_cast<ObjectImp*>(element->evaluate(exec));
KJS_CHECKEXCEPTIONVALUE
- length = opt ? array.get(exec,lengthPropertyName).toInt32(exec) : 0;
+ length = opt ? array->get(exec,lengthPropertyName)->toInt32(exec) : 0;
} else {
- Value newArr = exec->lexicalInterpreter()->builtinArray().construct(exec,List::empty());
- array = Object(static_cast<ObjectImp*>(newArr.imp()));
+ ValueImp *newArr = exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty());
+ array = static_cast<ObjectImp*>(newArr);
length = 0;
}
if (opt)
- array.put(exec,lengthPropertyName, Value(elision + length), DontEnum | DontDelete);
+ array->put(exec,lengthPropertyName, jsNumber(elision + length), DontEnum | DontDelete);
return array;
}
@@ -430,12 +428,12 @@
}
// ECMA 11.1.5
-Value ObjectLiteralNode::evaluate(ExecState *exec)
+ValueImp *ObjectLiteralNode::evaluate(ExecState *exec)
{
if (list)
return list->evaluate(exec);
- return exec->lexicalInterpreter()->builtinObject().construct(exec,List::empty());
+ return exec->lexicalInterpreter()->builtinObject()->construct(exec,List::empty());
}
// ------------------------------ PropertyValueNode ----------------------------
@@ -467,17 +465,17 @@
}
// ECMA 11.1.5
-Value PropertyValueNode::evaluate(ExecState *exec)
+ValueImp *PropertyValueNode::evaluate(ExecState *exec)
{
- Object obj = exec->lexicalInterpreter()->builtinObject().construct(exec, List::empty());
+ ObjectImp *obj = exec->lexicalInterpreter()->builtinObject()->construct(exec, List::empty());
for (PropertyValueNode *p = this; p; p = p->list) {
- Value n = p->name->evaluate(exec);
+ ValueImp *n = p->name->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
- Value v = p->assign->evaluate(exec);
+ ValueImp *v = p->assign->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
- obj.put(exec, Identifier(n.toString(exec)), v);
+ obj->put(exec, Identifier(n->toString(exec)), v);
}
return obj;
@@ -486,9 +484,9 @@
// ------------------------------ PropertyNode ---------------------------------
// ECMA 11.1.5
-Value PropertyNode::evaluate(ExecState */*exec*/)
+ValueImp *PropertyNode::evaluate(ExecState */*exec*/)
{
- Value s;
+ ValueImp *s;
if (str.isNull()) {
s = String(UString::from(numeric));
@@ -520,36 +518,32 @@
}
// ECMA 11.2.1a
-Value AccessorNode1::evaluate(ExecState *exec)
+ValueImp *AccessorNode1::evaluate(ExecState *exec)
{
- Value v1 = expr1->evaluate(exec);
+ ValueImp *v1 = expr1->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
- Value v2 = expr2->evaluate(exec);
+ ValueImp *v2 = expr2->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
- Object o = v1.toObject(exec);
- unsigned i;
- if (v2.toUInt32(i))
- return o.get(exec, i);
-
- String s = v2.toString(exec);
- return o.get(exec, Identifier(s.value()));
+ ObjectImp *o = v1->toObject(exec);
+ uint32_t i;
+ if (v2->getUInt32(i))
+ return o->get(exec, i);
+ return o->get(exec, Identifier(v2->toString(exec)));
}
Reference AccessorNode1::evaluateReference(ExecState *exec)
{
- Value v1 = expr1->evaluate(exec);
+ ValueImp *v1 = expr1->evaluate(exec);
KJS_CHECKEXCEPTIONREFERENCE
- Value v2 = expr2->evaluate(exec);
+ ValueImp *v2 = expr2->evaluate(exec);
KJS_CHECKEXCEPTIONREFERENCE
- Object o = v1.toObject(exec);
- unsigned i;
- if (v2.toUInt32(i))
+ ObjectImp *o = v1->toObject(exec);
+ uint32_t i;
+ if (v2->getUInt32(i))
return Reference(o, i);
- String s = v2.toString(exec);
- return Reference(o, Identifier(s.value()));
+ return Reference(o, Identifier(v2->toString(exec)));
}
-
// ------------------------------ AccessorNode2 --------------------------------
void AccessorNode2::ref()
@@ -567,20 +561,19 @@
}
// ECMA 11.2.1b
-Value AccessorNode2::evaluate(ExecState *exec)
+ValueImp *AccessorNode2::evaluate(ExecState *exec)
{
- Value v = expr->evaluate(exec);
+ ValueImp *v = expr->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
- Object o = v.toObject(exec);
- return o.get(exec, ident);
+ return v->toObject(exec)->get(exec, ident);
}
Reference AccessorNode2::evaluateReference(ExecState *exec)
{
- Value v = expr->evaluate(exec);
+ ValueImp *v = expr->evaluate(exec);
KJS_CHECKEXCEPTIONREFERENCE
- Object o = v.toObject(exec);
+ ObjectImp *o = v->toObject(exec);
return Reference(o, ident);
}
@@ -608,10 +601,10 @@
return Node::deref();
}
-Value ArgumentListNode::evaluate(ExecState */*exec*/)
+ValueImp *ArgumentListNode::evaluate(ExecState */*exec*/)
{
assert(0);
- return Value(); // dummy, see evaluateList()
+ return NULL; // dummy, see evaluateList()
}
// ECMA 11.2.4
@@ -620,7 +613,7 @@
List l;
for (ArgumentListNode *n = this; n; n = n->list) {
- Value v = n->expr->evaluate(exec);
+ ValueImp *v = n->expr->evaluate(exec);
KJS_CHECKEXCEPTIONLIST
l.append(v);
}
@@ -644,10 +637,10 @@
return Node::deref();
}
-Value ArgumentsNode::evaluate(ExecState */*exec*/)
+ValueImp *ArgumentsNode::evaluate(ExecState */*exec*/)
{
assert(0);
- return Value(); // dummy, see evaluateList()
+ return NULL; // dummy, see evaluateList()
}
// ECMA 11.2.4
@@ -681,9 +674,9 @@
return Node::deref();
}
-Value NewExprNode::evaluate(ExecState *exec)
+ValueImp *NewExprNode::evaluate(ExecState *exec)
{
- Value v = expr->evaluate(exec);
+ ValueImp *v = expr->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
List argList;
@@ -692,18 +685,16 @@
KJS_CHECKEXCEPTIONVALUE
}
- if (v.type() != ObjectType) {
+ if (!v->isObject()) {
return throwError(exec, TypeError, "Value %s (result of expression %s) is not an object. Cannot be used with new.", v, expr);
}
- Object constr = Object(static_cast<ObjectImp*>(v.imp()));
- if (!constr.implementsConstruct()) {
+ ObjectImp *constr = static_cast<ObjectImp*>(v);
+ if (!constr->implementsConstruct()) {
return throwError(exec, TypeError, "Value %s (result of expression %s) is not a constructor. Cannot be used with new.", v, expr);
}
- Value res = constr.construct(exec,argList);
-
- return res;
+ return constr->construct(exec, argList);
}
// ------------------------------ FunctionCallNode -----------------------------
@@ -727,7 +718,7 @@
}
// ECMA 11.2.3
-Value FunctionCallNode::evaluate(ExecState *exec)
+ValueImp *FunctionCallNode::evaluate(ExecState *exec)
{
Reference ref = expr->evaluateReference(exec);
KJS_CHECKEXCEPTIONVALUE
@@ -735,14 +726,14 @@
List argList = args->evaluateList(exec);
KJS_CHECKEXCEPTIONVALUE
- Value v = ref.getValue(exec);
+ ValueImp *v = ref.getValue(exec);
KJS_CHECKEXCEPTIONVALUE
-
- if (v.type() != ObjectType) {
+
+ if (!v->isObject()) {
return throwError(exec, TypeError, "Value %s (result of expression %s) is not object.", v, expr);
}
-
- ObjectImp *func = static_cast<ObjectImp*>(v.imp());
+
+ ObjectImp *func = static_cast<ObjectImp*>(v);
if (!func->implementsCall()) {
return throwError(exec, TypeError, "Object %s (result of expression %s) does not allow calls.", v, expr);
@@ -750,7 +741,7 @@
ObjectImp *thisObjImp = 0;
ValueImp *thisValImp = ref.baseIfMutable();
- if (thisValImp && thisValImp->type() == ObjectType && !static_cast<ObjectImp *>(thisValImp)->inherits(&ActivationImp::info))
+ if (thisValImp && thisValImp->isObject() && !static_cast<ObjectImp *>(thisValImp)->inherits(&ActivationImp::info))
thisObjImp = static_cast<ObjectImp *>(thisValImp);
if (!thisObjImp) {
@@ -760,10 +751,10 @@
// that the section does not apply to interal functions, but for simplicity
// of implementation we use the global object anyway here. This guarantees
// that in host objects you always get a valid object for this.
- thisObjImp = exec->dynamicInterpreter()->globalObject().imp();
+ thisObjImp = exec->dynamicInterpreter()->globalObject();
}
- Object thisObj(thisObjImp);
+ ObjectImp *thisObj(thisObjImp);
return func->call(exec, thisObj, argList);
}
@@ -784,19 +775,19 @@
}
// ECMA 11.3
-Value PostfixNode::evaluate(ExecState *exec)
+ValueImp *PostfixNode::evaluate(ExecState *exec)
{
Reference ref = expr->evaluateReference(exec);
KJS_CHECKEXCEPTIONVALUE
- Value v = ref.getValue(exec);
+ ValueImp *v = ref.getValue(exec);
bool knownToBeInteger;
- double n = v.toNumber(exec, knownToBeInteger);
+ double n = v->toNumber(exec, knownToBeInteger);
double newValue = (oper == OpPlusPlus) ? n + 1 : n - 1;
- ref.putValue(exec, Value(newValue, knownToBeInteger));
+ ref.putValue(exec, jsNumber(newValue, knownToBeInteger));
- return Value(n, knownToBeInteger);
+ return jsNumber(n, knownToBeInteger);
}
// ------------------------------ DeleteNode -----------------------------------
@@ -816,11 +807,11 @@
}
// ECMA 11.4.1
-Value DeleteNode::evaluate(ExecState *exec)
+ValueImp *DeleteNode::evaluate(ExecState *exec)
{
Reference ref = expr->evaluateReference(exec);
KJS_CHECKEXCEPTIONVALUE
- return Value(ref.deleteValue(exec));
+ return jsBoolean(ref.deleteValue(exec));
}
// ------------------------------ VoidNode -------------------------------------
@@ -840,9 +831,9 @@
}
// ECMA 11.4.2
-Value VoidNode::evaluate(ExecState *exec)
+ValueImp *VoidNode::evaluate(ExecState *exec)
{
- Value dummy1 = expr->evaluate(exec);
+ expr->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
return Undefined();
@@ -865,16 +856,16 @@
}
// ECMA 11.4.3
-Value TypeOfNode::evaluate(ExecState *exec)
+ValueImp *TypeOfNode::evaluate(ExecState *exec)
{
const char *s = 0L;
Reference ref = expr->evaluateReference(exec);
KJS_CHECKEXCEPTIONVALUE
ValueImp *b = ref.baseIfMutable();
- if (b && b->dispatchType() == NullType)
- return Value("undefined");
- Value v = ref.getValue(exec);
- switch (v.type())
+ if (b && b->isNull())
+ return jsString("undefined");
+ ValueImp *v = ref.getValue(exec);
+ switch (v->type())
{
case UndefinedType:
s = "undefined";
@@ -892,14 +883,14 @@
s = "string";
break;
default:
- if (v.type() == ObjectType && static_cast<ObjectImp*>(v.imp())->implementsCall())
+ if (v->isObject() && static_cast<ObjectImp*>(v)->implementsCall())
s = "function";
else
s = "object";
break;
}
- return Value(s);
+ return jsString(s);
}
// ------------------------------ PrefixNode -----------------------------------
@@ -919,17 +910,17 @@
}
// ECMA 11.4.4 and 11.4.5
-Value PrefixNode::evaluate(ExecState *exec)
+ValueImp *PrefixNode::evaluate(ExecState *exec)
{
Reference ref = expr->evaluateReference(exec);
KJS_CHECKEXCEPTIONVALUE
- Value v = ref.getValue(exec);
+ ValueImp *v = ref.getValue(exec);
bool knownToBeInteger;
- double n = v.toNumber(exec, knownToBeInteger);
+ double n = v->toNumber(exec, knownToBeInteger);
double newValue = (oper == OpPlusPlus) ? n + 1 : n - 1;
- Value n2(newValue, knownToBeInteger);
+ ValueImp *n2 = jsNumber(newValue, knownToBeInteger);
ref.putValue(exec, n2);
@@ -953,12 +944,12 @@
}
// ECMA 11.4.6
-Value UnaryPlusNode::evaluate(ExecState *exec)
+ValueImp *UnaryPlusNode::evaluate(ExecState *exec)
{
- Value v = expr->evaluate(exec);
+ ValueImp *v = expr->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
- return Value(v.toNumber(exec)); /* TODO: optimize */
+ return jsNumber(v->toNumber(exec)); /* TODO: optimize */
}
// ------------------------------ NegateNode -----------------------------------
@@ -978,14 +969,14 @@
}
// ECMA 11.4.7
-Value NegateNode::evaluate(ExecState *exec)
+ValueImp *NegateNode::evaluate(ExecState *exec)
{
- Value v = expr->evaluate(exec);
+ ValueImp *v = expr->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
bool knownToBeInteger;
- double n = v.toNumber(exec, knownToBeInteger);
- return Value(-n, knownToBeInteger && n != 0);
+ double n = v->toNumber(exec, knownToBeInteger);
+ return jsNumber(-n, knownToBeInteger && n != 0);
}
// ------------------------------ BitwiseNotNode -------------------------------
@@ -1005,11 +996,11 @@
}
// ECMA 11.4.8
-Value BitwiseNotNode::evaluate(ExecState *exec)
+ValueImp *BitwiseNotNode::evaluate(ExecState *exec)
{
- Value v = expr->evaluate(exec);
+ ValueImp *v = expr->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
- return Value(~v.toInt32(exec));
+ return jsNumber(~v->toInt32(exec));
}
// ------------------------------ LogicalNotNode -------------------------------
@@ -1029,11 +1020,11 @@
}
// ECMA 11.4.9
-Value LogicalNotNode::evaluate(ExecState *exec)
+ValueImp *LogicalNotNode::evaluate(ExecState *exec)
{
- Value v = expr->evaluate(exec);
+ ValueImp *v = expr->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
- return Value(!v.toBoolean(exec));
+ return jsBoolean(!v->toBoolean(exec));
}
// ------------------------------ MultNode -------------------------------------
@@ -1057,12 +1048,12 @@
}
// ECMA 11.5
-Value MultNode::evaluate(ExecState *exec)
+ValueImp *MultNode::evaluate(ExecState *exec)
{
- Value v1 = term1->evaluate(exec);
+ ValueImp *v1 = term1->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
- Value v2 = term2->evaluate(exec);
+ ValueImp *v2 = term2->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
return mult(exec, v1, v2, oper);
@@ -1089,12 +1080,12 @@
}
// ECMA 11.6
-Value AddNode::evaluate(ExecState *exec)
+ValueImp *AddNode::evaluate(ExecState *exec)
{
- Value v1 = term1->evaluate(exec);
+ ValueImp *v1 = term1->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
- Value v2 = term2->evaluate(exec);
+ ValueImp *v2 = term2->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
return add(exec, v1, v2, oper);
@@ -1121,22 +1112,22 @@
}
// ECMA 11.7
-Value ShiftNode::evaluate(ExecState *exec)
+ValueImp *ShiftNode::evaluate(ExecState *exec)
{
- Value v1 = term1->evaluate(exec);
+ ValueImp *v1 = term1->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
- Value v2 = term2->evaluate(exec);
+ ValueImp *v2 = term2->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
- unsigned int i2 = v2.toUInt32(exec);
+ unsigned int i2 = v2->toUInt32(exec);
i2 &= 0x1f;
switch (oper) {
case OpLShift:
- return Value(v1.toInt32(exec) << i2);
+ return jsNumber(v1->toInt32(exec) << i2);
case OpRShift:
- return Value(v1.toInt32(exec) >> i2);
+ return jsNumber(v1->toInt32(exec) >> i2);
case OpURShift:
- return Value(v1.toUInt32(exec) >> i2);
+ return jsNumber(v1->toUInt32(exec) >> i2);
default:
assert(!"ShiftNode: unhandled switch case");
return Undefined();
@@ -1164,11 +1155,11 @@
}
// ECMA 11.8
-Value RelationalNode::evaluate(ExecState *exec)
+ValueImp *RelationalNode::evaluate(ExecState *exec)
{
- Value v1 = expr1->evaluate(exec);
+ ValueImp *v1 = expr1->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
- Value v2 = expr2->evaluate(exec);
+ ValueImp *v2 = expr2->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
bool b;
@@ -1186,30 +1177,30 @@
b = (oper == OpGreater) ? (r == 1) : (r == 0);
} else if (oper == OpIn) {
// Is all of this OK for host objects?
- if (v2.type() != ObjectType)
+ if (!v2->isObject())
return throwError(exec, TypeError,
"Value %s (result of expression %s) is not an object. Cannot be used with IN expression.", v2, expr2);
- Object o2(static_cast<ObjectImp*>(v2.imp()));
- b = o2.hasProperty(exec, Identifier(v1.toString(exec)));
+ ObjectImp *o2(static_cast<ObjectImp*>(v2));
+ b = o2->hasProperty(exec, Identifier(v1->toString(exec)));
} else {
- if (v2.type() != ObjectType)
+ if (!v2->isObject())
return throwError(exec, TypeError,
"Value %s (result of expression %s) is not an object. Cannot be used with instanceof operator.", v2, expr2);
- Object o2(static_cast<ObjectImp*>(v2.imp()));
- if (!o2.implementsHasInstance()) {
- // According to the spec, only some types of objects "imlement" the [[HasInstance]] property.
+ ObjectImp *o2(static_cast<ObjectImp*>(v2));
+ if (!o2->implementsHasInstance()) {
+ // According to the spec, only some types of objects "implement" the [[HasInstance]] property.
// But we are supposed to throw an exception where the object does not "have" the [[HasInstance]]
// property. It seems that all object have the property, but not all implement it, so in this
// case we return false (consistent with mozilla)
- return Value(false);
+ return jsBoolean(false);
// return throwError(exec, TypeError,
// "Object does not implement the [[HasInstance]] method." );
}
- return o2.hasInstance(exec, v1);
+ return jsBoolean(o2->hasInstance(exec, v1));
}
- return Value(b);
+ return jsBoolean(b);
}
// ------------------------------ EqualNode ------------------------------------
@@ -1233,11 +1224,11 @@
}
// ECMA 11.9
-Value EqualNode::evaluate(ExecState *exec)
+ValueImp *EqualNode::evaluate(ExecState *exec)
{
- Value v1 = expr1->evaluate(exec);
+ ValueImp *v1 = expr1->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
- Value v2 = expr2->evaluate(exec);
+ ValueImp *v2 = expr2->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
bool result;
@@ -1250,7 +1241,7 @@
bool eq = strictEqual(exec,v1, v2);
result = oper == OpStrEq ? eq : !eq;
}
- return Value(result);
+ return jsBoolean(result);
}
// ------------------------------ BitOperNode ----------------------------------
@@ -1274,14 +1265,14 @@
}
// ECMA 11.10
-Value BitOperNode::evaluate(ExecState *exec)
+ValueImp *BitOperNode::evaluate(ExecState *exec)
{
- Value v1 = expr1->evaluate(exec);
+ ValueImp *v1 = expr1->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
- Value v2 = expr2->evaluate(exec);
+ ValueImp *v2 = expr2->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
- int i1 = v1.toInt32(exec);
- int i2 = v2.toInt32(exec);
+ int i1 = v1->toInt32(exec);
+ int i2 = v2->toInt32(exec);
int result;
if (oper == OpBitAnd)
result = i1 & i2;
@@ -1290,7 +1281,7 @@
else
result = i1 | i2;
- return Value(result);
+ return jsNumber(result);
}
// ------------------------------ BinaryLogicalNode ----------------------------
@@ -1314,15 +1305,15 @@
}
// ECMA 11.11
-Value BinaryLogicalNode::evaluate(ExecState *exec)
+ValueImp *BinaryLogicalNode::evaluate(ExecState *exec)
{
- Value v1 = expr1->evaluate(exec);
+ ValueImp *v1 = expr1->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
- bool b1 = v1.toBoolean(exec);
+ bool b1 = v1->toBoolean(exec);
if ((!b1 && oper == OpAnd) || (b1 && oper == OpOr))
return v1;
- Value v2 = expr2->evaluate(exec);
+ ValueImp *v2 = expr2->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
return v2;
@@ -1353,11 +1344,11 @@
}
// ECMA 11.12
-Value ConditionalNode::evaluate(ExecState *exec)
+ValueImp *ConditionalNode::evaluate(ExecState *exec)
{
- Value v = logical->evaluate(exec);
+ ValueImp *v = logical->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
- bool b = v.toBoolean(exec);
+ bool b = v->toBoolean(exec);
if (b)
v = expr1->evaluate(exec);
@@ -1389,17 +1380,17 @@
}
// ECMA 11.13
-Value AssignNode::evaluate(ExecState *exec)
+ValueImp *AssignNode::evaluate(ExecState *exec)
{
Reference l = left->evaluateReference(exec);
KJS_CHECKEXCEPTIONVALUE
- Value e, v;
+ ValueImp *v;
if (oper == OpEqual) {
v = expr->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
} else {
- Value v1 = l.getValue(exec);
- Value v2 = expr->evaluate(exec);
+ ValueImp *v1 = l.getValue(exec);
+ ValueImp *v2 = expr->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
int i1;
int i2;
@@ -1418,41 +1409,41 @@
v = add(exec, v1, v2, '-');
break;
case OpLShift:
- i1 = v1.toInt32(exec);
- i2 = v2.toInt32(exec);
- v = Value(i1 << i2);
+ i1 = v1->toInt32(exec);
+ i2 = v2->toInt32(exec);
+ v = jsNumber(i1 << i2);
break;
case OpRShift:
- i1 = v1.toInt32(exec);
- i2 = v2.toInt32(exec);
- v = Value(i1 >> i2);
+ i1 = v1->toInt32(exec);
+ i2 = v2->toInt32(exec);
+ v = jsNumber(i1 >> i2);
break;
case OpURShift:
- ui = v1.toUInt32(exec);
- i2 = v2.toInt32(exec);
- v = Value(ui >> i2);
+ ui = v1->toUInt32(exec);
+ i2 = v2->toInt32(exec);
+ v = jsNumber(ui >> i2);
break;
case OpAndEq:
- i1 = v1.toInt32(exec);
- i2 = v2.toInt32(exec);
- v = Value(i1 & i2);
+ i1 = v1->toInt32(exec);
+ i2 = v2->toInt32(exec);
+ v = jsNumber(i1 & i2);
break;
case OpXOrEq:
- i1 = v1.toInt32(exec);
- i2 = v2.toInt32(exec);
- v = Value(i1 ^ i2);
+ i1 = v1->toInt32(exec);
+ i2 = v2->toInt32(exec);
+ v = jsNumber(i1 ^ i2);
break;
case OpOrEq:
- i1 = v1.toInt32(exec);
- i2 = v2.toInt32(exec);
- v = Value(i1 | i2);
+ i1 = v1->toInt32(exec);
+ i2 = v2->toInt32(exec);
+ v = jsNumber(i1 | i2);
break;
case OpModEq: {
bool d1KnownToBeInteger;
- double d1 = v1.toNumber(exec, d1KnownToBeInteger);
+ double d1 = v1->toNumber(exec, d1KnownToBeInteger);
bool d2KnownToBeInteger;
- double d2 = v2.toNumber(exec, d2KnownToBeInteger);
- v = Value(fmod(d1, d2), d1KnownToBeInteger && d2KnownToBeInteger && d2 != 0);
+ double d2 = v2->toNumber(exec, d2KnownToBeInteger);
+ v = jsNumber(fmod(d1, d2), d1KnownToBeInteger && d2KnownToBeInteger && d2 != 0);
}
break;
default:
@@ -1487,11 +1478,11 @@
}
// ECMA 11.14
-Value CommaNode::evaluate(ExecState *exec)
+ValueImp *CommaNode::evaluate(ExecState *exec)
{
- Value dummy = expr1->evaluate(exec);
+ expr1->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
- Value v = expr2->evaluate(exec);
+ ValueImp *v = expr2->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
return v;
@@ -1540,7 +1531,7 @@
Completion c = statement->execute(exec);
KJS_ABORTPOINT
if (exec->hadException()) {
- Value ex = exec->exception();
+ ValueImp *ex = exec->exception();
exec->clearException();
return Completion(Throw, ex);
}
@@ -1548,7 +1539,7 @@
if (c.complType() != Normal)
return c;
- Value v = c.value();
+ ValueImp *v = c.value();
for (StatListNode *n = list; n; n = n->list) {
Completion c2 = n->statement->execute(exec);
@@ -1557,7 +1548,7 @@
return c2;
if (exec->hadException()) {
- Value ex = exec->exception();
+ ValueImp *ex = exec->exception();
exec->clearException();
return Completion(Throw, ex);
}
@@ -1593,7 +1584,7 @@
}
// ECMA 12.2
-Value AssignExprNode::evaluate(ExecState *exec)
+ValueImp *AssignExprNode::evaluate(ExecState *exec)
{
return expr->evaluate(exec);
}
@@ -1621,19 +1612,19 @@
}
// ECMA 12.2
-Value VarDeclNode::evaluate(ExecState *exec)
+ValueImp *VarDeclNode::evaluate(ExecState *exec)
{
- Object variable = exec->context().imp()->variableObject();
+ ObjectImp *variable = exec->context().imp()->variableObject();
- Value val;
+ ValueImp *val;
if (init) {
val = init->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
} else {
// already declared? - check with getDirect so you can override
// built-in properties of the global object with var declarations.
- if ( variable.imp()->getDirect(ident) )
- return Value();
+ if (variable->getDirect(ident))
+ return NULL;
val = Undefined();
}
@@ -1647,24 +1638,24 @@
flags |= DontDelete;
if (varType == VarDeclNode::Constant)
flags |= ReadOnly;
- variable.put(exec, ident, val, flags);
+ variable->put(exec, ident, val, flags);
- return ident.ustring();
+ return jsString(ident.ustring());
}
void VarDeclNode::processVarDecls(ExecState *exec)
{
- Object variable = exec->context().imp()->variableObject();
+ ObjectImp *variable = exec->context().imp()->variableObject();
// If a variable by this name already exists, don't clobber it -
// it might be a function parameter
- if (!variable.hasProperty(exec, ident)) {
+ if (!variable->hasProperty(exec, ident)) {
int flags = Internal;
if (exec->context().imp()->codeType() != EvalCode)
flags |= DontDelete;
if (varType == VarDeclNode::Constant)
flags |= ReadOnly;
- variable.put(exec, ident, Undefined(), flags);
+ variable->put(exec, ident, Undefined(), flags);
}
}
@@ -1694,7 +1685,7 @@
// ECMA 12.2
-Value VarDeclListNode::evaluate(ExecState *exec)
+ValueImp *VarDeclListNode::evaluate(ExecState *exec)
{
for (VarDeclListNode *n = this; n; n = n->list) {
n->var->evaluate(exec);
@@ -1814,7 +1805,7 @@
{
KJS_BREAKPOINT;
- Value v = expr->evaluate(exec);
+ ValueImp *v = expr->evaluate(exec);
KJS_CHECKEXCEPTION
return Completion(Normal, v);
@@ -1849,9 +1840,9 @@
{
KJS_BREAKPOINT;
- Value v = expr->evaluate(exec);
+ ValueImp *v = expr->evaluate(exec);
KJS_CHECKEXCEPTION
- bool b = v.toBoolean(exec);
+ bool b = v->toBoolean(exec);
// if ... then
if (b)
@@ -1898,9 +1889,8 @@
{
KJS_BREAKPOINT;
- Value be, bv;
+ ValueImp *bv;
Completion c;
- Value value;
do {
// bail out on error
@@ -1911,15 +1901,15 @@
exec->context().imp()->seenLabels()->popIteration();
if (!((c.complType() == Continue) && ls.contains(c.target()))) {
if ((c.complType() == Break) && ls.contains(c.target()))
- return Completion(Normal, value);
+ return Completion(Normal, NULL);
if (c.complType() != Normal)
return c;
}
bv = expr->evaluate(exec);
KJS_CHECKEXCEPTION
- } while (bv.toBoolean(exec));
+ } while (bv->toBoolean(exec));
- return Completion(Normal, value);
+ return Completion(Normal, NULL);
}
void DoWhileNode::processVarDecls(ExecState *exec)
@@ -1952,15 +1942,15 @@
{
KJS_BREAKPOINT;
- Value be, bv;
+ ValueImp *bv;
Completion c;
bool b(false);
- Value value;
+ ValueImp *value = NULL;
while (1) {
bv = expr->evaluate(exec);
KJS_CHECKEXCEPTION
- b = bv.toBoolean(exec);
+ b = bv->toBoolean(exec);
// bail out on error
KJS_CHECKEXCEPTION
@@ -2021,7 +2011,7 @@
// ECMA 12.6.3
Completion ForNode::execute(ExecState *exec)
{
- Value v, cval;
+ ValueImp *v, *cval = NULL;
if (expr1) {
v = expr1->evaluate(exec);
@@ -2031,7 +2021,7 @@
if (expr2) {
v = expr2->evaluate(exec);
KJS_CHECKEXCEPTION
- if (!v.toBoolean(exec))
+ if (!v->toBoolean(exec))
return Completion(Normal, cval);
}
// bail out on error
@@ -2113,8 +2103,9 @@
// ECMA 12.6.4
Completion ForInNode::execute(ExecState *exec)
{
- Value e, retval;
- Object v;
+ ValueImp *e;
+ ValueImp *retval = NULL;
+ ObjectImp *v;
Completion c;
ReferenceList propList;
@@ -2129,19 +2120,19 @@
// the loop at all, because their object wrappers will have a
// property list but will throw an exception if you attempt to
// access any property.
- if (e.type() == UndefinedType || e.type() == NullType) {
- return Completion(Normal, retval);
+ if (e->isUndefinedOrNull()) {
+ return Completion(Normal, NULL);
}
KJS_CHECKEXCEPTION
- v = e.toObject(exec);
- propList = v.propList(exec);
+ v = e->toObject(exec);
+ propList = v->propList(exec);
ReferenceListIterator propIt = propList.begin();
while (propIt != propList.end()) {
Identifier name = propIt->getPropertyName(exec);
- if (!v.hasProperty(exec,name)) {
+ if (!v->hasProperty(exec,name)) {
propIt++;
continue;
}
@@ -2185,8 +2176,6 @@
{
KJS_BREAKPOINT;
- Value dummy;
-
if (ident.isEmpty() && !exec->context().imp()->seenLabels()->inIteration())
return Completion(Throw,
throwError(exec, SyntaxError, "Invalid continue statement."));
@@ -2194,7 +2183,7 @@
return Completion(Throw,
throwError(exec, SyntaxError, "Label %s not found.", ident));
else
- return Completion(Continue, dummy, ident);
+ return Completion(Continue, NULL, ident);
}
// ------------------------------ BreakNode ------------------------------------
@@ -2204,8 +2193,6 @@
{
KJS_BREAKPOINT;
- Value dummy;
-
if (ident.isEmpty() && !exec->context().imp()->seenLabels()->inIteration() &&
!exec->context().imp()->seenLabels()->inSwitch())
return Completion(Throw,
@@ -2214,7 +2201,7 @@
return Completion(Throw,
throwError(exec, SyntaxError, "Label %s not found.", ident));
else
- return Completion(Break, dummy, ident);
+ return Completion(Break, NULL, ident);
}
// ------------------------------ ReturnNode -----------------------------------
@@ -2246,7 +2233,7 @@
if (!value)
return Completion(ReturnValue, Undefined());
- Value v = value->evaluate(exec);
+ ValueImp *v = value->evaluate(exec);
KJS_CHECKEXCEPTION
return Completion(ReturnValue, v);
@@ -2277,9 +2264,9 @@
{
KJS_BREAKPOINT;
- Value v = expr->evaluate(exec);
+ ValueImp *v = expr->evaluate(exec);
KJS_CHECKEXCEPTION
- Object o = v.toObject(exec);
+ ObjectImp *o = v->toObject(exec);
KJS_CHECKEXCEPTION
exec->context().imp()->pushScope(o);
Completion res = statement->execute(exec);
@@ -2314,9 +2301,9 @@
}
// ECMA 12.11
-Value CaseClauseNode::evaluate(ExecState *exec)
+ValueImp *CaseClauseNode::evaluate(ExecState *exec)
{
- Value v = expr->evaluate(exec);
+ ValueImp *v = expr->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
return v;
@@ -2361,11 +2348,11 @@
return Node::deref();
}
-Value ClauseListNode::evaluate(ExecState */*exec*/)
+ValueImp *ClauseListNode::evaluate(ExecState */*exec*/)
{
/* should never be called */
assert(false);
- return Value();
+ return NULL;
}
// ECMA 12.11
@@ -2420,17 +2407,17 @@
return Node::deref();
}
-Value CaseBlockNode::evaluate(ExecState */*exec*/)
+ValueImp *CaseBlockNode::evaluate(ExecState */*exec*/)
{
/* should never be called */
assert(false);
- return Value();
+ return NULL;
}
// ECMA 12.11
-Completion CaseBlockNode::evalBlock(ExecState *exec, const Value& input)
+Completion CaseBlockNode::evalBlock(ExecState *exec, ValueImp *input)
{
- Value v;
+ ValueImp *v;
Completion res;
ClauseListNode *a = list1, *b = list2;
CaseClauseNode *clause;
@@ -2524,7 +2511,7 @@
{
KJS_BREAKPOINT;
- Value v = expr->evaluate(exec);
+ ValueImp *v = expr->evaluate(exec);
KJS_CHECKEXCEPTION
exec->context().imp()->seenLabels()->pushSwitch();
@@ -2600,7 +2587,7 @@
{
KJS_BREAKPOINT;
- Value v = expr->evaluate(exec);
+ ValueImp *v = expr->evaluate(exec);
KJS_CHECKEXCEPTION
return Completion(Throw, v);
@@ -2630,14 +2617,14 @@
}
// ECMA 12.14
-Completion CatchNode::execute(ExecState *exec, const Value &arg)
+Completion CatchNode::execute(ExecState *exec, ValueImp *arg)
{
/* TODO: correct ? Not part of the spec */
exec->clearException();
- Object obj(new ObjectImp());
- obj.put(exec, ident, arg, DontDelete);
+ ObjectImp *obj(new ObjectImp());
+ obj->put(exec, ident, arg, DontDelete);
exec->context().imp()->pushScope(obj);
Completion c = block->execute(exec);
exec->context().imp()->popScope();
@@ -2717,7 +2704,7 @@
}
if (!_catch) {
- Value lastException = exec->exception();
+ ValueImp *lastException = exec->exception();
exec->clearException();
c2 = _final->execute(exec);
@@ -2764,7 +2751,7 @@
}
// ECMA 13
-Value ParameterNode::evaluate(ExecState */*exec*/)
+ValueImp *ParameterNode::evaluate(ExecState */*exec*/)
{
return Undefined();
}
@@ -2807,38 +2794,34 @@
// ECMA 13
void FuncDeclNode::processFuncDecl(ExecState *exec)
{
- // TODO: let this be an object with [[Class]] property "Function"
- FunctionImp *fimp = new DeclaredFunctionImp(exec, ident, body, exec->context().imp()->scopeChain());
- Object func(fimp); // protect from GC
+ ContextImp *context = exec->context().imp();
- // Value proto = exec->lexicalInterpreter()->builtinObject().construct(exec,List::empty());
- List empty;
- Object proto = exec->lexicalInterpreter()->builtinObject().construct(exec,empty);
- proto.put(exec, constructorPropertyName, func, ReadOnly|DontDelete|DontEnum);
- func.put(exec, prototypePropertyName, proto, Internal|DontDelete);
+ // TODO: let this be an object with [[Class]] property "Function"
+ FunctionImp *fimp = new DeclaredFunctionImp(exec, ident, body, context->scopeChain());
+ ObjectImp *func(fimp); // protect from GC
+
+ ObjectImp *proto = exec->lexicalInterpreter()->builtinObject()->construct(exec, List::empty());
+ proto->put(exec, constructorPropertyName, func, ReadOnly|DontDelete|DontEnum);
+ func->put(exec, prototypePropertyName, proto, Internal|DontDelete);
int plen = 0;
for(ParameterNode *p = param; p != 0L; p = p->nextParam(), plen++)
fimp->addParameter(p->ident());
- func.put(exec, lengthPropertyName, Number(plen), ReadOnly|DontDelete|DontEnum);
+ func->put(exec, lengthPropertyName, Number(plen), ReadOnly|DontDelete|DontEnum);
- if (exec->context().imp()->codeType() == EvalCode) {
- // ECMA 10.2.2
- exec->context().imp()->variableObject().put(exec, ident, func, Internal);
- } else {
- exec->context().imp()->variableObject().put(exec, ident, func, Internal | DontDelete);
- }
+ // ECMA 10.2.2
+ context->variableObject()->put(exec, ident, func, Internal | (context->codeType() == EvalCode ? 0 : DontDelete));
if (body) {
// hack the scope so that the function gets put as a property of func, and it's scope
// contains the func as well as our current scope
- Object oldVar = exec->context().imp()->variableObject();
- exec->context().imp()->setVariableObject(func);
- exec->context().imp()->pushScope(func);
+ ObjectImp *oldVar = context->variableObject();
+ context->setVariableObject(func);
+ context->pushScope(func);
body->processFuncDecl(exec);
- exec->context().imp()->popScope();
- exec->context().imp()->setVariableObject(oldVar);
+ context->popScope();
+ context->setVariableObject(oldVar);
}
}
@@ -2864,12 +2847,11 @@
// ECMA 13
-Value FuncExprNode::evaluate(ExecState *exec)
+ValueImp *FuncExprNode::evaluate(ExecState *exec)
{
FunctionImp *fimp = new DeclaredFunctionImp(exec, Identifier::null(), body, exec->context().imp()->scopeChain());
- Value ret(fimp);
- List empty;
- Value proto = exec->lexicalInterpreter()->builtinObject().construct(exec,empty);
+ ValueImp *ret(fimp);
+ ValueImp *proto = exec->lexicalInterpreter()->builtinObject()->construct(exec, List::empty());
fimp->put(exec, prototypePropertyName, proto, Internal|DontDelete);
int plen = 0;
@@ -2932,7 +2914,7 @@
return c2;
// The spec says to return c2 here, but it seems that mozilla returns c1 if
// c2 doesn't have a value
- if (!c2.value().isNull())
+ if (c2.value())
c1 = c2;
}
diff --git a/JavaScriptCore/kjs/nodes.h b/JavaScriptCore/kjs/nodes.h
index a2cfc3d..bc7bffb 100644
--- a/JavaScriptCore/kjs/nodes.h
+++ b/JavaScriptCore/kjs/nodes.h
@@ -82,7 +82,7 @@
KJS_FAST_ALLOCATED;
- virtual Value evaluate(ExecState *exec) = 0;
+ virtual ValueImp *evaluate(ExecState *exec) = 0;
virtual Reference evaluateReference(ExecState *exec);
UString toString() const;
virtual void streamTo(SourceStream &s) const = 0;
@@ -103,9 +103,9 @@
static void finalCheck();
#endif
protected:
- Value throwError(ExecState *exec, ErrorType e, const char *msg);
- Value throwError(ExecState *exec, ErrorType e, const char *msg, Value v, Node *expr);
- Value throwError(ExecState *exec, ErrorType e, const char *msg, Identifier label);
+ ValueImp *throwError(ExecState *exec, ErrorType e, const char *msg);
+ ValueImp *throwError(ExecState *exec, ErrorType e, const char *msg, ValueImp *v, Node *expr);
+ ValueImp *throwError(ExecState *exec, ErrorType e, const char *msg, Identifier label);
void setExceptionDetailsIfNeeded(ExecState *exec);
int line;
UString sourceURL;
@@ -136,7 +136,7 @@
protected:
LabelStack ls;
private:
- Value evaluate(ExecState */*exec*/) { return Undefined(); }
+ ValueImp *evaluate(ExecState */*exec*/) { return Undefined(); }
int l0, l1;
int sid;
bool breakPoint;
@@ -145,14 +145,14 @@
class NullNode : public Node {
public:
NullNode() {}
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
};
class BooleanNode : public Node {
public:
BooleanNode(bool v) : value(v) {}
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
bool value;
@@ -161,7 +161,7 @@
class NumberNode : public Node {
public:
NumberNode(double v) : value(v) { }
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
double value;
@@ -170,7 +170,7 @@
class StringNode : public Node {
public:
StringNode(const UString *v) { value = *v; }
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
UString value;
@@ -180,7 +180,7 @@
public:
RegExpNode(const UString &p, const UString &f)
: pattern(p), flags(f) { }
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
UString pattern, flags;
@@ -189,14 +189,14 @@
class ThisNode : public Node {
public:
ThisNode() {}
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
};
class ResolveNode : public Node {
public:
ResolveNode(const Identifier &s) : ident(s) { }
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual Reference evaluateReference(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
@@ -208,7 +208,7 @@
GroupNode(Node *g) : group(g) { }
virtual void ref();
virtual bool deref();
- virtual Value evaluate(ExecState *exec);
+ virtual ValueImp *evaluate(ExecState *exec);
virtual Reference evaluateReference(ExecState *exec);
virtual void streamTo(SourceStream &s) const { group->streamTo(s); }
private:
@@ -223,7 +223,7 @@
: list(l->list), elision(e), node(n) { l->list = this; }
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
friend class ArrayNode;
@@ -241,7 +241,7 @@
: element(ele->list), elision(eli), opt(true) { ele->list = 0; }
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
ElementNode *element;
@@ -258,7 +258,7 @@
: name(n), assign(a), list(l->list) { l->list = this; }
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
friend class ObjectLiteralNode;
@@ -273,7 +273,7 @@
ObjectLiteralNode(PropertyValueNode *l) : list(l->list) { l->list = 0; }
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
PropertyValueNode *list;
@@ -283,7 +283,7 @@
public:
PropertyNode(double d) : numeric(d) { }
PropertyNode(const Identifier &s) : str(s) { }
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
double numeric;
@@ -295,7 +295,7 @@
AccessorNode1(Node *e1, Node *e2) : expr1(e1), expr2(e2) {}
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual Reference evaluateReference(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
@@ -308,7 +308,7 @@
AccessorNode2(Node *e, const Identifier &s) : expr(e), ident(s) { }
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual Reference evaluateReference(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
@@ -324,7 +324,7 @@
: list(l->list), expr(e) { l->list = this; }
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
List evaluateList(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
@@ -340,7 +340,7 @@
: list(l->list) { l->list = 0; }
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
List evaluateList(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
@@ -353,7 +353,7 @@
NewExprNode(Node *e, ArgumentsNode *a) : expr(e), args(a) {}
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
@@ -365,7 +365,7 @@
FunctionCallNode(Node *e, ArgumentsNode *a) : expr(e), args(a) {}
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
@@ -377,7 +377,7 @@
PostfixNode(Node *e, Operator o) : expr(e), oper(o) {}
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
@@ -389,7 +389,7 @@
DeleteNode(Node *e) : expr(e) {}
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
@@ -400,7 +400,7 @@
VoidNode(Node *e) : expr(e) {}
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
@@ -411,7 +411,7 @@
TypeOfNode(Node *e) : expr(e) {}
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
@@ -422,7 +422,7 @@
PrefixNode(Operator o, Node *e) : oper(o), expr(e) {}
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Operator oper;
@@ -434,7 +434,7 @@
UnaryPlusNode(Node *e) : expr(e) {}
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
@@ -445,7 +445,7 @@
NegateNode(Node *e) : expr(e) {}
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
@@ -456,7 +456,7 @@
BitwiseNotNode(Node *e) : expr(e) {}
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
@@ -467,7 +467,7 @@
LogicalNotNode(Node *e) : expr(e) {}
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
@@ -478,7 +478,7 @@
MultNode(Node *t1, Node *t2, char op) : term1(t1), term2(t2), oper(op) {}
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Node *term1, *term2;
@@ -490,7 +490,7 @@
AddNode(Node *t1, Node *t2, char op) : term1(t1), term2(t2), oper(op) {}
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Node *term1, *term2;
@@ -503,7 +503,7 @@
: term1(t1), term2(t2), oper(o) {}
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Node *term1, *term2;
@@ -516,7 +516,7 @@
expr1(e1), expr2(e2), oper(o) {}
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Node *expr1, *expr2;
@@ -529,7 +529,7 @@
: expr1(e1), expr2(e2), oper(o) {}
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Node *expr1, *expr2;
@@ -542,7 +542,7 @@
expr1(e1), expr2(e2), oper(o) {}
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Node *expr1, *expr2;
@@ -558,7 +558,7 @@
expr1(e1), expr2(e2), oper(o) {}
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Node *expr1, *expr2;
@@ -574,7 +574,7 @@
logical(l), expr1(e1), expr2(e2) {}
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Node *logical, *expr1, *expr2;
@@ -585,7 +585,7 @@
AssignNode(Node *l, Operator o, Node *e) : left(l), oper(o), expr(e) {}
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Node *left;
@@ -598,7 +598,7 @@
CommaNode(Node *e1, Node *e2) : expr1(e1), expr2(e2) {}
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Node *expr1, *expr2;
@@ -625,7 +625,7 @@
AssignExprNode(Node *e) : expr(e) {}
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
Node *expr;
@@ -637,7 +637,7 @@
VarDeclNode(const Identifier &id, AssignExprNode *in, Type t);
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
@@ -654,7 +654,7 @@
: list(l->list), var(v) { l->list = this; }
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
@@ -830,7 +830,7 @@
: expr(e), list(l->list) { l->list = 0; }
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
Completion evalStatements(ExecState *exec);
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
@@ -847,7 +847,7 @@
: cl(c), nx(n->nx) { n->nx = this; }
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
CaseClauseNode *clause() const { return cl; }
ClauseListNode *next() const { return nx; }
virtual void processVarDecls(ExecState *exec);
@@ -863,8 +863,8 @@
CaseBlockNode(ClauseListNode *l1, CaseClauseNode *d, ClauseListNode *l2);
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
- Completion evalBlock(ExecState *exec, const Value& input);
+ ValueImp *evaluate(ExecState *exec);
+ Completion evalBlock(ExecState *exec, ValueImp *input);
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
@@ -916,7 +916,7 @@
virtual void ref();
virtual bool deref();
virtual Completion execute(ExecState *exec);
- Completion execute(ExecState *exec, const Value &arg);
+ Completion execute(ExecState *exec, ValueImp *arg);
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
@@ -963,7 +963,7 @@
: id(i), next(list->next) { list->next = this; }
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
Identifier ident() { return id; }
ParameterNode *nextParam() { return next; }
virtual void streamTo(SourceStream &s) const;
@@ -1006,7 +1006,7 @@
: param(p->next), body(b) { p->next = 0; }
virtual void ref();
virtual bool deref();
- Value evaluate(ExecState *exec);
+ ValueImp *evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
ParameterNode *param;
diff --git a/JavaScriptCore/kjs/number_object.cpp b/JavaScriptCore/kjs/number_object.cpp
index a26fb46..0896cc2 100644
--- a/JavaScriptCore/kjs/number_object.cpp
+++ b/JavaScriptCore/kjs/number_object.cpp
@@ -52,8 +52,7 @@
FunctionPrototypeImp *funcProto)
: NumberInstanceImp(objProto)
{
- Value protect(this);
- setInternalValue(NumberImp::zero());
+ setInternalValue(jsZero());
// The constructor will be added later, after NumberObjectImp has been constructed
@@ -72,7 +71,6 @@
FunctionPrototypeImp *funcProto, int i, int len)
: InternalFunctionImp(funcProto), id(i)
{
- Value protect(this);
putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
}
@@ -127,26 +125,24 @@
}
// ECMA 15.7.4.2 - 15.7.4.7
-Value NumberProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &args)
+ValueImp *NumberProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- Value result;
-
// no generic function. "this" has to be a Number object
- if (!thisObj.inherits(&NumberInstanceImp::info)) {
- Object err = Error::create(exec,TypeError);
+ if (!thisObj->inherits(&NumberInstanceImp::info)) {
+ ObjectImp *err = Error::create(exec,TypeError);
exec->setException(err);
return err;
}
- Value v = thisObj.internalValue();
+ ValueImp *v = thisObj->internalValue();
switch (id) {
case ToString: {
double dradix = 10;
if (!args.isEmpty())
- dradix = args[0].toInteger(exec);
+ dradix = args[0]->toInteger(exec);
if (dradix >= 2 && dradix <= 36 && dradix != 10) { // false for NaN
int radix = static_cast<int>(dradix);
- unsigned i = v.toUInt32(exec);
+ unsigned i = v->toUInt32(exec);
char s[33];
char *p = s + sizeof(s);
*--p = '\0';
@@ -154,23 +150,20 @@
*--p = "0123456789abcdefghijklmnopqrstuvwxyz"[i % radix];
i /= radix;
} while (i);
- result = String(p);
+ return String(p);
} else
- result = String(v.toString(exec));
- break;
+ return String(v->toString(exec));
}
case ToLocaleString: /* TODO */
- result = String(v.toString(exec));
- break;
+ return String(v->toString(exec));
case ValueOf:
- result = Number(v.toNumber(exec));
- break;
+ return Number(v->toNumber(exec));
case ToFixed:
{
- Value fractionDigits = args[0];
- double df = fractionDigits.toInteger(exec);
+ ValueImp *fractionDigits = args[0];
+ double df = fractionDigits->toInteger(exec);
if (!(df >= 0 && df <= 20)) { // true for NaN
- Object err = Error::create(exec, RangeError,
+ ObjectImp *err = Error::create(exec, RangeError,
"toFixed() digits argument must be between 0 and 20");
exec->setException(err);
@@ -178,7 +171,7 @@
}
int f = (int)df;
- double x = v.toNumber(exec);
+ double x = v->toNumber(exec);
if (isNaN(x))
return String("NaN");
@@ -212,15 +205,15 @@
return String(s+m.substr(0,k-f));
}
case ToExponential: {
- double x = v.toNumber(exec);
+ double x = v->toNumber(exec);
if (isNaN(x) || isInf(x))
return String(UString::from(x));
- Value fractionDigits = args[0];
- double df = fractionDigits.toInteger(exec);
+ ValueImp *fractionDigits = args[0];
+ double df = fractionDigits->toInteger(exec);
if (!(df >= 0 && df <= 20)) { // true for NaN
- Object err = Error::create(exec, RangeError,
+ ObjectImp *err = Error::create(exec, RangeError,
"toExponential() argument must between 0 and 20");
exec->setException(err);
return err;
@@ -228,7 +221,7 @@
int f = (int)df;
int decimalAdjust = 0;
- if (!fractionDigits.isA(UndefinedType)) {
+ if (!fractionDigits->isUndefined()) {
double logx = floor(log10(x));
x /= pow(10,logx);
double fx = floor(x*pow(10,f))/pow(10,f);
@@ -263,7 +256,7 @@
} else {
buf[i++] = result[0];
- if (fractionDigits.isA(UndefinedType))
+ if (fractionDigits->isUndefined())
f = length-1;
if (length > 1 && f > 0) {
@@ -310,10 +303,10 @@
int e = 0;
UString m;
- double dp = args[0].toInteger(exec);
- double x = v.toNumber(exec);
+ double dp = args[0]->toInteger(exec);
+ double x = v->toNumber(exec);
if (isNaN(dp) || isNaN(x) || isInf(x))
- return String(v.toString(exec));
+ return String(v->toString(exec));
UString s = "";
if (x < 0) {
@@ -322,7 +315,7 @@
}
if (dp < 1 || dp > 21) {
- Object err = Error::create(exec, RangeError,
+ ObjectImp *err = Error::create(exec, RangeError,
"toPrecision() argument must be between 1 and 21");
exec->setException(err);
return err;
@@ -372,7 +365,7 @@
}
}
- return result;
+ return NULL;
}
// ------------------------------ NumberObjectImp ------------------------------
@@ -394,12 +387,11 @@
NumberPrototypeImp *numberProto)
: InternalFunctionImp(funcProto)
{
- Value protect(this);
// Number.Prototype
putDirect(prototypePropertyName, numberProto,DontEnum|DontDelete|ReadOnly);
// no. of arguments for constructor
- putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum);
+ putDirect(lengthPropertyName, jsOne(), ReadOnly|DontDelete|DontEnum);
}
bool NumberObjectImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
@@ -407,12 +399,12 @@
return getStaticValueSlot<NumberObjectImp, InternalFunctionImp>(exec, &numberTable, this, propertyName, slot);
}
-Value NumberObjectImp::getValueProperty(ExecState *, int token) const
+ValueImp *NumberObjectImp::getValueProperty(ExecState *, int token) const
{
// ECMA 15.7.3
switch(token) {
case NaNValue:
- return Number(NaN);
+ return jsNaN();
case NegInfinity:
return Number(-Inf);
case PosInfinity:
@@ -432,18 +424,18 @@
// ECMA 15.7.1
-Object NumberObjectImp::construct(ExecState *exec, const List &args)
+ObjectImp *NumberObjectImp::construct(ExecState *exec, const List &args)
{
- ObjectImp *proto = exec->lexicalInterpreter()->builtinNumberPrototype().imp();
- Object obj(new NumberInstanceImp(proto));
+ ObjectImp *proto = exec->lexicalInterpreter()->builtinNumberPrototype();
+ ObjectImp *obj(new NumberInstanceImp(proto));
- Number n;
+ double n;
if (args.isEmpty())
- n = Number(0);
+ n = 0;
else
- n = args[0].toNumber(exec);
+ n = args[0]->toNumber(exec);
- obj.setInternalValue(n);
+ obj->setInternalValue(jsNumber(n));
return obj;
}
@@ -454,10 +446,10 @@
}
// ECMA 15.7.2
-Value NumberObjectImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
+ValueImp *NumberObjectImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
{
if (args.isEmpty())
return Number(0);
else
- return Number(args[0].toNumber(exec));
+ return Number(args[0]->toNumber(exec));
}
diff --git a/JavaScriptCore/kjs/number_object.h b/JavaScriptCore/kjs/number_object.h
index db8c64e..276aea2 100644
--- a/JavaScriptCore/kjs/number_object.h
+++ b/JavaScriptCore/kjs/number_object.h
@@ -60,7 +60,7 @@
int i, int len);
virtual bool implementsCall() const;
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
enum { ToString, ToLocaleString, ValueOf, ToFixed, ToExponential, ToPrecision };
private:
@@ -79,19 +79,20 @@
NumberPrototypeImp *numberProto);
virtual bool implementsConstruct() const;
- virtual Object construct(ExecState *exec, const List &args);
+ virtual ObjectImp *construct(ExecState *exec, const List &args);
virtual bool implementsCall() const;
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
- Value getValueProperty(ExecState *exec, int token) const;
+ ValueImp *getValueProperty(ExecState *exec, int token) const;
+
virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
enum { NaNValue, NegInfinity, PosInfinity, MaxValue, MinValue };
Completion execute(const List &);
- Object construct(const List &);
+ ObjectImp *construct(const List &);
};
} // namespace
diff --git a/JavaScriptCore/kjs/object.cpp b/JavaScriptCore/kjs/object.cpp
index dad26f4..8d24ac9 100644
--- a/JavaScriptCore/kjs/object.cpp
+++ b/JavaScriptCore/kjs/object.cpp
@@ -40,10 +40,10 @@
#include "nodes.h"
#ifndef NDEBUG
-#define JAVASCRIPT_CALL_TRACING Yes
+//#define JAVASCRIPT_CALL_TRACING 1
#endif
-#ifdef JAVASCRIPT_CALL_TRACING
+#if JAVASCRIPT_CALL_TRACING
static bool _traceJavaScript = false;
extern "C" {
@@ -63,21 +63,14 @@
// ------------------------------ Object ---------------------------------------
-Object Object::dynamicCast(const Value &v)
+ValueImp *ObjectImp::call(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (v.isNull() || v.type() != ObjectType)
- return Object(0);
+ assert(implementsCall());
- return Object(static_cast<ObjectImp*>(v.imp()));
-}
-
-
-Value Object::call(ExecState *exec, Object &thisObj, const List &args)
-{
#if KJS_MAX_STACK > 0
static int depth = 0; // sum of all concurrent interpreters
-#ifdef JAVASCRIPT_CALL_TRACING
+#if JAVASCRIPT_CALL_TRACING
static bool tracing = false;
if (traceJavaScript() && !tracing) {
tracing = true;
@@ -87,7 +80,7 @@
for (int j = 0; j < args.size(); j++) {
for (int i = 0; i < depth; i++)
putchar (' ');
- printf ("*** arg[%d] = %s\n", j, args[j].toString(exec).ascii());
+ printf ("*** arg[%d] = %s\n", j, args[j]->toString(exec).ascii());
}
tracing = false;
}
@@ -95,25 +88,25 @@
if (++depth > KJS_MAX_STACK) {
--depth;
- Object err = Error::create(exec, RangeError,
+ ObjectImp *err = Error::create(exec, RangeError,
"Maximum call stack size exceeded.");
exec->setException(err);
return err;
}
#endif
- Value ret = imp()->call(exec,thisObj,args);
+ ValueImp *ret = callAsFunction(exec,thisObj,args);
#if KJS_MAX_STACK > 0
--depth;
#endif
-#ifdef JAVASCRIPT_CALL_TRACING
+#if JAVASCRIPT_CALL_TRACING
if (traceJavaScript() && !tracing) {
tracing = true;
for (int i = 0; i < depth; i++)
putchar (' ');
- printf ("*** returning: %s\n", ret.toString(exec).ascii());
+ printf ("*** returning: %s\n", ret->toString(exec).ascii());
tracing = false;
}
#endif
@@ -123,37 +116,13 @@
// ------------------------------ ObjectImp ------------------------------------
-ObjectImp::ObjectImp(const Object &proto)
- : _proto(static_cast<ObjectImp*>(proto.imp())), _internalValue(0L)
-{
- //fprintf(stderr,"ObjectImp::ObjectImp %p\n",(void*)this);
-}
-
-ObjectImp::ObjectImp(ObjectImp *proto)
- : _proto(proto), _internalValue(0L)
-{
- //fprintf(stderr,"ObjectImp::ObjectImp %p\n",(void*)this);
-}
-
-ObjectImp::ObjectImp()
-{
- //fprintf(stderr,"ObjectImp::ObjectImp %p\n",(void*)this);
- _proto = NullImp::staticNull;
- _internalValue = 0L;
-}
-
-ObjectImp::~ObjectImp()
-{
- //fprintf(stderr,"ObjectImp::~ObjectImp %p\n",(void*)this);
-}
-
void ObjectImp::mark()
{
- //fprintf(stderr,"ObjectImp::mark() %p\n",(void*)this);
- ValueImp::mark();
+ AllocatedValueImp::mark();
- if (_proto && !_proto->marked())
- _proto->mark();
+ ValueImp *proto = _proto;
+ if (!proto->marked())
+ proto->mark();
_prop.mark();
@@ -163,39 +132,14 @@
_scope.mark();
}
-const ClassInfo *ObjectImp::classInfo() const
-{
- return 0;
-}
-
-bool ObjectImp::inherits(const ClassInfo *info) const
-{
- if (!info)
- return false;
-
- const ClassInfo *ci = classInfo();
- if (!ci)
- return false;
-
- while (ci && ci != info)
- ci = ci->parentClass;
-
- return (ci == info);
-}
-
Type ObjectImp::type() const
{
return ObjectType;
}
-Value ObjectImp::prototype() const
+const ClassInfo *ObjectImp::classInfo() const
{
- return Value(_proto);
-}
-
-void ObjectImp::setPrototype(const Value &proto)
-{
- _proto = proto.imp();
+ return 0;
}
UString ObjectImp::className() const
@@ -206,7 +150,7 @@
return "Object";
}
-Value ObjectImp::get(ExecState *exec, const Identifier &propertyName) const
+ValueImp *ObjectImp::get(ExecState *exec, const Identifier &propertyName) const
{
PropertySlot slot;
@@ -216,7 +160,7 @@
return Undefined();
}
-Value ObjectImp::get(ExecState *exec, unsigned propertyName) const
+ValueImp *ObjectImp::get(ExecState *exec, unsigned propertyName) const
{
PropertySlot slot;
if (const_cast<ObjectImp *>(this)->getPropertySlot(exec, propertyName, slot))
@@ -225,7 +169,7 @@
return Undefined();
}
-bool ObjectImp::getProperty(ExecState *exec, const Identifier& propertyName, Value& result) const
+bool ObjectImp::getProperty(ExecState *exec, const Identifier& propertyName, ValueImp*& result) const
{
PropertySlot slot;
if (const_cast<ObjectImp *>(this)->getPropertySlot(exec, propertyName, slot)) {
@@ -236,7 +180,7 @@
return false;
}
-bool ObjectImp::getProperty(ExecState *exec, unsigned propertyName, Value& result) const
+bool ObjectImp::getProperty(ExecState *exec, unsigned propertyName, ValueImp*& result) const
{
PropertySlot slot;
if (const_cast<ObjectImp *>(this)->getPropertySlot(exec, propertyName, slot)) {
@@ -256,7 +200,7 @@
return true;
ValueImp *proto = imp->_proto;
- if (proto->dispatchType() != ObjectType)
+ if (!proto->isObject())
break;
imp = static_cast<ObjectImp *>(proto);
@@ -271,10 +215,9 @@
}
// ECMA 8.6.2.2
-void ObjectImp::put(ExecState *exec, const Identifier &propertyName,
- const Value &value, int attr)
+void ObjectImp::put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr)
{
- assert(!value.isNull());
+ assert(value);
// non-standard netscape extension
if (propertyName == exec->dynamicInterpreter()->specialPrototypeIdentifier()) {
@@ -294,11 +237,11 @@
return;
}
- _prop.put(propertyName,value.imp(),attr);
+ _prop.put(propertyName,value,attr);
}
void ObjectImp::put(ExecState *exec, unsigned propertyName,
- const Value &value, int attr)
+ ValueImp *value, int attr)
{
put(exec, Identifier::from(propertyName), value, attr);
}
@@ -340,6 +283,12 @@
return const_cast<ObjectImp *>(this)->getOwnPropertySlot(exec, propertyName, slot);
}
+bool ObjectImp::hasOwnProperty(ExecState *exec, unsigned propertyName) const
+{
+ PropertySlot slot;
+ return const_cast<ObjectImp *>(this)->getOwnPropertySlot(exec, propertyName, slot);
+}
+
// ECMA 8.6.2.5
bool ObjectImp::deleteProperty(ExecState */*exec*/, const Identifier &propertyName)
{
@@ -370,28 +319,28 @@
}
// ECMA 8.6.2.6
-Value ObjectImp::defaultValue(ExecState *exec, Type hint) const
+ValueImp *ObjectImp::defaultValue(ExecState *exec, Type hint) const
{
if (hint != StringType && hint != NumberType) {
/* Prefer String for Date objects */
- if (_proto == exec->lexicalInterpreter()->builtinDatePrototype().imp())
+ if (_proto == exec->lexicalInterpreter()->builtinDatePrototype())
hint = StringType;
else
hint = NumberType;
}
- Value v;
+ ValueImp *v;
if (hint == StringType)
v = get(exec,toStringPropertyName);
else
v = get(exec,valueOfPropertyName);
- if (v.type() == ObjectType) {
- Object o = Object(static_cast<ObjectImp*>(v.imp()));
- if (o.implementsCall()) { // spec says "not primitive type" but ...
- Object thisObj = Object(const_cast<ObjectImp*>(this));
- Value def = o.call(exec,thisObj,List::empty());
- Type defType = def.type();
+ if (v->isObject()) {
+ ObjectImp *o = static_cast<ObjectImp*>(v);
+ if (o->implementsCall()) { // spec says "not primitive type" but ...
+ ObjectImp *thisObj = const_cast<ObjectImp*>(this);
+ ValueImp *def = o->call(exec,thisObj,List::empty());
+ Type defType = def->type();
if (defType == UnspecifiedType || defType == UndefinedType ||
defType == NullType || defType == BooleanType ||
defType == StringType || defType == NumberType) {
@@ -405,12 +354,12 @@
else
v = get(exec,toStringPropertyName);
- if (v.type() == ObjectType) {
- Object o = Object(static_cast<ObjectImp*>(v.imp()));
- if (o.implementsCall()) { // spec says "not primitive type" but ...
- Object thisObj = Object(const_cast<ObjectImp*>(this));
- Value def = o.call(exec,thisObj,List::empty());
- Type defType = def.type();
+ if (v->isObject()) {
+ ObjectImp *o = static_cast<ObjectImp*>(v);
+ if (o->implementsCall()) { // spec says "not primitive type" but ...
+ ObjectImp *thisObj = const_cast<ObjectImp*>(this);
+ ValueImp *def = o->call(exec,thisObj,List::empty());
+ Type defType = def->type();
if (defType == UnspecifiedType || defType == UndefinedType ||
defType == NullType || defType == BooleanType ||
defType == StringType || defType == NumberType) {
@@ -422,23 +371,20 @@
if (exec->hadException())
return exec->exception();
- Object err = Error::create(exec, TypeError, I18N_NOOP("No default value"));
+ ObjectImp *err = Error::create(exec, TypeError, I18N_NOOP("No default value"));
exec->setException(err);
return err;
}
-const HashEntry* ObjectImp::findPropertyHashEntry( const Identifier& propertyName ) const
+const HashEntry* ObjectImp::findPropertyHashEntry(const Identifier& propertyName) const
{
- const ClassInfo *info = classInfo();
- while (info) {
- if (info->propHashTable) {
- const HashEntry *e = Lookup::findEntry(info->propHashTable, propertyName);
- if (e)
+ for (const ClassInfo *info = classInfo(); info; info = info->parentClass) {
+ if (const HashTable *propHashTable = info->propHashTable) {
+ if (const HashEntry *e = Lookup::findEntry(propHashTable, propertyName))
return e;
}
- info = info->parentClass;
}
- return 0L;
+ return 0;
}
bool ObjectImp::implementsConstruct() const
@@ -446,13 +392,13 @@
return false;
}
-Object ObjectImp::construct(ExecState */*exec*/, const List &/*args*/)
+ObjectImp *ObjectImp::construct(ExecState */*exec*/, const List &/*args*/)
{
assert(false);
- return Object(0);
+ return NULL;
}
-Object ObjectImp::construct(ExecState *exec, const List &args, const UString &/*sourceURL*/, int /*lineNumber*/)
+ObjectImp *ObjectImp::construct(ExecState *exec, const List &args, const UString &/*sourceURL*/, int /*lineNumber*/)
{
return construct(exec, args);
}
@@ -462,10 +408,10 @@
return false;
}
-Value ObjectImp::call(ExecState */*exec*/, Object &/*thisObj*/, const List &/*args*/)
+ValueImp *ObjectImp::callAsFunction(ExecState */*exec*/, ObjectImp */*thisObj*/, const List &/*args*/)
{
assert(false);
- return Object(0);
+ return NULL;
}
bool ObjectImp::implementsHasInstance() const
@@ -473,19 +419,19 @@
return false;
}
-Boolean ObjectImp::hasInstance(ExecState */*exec*/, const Value &/*value*/)
+bool ObjectImp::hasInstance(ExecState */*exec*/, ValueImp */*value*/)
{
assert(false);
- return Boolean(false);
+ return false;
}
ReferenceList ObjectImp::propList(ExecState *exec, bool recursive)
{
ReferenceList list;
- if (_proto && _proto->dispatchType() == ObjectType && recursive)
+ if (_proto->isObject() && recursive)
list = static_cast<ObjectImp*>(_proto)->propList(exec,recursive);
- _prop.addEnumerablesToReferenceList(list, Object(this));
+ _prop.addEnumerablesToReferenceList(list, this);
// Add properties from the static hashtable of properties
const ClassInfo *info = classInfo();
@@ -504,22 +450,7 @@
return list;
}
-Value ObjectImp::internalValue() const
-{
- return Value(_internalValue);
-}
-
-void ObjectImp::setInternalValue(const Value &v)
-{
- _internalValue = v.imp();
-}
-
-void ObjectImp::setInternalValue(ValueImp *v)
-{
- _internalValue = v;
-}
-
-Value ObjectImp::toPrimitive(ExecState *exec, Type preferredType) const
+ValueImp *ObjectImp::toPrimitive(ExecState *exec, Type preferredType) const
{
return defaultValue(exec,preferredType);
}
@@ -531,23 +462,23 @@
double ObjectImp::toNumber(ExecState *exec) const
{
- Value prim = toPrimitive(exec,NumberType);
+ ValueImp *prim = toPrimitive(exec,NumberType);
if (exec->hadException()) // should be picked up soon in nodes.cpp
return 0.0;
- return prim.toNumber(exec);
+ return prim->toNumber(exec);
}
UString ObjectImp::toString(ExecState *exec) const
{
- Value prim = toPrimitive(exec,StringType);
+ ValueImp *prim = toPrimitive(exec,StringType);
if (exec->hadException()) // should be picked up soon in nodes.cpp
return "";
- return prim.toString(exec);
+ return prim->toString(exec);
}
-Object ObjectImp::toObject(ExecState */*exec*/) const
+ObjectImp *ObjectImp::toObject(ExecState */*exec*/) const
{
- return Object(const_cast<ObjectImp*>(this));
+ return const_cast<ObjectImp*>(this);
}
void ObjectImp::putDirect(const Identifier &propertyName, ValueImp *value, int attr)
@@ -557,7 +488,7 @@
void ObjectImp::putDirect(const Identifier &propertyName, int value, int attr)
{
- _prop.put(propertyName, NumberImp::create(value), attr);
+ _prop.put(propertyName, jsNumber(value), attr);
}
// ------------------------------ Error ----------------------------------------
@@ -574,10 +505,10 @@
const char * const * const Error::errorNames = errorNamesArr;
-Object Error::create(ExecState *exec, ErrorType errtype, const char *message,
+ObjectImp *Error::create(ExecState *exec, ErrorType errtype, const char *message,
int lineno, int sourceId, const UString *sourceURL)
{
- Object cons;
+ ObjectImp *cons;
switch (errtype) {
case EvalError:
cons = exec->lexicalInterpreter()->builtinEvalError();
@@ -606,21 +537,21 @@
message = errorNames[errtype];
List args;
args.append(String(message));
- Object err = Object::dynamicCast(cons.construct(exec,args));
+ ObjectImp *err = static_cast<ObjectImp *>(cons->construct(exec,args));
if (lineno != -1)
- err.put(exec, "line", Number(lineno));
+ err->put(exec, "line", Number(lineno));
if (sourceId != -1)
- err.put(exec, "sourceId", Number(sourceId));
+ err->put(exec, "sourceId", Number(sourceId));
if(sourceURL)
- err.put(exec,"sourceURL", String(*sourceURL));
+ err->put(exec,"sourceURL", String(*sourceURL));
return err;
/*
#ifndef NDEBUG
- const char *msg = err.get("message").toString().value().ascii();
+ const char *msg = err->get("message")->toString().value().ascii();
if (l >= 0)
fprintf(stderr, "KJS: %s at line %d. %s\n", estr, l, msg);
else
@@ -633,7 +564,7 @@
ObjectImp *error(ExecState *exec, ErrorType type, const char *message, int line, int sourceId, const UString *sourceURL)
{
- return Error::create(exec, type, message, line, sourceId, sourceURL).imp();
+ return Error::create(exec, type, message, line, sourceId, sourceURL);
}
} // namespace KJS
diff --git a/JavaScriptCore/kjs/object.h b/JavaScriptCore/kjs/object.h
index b43e284..bfc8bdb 100644
--- a/JavaScriptCore/kjs/object.h
+++ b/JavaScriptCore/kjs/object.h
@@ -22,9 +22,8 @@
*
*/
-
-#ifndef _KJS_OBJECT_H_
-#define _KJS_OBJECT_H_
+#ifndef KJS_OBJECT_H
+#define KJS_OBJECT_H
// Objects
@@ -38,9 +37,7 @@
#define KJS_MAX_STACK 1000
#endif
-#include "types.h"
#include "interpreter.h"
-#include "reference_list.h"
#include "property_map.h"
#include "property_slot.h"
#include "scope_chain.h"
@@ -51,6 +48,15 @@
class HashEntry;
class ListImp;
+ // ECMA 262-3 8.6.1
+ // Property attributes
+ enum Attribute { None = 0,
+ ReadOnly = 1 << 1, // property can be only read, not written
+ DontEnum = 1 << 2, // property doesn't appear in (for .. in ..)
+ DontDelete = 1 << 3, // property can't be deleted
+ Internal = 1 << 4, // an internal property, set to bypass checks
+ Function = 1 << 5 }; // property is a function - only used by static hashtables
+
/**
* Class Information
*/
@@ -74,27 +80,22 @@
void *dummy;
};
- inline Object Value::toObject(ExecState *exec) const { return rep->dispatchToObject(exec); }
-
- class ObjectImp : public ValueImp {
+ class ObjectImp : public AllocatedValueImp {
public:
/**
* Creates a new ObjectImp with the specified prototype
*
* @param proto The prototype
*/
- ObjectImp(const Object &proto);
ObjectImp(ObjectImp *proto);
/**
* Creates a new ObjectImp with a prototype of Null()
- * (that is, the ECMAScript "null" value, not a null Object).
+ * (that is, the ECMAScript "null" value, not a null object pointer).
*
*/
ObjectImp();
- virtual ~ObjectImp();
-
virtual void mark();
Type type() const;
@@ -169,15 +170,28 @@
// internal properties (ECMA 262-3 8.6.2)
/**
+ * Returns the prototype of this object. Note that this is not the same as
+ * the "prototype" property.
+ *
+ * See ECMA 8.6.2
+ *
+ * @return The object's prototype
+ */
+ /**
* Implementation of the [[Prototype]] internal property (implemented by
* all Objects)
- *
- * @see Object::prototype()
*/
- Value prototype() const;
- void setPrototype(const Value &proto);
+ ValueImp *prototype() const;
+ void setPrototype(ValueImp *proto);
/**
+ * Returns the class name of the object
+ *
+ * See ECMA 8.6.2
+ *
+ * @return The object's class name
+ */
+ /**
* Implementation of the [[Class]] internal property (implemented by all
* Objects)
*
@@ -185,64 +199,116 @@
* You should either implement classInfo(), or
* if you simply need a classname, you can reimplement className()
* instead.
- *
- * @see Object::className()
*/
virtual UString className() const;
/**
+ * Retrieves the specified property from the object. If neither the object
+ * or any other object in it's prototype chain have the property, this
+ * function will return Undefined.
+ *
+ * See ECMA 8.6.2.1
+ *
+ * @param exec The current execution state
+ * @param propertyName The name of the property to retrieve
+ *
+ * @return The specified property, or Undefined
+ */
+ /**
* Implementation of the [[Get]] internal property (implemented by all
* Objects)
- *
- * @see Object::get()
*/
// [[Get]] - must be implemented by all Objects
- Value get(ExecState *exec, const Identifier &propertyName) const;
- Value get(ExecState *exec, unsigned propertyName) const;
+ ValueImp *get(ExecState *exec, const Identifier &propertyName) const;
+ ValueImp *get(ExecState *exec, unsigned propertyName) const;
- bool getProperty(ExecState *exec, const Identifier& propertyName, Value& result) const;
- bool getProperty(ExecState *exec, unsigned propertyName, Value& result) const;
+ bool getProperty(ExecState *exec, const Identifier& propertyName, ValueImp*& result) const;
+ bool getProperty(ExecState *exec, unsigned propertyName, ValueImp*& result) const;
bool getPropertySlot(ExecState *, const Identifier&, PropertySlot&);
bool getPropertySlot(ExecState *, unsigned, PropertySlot&);
+
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
virtual bool getOwnPropertySlot(ExecState *, unsigned index, PropertySlot&);
/**
+ * Sets the specified property.
+ *
+ * See ECMA 8.6.2.2
+ *
+ * @param exec The current execution state
+ * @param propertyName The name of the property to set
+ * @param propertyValue The value to set
+ */
+ /**
* Implementation of the [[Put]] internal property (implemented by all
* Objects)
- *
- * @see Object::put()
*/
virtual void put(ExecState *exec, const Identifier &propertyName,
- const Value &value, int attr = None);
+ ValueImp *value, int attr = None);
virtual void put(ExecState *exec, unsigned propertyName,
- const Value &value, int attr = None);
+ ValueImp *value, int attr = None);
/**
+ * Used to check whether or not a particular property is allowed to be set
+ * on an object
+ *
+ * See ECMA 8.6.2.3
+ *
+ * @param exec The current execution state
+ * @param propertyName The name of the property
+ * @return true if the property can be set, otherwise false
+ */
+ /**
* Implementation of the [[CanPut]] internal property (implemented by all
* Objects)
- *
- * @see Object::canPut()
*/
virtual bool canPut(ExecState *exec, const Identifier &propertyName) const;
/**
+ * Checks to see whether the object (or any object in it's prototype chain)
+ * has a property with the specified name.
+ *
+ * See ECMA 8.6.2.4
+ *
+ * @param exec The current execution state
+ * @param propertyName The name of the property to check for
+ * @return true if the object has the property, otherwise false
+ */
+ /**
* Implementation of the [[HasProperty]] internal property (implemented by
* all Objects)
- *
- * @see Object::hasProperty()
*/
- bool hasProperty(ExecState *exec, const Identifier &propertyName) const;
+ bool hasProperty(ExecState *exec,
+ const Identifier &propertyName) const;
bool hasProperty(ExecState *exec, unsigned propertyName) const;
+ /**
+ * Checks to see whether the object has a property with the specified name.
+ *
+ * See ECMA 15.2.4.5
+ *
+ * @param exec The current execution state
+ * @param propertyName The name of the property to check for
+ * @return true if the object has the property, otherwise false
+ */
virtual bool hasOwnProperty(ExecState *exec, const Identifier &propertyName) const;
+ virtual bool hasOwnProperty(ExecState *exec, unsigned propertyName) const;
/**
+ * Removes the specified property from the object.
+ *
+ * See ECMA 8.6.2.5
+ *
+ * @param exec The current execution state
+ * @param propertyName The name of the property to delete
+ * @return true if the property was successfully deleted or did not
+ * exist on the object. false if deleting the specified property is not
+ * allowed.
+ */
+ /**
* Implementation of the [[Delete]] internal property (implemented by all
* Objects)
- *
- * @see Object::deleteProperty()
*/
virtual bool deleteProperty(ExecState *exec,
const Identifier &propertyName);
@@ -256,59 +322,196 @@
void deleteAllProperties(ExecState *);
/**
+ * Converts the object into a primitive value. The value return may differ
+ * depending on the supplied hint
+ *
+ * See ECMA 8.6.2.6
+ *
+ * @param exec The current execution state
+ * @param hint The desired primitive type to convert to
+ * @return A primitive value converted from the objetc. Note that the
+ * type of primitive value returned may not be the same as the requested
+ * hint.
+ */
+ /**
* Implementation of the [[DefaultValue]] internal property (implemented by
* all Objects)
- *
- * @see Object::defaultValue()
*/
- virtual Value defaultValue(ExecState *exec, Type hint) const;
+ virtual ValueImp *defaultValue(ExecState *exec, Type hint) const;
+ /**
+ * Whether or not the object implements the construct() method. If this
+ * returns false you should not call the construct() method on this
+ * object (typically, an assertion will fail to indicate this).
+ *
+ * @return true if this object implements the construct() method, otherwise
+ * false
+ */
virtual bool implementsConstruct() const;
+
+ /**
+ * Creates a new object based on this object. Typically this means the
+ * following:
+ * 1. A new object is created
+ * 2. The prototype of the new object is set to the value of this object's
+ * "prototype" property
+ * 3. The call() method of this object is called, with the new object
+ * passed as the this value
+ * 4. The new object is returned
+ *
+ * In some cases, Host objects may differ from these semantics, although
+ * this is discouraged.
+ *
+ * If an error occurs during construction, the execution state's exception
+ * will be set. This can be tested for with ExecState::hadException().
+ * Under some circumstances, the exception object may also be returned.
+ *
+ * Note: This function should not be called if implementsConstruct() returns
+ * false, in which case it will result in an assertion failure.
+ *
+ * @param exec The current execution state
+ * @param args The arguments to be passed to call() once the new object has
+ * been created
+ * @return The newly created & initialized object
+ */
/**
* Implementation of the [[Construct]] internal property
- *
- * @see Object::construct()
*/
- virtual Object construct(ExecState *exec, const List &args);
- virtual Object construct(ExecState *exec, const List &args, const UString &sourceURL, int lineNumber);
+ virtual ObjectImp *construct(ExecState *exec, const List &args);
+ virtual ObjectImp *construct(ExecState *exec, const List &args, const UString &sourceURL, int lineNumber);
+ /**
+ * Whether or not the object implements the call() method. If this returns
+ * false you should not call the call() method on this object (typically,
+ * an assertion will fail to indicate this).
+ *
+ * @return true if this object implements the call() method, otherwise
+ * false
+ */
virtual bool implementsCall() const;
+
+ /**
+ * Calls this object as if it is a function.
+ *
+ * Note: This function should not be called if implementsCall() returns
+ * false, in which case it will result in an assertion failure.
+ *
+ * See ECMA 8.6.2.3
+ *
+ * @param exec The current execution state
+ * @param thisObj The obj to be used as "this" within function execution.
+ * Note that in most cases this will be different from the C++ "this"
+ * object. For example, if the ECMAScript code "window.location->toString()"
+ * is executed, call() will be invoked on the C++ object which implements
+ * the toString method, with the thisObj being window.location
+ * @param args List of arguments to be passed to the function
+ * @return The return value from the function
+ */
/**
* Implementation of the [[Call]] internal property
- *
- * @see Object::call()
*/
- virtual Value call(ExecState *exec, Object &thisObj,
- const List &args);
+ ValueImp *call(ExecState *exec, ObjectImp *thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
+ /**
+ * Whether or not the object implements the hasInstance() method. If this
+ * returns false you should not call the hasInstance() method on this
+ * object (typically, an assertion will fail to indicate this).
+ *
+ * @return true if this object implements the hasInstance() method,
+ * otherwise false
+ */
virtual bool implementsHasInstance() const;
+
+ /**
+ * Checks whether value delegates behavior to this object. Used by the
+ * instanceof operator.
+ *
+ * @param exec The current execution state
+ * @param value The value to check
+ * @return true if value delegates behavior to this object, otherwise
+ * false
+ */
/**
* Implementation of the [[HasInstance]] internal property
- *
- * @see Object::hasInstance()
*/
- virtual Boolean hasInstance(ExecState *exec, const Value &value);
+ virtual bool hasInstance(ExecState *exec, ValueImp *value);
/**
- * Implementation of the [[Scope]] internal property
+ * Returns the scope of this object. This is used when execution declared
+ * functions - the execution context for the function is initialized with
+ * extra object in it's scope. An example of this is functions declared
+ * inside other functions:
*
- * @see Object::scope()
+ * \code
+ * function f() {
+ *
+ * function b() {
+ * return prototype;
+ * }
+ *
+ * var x = 4;
+ * // do some stuff
+ * }
+ * f.prototype = new String();
+ * \endcode
+ *
+ * When the function f.b is executed, its scope will include properties of
+ * f. So in the example above the return value of f.b() would be the new
+ * String object that was assigned to f.prototype.
+ *
+ * @param exec The current execution state
+ * @return The function's scope
+ */
+ /**
+ * Implementation of the [[Scope]] internal property
*/
const ScopeChain &scope() const { return _scope; }
void setScope(const ScopeChain &s) { _scope = s; }
+ /**
+ * Returns a List of References to all the properties of the object. Used
+ * in "for x in y" statements. The list is created new, so it can be freely
+ * modified without affecting the object's properties. It should be deleted
+ * by the caller.
+ *
+ * Subclasses can override this method in ObjectImpl to provide the
+ * appearance of
+ * having extra properties other than those set specifically with put().
+ *
+ * @param exec The current execution state
+ * @param recursive Whether or not properties in the object's prototype
+ * chain should be
+ * included in the list.
+ * @return A List of References to properties of the object.
+ **/
virtual ReferenceList propList(ExecState *exec, bool recursive = true);
- Value internalValue() const;
- void setInternalValue(const Value &v);
+ /**
+ * Returns the internal value of the object. This is used for objects such
+ * as String and Boolean which are wrappers for native types. The interal
+ * value is the actual value represented by the wrapper objects.
+ *
+ * @see ECMA 8.6.2
+ * @return The internal value of the object
+ */
+ ValueImp *internalValue() const;
+
+ /**
+ * Sets the internal value of the object
+ *
+ * @see internalValue()
+ *
+ * @param v The new internal value
+ */
+
void setInternalValue(ValueImp *v);
- Value toPrimitive(ExecState *exec,
- Type preferredType = UnspecifiedType) const;
+ ValueImp *toPrimitive(ExecState *exec, Type preferredType = UnspecifiedType) const;
bool toBoolean(ExecState *exec) const;
double toNumber(ExecState *exec) const;
UString toString(ExecState *exec) const;
- Object toObject(ExecState *exec) const;
+ ObjectImp *toObject(ExecState *exec) const;
// This get method only looks at the property map.
// A bit like hasProperty(recursive=false), this doesn't go to the prototype.
@@ -344,7 +547,7 @@
return true;
ValueImp *proto = imp->_proto;
- if (proto->dispatchType() != ObjectType)
+ if (!proto->isObject())
break;
imp = static_cast<ObjectImp *>(proto);
@@ -402,9 +605,9 @@
* @param lineno Optional line number.
* @param lineno Optional source id.
*/
- static Object create(ExecState *exec, ErrorType errtype = GeneralError,
- const char *message = 0, int lineno = -1,
- int sourceId = -1, const UString *sourceURL = 0);
+ static ObjectImp *create(ExecState *exec, ErrorType errtype = GeneralError,
+ const char *message = 0, int lineno = -1,
+ int sourceId = -1, const UString *sourceURL = 0);
/**
* Array of error names corresponding to ErrorType
@@ -412,97 +615,47 @@
static const char * const * const errorNames;
};
- inline bool ValueImp::isObject(const ClassInfo *info) const
- { return isObject() && static_cast<const ObjectImp *>(this)->inherits(info); }
+ inline bool AllocatedValueImp::isObject(const ClassInfo *info) const
+ { return isObject() && static_cast<const ObjectImp *>(this)->inherits(info); }
- inline ObjectImp *ValueImp::asObject()
- { return isObject() ? static_cast<ObjectImp *>(this) : 0; }
+inline ObjectImp::ObjectImp(ObjectImp *proto)
+ : _proto(proto), _internalValue(0)
+{
+}
- inline Object::Object(ObjectImp *o) : Value(o) { }
+inline ObjectImp::ObjectImp()
+ : _proto(jsNull()), _internalValue(0)
+{
+}
- inline ObjectImp *Object::imp() const
- { return static_cast<ObjectImp *>(Value::imp()); }
+inline ValueImp *ObjectImp::internalValue() const
+{
+ return _internalValue;
+}
- inline const ClassInfo *Object::classInfo() const
- { return imp()->classInfo(); }
+inline void ObjectImp::setInternalValue(ValueImp *v)
+{
+ _internalValue = v;
+}
- inline bool Object::inherits(const ClassInfo *cinfo) const
- { return imp()->inherits(cinfo); }
+inline ValueImp *ObjectImp::prototype() const
+{
+ return _proto;
+}
- inline Value Object::prototype() const
- { return Value(imp()->prototype()); }
+inline void ObjectImp::setPrototype(ValueImp *proto)
+{
+ _proto = proto;
+}
- inline UString Object::className() const
- { return imp()->className(); }
-
- inline Value Object::get(ExecState *exec, const Identifier &propertyName) const
- { return imp()->get(exec,propertyName); }
-
- inline Value Object::get(ExecState *exec, unsigned propertyName) const
- { return imp()->get(exec,propertyName); }
-
- inline void Object::put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr)
- { imp()->put(exec,propertyName,value,attr); }
-
- inline void Object::put(ExecState *exec, unsigned propertyName, const Value &value, int attr)
- { imp()->put(exec,propertyName,value,attr); }
-
- inline bool Object::canPut(ExecState *exec, const Identifier &propertyName) const
- { return imp()->canPut(exec,propertyName); }
-
- inline bool Object::hasProperty(ExecState *exec, const Identifier &propertyName) const
- { return imp()->hasProperty(exec, propertyName); }
-
- inline bool Object::hasOwnProperty(ExecState *exec, const Identifier &propertyName) const
- { return imp()->hasOwnProperty(exec, propertyName); }
-
- inline bool Object::deleteProperty(ExecState *exec, const Identifier &propertyName)
- { return imp()->deleteProperty(exec,propertyName); }
-
- inline bool Object::deleteProperty(ExecState *exec, unsigned propertyName)
- { return imp()->deleteProperty(exec,propertyName); }
-
- inline Value Object::defaultValue(ExecState *exec, Type hint) const
- { return imp()->defaultValue(exec,hint); }
-
- inline bool Object::implementsConstruct() const
- { return imp()->implementsConstruct(); }
-
- inline Object Object::construct(ExecState *exec, const List &args)
- { return imp()->construct(exec,args); }
-
- inline Object Object::construct(ExecState *exec, const List &args, const UString &sourceURL, int lineNumber)
- { return imp()->construct(exec,args,sourceURL,lineNumber); }
-
- inline bool Object::implementsCall() const
- { return imp()->implementsCall(); }
-
- inline bool Object::implementsHasInstance() const
- { return imp()->implementsHasInstance(); }
-
- inline Boolean Object::hasInstance(ExecState *exec, const Value &value)
- { return imp()->hasInstance(exec,value); }
-
- inline const ScopeChain &Object::scope() const
- { return imp()->scope(); }
-
- inline void Object::setScope(const ScopeChain &s)
- { imp()->setScope(s); }
-
- inline ReferenceList Object::propList(ExecState *exec, bool recursive)
- { return imp()->propList(exec,recursive); }
-
- inline Value Object::internalValue() const
- { return imp()->internalValue(); }
-
- inline void Object::setInternalValue(const Value &v)
- { imp()->setInternalValue(v); }
-
- inline void Object::saveProperties(SavedProperties &p) const
- { imp()->saveProperties(p); }
- inline void Object::restoreProperties(const SavedProperties &p)
- { imp()->restoreProperties(p); }
+inline bool ObjectImp::inherits(const ClassInfo *info) const
+{
+ for (const ClassInfo *ci = classInfo(); ci; ci = ci->parentClass)
+ if (ci == info)
+ return true;
+ return false;
+}
} // namespace
-#endif // _KJS_OBJECT_H_
+#endif // KJS_OBJECT_H
diff --git a/JavaScriptCore/kjs/object_object.cpp b/JavaScriptCore/kjs/object_object.cpp
index 0e4fb136..91f6287 100644
--- a/JavaScriptCore/kjs/object_object.cpp
+++ b/JavaScriptCore/kjs/object_object.cpp
@@ -37,7 +37,6 @@
FunctionPrototypeImp *funcProto)
: ObjectImp() // [[Prototype]] is Null()
{
- Value protect(this);
putDirect(toStringPropertyName, new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ToString, 0), DontEnum);
putDirect(toLocaleStringPropertyName, new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ToLocaleString,0), DontEnum);
putDirect(valueOfPropertyName, new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ValueOf, 0), DontEnum);
@@ -52,7 +51,6 @@
int i, int len)
: InternalFunctionImp(funcProto), id(i)
{
- Value protect(this);
putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
}
@@ -64,22 +62,19 @@
// ECMA 15.2.4.2, 15.2.4.4, 15.2.4.5
-Value ObjectProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &args)
+ValueImp *ObjectProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
switch (id) {
case ValueOf:
return thisObj;
- case HasOwnProperty: {
+ case HasOwnProperty:
// Same as the in operator but without checking the prototype
- Identifier propertyName(args[0].toString(exec));
- bool exists = thisObj.hasOwnProperty(exec, propertyName);
- return Value(exists ? BooleanImp::staticTrue : BooleanImp::staticFalse);
- }
+ return jsBoolean(thisObj->hasOwnProperty(exec, Identifier(args[0]->toString(exec))));
case ToLocaleString:
- return thisObj.imp()->toString(exec);
+ return jsString(thisObj->toString(exec));
case ToString:
default:
- return String("[object " + thisObj.className() + "]");
+ return String("[object " + thisObj->className() + "]");
}
}
@@ -90,12 +85,11 @@
FunctionPrototypeImp *funcProto)
: InternalFunctionImp(funcProto)
{
- Value protect(this);
// ECMA 15.2.3.1
putDirect(prototypePropertyName, objProto, DontEnum|DontDelete|ReadOnly);
// no. of arguments for constructor
- putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum);
+ putDirect(lengthPropertyName, jsOne(), ReadOnly|DontDelete|DontEnum);
}
@@ -105,32 +99,29 @@
}
// ECMA 15.2.2
-Object ObjectObjectImp::construct(ExecState *exec, const List &args)
+ObjectImp *ObjectObjectImp::construct(ExecState *exec, const List &args)
{
// if no arguments have been passed ...
if (args.isEmpty()) {
- Object proto = exec->lexicalInterpreter()->builtinObjectPrototype();
- Object result(new ObjectImp(proto));
+ ObjectImp *proto = exec->lexicalInterpreter()->builtinObjectPrototype();
+ ObjectImp *result(new ObjectImp(proto));
return result;
}
- Value arg = *(args.begin());
- Object obj = Object::dynamicCast(arg);
- if (!obj.isNull()) {
+ ValueImp *arg = *(args.begin());
+ if (ObjectImp *obj = arg->getObject())
return obj;
- }
- switch (arg.type()) {
+ switch (arg->type()) {
case StringType:
case BooleanType:
case NumberType:
- return arg.toObject(exec);
+ return arg->toObject(exec);
default:
assert(!"unhandled switch case in ObjectConstructor");
case NullType:
case UndefinedType:
- Object proto = exec->lexicalInterpreter()->builtinObjectPrototype();
- return Object(new ObjectImp(proto));
+ return new ObjectImp(exec->lexicalInterpreter()->builtinObjectPrototype());
}
}
@@ -139,21 +130,21 @@
return true;
}
-Value ObjectObjectImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
+ValueImp *ObjectObjectImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
{
- Value result;
+ ValueImp *result;
List argList;
// Construct a new Object
if (args.isEmpty()) {
result = construct(exec,argList);
} else {
- Value arg = args[0];
- if (arg.type() == NullType || arg.type() == UndefinedType) {
+ ValueImp *arg = args[0];
+ if (arg->isUndefinedOrNull()) {
argList.append(arg);
result = construct(exec,argList);
} else
- result = arg.toObject(exec);
+ result = arg->toObject(exec);
}
return result;
}
diff --git a/JavaScriptCore/kjs/object_object.h b/JavaScriptCore/kjs/object_object.h
index 0ccd36a..7a6ca02 100644
--- a/JavaScriptCore/kjs/object_object.h
+++ b/JavaScriptCore/kjs/object_object.h
@@ -47,11 +47,10 @@
*/
class ObjectProtoFuncImp : public InternalFunctionImp {
public:
- ObjectProtoFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto,
- int i, int len);
+ ObjectProtoFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto, int i, int len);
virtual bool implementsCall() const;
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *, ObjectImp *, const List &args);
enum { ToString, ToLocaleString, ValueOf, HasOwnProperty };
private:
@@ -71,9 +70,9 @@
FunctionPrototypeImp *funcProto);
virtual bool implementsConstruct() const;
- virtual Object construct(ExecState *exec, const List &args);
+ virtual ObjectImp *construct(ExecState *, const List &args);
virtual bool implementsCall() const;
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *, ObjectImp *, const List &args);
};
} // namespace
diff --git a/JavaScriptCore/kjs/operations.cpp b/JavaScriptCore/kjs/operations.cpp
index 26d84a4..eea0497 100644
--- a/JavaScriptCore/kjs/operations.cpp
+++ b/JavaScriptCore/kjs/operations.cpp
@@ -111,10 +111,10 @@
#endif
// ECMA 11.9.3
-bool KJS::equal(ExecState *exec, const Value& v1, const Value& v2)
+bool KJS::equal(ExecState *exec, ValueImp *v1, ValueImp *v2)
{
- Type t1 = v1.type();
- Type t2 = v2.type();
+ Type t1 = v1->type();
+ Type t2 = v2->type();
if (t1 != t2) {
if (t1 == UndefinedType)
@@ -134,9 +134,9 @@
// use toNumber
} else {
if ((t1 == StringType || t1 == NumberType) && t2 >= ObjectType)
- return equal(exec, v1, v2.toPrimitive(exec));
+ return equal(exec, v1, v2->toPrimitive(exec));
if (t1 >= ObjectType && (t2 == StringType || t2 == NumberType))
- return equal(exec, v1.toPrimitive(exec), v2);
+ return equal(exec, v1->toPrimitive(exec), v2);
if (t1 != t2)
return false;
}
@@ -146,8 +146,8 @@
return true;
if (t1 == NumberType) {
- double d1 = v1.toNumber(exec);
- double d2 = v2.toNumber(exec);
+ double d1 = v1->toNumber(exec);
+ double d2 = v2->toNumber(exec);
// FIXME: Isn't this already how NaN behaves?
// Why the extra line of code?
if (isNaN(d1) || isNaN(d2))
@@ -156,27 +156,27 @@
}
if (t1 == StringType)
- return v1.toString(exec) == v2.toString(exec);
+ return v1->toString(exec) == v2->toString(exec);
if (t1 == BooleanType)
- return v1.toBoolean(exec) == v2.toBoolean(exec);
+ return v1->toBoolean(exec) == v2->toBoolean(exec);
// types are Object
- return v1.imp() == v2.imp();
+ return v1 == v2;
}
-bool KJS::strictEqual(ExecState *exec, const Value &v1, const Value &v2)
+bool KJS::strictEqual(ExecState *exec, ValueImp *v1, ValueImp *v2)
{
- Type t1 = v1.type();
- Type t2 = v2.type();
+ Type t1 = v1->type();
+ Type t2 = v2->type();
if (t1 != t2)
return false;
if (t1 == UndefinedType || t1 == NullType)
return true;
if (t1 == NumberType) {
- double n1 = v1.toNumber(exec);
- double n2 = v2.toNumber(exec);
+ double n1 = v1->toNumber(exec);
+ double n2 = v2->toNumber(exec);
// FIXME: Isn't this already how NaN behaves?
// Why the extra line of code?
if (isNaN(n1) || isNaN(n2))
@@ -186,27 +186,27 @@
/* TODO: +0 and -0 */
return false;
} else if (t1 == StringType) {
- return v1.toString(exec) == v2.toString(exec);
+ return v1->toString(exec) == v2->toString(exec);
} else if (t2 == BooleanType) {
- return v1.toBoolean(exec) == v2.toBoolean(exec);
+ return v1->toBoolean(exec) == v2->toBoolean(exec);
}
- if (v1.imp() == v2.imp())
+ if (v1 == v2)
return true;
/* TODO: joined objects */
return false;
}
-int KJS::relation(ExecState *exec, const Value& v1, const Value& v2)
+int KJS::relation(ExecState *exec, ValueImp *v1, ValueImp *v2)
{
- Value p1 = v1.toPrimitive(exec,NumberType);
- Value p2 = v2.toPrimitive(exec,NumberType);
+ ValueImp *p1 = v1->toPrimitive(exec,NumberType);
+ ValueImp *p2 = v2->toPrimitive(exec,NumberType);
- if (p1.type() == StringType && p2.type() == StringType)
- return p1.toString(exec) < p2.toString(exec) ? 1 : 0;
+ if (p1->isString() && p2->isString())
+ return p1->toString(exec) < p2->toString(exec) ? 1 : 0;
- double n1 = p1.toNumber(exec);
- double n2 = p2.toNumber(exec);
+ double n1 = p1->toNumber(exec);
+ double n2 = p2->toNumber(exec);
if (n1 < n2)
return 1;
if (n1 >= n2)
@@ -225,37 +225,37 @@
}
// ECMA 11.6
-Value KJS::add(ExecState *exec, const Value &v1, const Value &v2, char oper)
+ValueImp *KJS::add(ExecState *exec, ValueImp *v1, ValueImp *v2, char oper)
{
// exception for the Date exception in defaultValue()
Type preferred = oper == '+' ? UnspecifiedType : NumberType;
- Value p1 = v1.toPrimitive(exec, preferred);
- Value p2 = v2.toPrimitive(exec, preferred);
+ ValueImp *p1 = v1->toPrimitive(exec, preferred);
+ ValueImp *p2 = v2->toPrimitive(exec, preferred);
- if ((p1.type() == StringType || p2.type() == StringType) && oper == '+') {
- return p1.toString(exec) + p2.toString(exec);
+ if ((p1->isString() || p2->isString()) && oper == '+') {
+ return jsString(p1->toString(exec) + p2->toString(exec));
}
bool n1KnownToBeInteger;
- double n1 = p1.toNumber(exec, n1KnownToBeInteger);
+ double n1 = p1->toNumber(exec, n1KnownToBeInteger);
bool n2KnownToBeInteger;
- double n2 = p2.toNumber(exec, n2KnownToBeInteger);
+ double n2 = p2->toNumber(exec, n2KnownToBeInteger);
bool resultKnownToBeInteger = n1KnownToBeInteger && n2KnownToBeInteger;
if (oper == '+')
- return Value(n1 + n2, resultKnownToBeInteger);
+ return jsNumber(n1 + n2, resultKnownToBeInteger);
else
- return Value(n1 - n2, resultKnownToBeInteger);
+ return jsNumber(n1 - n2, resultKnownToBeInteger);
}
// ECMA 11.5
-Value KJS::mult(ExecState *exec, const Value &v1, const Value &v2, char oper)
+ValueImp *KJS::mult(ExecState *exec, ValueImp *v1, ValueImp *v2, char oper)
{
bool n1KnownToBeInteger;
- double n1 = v1.toNumber(exec, n1KnownToBeInteger);
+ double n1 = v1->toNumber(exec, n1KnownToBeInteger);
bool n2KnownToBeInteger;
- double n2 = v2.toNumber(exec, n2KnownToBeInteger);
+ double n2 = v2->toNumber(exec, n2KnownToBeInteger);
double result;
bool resultKnownToBeInteger;
@@ -271,5 +271,5 @@
resultKnownToBeInteger = n1KnownToBeInteger && n2KnownToBeInteger && n2 != 0;
}
- return Value(result, resultKnownToBeInteger);
+ return jsNumber(result, resultKnownToBeInteger);
}
diff --git a/JavaScriptCore/kjs/operations.h b/JavaScriptCore/kjs/operations.h
index 69b17d4..eb20e5d 100644
--- a/JavaScriptCore/kjs/operations.h
+++ b/JavaScriptCore/kjs/operations.h
@@ -47,8 +47,8 @@
bool isNegInf(double d);
#endif
- bool equal(ExecState *exec, const Value& v1, const Value& v2);
- bool strictEqual(ExecState *exec, const Value &v1, const Value &v2);
+ bool equal(ExecState *exec, ValueImp *v1, ValueImp *v2);
+ bool strictEqual(ExecState *exec, ValueImp *v1, ValueImp *v2);
/**
* This operator performs an abstract relational comparison of the two
* arguments that can be of arbitrary type. If possible, conversions to the
@@ -57,7 +57,7 @@
* @return 1 if v1 is "less-than" v2, 0 if the relation is "greater-than-or-
* equal". -1 if the result is undefined.
*/
- int relation(ExecState *exec, const Value& v1, const Value& v2);
+ int relation(ExecState *exec, ValueImp *v1, ValueImp *v2);
int maxInt(int d1, int d2);
int minInt(int d1, int d2);
/**
@@ -66,7 +66,7 @@
* @param oper '+' or '-' for an addition or substraction, respectively.
* @return The result of the operation.
*/
- Value add(ExecState *exec, const Value &v1, const Value &v2, char oper);
+ ValueImp *add(ExecState *exec, ValueImp *v1, ValueImp *v2, char oper);
/**
* Multiplicative operator. Either multiplies/divides v1 and v2 or
* calculates the remainder from an division.
@@ -74,7 +74,7 @@
* modulo operation.
* @return The result of the operation.
*/
- Value mult(ExecState *exec, const Value &v1, const Value &v2, char oper);
+ ValueImp *mult(ExecState *exec, ValueImp *v1, ValueImp *v2, char oper);
};
diff --git a/JavaScriptCore/kjs/property_map.cpp b/JavaScriptCore/kjs/property_map.cpp
index 3f705c3..dd0277d 100644
--- a/JavaScriptCore/kjs/property_map.cpp
+++ b/JavaScriptCore/kjs/property_map.cpp
@@ -545,7 +545,7 @@
int size = _table->size;
Entry *entries = _table->entries;
- for (int i = 0; i != size; ++i) {
+ for (int i = 0; i < size; i++) {
ValueImp *v = entries[i].value;
if (v && !v->marked())
v->mark();
@@ -563,7 +563,7 @@
return 0;
}
-void PropertyMap::addEnumerablesToReferenceList(ReferenceList &list, const Object &base) const
+void PropertyMap::addEnumerablesToReferenceList(ReferenceList &list, ObjectImp *base) const
{
if (!_table) {
#if USE_SINGLE_ENTRY
@@ -605,7 +605,7 @@
delete [] sortedEnumerables;
}
-void PropertyMap::addSparseArrayPropertiesToReferenceList(ReferenceList &list, const Object &base) const
+void PropertyMap::addSparseArrayPropertiesToReferenceList(ReferenceList &list, ObjectImp *base) const
{
if (!_table) {
#if USE_SINGLE_ENTRY
@@ -625,8 +625,7 @@
Entry *entries = _table->entries;
for (int i = 0; i != size; ++i) {
UString::Rep *key = entries[i].key;
- if (key && key != &UString::Rep::null)
- {
+ if (key && key != &UString::Rep::null) {
UString k(key);
bool fitsInUInt32;
k.toUInt32(&fitsInUInt32);
@@ -670,7 +669,7 @@
#if USE_SINGLE_ENTRY
if (_singleEntry.key && !(_singleEntry.attributes & (ReadOnly | Function))) {
prop->key = Identifier(_singleEntry.key);
- prop->value = Value(_singleEntry.value);
+ prop->value = _singleEntry.value;
prop->attributes = _singleEntry.attributes;
++prop;
}
@@ -706,7 +705,7 @@
while (q != p) {
Entry *e = *q++;
prop->key = Identifier(e->key);
- prop->value = Value(e->value);
+ prop->value = e->value;
prop->attributes = e->attributes;
++prop;
}
@@ -720,7 +719,7 @@
void PropertyMap::restore(const SavedProperties &p)
{
for (int i = 0; i != p._count; ++i)
- put(p._properties[i].key, p._properties[i].value.imp(), p._properties[i].attributes);
+ put(p._properties[i].key, p._properties[i].value, p._properties[i].attributes);
}
#if DO_CONSISTENCY_CHECK
diff --git a/JavaScriptCore/kjs/property_map.h b/JavaScriptCore/kjs/property_map.h
index 8450271..0dc674eb 100644
--- a/JavaScriptCore/kjs/property_map.h
+++ b/JavaScriptCore/kjs/property_map.h
@@ -27,7 +27,7 @@
namespace KJS {
- class Object;
+ class ObjectImp;
class ReferenceList;
class ValueImp;
@@ -81,8 +81,8 @@
ValueImp **getLocation(const Identifier &name);
void mark() const;
- void addEnumerablesToReferenceList(ReferenceList &, const Object &) const;
- void addSparseArrayPropertiesToReferenceList(ReferenceList &, const Object &) const;
+ void addEnumerablesToReferenceList(ReferenceList &, ObjectImp *) const;
+ void addSparseArrayPropertiesToReferenceList(ReferenceList &, ObjectImp *) const;
void save(SavedProperties &) const;
void restore(const SavedProperties &p);
diff --git a/JavaScriptCore/kjs/property_slot.cpp b/JavaScriptCore/kjs/property_slot.cpp
index 8b44a80..cb00478 100644
--- a/JavaScriptCore/kjs/property_slot.cpp
+++ b/JavaScriptCore/kjs/property_slot.cpp
@@ -25,7 +25,7 @@
namespace KJS {
-Value PropertySlot::undefinedGetter(ExecState *, const Identifier& propertyName, const PropertySlot& slot)
+ValueImp *PropertySlot::undefinedGetter(ExecState *, const Identifier& propertyName, const PropertySlot& slot)
{
return Undefined();
}
diff --git a/JavaScriptCore/kjs/property_slot.h b/JavaScriptCore/kjs/property_slot.h
index dad6913..f8b4ecc 100644
--- a/JavaScriptCore/kjs/property_slot.h
+++ b/JavaScriptCore/kjs/property_slot.h
@@ -36,17 +36,17 @@
class PropertySlot
{
public:
- typedef Value (*GetValueFunc)(ExecState *, const Identifier&, const PropertySlot&);
+ typedef ValueImp *(*GetValueFunc)(ExecState *, const Identifier&, const PropertySlot&);
bool isSet() { return m_getValue != 0; }
- Value getValue(ExecState *exec, const Identifier& propertyName) const
+ ValueImp *getValue(ExecState *exec, const Identifier& propertyName) const
{
if (m_getValue == VALUE_SLOT_MARKER)
return *m_data.valueSlot;
return m_getValue(exec, propertyName, *this);
}
- Value getValue(ExecState *exec, unsigned propertyName) const
+ ValueImp *getValue(ExecState *exec, unsigned propertyName) const
{
if (m_getValue == VALUE_SLOT_MARKER)
return *m_data.valueSlot;
@@ -92,7 +92,7 @@
unsigned long index() const { return m_data.index; }
private:
- static Value undefinedGetter(ExecState *, const Identifier&, const PropertySlot&);
+ static ValueImp *undefinedGetter(ExecState *, const Identifier&, const PropertySlot&);
GetValueFunc m_getValue;
diff --git a/JavaScriptCore/kjs/protect.h b/JavaScriptCore/kjs/protect.h
index 6b39e4e..a220530 100644
--- a/JavaScriptCore/kjs/protect.h
+++ b/JavaScriptCore/kjs/protect.h
@@ -48,33 +48,26 @@
{
if (val) gcUnprotect(val);
}
-
- class ProtectedValue : public Value {
- public:
- ProtectedValue() : Value() {}
- ProtectedValue(const Value&v) : Value(v) { gcProtectNullTolerant(v.imp()); };
- ProtectedValue(const ProtectedValue&v) : Value(v) { gcProtectNullTolerant(v.imp()); };
- ~ProtectedValue() { gcUnprotectNullTolerant(imp());}
- ProtectedValue& operator=(const Value &v)
- {
- ValueImp *old = imp();
- Value::operator=(v);
- gcProtectNullTolerant(v.imp());
- gcUnprotectNullTolerant(old);
- return *this;
- }
- ProtectedValue& operator=(const ProtectedValue &v)
- {
- ValueImp *old = imp();
- Value::operator=(v);
- gcProtectNullTolerant(v.imp());
- gcUnprotectNullTolerant(old);
- return *this;
- }
- private:
- explicit ProtectedValue(ValueImp *v);
- };
+class ProtectedValue {
+public:
+ ProtectedValue() : m_value(0) { }
+ ProtectedValue(ValueImp *v) : m_value(v) { gcProtectNullTolerant(v); }
+ ProtectedValue(const ProtectedValue& v) : m_value(v.m_value) { gcProtectNullTolerant(m_value); }
+ ~ProtectedValue() { gcUnprotectNullTolerant(m_value); }
+ ProtectedValue& operator=(ValueImp *v)
+ {
+ gcProtectNullTolerant(v);
+ gcUnprotectNullTolerant(m_value);
+ m_value = v;
+ return *this;
+ }
+ ProtectedValue& operator=(const ProtectedValue& v) { return *this = v.m_value; }
+ operator ValueImp *() const { return m_value; }
+ ValueImp *operator->() const { return m_value; }
+protected:
+ ValueImp *m_value;
+};
} // namespace
diff --git a/JavaScriptCore/kjs/protected_object.h b/JavaScriptCore/kjs/protected_object.h
index e267657..fdb45ac 100644
--- a/JavaScriptCore/kjs/protected_object.h
+++ b/JavaScriptCore/kjs/protected_object.h
@@ -1,4 +1,3 @@
-// -*- c-basic-offset: 2 -*-
/*
* This file is part of the KDE libraries
* Copyright (C) 2004 Apple Computer, Inc.
@@ -20,9 +19,8 @@
*
*/
-
-#ifndef _KJS_PROTECTED_OBJECT_H_
-#define _KJS_PROTECTED_OBJECT_H_
+#ifndef KJS_PROTECTED_OBJECT_H
+#define KJS_PROTECTED_OBJECT_H
#include "protect.h"
#include "object.h"
@@ -30,53 +28,36 @@
namespace KJS {
- class ProtectedObject : public Object {
- public:
- ProtectedObject() : Object() {}
- ProtectedObject(const Object &o) : Object(o) { gcProtectNullTolerant(o.imp()); };
- ProtectedObject(const ProtectedObject &o) : Object(o) { gcProtectNullTolerant(o.imp()); };
- ~ProtectedObject() { gcUnprotectNullTolerant(imp());}
- ProtectedObject& operator=(const Object &o)
- {
- ValueImp *old = imp();
- Object::operator=(o);
- gcProtectNullTolerant(o.imp());
- gcUnprotectNullTolerant(old);
- return *this;
- }
- ProtectedObject& operator=(const ProtectedObject &o)
- {
- ValueImp *old = imp();
- Object::operator=(o);
- gcProtectNullTolerant(o.imp());
- gcUnprotectNullTolerant(old);
- return *this;
- }
- private:
- explicit ProtectedObject(ObjectImp *o);
- };
-
+class ProtectedObject : private ProtectedValue {
+public:
+ ProtectedObject() { }
+ ProtectedObject(ObjectImp *v) : ProtectedValue(v) { }
+ ProtectedObject(const ProtectedObject& v) : ProtectedValue(v) { }
+ ProtectedObject& operator=(ObjectImp *v) { ProtectedValue::operator=(v); return *this; }
+ ProtectedObject& operator=(const ProtectedObject& v) { ProtectedValue::operator=(v); return *this; }
+ operator ValueImp *() const { return m_value; }
+ operator ObjectImp *() const { return static_cast<ObjectImp *>(m_value); }
+ ObjectImp *operator->() const { return static_cast<ObjectImp *>(m_value); }
+};
class ProtectedReference : public Reference {
public:
- ProtectedReference(const Reference&r) : Reference(r) { gcProtectNullTolerant(r.base.imp()); };
- ~ProtectedReference() { gcUnprotectNullTolerant(base.imp());}
+ ProtectedReference(const Reference& r) : Reference(r) { gcProtectNullTolerant(r.base); };
+ ~ProtectedReference() { gcUnprotectNullTolerant(base);}
ProtectedReference& operator=(const Reference &r)
{
- ValueImp *old = base.imp();
+ ValueImp *old = base;
Reference::operator=(r);
- gcProtectNullTolerant(r.base.imp());
+ gcProtectNullTolerant(r.base);
gcUnprotectNullTolerant(old);
return *this;
}
private:
ProtectedReference();
- ProtectedReference(const Object& b, const Identifier& p);
- ProtectedReference(const Object& b, unsigned p);
ProtectedReference(ObjectImp *b, const Identifier& p);
ProtectedReference(ObjectImp *b, unsigned p);
- ProtectedReference(const Null& b, const Identifier& p);
- ProtectedReference(const Null& b, unsigned p);
+ ProtectedReference(const Identifier& p);
+ ProtectedReference(unsigned p);
};
} // namespace
diff --git a/JavaScriptCore/kjs/protected_values.cpp b/JavaScriptCore/kjs/protected_values.cpp
index 4621e3f..c7ca6c9 100644
--- a/JavaScriptCore/kjs/protected_values.cpp
+++ b/JavaScriptCore/kjs/protected_values.cpp
@@ -25,6 +25,7 @@
#include "pointer_hash.h"
#include "simple_number.h"
#include <stdint.h>
+#include "value.h"
namespace KJS {
@@ -43,14 +44,14 @@
if (SimpleNumber::is(k))
return 0;
- unsigned hash = computeHash(k);
+ unsigned hash = pointerHash(k);
int i = hash & _tableSizeMask;
#if DUMP_STATISTICS
++numProbes;
numCollisions += _table[i].key && _table[i].key != k;
#endif
- while (ValueImp *key = _table[i].key) {
+ while (AllocatedValueImp *key = _table[i].key) {
if (key == k) {
return _table[i].value;
}
@@ -71,14 +72,14 @@
if (!_table)
expand();
- unsigned hash = computeHash(k);
+ unsigned hash = pointerHash(k);
int i = hash & _tableSizeMask;
#if DUMP_STATISTICS
++numProbes;
numCollisions += _table[i].key && _table[i].key != k;
#endif
- while (ValueImp *key = _table[i].key) {
+ while (AllocatedValueImp *key = _table[i].key) {
if (key == k) {
_table[i].value++;
return;
@@ -86,7 +87,7 @@
i = (i + 1) & _tableSizeMask;
}
- _table[i].key = k;
+ _table[i].key = k->downcast();
_table[i].value = 1;
++_keyCount;
@@ -94,9 +95,9 @@
expand();
}
-inline void ProtectedValues::insert(ValueImp *k, int v)
+inline void ProtectedValues::insert(AllocatedValueImp *k, int v)
{
- unsigned hash = computeHash(k);
+ unsigned hash = pointerHash(k);
int i = hash & _tableSizeMask;
#if DUMP_STATISTICS
@@ -117,9 +118,9 @@
if (SimpleNumber::is(k))
return;
- unsigned hash = computeHash(k);
+ unsigned hash = pointerHash(k);
- ValueImp *key;
+ AllocatedValueImp *key;
int i = hash & _tableSizeMask;
#if DUMP_STATISTICS
@@ -186,9 +187,4 @@
free(oldTable);
}
-unsigned ProtectedValues::computeHash(ValueImp *pointer)
-{
- return pointerHash(pointer);
-}
-
} // namespace
diff --git a/JavaScriptCore/kjs/protected_values.h b/JavaScriptCore/kjs/protected_values.h
index 169eb9f..49e7d54 100644
--- a/JavaScriptCore/kjs/protected_values.h
+++ b/JavaScriptCore/kjs/protected_values.h
@@ -20,19 +20,14 @@
*
*/
-
-#ifndef _KJS_PROTECTED_VALUES_H_
-#define _KJS_PROTECTED_VALUES_H_
+#ifndef KJS_PROTECTED_VALUES_H
+#define KJS_PROTECTED_VALUES_H
namespace KJS {
class ValueImp;
+ class AllocatedValueImp;
class ProtectedValues {
- struct KeyValue {
- ValueImp *key;
- int value;
- };
-
public:
static void increaseProtectCount(ValueImp *key);
static void decreaseProtectCount(ValueImp *key);
@@ -40,15 +35,19 @@
static int getProtectCount(ValueImp *key);
private:
- static void insert(ValueImp *key, int value);
+ static void insert(AllocatedValueImp *key, int value);
static void expand();
static void shrink();
static void rehash(int newTableSize);
- static unsigned computeHash(ValueImp *pointer);
// let the collector scan the table directly for protected values
friend class Collector;
+ struct KeyValue {
+ AllocatedValueImp *key;
+ int value;
+ };
+
static KeyValue *_table;
static int _tableSize;
static int _tableSizeMask;
diff --git a/JavaScriptCore/kjs/reference.cpp b/JavaScriptCore/kjs/reference.cpp
index b063db7..d8c10f3 100644
--- a/JavaScriptCore/kjs/reference.cpp
+++ b/JavaScriptCore/kjs/reference.cpp
@@ -27,22 +27,6 @@
// ------------------------------ Reference ------------------------------------
-Reference::Reference(const Object& b, const Identifier& p)
- : base(b),
- baseIsValue(false),
- propertyNameIsNumber(false),
- prop(p)
-{
-}
-
-Reference::Reference(const Object& b, unsigned p)
- : base(b),
- propertyNameAsNumber(p),
- baseIsValue(false),
- propertyNameIsNumber(true)
-{
-}
-
Reference::Reference(ObjectImp *b, const Identifier& p)
: base(b),
baseIsValue(false),
@@ -59,23 +43,23 @@
{
}
-Reference::Reference(const Null& b, const Identifier& p)
- : base(b),
+Reference::Reference(const Identifier& p)
+ : base(jsNull()),
baseIsValue(false),
propertyNameIsNumber(false),
prop(p)
{
}
-Reference::Reference(const Null& b, unsigned p)
- : base(b),
+Reference::Reference(unsigned p)
+ : base(jsNull()),
propertyNameAsNumber(p),
baseIsValue(false),
propertyNameIsNumber(true)
{
}
-Reference Reference::makeValueReference(const Value& v)
+Reference Reference::makeValueReference(ValueImp *v)
{
Reference valueRef;
valueRef.base = v;
@@ -83,10 +67,10 @@
return valueRef;
}
-Value Reference::getBase(ExecState *exec) const
+ValueImp *Reference::getBase(ExecState *exec) const
{
if (baseIsValue) {
- Object err = Error::create(exec, ReferenceError, I18N_NOOP("Invalid reference base"));
+ ObjectImp *err = Error::create(exec, ReferenceError, I18N_NOOP("Invalid reference base"));
exec->setException(err);
return err;
}
@@ -108,25 +92,25 @@
return prop;
}
-Value Reference::getValue(ExecState *exec) const
+ValueImp *Reference::getValue(ExecState *exec) const
{
if (baseIsValue) {
return base;
}
- ValueImp *o = base.imp();
- Type t = o ? o->dispatchType() : NullType;
+ ValueImp *o = base;
+ Type t = o ? o->type() : NullType;
if (t == NullType) {
UString m = I18N_NOOP("Can't find variable: ") + getPropertyName(exec).ustring();
- Object err = Error::create(exec, ReferenceError, m.ascii());
+ ObjectImp *err = Error::create(exec, ReferenceError, m.ascii());
exec->setException(err);
return err;
}
if (t != ObjectType) {
UString m = I18N_NOOP("Base is not an object");
- Object err = Error::create(exec, ReferenceError, m.ascii());
+ ObjectImp *err = Error::create(exec, ReferenceError, m.ascii());
exec->setException(err);
return err;
}
@@ -136,10 +120,10 @@
return static_cast<ObjectImp*>(o)->get(exec, prop);
}
-void Reference::putValue(ExecState *exec, const Value &w)
+void Reference::putValue(ExecState *exec, ValueImp *w)
{
if (baseIsValue) {
- Object err = Error::create(exec, ReferenceError);
+ ObjectImp *err = Error::create(exec, ReferenceError);
exec->setException(err);
return;
}
@@ -148,11 +132,11 @@
printInfo(exec,(UString("setting property ")+getPropertyName(exec).ustring()).cstring().c_str(),w);
#endif
- ValueImp *o = base.imp();
- Type t = o ? o->dispatchType() : NullType;
+ ValueImp *o = base;
+ Type t = o ? o->type() : NullType;
if (t == NullType)
- o = exec->lexicalInterpreter()->globalObject().imp();
+ o = exec->lexicalInterpreter()->globalObject();
if (propertyNameIsNumber)
return static_cast<ObjectImp*>(o)->put(exec, propertyNameAsNumber, w);
@@ -162,13 +146,13 @@
bool Reference::deleteValue(ExecState *exec)
{
if (baseIsValue) {
- Object err = Error::create(exec,ReferenceError);
+ ObjectImp *err = Error::create(exec,ReferenceError);
exec->setException(err);
return false;
}
- ValueImp *o = base.imp();
- Type t = o ? o->dispatchType() : NullType;
+ ValueImp *o = base;
+ Type t = o ? o->type() : NullType;
// The spec doesn't mention what to do if the base is null... just return true
if (t != ObjectType) {
diff --git a/JavaScriptCore/kjs/reference.h b/JavaScriptCore/kjs/reference.h
index 4a4ec3a..6765614 100644
--- a/JavaScriptCore/kjs/reference.h
+++ b/JavaScriptCore/kjs/reference.h
@@ -24,11 +24,10 @@
#define _KJS_REFERENCE_H_
#include "identifier.h"
-#include "value.h"
+#include "object.h"
namespace KJS {
- class Object;
class ObjectImp;
class Reference {
@@ -36,13 +35,11 @@
friend class ReferenceListIterator;
friend class ProtectedReference;
public:
- Reference(const Object& b, const Identifier& p);
- Reference(const Object& b, unsigned p);
Reference(ObjectImp *b, const Identifier& p);
Reference(ObjectImp *b, unsigned p);
- Reference(const Null& b, const Identifier& p);
- Reference(const Null& b, unsigned p);
- static Reference makeValueReference(const Value& v);
+ Reference(const Identifier& p);
+ Reference(unsigned p);
+ static Reference makeValueReference(ValueImp *);
/**
* Performs the GetBase type conversion operation on this value (ECMA 8.7)
@@ -50,7 +47,7 @@
* Since references are supposed to have an Object or null as their base,
* this method is guaranteed to return either Null() or an Object value.
*/
- Value getBase(ExecState *exec) const;
+ ValueImp *getBase(ExecState *exec) const;
/**
* Performs the GetPropertyName type conversion operation on this value
@@ -62,26 +59,27 @@
* Performs the GetValue type conversion operation on this value
* (ECMA 8.7.1)
*/
- Value getValue(ExecState *exec) const;
+ ValueImp *getValue(ExecState *exec) const;
/**
* Performs the PutValue type conversion operation on this value
* (ECMA 8.7.1)
*/
- void putValue(ExecState *exec, const Value &w);
+ void putValue(ExecState *exec, ValueImp *);
bool deleteValue(ExecState *exec);
- ValueImp *baseIfMutable() const { return baseIsValue ? 0 : base.imp(); }
+ ValueImp *baseIfMutable() const { return baseIsValue ? 0 : base; }
private:
Reference() { }
- Value base;
+ ValueImp *base;
unsigned propertyNameAsNumber;
bool baseIsValue;
bool propertyNameIsNumber;
mutable Identifier prop;
};
+
}
#endif
diff --git a/JavaScriptCore/kjs/regexp_object.cpp b/JavaScriptCore/kjs/regexp_object.cpp
index 8f5d945..fb904bb 100644
--- a/JavaScriptCore/kjs/regexp_object.cpp
+++ b/JavaScriptCore/kjs/regexp_object.cpp
@@ -45,7 +45,6 @@
FunctionPrototypeImp *funcProto)
: ObjectImp(objProto)
{
- Value protect(this);
setInternalValue(String(""));
// The constructor will be added later in RegExpObject's constructor (?)
@@ -63,7 +62,6 @@
FunctionPrototypeImp *funcProto, int i, int len)
: InternalFunctionImp(funcProto), id(i)
{
- Value protect(this);
putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
}
@@ -72,45 +70,45 @@
return true;
}
-Value RegExpProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &args)
+ValueImp *RegExpProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- if (!thisObj.inherits(&RegExpImp::info)) {
- if (thisObj.inherits(&RegExpPrototypeImp::info)) {
+ if (!thisObj->inherits(&RegExpImp::info)) {
+ if (thisObj->inherits(&RegExpPrototypeImp::info)) {
switch (id) {
case ToString: return String("//");
}
}
- Object err = Error::create(exec,TypeError);
+ ObjectImp *err = Error::create(exec,TypeError);
exec->setException(err);
return err;
}
- RegExpImp *reimp = static_cast<RegExpImp*>(thisObj.imp());
+ RegExpImp *reimp = static_cast<RegExpImp*>(thisObj);
RegExp *re = reimp->regExp();
- String s;
+ UString s;
UString str;
switch (id) {
case Exec: // 15.10.6.2
case Test:
{
- s = args[0].toString(exec);
- int length = s.value().size();
- Value lastIndex = thisObj.get(exec,"lastIndex");
- int i = lastIndex.isNull() ? 0 : lastIndex.toInt32(exec);
- bool globalFlag = thisObj.get(exec,"global").toBoolean(exec);
+ s = args[0]->toString(exec);
+ int length = s.size();
+ ValueImp *lastIndex = thisObj->get(exec,"lastIndex");
+ int i = lastIndex->toInt32(exec);
+ bool globalFlag = thisObj->get(exec,"global")->toBoolean(exec);
if (!globalFlag)
i = 0;
if (i < 0 || i > length) {
- thisObj.put(exec,"lastIndex", Number(0), DontDelete | DontEnum);
+ thisObj->put(exec,"lastIndex", Number(0), DontDelete | DontEnum);
if (id == Test)
return Boolean(false);
else
return Null();
}
- RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->lexicalInterpreter()->builtinRegExp().imp());
- int **ovector = regExpObj->registerRegexp( re, s.value() );
+ RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->lexicalInterpreter()->builtinRegExp());
+ int **ovector = regExpObj->registerRegexp( re, s );
- str = re->match(s.value(), i, 0L, ovector);
+ str = re->match(s, i, 0L, ovector);
regExpObj->setSubPatterns(re->subPatterns());
if (id == Test)
@@ -119,29 +117,29 @@
if (str.isNull()) // no match
{
if (globalFlag)
- thisObj.put(exec,"lastIndex",Number(0), DontDelete | DontEnum);
+ thisObj->put(exec,"lastIndex",Number(0), DontDelete | DontEnum);
return Null();
}
else // success
{
if (globalFlag)
- thisObj.put(exec,"lastIndex",Number( (*ovector)[1] ), DontDelete | DontEnum);
+ thisObj->put(exec,"lastIndex",Number( (*ovector)[1] ), DontDelete | DontEnum);
return regExpObj->arrayOfMatches(exec,str);
}
}
break;
case ToString:
- s = thisObj.get(exec,"source").toString(exec);
+ s = thisObj->get(exec,"source")->toString(exec);
str = "/";
- str += s.value();
+ str += s;
str += "/";
- if (thisObj.get(exec,"global").toBoolean(exec)) {
+ if (thisObj->get(exec,"global")->toBoolean(exec)) {
str += "g";
}
- if (thisObj.get(exec,"ignoreCase").toBoolean(exec)) {
+ if (thisObj->get(exec,"ignoreCase")->toBoolean(exec)) {
str += "i";
}
- if (thisObj.get(exec,"multiline").toBoolean(exec)) {
+ if (thisObj->get(exec,"multiline")->toBoolean(exec)) {
str += "m";
}
return String(str);
@@ -172,12 +170,11 @@
: InternalFunctionImp(funcProto), lastOvector(0L), lastNrSubPatterns(0)
{
- Value protect(this);
// ECMA 15.10.5.1 RegExp.prototype
putDirect(prototypePropertyName, regProto, DontEnum|DontDelete|ReadOnly);
// no. of arguments for constructor
- putDirect(lengthPropertyName, NumberImp::two(), ReadOnly|DontDelete|DontEnum);
+ putDirect(lengthPropertyName, jsTwo(), ReadOnly|DontDelete|DontEnum);
}
RegExpObjectImp::~RegExpObjectImp()
@@ -194,7 +191,7 @@
return &lastOvector;
}
-Object RegExpObjectImp::arrayOfMatches(ExecState *exec, const UString &result) const
+ObjectImp *RegExpObjectImp::arrayOfMatches(ExecState *exec, const UString &result) const
{
List list;
// The returned array contains 'result' as first item, followed by the list of matches
@@ -204,19 +201,19 @@
{
int start = lastOvector[2*i];
if (start == -1)
- list.append(UndefinedImp::staticUndefined);
+ list.append(jsUndefined());
else {
UString substring = lastString.substr( start, lastOvector[2*i+1] - start );
list.append(String(substring));
}
}
- Object arr = exec->lexicalInterpreter()->builtinArray().construct(exec, list);
- arr.put(exec, "index", Number(lastOvector[0]));
- arr.put(exec, "input", String(lastString));
+ ObjectImp *arr = exec->lexicalInterpreter()->builtinArray()->construct(exec, list);
+ arr->put(exec, "index", Number(lastOvector[0]));
+ arr->put(exec, "input", String(lastString));
return arr;
}
-Value RegExpObjectImp::backrefGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
+ValueImp *RegExpObjectImp::backrefGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
{
RegExpObjectImp *thisObj = static_cast<RegExpObjectImp *>(slot.slotBase());
unsigned long i = slot.index();
@@ -253,36 +250,35 @@
}
// ECMA 15.10.4
-Object RegExpObjectImp::construct(ExecState *exec, const List &args)
+ObjectImp *RegExpObjectImp::construct(ExecState *exec, const List &args)
{
- Object o = Object::dynamicCast(args[0]);
- if (!o.isNull() && o.inherits(&RegExpImp::info)) {
- if (args[1].type() != UndefinedType) {
- Object err = Error::create(exec,TypeError);
+ ObjectImp *o = args[0]->getObject();
+ if (o && o->inherits(&RegExpImp::info)) {
+ if (!args[1]->isUndefined()) {
+ ObjectImp *err = Error::create(exec,TypeError);
exec->setException(err);
return err;
}
return o;
}
- UString p = args[0].type() == UndefinedType ? UString("") : args[0].toString(exec);
- UString flags = args[1].type() == UndefinedType ? UString("") : args[1].toString(exec);
+ UString p = args[0]->isUndefined() ? UString("") : args[0]->toString(exec);
+ UString flags = args[1]->isUndefined() ? UString("") : args[1]->toString(exec);
- RegExpPrototypeImp *proto = static_cast<RegExpPrototypeImp*>(exec->lexicalInterpreter()->builtinRegExpPrototype().imp());
+ RegExpPrototypeImp *proto = static_cast<RegExpPrototypeImp*>(exec->lexicalInterpreter()->builtinRegExpPrototype());
RegExpImp *dat = new RegExpImp(proto);
- Object obj(dat); // protect from GC
bool global = (flags.find("g") >= 0);
bool ignoreCase = (flags.find("i") >= 0);
bool multiline = (flags.find("m") >= 0);
// TODO: throw a syntax error on invalid flags
- dat->putDirect("global", global ? BooleanImp::staticTrue : BooleanImp::staticFalse, DontDelete | ReadOnly | DontEnum);
- dat->putDirect("ignoreCase", ignoreCase ? BooleanImp::staticTrue : BooleanImp::staticFalse, DontDelete | ReadOnly | DontEnum);
- dat->putDirect("multiline", multiline ? BooleanImp::staticTrue : BooleanImp::staticFalse, DontDelete | ReadOnly | DontEnum);
+ dat->putDirect("global", jsBoolean(global), DontDelete | ReadOnly | DontEnum);
+ dat->putDirect("ignoreCase", jsBoolean(ignoreCase), DontDelete | ReadOnly | DontEnum);
+ dat->putDirect("multiline", jsBoolean(multiline), DontDelete | ReadOnly | DontEnum);
- dat->putDirect("source", new StringImp(p), DontDelete | ReadOnly | DontEnum);
- dat->putDirect("lastIndex", NumberImp::zero(), DontDelete | DontEnum);
+ dat->putDirect("source", jsString(p), DontDelete | ReadOnly | DontEnum);
+ dat->putDirect("lastIndex", jsZero(), DontDelete | DontEnum);
int reflags = RegExp::None;
if (global)
@@ -293,7 +289,7 @@
reflags |= RegExp::Multiline;
dat->setRegExp(new RegExp(p, reflags));
- return obj;
+ return dat;
}
bool RegExpObjectImp::implementsCall() const
@@ -302,7 +298,7 @@
}
// ECMA 15.10.3
-Value RegExpObjectImp::call(ExecState *exec, Object &/*thisObj*/,
+ValueImp *RegExpObjectImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/,
const List &args)
{
// TODO: handle RegExp argument case (15.10.3.1)
diff --git a/JavaScriptCore/kjs/regexp_object.h b/JavaScriptCore/kjs/regexp_object.h
index 5b0eeb9..db896de 100644
--- a/JavaScriptCore/kjs/regexp_object.h
+++ b/JavaScriptCore/kjs/regexp_object.h
@@ -43,7 +43,7 @@
FunctionPrototypeImp *funcProto, int i, int len);
virtual bool implementsCall() const;
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
enum { Exec, Test, ToString };
private:
@@ -70,16 +70,16 @@
RegExpPrototypeImp *regProto);
virtual ~RegExpObjectImp();
virtual bool implementsConstruct() const;
- virtual Object construct(ExecState *exec, const List &args);
+ virtual ObjectImp *construct(ExecState *exec, const List &args);
virtual bool implementsCall() const;
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
int ** registerRegexp( const RegExp* re, const UString& s );
void setSubPatterns(int num) { lastNrSubPatterns = num; }
- Object arrayOfMatches(ExecState *exec, const UString &result) const;
+ ObjectImp *arrayOfMatches(ExecState *exec, const UString &result) const;
private:
- static Value backrefGetter(ExecState *exec, const Identifier&, const PropertySlot& slot);
+ static ValueImp *backrefGetter(ExecState *exec, const Identifier&, const PropertySlot& slot);
UString lastString;
int *lastOvector;
diff --git a/JavaScriptCore/kjs/string_object.cpp b/JavaScriptCore/kjs/string_object.cpp
index 36563c3..a115697 100644
--- a/JavaScriptCore/kjs/string_object.cpp
+++ b/JavaScriptCore/kjs/string_object.cpp
@@ -50,15 +50,15 @@
setInternalValue(String(string));
}
-Value StringInstanceImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot &slot)
+ValueImp *StringInstanceImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot &slot)
{
- return Value(static_cast<StringInstanceImp *>(slot.slotBase())->internalValue().toString(exec).size());
+ return jsNumber(static_cast<StringInstanceImp *>(slot.slotBase())->internalValue()->toString(exec).size());
}
-Value StringInstanceImp::indexGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot &slot)
+ValueImp *StringInstanceImp::indexGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot &slot)
{
- const UChar c = static_cast<StringInstanceImp *>(slot.slotBase())->internalValue().toString(exec)[slot.index()];
- return Value(UString(&c, 1));
+ const UChar c = static_cast<StringInstanceImp *>(slot.slotBase())->internalValue()->toString(exec)[slot.index()];
+ return jsString(UString(&c, 1));
}
bool StringInstanceImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot)
@@ -71,7 +71,7 @@
bool ok;
const unsigned index = propertyName.toArrayIndex(&ok);
if (ok) {
- const UString s = internalValue().toString(exec);
+ const UString s = internalValue()->toString(exec);
const unsigned length = s.size();
if (index >= length)
return false;
@@ -82,7 +82,7 @@
return ObjectImp::getOwnPropertySlot(exec, propertyName, slot);
}
-void StringInstanceImp::put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr)
+void StringInstanceImp::put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr)
{
if (propertyName == lengthPropertyName)
return;
@@ -142,10 +142,8 @@
ObjectPrototypeImp *objProto)
: StringInstanceImp(objProto)
{
- Value protect(this);
// The constructor will be added later, after StringObjectImp has been built
- putDirect(lengthPropertyName, NumberImp::zero(), DontDelete|ReadOnly|DontEnum);
-
+ putDirect(lengthPropertyName, jsZero(), DontDelete|ReadOnly|DontEnum);
}
bool StringPrototypeImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot)
@@ -157,10 +155,9 @@
StringProtoFuncImp::StringProtoFuncImp(ExecState *exec, int i, int len)
: InternalFunctionImp(
- static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype().imp())
+ static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype())
), id(i)
{
- Value protect(this);
putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
}
@@ -171,8 +168,8 @@
static inline bool regExpIsGlobal(RegExpImp *regExp, ExecState *exec)
{
- Value globalProperty = regExp->get(exec,"global");
- return globalProperty.type() != UndefinedType && globalProperty.toBoolean(exec);
+ ValueImp *globalProperty = regExp->get(exec,"global");
+ return !globalProperty->isUndefined() && globalProperty->toBoolean(exec);
}
static inline void expandSourceRanges(UString::Range * & array, int& count, int& capacity)
@@ -259,22 +256,22 @@
return substitutedReplacement;
}
-static Value replace(ExecState *exec, const UString &source, const Value &pattern, const Value &replacement)
+static ValueImp *replace(ExecState *exec, const UString &source, ValueImp *pattern, ValueImp *replacement)
{
ObjectImp *replacementFunction = 0;
UString replacementString;
- if (replacement.type() == ObjectType && replacement.toObject(exec).implementsCall())
- replacementFunction = replacement.toObject(exec).imp();
+ if (replacement->isObject() && replacement->toObject(exec)->implementsCall())
+ replacementFunction = replacement->toObject(exec);
else
- replacementString = replacement.toString(exec);
+ replacementString = replacement->toString(exec);
- if (pattern.type() == ObjectType && pattern.toObject(exec).inherits(&RegExpImp::info)) {
- RegExpImp* imp = static_cast<RegExpImp *>( pattern.toObject(exec).imp() );
+ if (pattern->isObject() && pattern->toObject(exec)->inherits(&RegExpImp::info)) {
+ RegExpImp* imp = static_cast<RegExpImp *>( pattern->toObject(exec) );
RegExp *reg = imp->regExp();
bool global = regExpIsGlobal(imp, exec);
- RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->lexicalInterpreter()->builtinRegExp().imp());
+ RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->lexicalInterpreter()->builtinRegExp());
int matchIndex = 0;
int lastIndex = 0;
@@ -302,20 +299,20 @@
int completeMatchStart = (*ovector)[0];
List args;
- args.append(Value(matchString));
+ args.append(jsString(matchString));
for (unsigned i = 0; i < reg->subPatterns(); i++) {
int matchStart = (*ovector)[(i + 1) * 2];
int matchLen = (*ovector)[(i + 1) * 2 + 1] - matchStart;
- args.append(Value(source.substr(matchStart, matchLen)));
+ args.append(jsString(source.substr(matchStart, matchLen)));
}
- args.append(Value(completeMatchStart));
- args.append(Value(source));
+ args.append(jsNumber(completeMatchStart));
+ args.append(jsString(source));
replacementString = replacementFunction->call(exec, exec->dynamicInterpreter()->globalObject(),
- args).toString(exec);
+ args)->toString(exec);
}
UString substitutedReplacement = substituteBackreferences(replacementString, source, ovector, reg);
@@ -344,7 +341,7 @@
}
// First arg is a string
- UString patternString = pattern.toString(exec);
+ UString patternString = pattern->toString(exec);
int matchPos = source.find(patternString);
int matchLen = patternString.size();
// Do the replacement
@@ -354,31 +351,31 @@
if (replacementFunction) {
List args;
- args.append(Value(source.substr(matchPos, matchLen)));
- args.append(Value(matchPos));
- args.append(Value(source));
+ args.append(jsString(source.substr(matchPos, matchLen)));
+ args.append(jsNumber(matchPos));
+ args.append(jsString(source));
replacementString = replacementFunction->call(exec, exec->dynamicInterpreter()->globalObject(),
- args).toString(exec);
+ args)->toString(exec);
}
return String(source.substr(0, matchPos) + replacementString + source.substr(matchPos + matchLen));
}
// ECMA 15.5.4.2 - 15.5.4.20
-Value StringProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &args)
+ValueImp *StringProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
- Value result;
+ ValueImp *result = NULL;
// toString and valueOf are no generic function.
if (id == ToString || id == ValueOf) {
- if (thisObj.isNull() || !thisObj.inherits(&StringInstanceImp::info)) {
- Object err = Error::create(exec,TypeError);
+ if (!thisObj || !thisObj->inherits(&StringInstanceImp::info)) {
+ ObjectImp *err = Error::create(exec,TypeError);
exec->setException(err);
return err;
}
- return String(thisObj.internalValue().toString(exec));
+ return String(thisObj->internalValue()->toString(exec));
}
UString u, u2, u3;
@@ -386,11 +383,11 @@
double dpos;
double d = 0.0;
- UString s = thisObj.toString(exec);
+ UString s = thisObj->toString(exec);
int len = s.size();
- Value a0 = args[0];
- Value a1 = args[1];
+ ValueImp *a0 = args[0];
+ ValueImp *a1 = args[1];
switch (id) {
case ToString:
@@ -400,7 +397,7 @@
case CharAt:
// Other browsers treat an omitted parameter as 0 rather than NaN.
// That doesn't match the ECMA standard, but is needed for site compatibility.
- dpos = a0.isA(UndefinedType) ? 0 : a0.toInteger(exec);
+ dpos = a0->isUndefined() ? 0 : a0->toInteger(exec);
if (dpos >= 0 && dpos < len) // false for NaN
u = s.substr(static_cast<int>(dpos), 1);
else
@@ -410,26 +407,26 @@
case CharCodeAt:
// Other browsers treat an omitted parameter as 0 rather than NaN.
// That doesn't match the ECMA standard, but is needed for site compatibility.
- dpos = a0.isA(UndefinedType) ? 0 : a0.toInteger(exec);
+ dpos = a0->isUndefined() ? 0 : a0->toInteger(exec);
if (dpos >= 0 && dpos < len) // false for NaN
result = Number(s[static_cast<int>(dpos)].unicode());
else
- result = Number(NaN);
+ result = jsNaN();
break;
case Concat: {
ListIterator it = args.begin();
for ( ; it != args.end() ; ++it) {
- s += it->dispatchToString(exec);
+ s += it->toString(exec);
}
result = String(s);
break;
}
case IndexOf:
- u2 = a0.toString(exec);
- if (a1.type() == UndefinedType)
+ u2 = a0->toString(exec);
+ if (a1->isUndefined())
dpos = 0;
else {
- dpos = a1.toInteger(exec);
+ dpos = a1->toInteger(exec);
if (dpos >= 0) { // false for NaN
if (dpos > len)
dpos = len;
@@ -439,12 +436,12 @@
result = Number(s.find(u2, static_cast<int>(dpos)));
break;
case LastIndexOf:
- u2 = a0.toString(exec);
- d = a1.toNumber(exec);
- if (a1.type() == UndefinedType || KJS::isNaN(d))
+ u2 = a0->toString(exec);
+ d = a1->toNumber(exec);
+ if (a1->isUndefined() || KJS::isNaN(d))
dpos = len;
else {
- dpos = a1.toInteger(exec);
+ dpos = a1->toInteger(exec);
if (dpos >= 0) { // false for NaN
if (dpos > len)
dpos = len;
@@ -458,9 +455,9 @@
u = s;
RegExp *reg, *tmpReg = 0;
RegExpImp *imp = 0;
- if (a0.isA(ObjectType) && a0.toObject(exec).inherits(&RegExpImp::info))
+ if (a0->isObject() && a0->getObject()->inherits(&RegExpImp::info))
{
- imp = static_cast<RegExpImp *>( a0.toObject(exec).imp() );
+ imp = static_cast<RegExpImp *>(a0);
reg = imp->regExp();
}
else
@@ -469,9 +466,9 @@
* If regexp is not an object whose [[Class]] property is "RegExp", it is
* replaced with the result of the expression new RegExp(regexp).
*/
- reg = tmpReg = new RegExp(a0.toString(exec), RegExp::None);
+ reg = tmpReg = new RegExp(a0->toString(exec), RegExp::None);
}
- RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->lexicalInterpreter()->builtinRegExp().imp());
+ RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->lexicalInterpreter()->builtinRegExp());
int **ovector = regExpObj->registerRegexp(reg, u);
UString mstr = reg->match(u, -1, &pos, ovector);
if (id == Search) {
@@ -492,7 +489,7 @@
int lastIndex = 0;
while (pos >= 0) {
if (mstr.isNull())
- list.append(UndefinedImp::staticUndefined);
+ list.append(jsUndefined());
else
list.append(String(mstr));
lastIndex = pos;
@@ -508,7 +505,7 @@
// other browsers and because Null is a false value.
result = Null();
} else {
- result = exec->lexicalInterpreter()->builtinArray().construct(exec, list);
+ result = exec->lexicalInterpreter()->builtinArray()->construct(exec, list);
}
}
}
@@ -521,7 +518,7 @@
case Slice: // http://developer.netscape.com/docs/manuals/js/client/jsref/string.htm#1194366
{
// The arg processing is very much like ArrayProtoFunc::Slice
- double begin = args[0].toInteger(exec);
+ double begin = args[0]->toInteger(exec);
if (begin >= 0) { // false for NaN
if (begin > len)
begin = len;
@@ -531,8 +528,8 @@
begin = 0;
}
double end = len;
- if (args[1].type() != UndefinedType) {
- end = args[1].toInteger(exec);
+ if (!args[1]->isUndefined()) {
+ end = args[1]->toInteger(exec);
if (end >= 0) { // false for NaN
if (end > len)
end = len;
@@ -547,18 +544,18 @@
break;
}
case Split: {
- Object constructor = exec->lexicalInterpreter()->builtinArray();
- Object res = Object::dynamicCast(constructor.construct(exec,List::empty()));
+ ObjectImp *constructor = exec->lexicalInterpreter()->builtinArray();
+ ObjectImp *res = static_cast<ObjectImp *>(constructor->construct(exec,List::empty()));
result = res;
u = s;
i = p0 = 0;
- uint32_t limit = a1.type() == UndefinedType ? 0xFFFFFFFFU : a1.toUInt32(exec);
- if (a0.type() == ObjectType && Object::dynamicCast(a0).inherits(&RegExpImp::info)) {
- Object obj0 = Object::dynamicCast(a0);
- RegExp reg(obj0.get(exec,"source").toString(exec));
+ uint32_t limit = a1->isUndefined() ? 0xFFFFFFFFU : a1->toUInt32(exec);
+ if (a0->isObject() && static_cast<ObjectImp *>(a0)->inherits(&RegExpImp::info)) {
+ ObjectImp *obj0 = static_cast<ObjectImp *>(a0);
+ RegExp reg(obj0->get(exec,"source")->toString(exec));
if (u.isEmpty() && !reg.match(u, 0).isNull()) {
// empty string matched by regexp -> empty array
- res.put(exec,lengthPropertyName, Number(0));
+ res->put(exec,lengthPropertyName, Number(0));
break;
}
pos = 0;
@@ -572,13 +569,13 @@
break;
pos = mpos + (mstr.isEmpty() ? 1 : mstr.size());
if (mpos != p0 || !mstr.isEmpty()) {
- res.put(exec,i, String(u.substr(p0, mpos-p0)));
+ res->put(exec,i, String(u.substr(p0, mpos-p0)));
p0 = mpos + mstr.size();
i++;
}
}
} else {
- u2 = a0.toString(exec);
+ u2 = a0->toString(exec);
if (u2.isEmpty()) {
if (u.isEmpty()) {
// empty separator matches empty string -> empty array
@@ -586,11 +583,11 @@
break;
} else {
while (static_cast<uint32_t>(i) != limit && i < u.size()-1)
- res.put(exec, i++, String(u.substr(p0++, 1)));
+ res->put(exec, i++, String(u.substr(p0++, 1)));
}
} else {
while (static_cast<uint32_t>(i) != limit && (pos = u.find(u2, p0)) >= 0) {
- res.put(exec, i, String(u.substr(p0, pos-p0)));
+ res->put(exec, i, String(u.substr(p0, pos-p0)));
p0 = pos + u2.size();
i++;
}
@@ -598,13 +595,13 @@
}
// add remaining string, if any
if (static_cast<uint32_t>(i) != limit)
- res.put(exec, i++, String(u.substr(p0)));
- res.put(exec,lengthPropertyName, Number(i));
+ res->put(exec, i++, String(u.substr(p0)));
+ res->put(exec,lengthPropertyName, Number(i));
}
break;
case Substr: {
- double d = a0.toInteger(exec);
- double d2 = a1.toInteger(exec);
+ double d = a0->toInteger(exec);
+ double d2 = a1->toInteger(exec);
if (!(d >= 0)) { // true for NaN
d += len;
if (!(d >= 0)) // true for NaN
@@ -622,8 +619,8 @@
break;
}
case Substring: {
- double start = a0.toNumber(exec);
- double end = a1.toNumber(exec);
+ double start = a0->toNumber(exec);
+ double end = a1->toNumber(exec);
if (KJS::isNaN(start))
start = 0;
if (KJS::isNaN(end))
@@ -636,7 +633,7 @@
start = len;
if (end > len)
end = len;
- if (a1.type() == UndefinedType)
+ if (a1->isUndefined())
end = len;
if (start > end) {
double temp = end;
@@ -689,16 +686,16 @@
result = String("<sup>" + s + "</sup>");
break;
case Fontcolor:
- result = String("<font color=\"" + a0.toString(exec) + "\">" + s + "</font>");
+ result = String("<font color=\"" + a0->toString(exec) + "\">" + s + "</font>");
break;
case Fontsize:
- result = String("<font size=\"" + a0.toString(exec) + "\">" + s + "</font>");
+ result = String("<font size=\"" + a0->toString(exec) + "\">" + s + "</font>");
break;
case Anchor:
- result = String("<a name=\"" + a0.toString(exec) + "\">" + s + "</a>");
+ result = String("<a name=\"" + a0->toString(exec) + "\">" + s + "</a>");
break;
case Link:
- result = String("<a href=\"" + a0.toString(exec) + "\">" + s + "</a>");
+ result = String("<a href=\"" + a0->toString(exec) + "\">" + s + "</a>");
break;
#endif
}
@@ -713,7 +710,6 @@
StringPrototypeImp *stringProto)
: InternalFunctionImp(funcProto)
{
- Value protect(this);
// ECMA 15.5.3.1 String.prototype
putDirect(prototypePropertyName, stringProto, DontEnum|DontDelete|ReadOnly);
@@ -721,7 +717,7 @@
putDirect(fromCharCode, new StringObjectFuncImp(exec,funcProto), DontEnum);
// no. of arguments for constructor
- putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum);
+ putDirect(lengthPropertyName, jsOne(), ReadOnly|DontDelete|DontEnum);
}
@@ -731,12 +727,12 @@
}
// ECMA 15.5.2
-Object StringObjectImp::construct(ExecState *exec, const List &args)
+ObjectImp *StringObjectImp::construct(ExecState *exec, const List &args)
{
- ObjectImp *proto = exec->lexicalInterpreter()->builtinStringPrototype().imp();
+ ObjectImp *proto = exec->lexicalInterpreter()->builtinStringPrototype();
if (args.size() == 0)
- return Object(new StringInstanceImp(proto));
- return Object(new StringInstanceImp(proto, args.begin()->dispatchToString(exec)));
+ return new StringInstanceImp(proto);
+ return new StringInstanceImp(proto, args.begin()->toString(exec));
}
bool StringObjectImp::implementsCall() const
@@ -745,13 +741,13 @@
}
// ECMA 15.5.1
-Value StringObjectImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
+ValueImp *StringObjectImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
{
if (args.isEmpty())
return String("");
else {
- Value v = args[0];
- return String(v.toString(exec));
+ ValueImp *v = args[0];
+ return String(v->toString(exec));
}
}
@@ -761,8 +757,7 @@
StringObjectFuncImp::StringObjectFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto)
: InternalFunctionImp(funcProto)
{
- Value protect(this);
- putDirect(lengthPropertyName, NumberImp::one(), DontDelete|ReadOnly|DontEnum);
+ putDirect(lengthPropertyName, jsOne(), DontDelete|ReadOnly|DontEnum);
}
bool StringObjectFuncImp::implementsCall() const
@@ -770,7 +765,7 @@
return true;
}
-Value StringObjectFuncImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
+ValueImp *StringObjectFuncImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
{
UString s;
if (args.size()) {
diff --git a/JavaScriptCore/kjs/string_object.h b/JavaScriptCore/kjs/string_object.h
index 7cce991..a2c47e5 100644
--- a/JavaScriptCore/kjs/string_object.h
+++ b/JavaScriptCore/kjs/string_object.h
@@ -33,14 +33,14 @@
StringInstanceImp(ObjectImp *proto, const UString &string);
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
- virtual void put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr = None);
+ virtual void put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr = None);
virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
private:
- static Value lengthGetter(ExecState *exec, const Identifier&, const PropertySlot &slot);
- static Value indexGetter(ExecState *exec, const Identifier&, const PropertySlot &slot);
+ static ValueImp *lengthGetter(ExecState *exec, const Identifier&, const PropertySlot &slot);
+ static ValueImp *indexGetter(ExecState *exec, const Identifier&, const PropertySlot &slot);
};
/**
@@ -69,7 +69,7 @@
StringProtoFuncImp(ExecState *exec, int i, int len);
virtual bool implementsCall() const;
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
enum { ToString, ValueOf, CharAt, CharCodeAt, Concat, IndexOf, LastIndexOf,
Match, Replace, Search, Slice, Split,
@@ -96,9 +96,9 @@
StringPrototypeImp *stringProto);
virtual bool implementsConstruct() const;
- virtual Object construct(ExecState *exec, const List &args);
+ virtual ObjectImp *construct(ExecState *exec, const List &args);
virtual bool implementsCall() const;
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
};
/**
@@ -111,7 +111,7 @@
public:
StringObjectFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto);
virtual bool implementsCall() const;
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
};
} // namespace
diff --git a/JavaScriptCore/kjs/testkjs.cpp b/JavaScriptCore/kjs/testkjs.cpp
index 570e8e4..5c7106e 100644
--- a/JavaScriptCore/kjs/testkjs.cpp
+++ b/JavaScriptCore/kjs/testkjs.cpp
@@ -37,7 +37,7 @@
public:
TestFunctionImp(int i, int length);
virtual bool implementsCall() const { return true; }
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
enum { Print, Debug, Quit, GC };
@@ -50,12 +50,12 @@
putDirect(lengthPropertyName,length,DontDelete|ReadOnly|DontEnum);
}
-Value TestFunctionImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
+ValueImp *TestFunctionImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
{
switch (id) {
case Print:
case Debug:
- fprintf(stderr,"--> %s\n",args[0].toString(exec).ascii());
+ fprintf(stderr,"--> %s\n",args[0]->toString(exec).ascii());
return Undefined();
case Quit:
exit(0);
@@ -76,10 +76,10 @@
public:
VersionFunctionImp() : ObjectImp() {}
virtual bool implementsCall() const { return true; }
- virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+ virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
};
-Value VersionFunctionImp::call(ExecState */*exec*/, Object &/*thisObj*/, const List &/*args*/)
+ValueImp *VersionFunctionImp::callAsFunction(ExecState */*exec*/, ObjectImp */*thisObj*/, const List &/*args*/)
{
// We need this function for compatibility with the Mozilla JS tests but for now
// we don't actually do any version-specific handling
@@ -103,20 +103,20 @@
{
Interpreter::lock();
- Object global(new GlobalImp());
+ ObjectImp *global(new GlobalImp());
// create interpreter
Interpreter interp(global);
// add debug() function
- global.put(interp.globalExec(), "debug", Object(new TestFunctionImp(TestFunctionImp::Debug,1)));
+ global->put(interp.globalExec(), "debug", new TestFunctionImp(TestFunctionImp::Debug, 1));
// add "print" for compatibility with the mozilla js shell
- global.put(interp.globalExec(), "print", Object(new TestFunctionImp(TestFunctionImp::Print,1)));
+ global->put(interp.globalExec(), "print", new TestFunctionImp(TestFunctionImp::Print, 1));
// add "quit" for compatibility with the mozilla js shell
- global.put(interp.globalExec(), "quit", Object(new TestFunctionImp(TestFunctionImp::Quit,0)));
+ global->put(interp.globalExec(), "quit", new TestFunctionImp(TestFunctionImp::Quit, 0));
// add "gc" for compatibility with the mozilla js shell
- global.put(interp.globalExec(), "gc", Object(new TestFunctionImp(TestFunctionImp::GC,0)));
+ global->put(interp.globalExec(), "gc", new TestFunctionImp(TestFunctionImp::GC, 0));
// add "version" for compatibility with the mozilla js shell
- global.put(interp.globalExec(), "version", Object(new VersionFunctionImp()));
+ global->put(interp.globalExec(), "version", new VersionFunctionImp());
for (int i = 1; i < argc; i++) {
int code_len = 0;
@@ -150,13 +150,13 @@
if (comp.complType() == Throw) {
ExecState *exec = interp.globalExec();
- Value exVal = comp.value();
- char *msg = exVal.toString(exec).ascii();
+ ValueImp *exVal = comp.value();
+ char *msg = exVal->toString(exec).ascii();
int lineno = -1;
- if (exVal.type() == ObjectType) {
- Value lineVal = Object::dynamicCast(exVal).get(exec,"line");
- if (lineVal.type() == NumberType)
- lineno = int(lineVal.toNumber(exec));
+ if (exVal->isObject()) {
+ ValueImp *lineVal = static_cast<ObjectImp *>(exVal)->get(exec,"line");
+ if (lineVal->isNumber())
+ lineno = int(lineVal->toNumber(exec));
}
if (lineno != -1)
fprintf(stderr,"Exception, line %d: %s\n",lineno,msg);
@@ -165,7 +165,7 @@
ret = false;
}
else if (comp.complType() == ReturnValue) {
- char *msg = comp.value().toString(interp.globalExec()).ascii();
+ char *msg = comp.value()->toString(interp.globalExec()).ascii();
fprintf(stderr,"Return value: %s\n",msg);
}
diff --git a/JavaScriptCore/kjs/value.cpp b/JavaScriptCore/kjs/value.cpp
index a751104..4dcd57f 100644
--- a/JavaScriptCore/kjs/value.cpp
+++ b/JavaScriptCore/kjs/value.cpp
@@ -1,4 +1,3 @@
-// -*- c-basic-offset: 2 -*-
/*
* This file is part of the KDE libraries
* Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
@@ -23,11 +22,11 @@
*/
#include "value.h"
+
#include "object.h"
#include "types.h"
#include "interpreter.h"
-#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
@@ -37,120 +36,98 @@
#include "operations.h"
#include "error_object.h"
#include "nodes.h"
-#include "simple_number.h"
namespace KJS {
-// ----------------------------- ValueImp -------------------------------------
+AllocatedValueImp *ConstantValues::undefined = NULL;
+AllocatedValueImp *ConstantValues::null = NULL;
+AllocatedValueImp *ConstantValues::jsTrue = NULL;
+AllocatedValueImp *ConstantValues::jsFalse = NULL;
+AllocatedValueImp *ConstantValues::NaN = NULL;
-void ValueImp::mark()
+static const double D16 = 65536;
+static const double D32 = 4294967296.0;
+
+void *AllocatedValueImp::operator new(size_t size)
{
- _marked = true;
+ return Collector::allocate(size);
}
-void* ValueImp::operator new(size_t s)
+bool AllocatedValueImp::getUInt32(unsigned&) const
{
- return Collector::allocate(s);
-}
-
-void ValueImp::operator delete(void*)
-{
- // Do nothing. So far.
-}
-
-bool ValueImp::toUInt32(unsigned&) const
-{
- return false;
+ return false;
}
// ECMA 9.4
double ValueImp::toInteger(ExecState *exec) const
{
- uint32_t i;
- if (dispatchToUInt32(i))
- return i;
- return roundValue(exec, Value(const_cast<ValueImp*>(this)));
+ uint32_t i;
+ if (getUInt32(i))
+ return i;
+ return roundValue(exec, const_cast<ValueImp*>(this));
}
int32_t ValueImp::toInt32(ExecState *exec) const
{
- uint32_t i;
- if (dispatchToUInt32(i))
- return i;
+ uint32_t i;
+ if (getUInt32(i))
+ return i;
- double d = roundValue(exec, Value(const_cast<ValueImp*>(this)));
- if (isNaN(d) || isInf(d))
- return 0;
- double d32 = fmod(d, D32);
+ double d = roundValue(exec, const_cast<ValueImp*>(this));
+ if (isNaN(d) || isInf(d))
+ return 0;
+ double d32 = fmod(d, D32);
- if (d32 >= D32 / 2.0)
- d32 -= D32;
- else if (d32 < -D32 / 2.0)
- d32 += D32;
+ if (d32 >= D32 / 2)
+ d32 -= D32;
+ else if (d32 < -D32 / 2)
+ d32 += D32;
- return static_cast<int32_t>(d32);
+ return static_cast<int32_t>(d32);
}
uint32_t ValueImp::toUInt32(ExecState *exec) const
{
- uint32_t i;
- if (dispatchToUInt32(i))
- return i;
+ uint32_t i;
+ if (getUInt32(i))
+ return i;
- double d = roundValue(exec, Value(const_cast<ValueImp*>(this)));
- if (isNaN(d) || isInf(d))
- return 0;
- double d32 = fmod(d, D32);
+ double d = roundValue(exec, const_cast<ValueImp*>(this));
+ if (isNaN(d) || isInf(d))
+ return 0;
+ double d32 = fmod(d, D32);
- if (d32 < 0)
- d32 += D32;
+ if (d32 < 0)
+ d32 += D32;
- return static_cast<uint32_t>(d32);
+ return static_cast<uint32_t>(d32);
}
uint16_t ValueImp::toUInt16(ExecState *exec) const
{
- uint32_t i;
- if (dispatchToUInt32(i))
- return i;
+ uint32_t i;
+ if (getUInt32(i))
+ return i;
- double d = roundValue(exec, Value(const_cast<ValueImp*>(this)));
- if (isNaN(d) || isInf(d))
- return 0;
- double d16 = fmod(d, D16);
+ double d = roundValue(exec, const_cast<ValueImp*>(this));
+ if (isNaN(d) || isInf(d))
+ return 0;
+ double d16 = fmod(d, D16);
- if (d16 < 0)
- d16 += D16;
+ if (d16 < 0)
+ d16 += D16;
- return static_cast<uint16_t>(d16);
+ return static_cast<uint16_t>(d16);
}
-Object ValueImp::dispatchToObject(ExecState *exec) const
+ObjectImp *ValueImp::toObject(ExecState *exec) const
{
- if (SimpleNumber::is(this))
- return static_cast<const NumberImp *>(this)->NumberImp::toObject(exec);
- return toObject(exec);
+ if (SimpleNumber::is(this))
+ return static_cast<const NumberImp *>(this)->NumberImp::toObject(exec);
+ return downcast()->toObject(exec);
}
-bool ValueImp::isUndefinedOrNull() const
-{
- switch (dispatchType()) {
- case BooleanType:
- case NumberType:
- case ObjectType:
- case StringType:
- break;
- case NullType:
- case UndefinedType:
- return true;
- case UnspecifiedType:
- assert(false);
- break;
- }
- return false;
-}
-
-bool ValueImp::isBoolean(bool &booleanValue) const
+bool AllocatedValueImp::getBoolean(bool &booleanValue) const
{
if (!isBoolean())
return false;
@@ -158,7 +135,7 @@
return true;
}
-bool ValueImp::isNumber(double &numericValue) const
+bool AllocatedValueImp::getNumber(double &numericValue) const
{
if (!isNumber())
return false;
@@ -166,7 +143,12 @@
return true;
}
-bool ValueImp::isString(UString &stringValue) const
+double AllocatedValueImp::getNumber() const
+{
+ return isNumber() ? static_cast<const NumberImp *>(this)->value() : NaN;
+}
+
+bool AllocatedValueImp::getString(UString &stringValue) const
{
if (!isString())
return false;
@@ -174,253 +156,100 @@
return true;
}
-UString ValueImp::asString() const
+UString AllocatedValueImp::getString() const
{
return isString() ? static_cast<const StringImp *>(this)->value() : UString();
}
-bool ValueImp::isObject(ObjectImp *&object)
+ObjectImp *AllocatedValueImp::getObject()
{
- if (!isObject())
- return false;
- object = static_cast<ObjectImp *>(this);
- return true;
+ return isObject() ? static_cast<ObjectImp *>(this) : 0;
}
-// ------------------------------ Value ----------------------------------------
-
-Value::Value(bool b) : rep(b ? BooleanImp::staticTrue : BooleanImp::staticFalse) { }
-
-Value::Value(int i)
- : rep(SimpleNumber::fits(i) ? SimpleNumber::make(i) : new NumberImp(static_cast<double>(i))) { }
-
-Value::Value(unsigned u)
- : rep(SimpleNumber::fits(u) ? SimpleNumber::make(u) : new NumberImp(static_cast<double>(u))) { }
-
-Value::Value(double d)
- : rep(SimpleNumber::fits(d)
- ? SimpleNumber::make(static_cast<long>(d))
- : (KJS::isNaN(d) ? NumberImp::staticNaN : new NumberImp(d)))
-{ }
-
-Value::Value(double d, bool knownToBeInteger)
- : rep((knownToBeInteger ? SimpleNumber::integerFits(d) : SimpleNumber::fits(d))
- ? SimpleNumber::make(static_cast<long>(d))
- : ((!knownToBeInteger && KJS::isNaN(d)) ? NumberImp::staticNaN : new NumberImp(d)))
-{ }
-
-Value::Value(long l)
- : rep(SimpleNumber::fits(l) ? SimpleNumber::make(l) : new NumberImp(static_cast<double>(l))) { }
-
-Value::Value(unsigned long l)
- : rep(SimpleNumber::fits(l) ? SimpleNumber::make(l) : new NumberImp(static_cast<double>(l))) { }
-
-Value::Value(const char *s) : rep(new StringImp(s)) { }
-
-Value::Value(const UString &s) : rep(new StringImp(s)) { }
-
-// ------------------------------ Undefined ------------------------------------
-
-Undefined::Undefined() : Value(UndefinedImp::staticUndefined)
+const ObjectImp *AllocatedValueImp::getObject() const
{
+ return isObject() ? static_cast<const ObjectImp *>(this) : 0;
}
-Undefined Undefined::dynamicCast(const Value &v)
-{
- if (v.isNull() || v.type() != UndefinedType)
- return Undefined(0);
-
- return Undefined();
-}
-
-// ------------------------------ Null -----------------------------------------
-
-Null::Null() : Value(NullImp::staticNull)
-{
-}
-
-Null Null::dynamicCast(const Value &v)
-{
- if (v.isNull() || v.type() != NullType)
- return Null(0);
-
- return Null();
-}
-
-// ------------------------------ Boolean --------------------------------------
-
-Boolean::Boolean(bool b)
- : Value(b ? BooleanImp::staticTrue : BooleanImp::staticFalse)
-{
-}
-
-bool Boolean::value() const
-{
- assert(rep);
- return ((BooleanImp*)rep)->value();
-}
-
-Boolean Boolean::dynamicCast(const Value &v)
-{
- if (v.isNull() || v.type() != BooleanType)
- return static_cast<BooleanImp*>(0);
-
- return static_cast<BooleanImp*>(v.imp());
-}
-
-// ------------------------------ String ---------------------------------------
-
-String::String(const UString &s) : Value(new StringImp(s))
-{
-}
-
-UString String::value() const
-{
- assert(rep);
- return ((StringImp*)rep)->value();
-}
-
-String String::dynamicCast(const Value &v)
-{
- if (v.isNull() || v.type() != StringType)
- return String(0);
-
- return String(static_cast<StringImp*>(v.imp()));
-}
-
-// ------------------------------ Number ---------------------------------------
-
-Number::Number(int i)
- : Value(SimpleNumber::fits(i) ? SimpleNumber::make(i) : new NumberImp(static_cast<double>(i))) { }
-
-Number::Number(unsigned int u)
- : Value(SimpleNumber::fits(u) ? SimpleNumber::make(u) : new NumberImp(static_cast<double>(u))) { }
-
-Number::Number(double d)
- : Value(SimpleNumber::fits(d)
- ? SimpleNumber::make(static_cast<long>(d))
- : (KJS::isNaN(d) ? NumberImp::staticNaN : new NumberImp(d)))
-{ }
-
-Number::Number(double d, bool knownToBeInteger)
- : Value((knownToBeInteger ? SimpleNumber::integerFits(d) : SimpleNumber::fits(d))
- ? SimpleNumber::make(static_cast<long>(d))
- : ((!knownToBeInteger && KJS::isNaN(d)) ? NumberImp::staticNaN : new NumberImp(d)))
-{ }
-
-Number::Number(long int l)
- : Value(SimpleNumber::fits(l) ? SimpleNumber::make(l) : new NumberImp(static_cast<double>(l))) { }
-
-Number::Number(long unsigned int l)
- : Value(SimpleNumber::fits(l) ? SimpleNumber::make(l) : new NumberImp(static_cast<double>(l))) { }
-
-Number Number::dynamicCast(const Value &v)
-{
- if (v.isNull() || v.type() != NumberType)
- return Number((NumberImp*)0);
-
- return Number(static_cast<NumberImp*>(v.imp()));
-}
-
-double Number::value() const
-{
- if (SimpleNumber::is(rep))
- return (double)SimpleNumber::value(rep);
- assert(rep);
- return ((NumberImp*)rep)->value();
-}
-
-int Number::intValue() const
-{
- if (SimpleNumber::is(rep))
- return SimpleNumber::value(rep);
- return (int)((NumberImp*)rep)->value();
-}
-
-bool Number::isNaN() const
-{
- return rep == NumberImp::staticNaN;
-}
-
-bool Number::isInf() const
-{
- if (SimpleNumber::is(rep))
- return false;
- return KJS::isInf(((NumberImp*)rep)->value());
-}
-
-ValueImp *undefined()
-{
- return UndefinedImp::staticUndefined;
-}
-
-ValueImp *null()
-{
- return NullImp::staticNull;
-}
-
-ValueImp *boolean(bool b)
-{
- return b ? BooleanImp::staticTrue : BooleanImp::staticFalse;
-}
-
-ValueImp *string(const char *s)
+AllocatedValueImp *jsString(const char *s)
{
return new StringImp(s ? s : "");
}
-ValueImp *string(const UString &s)
+AllocatedValueImp *jsString(const UString &s)
{
return s.isNull() ? new StringImp("") : new StringImp(s);
}
-ValueImp *zero()
-{
- return SimpleNumber::make(0);
-}
-
-ValueImp *one()
-{
- return SimpleNumber::make(1);
-}
-
-ValueImp *two()
-{
- return SimpleNumber::make(2);
-}
-
-ValueImp *number(int i)
+ValueImp *jsNumber(int i)
{
return SimpleNumber::fits(i) ? SimpleNumber::make(i) : new NumberImp(static_cast<double>(i));
}
-ValueImp *number(unsigned i)
+ValueImp *jsNumber(unsigned i)
{
return SimpleNumber::fits(i) ? SimpleNumber::make(i) : new NumberImp(static_cast<double>(i));
}
-ValueImp *number(long i)
+ValueImp *jsNumber(long i)
{
return SimpleNumber::fits(i) ? SimpleNumber::make(i) : new NumberImp(static_cast<double>(i));
}
-ValueImp *number(unsigned long i)
+ValueImp *jsNumber(unsigned long i)
{
return SimpleNumber::fits(i) ? SimpleNumber::make(i) : new NumberImp(static_cast<double>(i));
}
-ValueImp *number(double d)
+ValueImp *jsNumber(double d)
{
return SimpleNumber::fits(d)
? SimpleNumber::make(static_cast<long>(d))
- : (isNaN(d) ? NumberImp::staticNaN : new NumberImp(d));
+ : (isNaN(d) ? jsNaN() : new NumberImp(d));
}
-ValueImp *number(double d, bool knownToBeInteger)
+ValueImp *jsNumber(double d, bool knownToBeInteger)
{
return (knownToBeInteger ? SimpleNumber::integerFits(d) : SimpleNumber::fits(d))
? SimpleNumber::make(static_cast<long>(d))
- : ((!knownToBeInteger && isNaN(d)) ? NumberImp::staticNaN : new NumberImp(d));
+ : ((!knownToBeInteger && isNaN(d)) ? jsNaN() : new NumberImp(d));
+}
+
+void ConstantValues::init()
+{
+ undefined = new UndefinedImp();
+ null = new NullImp();
+ jsTrue = new BooleanImp(true);
+ jsFalse = new BooleanImp(false);
+ NaN = new NumberImp(::KJS::NaN);
+}
+
+void ConstantValues::clear()
+{
+ undefined = NULL;
+ null = NULL;
+ jsTrue = NULL;
+ jsFalse = NULL;
+ NaN = NULL;
+}
+
+void ConstantValues::mark()
+{
+ if (AllocatedValueImp *v = undefined)
+ if (!v->marked())
+ v->mark();
+ if (AllocatedValueImp *v = null)
+ if (!v->marked())
+ v->mark();
+ if (AllocatedValueImp *v = jsTrue)
+ if (!v->marked())
+ v->mark();
+ if (AllocatedValueImp *v = jsFalse)
+ if (!v->marked())
+ v->mark();
+ if (AllocatedValueImp *v = NaN)
+ if (!v->marked())
+ v->mark();
}
}
diff --git a/JavaScriptCore/kjs/value.h b/JavaScriptCore/kjs/value.h
index 68fcfeb..1c61a0e 100644
--- a/JavaScriptCore/kjs/value.h
+++ b/JavaScriptCore/kjs/value.h
@@ -1,9 +1,8 @@
-// -*- c-basic-offset: 2 -*-
/*
* This file is part of the KDE libraries
* Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
- * Copyright (C) 2003 Apple Computer, Inc.
+ * Copyright (C) 2003-2005 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -22,8 +21,8 @@
*
*/
-#ifndef _KJS_VALUE_H_
-#define _KJS_VALUE_H_
+#ifndef KJS_VALUE_H
+#define KJS_VALUE_H
#ifndef NDEBUG // protection against problems if committing with KJS_VERBOSE on
@@ -34,43 +33,21 @@
#endif
-#include <stdlib.h> // Needed for size_t
-
-#include "ustring.h"
-
+#include <assert.h>
+#include <stdlib.h> // for size_t
#include "simple_number.h"
-
-// Primitive data types
+#include "ustring.h"
namespace KJS {
- class Value;
- class ValueImp;
- class ValueImpPrivate;
- class Undefined;
- class UndefinedImp;
- class Null;
- class NullImp;
- class Boolean;
- class BooleanImp;
- class String;
- class StringImp;
- class Number;
- class NumberImp;
- class Object;
- class ObjectImp;
- class Reference;
- class ReferenceImp;
- class List;
- class ListImp;
- class Completion;
- class ExecState;
- class ClassInfo;
+class ClassInfo;
+class ExecState;
+class ObjectImp;
- /**
- * Primitive types
- */
- enum Type {
+/**
+ * Primitive types
+ */
+enum Type {
UnspecifiedType = 0,
UndefinedType = 1,
NullType = 2,
@@ -78,431 +55,404 @@
StringType = 4,
NumberType = 5,
ObjectType = 6
- };
+};
- /**
- * ValueImp is the base type for all primitives (Undefined, Null, Boolean,
- * String, Number) and objects in ECMAScript.
- *
- * Note: you should never inherit from ValueImp as it is for primitive types
- * only (all of which are provided internally by KJS). Instead, inherit from
- * ObjectImp.
- */
- class ValueImp {
- friend class Collector;
- friend class Value;
- friend class ContextImp;
- friend class FunctionCallNode;
- public:
- ValueImp() : _marked(false) { }
- virtual ~ValueImp() { }
+/**
+ * ValueImp is the base type for all primitives (Undefined, Null, Boolean,
+ * String, Number) and objects in ECMAScript.
+ *
+ * Note: you should never inherit from ValueImp as it is for primitive types
+ * only (all of which are provided internally by KJS). Instead, inherit from
+ * ObjectImp.
+ */
+class ValueImp {
+ friend class AllocatedValueImp; // so it can derive from this class
+ friend class ProtectedValues; // so it can call downcast()
- virtual void mark();
- bool marked() const;
- void* operator new(size_t);
- void operator delete(void*);
+private:
+ ValueImp();
+ ~ValueImp();
+public:
+ // Querying the type.
+ Type type() const;
+ bool isUndefined() const;
+ bool isNull() const;
+ bool isUndefinedOrNull() const;
+ bool isBoolean() const;
+ bool isNumber() const;
+ bool isString() const;
+ bool isObject() const;
+ bool isObject(const ClassInfo *) const;
+
+ // Extracting the value.
+ bool getBoolean(bool&) const;
+ bool getNumber(double&) const;
+ double getNumber() const; // NaN if not a number
+ bool getString(UString&) const;
+ UString getString() const; // null string if not a string
+ ObjectImp *getObject(); // NULL if not an object
+ const ObjectImp *getObject() const; // NULL if not an object
+
+ // Extracting integer values.
+ bool getUInt32(uint32_t&) const;
+
+ // Basic conversions.
+ ValueImp *toPrimitive(ExecState *exec, Type preferredType = UnspecifiedType) const;
+ bool toBoolean(ExecState *exec) const;
+ double toNumber(ExecState *exec) const;
+ double toNumber(ExecState *exec, bool& knownToBeInteger) const;
+ UString toString(ExecState *exec) const;
+ ObjectImp *toObject(ExecState *exec) const;
+
+ // Integer conversions.
double toInteger(ExecState *exec) const;
int32_t toInt32(ExecState *exec) const;
uint32_t toUInt32(ExecState *exec) const;
uint16_t toUInt16(ExecState *exec) const;
- // Dispatch wrappers that handle the special small number case
+ // Garbage collection.
+ void mark();
+ bool marked() const;
- Type dispatchType() const;
- Value dispatchToPrimitive(ExecState *exec, Type preferredType = UnspecifiedType) const;
- bool dispatchToBoolean(ExecState *exec) const;
- double dispatchToNumber(ExecState *exec) const;
- double dispatchToNumber(ExecState *exec, bool &knownToBeInteger) const;
- UString dispatchToString(ExecState *exec) const;
- bool dispatchToUInt32(uint32_t&) const;
- Object dispatchToObject(ExecState *exec) const;
-
- bool isUndefined() const { return dispatchType() == UndefinedType; }
- bool isNull() const { return dispatchType() == NullType; }
- bool isUndefinedOrNull() const;
-
- bool isBoolean() const { return dispatchType() == BooleanType; }
- bool isBoolean(bool &booleanValue) const;
-
- bool isNumber() const { return dispatchType() == NumberType; }
- bool isNumber(double &numericValue) const;
-
- bool isString() const { return dispatchType() == StringType; }
- bool isString(UString &stringValue) const;
- UString asString() const; // null string if not a string
-
- bool isObject() const { return dispatchType() == ObjectType; }
- bool isObject(ObjectImp *&object);
- ObjectImp *asObject(); // 0 if not an object
- bool isObject(const ClassInfo *) const; // combine an isObject check with an inherits check
-
- private:
- virtual Type type() const = 0;
-
- // The conversion operations
-
- virtual Value toPrimitive(ExecState *exec, Type preferredType = UnspecifiedType) const = 0;
- virtual bool toBoolean(ExecState *exec) const = 0;
- virtual double toNumber(ExecState *exec) const = 0;
- virtual UString toString(ExecState *exec) const = 0;
- virtual Object toObject(ExecState *exec) const = 0;
- virtual bool toUInt32(unsigned&) const;
-
- bool _marked;
+private:
+ // Implementation details.
+ AllocatedValueImp *downcast();
+ const AllocatedValueImp *downcast() const;
// Give a compile time error if we try to copy one of these.
ValueImp(const ValueImp&);
ValueImp& operator=(const ValueImp&);
- };
-
- ValueImp *undefined();
- ValueImp *null();
+};
- ValueImp *boolean(bool = false);
-
- ValueImp *string(const char * = ""); // returns empty string if passed 0
- ValueImp *string(const UString &); // returns empty string if passed null string
-
- ValueImp *zero();
- ValueImp *one();
- ValueImp *two();
- ValueImp *number(int);
- ValueImp *number(unsigned);
- ValueImp *number(long);
- ValueImp *number(unsigned long);
- ValueImp *number(double);
- ValueImp *number(double, bool knownToBeInteger);
-
- /**
- * FIXME: Now that we have conservative GC, we will be deprecating the
- * Value wrappers and programming in terms of the ValueImp objects.
- * Eventually we will remove Value and rename ValueImp to Value.
- * We'll need to move the comments from Value to ValueImp too.
- */
- /**
- * Value objects are act as wrappers ("smart pointers") around ValueImp
- * objects and their descendents. Instead of using ValueImps
- * (and derivatives) during normal program execution, you should use a
- * Value-derived class.
- *
- * Value maintains a pointer to a ValueImp object and uses a reference
- * counting scheme to ensure that the ValueImp object is not deleted or
- * garbage collected.
- *
- * Note: The conversion operations all return values of various types -
- * if an error occurs during conversion, an error object will instead
- * be returned (where possible), and the execution state's exception
- * will be set appropriately.
- */
- class Value {
- public:
- Value() : rep(0) { }
- Value(ValueImp *v) : rep(v) { }
- operator ValueImp *() const { return rep; }
-
- explicit Value(bool);
-
- explicit Value(int);
- explicit Value(unsigned);
- explicit Value(double);
- explicit Value(long);
- explicit Value(unsigned long);
- Value(double, bool knownToBeInteger);
-
- explicit Value(const char *);
- Value(const UString &);
-
- /**
- * Returns whether or not this is a valid value. An invalid value
- * has a 0 implementation pointer and should not be used for
- * any other operation than this check. Current use: as a
- * distinct return value signalling failing dynamicCast() calls.
- */
- bool isValid() const { return rep != 0; }
- /**
- * @deprecated
- * Use !isValid() instead.
- */
- bool isNull() const { return rep == 0; }
- ValueImp *imp() const { return rep; }
-
- /**
- * Returns the type of value. This is one of UndefinedType, NullType,
- * BooleanType, StringType, NumberType, or ObjectType.
- *
- * @return The type of value
- */
- Type type() const { return rep->dispatchType(); }
-
- /**
- * Checks whether or not the value is of a particular tpye
- *
- * @param t The type to compare with
- * @return true if the value is of the specified type, otherwise false
- */
- bool isA(Type t) const { return rep->dispatchType() == t; }
-
- /**
- * Performs the ToPrimitive type conversion operation on this value
- * (ECMA 9.1)
- */
- Value toPrimitive(ExecState *exec,
- Type preferredType = UnspecifiedType) const
- { return rep->dispatchToPrimitive(exec, preferredType); }
-
- /**
- * Performs the ToBoolean type conversion operation on this value (ECMA 9.2)
- */
- bool toBoolean(ExecState *exec) const { return rep->dispatchToBoolean(exec); }
-
- /**
- * Performs the ToNumber type conversion operation on this value (ECMA 9.3)
- */
- double toNumber(ExecState *exec) const { return rep->dispatchToNumber(exec); }
- double toNumber(ExecState *exec, bool &knownToBeInteger) const { return rep->dispatchToNumber(exec, knownToBeInteger); }
-
- /**
- * Performs the ToInteger type conversion operation on this value (ECMA 9.4)
- */
- double toInteger(ExecState *exec) const { return rep->toInteger(exec); }
-
- /**
- * Performs the ToInt32 type conversion operation on this value (ECMA 9.5)
- */
- int32_t toInt32(ExecState *exec) const { return rep->toInt32(exec); }
-
- /**
- * Performs the ToUint32 type conversion operation on this value (ECMA 9.6)
- */
- uint32_t toUInt32(ExecState *exec) const { return rep->toUInt32(exec); }
-
- /**
- * Performs the ToUint16 type conversion operation on this value (ECMA 9.7)
- */
- uint16_t toUInt16(ExecState *exec) const { return rep->toUInt16(exec); }
-
- /**
- * Performs the ToString type conversion operation on this value (ECMA 9.8)
- */
- UString toString(ExecState *exec) const { return rep->dispatchToString(exec); }
-
- /**
- * Performs the ToObject type conversion operation on this value (ECMA 9.9)
- */
- Object toObject(ExecState *exec) const;
-
- /**
- * Checks if we can do a lossless conversion to UInt32.
- */
- bool toUInt32(uint32_t& i) const { return rep->dispatchToUInt32(i); }
-
- protected:
- ValueImp *rep;
- };
-
- // Primitive types
-
- /**
- * Represents an primitive Undefined value. All instances of this class
- * share the same implementation object, so == will always return true
- * for any comparison between two Undefined objects.
- */
- class Undefined : public Value {
- public:
- Undefined();
-
- /**
- * Converts a Value into an Undefined. If the value's type is not
- * UndefinedType, a null object will be returned (i.e. one with it's
- * internal pointer set to 0). If you do not know for sure whether the
- * value is of type UndefinedType, you should check the isValid()
- * methods afterwards before calling any methods on the returned value.
- *
- * @return The value converted to an Undefined
- */
- static Undefined dynamicCast(const Value &v);
- private:
+class AllocatedValueImp : public ValueImp {
+ friend class Collector;
friend class UndefinedImp;
- explicit Undefined(UndefinedImp *v);
-
- };
-
- /**
- * Represents an primitive Null value. All instances of this class
- * share the same implementation object, so == will always return true
- * for any comparison between two Null objects.
- */
- class Null : public Value {
- public:
- Null();
-
- /**
- * Converts a Value into an Null. If the value's type is not NullType,
- * a null object will be returned (i.e. one with it's internal pointer set
- * to 0). If you do not know for sure whether the value is of type
- * NullType, you should check the isValid() methods afterwards before
- * calling any methods on the returned value.
- *
- * @return The value converted to a Null
- */
- static Null dynamicCast(const Value &v);
- private:
friend class NullImp;
- explicit Null(NullImp *v);
- };
-
- /**
- * Represents an primitive Boolean value
- */
- class Boolean : public Value {
- public:
- Boolean(bool b = false);
-
- /**
- * Converts a Value into an Boolean. If the value's type is not BooleanType,
- * a null object will be returned (i.e. one with it's internal pointer set
- * to 0). If you do not know for sure whether the value is of type
- * BooleanType, you should check the isValid() methods afterwards before
- * calling any methods on the returned value.
- *
- * @return The value converted to a Boolean
- */
- static Boolean dynamicCast(const Value &v);
-
- bool value() const;
- private:
friend class BooleanImp;
- explicit Boolean(BooleanImp *v);
- };
-
- /**
- * Represents an primitive String value
- */
- class String : public Value {
- public:
- String(const UString &s = "");
-
- /**
- * Converts a Value into an String. If the value's type is not StringType,
- * a null object will be returned (i.e. one with it's internal pointer set
- * to 0). If you do not know for sure whether the value is of type
- * StringType, you should check the isValid() methods afterwards before
- * calling any methods on the returned value.
- *
- * @return The value converted to a String
- */
- static String dynamicCast(const Value &v);
-
- UString value() const;
- private:
- friend class StringImp;
- explicit String(StringImp *v);
- };
-
- extern const double NaN;
- extern const double Inf;
-
- /**
- * Represents an primitive Number value
- */
- class Number : public Value {
- friend class ValueImp;
- public:
- Number(int i);
- Number(unsigned int u);
- Number(double d = 0.0);
- Number(long int l);
- Number(long unsigned int l);
- Number(double d, bool knownToBeInteger);
-
- double value() const;
- int intValue() const;
-
- bool isNaN() const;
- bool isInf() const;
-
- /**
- * Converts a Value into an Number. If the value's type is not NumberType,
- * a null object will be returned (i.e. one with it's internal pointer set
- * to 0). If you do not know for sure whether the value is of type
- * NumberType, you should check the isNull() methods afterwards before
- * calling any methods on the returned value.
- *
- * @return The value converted to a Number
- */
- static Number dynamicCast(const Value &v);
- private:
friend class NumberImp;
- explicit Number(NumberImp *v);
- };
+ friend class StringImp;
+ friend class ObjectImp;
+private:
+ AllocatedValueImp();
+ virtual ~AllocatedValueImp();
+public:
+ // Querying the type.
+ virtual Type type() const = 0;
+ bool isBoolean() const;
+ bool isNumber() const;
+ bool isString() const;
+ bool isObject() const;
+ bool isObject(const ClassInfo *) const;
+
+ // Extracting the value.
+ bool getBoolean(bool&) const;
+ bool getNumber(double&) const;
+ double getNumber() const; // NaN if not a number
+ bool getString(UString&) const;
+ UString getString() const; // null string if not a string
+ ObjectImp *getObject(); // NULL if not an object
+ const ObjectImp *getObject() const; // NULL if not an object
+
+ // Extracting integer values.
+ virtual bool getUInt32(uint32_t&) const;
+
+ // Basic conversions.
+ virtual ValueImp *toPrimitive(ExecState *exec, Type preferredType = UnspecifiedType) const = 0;
+ virtual bool toBoolean(ExecState *exec) const = 0;
+ virtual double toNumber(ExecState *exec) const = 0;
+ double toNumber(ExecState *exec, bool& knownToBeInteger) const;
+ virtual UString toString(ExecState *exec) const = 0;
+ virtual ObjectImp *toObject(ExecState *exec) const = 0;
+
+ // Garbage collection.
+ void *operator new(size_t);
+ virtual void mark();
+ bool marked() const;
+
+private:
+ bool m_marked;
+};
+
+AllocatedValueImp *jsUndefined();
+AllocatedValueImp *jsNull();
+
+AllocatedValueImp *jsBoolean(bool = false);
+
+ValueImp *jsNumber(double);
+ValueImp *jsNumber(double, bool knownToBeInteger);
+AllocatedValueImp *jsNaN();
+ValueImp *jsZero();
+ValueImp *jsOne();
+ValueImp *jsTwo();
+ValueImp *jsNumber(int);
+ValueImp *jsNumber(unsigned);
+ValueImp *jsNumber(long);
+ValueImp *jsNumber(unsigned long);
+
+AllocatedValueImp *jsString(const UString &); // returns empty string if passed null string
+AllocatedValueImp *jsString(const char * = ""); // returns empty string if passed 0
+
+extern const double NaN;
+extern const double Inf;
+
+class ConstantValues {
+public:
+ static AllocatedValueImp *undefined;
+ static AllocatedValueImp *null;
+ static AllocatedValueImp *jsFalse;
+ static AllocatedValueImp *jsTrue;
+ static AllocatedValueImp *NaN;
+
+ static void init();
+ static void clear();
+ static void mark();
+};
+
+inline AllocatedValueImp *jsUndefined()
+{
+ return ConstantValues::undefined;
+}
+
+inline AllocatedValueImp *jsNull()
+{
+ return ConstantValues::null;
+}
+
+inline AllocatedValueImp *jsBoolean(bool b)
+{
+ return b ? ConstantValues::jsTrue : ConstantValues::jsFalse;
+}
+
+inline AllocatedValueImp *jsNaN()
+{
+ return ConstantValues::NaN;
+}
+
+inline ValueImp::ValueImp()
+{
+}
+
+inline ValueImp::~ValueImp()
+{
+}
+
+inline AllocatedValueImp::AllocatedValueImp()
+ : m_marked(false)
+{
+}
+
+inline AllocatedValueImp::~AllocatedValueImp()
+{
+}
+
+inline bool AllocatedValueImp::isBoolean() const
+{
+ return type() == BooleanType;
+}
+
+inline bool AllocatedValueImp::isNumber() const
+{
+ return type() == NumberType;
+}
+
+inline bool AllocatedValueImp::isString() const
+{
+ return type() == StringType;
+}
+
+inline bool AllocatedValueImp::isObject() const
+{
+ return type() == ObjectType;
+}
+
+inline bool AllocatedValueImp::marked() const
+{
+ return m_marked;
+}
+
+inline void AllocatedValueImp::mark()
+{
+ m_marked = true;
+}
+
+inline AllocatedValueImp *ValueImp::downcast()
+{
+ assert(!SimpleNumber::is(this));
+ return static_cast<AllocatedValueImp *>(this);
+}
+
+inline const AllocatedValueImp *ValueImp::downcast() const
+{
+ assert(!SimpleNumber::is(this));
+ return static_cast<const AllocatedValueImp *>(this);
+}
+
+inline bool ValueImp::isUndefined() const
+{
+ return this == jsUndefined();
+}
+
+inline bool ValueImp::isNull() const
+{
+ return this == jsNull();
+}
+
+inline bool ValueImp::isUndefinedOrNull() const
+{
+ return this == jsUndefined() || this == jsNull();
+}
+
+inline bool ValueImp::isBoolean() const
+{
+ return !SimpleNumber::is(this) && downcast()->isBoolean();
+}
+
+inline bool ValueImp::isNumber() const
+{
+ return SimpleNumber::is(this) || downcast()->isNumber();
+}
+
+inline bool ValueImp::isString() const
+{
+ return !SimpleNumber::is(this) && downcast()->isString();
+}
+
+inline bool ValueImp::isObject() const
+{
+ return !SimpleNumber::is(this) && downcast()->isObject();
+}
+
+inline bool ValueImp::isObject(const ClassInfo *c) const
+{
+ return !SimpleNumber::is(this) && downcast()->isObject(c);
+}
+
+inline bool ValueImp::getBoolean(bool& v) const
+{
+ return !SimpleNumber::is(this) && downcast()->getBoolean(v);
+}
+
+inline bool ValueImp::getNumber(double& v) const
+{
+ if (SimpleNumber::is(this)) {
+ v = SimpleNumber::value(this);
+ return true;
+ }
+ return downcast()->getNumber(v);
+}
+
+inline double ValueImp::getNumber() const
+{
+ return SimpleNumber::is(this) ? SimpleNumber::value(this) : downcast()->getNumber();
+}
+
+inline bool ValueImp::getString(UString& s) const
+{
+ return !SimpleNumber::is(this) && downcast()->getString(s);
+}
+
+inline UString ValueImp::getString() const
+{
+ return SimpleNumber::is(this) ? UString() : downcast()->getString();
+}
+
+inline ObjectImp *ValueImp::getObject()
+{
+ return SimpleNumber::is(this) ? 0 : downcast()->getObject();
+}
+
+inline const ObjectImp *ValueImp::getObject() const
+{
+ return SimpleNumber::is(this) ? 0 : downcast()->getObject();
+}
+
+inline bool ValueImp::getUInt32(uint32_t& v) const
+{
+ if (SimpleNumber::is(this)) {
+ long i = SimpleNumber::value(this);
+ if (i < 0)
+ return false;
+ v = i;
+ return true;
+ }
+ return downcast()->getUInt32(v);
+}
+
+inline void ValueImp::mark()
+{
+ if (!SimpleNumber::is(this))
+ downcast()->mark();
+}
inline bool ValueImp::marked() const
{
- // Simple numbers are always considered marked.
- return SimpleNumber::is(this) || _marked;
+ return SimpleNumber::is(this) || downcast()->marked();
}
-// Dispatchers for virtual functions, to special-case simple numbers which
-// won't be real pointers.
-
-inline Type ValueImp::dispatchType() const
+inline Type ValueImp::type() const
{
- if (SimpleNumber::is(this))
- return NumberType;
- return type();
+ return SimpleNumber::is(this) ? NumberType : downcast()->type();
}
-inline Value ValueImp::dispatchToPrimitive(ExecState *exec, Type preferredType) const
+inline ValueImp *ValueImp::toPrimitive(ExecState *exec, Type preferredType) const
{
- if (SimpleNumber::is(this))
- return Value(const_cast<ValueImp *>(this));
- return toPrimitive(exec, preferredType);
+ return SimpleNumber::is(this) ? const_cast<ValueImp *>(this) : downcast()->toPrimitive(exec, preferredType);
}
-inline bool ValueImp::dispatchToBoolean(ExecState *exec) const
+inline bool ValueImp::toBoolean(ExecState *exec) const
{
- if (SimpleNumber::is(this))
- return SimpleNumber::value(this);
- return toBoolean(exec);
+ return SimpleNumber::is(this) ? SimpleNumber::value(this) : downcast()->toBoolean(exec);
}
-inline double ValueImp::dispatchToNumber(ExecState *exec) const
+inline double ValueImp::toNumber(ExecState *exec) const
{
- if (SimpleNumber::is(this))
- return SimpleNumber::value(this);
- return toNumber(exec);
+ return SimpleNumber::is(this) ? SimpleNumber::value(this) : downcast()->toNumber(exec);
}
-inline double ValueImp::dispatchToNumber(ExecState *exec, bool &knownToBeInteger) const
+inline double ValueImp::toNumber(ExecState *exec, bool& knownToBeInteger) const
{
if (SimpleNumber::is(this)) {
knownToBeInteger = true;
return SimpleNumber::value(this);
}
knownToBeInteger = false;
- return toNumber(exec);
+ return downcast()->toNumber(exec);
}
-inline UString ValueImp::dispatchToString(ExecState *exec) const
+inline UString ValueImp::toString(ExecState *exec) const
{
- if (SimpleNumber::is(this))
- return UString::from(SimpleNumber::value(this));
- return toString(exec);
+ return SimpleNumber::is(this) ? UString::from(SimpleNumber::value(this)) : downcast()->toString(exec);
}
-inline bool ValueImp::dispatchToUInt32(uint32_t& result) const
+inline ValueImp *jsZero()
{
- if (SimpleNumber::is(this)) {
- long i = SimpleNumber::value(this);
- if (i < 0)
- return false;
- result = i;
- return true;
- }
- return toUInt32(result);
+ return SimpleNumber::make(0);
}
+inline ValueImp *jsOne()
+{
+ return SimpleNumber::make(1);
+}
+
+inline ValueImp *jsTwo()
+{
+ return SimpleNumber::make(2);
+}
+
+// compatibility names so we don't have to change so much code
+
+inline AllocatedValueImp *Undefined() { return jsUndefined(); }
+inline AllocatedValueImp *Null() { return jsNull(); }
+inline AllocatedValueImp *Boolean(bool b) { return jsBoolean(b); }
+inline ValueImp *Number(double n) { return jsNumber(n); }
+inline ValueImp *Number(int n) { return jsNumber(n); }
+inline ValueImp *Number(unsigned n) { return jsNumber(n); }
+inline ValueImp *Number(long n) { return jsNumber(n); }
+inline ValueImp *Number(unsigned long n) { return jsNumber(n); }
+inline AllocatedValueImp *String(const UString& s) { return jsString(s); }
+inline AllocatedValueImp *String(const char *s) { return jsString(s); }
+
} // namespace
-#endif // _KJS_VALUE_H_
+#endif // KJS_VALUE_H