Changeset 10084 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Aug 7, 2005, 9:07:46 PM (20 years ago)
Author:
darin
Message:

JavaScriptCore:

Rubber stamped by Maciej.

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.

  • 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:]):
Location:
trunk/JavaScriptCore
Files:
90 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r10076 r10084  
     12005-08-07  Darin Adler  <[email protected]>
     2
     3        Rubber stamped by Maciej.
     4
     5        - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4313
     6          eliminate KJS::Value and KJS::Object smart pointer wrappers (for simplicity and speed)
     7
     8        * JavaScriptCore.xcodeproj/project.pbxproj: Removed object_wrapper.h.
     9
     10        Global replaces and other wonderful stuff.
     11
     12        * bindings/NP_jsobject.cpp:
     13        (_NPN_Invoke):
     14        (_NPN_Evaluate):
     15        (_NPN_GetProperty):
     16        (_NPN_SetProperty):
     17        (_NPN_HasMethod):
     18        (_NPN_SetException):
     19        * bindings/c/c_instance.cpp:
     20        (KJS::Bindings::CInstance::CInstance):
     21        (KJS::Bindings::CInstance::invokeMethod):
     22        (KJS::Bindings::CInstance::invokeDefaultMethod):
     23        (KJS::Bindings::CInstance::defaultValue):
     24        (KJS::Bindings::CInstance::stringValue):
     25        (KJS::Bindings::CInstance::numberValue):
     26        (KJS::Bindings::CInstance::booleanValue):
     27        (KJS::Bindings::CInstance::valueOf):
     28        * bindings/c/c_instance.h:
     29        * bindings/c/c_runtime.cpp:
     30        (CField::valueFromInstance):
     31        (CField::setValueToInstance):
     32        * bindings/c/c_runtime.h:
     33        * bindings/c/c_utility.cpp:
     34        (convertNPStringToUTF16):
     35        (convertUTF8ToUTF16):
     36        (coerceValueToNPVariantStringType):
     37        (convertValueToNPVariant):
     38        (convertNPVariantToValue):
     39        * bindings/c/c_utility.h:
     40        * bindings/jni/jni_instance.cpp:
     41        (JavaInstance::stringValue):
     42        (JavaInstance::numberValue):
     43        (JavaInstance::booleanValue):
     44        (JavaInstance::invokeMethod):
     45        (JavaInstance::invokeDefaultMethod):
     46        (JavaInstance::defaultValue):
     47        (JavaInstance::valueOf):
     48        * bindings/jni/jni_instance.h:
     49        * bindings/jni/jni_jsobject.cpp:
     50        (JSObject::invoke):
     51        (JSObject::call):
     52        (JSObject::eval):
     53        (JSObject::getMember):
     54        (JSObject::getSlot):
     55        (JSObject::toString):
     56        (JSObject::convertValueToJObject):
     57        (JSObject::convertJObjectToValue):
     58        (JSObject::listFromJArray):
     59        * bindings/jni/jni_jsobject.h:
     60        * bindings/jni/jni_objc.mm:
     61        (KJS::Bindings::dispatchJNICall):
     62        * bindings/jni/jni_runtime.cpp:
     63        (JavaArray::convertJObjectToArray):
     64        (JavaField::dispatchValueFromInstance):
     65        (JavaField::valueFromInstance):
     66        (JavaField::dispatchSetValueToInstance):
     67        (JavaField::setValueToInstance):
     68        (JavaArray::setValueAt):
     69        (JavaArray::valueAt):
     70        * bindings/jni/jni_runtime.h:
     71        (KJS::Bindings::JavaString::ustring):
     72        * bindings/jni/jni_utility.cpp:
     73        (KJS::Bindings::getJavaVM):
     74        (KJS::Bindings::getJNIEnv):
     75        (KJS::Bindings::getMethodID):
     76        (KJS::Bindings::callJNIVoidMethod):
     77        (KJS::Bindings::callJNIObjectMethod):
     78        (KJS::Bindings::callJNIBooleanMethod):
     79        (KJS::Bindings::callJNIStaticBooleanMethod):
     80        (KJS::Bindings::callJNIByteMethod):
     81        (KJS::Bindings::callJNICharMethod):
     82        (KJS::Bindings::callJNIShortMethod):
     83        (KJS::Bindings::callJNIIntMethod):
     84        (KJS::Bindings::callJNILongMethod):
     85        (KJS::Bindings::callJNIFloatMethod):
     86        (KJS::Bindings::callJNIDoubleMethod):
     87        (KJS::Bindings::callJNIVoidMethodA):
     88        (KJS::Bindings::callJNIObjectMethodA):
     89        (KJS::Bindings::callJNIByteMethodA):
     90        (KJS::Bindings::callJNICharMethodA):
     91        (KJS::Bindings::callJNIShortMethodA):
     92        (KJS::Bindings::callJNIIntMethodA):
     93        (KJS::Bindings::callJNILongMethodA):
     94        (KJS::Bindings::callJNIFloatMethodA):
     95        (KJS::Bindings::callJNIDoubleMethodA):
     96        (KJS::Bindings::callJNIBooleanMethodA):
     97        (KJS::Bindings::callJNIVoidMethodIDA):
     98        (KJS::Bindings::callJNIObjectMethodIDA):
     99        (KJS::Bindings::callJNIByteMethodIDA):
     100        (KJS::Bindings::callJNICharMethodIDA):
     101        (KJS::Bindings::callJNIShortMethodIDA):
     102        (KJS::Bindings::callJNIIntMethodIDA):
     103        (KJS::Bindings::callJNILongMethodIDA):
     104        (KJS::Bindings::callJNIFloatMethodIDA):
     105        (KJS::Bindings::callJNIDoubleMethodIDA):
     106        (KJS::Bindings::callJNIBooleanMethodIDA):
     107        (KJS::Bindings::getCharactersFromJString):
     108        (KJS::Bindings::releaseCharactersForJString):
     109        (KJS::Bindings::getCharactersFromJStringInEnv):
     110        (KJS::Bindings::releaseCharactersForJStringInEnv):
     111        (KJS::Bindings::getUCharactersFromJStringInEnv):
     112        (KJS::Bindings::releaseUCharactersForJStringInEnv):
     113        (KJS::Bindings::JNITypeFromClassName):
     114        (KJS::Bindings::signatureFromPrimitiveType):
     115        (KJS::Bindings::JNITypeFromPrimitiveType):
     116        (KJS::Bindings::getJNIField):
     117        (KJS::Bindings::convertValueToJValue):
     118        * bindings/jni/jni_utility.h:
     119        * bindings/objc/WebScriptObject.mm:
     120        (_didExecute):
     121        (-[WebScriptObject _initializeWithObjectImp:originExecutionContext:Bindings::executionContext:Bindings::]):
     122        (-[WebScriptObject _initWithObjectImp:originExecutionContext:Bindings::executionContext:Bindings::]):
     123        (-[WebScriptObject _imp]):
     124        (-[WebScriptObject _executionContext]):
     125        (-[WebScriptObject _setExecutionContext:]):
     126        (-[WebScriptObject _originExecutionContext]):
     127        (-[WebScriptObject _setOriginExecutionContext:]):
     128        (+[WebScriptObject throwException:]):
     129        (listFromNSArray):
     130        (-[WebScriptObject callWebScriptMethod:withArguments:]):
     131        (-[WebScriptObject evaluateWebScript:]):
     132        (-[WebScriptObject setValue:forKey:]):
     133        (-[WebScriptObject valueForKey:]):
     134        (-[WebScriptObject removeWebScriptKey:]):
     135        (-[WebScriptObject stringRepresentation]):
     136        (-[WebScriptObject webScriptValueAtIndex:]):
     137        (-[WebScriptObject setException:]):
     138        (+[WebScriptObject _convertValueToObjcValue:originExecutionContext:executionContext:Bindings::]):
     139        * bindings/objc/WebScriptObjectPrivate.h:
     140        * bindings/objc/objc_class.h:
     141        * bindings/objc/objc_class.mm:
     142        (KJS::Bindings::ObjcClass::fallbackObject):
     143        * bindings/objc/objc_instance.h:
     144        * bindings/objc/objc_instance.mm:
     145        (ObjcInstance::invokeMethod):
     146        (ObjcInstance::invokeDefaultMethod):
     147        (ObjcInstance::setValueOfField):
     148        (ObjcInstance::setValueOfUndefinedField):
     149        (ObjcInstance::getValueOfField):
     150        (ObjcInstance::getValueOfUndefinedField):
     151        (ObjcInstance::defaultValue):
     152        (ObjcInstance::stringValue):
     153        (ObjcInstance::numberValue):
     154        (ObjcInstance::booleanValue):
     155        (ObjcInstance::valueOf):
     156        * bindings/objc/objc_runtime.h:
     157        * bindings/objc/objc_runtime.mm:
     158        (ObjcField::valueFromInstance):
     159        (convertValueToObjcObject):
     160        (ObjcField::setValueToInstance):
     161        (ObjcArray::setValueAt):
     162        (ObjcArray::valueAt):
     163        (ObjcFallbackObjectImp::put):
     164        (ObjcFallbackObjectImp::callAsFunction):
     165        (ObjcFallbackObjectImp::defaultValue):
     166        * bindings/objc/objc_utility.h:
     167        * bindings/objc/objc_utility.mm:
     168        (Bindings::JSMethodNameToObjCMethodName):
     169        (Bindings::convertValueToObjcValue):
     170        (Bindings::convertNSStringToString):
     171        (Bindings::convertObjcValueToValue):
     172        (Bindings::objcValueTypeForType):
     173        (Bindings::createObjcInstanceForValue):
     174        * bindings/runtime.cpp:
     175        (Instance::getValueOfField):
     176        (Instance::setValueOfField):
     177        (Instance::createRuntimeObject):
     178        (Instance::createLanguageInstanceForValue):
     179        * bindings/runtime.h:
     180        (KJS::Bindings::Constructor::~Constructor):
     181        (KJS::Bindings::Field::~Field):
     182        (KJS::Bindings::MethodList::MethodList):
     183        (KJS::Bindings::Class::fallbackObject):
     184        (KJS::Bindings::Class::~Class):
     185        (KJS::Bindings::Instance::Instance):
     186        (KJS::Bindings::Instance::getValueOfUndefinedField):
     187        (KJS::Bindings::Instance::supportsSetValueOfUndefinedField):
     188        (KJS::Bindings::Instance::setValueOfUndefinedField):
     189        (KJS::Bindings::Instance::valueOf):
     190        (KJS::Bindings::Instance::setExecutionContext):
     191        (KJS::Bindings::Instance::~Instance):
     192        (KJS::Bindings::Array::~Array):
     193        * bindings/runtime_array.cpp:
     194        (RuntimeArrayImp::RuntimeArrayImp):
     195        (RuntimeArrayImp::lengthGetter):
     196        (RuntimeArrayImp::indexGetter):
     197        (RuntimeArrayImp::put):
     198        * bindings/runtime_array.h:
     199        * bindings/runtime_method.cpp:
     200        (RuntimeMethodImp::lengthGetter):
     201        (RuntimeMethodImp::callAsFunction):
     202        * bindings/runtime_method.h:
     203        * bindings/runtime_object.cpp:
     204        (RuntimeObjectImp::fallbackObjectGetter):
     205        (RuntimeObjectImp::fieldGetter):
     206        (RuntimeObjectImp::methodGetter):
     207        (RuntimeObjectImp::getOwnPropertySlot):
     208        (RuntimeObjectImp::put):
     209        (RuntimeObjectImp::defaultValue):
     210        (RuntimeObjectImp::callAsFunction):
     211        * bindings/runtime_object.h:
     212        * kjs/array_instance.h:
     213        * kjs/array_object.cpp:
     214        (ArrayInstanceImp::ArrayInstanceImp):
     215        (ArrayInstanceImp::lengthGetter):
     216        (ArrayInstanceImp::getOwnPropertySlot):
     217        (ArrayInstanceImp::put):
     218        (ArrayInstanceImp::propList):
     219        (ArrayInstanceImp::setLength):
     220        (compareByStringForQSort):
     221        (compareWithCompareFunctionForQSort):
     222        (ArrayInstanceImp::sort):
     223        (ArrayInstanceImp::pushUndefinedObjectsToEnd):
     224        (ArrayPrototypeImp::ArrayPrototypeImp):
     225        (ArrayProtoFuncImp::ArrayProtoFuncImp):
     226        (ArrayProtoFuncImp::callAsFunction):
     227        (ArrayObjectImp::ArrayObjectImp):
     228        (ArrayObjectImp::construct):
     229        (ArrayObjectImp::callAsFunction):
     230        * kjs/array_object.h:
     231        * kjs/bool_object.cpp:
     232        (BooleanPrototypeImp::BooleanPrototypeImp):
     233        (BooleanProtoFuncImp::BooleanProtoFuncImp):
     234        (BooleanProtoFuncImp::callAsFunction):
     235        (BooleanObjectImp::BooleanObjectImp):
     236        (BooleanObjectImp::construct):
     237        (BooleanObjectImp::callAsFunction):
     238        * kjs/bool_object.h:
     239        * kjs/collector.cpp:
     240        (KJS::Collector::markStackObjectsConservatively):
     241        (KJS::Collector::collect):
     242        (KJS::className):
     243        * kjs/completion.h:
     244        (KJS::Completion::Completion):
     245        (KJS::Completion::value):
     246        (KJS::Completion::isValueCompletion):
     247        * kjs/context.h:
     248        (KJS::ContextImp::variableObject):
     249        (KJS::ContextImp::setVariableObject):
     250        (KJS::ContextImp::thisValue):
     251        (KJS::ContextImp::activationObject):
     252        (KJS::ContextImp::pushScope):
     253        * kjs/date_object.cpp:
     254        (formatLocaleDate):
     255        (KJS::timeFromArgs):
     256        (KJS::DatePrototypeImp::DatePrototypeImp):
     257        (KJS::DateProtoFuncImp::DateProtoFuncImp):
     258        (KJS::DateProtoFuncImp::callAsFunction):
     259        (KJS::DateObjectImp::DateObjectImp):
     260        (KJS::DateObjectImp::construct):
     261        (KJS::DateObjectImp::callAsFunction):
     262        (KJS::DateObjectFuncImp::DateObjectFuncImp):
     263        (KJS::DateObjectFuncImp::callAsFunction):
     264        (KJS::parseDate):
     265        (KJS::KRFCDate_parseDate):
     266        (KJS::timeClip):
     267        * kjs/date_object.h:
     268        * kjs/debugger.cpp:
     269        (Debugger::exception):
     270        (Debugger::callEvent):
     271        (Debugger::returnEvent):
     272        * kjs/debugger.h:
     273        * kjs/error_object.cpp:
     274        (ErrorPrototypeImp::ErrorPrototypeImp):
     275        (ErrorProtoFuncImp::ErrorProtoFuncImp):
     276        (ErrorProtoFuncImp::callAsFunction):
     277        (ErrorObjectImp::ErrorObjectImp):
     278        (ErrorObjectImp::construct):
     279        (ErrorObjectImp::callAsFunction):
     280        (NativeErrorPrototypeImp::NativeErrorPrototypeImp):
     281        (NativeErrorImp::NativeErrorImp):
     282        (NativeErrorImp::construct):
     283        (NativeErrorImp::callAsFunction):
     284        * kjs/error_object.h:
     285        * kjs/function.cpp:
     286        (KJS::FunctionImp::FunctionImp):
     287        (KJS::FunctionImp::callAsFunction):
     288        (KJS::FunctionImp::processParameters):
     289        (KJS::FunctionImp::argumentsGetter):
     290        (KJS::FunctionImp::lengthGetter):
     291        (KJS::FunctionImp::put):
     292        (KJS::DeclaredFunctionImp::DeclaredFunctionImp):
     293        (KJS::DeclaredFunctionImp::construct):
     294        (KJS::ArgumentsImp::ArgumentsImp):
     295        (KJS::ArgumentsImp::mappedIndexGetter):
     296        (KJS::ArgumentsImp::put):
     297        (KJS::ActivationImp::argumentsGetter):
     298        (KJS::GlobalFuncImp::GlobalFuncImp):
     299        (KJS::encode):
     300        (KJS::decode):
     301        (KJS::GlobalFuncImp::callAsFunction):
     302        * kjs/function.h:
     303        * kjs/function_object.cpp:
     304        (FunctionPrototypeImp::FunctionPrototypeImp):
     305        (FunctionPrototypeImp::callAsFunction):
     306        (FunctionProtoFuncImp::FunctionProtoFuncImp):
     307        (FunctionProtoFuncImp::callAsFunction):
     308        (FunctionObjectImp::FunctionObjectImp):
     309        (FunctionObjectImp::construct):
     310        (FunctionObjectImp::callAsFunction):
     311        * kjs/function_object.h:
     312        * kjs/internal.cpp:
     313        (KJS::UndefinedImp::toPrimitive):
     314        (KJS::UndefinedImp::toObject):
     315        (KJS::NullImp::toPrimitive):
     316        (KJS::NullImp::toObject):
     317        (KJS::BooleanImp::toPrimitive):
     318        (KJS::BooleanImp::toObject):
     319        (KJS::StringImp::toPrimitive):
     320        (KJS::StringImp::toObject):
     321        (KJS::NumberImp::toPrimitive):
     322        (KJS::NumberImp::toObject):
     323        (KJS::NumberImp::getUInt32):
     324        (KJS::LabelStack::push):
     325        (KJS::ContextImp::ContextImp):
     326        (KJS::InterpreterImp::globalInit):
     327        (KJS::InterpreterImp::globalClear):
     328        (KJS::InterpreterImp::InterpreterImp):
     329        (KJS::InterpreterImp::initGlobalObject):
     330        (KJS::InterpreterImp::clear):
     331        (KJS::InterpreterImp::mark):
     332        (KJS::InterpreterImp::evaluate):
     333        (KJS::InternalFunctionImp::hasInstance):
     334        (KJS::roundValue):
     335        (KJS::printInfo):
     336        * kjs/internal.h:
     337        (KJS::InterpreterImp::builtinObject):
     338        (KJS::InterpreterImp::builtinFunction):
     339        (KJS::InterpreterImp::builtinArray):
     340        (KJS::InterpreterImp::builtinBoolean):
     341        (KJS::InterpreterImp::builtinString):
     342        (KJS::InterpreterImp::builtinNumber):
     343        (KJS::InterpreterImp::builtinDate):
     344        (KJS::InterpreterImp::builtinRegExp):
     345        (KJS::InterpreterImp::builtinError):
     346        (KJS::InterpreterImp::builtinObjectPrototype):
     347        (KJS::InterpreterImp::builtinFunctionPrototype):
     348        (KJS::InterpreterImp::builtinArrayPrototype):
     349        (KJS::InterpreterImp::builtinBooleanPrototype):
     350        (KJS::InterpreterImp::builtinStringPrototype):
     351        (KJS::InterpreterImp::builtinNumberPrototype):
     352        (KJS::InterpreterImp::builtinDatePrototype):
     353        (KJS::InterpreterImp::builtinRegExpPrototype):
     354        (KJS::InterpreterImp::builtinErrorPrototype):
     355        (KJS::InterpreterImp::builtinEvalError):
     356        (KJS::InterpreterImp::builtinRangeError):
     357        (KJS::InterpreterImp::builtinReferenceError):
     358        (KJS::InterpreterImp::builtinSyntaxError):
     359        (KJS::InterpreterImp::builtinTypeError):
     360        (KJS::InterpreterImp::builtinURIError):
     361        (KJS::InterpreterImp::builtinEvalErrorPrototype):
     362        (KJS::InterpreterImp::builtinRangeErrorPrototype):
     363        (KJS::InterpreterImp::builtinReferenceErrorPrototype):
     364        (KJS::InterpreterImp::builtinSyntaxErrorPrototype):
     365        (KJS::InterpreterImp::builtinTypeErrorPrototype):
     366        (KJS::InterpreterImp::builtinURIErrorPrototype):
     367        * kjs/interpreter.cpp:
     368        (Context::variableObject):
     369        (Context::thisValue):
     370        (Interpreter::Interpreter):
     371        (Interpreter::globalObject):
     372        (Interpreter::evaluate):
     373        (Interpreter::builtinObject):
     374        (Interpreter::builtinFunction):
     375        (Interpreter::builtinArray):
     376        (Interpreter::builtinBoolean):
     377        (Interpreter::builtinString):
     378        (Interpreter::builtinNumber):
     379        (Interpreter::builtinDate):
     380        (Interpreter::builtinRegExp):
     381        (Interpreter::builtinError):
     382        (Interpreter::builtinObjectPrototype):
     383        (Interpreter::builtinFunctionPrototype):
     384        (Interpreter::builtinArrayPrototype):
     385        (Interpreter::builtinBooleanPrototype):
     386        (Interpreter::builtinStringPrototype):
     387        (Interpreter::builtinNumberPrototype):
     388        (Interpreter::builtinDatePrototype):
     389        (Interpreter::builtinRegExpPrototype):
     390        (Interpreter::builtinErrorPrototype):
     391        (Interpreter::builtinEvalError):
     392        (Interpreter::builtinRangeError):
     393        (Interpreter::builtinReferenceError):
     394        (Interpreter::builtinSyntaxError):
     395        (Interpreter::builtinTypeError):
     396        (Interpreter::builtinURIError):
     397        (Interpreter::builtinEvalErrorPrototype):
     398        (Interpreter::builtinRangeErrorPrototype):
     399        (Interpreter::builtinReferenceErrorPrototype):
     400        (Interpreter::builtinSyntaxErrorPrototype):
     401        (Interpreter::builtinTypeErrorPrototype):
     402        (Interpreter::builtinURIErrorPrototype):
     403        (Interpreter::createLanguageInstanceForValue):
     404        * kjs/interpreter.h:
     405        (KJS::Interpreter::isGlobalObject):
     406        (KJS::ExecState::setException):
     407        (KJS::ExecState::clearException):
     408        (KJS::ExecState::exception):
     409        (KJS::ExecState::hadException):
     410        (KJS::ExecState::ExecState):
     411        * kjs/list.cpp:
     412        (KJS::List::at):
     413        * kjs/list.h:
     414        (KJS::List::operator[]):
     415        (KJS::ListIterator::operator->):
     416        (KJS::ListIterator::operator*):
     417        (KJS::ListIterator::operator++):
     418        (KJS::ListIterator::operator--):
     419        * kjs/lookup.h:
     420        (KJS::staticFunctionGetter):
     421        (KJS::staticValueGetter):
     422        (KJS::lookupPut):
     423        (KJS::cacheGlobalObject):
     424        * kjs/math_object.cpp:
     425        (MathObjectImp::getValueProperty):
     426        (MathFuncImp::MathFuncImp):
     427        (MathFuncImp::callAsFunction):
     428        * kjs/math_object.h:
     429        * kjs/nodes.cpp:
     430        (Node::evaluateReference):
     431        (Node::throwError):
     432        (Node::setExceptionDetailsIfNeeded):
     433        (NullNode::evaluate):
     434        (BooleanNode::evaluate):
     435        (NumberNode::evaluate):
     436        (StringNode::evaluate):
     437        (RegExpNode::evaluate):
     438        (ThisNode::evaluate):
     439        (ResolveNode::evaluate):
     440        (ResolveNode::evaluateReference):
     441        (GroupNode::evaluate):
     442        (ElementNode::evaluate):
     443        (ArrayNode::evaluate):
     444        (ObjectLiteralNode::evaluate):
     445        (PropertyValueNode::evaluate):
     446        (PropertyNode::evaluate):
     447        (AccessorNode1::evaluate):
     448        (AccessorNode1::evaluateReference):
     449        (AccessorNode2::evaluate):
     450        (AccessorNode2::evaluateReference):
     451        (ArgumentListNode::evaluate):
     452        (ArgumentListNode::evaluateList):
     453        (ArgumentsNode::evaluate):
     454        (NewExprNode::evaluate):
     455        (FunctionCallNode::evaluate):
     456        (PostfixNode::evaluate):
     457        (DeleteNode::evaluate):
     458        (VoidNode::evaluate):
     459        (TypeOfNode::evaluate):
     460        (PrefixNode::evaluate):
     461        (UnaryPlusNode::evaluate):
     462        (NegateNode::evaluate):
     463        (BitwiseNotNode::evaluate):
     464        (LogicalNotNode::evaluate):
     465        (MultNode::evaluate):
     466        (AddNode::evaluate):
     467        (ShiftNode::evaluate):
     468        (RelationalNode::evaluate):
     469        (EqualNode::evaluate):
     470        (BitOperNode::evaluate):
     471        (BinaryLogicalNode::evaluate):
     472        (ConditionalNode::evaluate):
     473        (AssignNode::evaluate):
     474        (CommaNode::evaluate):
     475        (StatListNode::execute):
     476        (AssignExprNode::evaluate):
     477        (VarDeclNode::evaluate):
     478        (VarDeclNode::processVarDecls):
     479        (VarDeclListNode::evaluate):
     480        (ExprStatementNode::execute):
     481        (IfNode::execute):
     482        (DoWhileNode::execute):
     483        (WhileNode::execute):
     484        (ForNode::execute):
     485        (ForInNode::execute):
     486        (ContinueNode::execute):
     487        (BreakNode::execute):
     488        (ReturnNode::execute):
     489        (WithNode::execute):
     490        (CaseClauseNode::evaluate):
     491        (ClauseListNode::evaluate):
     492        (CaseBlockNode::evaluate):
     493        (CaseBlockNode::evalBlock):
     494        (SwitchNode::execute):
     495        (ThrowNode::execute):
     496        (CatchNode::execute):
     497        (TryNode::execute):
     498        (ParameterNode::evaluate):
     499        (FuncDeclNode::processFuncDecl):
     500        (FuncExprNode::evaluate):
     501        (SourceElementsNode::execute):
     502        * kjs/nodes.h:
     503        (KJS::StatementNode::evaluate):
     504        * kjs/number_object.cpp:
     505        (NumberPrototypeImp::NumberPrototypeImp):
     506        (NumberProtoFuncImp::NumberProtoFuncImp):
     507        (NumberProtoFuncImp::callAsFunction):
     508        (NumberObjectImp::NumberObjectImp):
     509        (NumberObjectImp::getValueProperty):
     510        (NumberObjectImp::construct):
     511        (NumberObjectImp::callAsFunction):
     512        * kjs/number_object.h:
     513        * kjs/object.cpp:
     514        (KJS::ObjectImp::call):
     515        (KJS::ObjectImp::mark):
     516        (KJS::ObjectImp::classInfo):
     517        (KJS::ObjectImp::get):
     518        (KJS::ObjectImp::getProperty):
     519        (KJS::ObjectImp::getPropertySlot):
     520        (KJS::ObjectImp::put):
     521        (KJS::ObjectImp::hasOwnProperty):
     522        (KJS::ObjectImp::defaultValue):
     523        (KJS::ObjectImp::findPropertyHashEntry):
     524        (KJS::ObjectImp::construct):
     525        (KJS::ObjectImp::callAsFunction):
     526        (KJS::ObjectImp::hasInstance):
     527        (KJS::ObjectImp::propList):
     528        (KJS::ObjectImp::toPrimitive):
     529        (KJS::ObjectImp::toNumber):
     530        (KJS::ObjectImp::toString):
     531        (KJS::ObjectImp::toObject):
     532        (KJS::ObjectImp::putDirect):
     533        (KJS::Error::create):
     534        (KJS::error):
     535        * kjs/object.h:
     536        (KJS::):
     537        (KJS::ObjectImp::getPropertySlot):
     538        (KJS::AllocatedValueImp::isObject):
     539        (KJS::ObjectImp::ObjectImp):
     540        (KJS::ObjectImp::internalValue):
     541        (KJS::ObjectImp::setInternalValue):
     542        (KJS::ObjectImp::prototype):
     543        (KJS::ObjectImp::setPrototype):
     544        (KJS::ObjectImp::inherits):
     545        * kjs/object_object.cpp:
     546        (ObjectPrototypeImp::ObjectPrototypeImp):
     547        (ObjectProtoFuncImp::ObjectProtoFuncImp):
     548        (ObjectProtoFuncImp::callAsFunction):
     549        (ObjectObjectImp::ObjectObjectImp):
     550        (ObjectObjectImp::construct):
     551        (ObjectObjectImp::callAsFunction):
     552        * kjs/object_object.h:
     553        * kjs/operations.cpp:
     554        (KJS::equal):
     555        (KJS::strictEqual):
     556        (KJS::relation):
     557        (KJS::add):
     558        (KJS::mult):
     559        * kjs/operations.h:
     560        * kjs/property_map.cpp:
     561        (KJS::PropertyMap::mark):
     562        (KJS::PropertyMap::addEnumerablesToReferenceList):
     563        (KJS::PropertyMap::addSparseArrayPropertiesToReferenceList):
     564        (KJS::PropertyMap::save):
     565        (KJS::PropertyMap::restore):
     566        * kjs/property_map.h:
     567        * kjs/property_slot.cpp:
     568        (KJS::PropertySlot::undefinedGetter):
     569        * kjs/property_slot.h:
     570        (KJS::PropertySlot::getValue):
     571        * kjs/protect.h:
     572        (KJS::gcUnprotectNullTolerant):
     573        (KJS::ProtectedValue::ProtectedValue):
     574        (KJS::ProtectedValue::~ProtectedValue):
     575        (KJS::ProtectedValue::operator=):
     576        (KJS::ProtectedValue::operator ValueImp *):
     577        (KJS::ProtectedValue::operator->):
     578        * kjs/protected_object.h:
     579        (KJS::ProtectedObject::ProtectedObject):
     580        (KJS::ProtectedObject::operator=):
     581        (KJS::ProtectedObject::operator ValueImp *):
     582        (KJS::ProtectedObject::operator ObjectImp *):
     583        (KJS::ProtectedObject::operator->):
     584        (KJS::ProtectedReference::ProtectedReference):
     585        (KJS::ProtectedReference::~ProtectedReference):
     586        (KJS::ProtectedReference::operator=):
     587        * kjs/protected_values.cpp:
     588        (KJS::ProtectedValues::getProtectCount):
     589        (KJS::ProtectedValues::increaseProtectCount):
     590        (KJS::ProtectedValues::insert):
     591        (KJS::ProtectedValues::decreaseProtectCount):
     592        * kjs/protected_values.h:
     593        * kjs/reference.cpp:
     594        (KJS::Reference::Reference):
     595        (KJS::Reference::makeValueReference):
     596        (KJS::Reference::getBase):
     597        (KJS::Reference::getValue):
     598        (KJS::Reference::putValue):
     599        (KJS::Reference::deleteValue):
     600        * kjs/reference.h:
     601        (KJS::Reference::baseIfMutable):
     602        * kjs/regexp_object.cpp:
     603        (RegExpPrototypeImp::RegExpPrototypeImp):
     604        (RegExpProtoFuncImp::RegExpProtoFuncImp):
     605        (RegExpProtoFuncImp::callAsFunction):
     606        (RegExpObjectImp::RegExpObjectImp):
     607        (RegExpObjectImp::arrayOfMatches):
     608        (RegExpObjectImp::backrefGetter):
     609        (RegExpObjectImp::construct):
     610        (RegExpObjectImp::callAsFunction):
     611        * kjs/regexp_object.h:
     612        * kjs/string_object.cpp:
     613        (StringInstanceImp::lengthGetter):
     614        (StringInstanceImp::indexGetter):
     615        (StringInstanceImp::getOwnPropertySlot):
     616        (StringInstanceImp::put):
     617        (StringPrototypeImp::StringPrototypeImp):
     618        (StringProtoFuncImp::StringProtoFuncImp):
     619        (regExpIsGlobal):
     620        (replace):
     621        (StringProtoFuncImp::callAsFunction):
     622        (StringObjectImp::StringObjectImp):
     623        (StringObjectImp::construct):
     624        (StringObjectImp::callAsFunction):
     625        (StringObjectFuncImp::StringObjectFuncImp):
     626        (StringObjectFuncImp::callAsFunction):
     627        * kjs/string_object.h:
     628        * kjs/testkjs.cpp:
     629        (TestFunctionImp::callAsFunction):
     630        (VersionFunctionImp::callAsFunction):
     631        (main):
     632        * kjs/value.cpp:
     633        (KJS::AllocatedValueImp::operator new):
     634        (KJS::AllocatedValueImp::getUInt32):
     635        (KJS::ValueImp::toInteger):
     636        (KJS::ValueImp::toInt32):
     637        (KJS::ValueImp::toUInt32):
     638        (KJS::ValueImp::toUInt16):
     639        (KJS::ValueImp::toObject):
     640        (KJS::AllocatedValueImp::getBoolean):
     641        (KJS::AllocatedValueImp::getNumber):
     642        (KJS::AllocatedValueImp::getString):
     643        (KJS::AllocatedValueImp::getObject):
     644        (KJS::jsString):
     645        (KJS::jsNumber):
     646        (KJS::ConstantValues::init):
     647        (KJS::ConstantValues::clear):
     648        (KJS::ConstantValues::mark):
     649        * kjs/value.h:
     650        (KJS::):
     651        (KJS::jsUndefined):
     652        (KJS::jsNull):
     653        (KJS::jsBoolean):
     654        (KJS::jsNaN):
     655        (KJS::ValueImp::ValueImp):
     656        (KJS::ValueImp::~ValueImp):
     657        (KJS::AllocatedValueImp::AllocatedValueImp):
     658        (KJS::AllocatedValueImp::~AllocatedValueImp):
     659        (KJS::AllocatedValueImp::isBoolean):
     660        (KJS::AllocatedValueImp::isNumber):
     661        (KJS::AllocatedValueImp::isString):
     662        (KJS::AllocatedValueImp::isObject):
     663        (KJS::AllocatedValueImp::marked):
     664        (KJS::AllocatedValueImp::mark):
     665        (KJS::ValueImp::downcast):
     666        (KJS::ValueImp::isUndefined):
     667        (KJS::ValueImp::isNull):
     668        (KJS::ValueImp::isUndefinedOrNull):
     669        (KJS::ValueImp::isBoolean):
     670        (KJS::ValueImp::isNumber):
     671        (KJS::ValueImp::isString):
     672        (KJS::ValueImp::isObject):
     673        (KJS::ValueImp::getBoolean):
     674        (KJS::ValueImp::getNumber):
     675        (KJS::ValueImp::getString):
     676        (KJS::ValueImp::getObject):
     677        (KJS::ValueImp::getUInt32):
     678        (KJS::ValueImp::mark):
     679        (KJS::ValueImp::marked):
     680        (KJS::ValueImp::type):
     681        (KJS::ValueImp::toPrimitive):
     682        (KJS::ValueImp::toBoolean):
     683        (KJS::ValueImp::toNumber):
     684        (KJS::ValueImp::toString):
     685        (KJS::jsZero):
     686        (KJS::jsOne):
     687        (KJS::jsTwo):
     688        (KJS::Undefined):
     689        (KJS::Null):
     690        (KJS::Boolean):
     691        (KJS::Number):
     692        (KJS::String):
     693
    16942005-08-06  Maciej Stachowiak  <[email protected]>
    2695
  • trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r10076 r10084  
    2828                65305EAF08A58DDE00F31E73 /* protected_object.h in Headers */ = {isa = PBXBuildFile; fileRef = 65305EAE08A58DDE00F31E73 /* protected_object.h */; settings = {ATTRIBUTES = (Private, ); }; };
    2929                65305EB008A58E0900F31E73 /* protected_object.h in Headers */ = {isa = PBXBuildFile; fileRef = 65305EAE08A58DDE00F31E73 /* protected_object.h */; settings = {ATTRIBUTES = (Private, ); }; };
    30                 6539AACB08A3225A00223EE2 /* object_wrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 6539AACA08A3225A00223EE2 /* object_wrapper.h */; settings = {ATTRIBUTES = (Private, ); }; };
    3130                65621E6D089E859700760F35 /* property_slot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65621E6B089E859700760F35 /* property_slot.cpp */; };
    3231                65621E6E089E859700760F35 /* property_slot.h in Headers */ = {isa = PBXBuildFile; fileRef = 65621E6C089E859700760F35 /* property_slot.h */; settings = {ATTRIBUTES = (Private, ); }; };
    3332                65621E6F089E85D300760F35 /* property_slot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65621E6B089E859700760F35 /* property_slot.cpp */; };
    3433                65621E70089E85D300760F35 /* property_slot.h in Headers */ = {isa = PBXBuildFile; fileRef = 65621E6C089E859700760F35 /* property_slot.h */; settings = {ATTRIBUTES = (Private, ); }; };
    35                 65BBAEE008A329B300357728 /* object_wrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 6539AACA08A3225A00223EE2 /* object_wrapper.h */; settings = {ATTRIBUTES = (Private, ); }; };
    3634                932F5B400822A1C700736975 /* array_object.h in Headers */ = {isa = PBXBuildFile; fileRef = F692A84E0255597D01FF60F7 /* array_object.h */; settings = {ATTRIBUTES = (Private, ); }; };
    3735                932F5B420822A1C700736975 /* collector.h in Headers */ = {isa = PBXBuildFile; fileRef = F692A8530255597D01FF60F7 /* collector.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    459457                651F6413039D5B5F0078395C /* dtoa.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = dtoa.h; sourceTree = "<group>"; };
    460458                65305EAE08A58DDE00F31E73 /* protected_object.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = protected_object.h; sourceTree = "<group>"; };
    461                 6539AACA08A3225A00223EE2 /* object_wrapper.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = object_wrapper.h; sourceTree = "<group>"; };
    462459                65417205039E02E70058BFEB /* get.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = get.c; path = pcre/get.c; sourceTree = "<group>"; };
    463460                65417206039E02E70058BFEB /* maketables.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = maketables.c; path = pcre/maketables.c; sourceTree = "<group>"; };
     
    646643                        children = (
    647644                                65305EAE08A58DDE00F31E73 /* protected_object.h */,
    648                                 6539AACA08A3225A00223EE2 /* object_wrapper.h */,
    649645                                65621E6B089E859700760F35 /* property_slot.cpp */,
    650646                                65621E6C089E859700760F35 /* property_slot.h */,
     
    919915                                932FC11D0824A6A3005B3C75 /* create_hash_table in Headers */,
    920916                                65621E6E089E859700760F35 /* property_slot.h in Headers */,
    921                                 6539AACB08A3225A00223EE2 /* object_wrapper.h in Headers */,
    922917                        );
    923918                        runOnlyForDeploymentPostprocessing = 0;
     
    943938                                A85D8205087B2822006A9172 /* number_object.h in Headers */,
    944939                                A85D8206087B2822006A9172 /* object_object.h in Headers */,
    945                                 65BBAEE008A329B300357728 /* object_wrapper.h in Headers */,
    946940                                A85D8207087B2822006A9172 /* object.h in Headers */,
    947941                                A85D8208087B2822006A9172 /* operations.h in Headers */,
  • trunk/JavaScriptCore/bindings/NP_jsobject.cpp

    r9061 r10084  
    150150            ExecState *exec = obj->executionContext->interpreter()->globalExec();
    151151            Interpreter::lock();
    152             Value func = obj->imp->get (exec, identiferFromNPIdentifier(i->value.string));
     152            ValueImp *func = obj->imp->get (exec, identiferFromNPIdentifier(i->value.string));
    153153            Interpreter::unlock();
    154154
    155             if (func.isNull()) {
     155            if (func->isNull()) {
    156156                NPN_InitializeVariantAsNull(result);
    157157                return false;
    158158            }
    159             else if ( func.type() == UndefinedType) {
     159            else if (func->isUndefined()) {
    160160                NPN_InitializeVariantAsUndefined(result);
    161161                return false;
     
    163163            else {
    164164                // Call the function object.
    165                 ObjectImp *funcImp = static_cast<ObjectImp*>(func.imp());
    166                 Object thisObj = Object(const_cast<ObjectImp*>(obj->imp));
     165                ObjectImp *funcImp = static_cast<ObjectImp*>(func);
     166                ObjectImp *thisObj = const_cast<ObjectImp*>(obj->imp);
    167167                List argList = listFromVariantArgs(exec, args, argCount);
    168168                Interpreter::lock();
    169                 Value resultV = funcImp->call (exec, thisObj, argList);
     169                ValueImp *resultV = funcImp->call (exec, thisObj, argList);
    170170                Interpreter::unlock();
    171171
     
    194194
    195195        ExecState *exec = obj->executionContext->interpreter()->globalExec();
    196         Object thisObj = Object(const_cast<ObjectImp*>(obj->imp));
    197         Value result;
     196        ValueImp *result;
    198197       
    199198        Interpreter::lock();
     
    206205        if (type == Normal) {
    207206            result = completion.value();
    208             if (result.isNull()) {
     207            if (!result) {
    209208                result = Undefined();
    210209            }
     
    235234
    236235        PrivateIdentifier *i = (PrivateIdentifier *)propertyName;
    237         if (i->isString) {
    238             if (!obj->imp->hasProperty (exec, identiferFromNPIdentifier(i->value.string))) {
    239                 NPN_InitializeVariantAsNull(variant);
    240                 return false;
    241             }
    242         }
    243         else {
    244             if (!obj->imp->hasProperty (exec, i->value.number)) {
    245                 NPN_InitializeVariantAsNull(variant);
    246                 return false;
    247             }
    248         }
    249        
    250         Interpreter::lock();
    251         Value result;
     236       
     237        Interpreter::lock();
     238        ValueImp *result;
    252239        if (i->isString) {
    253240            result = obj->imp->get (exec, identiferFromNPIdentifier(i->value.string));
     
    258245        Interpreter::unlock();
    259246
    260         if (result.isNull()) {
     247        if (result->isNull()) {
    261248            NPN_InitializeVariantAsNull(variant);
    262249            return false;
    263250        }
    264         else if (result.type() == UndefinedType) {
     251        else if (result->isUndefined()) {
    265252            NPN_InitializeVariantAsUndefined(variant);
    266253            return false;
     
    293280        ExecState *exec = obj->executionContext->interpreter()->globalExec();
    294281        Interpreter::lock();
    295         Value result;
    296282        PrivateIdentifier *i = (PrivateIdentifier *)propertyName;
    297283        if (i->isString) {
     
    395381        ExecState *exec = obj->executionContext->interpreter()->globalExec();
    396382        Interpreter::lock();
    397         Value func = obj->imp->get (exec, identiferFromNPIdentifier(i->value.string));
    398         Interpreter::unlock();
    399 
    400         if (func.isNull() || func.type() == UndefinedType) {
     383        ValueImp *func = obj->imp->get (exec, identiferFromNPIdentifier(i->value.string));
     384        Interpreter::unlock();
     385
     386        if (func->isUndefined()) {
    401387            return false;
    402388        }
     
    418404        ExecState *exec = obj->executionContext->interpreter()->globalExec();
    419405        Interpreter::lock();
    420         Object err = Error::create(exec, GeneralError, message);
     406        ObjectImp *err = Error::create(exec, GeneralError, message);
    421407        exec->setException (err);
    422408        Interpreter::unlock();
  • trunk/JavaScriptCore/bindings/c/c_instance.cpp

    r8384 r10084  
    4040#endif
    4141
    42 using namespace KJS::Bindings;
    43 using namespace KJS;
     42namespace KJS {
     43namespace Bindings {
    4444
    4545CInstance::CInstance (NPObject *o)
     
    4848    _class = 0;
    4949    setExecutionContext (0);
    50 };
     50}
    5151
    5252CInstance::~CInstance ()
     
    9595}
    9696
    97 Value CInstance::invokeMethod (KJS::ExecState *exec, const MethodList &methodList, const List &args)
    98 {
    99     Value resultValue;
     97ValueImp *CInstance::invokeMethod (ExecState *exec, const MethodList &methodList, const List &args)
     98{
     99    ValueImp *resultValue;
    100100
    101101    // Overloading methods are not allowed by NPObjects.  Should only be one
     
    147147
    148148
    149 Value CInstance::invokeDefaultMethod (KJS::ExecState *exec, const List &args)
    150 {
    151     Value resultValue;
     149ValueImp *CInstance::invokeDefaultMethod (ExecState *exec, const List &args)
     150{
     151    ValueImp *resultValue;
    152152
    153153    if (_object->_class->invokeDefault) {     
     
    189189
    190190
    191 KJS::Value CInstance::defaultValue (KJS::Type hint) const
    192 {
    193     if (hint == KJS::StringType) {
     191ValueImp *CInstance::defaultValue (Type hint) const
     192{
     193    if (hint == StringType) {
    194194        return stringValue();
    195195    }
    196     else if (hint == KJS::NumberType) {
     196    else if (hint == NumberType) {
    197197        return numberValue();
    198198    }
    199     else if (hint == KJS::BooleanType) {
     199    else if (hint == BooleanType) {
    200200        return booleanValue();
    201201    }
     
    204204}
    205205
    206 KJS::Value CInstance::stringValue() const
     206ValueImp *CInstance::stringValue() const
    207207{
    208208    char buf[1024];
    209     snprintf (buf, 1024, "NPObject %p, NPClass %p", _object, _object->_class);
    210     KJS::String v(buf);
    211     return v;
    212 }
    213 
    214 KJS::Value CInstance::numberValue() const
     209    snprintf(buf, 1024, "NPObject %p, NPClass %p", _object, _object->_class);
     210    return jsString(buf);
     211}
     212
     213ValueImp *CInstance::numberValue() const
    215214{
    216215    // FIXME:  Implement something sensible
    217     KJS::Number v(0);
    218     return v;
    219 }
    220 
    221 KJS::Value CInstance::booleanValue() const
     216    return jsNumber(0);
     217}
     218
     219ValueImp *CInstance::booleanValue() const
    222220{
    223221    // FIXME:  Implement something sensible
    224     KJS::Boolean v((bool)0);
    225     return v;
    226 }
    227 
    228 KJS::Value CInstance::valueOf() const
     222    return jsBoolean(false);
     223}
     224
     225ValueImp *CInstance::valueOf() const
    229226{
    230227    return stringValue();
    231 };
     228}
     229
     230}
     231}
  • trunk/JavaScriptCore/bindings/c/c_instance.h

    r8384 r10084  
    5252    virtual void end();
    5353   
    54     virtual Value valueOf() const;
    55     virtual Value defaultValue (KJS::Type hint) const;
     54    virtual ValueImp *valueOf() const;
     55    virtual ValueImp *defaultValue (KJS::Type hint) const;
    5656
    57     virtual Value invokeMethod (ExecState *exec, const MethodList &method, const List &args);
    58     virtual Value invokeDefaultMethod (ExecState *exec, const List &args);
     57    virtual ValueImp *invokeMethod (ExecState *exec, const MethodList &method, const List &args);
     58    virtual ValueImp *invokeDefaultMethod (ExecState *exec, const List &args);
    5959
    60     Value stringValue() const;
    61     Value numberValue() const;
    62     Value booleanValue() const;
     60    ValueImp *stringValue() const;
     61    ValueImp *numberValue() const;
     62    ValueImp *booleanValue() const;
    6363   
    6464    NPObject *getObject() const { return _object; }
  • trunk/JavaScriptCore/bindings/c/c_runtime.cpp

    r7927 r10084  
    4242// ---------------------- CField ----------------------
    4343
    44 Value CField::valueFromInstance(KJS::ExecState *exec, const Instance *inst) const
     44ValueImp *CField::valueFromInstance(ExecState *exec, const Instance *inst) const
    4545{
    4646    const CInstance *instance = static_cast<const CInstance*>(inst);
    4747    NPObject *obj = instance->getObject();
    48     Value aValue;
     48    ValueImp *aValue;
    4949    NPVariant property;
    5050    VOID_TO_NPVARIANT(property);
     
    5959}
    6060
    61 void CField::setValueToInstance(KJS::ExecState *exec, const Instance *inst, const KJS::Value &aValue) const
     61void CField::setValueToInstance(ExecState *exec, const Instance *inst, ValueImp *aValue) const
    6262{
    6363    const CInstance *instance = static_cast<const CInstance*>(inst);
  • trunk/JavaScriptCore/bindings/c/c_runtime.h

    r7733 r10084  
    3636namespace KJS
    3737{
    38 class Value;
    3938
    4039namespace Bindings
     
    5049    };
    5150   
    52     virtual KJS::Value valueFromInstance(KJS::ExecState *exec, const Instance *instance) const;
    53     virtual void setValueToInstance(KJS::ExecState *exec, const Instance *instance, const KJS::Value &aValue) const;
     51    virtual ValueImp *valueFromInstance(ExecState *exec, const Instance *instance) const;
     52    virtual void setValueToInstance(ExecState *exec, const Instance *instance, ValueImp *aValue) const;
    5453   
    5554    virtual const char *name() const { return _NPN_UTF8FromIdentifier(_fieldIdentifier); }
     
    8685    CArray &operator=(const CArray &other);
    8786   
    88     virtual void setValueAt(KJS::ExecState *exec, unsigned int index, const KJS::Value &aValue) const;
    89     virtual KJS::Value valueAt(KJS::ExecState *exec, unsigned int index) const;
     87    virtual void setValueAt(ExecState *exec, unsigned int index, ValueImp *aValue) const;
     88    virtual ValueImp *valueAt(ExecState *exec, unsigned int index) const;
    9089    virtual unsigned int getLength() const;
    9190   
  • trunk/JavaScriptCore/bindings/c/c_utility.cpp

    r8585 r10084  
    3838
    3939// Requires free() of returned UTF16Chars.
    40 void convertNPStringToUTF16 (const NPString *string, NPUTF16 **UTF16Chars, unsigned int *UTF16Length)
     40void convertNPStringToUTF16(const NPString *string, NPUTF16 **UTF16Chars, unsigned int *UTF16Length)
    4141{
    42     convertUTF8ToUTF16 (string->UTF8Characters, string->UTF8Length, UTF16Chars, UTF16Length);
     42    convertUTF8ToUTF16(string->UTF8Characters, string->UTF8Length, UTF16Chars, UTF16Length);
    4343}
    4444
    4545// Requires free() of returned UTF16Chars.
    46 void convertUTF8ToUTF16 (const NPUTF8 *UTF8Chars, int UTF8Length, NPUTF16 **UTF16Chars, unsigned int *UTF16Length)
     46void convertUTF8ToUTF16(const NPUTF8 *UTF8Chars, int UTF8Length, NPUTF16 **UTF16Chars, unsigned int *UTF16Length)
    4747{
    48     assert (UTF8Chars);
     48    assert(UTF8Chars);
    4949   
    5050    if (UTF8Length == -1)
    5151        UTF8Length = strlen(UTF8Chars);
    5252       
    53     CFStringRef stringRef = CFStringCreateWithBytes (NULL, (const UInt8*)UTF8Chars, (CFIndex)UTF8Length, kCFStringEncodingUTF8, false);
     53    CFStringRef stringRef = CFStringCreateWithBytes(NULL, (const UInt8*)UTF8Chars, (CFIndex)UTF8Length, kCFStringEncodingUTF8, false);
    5454
    55     *UTF16Length = (unsigned int)CFStringGetLength (stringRef);
    56     *UTF16Chars = (NPUTF16 *)malloc (sizeof(NPUTF16) * (*UTF16Length));
     55    *UTF16Length = (unsigned int)CFStringGetLength(stringRef);
     56    *UTF16Chars = (NPUTF16 *)malloc(sizeof(NPUTF16) * (*UTF16Length));
    5757
    5858    // Convert the string to UTF16.
    5959    CFRange range = { 0, *UTF16Length };
    60     CFStringGetCharacters (stringRef, range, (UniChar *)*UTF16Chars);
    61     CFRelease (stringRef);
     60    CFStringGetCharacters(stringRef, range, (UniChar *)*UTF16Chars);
     61    CFRelease(stringRef);
    6262}
    6363
    6464// Variant value must be released with NPReleaseVariantValue()
    65 void coerceValueToNPVariantStringType (KJS::ExecState *exec, const KJS::Value &value, NPVariant *result)
     65void coerceValueToNPVariantStringType(ExecState *exec, ValueImp *value, NPVariant *result)
    6666{
    67     UString ustring = value.toString(exec);
     67    UString ustring = value->toString(exec);
    6868    CString cstring = ustring.UTF8String();
    6969    NPString string = { (const NPUTF8 *)cstring.c_str(), cstring.size() };
    70     NPN_InitializeVariantWithStringCopy (result, &string);
     70    NPN_InitializeVariantWithStringCopy(result, &string);
    7171}
    7272
    7373// Variant value must be released with NPReleaseVariantValue()
    74 void convertValueToNPVariant (KJS::ExecState *exec, const KJS::Value &value, NPVariant *result)
     74void convertValueToNPVariant(ExecState *exec, ValueImp *value, NPVariant *result)
    7575{
    76     Type type = value.type();
     76    Type type = value->type();
    7777   
    7878    if (type == StringType) {
    79         UString ustring = value.toString(exec);
     79        UString ustring = value->toString(exec);
    8080        CString cstring = ustring.UTF8String();
    8181        NPString string = { (const NPUTF8 *)cstring.c_str(), cstring.size() };
    82         NPN_InitializeVariantWithStringCopy (result, &string );
     82        NPN_InitializeVariantWithStringCopy(result, &string );
    8383    }
    8484    else if (type == NumberType) {
    85         NPN_InitializeVariantWithDouble (result, value.toNumber(exec));
     85        NPN_InitializeVariantWithDouble(result, value->toNumber(exec));
    8686    }
    8787    else if (type == BooleanType) {
    88         NPN_InitializeVariantWithBool (result, value.toBoolean(exec));
     88        NPN_InitializeVariantWithBool(result, value->toBoolean(exec));
    8989    }
    9090    else if (type == UnspecifiedType) {
     
    9595    }
    9696    else if (type == ObjectType) {
    97         KJS::ObjectImp *objectImp = static_cast<KJS::ObjectImp*>(value.imp());
    98         if (objectImp->classInfo() == &KJS::RuntimeObjectImp::info) {
    99             KJS::RuntimeObjectImp *imp = static_cast<KJS::RuntimeObjectImp *>(value.imp());
     97        ObjectImp *objectImp = static_cast<ObjectImp*>(value);
     98        if (objectImp->classInfo() == &RuntimeObjectImp::info) {
     99            RuntimeObjectImp *imp = static_cast<RuntimeObjectImp *>(value);
    100100            CInstance *instance = static_cast<CInstance*>(imp->getInternalInstance());
    101             NPN_InitializeVariantWithObject (result, instance->getObject());
     101            NPN_InitializeVariantWithObject(result, instance->getObject());
    102102        }
    103103        else {
    104104
    105             KJS::Interpreter *originInterpreter = exec->interpreter();
     105            Interpreter *originInterpreter = exec->interpreter();
    106106            const Bindings::RootObject *originExecutionContext = rootForInterpreter(originInterpreter);
    107107
    108             KJS::Interpreter *interpreter = 0;
     108            Interpreter *interpreter = 0;
    109109            if (originInterpreter->isGlobalObject(value)) {
    110                 interpreter = originInterpreter->interpreterForGlobalObject (value.imp());
     110                interpreter = originInterpreter->interpreterForGlobalObject(value);
    111111            }
    112112
     
    116116            const Bindings::RootObject *executionContext = rootForInterpreter(interpreter);
    117117            if (!executionContext) {
    118                 Bindings::RootObject *newExecutionContext = new KJS::Bindings::RootObject(0);
    119                 newExecutionContext->setInterpreter (interpreter);
     118                Bindings::RootObject *newExecutionContext = new Bindings::RootObject(0);
     119                newExecutionContext->setInterpreter(interpreter);
    120120                executionContext = newExecutionContext;
    121121            }
    122122   
    123             NPObject *obj = (NPObject *)exec->interpreter()->createLanguageInstanceForValue (exec, Instance::CLanguage, value.toObject(exec), originExecutionContext, executionContext);
    124             NPN_InitializeVariantWithObject (result, obj);
    125             _NPN_ReleaseObject (obj);
     123            NPObject *obj = (NPObject *)exec->interpreter()->createLanguageInstanceForValue(exec, Instance::CLanguage, value->toObject(exec), originExecutionContext, executionContext);
     124            NPN_InitializeVariantWithObject(result, obj);
     125            _NPN_ReleaseObject(obj);
    126126        }
    127127    }
     
    130130}
    131131
    132 Value convertNPVariantToValue (KJS::ExecState *exec, const NPVariant *variant)
     132ValueImp *convertNPVariantToValue(ExecState *exec, const NPVariant *variant)
    133133{
    134134    NPVariantType type = variant->type;
     
    136136    if (type == NPVariantType_Bool) {
    137137        NPBool aBool;
    138         if (NPN_VariantToBool (variant, &aBool))
    139             return KJS::Boolean (aBool);
    140         return KJS::Boolean (false);
     138        if (NPN_VariantToBool(variant, &aBool))
     139            return jsBoolean(aBool);
     140        return jsBoolean(false);
    141141    }
    142142    else if (type == NPVariantType_Null) {
     
    148148    else if (type == NPVariantType_Int32) {
    149149        int32_t anInt;
    150         if (NPN_VariantToInt32 (variant, &anInt))
    151             return Number (anInt);
    152         return Number (0);
     150        if (NPN_VariantToInt32(variant, &anInt))
     151            return Number(anInt);
     152        return Number(0);
    153153    }
    154154    else if (type == NPVariantType_Double) {
    155155        double aDouble;
    156         if (NPN_VariantToDouble (variant, &aDouble))
    157             return Number (aDouble);
    158         return Number (0);
     156        if (NPN_VariantToDouble(variant, &aDouble))
     157            return Number(aDouble);
     158        return Number(0);
    159159    }
    160160    else if (type == NPVariantType_String) {
    161161        NPUTF16 *stringValue;
    162162        unsigned int UTF16Length;
    163         convertNPStringToUTF16 (&variant->value.stringValue, &stringValue, &UTF16Length);    // requires free() of returned memory.
    164         String resultString(UString((const UChar *)stringValue,UTF16Length));
    165         free (stringValue);
    166         return resultString;
     163        convertNPStringToUTF16(&variant->value.stringValue, &stringValue, &UTF16Length);    // requires free() of returned memory.
     164        UString resultString((const UChar *)stringValue,UTF16Length);
     165        free(stringValue);
     166        return jsString(resultString);
    167167    }
    168168    else if (type == NPVariantType_Object) {
     
    172172            // Get ObjectImp from NP_JavaScriptObject.
    173173            JavaScriptObject *o = (JavaScriptObject *)obj;
    174             return Object(const_cast<ObjectImp*>(o->imp));
     174            return const_cast<ObjectImp*>(o->imp);
    175175        }
    176176        else {
  • trunk/JavaScriptCore/bindings/c/c_utility.h

    r6909 r10084  
    4646} NP_ValueType;
    4747
    48 
    49 extern void convertNPStringToUTF16 (const NPString *string, NPUTF16 **UTF16Chars, unsigned int *UTF16Length);
    50 extern void convertUTF8ToUTF16 (const NPUTF8 *UTF8Chars, int UTF8Length, NPUTF16 **UTF16Chars, unsigned int *UTF16Length);
    51 extern void coerceValueToNPVariantStringType (KJS::ExecState *exec, const KJS::Value &value, NPVariant *result);
    52 extern void convertValueToNPVariant (KJS::ExecState *exec, const KJS::Value &value, NPVariant *result);
    53 extern KJS::Value convertNPVariantToValue (KJS::ExecState *exec, const NPVariant *variant);
     48void convertNPStringToUTF16(const NPString *string, NPUTF16 **UTF16Chars, unsigned int *UTF16Length);
     49void convertUTF8ToUTF16(const NPUTF8 *UTF8Chars, int UTF8Length, NPUTF16 **UTF16Chars, unsigned int *UTF16Length);
     50void coerceValueToNPVariantStringType(KJS::ExecState *exec, KJS::ValueImp *value, NPVariant *result);
     51void convertValueToNPVariant(KJS::ExecState *exec, KJS::ValueImp *value, NPVariant *result);
     52KJS::ValueImp *convertNPVariantToValue(KJS::ExecState *exec, const NPVariant *variant);
    5453
    5554typedef struct
  • trunk/JavaScriptCore/bindings/jni/jni_instance.cpp

    r8585 r10084  
    8282}
    8383
    84 KJS::Value JavaInstance::stringValue() const
     84ValueImp *JavaInstance::stringValue() const
    8585{
    8686    jstring stringValue = (jstring)callJNIObjectMethod (_instance->_instance, "toString", "()Ljava/lang/String;");
    8787    JNIEnv *env = getJNIEnv();
    88     const UChar *c = (const UChar *)getUCharactersFromJStringInEnv (env, stringValue);
    89     UString u(c, (int)env->GetStringLength(stringValue));
    90     String v(u);
    91     releaseUCharactersForJStringInEnv (env, stringValue, (const jchar *)c);
    92     return v;
    93 }
    94 
    95 KJS::Value JavaInstance::numberValue() const
     88    const jchar *c = getUCharactersFromJStringInEnv(env, stringValue);
     89    UString u((const UChar *)c, (int)env->GetStringLength(stringValue));
     90    releaseUCharactersForJStringInEnv(env, stringValue, c);
     91    return jsString(u);
     92}
     93
     94ValueImp *JavaInstance::numberValue() const
    9695{
    9796    jdouble doubleValue = callJNIDoubleMethod (_instance->_instance, "doubleValue", "()D");
    98     KJS::Number v(doubleValue);
    99     return v;
    100 }
    101 
    102 KJS::Value JavaInstance::booleanValue() const
     97    return jsNumber(doubleValue);
     98}
     99
     100ValueImp *JavaInstance::booleanValue() const
    103101{
    104102    jboolean booleanValue = callJNIBooleanMethod (_instance->_instance, "booleanValue", "()Z");
    105     KJS::Boolean v(booleanValue);
    106     return v;
    107 }
    108 
    109 Value JavaInstance::invokeMethod (KJS::ExecState *exec, const MethodList &methodList, const List &args)
     103    return jsBoolean(booleanValue);
     104}
     105
     106ValueImp *JavaInstance::invokeMethod (ExecState *exec, const MethodList &methodList, const List &args)
    110107{
    111108    int i, count = args.size();
    112109    jvalue *jArgs;
    113     Value resultValue;
     110    ValueImp *resultValue;
    114111    Method *method = 0;
    115112    unsigned int numMethods = methodList.length();
     
    146143        JavaParameter *aParameter = static_cast<JavaParameter *>(jMethod->parameterAt(i));
    147144        jArgs[i] = convertValueToJValue (exec, args.at(i), aParameter->getJNIType(), aParameter->type());
    148         JS_LOG("arg[%d] = %s\n", i, args.at(i).toString(exec).ascii());
     145        JS_LOG("arg[%d] = %s\n", i, args.at(i)->toString(exec).ascii());
    149146    }
    150147       
     
    159156    if (execContext && execContext->nativeHandle()) {
    160157        jobject obj = _instance->_instance;
    161         Value exceptionDescription;
     158        ValueImp *exceptionDescription;
    162159        const char *callingURL = 0;  // FIXME, need to propagate calling URL to Java
    163160        handled = dispatchJNICall (execContext->nativeHandle(), obj, jMethod->isStatic(), jMethod->JNIReturnType(), jMethod->methodID(obj), jArgs, result, callingURL, exceptionDescription);
    164         if (!exceptionDescription.isNull()) {
    165             Object error = Error::create(exec, GeneralError, exceptionDescription.toString(exec).UTF8String().c_str());
    166            
     161        if (exceptionDescription) {
     162            ObjectImp *error = Error::create(exec, GeneralError, exceptionDescription->toString(exec).UTF8String().c_str());
    167163            exec->setException(error);
    168164           
     
    257253       
    258254        case boolean_type: {
    259             resultValue = KJS::Boolean(result.z);
     255            resultValue = Boolean(result.z);
    260256        }
    261257        break;
     
    308304}
    309305
    310 KJS::Value JavaInstance::invokeDefaultMethod (KJS::ExecState *exec, const KJS::List &args)
     306ValueImp *JavaInstance::invokeDefaultMethod (ExecState *exec, const List &args)
    311307{
    312308    return Undefined();
     
    314310
    315311
    316 KJS::Value JavaInstance::defaultValue (KJS::Type hint) const
     312ValueImp *JavaInstance::defaultValue (Type hint) const
    317313{
    318314    if (hint == StringType) {
     
    341337}
    342338
    343 KJS::Value JavaInstance::valueOf() const
     339ValueImp *JavaInstance::valueOf() const
    344340{
    345341    return stringValue();
  • trunk/JavaScriptCore/bindings/jni/jni_instance.h

    r8384 r10084  
    9191    virtual void end();
    9292   
    93     virtual Value valueOf() const;
    94     virtual Value defaultValue (Type hint) const;
     93    virtual ValueImp *valueOf() const;
     94    virtual ValueImp *defaultValue (Type hint) const;
    9595
    96     virtual Value invokeMethod (ExecState *exec, const MethodList &method, const List &args);
    97     virtual Value invokeDefaultMethod (ExecState *exec, const List &args);
     96    virtual ValueImp *invokeMethod (ExecState *exec, const MethodList &method, const List &args);
     97    virtual ValueImp *invokeDefaultMethod (ExecState *exec, const List &args);
    9898
    9999    jobject javaInstance() const { return _instance->_instance; }
    100100   
    101     Value stringValue() const;
    102     Value numberValue() const;
    103     Value booleanValue() const;
     101    ValueImp *stringValue() const;
     102    ValueImp *numberValue() const;
     103    ValueImp *booleanValue() const;
    104104       
    105105private:
  • trunk/JavaScriptCore/bindings/jni/jni_jsobject.cpp

    r9078 r10084  
    7878        }
    7979        else {
    80             KJS::ObjectImp *imp = jlong_to_impptr(nativeHandle);
     80            ObjectImp *imp = jlong_to_impptr(nativeHandle);
    8181            if (!rootForImp(imp)) {
    8282                fprintf (stderr, "%s:%d:  Attempt to access JavaScript from destroyed applet, type %d.\n", __FILE__, __LINE__, context->type);
     
    174174   
    175175    Identifier identifier(JavaString(methodName).ustring());
    176     Value func = _imp->get (exec, identifier);
    177     Interpreter::unlock();
    178     if (func.isNull() || func.type() == UndefinedType) {
     176    ValueImp *func = _imp->get (exec, identifier);
     177    Interpreter::unlock();
     178    if (func->isUndefinedOrNull()) {
    179179        // Maybe throw an exception here?
    180180        return 0;
     
    182182
    183183    // Call the function object.
    184     ObjectImp *funcImp = static_cast<ObjectImp*>(func.imp());
    185     Object thisObj = Object(const_cast<ObjectImp*>(_imp));
     184    ObjectImp *funcImp = static_cast<ObjectImp*>(func);
     185    ObjectImp *thisObj = const_cast<ObjectImp*>(_imp);
    186186    List argList = listFromJArray(args);
    187187    Interpreter::lock();
    188     Value result = funcImp->call (exec, thisObj, argList);
     188    ValueImp *result = funcImp->call (exec, thisObj, argList);
    189189    Interpreter::unlock();
    190190
     
    197197    JS_LOG ("script = %s\n", JavaString(script).UTF8String());
    198198
    199     Object thisObj = Object(const_cast<ObjectImp*>(_imp));
    200     Value result;
     199    ObjectImp *thisObj = const_cast<ObjectImp*>(_imp);
     200    ValueImp *result;
    201201   
    202202    Interpreter::lock();
     
    207207    if (type == Normal) {
    208208        result = completion.value();
    209         if (result.isNull()) {
     209        if (!result) {
    210210            result = Undefined();
    211211        }
     
    226226
    227227    Interpreter::lock();
    228     Value result = _imp->get (exec, Identifier (JavaString(memberName).ustring()));
     228    ValueImp *result = _imp->get (exec, Identifier (JavaString(memberName).ustring()));
    229229    Interpreter::unlock();
    230230
     
    259259    ExecState *exec = _root->interpreter()->globalExec();
    260260    Interpreter::lock();
    261     Value result = _imp->get (exec, (unsigned)index);
     261    ValueImp *result = _imp->get (exec, (unsigned)index);
    262262    Interpreter::unlock();
    263263
     
    282282
    283283    Interpreter::lock();
    284     Object thisObj = Object(const_cast<ObjectImp*>(_imp));
     284    ObjectImp *thisObj = const_cast<ObjectImp*>(_imp);
    285285    ExecState *exec = _root->interpreter()->globalExec();
    286286   
     
    329329}
    330330
    331 jobject JSObject::convertValueToJObject (KJS::Value value) const
     331jobject JSObject::convertValueToJObject (ValueImp *value) const
    332332{
    333333    ExecState *exec = _root->interpreter()->globalExec();
     
    343343    // Everything else -> JSObject
    344344   
    345     KJS::Type type = value.type();
    346     if (type == KJS::NumberType) {
     345    Type type = value->type();
     346    if (type == NumberType) {
    347347        jclass JSObjectClass = env->FindClass ("java/lang/Double");
    348348        jmethodID constructorID = env->GetMethodID (JSObjectClass, "<init>", "(D)V");
    349349        if (constructorID != NULL) {
    350             result = env->NewObject (JSObjectClass, constructorID, (jdouble)value.toNumber(exec));
    351         }
    352     }
    353     else if (type == KJS::StringType) {
    354         KJS::UString stringValue = value.toString(exec);
     350            result = env->NewObject (JSObjectClass, constructorID, (jdouble)value->toNumber(exec));
     351        }
     352    }
     353    else if (type == StringType) {
     354        UString stringValue = value->toString(exec);
    355355        JNIEnv *env = getJNIEnv();
    356356        result = env->NewString ((const jchar *)stringValue.data(), stringValue.size());
    357357    }
    358     else if (type == KJS::BooleanType) {
     358    else if (type == BooleanType) {
    359359        jclass JSObjectClass = env->FindClass ("java/lang/Boolean");
    360360        jmethodID constructorID = env->GetMethodID (JSObjectClass, "<init>", "(Z)V");
    361361        if (constructorID != NULL) {
    362             result = env->NewObject (JSObjectClass, constructorID, (jboolean)value.toBoolean(exec));
     362            result = env->NewObject (JSObjectClass, constructorID, (jboolean)value->toBoolean(exec));
    363363        }
    364364    }
     
    367367        jlong nativeHandle;
    368368       
    369         if (type == KJS::ObjectType){
    370             KJS::ObjectImp *imp = static_cast<KJS::ObjectImp*>(value.imp());
     369        if (type == ObjectType){
     370            ObjectImp *imp = static_cast<ObjectImp*>(value);
    371371           
    372372            // We either have a wrapper around a Java instance or a JavaScript
     
    375375            // as it's nativeHandle.
    376376            if (imp->classInfo() && strcmp(imp->classInfo()->className, "RuntimeObject") == 0) {
    377                 KJS::RuntimeObjectImp *runtimeImp = static_cast<KJS::RuntimeObjectImp*>(value.imp());
     377                RuntimeObjectImp *runtimeImp = static_cast<RuntimeObjectImp*>(value);
    378378                Bindings::JavaInstance *runtimeInstance = static_cast<Bindings::JavaInstance *>(runtimeImp->getInternalInstance());
    379379                return runtimeInstance->javaInstance();
     
    412412}
    413413
    414 KJS::Value JSObject::convertJObjectToValue (jobject theObject) const
     414ValueImp *JSObject::convertJObjectToValue (jobject theObject) const
    415415{
    416416    // Instances of netscape.javascript.JSObject get converted back to
     
    428428        jfieldID fieldID = env->GetFieldID((jclass)classOfInstance, "nativeJSObject", "long");
    429429        if (fieldID == NULL) {
    430             return KJS::Undefined();
     430            return Undefined();
    431431        }
    432432        jlong nativeHandle = env->GetLongField(theObject, fieldID);
    433433        if (nativeHandle == UndefinedHandle) {
    434             return KJS::Undefined();
    435         }
    436         KJS::ObjectImp *imp = static_cast<KJS::ObjectImp*>(jlong_to_impptr(nativeHandle));
    437         return KJS::Object(const_cast<KJS::ObjectImp*>(imp));
    438     }
    439 
    440     Interpreter::lock();
    441     KJS::RuntimeObjectImp *newImp = new KJS::RuntimeObjectImp(new Bindings::JavaInstance (theObject, _root));
    442     Interpreter::unlock();
    443 
    444     return KJS::Object(newImp);
    445 }
    446 
    447 KJS::List JSObject::listFromJArray(jobjectArray jArray) const
     434            return Undefined();
     435        }
     436        ObjectImp *imp = static_cast<ObjectImp*>(jlong_to_impptr(nativeHandle));
     437        return imp;
     438    }
     439
     440    Interpreter::lock();
     441    RuntimeObjectImp *newImp = new RuntimeObjectImp(new Bindings::JavaInstance (theObject, _root));
     442    Interpreter::unlock();
     443
     444    return newImp;
     445}
     446
     447List JSObject::listFromJArray(jobjectArray jArray) const
    448448{
    449449    JNIEnv *env = getJNIEnv();
    450450    long i, numObjects = jArray ? env->GetArrayLength (jArray) : 0;
    451     KJS::List aList;
     451    List aList;
    452452   
    453453    for (i = 0; i < numObjects; i++) {
  • trunk/JavaScriptCore/bindings/jni/jni_jsobject.h

    r6637 r10084  
    8989    static jvalue invoke (JSObjectCallContext *context);
    9090
    91     jobject convertValueToJObject (KJS::Value value) const;
    92     KJS::Value convertJObjectToValue (jobject theObject) const;
    93     KJS::List listFromJArray(jobjectArray jArray) const;
     91    jobject convertValueToJObject (ValueImp *value) const;
     92    ValueImp *convertJObjectToValue (jobject theObject) const;
     93    List listFromJArray(jobjectArray jArray) const;
    9494   
    9595private:
    96     const Bindings::RootObject *_root;
    97     KJS::ObjectImp *_imp;
     96    const RootObject *_root;
     97    ObjectImp *_imp;
    9898};
    9999
     
    117117jstring KJS_JSObject_JSObjectToString (JNIEnv *env, jclass clazz, jlong nativeJSObject);
    118118
    119 } // namespace Bindings
     119}
    120120
    121121#endif
  • trunk/JavaScriptCore/bindings/jni/jni_objc.mm

    r8213 r10084  
    4444@end
    4545
    46 bool KJS::Bindings::dispatchJNICall (const void *targetAppletView, jobject obj, bool isStatic, JNIType returnType, jmethodID methodID, jvalue *args, jvalue &result, const char *callingURL, Value &exceptionDescription)
     46bool KJS::Bindings::dispatchJNICall (const void *targetAppletView, jobject obj, bool isStatic, JNIType returnType, jmethodID methodID, jvalue *args, jvalue &result, const char *callingURL, ValueImp *&exceptionDescription)
    4747{
    4848    id view = (id)targetAppletView;
  • trunk/JavaScriptCore/bindings/jni/jni_runtime.cpp

    r9102 r10084  
    6868}
    6969
    70 KJS::Value JavaArray::convertJObjectToArray (KJS::ExecState *exec, jobject anObject, const char *type, const RootObject *r)
     70ValueImp *JavaArray::convertJObjectToArray (ExecState *exec, jobject anObject, const char *type, const RootObject *r)
    7171{
    7272    if (type[0] != '[')
    7373        return Undefined();
    7474
    75     return KJS::Object(new RuntimeArrayImp(exec, new JavaArray ((jobject)anObject, type, r)));
    76 }
    77 
    78 jvalue JavaField::dispatchValueFromInstance(KJS::ExecState *exec, const JavaInstance *instance, const char *name, const char *sig, JNIType returnType) const
     75    return new RuntimeArrayImp(exec, new JavaArray((jobject)anObject, type, r));
     76}
     77
     78jvalue JavaField::dispatchValueFromInstance(ExecState *exec, const JavaInstance *instance, const char *name, const char *sig, JNIType returnType) const
    7979{
    8080    jobject jinstance = instance->javaInstance();
     
    9191            const RootObject *execContext = instance->executionContext();
    9292            if (execContext && execContext->nativeHandle()) {
    93                 Value exceptionDescription;
     93                ValueImp *exceptionDescription;
    9494                jvalue args[1];
    9595               
    9696                args[0].l = jinstance;
    9797                dispatchJNICall (execContext->nativeHandle(), fieldJInstance, false, returnType, mid, args, result, 0, exceptionDescription);
    98                 if (!exceptionDescription.isNull()) {
    99                     Object error = Error::create(exec, GeneralError, exceptionDescription.toString(exec).UTF8String().c_str());
     98                if (exceptionDescription) {
     99                    ObjectImp *error = Error::create(exec, GeneralError, exceptionDescription->toString(exec).UTF8String().c_str());
    100100                    exec->setException(error);
    101101                }
     
    106106}
    107107
    108 KJS::Value JavaField::valueFromInstance(KJS::ExecState *exec, const Instance *i) const
     108ValueImp *JavaField::valueFromInstance(ExecState *exec, const Instance *i) const
    109109{
    110110    const JavaInstance *instance = static_cast<const JavaInstance *>(i);
    111111
    112     Value jsresult = Undefined();
     112    ValueImp *jsresult = Undefined();
    113113   
    114114    switch (_JNIType) {
     
    130130            jvalue result = dispatchValueFromInstance (exec, instance, "getBoolean", "(Ljava/lang/Object;)Z", boolean_type);
    131131            jboolean value = result.z;
    132             jsresult = KJS::Boolean((bool)value);
     132            jsresult = Boolean((bool)value);
    133133        }
    134134        break;
     
    159159    }
    160160
    161     JS_LOG ("getting %s = %s\n", name(), jsresult.toString(exec).ascii());
     161    JS_LOG ("getting %s = %s\n", name(), jsresult->toString(exec).ascii());
    162162   
    163163    return jsresult;
    164164}
    165165
    166 void JavaField::dispatchSetValueToInstance(KJS::ExecState *exec, const JavaInstance *instance, jvalue javaValue, const char *name, const char *sig) const
     166void JavaField::dispatchSetValueToInstance(ExecState *exec, const JavaInstance *instance, jvalue javaValue, const char *name, const char *sig) const
    167167{
    168168    jobject jinstance = instance->javaInstance();
     
    177177            const RootObject *execContext = instance->executionContext();
    178178            if (execContext && execContext->nativeHandle()) {
    179                 Value exceptionDescription;
     179                ValueImp *exceptionDescription;
    180180                jvalue args[2];
    181181                jvalue result;
     
    184184                args[1] = javaValue;
    185185                dispatchJNICall (execContext->nativeHandle(), fieldJInstance, false, void_type, mid, args, result, 0, exceptionDescription);
    186                 if (!exceptionDescription.isNull()) {
    187                     Object error = Error::create(exec, GeneralError, exceptionDescription.toString(exec).UTF8String().c_str());
     186                if (exceptionDescription) {
     187                    ObjectImp *error = Error::create(exec, GeneralError, exceptionDescription->toString(exec).UTF8String().c_str());
    188188                    exec->setException(error);
    189189                }
     
    193193}
    194194
    195 void JavaField::setValueToInstance(KJS::ExecState *exec, const Instance *i, const KJS::Value &aValue) const
     195void JavaField::setValueToInstance(ExecState *exec, const Instance *i, ValueImp *aValue) const
    196196{
    197197    const JavaInstance *instance = static_cast<const JavaInstance *>(i);
    198198    jvalue javaValue = convertValueToJValue (exec, aValue, _JNIType, type());
    199199
    200     JS_LOG ("setting value %s to %s\n", name(), aValue.toString(exec).ascii());
     200    JS_LOG ("setting value %s to %s\n", name(), aValue->toString(exec).ascii());
    201201
    202202    switch (_JNIType) {
     
    395395};
    396396
    397 void JavaArray::setValueAt(KJS::ExecState *exec, unsigned int index, const KJS::Value &aValue) const
     397void JavaArray::setValueAt(ExecState *exec, unsigned int index, ValueImp *aValue) const
    398398{
    399399    JNIEnv *env = getJNIEnv();
     
    463463
    464464
    465 KJS::Value JavaArray::valueAt(KJS::ExecState *exec, unsigned int index) const
     465ValueImp *JavaArray::valueAt(ExecState *exec, unsigned int index) const
    466466{
    467467    JNIEnv *env = getJNIEnv();
     
    490490            jboolean aBoolean;
    491491            env->GetBooleanArrayRegion(booleanArray, index, 1, &aBoolean);
    492             return KJS::Boolean (aBoolean);
     492            return Boolean (aBoolean);
    493493        }
    494494           
  • trunk/JavaScriptCore/bindings/jni/jni_runtime.h

    r8344 r10084  
    3636namespace KJS
    3737{
    38 class Value;
    3938
    4039namespace Bindings
     
    6968    const jchar *uchars() const { return (const jchar *)_ustring.data(); }
    7069    int length() const { return _ustring.size(); }
    71     KJS::UString ustring() const { return _ustring; }
     70    UString ustring() const { return _ustring; }
    7271   
    7372private:
     
    183182    }
    184183   
    185     virtual KJS::Value valueFromInstance(KJS::ExecState *exec, const Instance *instance) const;
    186     virtual void setValueToInstance(KJS::ExecState *exec, const Instance *instance, const KJS::Value &aValue) const;
     184    virtual ValueImp *valueFromInstance(ExecState *exec, const Instance *instance) const;
     185    virtual void setValueToInstance(ExecState *exec, const Instance *instance, ValueImp *aValue) const;
    187186   
    188187    virtual const char *name() const { return _name.UTF8String(); }
     
    192191   
    193192private:
    194     void JavaField::dispatchSetValueToInstance(KJS::ExecState *exec, const JavaInstance *instance, jvalue javaValue, const char *name, const char *sig) const;
    195     jvalue JavaField::dispatchValueFromInstance(KJS::ExecState *exec, const JavaInstance *instance, const char *name, const char *sig, JNIType returnType) const;
     193    void JavaField::dispatchSetValueToInstance(ExecState *exec, const JavaInstance *instance, jvalue javaValue, const char *name, const char *sig) const;
     194    jvalue JavaField::dispatchValueFromInstance(ExecState *exec, const JavaInstance *instance, const char *name, const char *sig, JNIType returnType) const;
    196195
    197196    JavaString _name;
     
    262261    long _numParameters;
    263262    JavaString _name;
    264     mutable KJS::UString *_signature;
     263    mutable UString *_signature;
    265264    JavaString _returnType;
    266265    JNIType _JNIReturnType;
     
    292291    };
    293292
    294     virtual void setValueAt(KJS::ExecState *exec, unsigned int index, const KJS::Value &aValue) const;
    295     virtual KJS::Value valueAt(KJS::ExecState *exec, unsigned int index) const;
     293    virtual void setValueAt(ExecState *exec, unsigned int index, ValueImp *aValue) const;
     294    virtual ValueImp *valueAt(ExecState *exec, unsigned int index) const;
    296295    virtual unsigned int getLength() const;
    297296   
     
    300299    jobject javaArray() const { return _array->_instance; }
    301300
    302     static KJS::Value convertJObjectToArray (KJS::ExecState *exec, jobject anObject, const char *type, const RootObject *r);
     301    static ValueImp *convertJObjectToArray (ExecState *exec, jobject anObject, const char *type, const RootObject *r);
    303302
    304303    const RootObject *executionContext() const { return _root; }
  • trunk/JavaScriptCore/bindings/jni/jni_utility.cpp

    r9078 r10084  
    3131#include "runtime_object.h"
    3232
    33 using namespace KJS::Bindings;
     33namespace KJS {
     34
     35namespace Bindings {
    3436
    3537static JavaVM *jvm = 0;
    3638
    37 JavaVM *KJS::Bindings::getJavaVM()
     39JavaVM *getJavaVM()
    3840{
    3941    if (jvm)
     
    5658}
    5759
    58 JNIEnv *KJS::Bindings::getJNIEnv()
     60JNIEnv *getJNIEnv()
    5961{
    6062    JNIEnv *env;
     
    271273}
    272274
    273 jmethodID KJS::Bindings::getMethodID (jobject obj, const char *name, const char *sig)
     275jmethodID getMethodID (jobject obj, const char *name, const char *sig)
    274276{
    275277    JNIEnv *env = getJNIEnv();
     
    310312    va_end (args);
    311313
    312 void KJS::Bindings::callJNIVoidMethod (jobject obj, const char *name, const char *sig, ... )
     314void callJNIVoidMethod (jobject obj, const char *name, const char *sig, ... )
    313315{
    314316    CALL_JNI_METHOD (void_type, obj, name, sig);
    315317}
    316318
    317 jobject KJS::Bindings::callJNIObjectMethod (jobject obj, const char *name, const char *sig, ... )
     319jobject callJNIObjectMethod (jobject obj, const char *name, const char *sig, ... )
    318320{
    319321    CALL_JNI_METHOD (object_type, obj, name, sig);
     
    321323}
    322324
    323 jboolean KJS::Bindings::callJNIBooleanMethod( jobject obj, const char *name, const char *sig, ... )
     325jboolean callJNIBooleanMethod( jobject obj, const char *name, const char *sig, ... )
    324326{
    325327    CALL_JNI_METHOD (boolean_type, obj, name, sig);
     
    327329}
    328330
    329 jboolean KJS::Bindings::callJNIStaticBooleanMethod (jclass cls, const char *name, const char *sig, ... )
     331jboolean callJNIStaticBooleanMethod (jclass cls, const char *name, const char *sig, ... )
    330332{
    331333    CALL_JNI_STATIC_METHOD (boolean_type, cls, name, sig);
     
    333335}
    334336
    335 jbyte KJS::Bindings::callJNIByteMethod( jobject obj, const char *name, const char *sig, ... )
     337jbyte callJNIByteMethod( jobject obj, const char *name, const char *sig, ... )
    336338{
    337339    CALL_JNI_METHOD (byte_type, obj, name, sig);
     
    339341}
    340342
    341 jchar KJS::Bindings::callJNICharMethod (jobject obj, const char *name, const char *sig, ... )
     343jchar callJNICharMethod (jobject obj, const char *name, const char *sig, ... )
    342344{
    343345    CALL_JNI_METHOD (char_type, obj, name, sig);
     
    345347}
    346348
    347 jshort KJS::Bindings::callJNIShortMethod (jobject obj, const char *name, const char *sig, ... )
     349jshort callJNIShortMethod (jobject obj, const char *name, const char *sig, ... )
    348350{
    349351    CALL_JNI_METHOD (short_type, obj, name, sig);
     
    351353}
    352354
    353 jint KJS::Bindings::callJNIIntMethod (jobject obj, const char *name, const char *sig, ... )
     355jint callJNIIntMethod (jobject obj, const char *name, const char *sig, ... )
    354356{
    355357    CALL_JNI_METHOD (int_type, obj, name, sig);
     
    357359}
    358360
    359 jlong KJS::Bindings::callJNILongMethod (jobject obj, const char *name, const char *sig, ... )
     361jlong callJNILongMethod (jobject obj, const char *name, const char *sig, ... )
    360362{
    361363    CALL_JNI_METHOD (long_type, obj, name, sig);
     
    363365}
    364366
    365 jfloat KJS::Bindings::callJNIFloatMethod (jobject obj, const char *name, const char *sig, ... )
     367jfloat callJNIFloatMethod (jobject obj, const char *name, const char *sig, ... )
    366368{
    367369    CALL_JNI_METHOD (float_type, obj, name, sig);
     
    369371}
    370372
    371 jdouble KJS::Bindings::callJNIDoubleMethod (jobject obj, const char *name, const char *sig, ... )
     373jdouble callJNIDoubleMethod (jobject obj, const char *name, const char *sig, ... )
    372374{
    373375    CALL_JNI_METHOD (double_type, obj, name, sig);
     
    375377}
    376378
    377 void KJS::Bindings::callJNIVoidMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
     379void callJNIVoidMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
    378380{
    379381    jvalue result = callJNIMethodA (void_type, obj, name, sig, args);
    380382}
    381383
    382 jobject KJS::Bindings::callJNIObjectMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
     384jobject callJNIObjectMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
    383385{
    384386    jvalue result = callJNIMethodA (object_type, obj, name, sig, args);
     
    386388}
    387389
    388 jbyte KJS::Bindings::callJNIByteMethodA ( jobject obj, const char *name, const char *sig, jvalue *args)
     390jbyte callJNIByteMethodA ( jobject obj, const char *name, const char *sig, jvalue *args)
    389391{
    390392    jvalue result = callJNIMethodA (byte_type, obj, name, sig, args);
     
    392394}
    393395
    394 jchar KJS::Bindings::callJNICharMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
     396jchar callJNICharMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
    395397{
    396398    jvalue result = callJNIMethodA (char_type, obj, name, sig, args);
     
    398400}
    399401
    400 jshort KJS::Bindings::callJNIShortMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
     402jshort callJNIShortMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
    401403{
    402404    jvalue result = callJNIMethodA (short_type, obj, name, sig, args);
     
    404406}
    405407
    406 jint KJS::Bindings::callJNIIntMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
     408jint callJNIIntMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
    407409{
    408410    jvalue result = callJNIMethodA (int_type, obj, name, sig, args);
     
    410412}
    411413
    412 jlong KJS::Bindings::callJNILongMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
     414jlong callJNILongMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
    413415{
    414416    jvalue result = callJNIMethodA (long_type, obj, name, sig, args);
     
    416418}
    417419
    418 jfloat KJS::Bindings::callJNIFloatMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
     420jfloat callJNIFloatMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
    419421{
    420422    jvalue result = callJNIMethodA  (float_type, obj, name, sig, args);
     
    422424}
    423425
    424 jdouble KJS::Bindings::callJNIDoubleMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
     426jdouble callJNIDoubleMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
    425427{
    426428    jvalue result = callJNIMethodA (double_type, obj, name, sig, args);
     
    428430}
    429431
    430 jboolean KJS::Bindings::callJNIBooleanMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
     432jboolean callJNIBooleanMethodA (jobject obj, const char *name, const char *sig, jvalue *args)
    431433{
    432434    jvalue result = callJNIMethodA (boolean_type, obj, name, sig, args);
     
    434436}
    435437
    436 void KJS::Bindings::callJNIVoidMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
     438void callJNIVoidMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
    437439{
    438440    jvalue result = callJNIMethodIDA (void_type, obj, methodID, args);
    439441}
    440442
    441 jobject KJS::Bindings::callJNIObjectMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
     443jobject callJNIObjectMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
    442444{
    443445    jvalue result = callJNIMethodIDA (object_type, obj, methodID, args);
     
    445447}
    446448
    447 jbyte KJS::Bindings::callJNIByteMethodIDA ( jobject obj, jmethodID methodID, jvalue *args)
     449jbyte callJNIByteMethodIDA ( jobject obj, jmethodID methodID, jvalue *args)
    448450{
    449451    jvalue result = callJNIMethodIDA (byte_type, obj, methodID, args);
     
    451453}
    452454
    453 jchar KJS::Bindings::callJNICharMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
     455jchar callJNICharMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
    454456{
    455457    jvalue result = callJNIMethodIDA (char_type, obj, methodID, args);
     
    457459}
    458460
    459 jshort KJS::Bindings::callJNIShortMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
     461jshort callJNIShortMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
    460462{
    461463    jvalue result = callJNIMethodIDA (short_type, obj, methodID, args);
     
    463465}
    464466
    465 jint KJS::Bindings::callJNIIntMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
     467jint callJNIIntMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
    466468{
    467469    jvalue result = callJNIMethodIDA (int_type, obj, methodID, args);
     
    469471}
    470472
    471 jlong KJS::Bindings::callJNILongMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
     473jlong callJNILongMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
    472474{
    473475    jvalue result = callJNIMethodIDA (long_type, obj, methodID, args);
     
    475477}
    476478
    477 jfloat KJS::Bindings::callJNIFloatMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
     479jfloat callJNIFloatMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
    478480{
    479481    jvalue result = callJNIMethodIDA  (float_type, obj, methodID, args);
     
    481483}
    482484
    483 jdouble KJS::Bindings::callJNIDoubleMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
     485jdouble callJNIDoubleMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
    484486{
    485487    jvalue result = callJNIMethodIDA (double_type, obj, methodID, args);
     
    487489}
    488490
    489 jboolean KJS::Bindings::callJNIBooleanMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
     491jboolean callJNIBooleanMethodIDA (jobject obj, jmethodID methodID, jvalue *args)
    490492{
    491493    jvalue result = callJNIMethodIDA (boolean_type, obj, methodID, args);
     
    493495}
    494496
    495 const char *KJS::Bindings::getCharactersFromJString (jstring aJString)
     497const char *getCharactersFromJString (jstring aJString)
    496498{
    497499    return getCharactersFromJStringInEnv (getJNIEnv(), aJString);
    498500}
    499501
    500 void KJS::Bindings::releaseCharactersForJString (jstring aJString, const char *s)
     502void releaseCharactersForJString (jstring aJString, const char *s)
    501503{
    502504    releaseCharactersForJStringInEnv (getJNIEnv(), aJString, s);
    503505}
    504506
    505 const char *KJS::Bindings::getCharactersFromJStringInEnv (JNIEnv *env, jstring aJString)
     507const char *getCharactersFromJStringInEnv (JNIEnv *env, jstring aJString)
    506508{
    507509    jboolean isCopy;
     
    515517}
    516518
    517 void KJS::Bindings::releaseCharactersForJStringInEnv (JNIEnv *env, jstring aJString, const char *s)
     519void releaseCharactersForJStringInEnv (JNIEnv *env, jstring aJString, const char *s)
    518520{
    519521    env->ReleaseStringUTFChars (aJString, s);
    520522}
    521523
    522 const jchar *KJS::Bindings::getUCharactersFromJStringInEnv (JNIEnv *env, jstring aJString)
     524const jchar *getUCharactersFromJStringInEnv (JNIEnv *env, jstring aJString)
    523525{
    524526    jboolean isCopy;
     
    532534}
    533535
    534 void KJS::Bindings::releaseUCharactersForJStringInEnv (JNIEnv *env, jstring aJString, const jchar *s)
     536void releaseUCharactersForJStringInEnv (JNIEnv *env, jstring aJString, const jchar *s)
    535537{
    536538    env->ReleaseStringChars (aJString, s);
    537539}
    538540
    539 JNIType KJS::Bindings::JNITypeFromClassName(const char *name)
     541JNIType JNITypeFromClassName(const char *name)
    540542{
    541543    JNIType type;
     
    565567}
    566568
    567 const char *KJS::Bindings::signatureFromPrimitiveType(JNIType type)
     569const char *signatureFromPrimitiveType(JNIType type)
    568570{
    569571    switch (type){
     
    605607}
    606608
    607 JNIType KJS::Bindings::JNITypeFromPrimitiveType(char type)
     609JNIType JNITypeFromPrimitiveType(char type)
    608610{
    609611    switch (type){
     
    645647}
    646648
    647 jvalue KJS::Bindings::getJNIField( jobject obj, JNIType type, const char *name, const char *signature)
     649jvalue getJNIField( jobject obj, JNIType type, const char *name, const char *signature)
    648650{
    649651    JavaVM *jvm = getJavaVM();
     
    707709}
    708710
    709 jvalue KJS::Bindings::convertValueToJValue (KJS::ExecState *exec, KJS::Value value, JNIType _JNIType, const char *javaClassName)
     711jvalue convertValueToJValue (ExecState *exec, ValueImp *value, JNIType _JNIType, const char *javaClassName)
    710712{
    711713    jvalue result;
     
    716718           
    717719            // First see if we have a Java instance.
    718             if (value.type() == KJS::ObjectType){
    719                 KJS::ObjectImp *objectImp = static_cast<KJS::ObjectImp*>(value.imp());
    720                 if (objectImp->classInfo() == &KJS::RuntimeObjectImp::info) {
    721                     KJS::RuntimeObjectImp *imp = static_cast<KJS::RuntimeObjectImp *>(value.imp());
     720            if (value->isObject()){
     721                ObjectImp *objectImp = static_cast<ObjectImp*>(value);
     722                if (objectImp->classInfo() == &RuntimeObjectImp::info) {
     723                    RuntimeObjectImp *imp = static_cast<RuntimeObjectImp *>(value);
    722724                    JavaInstance *instance = static_cast<JavaInstance*>(imp->getInternalInstance());
    723725                    result.l = instance->javaInstance();
    724726                }
    725                 else if (objectImp->classInfo() == &KJS::RuntimeArrayImp::info) {
    726                     KJS::RuntimeArrayImp *imp = static_cast<KJS::RuntimeArrayImp *>(value.imp());
     727                else if (objectImp->classInfo() == &RuntimeArrayImp::info) {
     728                    RuntimeArrayImp *imp = static_cast<RuntimeArrayImp *>(value);
    727729                    JavaArray *array = static_cast<JavaArray*>(imp->getConcreteArray());
    728730                    result.l = array->javaArray();
     
    734736            if (result.l == 0 && strcmp(javaClassName, "java.lang.String") == 0) {
    735737#if CONVERT_NULL_TO_EMPTY_STRING
    736                 if (value.type() == KJS::NullType) {
     738                if (value->isNull()) {
    737739                    JNIEnv *env = getJNIEnv();
    738740                    jchar buf[2];
     
    742744                else
    743745#else
    744                 if (value.type() != KJS::NullType)
     746                if (!value->isNull())
    745747#endif
    746748                {
    747                     KJS::UString stringValue = value.toString(exec);
     749                    UString stringValue = value->toString(exec);
    748750                    JNIEnv *env = getJNIEnv();
    749751                    jobject javaString = env->functions->NewString (env, (const jchar *)stringValue.data(), stringValue.size());
     
    755757       
    756758        case boolean_type: {
    757             result.z = (jboolean)value.toNumber(exec);
     759            result.z = (jboolean)value->toNumber(exec);
    758760        }
    759761        break;
    760762           
    761763        case byte_type: {
    762             result.b = (jbyte)value.toNumber(exec);
     764            result.b = (jbyte)value->toNumber(exec);
    763765        }
    764766        break;
    765767       
    766768        case char_type: {
    767             result.c = (jchar)value.toNumber(exec);
     769            result.c = (jchar)value->toNumber(exec);
    768770        }
    769771        break;
    770772
    771773        case short_type: {
    772             result.s = (jshort)value.toNumber(exec);
     774            result.s = (jshort)value->toNumber(exec);
    773775        }
    774776        break;
    775777
    776778        case int_type: {
    777             result.i = (jint)value.toNumber(exec);
     779            result.i = (jint)value->toNumber(exec);
    778780        }
    779781        break;
    780782
    781783        case long_type: {
    782             result.j = (jlong)value.toNumber(exec);
     784            result.j = (jlong)value->toNumber(exec);
    783785        }
    784786        break;
    785787
    786788        case float_type: {
    787             result.f = (jfloat)value.toNumber(exec);
     789            result.f = (jfloat)value->toNumber(exec);
    788790        }
    789791        break;
    790792
    791793        case double_type: {
    792             result.d = (jdouble)value.toNumber(exec);
     794            result.d = (jdouble)value->toNumber(exec);
    793795        }
    794796        break;
     
    806808}
    807809
     810}
     811
     812}
  • trunk/JavaScriptCore/bindings/jni/jni_utility.h

    r8201 r10084  
    5252class JavaParameter;
    5353
    54 const char *getCharactersFromJString (jstring aJString);
    55 void releaseCharactersForJString (jstring aJString, const char *s);
     54const char *getCharactersFromJString(jstring aJString);
     55void releaseCharactersForJString(jstring aJString, const char *s);
    5656
    57 const char *getCharactersFromJStringInEnv (JNIEnv *env, jstring aJString);
    58 void releaseCharactersForJStringInEnv (JNIEnv *env, jstring aJString, const char *s);
    59 const jchar *getUCharactersFromJStringInEnv (JNIEnv *env, jstring aJString);
    60 void releaseUCharactersForJStringInEnv (JNIEnv *env, jstring aJString, const jchar *s);
     57const char *getCharactersFromJStringInEnv(JNIEnv *env, jstring aJString);
     58void releaseCharactersForJStringInEnv(JNIEnv *env, jstring aJString, const char *s);
     59const jchar *getUCharactersFromJStringInEnv(JNIEnv *env, jstring aJString);
     60void releaseUCharactersForJStringInEnv(JNIEnv *env, jstring aJString, const jchar *s);
    6161
    6262JNIType JNITypeFromClassName(const char *name);
     
    6464const char *signatureFromPrimitiveType(JNIType type);
    6565
    66 jvalue convertValueToJValue (KJS::ExecState *exec, KJS::Value value, JNIType _JNIType, const char *javaClassName);
     66jvalue convertValueToJValue(ExecState *exec, ValueImp *value, JNIType _JNIType, const char *javaClassName);
    6767
    68 jvalue getJNIField (jobject obj, JNIType type, const char *name, const char *signature);
     68jvalue getJNIField(jobject obj, JNIType type, const char *name, const char *signature);
    6969
    70 jmethodID getMethodID (jobject obj, const char *name, const char *sig);
     70jmethodID getMethodID(jobject obj, const char *name, const char *sig);
    7171
    72 jobject callJNIObjectMethod (jobject obj, const char *name, const char *sig, ... );
    73 void callJNIVoidMethod (jobject obj, const char *name, const char *sig, ... );
    74 jboolean callJNIBooleanMethod (jobject obj, const char *name, const char *sig, ... );
    75 jboolean callJNIStaticBooleanMethod (jclass cls, const char *name, const char *sig, ... );
    76 jbyte callJNIByteMethod (jobject obj, const char *name, const char *sig, ... );
    77 jchar callJNICharMethod (jobject obj, const char *name, const char *sig, ... );
    78 jshort callJNIShortMethod (jobject obj, const char *name, const char *sig, ... );
    79 jint callJNIIntMethod (jobject obj, const char *name, const char *sig, ... );
    80 jlong callJNILongMethod (jobject obj, const char *name, const char *sig, ... );
    81 jfloat callJNIFloatMethod (jobject obj, const char *name, const char *sig, ... );
    82 jdouble callJNIDoubleMethod (jobject obj, const char *name, const char *sig, ... );
     72jobject callJNIObjectMethod(jobject obj, const char *name, const char *sig, ... );
     73void callJNIVoidMethod(jobject obj, const char *name, const char *sig, ... );
     74jboolean callJNIBooleanMethod(jobject obj, const char *name, const char *sig, ... );
     75jboolean callJNIStaticBooleanMethod(jclass cls, const char *name, const char *sig, ... );
     76jbyte callJNIByteMethod(jobject obj, const char *name, const char *sig, ... );
     77jchar callJNICharMethod(jobject obj, const char *name, const char *sig, ... );
     78jshort callJNIShortMethod(jobject obj, const char *name, const char *sig, ... );
     79jint callJNIIntMethod(jobject obj, const char *name, const char *sig, ... );
     80jlong callJNILongMethod(jobject obj, const char *name, const char *sig, ... );
     81jfloat callJNIFloatMethod(jobject obj, const char *name, const char *sig, ... );
     82jdouble callJNIDoubleMethod(jobject obj, const char *name, const char *sig, ... );
    8383
    84 jobject callJNIObjectMethodA (jobject obj, const char *name, const char *sig, jvalue *args);
    85 void callJNIVoidMethodA (jobject obj, const char *name, const char *sig, jvalue *args);
    86 jboolean callJNIBooleanMethodA (jobject obj, const char *name, const char *sig, jvalue *args);
    87 jbyte callJNIByteMethodA (jobject obj, const char *name, const char *sig, jvalue *args);
    88 jchar callJNICharMethodA (jobject obj, const char *name, const char *sig, jvalue *args);
    89 jshort callJNIShortMethodA (jobject obj, const char *name, const char *sig, jvalue *args);
    90 jint callJNIIntMethodA (jobject obj, const char *name, const char *sig, jvalue *args);
    91 jlong callJNILongMethodA (jobject obj, const char *name, const char *sig, jvalue *args);
    92 jfloat callJNIFloatMethodA (jobject obj, const char *name, const char *sig, jvalue *args);
    93 jdouble callJNIDoubleMethodA (jobject obj, const char *name, const char *sig, jvalue *args);
     84jobject callJNIObjectMethodA(jobject obj, const char *name, const char *sig, jvalue *args);
     85void callJNIVoidMethodA(jobject obj, const char *name, const char *sig, jvalue *args);
     86jboolean callJNIBooleanMethodA(jobject obj, const char *name, const char *sig, jvalue *args);
     87jbyte callJNIByteMethodA(jobject obj, const char *name, const char *sig, jvalue *args);
     88jchar callJNICharMethodA(jobject obj, const char *name, const char *sig, jvalue *args);
     89jshort callJNIShortMethodA(jobject obj, const char *name, const char *sig, jvalue *args);
     90jint callJNIIntMethodA(jobject obj, const char *name, const char *sig, jvalue *args);
     91jlong callJNILongMethodA(jobject obj, const char *name, const char *sig, jvalue *args);
     92jfloat callJNIFloatMethodA(jobject obj, const char *name, const char *sig, jvalue *args);
     93jdouble callJNIDoubleMethodA(jobject obj, const char *name, const char *sig, jvalue *args);
    9494
    95 jobject callJNIObjectMethodIDA (jobject obj, jmethodID methodID, jvalue *args);
    96 void callJNIVoidMethodIDA (jobject obj, jmethodID methodID, jvalue *args);
    97 jboolean callJNIBooleanMethodIDA (jobject obj, jmethodID methodID, jvalue *args);
    98 jbyte callJNIByteMethodIDA (jobject obj, jmethodID methodID, jvalue *args);
    99 jchar callJNICharMethodIDA (jobject obj, jmethodID methodID, jvalue *args);
    100 jshort callJNIShortMethodIDA (jobject obj, jmethodID methodID, jvalue *args);
    101 jint callJNIIntMethodIDA (jobject obj, jmethodID methodID, jvalue *args);
    102 jlong callJNILongMethodIDA (jobject obj, jmethodID methodID, jvalue *args);
    103 jfloat callJNIFloatMethodIDA (jobject obj, jmethodID methodID, jvalue *args);
    104 jdouble callJNIDoubleMethodIDA (jobject obj, jmethodID methodID, jvalue *args);
     95jobject callJNIObjectMethodIDA(jobject obj, jmethodID methodID, jvalue *args);
     96void callJNIVoidMethodIDA(jobject obj, jmethodID methodID, jvalue *args);
     97jboolean callJNIBooleanMethodIDA(jobject obj, jmethodID methodID, jvalue *args);
     98jbyte callJNIByteMethodIDA(jobject obj, jmethodID methodID, jvalue *args);
     99jchar callJNICharMethodIDA(jobject obj, jmethodID methodID, jvalue *args);
     100jshort callJNIShortMethodIDA(jobject obj, jmethodID methodID, jvalue *args);
     101jint callJNIIntMethodIDA(jobject obj, jmethodID methodID, jvalue *args);
     102jlong callJNILongMethodIDA(jobject obj, jmethodID methodID, jvalue *args);
     103jfloat callJNIFloatMethodIDA(jobject obj, jmethodID methodID, jvalue *args);
     104jdouble callJNIDoubleMethodIDA(jobject obj, jmethodID methodID, jvalue *args);
    105105
    106106JavaVM *getJavaVM();
    107107JNIEnv *getJNIEnv();
    108108
    109 bool dispatchJNICall (const void *targetAppletView, jobject obj, bool isStatic, JNIType returnType, jmethodID methodID, jvalue *args, jvalue &result, const char *callingURL, Value &exceptionDescription);
     109bool dispatchJNICall(const void *targetAppletView, jobject obj, bool isStatic, JNIType returnType, jmethodID methodID, jvalue *args, jvalue &result, const char *callingURL, ValueImp *&exceptionDescription);
    110110
    111111} // namespace Bindings
  • trunk/JavaScriptCore/bindings/objc/WebScriptObject.mm

    r9549 r10084  
    5050#define LOG_EXCEPTION(exec) \
    5151    if (Interpreter::shouldPrintExceptions()) \
    52         printf("%s:%d:[%d]  JavaScript exception:  %s\n", __FILE__, __LINE__, getpid(), exec->exception().toObject(exec).get(exec, messagePropertyName).toString(exec).ascii());
     52        printf("%s:%d:[%d]  JavaScript exception:  %s\n", __FILE__, __LINE__, getpid(), exec->exception()->toObject(exec)->get(exec, messagePropertyName)->toString(exec).ascii());
    5353
    5454@implementation WebScriptObjectPrivate
     
    6363    KJSDidExecuteFunctionPtr func = Instance::didExecuteFunction();
    6464    if (func)
    65         func (exec, static_cast<KJS::ObjectImp*>([obj _executionContext]->rootObjectImp()));
    66 }
    67 
    68 - (void)_initializeWithObjectImp:(KJS::ObjectImp *)imp originExecutionContext:(const Bindings::RootObject *)originExecutionContext executionContext:(const Bindings::RootObject *)executionContext
     65        func (exec, static_cast<ObjectImp*>([obj _executionContext]->rootObjectImp()));
     66}
     67
     68- (void)_initializeWithObjectImp:(ObjectImp *)imp originExecutionContext:(const Bindings::RootObject *)originExecutionContext executionContext:(const Bindings::RootObject *)executionContext
    6969{
    7070    _private->imp = imp;
     
    7575}
    7676
    77 - _initWithObjectImp:(KJS::ObjectImp *)imp originExecutionContext:(const Bindings::RootObject *)originExecutionContext executionContext:(const Bindings::RootObject *)executionContext
     77- _initWithObjectImp:(ObjectImp *)imp originExecutionContext:(const Bindings::RootObject *)originExecutionContext executionContext:(const Bindings::RootObject *)executionContext
    7878{
    7979    assert (imp != 0);
     
    8989}
    9090
    91 - (KJS::ObjectImp *)_imp
     91- (ObjectImp *)_imp
    9292{
    9393    if (!_private->imp && _private->isCreatedByDOMWrapper) {
     
    9999}
    100100
    101 - (const KJS::Bindings::RootObject *)_executionContext
     101- (const RootObject *)_executionContext
    102102{
    103103    return _private->executionContext;
    104104}
    105105
    106 - (void)_setExecutionContext:(const KJS::Bindings::RootObject *)context
     106- (void)_setExecutionContext:(const RootObject *)context
    107107{
    108108    _private->executionContext = context;
     
    110110
    111111
    112 - (const KJS::Bindings::RootObject *)_originExecutionContext
     112- (const RootObject *)_originExecutionContext
    113113{
    114114    return _private->originExecutionContext;
    115115}
    116116
    117 - (void)_setOriginExecutionContext:(const KJS::Bindings::RootObject *)originExecutionContext
     117- (void)_setOriginExecutionContext:(const RootObject *)originExecutionContext
    118118{
    119119    _private->originExecutionContext = originExecutionContext;
     
    159159        // If the interpreter has a context, we set the exception.
    160160        if (interp->context()) {
    161             Object err = Error::create(exec, GeneralError, [exceptionMessage UTF8String]);
     161            ObjectImp *err = Error::create(exec, GeneralError, [exceptionMessage UTF8String]);
    162162            exec->setException (err);
    163163            return YES;
     
    169169}
    170170
    171 static KJS::List listFromNSArray(ExecState *exec, NSArray *array)
     171static List listFromNSArray(ExecState *exec, NSArray *array)
    172172{
    173173    long i, numObjects = array ? [array count] : 0;
    174     KJS::List aList;
     174    List aList;
    175175   
    176176    for (i = 0; i < numObjects; i++) {
     
    194194    Interpreter::lock();
    195195   
    196     Value v = convertObjcValueToValue(exec, &name, ObjcObjectType);
    197     Identifier identifier(v.toString(exec));
    198     Value func = [self _imp]->get (exec, identifier);
    199     Interpreter::unlock();
    200     if (func.isNull() || func.type() == UndefinedType) {
     196    ValueImp *v = convertObjcValueToValue(exec, &name, ObjcObjectType);
     197    Identifier identifier(v->toString(exec));
     198    ValueImp *func = [self _imp]->get (exec, identifier);
     199    Interpreter::unlock();
     200    if (!func || func->isUndefined()) {
    201201        // Maybe throw an exception here?
    202202        return 0;
     
    205205    // Call the function object.   
    206206    Interpreter::lock();
    207     ObjectImp *funcImp = static_cast<ObjectImp*>(func.imp());
    208     Object thisObj = Object(const_cast<ObjectImp*>([self _imp]));
     207    ObjectImp *funcImp = static_cast<ObjectImp*>(func);
     208    ObjectImp *thisObj = const_cast<ObjectImp*>([self _imp]);
    209209    List argList = listFromNSArray(exec, args);
    210     Value result = funcImp->call (exec, thisObj, argList);
     210    ValueImp *result = funcImp->call (exec, thisObj, argList);
    211211    Interpreter::unlock();
    212212
     
    234234    ExecState *exec = [self _executionContext]->interpreter()->globalExec();
    235235
    236     Object thisObj = Object(const_cast<ObjectImp*>([self _imp]));
    237     Value result;
    238    
    239     Interpreter::lock();
    240    
    241     Value v = convertObjcValueToValue(exec, &script, ObjcObjectType);
    242     Completion completion = [self _executionContext]->interpreter()->evaluate(UString(), 0, v.toString(exec));
     236    ValueImp *result;
     237   
     238    Interpreter::lock();
     239   
     240    ValueImp *v = convertObjcValueToValue(exec, &script, ObjcObjectType);
     241    Completion completion = [self _executionContext]->interpreter()->evaluate(UString(), 0, v->toString(exec));
    243242    ComplType type = completion.complType();
    244243   
    245244    if (type == Normal) {
    246245        result = completion.value();
    247         if (result.isNull()) {
     246        if (!result) {
    248247            result = Undefined();
    249248        }
     
    277276
    278277    Interpreter::lock();
    279     Value v = convertObjcValueToValue(exec, &key, ObjcObjectType);
    280     [self _imp]->put (exec, Identifier (v.toString(exec)), (convertObjcValueToValue(exec, &value, ObjcObjectType)));
     278    ValueImp *v = convertObjcValueToValue(exec, &key, ObjcObjectType);
     279    [self _imp]->put (exec, Identifier (v->toString(exec)), (convertObjcValueToValue(exec, &value, ObjcObjectType)));
    281280    Interpreter::unlock();
    282281
     
    299298
    300299    Interpreter::lock();
    301     Value v = convertObjcValueToValue(exec, &key, ObjcObjectType);
    302     Value result = [self _imp]->get (exec, Identifier (v.toString(exec)));
     300    ValueImp *v = convertObjcValueToValue(exec, &key, ObjcObjectType);
     301    ValueImp *result = [self _imp]->get (exec, Identifier (v->toString(exec)));
    303302    Interpreter::unlock();
    304303   
     
    326325
    327326    Interpreter::lock();
    328     Value v = convertObjcValueToValue(exec, &key, ObjcObjectType);
    329     [self _imp]->deleteProperty (exec, Identifier (v.toString(exec)));
     327    ValueImp *v = convertObjcValueToValue(exec, &key, ObjcObjectType);
     328    [self _imp]->deleteProperty (exec, Identifier (v->toString(exec)));
    330329    Interpreter::unlock();
    331330
     
    344343
    345344    Interpreter::lock();
    346     Object thisObj = Object(const_cast<ObjectImp*>([self _imp]));
     345    ObjectImp *thisObj = const_cast<ObjectImp*>([self _imp]);
    347346    ExecState *exec = [self _executionContext]->interpreter()->globalExec();
    348347   
     
    368367    ExecState *exec = [self _executionContext]->interpreter()->globalExec();
    369368    Interpreter::lock();
    370     Value result = [self _imp]->get (exec, (unsigned)index);
     369    ValueImp *result = [self _imp]->get (exec, (unsigned)index);
    371370    Interpreter::unlock();
    372371
     
    409408
    410409    ExecState *exec = [self _executionContext]->interpreter()->globalExec();
    411     Object err = Error::create(exec, GeneralError, [description UTF8String]);
     410    ObjectImp *err = Error::create(exec, GeneralError, [description UTF8String]);
    412411    exec->setException (err);
    413412}
    414413
    415 + (id)_convertValueToObjcValue:(KJS::Value)value originExecutionContext:(const Bindings::RootObject *)originExecutionContext executionContext:(const Bindings::RootObject *)executionContext
     414+ (id)_convertValueToObjcValue:(ValueImp *)value originExecutionContext:(const RootObject *)originExecutionContext executionContext:(const Bindings::RootObject *)executionContext
    416415{
    417416    id result = 0;
    418417
    419418    // First see if we have a ObjC instance.
    420     if (value.type() == KJS::ObjectType){
    421         ObjectImp *objectImp = static_cast<ObjectImp*>(value.imp());
     419    if (value->isObject()) {
     420        ObjectImp *objectImp = static_cast<ObjectImp*>(value);
    422421        Interpreter *intepreter = executionContext->interpreter();
    423422        ExecState *exec = intepreter->globalExec();
    424423        Interpreter::lock();
    425424       
    426         if (objectImp->classInfo() != &KJS::RuntimeObjectImp::info) {
    427             Value runtimeObject = objectImp->get(exec, "__apple_runtime_object");
    428             if (!runtimeObject.isNull() && runtimeObject.type() == KJS::ObjectType)
    429                 objectImp = static_cast<RuntimeObjectImp*>(runtimeObject.imp());
     425        if (objectImp->classInfo() != &RuntimeObjectImp::info) {
     426            ValueImp *runtimeObject = objectImp->get(exec, "__apple_runtime_object");
     427            if (!runtimeObject && runtimeObject->isObject())
     428                objectImp = static_cast<RuntimeObjectImp*>(runtimeObject);
    430429        }
    431430       
    432431        Interpreter::unlock();
    433432
    434         if (objectImp->classInfo() == &KJS::RuntimeObjectImp::info) {
     433        if (objectImp->classInfo() == &RuntimeObjectImp::info) {
    435434            RuntimeObjectImp *imp = static_cast<RuntimeObjectImp *>(objectImp);
    436435            ObjcInstance *instance = static_cast<ObjcInstance*>(imp->getInternalInstance());
     
    440439        // Convert to a WebScriptObject
    441440        else {
    442             result = (id)intepreter->createLanguageInstanceForValue (exec, Instance::ObjectiveCLanguage, value.toObject(exec), originExecutionContext, executionContext);
     441            result = (id)intepreter->createLanguageInstanceForValue (exec, Instance::ObjectiveCLanguage, value->toObject(exec), originExecutionContext, executionContext);
    443442        }
    444443    }
    445444   
    446445    // Convert JavaScript String value to NSString?
    447     else if (value.type() == KJS::StringType) {
    448         StringImp *s = static_cast<KJS::StringImp*>(value.imp());
     446    else if (value->isString()) {
     447        StringImp *s = static_cast<StringImp*>(value);
    449448        UString u = s->value();
    450449       
     
    454453   
    455454    // Convert JavaScript Number value to NSNumber?
    456     else if (value.type() == KJS::NumberType) {
    457         Number n = Number::dynamicCast(value);
    458         result = [NSNumber numberWithDouble:n.value()];
    459     }
    460    
    461     else if (value.type() == KJS::BooleanType) {
    462         KJS::BooleanImp *b = static_cast<KJS::BooleanImp*>(value.imp());
     455    else if (value->isNumber()) {
     456        result = [NSNumber numberWithDouble:value->getNumber()];
     457    }
     458   
     459    else if (value->isBoolean()) {
     460        BooleanImp *b = static_cast<BooleanImp*>(value);
    463461        result = [NSNumber numberWithBool:b->value()];
    464462    }
    465463   
    466464    // Convert JavaScript Undefined types to WebUndefined
    467     else if (value.type() == KJS::UndefinedType) {
     465    else if (value->isUndefined()) {
    468466        result = [WebUndefined undefined];
    469467    }
  • trunk/JavaScriptCore/bindings/objc/WebScriptObjectPrivate.h

    r8585 r10084  
    1414
    1515@interface WebScriptObject (Private)
    16 + (id)_convertValueToObjcValue:(KJS::Value)value originExecutionContext:(const KJS::Bindings::RootObject *)originExecutionContext executionContext:(const KJS::Bindings::RootObject *)executionContext;
     16+ (id)_convertValueToObjcValue:(KJS::ValueImp *)value originExecutionContext:(const KJS::Bindings::RootObject *)originExecutionContext executionContext:(const KJS::Bindings::RootObject *)executionContext;
    1717- _init;
    1818- _initWithObjectImp:(KJS::ObjectImp *)imp originExecutionContext:(const KJS::Bindings::RootObject *)originExecutionContext executionContext:(const KJS::Bindings::RootObject *)executionContext ;
  • trunk/JavaScriptCore/bindings/objc/objc_class.h

    r7742 r10084  
    7878    virtual Field *fieldNamed(const char *name, Instance *instance) const;
    7979
    80     virtual Value fallbackObject(ExecState *exec, Instance *instance, const Identifier &propertyName);
     80    virtual ValueImp *fallbackObject(ExecState *exec, Instance *instance, const Identifier &propertyName);
    8181   
    8282    virtual Constructor *constructorAt(long i) const {
  • trunk/JavaScriptCore/bindings/objc/objc_class.mm

    r10028 r10084  
    3131#include <WebScriptObject.h>
    3232
    33 using namespace KJS::Bindings;
     33namespace KJS {
     34namespace Bindings {
    3435
    3536void ObjcClass::_commonDelete() {
     
    233234}
    234235
    235 KJS::Value ObjcClass::fallbackObject (ExecState *exec, Instance *instance, const Identifier &propertyName)
    236 {
    237     return Object (new ObjcFallbackObjectImp(static_cast<ObjcInstance*>(instance), propertyName));
    238 }
     236ValueImp *ObjcClass::fallbackObject (ExecState *exec, Instance *instance, const Identifier &propertyName)
     237{
     238    return new ObjcFallbackObjectImp(static_cast<ObjcInstance*>(instance), propertyName);
     239}
     240
     241}
     242}
  • trunk/JavaScriptCore/bindings/objc/objc_instance.h

    r8400 r10084  
    5454    virtual void end();
    5555   
    56     virtual Value valueOf() const;
    57     virtual Value defaultValue (Type hint) const;
     56    virtual ValueImp *valueOf() const;
     57    virtual ValueImp *defaultValue (Type hint) const;
    5858
    59     virtual Value invokeMethod (ExecState *exec, const MethodList &method, const List &args);
    60     virtual Value invokeDefaultMethod (ExecState *exec, const List &args);
     59    virtual ValueImp *invokeMethod (ExecState *exec, const MethodList &method, const List &args);
     60    virtual ValueImp *invokeDefaultMethod (ExecState *exec, const List &args);
    6161
    62     virtual void setValueOfField (ExecState *exec, const Field *aField, const Value &aValue) const;
     62    virtual void setValueOfField (ExecState *exec, const Field *aField, ValueImp *aValue) const;
    6363    virtual bool supportsSetValueOfUndefinedField ();
    64     virtual void setValueOfUndefinedField (ExecState *exec, const Identifier &property, const Value &aValue);
     64    virtual void setValueOfUndefinedField (ExecState *exec, const Identifier &property, ValueImp *aValue);
    6565   
    66     virtual Value ObjcInstance::getValueOfField (ExecState *exec, const Field *aField) const;
    67     virtual Value getValueOfUndefinedField (ExecState *exec, const Identifier &property, Type hint) const;
     66    virtual ValueImp *ObjcInstance::getValueOfField (ExecState *exec, const Field *aField) const;
     67    virtual ValueImp *getValueOfUndefinedField (ExecState *exec, const Identifier &property, Type hint) const;
    6868
    6969    ObjectStructPtr getObject() const { return _instance; }
    7070   
    71     Value stringValue() const;
    72     Value numberValue() const;
    73     Value booleanValue() const;
     71    ValueImp *stringValue() const;
     72    ValueImp *numberValue() const;
     73    ValueImp *booleanValue() const;
    7474   
    7575private:
  • trunk/JavaScriptCore/bindings/objc/objc_instance.mm

    r8400 r10084  
    123123}
    124124
    125 Value ObjcInstance::invokeMethod (KJS::ExecState *exec, const MethodList &methodList, const List &args)
    126 {
    127     Value resultValue;
     125ValueImp *ObjcInstance::invokeMethod (ExecState *exec, const MethodList &methodList, const List &args)
     126{
     127    ValueImp *resultValue;
    128128
    129129    // Overloading methods is not allowed in ObjectiveC.  Should only be one
     
    222222    assert (objcValueType != ObjcInvalidType);
    223223   
    224     // Get the return value and convert it to a KJS::Value. Length
     224    // Get the return value and convert it to a JavaScript value. Length
    225225    // of return value will never exceed the size of largest scalar
    226226    // or a pointer.
     
    245245}
    246246
    247 Value ObjcInstance::invokeDefaultMethod (KJS::ExecState *exec, const List &args)
    248 {
    249     Value resultValue;
     247ValueImp *ObjcInstance::invokeDefaultMethod (ExecState *exec, const List &args)
     248{
     249    ValueImp *resultValue;
    250250   
    251251NS_DURING
     
    282282    ObjcValueType objcValueType = objcValueTypeForType (type);
    283283   
    284     // Get the return value and convert it to a KJS::Value. Length
     284    // Get the return value and convert it to a JavaScript value. Length
    285285    // of return value will never exceed the size of a pointer, so we're
    286     // OK we 32 here.
     286    // OK with 32 here.
    287287    char buffer[32];
    288288    [invocation getReturnValue:buffer];
     
    298298}
    299299
    300 void ObjcInstance::setValueOfField (KJS::ExecState *exec, const Field *aField, const KJS::Value &aValue) const
     300void ObjcInstance::setValueOfField (ExecState *exec, const Field *aField, ValueImp *aValue) const
    301301{
    302302    aField->setValueToInstance (exec, this, aValue);
     
    313313}
    314314
    315 void ObjcInstance::setValueOfUndefinedField (KJS::ExecState *exec, const KJS::Identifier &property, const KJS::Value &aValue)
     315void ObjcInstance::setValueOfUndefinedField (ExecState *exec, const Identifier &property, ValueImp *aValue)
    316316{
    317317    id targetObject = getObject();
     
    336336}
    337337
    338 Value ObjcInstance::getValueOfField (KJS::ExecState *exec, const Field *aField) const { 
     338ValueImp *ObjcInstance::getValueOfField (ExecState *exec, const Field *aField) const { 
    339339    return aField->valueFromInstance (exec, this);
    340340}
    341341
    342 KJS::Value ObjcInstance::getValueOfUndefinedField (KJS::ExecState *exec, const KJS::Identifier &property, KJS::Type hint) const
    343 {
    344     Value result = Undefined();
     342ValueImp *ObjcInstance::getValueOfUndefinedField (ExecState *exec, const Identifier &property, Type hint) const
     343{
     344    ValueImp *volatile result = Undefined();
    345345   
    346346    id targetObject = getObject();
     
    368368}
    369369
    370 KJS::Value ObjcInstance::defaultValue (KJS::Type hint) const
    371 {
    372     if (hint == KJS::StringType) {
     370ValueImp *ObjcInstance::defaultValue (Type hint) const
     371{
     372    if (hint == StringType) {
    373373        return stringValue();
    374374    }
    375     else if (hint == KJS::NumberType) {
     375    else if (hint == NumberType) {
    376376        return numberValue();
    377377    }
    378     else if (hint == KJS::BooleanType) {
     378    else if (hint == BooleanType) {
    379379        return booleanValue();
    380380    }
    381     else if (hint == KJS::UnspecifiedType) {
     381    else if (hint == UnspecifiedType) {
    382382        if ([_instance isKindOfClass:[NSString class]]) {
    383383            return stringValue();
     
    394394}
    395395
    396 KJS::Value ObjcInstance::stringValue() const
     396ValueImp *ObjcInstance::stringValue() const
    397397{
    398398    return convertNSStringToString ([getObject() description]);
    399399}
    400400
    401 KJS::Value ObjcInstance::numberValue() const
     401ValueImp *ObjcInstance::numberValue() const
    402402{
    403403    // FIXME:  Implement something sensible
    404     KJS::Number v(0);
    405     return v;
    406 }
    407 
    408 KJS::Value ObjcInstance::booleanValue() const
     404    return jsNumber(0);
     405}
     406
     407ValueImp *ObjcInstance::booleanValue() const
    409408{
    410409    // FIXME:  Implement something sensible
    411     KJS::Boolean v((bool)0);
    412     return v;
    413 }
    414 
    415 KJS::Value ObjcInstance::valueOf() const
     410    return jsBoolean(false);
     411}
     412
     413ValueImp *ObjcInstance::valueOf() const
    416414{
    417415    return stringValue();
  • trunk/JavaScriptCore/bindings/objc/objc_runtime.h

    r10076 r10084  
    3535namespace KJS
    3636{
    37 class Value;
    3837
    3938namespace Bindings
     
    8584    };
    8685       
    87     virtual KJS::Value valueFromInstance(KJS::ExecState *exec, const Instance *instance) const;
    88     virtual void setValueToInstance(KJS::ExecState *exec, const Instance *instance, const KJS::Value &aValue) const;
     86    virtual ValueImp *valueFromInstance(ExecState *exec, const Instance *instance) const;
     87    virtual void setValueToInstance(ExecState *exec, const Instance *instance, ValueImp *aValue) const;
    8988   
    9089    virtual const char *name() const;
     
    148147    ObjcArray &operator=(const ObjcArray &other);
    149148   
    150     virtual void setValueAt(KJS::ExecState *exec, unsigned int index, const KJS::Value &aValue) const;
    151     virtual KJS::Value valueAt(KJS::ExecState *exec, unsigned int index) const;
     149    virtual void setValueAt(ExecState *exec, unsigned int index, ValueImp *aValue) const;
     150    virtual ValueImp *valueAt(ExecState *exec, unsigned int index) const;
    152151    virtual unsigned int getLength() const;
    153152   
     
    156155    ObjectStructPtr getObjcArray() const { return _array; }
    157156
    158     static KJS::Value convertObjcArrayToArray (KJS::ExecState *exec, ObjectStructPtr anObject);
     157    static ValueImp *convertObjcArrayToArray (ExecState *exec, ObjectStructPtr anObject);
    159158
    160159private:
     
    162161};
    163162
    164 class ObjcFallbackObjectImp : public KJS::ObjectImp {
     163class ObjcFallbackObjectImp : public ObjectImp {
    165164public:
    166165    ObjcFallbackObjectImp(ObjectImp *proto);
    167166       
    168     ObjcFallbackObjectImp(ObjcInstance *i, const KJS::Identifier propertyName);
     167    ObjcFallbackObjectImp(ObjcInstance *i, const Identifier propertyName);
    169168
    170169    const ClassInfo *classInfo() const { return &info; }
     
    173172
    174173    virtual void put(ExecState *exec, const Identifier &propertyName,
    175                      const Value &value, int attr = None);
     174                     ValueImp *value, int attr = None);
    176175
    177176    virtual bool canPut(ExecState *exec, const Identifier &propertyName) const;
    178177
    179178    virtual bool implementsCall() const;
    180     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     179    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    181180
    182181    virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
    183182
    184     virtual Value defaultValue(ExecState *exec, Type hint) const;
     183    virtual ValueImp *defaultValue(ExecState *exec, Type hint) const;
    185184
    186185    virtual Type type() const;
     
    191190
    192191    ObjcInstance *_instance;
    193     KJS::Identifier _item;
     192    Identifier _item;
    194193};
    195194
  • trunk/JavaScriptCore/bindings/objc/objc_runtime.mm

    r10076 r10084  
    103103}
    104104
    105 Value ObjcField::valueFromInstance(KJS::ExecState *exec, const Instance *instance) const
    106 {
    107     Value aValue;
     105ValueImp *ObjcField::valueFromInstance(ExecState *exec, const Instance *instance) const
     106{
     107    ValueImp *aValue;
    108108    id targetObject = (static_cast<const ObjcInstance*>(instance))->getObject();
    109109    id objcValue = nil;
     
    116116    NS_HANDLER
    117117       
    118         Value exceptionValue = Error::create(exec, GeneralError, [[localException reason] lossyCString]);
     118        ValueImp *exceptionValue = Error::create(exec, GeneralError, [[localException reason] lossyCString]);
    119119        exec->setException(exceptionValue);
    120120       
     
    129129}
    130130
    131 static id convertValueToObjcObject (KJS::ExecState *exec, const KJS::Value &value)
     131static id convertValueToObjcObject (ExecState *exec, ValueImp *value)
    132132{
    133133    const Bindings::RootObject *root = rootForInterpreter(exec->interpreter());
    134134    if (!root) {
    135         Bindings::RootObject *newRoot = new KJS::Bindings::RootObject(0);
     135        Bindings::RootObject *newRoot = new Bindings::RootObject(0);
    136136        newRoot->setInterpreter (exec->interpreter());
    137137        root = newRoot;
     
    141141
    142142
    143 void ObjcField::setValueToInstance(KJS::ExecState *exec, const Instance *instance, const KJS::Value &aValue) const
     143void ObjcField::setValueToInstance(ExecState *exec, const Instance *instance, ValueImp *aValue) const
    144144{
    145145    id targetObject = (static_cast<const ObjcInstance*>(instance))->getObject();
     
    153153    NS_HANDLER
    154154       
    155         Value aValue = Error::create(exec, GeneralError, [[localException reason] lossyCString]);
     155        ValueImp *aValue = Error::create(exec, GeneralError, [[localException reason] lossyCString]);
    156156        exec->setException(aValue);
    157157       
     
    187187}
    188188
    189 void ObjcArray::setValueAt(KJS::ExecState *exec, unsigned int index, const KJS::Value &aValue) const
     189void ObjcArray::setValueAt(ExecState *exec, unsigned int index, ValueImp *aValue) const
    190190{
    191191    if (![_array respondsToSelector:@selector(insertObject:atIndex:)]) {
    192         Object error = Error::create(exec, TypeError, "Array is not mutable.");
     192        ObjectImp *error = Error::create(exec, TypeError, "Array is not mutable.");
    193193        exec->setException(error);
    194194        return;
     
    196196
    197197    if (index > [_array count]) {
    198         Object error = Error::create(exec, RangeError, "Index exceeds array size.");
     198        ObjectImp *error = Error::create(exec, RangeError, "Index exceeds array size.");
    199199        exec->setException(error);
    200200        return;
     
    211211NS_HANDLER
    212212   
    213     Object error = Error::create(exec, GeneralError, "ObjectiveC exception.");
     213    ObjectImp *error = Error::create(exec, GeneralError, "ObjectiveC exception.");
    214214    exec->setException(error);
    215215   
     
    218218
    219219
    220 KJS::Value ObjcArray::valueAt(KJS::ExecState *exec, unsigned int index) const
    221 {
    222     ObjectStructPtr obj = 0;
    223     Object error;
    224     volatile bool haveError = false;
    225    
     220ValueImp *ObjcArray::valueAt(ExecState *exec, unsigned int index) const
     221{
    226222    if (index > [_array count]) {
    227         Object error = Error::create(exec, RangeError, "Index exceeds array size.");
     223        ObjectImp *error = Error::create(exec, RangeError, "Index exceeds array size.");
    228224        exec->setException(error);
    229225        return error;
    230226    }
    231227   
     228    ObjectStructPtr obj = 0;
     229    ObjectImp * volatile error;
     230    volatile bool haveError = false;
     231
    232232NS_DURING
    233233
     
    236236NS_HANDLER
    237237   
    238     Object error = Error::create(exec, GeneralError, "ObjectiveC exception.");
     238    error = Error::create(exec, GeneralError, "ObjectiveC exception.");
    239239    exec->setException(error);
    240240    haveError = true;
     
    276276
    277277void ObjcFallbackObjectImp::put(ExecState *exec, const Identifier &propertyName,
    278                  const Value &value, int attr)
     278                 ValueImp *value, int attr)
    279279{
    280280}
     
    306306}
    307307
    308 Value ObjcFallbackObjectImp::call(ExecState *exec, Object &thisObj, const List &args)
    309 {
    310     Value result = Undefined();
    311    
    312     RuntimeObjectImp *imp = static_cast<RuntimeObjectImp*>(thisObj.imp());
     308ValueImp *ObjcFallbackObjectImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
     309{
     310    ValueImp *result = Undefined();
     311   
     312    RuntimeObjectImp *imp = static_cast<RuntimeObjectImp*>(thisObj);
    313313    if (imp) {
    314314        Instance *instance = imp->getInternalInstance();
     
    341341}
    342342
    343 Value ObjcFallbackObjectImp::defaultValue(ExecState *exec, Type hint) const
     343ValueImp *ObjcFallbackObjectImp::defaultValue(ExecState *exec, Type hint) const
    344344{
    345345    return _instance->getValueOfUndefinedField(exec, _item, hint);
  • trunk/JavaScriptCore/bindings/objc/objc_utility.h

    r8585 r10084  
    6969class RootObject;
    7070
    71 ObjcValue convertValueToObjcValue (KJS::ExecState *exec, const KJS::Value &value, ObjcValueType type);
    72 Value convertNSStringToString(NSString *nsstring);
    73 Value convertObjcValueToValue (KJS::ExecState *exec, void *buffer, ObjcValueType type);
    74 ObjcValueType objcValueTypeForType (const char *type);
     71ObjcValue convertValueToObjcValue(ExecState *exec, ValueImp *value, ObjcValueType type);
     72ValueImp *convertNSStringToString(NSString *nsstring);
     73ValueImp *convertObjcValueToValue(ExecState *exec, void *buffer, ObjcValueType type);
     74ObjcValueType objcValueTypeForType(const char *type);
    7575
    7676void JSMethodNameToObjCMethodName(const char *name, char *name, unsigned int length);
    7777
    78 void *createObjcInstanceForValue (const Object &value, const RootObject *origin, const RootObject *current);
     78void *createObjcInstanceForValue(ObjectImp *value, const RootObject *origin, const RootObject *current);
    7979
    8080} // namespace Bindings
  • trunk/JavaScriptCore/bindings/objc/objc_utility.mm

    r9078 r10084  
    5151    @result Returns the name to be used to represent the specificed selector in the
    5252*/
    53 void KJS::Bindings::JSMethodNameToObjCMethodName(const char *name, char *buffer, unsigned int len)
     53void Bindings::JSMethodNameToObjCMethodName(const char *name, char *buffer, unsigned int len)
    5454{
    5555    const char *np = name;
     
    8888
    8989*/
    90 ObjcValue KJS::Bindings::convertValueToObjcValue (KJS::ExecState *exec, const KJS::Value &value, ObjcValueType type)
     90ObjcValue Bindings::convertValueToObjcValue (ExecState *exec, ValueImp *value, ObjcValueType type)
    9191{
    9292    ObjcValue result;
    9393    double d = 0;
    94    
    95     if (value.type() == NumberType || value.type() == StringType || value.type() == BooleanType)
    96         d = value.toNumber(exec);
     94
     95    if (value->isNumber() || value->isString() || value->isBoolean())
     96        d = value->toNumber(exec);
    9797       
    9898    switch (type){
    9999        case ObjcObjectType: {
    100             KJS::Interpreter *originInterpreter = exec->interpreter();
     100            Interpreter *originInterpreter = exec->interpreter();
    101101            const Bindings::RootObject *originExecutionContext = rootForInterpreter(originInterpreter);
    102102
    103             KJS::Interpreter *interpreter = 0;
     103            Interpreter *interpreter = 0;
    104104            if (originInterpreter->isGlobalObject(value)) {
    105                 interpreter = originInterpreter->interpreterForGlobalObject (value.imp());
     105                interpreter = originInterpreter->interpreterForGlobalObject (value);
    106106            }
    107107
     
    111111            const Bindings::RootObject *executionContext = rootForInterpreter(interpreter);
    112112            if (!executionContext) {
    113                 Bindings::RootObject *newExecutionContext = new KJS::Bindings::RootObject(0);
     113                Bindings::RootObject *newExecutionContext = new Bindings::RootObject(0);
    114114                newExecutionContext->setInterpreter (interpreter);
    115115                executionContext = newExecutionContext;
     
    165165}
    166166
    167 Value KJS::Bindings::convertNSStringToString(NSString *nsstring)
     167ValueImp *Bindings::convertNSStringToString(NSString *nsstring)
    168168{
    169169    unichar *chars;
     
    171171    chars = (unichar *)malloc(sizeof(unichar)*length);
    172172    [nsstring getCharacters:chars];
    173     UString u((const KJS::UChar*)chars, length);
    174     Value aValue = String (u);
     173    UString u((const UChar*)chars, length);
     174    ValueImp *aValue = String (u);
    175175    free((void *)chars);
    176176    return aValue;
     
    193193
    194194*/
    195 Value KJS::Bindings::convertObjcValueToValue (KJS::ExecState *exec, void *buffer, ObjcValueType type)
    196 {
    197     Value aValue;
     195ValueImp *Bindings::convertObjcValueToValue (ExecState *exec, void *buffer, ObjcValueType type)
     196{
     197    ValueImp *aValue = NULL;
    198198
    199199    switch (type) {
     
    225225                }
    226226                else if ([*obj isKindOfClass:[NSArray class]]) {
    227                     aValue = Object(new RuntimeArrayImp(exec, new ObjcArray (*obj)));
     227                    aValue = new RuntimeArrayImp(exec, new ObjcArray (*obj));
    228228                }
    229229                else if ([*obj isKindOfClass:[WebScriptObject class]]) {
    230230                    WebScriptObject *jsobject = (WebScriptObject *)*obj;
    231                     aValue = Object([jsobject _imp]);
     231                    aValue = [jsobject _imp];
    232232                }
    233233                else if (*obj == 0) {
     
    287287
    288288
    289 ObjcValueType KJS::Bindings::objcValueTypeForType (const char *type)
     289ObjcValueType Bindings::objcValueTypeForType (const char *type)
    290290{
    291291    int typeLength = strlen(type);
     
    333333
    334334
    335 void *KJS::Bindings::createObjcInstanceForValue (const Object &value, const RootObject *origin, const RootObject *current)
    336 {
    337     if (value.type() != ObjectType)
     335void *Bindings::createObjcInstanceForValue (ObjectImp *value, const RootObject *origin, const RootObject *current)
     336{
     337    if (!value->isObject())
    338338        return 0;
    339339
    340     ObjectImp *imp = static_cast<ObjectImp*>(value.imp());
     340    ObjectImp *imp = static_cast<ObjectImp*>(value);
    341341   
    342342    return [[[WebScriptObject alloc] _initWithObjectImp:imp originExecutionContext:origin executionContext:current] autorelease];
  • trunk/JavaScriptCore/bindings/runtime.cpp

    r8585 r10084  
    9292KJSDidExecuteFunctionPtr Instance::didExecuteFunction () { return _DidExecuteFunction; }
    9393
    94 Value Instance::getValueOfField (KJS::ExecState *exec, const Field *aField) const { 
     94ValueImp *Instance::getValueOfField (KJS::ExecState *exec, const Field *aField) const { 
    9595    return aField->valueFromInstance (exec, this);
    9696}
    9797
    98 void Instance::setValueOfField (KJS::ExecState *exec, const Field *aField, const Value &aValue) const { 
     98void Instance::setValueOfField (KJS::ExecState *exec, const Field *aField, ValueImp *aValue) const { 
    9999    aField->setValueToInstance (exec, this, aValue);
    100100}
     
    127127}
    128128
    129 Object Instance::createRuntimeObject (BindingLanguage language, void *nativeInstance, const RootObject *executionContext)
     129ObjectImp *Instance::createRuntimeObject (BindingLanguage language, void *nativeInstance, const RootObject *executionContext)
    130130{
    131131    Instance *interfaceObject = Instance::createBindingForLanguageInstance (language, (void *)nativeInstance, executionContext);
    132132   
    133133    Interpreter::lock();
    134     Object theObject(new RuntimeObjectImp(interfaceObject,true));
     134    ObjectImp *theObject(new RuntimeObjectImp(interfaceObject,true));
    135135    Interpreter::unlock();
    136136   
     
    138138}
    139139
    140 void *Instance::createLanguageInstanceForValue (ExecState *exec, BindingLanguage language, const Object &value, const RootObject *origin, const RootObject *current)
     140void *Instance::createLanguageInstanceForValue (ExecState *exec, BindingLanguage language, ObjectImp *value, const RootObject *origin, const RootObject *current)
    141141{
    142142    void *result = 0;
    143143   
    144     if (value.type() != ObjectType)
     144    if (!value->isObject())
    145145        return 0;
    146146
    147     ObjectImp *imp = static_cast<ObjectImp*>(value.imp());
     147    ObjectImp *imp = static_cast<ObjectImp*>(value);
    148148   
    149149    switch (language) {
  • trunk/JavaScriptCore/bindings/runtime.h

    r8585 r10084  
    6060    virtual long numParameters() const = 0;
    6161
    62     virtual ~Constructor() {};
     62    virtual ~Constructor() {}
    6363};
    6464
     
    6969    virtual RuntimeType type() const = 0;
    7070
    71     virtual KJS::Value valueFromInstance(ExecState *exec, const Instance *instance) const = 0;
    72     virtual void setValueToInstance(ExecState *exec, const Instance *instance, const Value &aValue) const = 0;
     71    virtual ValueImp *valueFromInstance(ExecState *, const Instance *) const = 0;
     72    virtual void setValueToInstance(ExecState *, const Instance *, ValueImp *) const = 0;
    7373
    74     virtual ~Field() {};
     74    virtual ~Field() {}
    7575};
    7676
     
    7979{
    8080public:
    81     MethodList() : _methods(0), _length(0) {};
     81    MethodList() : _methods(0), _length(0) {}
    8282   
    83     void addMethod (Method *aMethod);
     83    void addMethod(Method *aMethod);
    8484    unsigned int length() const;
    85     Method *methodAt (unsigned int index) const;
     85    Method *methodAt(unsigned int index) const;
    8686   
    8787    ~MethodList();
    8888   
    89     MethodList (const MethodList &other);
     89    MethodList(const MethodList &other);
    9090    MethodList &operator=(const MethodList &other);
    9191
     
    118118    virtual Field *fieldNamed(const char *name, Instance *instance) const = 0;
    119119
    120     virtual Value fallbackObject(ExecState *exec, Bindings::Instance *instance, const Identifier &propertyName) { return Undefined(); }
     120    virtual ValueImp *fallbackObject(ExecState *, Instance *, const Identifier &) { return Undefined(); }
    121121   
    122     virtual ~Class() {};
     122    virtual ~Class() {}
    123123};
    124124
     
    134134    } BindingLanguage;
    135135
    136     static void setDidExecuteFunction (KJSDidExecuteFunctionPtr func);
    137     static KJSDidExecuteFunctionPtr didExecuteFunction ();
     136    static void setDidExecuteFunction(KJSDidExecuteFunctionPtr func);
     137    static KJSDidExecuteFunctionPtr didExecuteFunction();
    138138   
    139     static Instance *createBindingForLanguageInstance (BindingLanguage language, void *nativeInstance, const RootObject *r = 0);
    140     static void *createLanguageInstanceForValue (ExecState *exec, BindingLanguage language, const Object &value, const RootObject *origin, const RootObject *current);
    141     static Object createRuntimeObject (BindingLanguage language, void *nativeInstance, const RootObject *r = 0);
     139    static Instance *createBindingForLanguageInstance(BindingLanguage language, void *nativeInstance, const RootObject *r = 0);
     140    static void *createLanguageInstanceForValue(ExecState *exec, BindingLanguage language, ObjectImp *value, const RootObject *origin, const RootObject *current);
     141    static ObjectImp *createRuntimeObject(BindingLanguage language, void *nativeInstance, const RootObject *r = 0);
    142142
    143     Instance () : _executionContext(0) {};
     143    Instance() : _executionContext(0) {};
    144144   
    145     Instance (const Instance &other);
     145    Instance(const Instance &other);
    146146
    147147    Instance &operator=(const Instance &other);
     
    155155    virtual Class *getClass() const = 0;
    156156   
    157     virtual Value getValueOfField (ExecState *exec, const Field *aField) const;
    158     virtual Value getValueOfUndefinedField (ExecState *exec, const Identifier &property, Type hint) const { return Undefined(); };
    159     virtual void setValueOfField (ExecState *exec, const Field *aField, const Value &aValue) const;
    160     virtual bool supportsSetValueOfUndefinedField () { return false; };
    161     virtual void setValueOfUndefinedField (ExecState *exec, const Identifier &property, const Value &aValue) {};
     157    virtual ValueImp *getValueOfField(ExecState *exec, const Field *aField) const;
     158    virtual ValueImp *getValueOfUndefinedField(ExecState *exec, const Identifier &property, Type hint) const { return Undefined(); };
     159    virtual void setValueOfField(ExecState *exec, const Field *aField, ValueImp *aValue) const;
     160    virtual bool supportsSetValueOfUndefinedField() { return false; };
     161    virtual void setValueOfUndefinedField(ExecState *exec, const Identifier &property, ValueImp *aValue) {};
    162162   
    163     virtual Value invokeMethod (ExecState *exec, const MethodList &method, const List &args) = 0;
    164     virtual Value invokeDefaultMethod (ExecState *exec, const List &args) = 0;
     163    virtual ValueImp *invokeMethod(ExecState *exec, const MethodList &method, const List &args) = 0;
     164    virtual ValueImp *invokeDefaultMethod(ExecState *exec, const List &args) = 0;
    165165   
    166     virtual Value defaultValue (Type hint) const = 0;
     166    virtual ValueImp *defaultValue(Type hint) const = 0;
    167167   
    168     virtual Value valueOf() const { return String(getClass()->name()); };
     168    virtual ValueImp *valueOf() const { return String(getClass()->name()); };
    169169   
    170     void setExecutionContext (const RootObject *r) { _executionContext = r; }
     170    void setExecutionContext(const RootObject *r) { _executionContext = r; }
    171171    const RootObject *executionContext() const { return _executionContext; }
    172172   
    173     virtual ~Instance() {};
     173    virtual ~Instance() {}
    174174
    175175protected:
     
    180180{
    181181public:
    182     virtual void setValueAt(ExecState *exec, unsigned int index, const Value &aValue) const = 0;
    183     virtual Value valueAt(ExecState *exec, unsigned int index) const = 0;
     182    virtual void setValueAt(ExecState *, unsigned index, ValueImp *) const = 0;
     183    virtual ValueImp *valueAt(ExecState *, unsigned index) const = 0;
    184184    virtual unsigned int getLength() const = 0;
    185     virtual ~Array() {};
     185    virtual ~Array() {}
    186186};
    187187
    188 const char *signatureForParameters(const KJS::List &aList);
     188const char *signatureForParameters(const List &aList);
    189189
    190190} // namespace Bindings
  • trunk/JavaScriptCore/bindings/runtime_array.cpp

    r10076 r10084  
    3333
    3434RuntimeArrayImp::RuntimeArrayImp(ExecState *exec, Bindings::Array *a)
    35     : ArrayInstanceImp (exec->lexicalInterpreter()->builtinArrayPrototype().imp(), a->getLength())
     35    : ArrayInstanceImp(exec->lexicalInterpreter()->builtinArrayPrototype(), a->getLength())
    3636{
    3737    // Always takes ownership of concrete array.
     
    4444}
    4545
    46 Value RuntimeArrayImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
     46ValueImp *RuntimeArrayImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
    4747{
    4848    RuntimeArrayImp *thisObj = static_cast<RuntimeArrayImp *>(slot.slotBase());
     
    5050}
    5151
    52 Value RuntimeArrayImp::indexGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
     52ValueImp *RuntimeArrayImp::indexGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
    5353{
    5454    RuntimeArrayImp *thisObj = static_cast<RuntimeArrayImp *>(slot.slotBase());
     
    8585}
    8686
    87 void RuntimeArrayImp::put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr)
     87void RuntimeArrayImp::put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr)
    8888{
    8989    if (propertyName == lengthPropertyName) {
    90         Object err = Error::create(exec,RangeError);
     90        ObjectImp *err = Error::create(exec,RangeError);
    9191        exec->setException(err);
    9292        return;
     
    103103}
    104104
    105 void RuntimeArrayImp::put(ExecState *exec, unsigned index, const Value &value, int attr)
     105void RuntimeArrayImp::put(ExecState *exec, unsigned index, ValueImp *value, int attr)
    106106{
    107107    if (index >= getLength()) {
    108         Object err = Error::create(exec,RangeError);
     108        ObjectImp *err = Error::create(exec,RangeError);
    109109        exec->setException(err);
    110110        return;
  • trunk/JavaScriptCore/bindings/runtime_array.h

    r10076 r10084  
    4040    virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
    4141    virtual bool getOwnPropertySlot(ExecState *, unsigned, PropertySlot&);
    42     virtual void put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr = None);
    43     virtual void put(ExecState *exec, unsigned propertyName, const Value &value, int attr = None);
     42    virtual void put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr = None);
     43    virtual void put(ExecState *exec, unsigned propertyName, ValueImp *value, int attr = None);
    4444   
    4545    virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
     
    5555
    5656private:
    57     static Value lengthGetter(ExecState *, const Identifier&, const PropertySlot&);
    58     static Value indexGetter(ExecState *, const Identifier&, const PropertySlot&);
     57    static ValueImp *lengthGetter(ExecState *, const Identifier&, const PropertySlot&);
     58    static ValueImp *indexGetter(ExecState *, const Identifier&, const PropertySlot&);
    5959
    6060    Bindings::Array *_array;
  • trunk/JavaScriptCore/bindings/runtime_method.cpp

    r10076 r10084  
    4141}
    4242
    43 Value RuntimeMethodImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
     43ValueImp *RuntimeMethodImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
    4444{
    4545    RuntimeMethodImp *thisObj = static_cast<RuntimeMethodImp *>(slot.slotBase());
     
    6969}
    7070
    71 Value RuntimeMethodImp::call(ExecState *exec, Object &thisObj, const List &args)
     71ValueImp *RuntimeMethodImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
    7272{
    7373    if (_methodList.length() > 0) {
     
    7676        // If thisObj is the DOM object for a plugin, get the corresponding
    7777        // runtime object from the DOM object.
    78         if (thisObj.classInfo() != &KJS::RuntimeObjectImp::info) {
    79             Value runtimeObject = thisObj.get(exec, "__apple_runtime_object");
    80             imp = static_cast<RuntimeObjectImp*>(runtimeObject.imp());
     78        if (thisObj->classInfo() != &KJS::RuntimeObjectImp::info) {
     79            ValueImp *runtimeObject = thisObj->get(exec, "__apple_runtime_object");
     80            imp = static_cast<RuntimeObjectImp*>(runtimeObject);
    8181        }
    8282        else {
    83             imp = static_cast<RuntimeObjectImp*>(thisObj.imp());
     83            imp = static_cast<RuntimeObjectImp*>(thisObj);
    8484        }
    8585        if (imp) {
     
    8888            instance->begin();
    8989           
    90             Value aValue = instance->invokeMethod(exec, _methodList, args);
     90            ValueImp *aValue = instance->invokeMethod(exec, _methodList, args);
    9191           
    9292            instance->end();
  • trunk/JavaScriptCore/bindings/runtime_method.h

    r10076 r10084  
    4242
    4343    virtual bool implementsCall() const;
    44     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     44    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    4545
    4646    virtual CodeType codeType() const;
     
    4949
    5050private:
    51     static Value lengthGetter(ExecState *, const Identifier&, const PropertySlot&);
     51    static ValueImp *lengthGetter(ExecState *, const Identifier&, const PropertySlot&);
    5252
    5353    Bindings::MethodList _methodList;
  • trunk/JavaScriptCore/bindings/runtime_object.cpp

    r10076 r10084  
    6161}
    6262
    63 Value RuntimeObjectImp::fallbackObjectGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
     63ValueImp *RuntimeObjectImp::fallbackObjectGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
    6464{
    6565    RuntimeObjectImp *thisObj = static_cast<RuntimeObjectImp *>(slot.slotBase());
     
    6969
    7070    Class *aClass = instance->getClass();
    71     Value result = aClass->fallbackObject(exec, instance, propertyName);
     71    ValueImp *result = aClass->fallbackObject(exec, instance, propertyName);
    7272
    7373    instance->end();
     
    7676}
    7777
    78 Value RuntimeObjectImp::fieldGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
     78ValueImp *RuntimeObjectImp::fieldGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
    7979{
    8080    RuntimeObjectImp *thisObj = static_cast<RuntimeObjectImp *>(slot.slotBase());
     
    8585    Class *aClass = instance->getClass();
    8686    Field *aField = aClass->fieldNamed(propertyName.ascii(), instance);
    87     Value result = instance->getValueOfField(exec, aField);
     87    ValueImp *result = instance->getValueOfField(exec, aField);
    8888   
    8989    instance->end();
     
    9292}
    9393
    94 Value RuntimeObjectImp::methodGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
     94ValueImp *RuntimeObjectImp::methodGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
    9595{
    9696    RuntimeObjectImp *thisObj = static_cast<RuntimeObjectImp *>(slot.slotBase());
     
    101101    Class *aClass = instance->getClass();
    102102    MethodList methodList = aClass->methodsNamed(propertyName.ascii(), instance);
    103     Value result = Object(new RuntimeMethodImp(exec, propertyName, methodList));
     103    ValueImp *result = new RuntimeMethodImp(exec, propertyName, methodList);
    104104
    105105    instance->end();
     
    133133       
    134134        // Try a fallback object.
    135         if (!aClass->fallbackObject(exec, instance, propertyName).type() != UndefinedType) {
     135        if (!aClass->fallbackObject(exec, instance, propertyName)->isUndefined()) {
    136136            slot.setCustom(this, fallbackObjectGetter);
    137137            instance->end();
     
    147147
    148148void RuntimeObjectImp::put(ExecState *exec, const Identifier &propertyName,
    149                     const Value &value, int attr)
     149                    ValueImp *value, int attr)
    150150{
    151151    instance->begin();
     
    188188}
    189189
    190 Value RuntimeObjectImp::defaultValue(ExecState *exec, Type hint) const
    191 {
    192     Value result;
     190ValueImp *RuntimeObjectImp::defaultValue(ExecState *exec, Type hint) const
     191{
     192    ValueImp *result;
    193193   
    194194    instance->begin();
     
    207207}
    208208
    209 Value RuntimeObjectImp::call(ExecState *exec, Object &thisObj, const List &args)
    210 {
    211     instance->begin();
    212 
    213     Value aValue = getInternalInstance()->invokeDefaultMethod(exec, args);
     209ValueImp *RuntimeObjectImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
     210{
     211    instance->begin();
     212
     213    ValueImp *aValue = getInternalInstance()->invokeDefaultMethod(exec, args);
    214214   
    215215    instance->end();
  • trunk/JavaScriptCore/bindings/runtime_object.h

    r10076 r10084  
    4545
    4646    virtual void put(ExecState *exec, const Identifier &propertyName,
    47                      const Value &value, int attr = None);
     47                     ValueImp *value, int attr = None);
    4848
    4949    virtual bool canPut(ExecState *exec, const Identifier &propertyName) const;
     
    5252                                const Identifier &propertyName);
    5353
    54     virtual Value defaultValue(ExecState *exec, Type hint) const;
     54    virtual ValueImp *defaultValue(ExecState *exec, Type hint) const;
    5555
    5656    void setInternalInstance (Bindings::Instance *i) { instance = i; }
     
    5858
    5959    virtual bool implementsCall() const;
    60     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     60    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    6161   
    6262    static const ClassInfo info;
    6363
    6464private:
    65     static Value fallbackObjectGetter(ExecState *, const Identifier&, const PropertySlot&);
    66     static Value fieldGetter(ExecState *, const Identifier&, const PropertySlot&);
    67     static Value methodGetter(ExecState *, const Identifier&, const PropertySlot&);
     65    static ValueImp *fallbackObjectGetter(ExecState *, const Identifier&, const PropertySlot&);
     66    static ValueImp *fieldGetter(ExecState *, const Identifier&, const PropertySlot&);
     67    static ValueImp *methodGetter(ExecState *, const Identifier&, const PropertySlot&);
    6868
    6969    Bindings::Instance *instance;
  • trunk/JavaScriptCore/kjs/array_instance.h

    r10076 r10084  
    3636    virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
    3737    virtual bool getOwnPropertySlot(ExecState *, unsigned, PropertySlot&);
    38     virtual void put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr = None);
    39     virtual void put(ExecState *exec, unsigned propertyName, const Value &value, int attr = None);
     38    virtual void put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr = None);
     39    virtual void put(ExecState *exec, unsigned propertyName, ValueImp *value, int attr = None);
    4040    virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
    4141    virtual bool deleteProperty(ExecState *exec, unsigned propertyName);
     
    5050   
    5151    void sort(ExecState *exec);
    52     void sort(ExecState *exec, Object &compareFunction);
     52    void sort(ExecState *exec, ObjectImp *compareFunction);
    5353   
    5454  private:
    55     static Value lengthGetter(ExecState *, const Identifier&, const PropertySlot&);
     55    static ValueImp *lengthGetter(ExecState *, const Identifier&, const PropertySlot&);
    5656
    5757    void setLength(unsigned newLength, ExecState *exec);
  • trunk/JavaScriptCore/kjs/array_object.cpp

    r10076 r10084  
    2121 */
    2222
     23#include "array_object.h"
     24
     25#include "error_object.h"
     26#include "internal.h"
     27#include "interpreter.h"
     28#include "object.h"
     29#include "operations.h"
     30#include "reference_list.h"
     31#include "types.h"
    2332#include "value.h"
    24 #include "object.h"
    25 #include "types.h"
    26 #include "interpreter.h"
    27 #include "operations.h"
    28 #include "array_object.h"
    29 #include "internal.h"
    30 #include "error_object.h"
    3133
    3234#include "array_object.lut.h"
     
    6264  unsigned l = length;
    6365  for (unsigned i = 0; i < l; ++i) {
    64     storage[i] = (it++).imp();
     66    storage[i] = it++;
    6567  }
    6668}
     
    7173}
    7274
    73 Value ArrayInstanceImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
     75ValueImp *ArrayInstanceImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
    7476{
    7577  return Number(static_cast<ArrayInstanceImp *>(slot.slotBase())->length);
     
    9092    if (index < storageLength) {
    9193      ValueImp *v = storage[index];
    92       if (!v || v == UndefinedImp::staticUndefined)
    93         return false;
    94      
     94      if (!v || v->isUndefined())
     95        return false;     
    9596      slot.setValueSlot(this, &storage[index]);
    9697      return true;
     
    107108  if (index < storageLength) {
    108109    ValueImp *v = storage[index];
    109     if (!v || v == UndefinedImp::staticUndefined)
     110    if (!v || v->isUndefined())
    110111      return false;
    111    
    112112    slot.setValueSlot(this, &storage[index]);
    113113    return true;
     
    118118
    119119// Special implementation of [[Put]] - see ECMA 15.4.5.1
    120 void ArrayInstanceImp::put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr)
     120void ArrayInstanceImp::put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr)
    121121{
    122122  if (propertyName == lengthPropertyName) {
    123     setLength(value.toUInt32(exec), exec);
     123    setLength(value->toUInt32(exec), exec);
    124124    return;
    125125  }
     
    135135}
    136136
    137 void ArrayInstanceImp::put(ExecState *exec, unsigned index, const Value &value, int attr)
     137void ArrayInstanceImp::put(ExecState *exec, unsigned index, ValueImp *value, int attr)
    138138{
    139139  if (index < sparseArrayCutoff && index >= storageLength) {
     
    146146
    147147  if (index < storageLength) {
    148     storage[index] = value.imp();
     148    storage[index] = value;
    149149    return;
    150150  }
     
    190190
    191191  // avoid fetching this every time through the loop
    192   ValueImp *undefined = UndefinedImp::staticUndefined;
     192  ValueImp *undefined = jsUndefined();
    193193
    194194  for (unsigned i = 0; i < storageLength; ++i) {
     
    232232    ReferenceList sparseProperties;
    233233   
    234     _prop.addSparseArrayPropertiesToReferenceList(sparseProperties, Object(this));
     234    _prop.addSparseArrayPropertiesToReferenceList(sparseProperties, this);
    235235   
    236236    ReferenceListIterator it = sparseProperties.begin();
     
    266266    ValueImp *va = *(ValueImp **)a;
    267267    ValueImp *vb = *(ValueImp **)b;
    268     if (va->dispatchType() == UndefinedType) {
    269         return vb->dispatchType() == UndefinedType ? 0 : 1;
    270     }
    271     if (vb->dispatchType() == UndefinedType) {
     268    if (va->isUndefined()) {
     269        return vb->isUndefined() ? 0 : 1;
     270    }
     271    if (vb->isUndefined()) {
    272272        return -1;
    273273    }
    274     return compare(va->dispatchToString(exec), vb->dispatchToString(exec));
     274    return compare(va->toString(exec), vb->toString(exec));
    275275}
    276276
     
    297297    ObjectImp *compareFunction;
    298298    List arguments;
    299     Object globalObject;
     299    ObjectImp *globalObject;
    300300};
    301301
     
    308308    ValueImp *va = *(ValueImp **)a;
    309309    ValueImp *vb = *(ValueImp **)b;
    310     if (va->dispatchType() == UndefinedType) {
    311         return vb->dispatchType() == UndefinedType ? 0 : 1;
    312     }
    313     if (vb->dispatchType() == UndefinedType) {
     310    if (va->isUndefined()) {
     311        return vb->isUndefined() ? 0 : 1;
     312    }
     313    if (vb->isUndefined()) {
    314314        return -1;
    315315    }
     
    319319    args->arguments.append(vb);
    320320    double compareResult = args->compareFunction->call
    321         (args->exec, args->globalObject, args->arguments).toNumber(args->exec);
     321        (args->exec, args->globalObject, args->arguments)->toNumber(args->exec);
    322322    return compareResult < 0 ? -1 : compareResult > 0 ? 1 : 0;
    323323}
    324324
    325 void ArrayInstanceImp::sort(ExecState *exec, Object &compareFunction)
     325void ArrayInstanceImp::sort(ExecState *exec, ObjectImp *compareFunction)
    326326{
    327327    int lengthNotIncludingUndefined = pushUndefinedObjectsToEnd(exec);
    328328   
    329     CompareWithCompareFunctionArguments args(exec, compareFunction.imp());
     329    CompareWithCompareFunctionArguments args(exec, compareFunction);
    330330    compareWithCompareFunctionArguments = &args;
    331331    qsort(storage, lengthNotIncludingUndefined, sizeof(ValueImp *), compareWithCompareFunctionForQSort);
     
    335335unsigned ArrayInstanceImp::pushUndefinedObjectsToEnd(ExecState *exec)
    336336{
    337     ValueImp *undefined = UndefinedImp::staticUndefined;
     337    ValueImp *undefined = jsUndefined();
    338338
    339339    unsigned o = 0;
     
    349349   
    350350    ReferenceList sparseProperties;
    351     _prop.addSparseArrayPropertiesToReferenceList(sparseProperties, Object(this));
     351    _prop.addSparseArrayPropertiesToReferenceList(sparseProperties, this);
    352352    unsigned newLength = o + sparseProperties.length();
    353353
     
    359359    while (it != sparseProperties.end()) {
    360360      Reference ref = it++;
    361       storage[o] = ref.getValue(exec).imp();
     361      storage[o] = ref.getValue(exec);
    362362      ObjectImp::deleteProperty(exec, ref.getPropertyName(exec));
    363363      o++;
     
    399399  : ArrayInstanceImp(objProto, 0)
    400400{
    401   Value protect(this);
    402401  setInternalValue(Null());
    403402}
     
    412411ArrayProtoFuncImp::ArrayProtoFuncImp(ExecState *exec, int i, int len)
    413412  : InternalFunctionImp(
    414     static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype().imp())
     413    static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype())
    415414    ), id(i)
    416415{
    417   Value protect(this);
    418416  put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
    419417}
     
    425423
    426424// ECMA 15.4.4
    427 Value ArrayProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &args)
    428 {
    429   unsigned int length = thisObj.get(exec,lengthPropertyName).toUInt32(exec);
    430   ObjectImp *thisImp = thisObj.imp();
    431 
    432   Value result;
     425ValueImp *ArrayProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
     426{
     427  unsigned length = thisObj->get(exec,lengthPropertyName)->toUInt32(exec);
     428
     429  ValueImp *result;
    433430 
    434431  switch (id) {
     
    436433  case ToString:
    437434
    438     if (!thisObj.inherits(&ArrayInstanceImp::info)) {
    439       Object err = Error::create(exec,TypeError);
     435    if (!thisObj->inherits(&ArrayInstanceImp::info)) {
     436      ObjectImp *err = Error::create(exec,TypeError);
    440437      exec->setException(err);
    441438      return err;
     
    447444    UString str = "";
    448445
    449     if (args[0].type() != UndefinedType)
    450       separator = args[0].toString(exec);
     446    if (!args[0]->isUndefined())
     447      separator = args[0]->toString(exec);
    451448    for (unsigned int k = 0; k < length; k++) {
    452449      if (k >= 1)
    453450        str += separator;
    454451     
    455       Value element = thisObj.get(exec, k);
    456       if (element.type() == UndefinedType || element.type() == NullType)
     452      ValueImp *element = thisObj->get(exec, k);
     453      if (element->isUndefinedOrNull())
    457454        continue;
    458455
    459456      bool fallback = false;
    460457      if (id == ToLocaleString) {
    461         Object o = element.toObject(exec);
    462         Object conversionFunction =
    463           Object::dynamicCast(o.get(exec, toLocaleStringPropertyName));
    464         if (conversionFunction.isValid() &&
    465             conversionFunction.implementsCall()) {
    466           str += conversionFunction.call(exec, o, List()).toString(exec);
     458        ObjectImp *o = element->toObject(exec);
     459        ValueImp *conversionFunction = o->get(exec, toLocaleStringPropertyName);
     460        if (conversionFunction->isObject() && static_cast<ObjectImp *>(conversionFunction)->implementsCall()) {
     461          str += static_cast<ObjectImp *>(conversionFunction)->call(exec, o, List())->toString(exec);
    467462        } else {
    468463          // try toString() fallback
     
    472467
    473468      if (id == ToString || id == Join || fallback) {
    474         if (element.type() == ObjectType) {
    475           Object o = Object::dynamicCast(element);
    476           Object conversionFunction =
    477             Object::dynamicCast(o.get(exec, toStringPropertyName));
    478           if (conversionFunction.isValid() &&
    479               conversionFunction.implementsCall()) {
    480             str += conversionFunction.call(exec, o, List()).toString(exec);
     469        if (element->isObject()) {
     470          ObjectImp *o = static_cast<ObjectImp *>(element);
     471          ValueImp *conversionFunction = o->get(exec, toStringPropertyName);
     472          if (conversionFunction->isObject() && static_cast<ObjectImp *>(conversionFunction)->implementsCall()) {
     473            str += static_cast<ObjectImp *>(conversionFunction)->call(exec, o, List())->toString(exec);
    481474          } else {
    482             UString msg = "Can't convert " + o.className() +
    483               " object to string";
    484             Object error = Error::create(exec, RangeError,
    485                 msg.cstring().c_str());
     475            UString msg = "Can't convert " + o->className() + " object to string";
     476            ObjectImp *error = Error::create(exec, RangeError, msg.cstring().c_str());
    486477            exec->setException(error);
    487478            return error;
    488479          }
    489480        } else {
    490           str += element.toString(exec);
     481          str += element->toString(exec);
    491482        }
    492483      }
     
    499490  }
    500491  case Concat: {
    501     Object arr = Object::dynamicCast(exec->lexicalInterpreter()->builtinArray().construct(exec,List::empty()));
     492    ObjectImp *arr = static_cast<ObjectImp *>(exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty()));
    502493    int n = 0;
    503     Value curArg = thisObj;
    504     Object curObj = Object::dynamicCast(thisObj);
     494    ValueImp *curArg = thisObj;
     495    ObjectImp *curObj = static_cast<ObjectImp *>(thisObj);
    505496    ListIterator it = args.begin();
    506497    for (;;) {
    507       if (curArg.type() == ObjectType &&
    508           curObj.inherits(&ArrayInstanceImp::info)) {
     498      if (curArg->isObject() &&
     499          curObj->inherits(&ArrayInstanceImp::info)) {
    509500        unsigned int k = 0;
    510501        // Older versions tried to optimize out getting the length of thisObj
    511502        // by checking for n != 0, but that doesn't work if thisObj is an empty array.
    512         length = curObj.get(exec,lengthPropertyName).toUInt32(exec);
     503        length = curObj->get(exec,lengthPropertyName)->toUInt32(exec);
    513504        while (k < length) {
    514           Value v;
    515           if (curObj.imp()->getProperty(exec, k, v))
    516             arr.put(exec, n, v);
     505          ValueImp *v;
     506          if (curObj->getProperty(exec, k, v))
     507            arr->put(exec, n, v);
    517508          n++;
    518509          k++;
    519510        }
    520511      } else {
    521         arr.put(exec, n, curArg);
     512        arr->put(exec, n, curArg);
    522513        n++;
    523514      }
     
    525516        break;
    526517      curArg = *it;
    527       curObj = Object::dynamicCast(it++); // may be 0
    528     }
    529     arr.put(exec,lengthPropertyName, Number(n), DontEnum | DontDelete);
     518      curObj = static_cast<ObjectImp *>(it++); // may be 0
     519    }
     520    arr->put(exec,lengthPropertyName, Number(n), DontEnum | DontDelete);
    530521
    531522    result = arr;
     
    534525  case Pop:{
    535526    if (length == 0) {
    536       thisObj.put(exec, lengthPropertyName, Number(length), DontEnum | DontDelete);
     527      thisObj->put(exec, lengthPropertyName, Number(length), DontEnum | DontDelete);
    537528      result = Undefined();
    538529    } else {
    539       result = thisObj.get(exec, length - 1);
    540       thisObj.put(exec, lengthPropertyName, Number(length - 1), DontEnum | DontDelete);
     530      result = thisObj->get(exec, length - 1);
     531      thisObj->put(exec, lengthPropertyName, Number(length - 1), DontEnum | DontDelete);
    541532    }
    542533    break;
     
    544535  case Push: {
    545536    for (int n = 0; n < args.size(); n++)
    546       thisObj.put(exec, length + n, args[n]);
     537      thisObj->put(exec, length + n, args[n]);
    547538    length += args.size();
    548     thisObj.put(exec,lengthPropertyName, Number(length), DontEnum | DontDelete);
     539    thisObj->put(exec,lengthPropertyName, Number(length), DontEnum | DontDelete);
    549540    result = Number(length);
    550541    break;
     
    556547    for (unsigned int k = 0; k < middle; k++) {
    557548      unsigned lk1 = length - k - 1;
    558       Value obj;
    559       Value obj2;
    560       bool has2 = thisImp->getProperty(exec, lk1, obj2);
    561       bool has1 = thisImp->getProperty(exec, k, obj);
     549      ValueImp *obj;
     550      ValueImp *obj2;
     551      bool has2 = thisObj->getProperty(exec, lk1, obj2);
     552      bool has1 = thisObj->getProperty(exec, k, obj);
    562553
    563554      if (has2)
    564         thisObj.put(exec, k, obj2);
     555        thisObj->put(exec, k, obj2);
    565556      else
    566         thisObj.deleteProperty(exec, k);
     557        thisObj->deleteProperty(exec, k);
    567558
    568559      if (has1)
    569         thisObj.put(exec, lk1, obj);
     560        thisObj->put(exec, lk1, obj);
    570561      else
    571         thisObj.deleteProperty(exec, lk1);
     562        thisObj->deleteProperty(exec, lk1);
    572563    }
    573564    result = thisObj;
     
    576567  case Shift: {
    577568    if (length == 0) {
    578       thisObj.put(exec, lengthPropertyName, Number(length), DontEnum | DontDelete);
     569      thisObj->put(exec, lengthPropertyName, Number(length), DontEnum | DontDelete);
    579570      result = Undefined();
    580571    } else {
    581       result = thisObj.get(exec, 0);
     572      result = thisObj->get(exec, 0);
    582573      for(unsigned int k = 1; k < length; k++) {
    583         Value obj;
    584         if (thisImp->getProperty(exec, k, obj))
    585           thisObj.put(exec, k-1, obj);
     574        ValueImp *obj;
     575        if (thisObj->getProperty(exec, k, obj))
     576          thisObj->put(exec, k-1, obj);
    586577        else
    587           thisObj.deleteProperty(exec, k-1);
    588       }
    589       thisObj.deleteProperty(exec, length - 1);
    590       thisObj.put(exec, lengthPropertyName, Number(length - 1), DontEnum | DontDelete);
     578          thisObj->deleteProperty(exec, k-1);
     579      }
     580      thisObj->deleteProperty(exec, length - 1);
     581      thisObj->put(exec, lengthPropertyName, Number(length - 1), DontEnum | DontDelete);
    591582    }
    592583    break;
     
    596587
    597588    // We return a new array
    598     Object resObj = Object::dynamicCast(exec->lexicalInterpreter()->builtinArray().construct(exec,List::empty()));
     589    ObjectImp *resObj = static_cast<ObjectImp *>(exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty()));
    599590    result = resObj;
    600591    double begin = 0;
    601     if (args[0].type() != UndefinedType) {
    602         begin = args[0].toInteger(exec);
     592    if (!args[0]->isUndefined()) {
     593        begin = args[0]->toInteger(exec);
    603594        if (begin >= 0) { // false for NaN
    604595            if (begin > length)
     
    611602    }
    612603    double end = length;
    613     if (args[1].type() != UndefinedType) {
    614       end = args[1].toInteger(exec);
     604    if (!args[1]->isUndefined()) {
     605      end = args[1]->toInteger(exec);
    615606      if (end < 0) { // false for NaN
    616607        end += length;
     
    628619    int e = static_cast<int>(end);
    629620    for(int k = b; k < e; k++, n++) {
    630       Value obj;
    631       if (thisImp->getProperty(exec, k, obj))
    632         resObj.put(exec, n, obj);
    633     }
    634     resObj.put(exec, lengthPropertyName, Number(n), DontEnum | DontDelete);
     621      ValueImp *obj;
     622      if (thisObj->getProperty(exec, k, obj))
     623        resObj->put(exec, n, obj);
     624    }
     625    resObj->put(exec, lengthPropertyName, Number(n), DontEnum | DontDelete);
    635626    break;
    636627  }
     
    639630    printf("KJS Array::Sort length=%d\n", length);
    640631    for ( unsigned int i = 0 ; i<length ; ++i )
    641       printf("KJS Array::Sort: %d: %s\n", i, thisObj.get(exec, i).toString(exec).ascii() );
     632      printf("KJS Array::Sort: %d: %s\n", i, thisObj->get(exec, i)->toString(exec).ascii() );
    642633#endif
    643     Object sortFunction;
    644     bool useSortFunction = (args[0].type() != UndefinedType);
    645     if (useSortFunction)
     634    ObjectImp *sortFunction = NULL;
     635    if (!args[0]->isUndefined())
    646636      {
    647         sortFunction = args[0].toObject(exec);
    648         if (!sortFunction.implementsCall())
    649           useSortFunction = false;
    650       }
    651    
    652     if (thisImp->classInfo() == &ArrayInstanceImp::info) {
    653       if (useSortFunction)
    654         ((ArrayInstanceImp *)thisImp)->sort(exec, sortFunction);
     637        sortFunction = args[0]->toObject(exec);
     638        if (!sortFunction->implementsCall())
     639          sortFunction = NULL;
     640      }
     641   
     642    if (thisObj->classInfo() == &ArrayInstanceImp::info) {
     643      if (sortFunction)
     644        ((ArrayInstanceImp *)thisObj)->sort(exec, sortFunction);
    655645      else
    656         ((ArrayInstanceImp *)thisImp)->sort(exec);
     646        ((ArrayInstanceImp *)thisObj)->sort(exec);
    657647      result = thisObj;
    658648      break;
     
    660650
    661651    if (length == 0) {
    662       thisObj.put(exec, lengthPropertyName, Number(0), DontEnum | DontDelete);
     652      thisObj->put(exec, lengthPropertyName, Number(0), DontEnum | DontDelete);
    663653      result = thisObj;
    664654      break;
     
    669659    for ( unsigned int i = 0 ; i<length-1 ; ++i )
    670660      {
    671         Value iObj = thisObj.get(exec,i);
     661        ValueImp *iObj = thisObj->get(exec,i);
    672662        unsigned int themin = i;
    673         Value minObj = iObj;
     663        ValueImp *minObj = iObj;
    674664        for ( unsigned int j = i+1 ; j<length ; ++j )
    675665          {
    676             Value jObj = thisObj.get(exec,j);
     666            ValueImp *jObj = thisObj->get(exec,j);
    677667            double cmp;
    678             if (jObj.type() == UndefinedType) {
     668            if (jObj->isUndefined()) {
    679669              cmp = 1; // don't check minObj because there's no need to differentiate == (0) from > (1)
    680             } else if (minObj.type() == UndefinedType) {
     670            } else if (minObj->isUndefined()) {
    681671              cmp = -1;
    682             } else if (useSortFunction) {
     672            } else if (sortFunction) {
    683673                List l;
    684674                l.append(jObj);
    685675                l.append(minObj);
    686                 cmp = sortFunction.call(exec, exec->dynamicInterpreter()->globalObject(), l).toNumber(exec);
     676                cmp = sortFunction->call(exec, exec->dynamicInterpreter()->globalObject(), l)->toNumber(exec);
    687677            } else {
    688               cmp = (jObj.toString(exec) < minObj.toString(exec)) ? -1 : 1;
     678              cmp = (jObj->toString(exec) < minObj->toString(exec)) ? -1 : 1;
    689679            }
    690680            if ( cmp < 0 )
     
    698688          {
    699689            //printf("KJS Array::Sort: swapping %d and %d\n", i, themin );
    700             thisObj.put( exec, i, minObj );
    701             thisObj.put( exec, themin, iObj );
     690            thisObj->put( exec, i, minObj );
     691            thisObj->put( exec, themin, iObj );
    702692          }
    703693      }
     
    705695    printf("KJS Array::Sort -- Resulting array:\n");
    706696    for ( unsigned int i = 0 ; i<length ; ++i )
    707       printf("KJS Array::Sort: %d: %s\n", i, thisObj.get(exec, i).toString(exec).ascii() );
     697      printf("KJS Array::Sort: %d: %s\n", i, thisObj->get(exec, i)->toString(exec).ascii() );
    708698#endif
    709699    result = thisObj;
     
    712702  case Splice: {
    713703    // 15.4.4.12 - oh boy this is huge
    714     Object resObj = Object::dynamicCast(exec->lexicalInterpreter()->builtinArray().construct(exec,List::empty()));
     704    ObjectImp *resObj = static_cast<ObjectImp *>(exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty()));
    715705    result = resObj;
    716     int begin = args[0].toUInt32(exec);
     706    int begin = args[0]->toUInt32(exec);
    717707    if ( begin < 0 )
    718708      begin = maxInt( begin + length, 0 );
    719709    else
    720710      begin = minInt( begin, length );
    721     unsigned int deleteCount = minInt( maxInt( args[1].toUInt32(exec), 0 ), length - begin );
     711    unsigned int deleteCount = minInt( maxInt( args[1]->toUInt32(exec), 0 ), length - begin );
    722712
    723713    //printf( "Splicing from %d, deleteCount=%d \n", begin, deleteCount );
    724714    for(unsigned int k = 0; k < deleteCount; k++) {
    725       Value obj;
    726       if (thisImp->getProperty(exec, k+begin, obj))
    727         resObj.put(exec, k, obj);
    728     }
    729     resObj.put(exec, lengthPropertyName, Number(deleteCount), DontEnum | DontDelete);
     715      ValueImp *obj;
     716      if (thisObj->getProperty(exec, k+begin, obj))
     717        resObj->put(exec, k, obj);
     718    }
     719    resObj->put(exec, lengthPropertyName, Number(deleteCount), DontEnum | DontDelete);
    730720
    731721    unsigned int additionalArgs = maxInt( args.size() - 2, 0 );
     
    736726        for ( unsigned int k = begin; k < length - deleteCount; ++k )
    737727        {
    738           Value obj;
    739           if (thisImp->getProperty(exec, k+deleteCount, obj))
    740             thisObj.put(exec, k+additionalArgs, obj);
     728          ValueImp *obj;
     729          if (thisObj->getProperty(exec, k+deleteCount, obj))
     730            thisObj->put(exec, k+additionalArgs, obj);
    741731          else
    742             thisObj.deleteProperty(exec, k+additionalArgs);
     732            thisObj->deleteProperty(exec, k+additionalArgs);
    743733        }
    744734        for ( unsigned int k = length ; k > length - deleteCount + additionalArgs; --k )
    745           thisObj.deleteProperty(exec, k-1);
     735          thisObj->deleteProperty(exec, k-1);
    746736      }
    747737      else
     
    749739        for ( unsigned int k = length - deleteCount; (int)k > begin; --k )
    750740        {
    751           Value obj;
    752           if (thisImp->getProperty(exec, k + deleteCount - 1, obj))
    753             thisObj.put(exec, k + additionalArgs - 1, obj);
     741          ValueImp *obj;
     742          if (thisObj->getProperty(exec, k + deleteCount - 1, obj))
     743            thisObj->put(exec, k + additionalArgs - 1, obj);
    754744          else
    755             thisObj.deleteProperty(exec, k+additionalArgs-1);
     745            thisObj->deleteProperty(exec, k+additionalArgs-1);
    756746        }
    757747      }
     
    759749    for ( unsigned int k = 0; k < additionalArgs; ++k )
    760750    {
    761       thisObj.put(exec, k+begin, args[k+2]);
    762     }
    763     thisObj.put(exec, lengthPropertyName, Number(length - deleteCount + additionalArgs), DontEnum | DontDelete);
     751      thisObj->put(exec, k+begin, args[k+2]);
     752    }
     753    thisObj->put(exec, lengthPropertyName, Number(length - deleteCount + additionalArgs), DontEnum | DontDelete);
    764754    break;
    765755  }
     
    768758    for ( unsigned int k = length; k > 0; --k )
    769759    {
    770       Value obj;
    771       if (thisImp->getProperty(exec, k - 1, obj))
    772         thisObj.put(exec, k+nrArgs-1, obj);
     760      ValueImp *obj;
     761      if (thisObj->getProperty(exec, k - 1, obj))
     762        thisObj->put(exec, k+nrArgs-1, obj);
    773763      else
    774         thisObj.deleteProperty(exec, k+nrArgs-1);
     764        thisObj->deleteProperty(exec, k+nrArgs-1);
    775765    }
    776766    for ( unsigned int k = 0; k < nrArgs; ++k )
    777       thisObj.put(exec, k, args[k]);
     767      thisObj->put(exec, k, args[k]);
    778768    result = Number(length + nrArgs);
    779     thisObj.put(exec, lengthPropertyName, result, DontEnum | DontDelete);
     769    thisObj->put(exec, lengthPropertyName, result, DontEnum | DontDelete);
    780770    break;
    781771  }
     
    788778    //http://developer-test.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:some
    789779   
    790     Object eachFunction = args[0].toObject(exec);
    791    
    792     if (!eachFunction.implementsCall()) {
    793       Object err = Error::create(exec,TypeError);
     780    ObjectImp *eachFunction = args[0]->toObject(exec);
     781   
     782    if (!eachFunction->implementsCall()) {
     783      ObjectImp *err = Error::create(exec,TypeError);
    794784      exec->setException(err);
    795785      return err;
    796786    }
    797787   
    798     Object applyThis = args[1].imp()->isUndefinedOrNull() ? exec->dynamicInterpreter()->globalObject() :  args[1].toObject(exec);
     788    ObjectImp *applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicInterpreter()->globalObject() :  args[1]->toObject(exec);
    799789   
    800790    if (id == Some || id == Every)
     
    807797      List eachArguments;
    808798     
    809       eachArguments.append(thisObj.get(exec, k));
     799      eachArguments.append(thisObj->get(exec, k));
    810800      eachArguments.append(Number(k));
    811801      eachArguments.append(thisObj);
    812802     
    813       bool predicateResult = eachFunction.call(exec, applyThis, eachArguments).toBoolean(exec);
     803      bool predicateResult = eachFunction->call(exec, applyThis, eachArguments)->toBoolean(exec);
    814804     
    815805      if (id == Every && !predicateResult) {
     
    827817  default:
    828818    assert(0);
     819    result = 0;
    829820    break;
    830821  }
     
    839830  : InternalFunctionImp(funcProto)
    840831{
    841   Value protect(this);
    842832  // ECMA 15.4.3.1 Array.prototype
    843   put(exec,prototypePropertyName, Object(arrayProto), DontEnum|DontDelete|ReadOnly);
     833  put(exec,prototypePropertyName, arrayProto, DontEnum|DontDelete|ReadOnly);
    844834
    845835  // no. of arguments for constructor
     
    853843
    854844// ECMA 15.4.2
    855 Object ArrayObjectImp::construct(ExecState *exec, const List &args)
     845ObjectImp *ArrayObjectImp::construct(ExecState *exec, const List &args)
    856846{
    857847  // a single numeric argument denotes the array size (!)
    858   if (args.size() == 1 && args[0].type() == NumberType) {
    859     uint32_t n = args[0].toUInt32(exec);
    860     if (n != args[0].toNumber(exec)) {
    861       Object error = Error::create(exec, RangeError, "Array size is not a small enough positive integer.");
     848  if (args.size() == 1 && args[0]->isNumber()) {
     849    uint32_t n = args[0]->toUInt32(exec);
     850    if (n != args[0]->toNumber(exec)) {
     851      ObjectImp *error = Error::create(exec, RangeError, "Array size is not a small enough positive integer.");
    862852      exec->setException(error);
    863853      return error;
    864854    }
    865     return Object(new ArrayInstanceImp(exec->lexicalInterpreter()->builtinArrayPrototype().imp(), n));
     855    return new ArrayInstanceImp(exec->lexicalInterpreter()->builtinArrayPrototype(), n);
    866856  }
    867857
    868858  // otherwise the array is constructed with the arguments in it
    869   return Object(new ArrayInstanceImp(exec->lexicalInterpreter()->builtinArrayPrototype().imp(), args));
     859  return new ArrayInstanceImp(exec->lexicalInterpreter()->builtinArrayPrototype(), args);
    870860}
    871861
     
    876866
    877867// ECMA 15.6.1
    878 Value ArrayObjectImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
     868ValueImp *ArrayObjectImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
    879869{
    880870  // equivalent to 'new Array(....)'
  • trunk/JavaScriptCore/kjs/array_object.h

    r10076 r10084  
    4242
    4343    virtual bool implementsCall() const;
    44     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     44    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    4545
    4646    enum { ToString, ToLocaleString, Concat, Join, Pop, Push,
     
    5858
    5959    virtual bool implementsConstruct() const;
    60     virtual Object construct(ExecState *exec, const List &args);
     60    virtual ObjectImp *construct(ExecState *exec, const List &args);
    6161    virtual bool implementsCall() const;
    62     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     62    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    6363
    6464  };
  • trunk/JavaScriptCore/kjs/bool_object.cpp

    r9768 r10084  
    5151  : BooleanInstanceImp(objectProto)
    5252{
    53   Value protect(this);
    5453  // The constructor will be added later by InterpreterImp::InterpreterImp()
    5554
     
    6665  : InternalFunctionImp(funcProto), id(i)
    6766{
    68   Value protect(this);
    6967  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
    7068}
     
    7876
    7977// ECMA 15.6.4.2 + 15.6.4.3
    80 Value BooleanProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &/*args*/)
     78ValueImp *BooleanProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &/*args*/)
    8179{
    8280  // no generic function. "this" has to be a Boolean object
    83   if (!thisObj.inherits(&BooleanInstanceImp::info)) {
    84     Object err = Error::create(exec,TypeError);
     81  if (!thisObj->inherits(&BooleanInstanceImp::info)) {
     82    ObjectImp *err = Error::create(exec,TypeError);
    8583    exec->setException(err);
    8684    return err;
     
    8987  // execute "toString()" or "valueOf()", respectively
    9088
    91   Value v = thisObj.internalValue();
    92   assert(!v.isNull());
     89  ValueImp *v = thisObj->internalValue();
     90  assert(v);
    9391
    9492  if (id == ToString)
    95     return String(v.toString(exec));
    96   return Boolean(v.toBoolean(exec)); /* TODO: optimize for bool case */
     93    return String(v->toString(exec));
     94  return Boolean(v->toBoolean(exec)); /* TODO: optimize for bool case */
    9795}
    9896
     
    104102  : InternalFunctionImp(funcProto)
    105103{
    106   Value protect(this);
    107104  putDirect(prototypePropertyName, booleanProto, DontEnum|DontDelete|ReadOnly);
    108105
    109106  // no. of arguments for constructor
    110   putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum);
     107  putDirect(lengthPropertyName, jsOne(), ReadOnly|DontDelete|DontEnum);
    111108}
    112109
     
    118115
    119116// ECMA 15.6.2
    120 Object BooleanObjectImp::construct(ExecState *exec, const List &args)
     117ObjectImp *BooleanObjectImp::construct(ExecState *exec, const List &args)
    121118{
    122   Object obj(new BooleanInstanceImp(exec->lexicalInterpreter()->builtinBooleanPrototype().imp()));
     119  ObjectImp *obj(new BooleanInstanceImp(exec->lexicalInterpreter()->builtinBooleanPrototype()));
    123120
    124   Boolean b;
     121  bool b;
    125122  if (args.size() > 0)
    126     b = args.begin()->dispatchToBoolean(exec);
     123    b = args.begin()->toBoolean(exec);
    127124  else
    128     b = Boolean(false);
     125    b = false;
    129126
    130   obj.setInternalValue(b);
     127  obj->setInternalValue(jsBoolean(b));
    131128
    132129  return obj;
     
    139136
    140137// ECMA 15.6.1
    141 Value BooleanObjectImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
     138ValueImp *BooleanObjectImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
    142139{
    143140  if (args.isEmpty())
    144141    return Boolean(false);
    145142  else
    146     return Boolean(args[0].toBoolean(exec)); /* TODO: optimize for bool case */
     143    return Boolean(args[0]->toBoolean(exec)); /* TODO: optimize for bool case */
    147144}
    148145
  • trunk/JavaScriptCore/kjs/bool_object.h

    r9768 r10084  
    6161
    6262    virtual bool implementsCall() const;
    63     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     63    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    6464
    6565    enum { ToString, ValueOf };
     
    8080
    8181    virtual bool implementsConstruct() const;
    82     virtual Object construct(ExecState *exec, const List &args);
     82    virtual ObjectImp *construct(ExecState *exec, const List &args);
    8383
    8484    virtual bool implementsCall() const;
    85     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     85    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    8686  };
    8787
  • trunk/JavaScriptCore/kjs/collector.cpp

    r9992 r10084  
    252252     
    253253      if (good && ((CollectorCell *)x)->u.freeCell.zeroIfFree != 0) {
    254         ValueImp *imp = (ValueImp *)x;
     254        AllocatedValueImp *imp = (AllocatedValueImp *)x;
    255255        if (!imp->marked())
    256256          imp->mark();
     
    371371
    372372      CollectorCell *cell = curBlock->cells + i;
    373       ValueImp *imp = reinterpret_cast<ValueImp *>(cell);
     373      AllocatedValueImp *imp = reinterpret_cast<AllocatedValueImp *>(cell);
    374374
    375375      if (cell->u.freeCell.zeroIfFree != 0) {
    376         if (!imp->_marked)
     376        if (!imp->m_marked)
    377377        {
    378           //fprintf(stderr, "Collector::deleting ValueImp %p (%s)\n", imp, className(imp));
     378          //fprintf(stderr, "Collector::deleting AllocatedValueImp %p (%s)\n", imp, className(imp));
    379379          // emulate destructing part of 'operator delete()'
    380           imp->~ValueImp();
     380          imp->~AllocatedValueImp();
    381381          curBlock->usedCells--;
    382382          numLiveObjects--;
     
    389389
    390390        } else {
    391           imp->_marked = false;
     391          imp->m_marked = false;
    392392        }
    393393      } else {
     
    423423  int cell = 0;
    424424  while (cell < heap.usedOversizeCells) {
    425     ValueImp *imp = (ValueImp *)heap.oversizeCells[cell];
     425    AllocatedValueImp *imp = (AllocatedValueImp *)heap.oversizeCells[cell];
    426426   
    427     if (!imp->_marked) {
    428       imp->~ValueImp();
     427    if (!imp->m_marked) {
     428      imp->~AllocatedValueImp();
    429429#if DEBUG_COLLECTOR
    430430      heap.oversizeCells[cell]->u.freeCell.zeroIfFree = 0;
     
    446446
    447447    } else {
    448       imp->_marked = false;
     448      imp->m_marked = false;
    449449      cell++;
    450450    }
     
    509509{
    510510  const char *name = "???";
    511   switch (val->dispatchType()) {
     511  switch (val->type()) {
    512512    case UnspecifiedType:
    513513      break;
  • trunk/JavaScriptCore/kjs/completion.h

    r9768 r10084  
    4848  class Completion {
    4949  public:
    50     Completion(ComplType c = Normal, const Value& v = Value(),
    51                const Identifier &t = Identifier::null())
     50    Completion(ComplType c = Normal, ValueImp *v = NULL, const Identifier &t = Identifier::null())
    5251        : comp(c), val(v), tar(t) { }
    5352
    5453    ComplType complType() const { return comp; }
    55     Value value() const { return val; }
     54    ValueImp *value() const { return val; }
    5655    Identifier target() const { return tar; }
    57     bool isValueCompletion() const { return !val.isNull(); }
     56    bool isValueCompletion() const { return val; }
    5857  private:
    5958    ComplType comp;
    60     Value val;
     59    ValueImp *val;
    6160    Identifier tar;
    6261  };
  • trunk/JavaScriptCore/kjs/context.h

    r9768 r10084  
    3636  class ContextImp {
    3737  public:
    38     ContextImp(Object &glob, InterpreterImp *, Object &thisV, CodeType type = GlobalCode,
     38    ContextImp(ObjectImp *glob, InterpreterImp *, ObjectImp *thisV, CodeType type = GlobalCode,
    3939               ContextImp *callingContext = 0, FunctionImp *functiion = 0, const List *args = 0);
    4040    ~ContextImp();
     
    4242    const ScopeChain &scopeChain() const { return scope; }
    4343    CodeType codeType() { return m_codeType; }
    44     Object variableObject() const { return variable; }
    45     void setVariableObject(const Object &v) { variable = v; }
    46     Object thisValue() const { return thisVal; }
     44    ObjectImp *variableObject() const { return variable; }
     45    void setVariableObject(ObjectImp *v) { variable = v; }
     46    ObjectImp *thisValue() const { return thisVal; }
    4747    ContextImp *callingContext() { return _callingContext; }
    48     ObjectImp *activationObject() { return activation.imp(); }
     48    ObjectImp *activationObject() { return activation; }
    4949    FunctionImp *function() const { return _function; }
    5050    const List *arguments() const { return _arguments; }
    5151
    52     void pushScope(const Object &s) { scope.push(s.imp()); }
     52    void pushScope(ObjectImp *s) { scope.push(s); }
    5353    void popScope() { scope.pop(); }
    5454    LabelStack *seenLabels() { return &ls; }
     
    6464    // there is no need to protect various pointers from conservative
    6565    // GC since they will be caught by the conservative sweep anyway!
    66     Object activation;
     66    ObjectImp *activation;
    6767   
    6868    ScopeChain scope;
    69     Object variable;
    70     Object thisVal;
     69    ObjectImp *variable;
     70    ObjectImp *thisVal;
    7171
    7272    LabelStack ls;
  • trunk/JavaScriptCore/kjs/date_object.cpp

    r10076 r10084  
    270270    bool        useCustomFormat = false;
    271271    UString     customFormatString;
    272     arg0String = args[0].toString(exec);
     272    arg0String = args[0]->toString(exec);
    273273    if ((arg0String == "custom") && (argCount >= 2)) {
    274274        useCustomFormat = true;
    275         customFormatString = args[1].toString(exec);
     275        customFormatString = args[1]->toString(exec);
    276276    } else if (includeDate && includeTime && (argCount >= 2)) {
    277         arg1String = args[1].toString(exec);
     277        arg1String = args[1]->toString(exec);
    278278        dateStyle = styleFromArgString(arg0String,dateStyle);
    279279        timeStyle = styleFromArgString(arg1String,timeStyle);
     
    309309#endif // APPLE_CHANGES
    310310
    311 using namespace KJS;
     311namespace KJS {
    312312
    313313static int day(double t)
     
    400400    if (maxArgs >= 4 && idx < numArgs) {
    401401        t->tm_hour = 0;
    402         result = args[idx++].toInt32(exec) * msPerHour;
     402        result = args[idx++]->toInt32(exec) * msPerHour;
    403403    }
    404404    // minutes
    405405    if (maxArgs >= 3 && idx < numArgs) {
    406406        t->tm_min = 0;
    407         result += args[idx++].toInt32(exec) * msPerMinute;
     407        result += args[idx++]->toInt32(exec) * msPerMinute;
    408408    }
    409409    // seconds
    410410    if (maxArgs >= 2 && idx < numArgs) {
    411411        t->tm_sec = 0;
    412         result += args[idx++].toInt32(exec) * msPerSecond;
     412        result += args[idx++]->toInt32(exec) * msPerSecond;
    413413    }
    414414    // read ms from args if present or add the old value
     
    486486  : DateInstanceImp(objectProto)
    487487{
    488   Value protect(this);
    489   setInternalValue(NumberImp::create(NaN));
     488  setInternalValue(jsNaN());
    490489  // The constructor will be added later, after DateObjectImp has been built
    491490}
     
    500499DateProtoFuncImp::DateProtoFuncImp(ExecState *exec, int i, int len)
    501500  : InternalFunctionImp(
    502     static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype().imp())
     501    static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype())
    503502    ), id(abs(i)), utc(i<0)
    504503  // We use a negative ID to denote the "UTC" variant.
    505504{
    506   Value protect(this);
    507505  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
    508506}
     
    513511}
    514512
    515 Value DateProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &args)
     513ValueImp *DateProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
    516514{
    517515  if ((id == ToString || id == ValueOf || id == GetTime || id == SetTime) &&
    518       !thisObj.inherits(&DateInstanceImp::info)) {
     516      !thisObj->inherits(&DateInstanceImp::info)) {
    519517    // non-generic function called on non-date object
    520518
    521519    // ToString and ValueOf are generic according to the spec, but the mozilla
    522520    // tests suggest otherwise...
    523     Object err = Error::create(exec,TypeError);
     521    ObjectImp *err = Error::create(exec,TypeError);
    524522    exec->setException(err);
    525523    return err;
     
    527525
    528526
    529   Value result;
     527  ValueImp *result = NULL;
    530528  UString s;
    531529#if !APPLE_CHANGES
     
    536534    oldlocale = setlocale(LC_ALL, NULL);
    537535#endif
    538   Value v = thisObj.internalValue();
    539   double milli = v.toNumber(exec);
     536  ValueImp *v = thisObj->internalValue();
     537  double milli = v->toNumber(exec);
    540538 
    541539  if (isNaN(milli)) {
     
    562560      case GetMilliSeconds:
    563561      case GetTimezoneOffset:
    564         return Number(NaN);
     562        return jsNaN();
    565563    }
    566564  }
     
    708706    milli = roundValue(exec, args[0]);
    709707    result = Number(milli);
    710     thisObj.setInternalValue(result);
     708    thisObj->setInternalValue(result);
    711709    break;
    712710  case SetMilliSeconds:
     
    724722  case SetDate:
    725723      t->tm_mday = 0;
    726       ms += args[0].toInt32(exec) * msPerDay;
     724      ms += args[0]->toInt32(exec) * msPerDay;
    727725      break;
    728726  case SetMonth:
    729     t->tm_mon = args[0].toInt32(exec);
     727    t->tm_mon = args[0]->toInt32(exec);
    730728    if (args.size() >= 2)
    731       t->tm_mday = args[1].toInt32(exec);
     729      t->tm_mday = args[1]->toInt32(exec);
    732730    break;
    733731  case SetFullYear:
    734     t->tm_year = args[0].toInt32(exec) - 1900;
     732    t->tm_year = args[0]->toInt32(exec) - 1900;
    735733    if (args.size() >= 2)
    736       t->tm_mon = args[1].toInt32(exec);
     734      t->tm_mon = args[1]->toInt32(exec);
    737735    if (args.size() >= 3)
    738       t->tm_mday = args[2].toInt32(exec);
     736      t->tm_mday = args[2]->toInt32(exec);
    739737    break;
    740738  case SetYear:
    741     t->tm_year = args[0].toInt32(exec) >= 1900 ? args[0].toInt32(exec) - 1900 : args[0].toInt32(exec);
     739    t->tm_year = args[0]->toInt32(exec) >= 1900 ? args[0]->toInt32(exec) - 1900 : args[0]->toInt32(exec);
    742740    break;
    743741  }
     
    747745      id == SetMonth || id == SetFullYear ) {
    748746    result = Number(makeTime(t, ms, utc));
    749     thisObj.setInternalValue(result);
     747    thisObj->setInternalValue(result);
    750748  }
    751749 
     
    762760  : InternalFunctionImp(funcProto)
    763761{
    764   Value protect(this);
    765  
    766762  // ECMA 15.9.4.1 Date.prototype
    767763  putDirect(prototypePropertyName, dateProto, DontEnum|DontDelete|ReadOnly);
     
    782778
    783779// ECMA 15.9.3
    784 Object DateObjectImp::construct(ExecState *exec, const List &args)
     780ObjectImp *DateObjectImp::construct(ExecState *exec, const List &args)
    785781{
    786782  int numArgs = args.size();
     
    808804    value = utc;
    809805  } else if (numArgs == 1) {
    810       if (args[0].type() == StringType)
    811           value = parseDate(args[0].toString(exec));
     806      if (args[0]->isString())
     807          value = parseDate(args[0]->toString(exec));
    812808      else
    813           value = args[0].toPrimitive(exec).toNumber(exec);
     809          value = args[0]->toPrimitive(exec)->toNumber(exec);
    814810  } else {
    815811    struct tm t;
    816812    memset(&t, 0, sizeof(t));
    817     if (isNaN(args[0].toNumber(exec))
    818         || isNaN(args[1].toNumber(exec))
    819         || (numArgs >= 3 && isNaN(args[2].toNumber(exec)))
    820         || (numArgs >= 4 && isNaN(args[3].toNumber(exec)))
    821         || (numArgs >= 5 && isNaN(args[4].toNumber(exec)))
    822         || (numArgs >= 6 && isNaN(args[5].toNumber(exec)))
    823         || (numArgs >= 7 && isNaN(args[6].toNumber(exec)))) {
     813    if (isNaN(args[0]->toNumber(exec))
     814        || isNaN(args[1]->toNumber(exec))
     815        || (numArgs >= 3 && isNaN(args[2]->toNumber(exec)))
     816        || (numArgs >= 4 && isNaN(args[3]->toNumber(exec)))
     817        || (numArgs >= 5 && isNaN(args[4]->toNumber(exec)))
     818        || (numArgs >= 6 && isNaN(args[5]->toNumber(exec)))
     819        || (numArgs >= 7 && isNaN(args[6]->toNumber(exec)))) {
    824820      value = NaN;
    825821    } else {
    826       int year = args[0].toInt32(exec);
     822      int year = args[0]->toInt32(exec);
    827823      t.tm_year = (year >= 0 && year <= 99) ? year : year - 1900;
    828       t.tm_mon = args[1].toInt32(exec);
    829       t.tm_mday = (numArgs >= 3) ? args[2].toInt32(exec) : 1;
    830       t.tm_hour = (numArgs >= 4) ? args[3].toInt32(exec) : 0;
    831       t.tm_min = (numArgs >= 5) ? args[4].toInt32(exec) : 0;
    832       t.tm_sec = (numArgs >= 6) ? args[5].toInt32(exec) : 0;
     824      t.tm_mon = args[1]->toInt32(exec);
     825      t.tm_mday = (numArgs >= 3) ? args[2]->toInt32(exec) : 1;
     826      t.tm_hour = (numArgs >= 4) ? args[3]->toInt32(exec) : 0;
     827      t.tm_min = (numArgs >= 5) ? args[4]->toInt32(exec) : 0;
     828      t.tm_sec = (numArgs >= 6) ? args[5]->toInt32(exec) : 0;
    833829      t.tm_isdst = -1;
    834830      double ms = (numArgs >= 7) ? roundValue(exec, args[6]) : 0;
     
    837833  }
    838834 
    839   Object proto = exec->lexicalInterpreter()->builtinDatePrototype();
    840   Object ret(new DateInstanceImp(proto.imp()));
    841   ret.setInternalValue(Number(timeClip(value)));
     835  DateInstanceImp *ret = new DateInstanceImp(exec->lexicalInterpreter()->builtinDatePrototype());
     836  ret->setInternalValue(Number(timeClip(value)));
    842837  return ret;
    843838}
     
    849844
    850845// ECMA 15.9.2
    851 Value DateObjectImp::call(ExecState */*exec*/, Object &/*thisObj*/, const List &/*args*/)
    852 {
    853 #ifdef KJS_VERBOSE
    854   fprintf(stderr,"DateObjectImp::call - current time\n");
    855 #endif
     846ValueImp *DateObjectImp::callAsFunction(ExecState */*exec*/, ObjectImp */*thisObj*/, const List &/*args*/)
     847{
    856848  time_t t = time(0L);
    857849#if APPLE_CHANGES
     
    872864  : InternalFunctionImp(funcProto), id(i)
    873865{
    874   Value protect(this);
    875866  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
    876867}
     
    882873
    883874// ECMA 15.9.4.2 - 3
    884 Value DateObjectFuncImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
     875ValueImp *DateObjectFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
    885876{
    886877  if (id == Parse) {
    887     return Number(parseDate(args[0].toString(exec)));
     878    return Number(parseDate(args[0]->toString(exec)));
    888879  }
    889880  else { // UTC
     
    891882    memset(&t, 0, sizeof(t));
    892883    int n = args.size();
    893     if (isNaN(args[0].toNumber(exec))
    894         || isNaN(args[1].toNumber(exec))
    895         || (n >= 3 && isNaN(args[2].toNumber(exec)))
    896         || (n >= 4 && isNaN(args[3].toNumber(exec)))
    897         || (n >= 5 && isNaN(args[4].toNumber(exec)))
    898         || (n >= 6 && isNaN(args[5].toNumber(exec)))
    899         || (n >= 7 && isNaN(args[6].toNumber(exec)))) {
     884    if (isNaN(args[0]->toNumber(exec))
     885        || isNaN(args[1]->toNumber(exec))
     886        || (n >= 3 && isNaN(args[2]->toNumber(exec)))
     887        || (n >= 4 && isNaN(args[3]->toNumber(exec)))
     888        || (n >= 5 && isNaN(args[4]->toNumber(exec)))
     889        || (n >= 6 && isNaN(args[5]->toNumber(exec)))
     890        || (n >= 7 && isNaN(args[6]->toNumber(exec)))) {
    900891      return Number(NaN);
    901892    }
    902     int year = args[0].toInt32(exec);
     893    int year = args[0]->toInt32(exec);
    903894    t.tm_year = (year >= 0 && year <= 99) ? year : year - 1900;
    904     t.tm_mon = args[1].toInt32(exec);
    905     t.tm_mday = (n >= 3) ? args[2].toInt32(exec) : 1;
    906     t.tm_hour = (n >= 4) ? args[3].toInt32(exec) : 0;
    907     t.tm_min = (n >= 5) ? args[4].toInt32(exec) : 0;
    908     t.tm_sec = (n >= 6) ? args[5].toInt32(exec) : 0;
     895    t.tm_mon = args[1]->toInt32(exec);
     896    t.tm_mday = (n >= 3) ? args[2]->toInt32(exec) : 1;
     897    t.tm_hour = (n >= 4) ? args[3]->toInt32(exec) : 0;
     898    t.tm_min = (n >= 5) ? args[4]->toInt32(exec) : 0;
     899    t.tm_sec = (n >= 6) ? args[5]->toInt32(exec) : 0;
    909900    double ms = (n >= 7) ? roundValue(exec, args[6]) : 0;
    910901    return Number(makeTime(&t, ms, true));
     
    915906
    916907
    917 double KJS::parseDate(const UString &u)
     908double parseDate(const UString &u)
    918909{
    919910#ifdef KJS_VERBOSE
     
    10281019}
    10291020
    1030 double KJS::KRFCDate_parseDate(const UString &_date)
     1021double KRFCDate_parseDate(const UString &_date)
    10311022{
    10321023     // This parse a date in the form:
     
    13451336
    13461337
    1347 double KJS::timeClip(double t)
     1338double timeClip(double t)
    13481339{
    13491340    if (!isfinite(t))
     
    13541345    return copysign(floor(at), t);
    13551346}
     1347
     1348}
  • trunk/JavaScriptCore/kjs/date_object.h

    r10076 r10084  
    6363
    6464    virtual bool implementsCall() const;
    65     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     65    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    6666
    6767
     
    9292
    9393    virtual bool implementsConstruct() const;
    94     virtual Object construct(ExecState *exec, const List &args);
     94    virtual ObjectImp *construct(ExecState *exec, const List &args);
    9595    virtual bool implementsCall() const;
    96     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     96    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    9797
    9898    Completion execute(const List &);
    99     Object construct(const List &);
     99    ObjectImp *construct(const List &);
    100100  };
    101101
     
    112112
    113113    virtual bool implementsCall() const;
    114     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     114    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    115115
    116116    enum { Parse, UTC };
  • trunk/JavaScriptCore/kjs/debugger.cpp

    r9929 r10084  
    100100
    101101bool Debugger::exception(ExecState */*exec*/, int /*sourceId*/, int /*lineno*/,
    102                          Object &/*exceptionObj*/)
     102                         ObjectImp */*exceptionObj*/)
    103103{
    104104  return true;
     
    112112
    113113bool Debugger::callEvent(ExecState */*exec*/, int /*sourceId*/, int /*lineno*/,
    114                          Object &/*function*/, const List &/*args*/)
     114                         ObjectImp */*function*/, const List &/*args*/)
    115115{
    116116  return true;
     
    118118
    119119bool Debugger::returnEvent(ExecState */*exec*/, int /*sourceId*/, int /*lineno*/,
    120                            Object &/*function*/)
     120                           ObjectImp */*function*/)
    121121{
    122122  return true;
  • trunk/JavaScriptCore/kjs/debugger.h

    r9929 r10084  
    2929  class Interpreter;
    3030  class ExecState;
    31   class Object;
     31  class ObjectImp;
    3232  class UString;
    3333  class List;
     
    142142     */
    143143    virtual bool exception(ExecState *exec, int sourceId, int lineno,
    144                            Object &exceptionObj);
     144                           ObjectImp *exceptionObj);
    145145
    146146    /**
     
    182182     */
    183183    virtual bool callEvent(ExecState *exec, int sourceId, int lineno,
    184                            Object &function, const List &args);
     184                           ObjectImp *function, const List &args);
    185185
    186186    /**
     
    203203     */
    204204    virtual bool returnEvent(ExecState *exec, int sourceId, int lineno,
    205                              Object &function);
     205                             ObjectImp *function);
    206206
    207207  private:
  • trunk/JavaScriptCore/kjs/error_object.cpp

    r9819 r10084  
    4848  : ObjectImp(objectProto)
    4949{
    50   Value protect(this);
    5150  setInternalValue(Undefined());
    5251  // The constructor will be added later in ErrorObjectImp's constructor
     
    6261  : InternalFunctionImp(funcProto)
    6362{
    64   Value protect(this);
    65   putDirect(lengthPropertyName, NumberImp::zero(), DontDelete|ReadOnly|DontEnum);
     63  putDirect(lengthPropertyName, jsZero(), DontDelete|ReadOnly|DontEnum);
    6664}
    6765
     
    7169}
    7270
    73 Value ErrorProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &/*args*/)
     71ValueImp *ErrorProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &/*args*/)
    7472{
    7573  // toString()
    7674  UString s = "Error";
    7775
    78   Value v = thisObj.get(exec, namePropertyName);
    79   if (v.type() != UndefinedType) {
    80     s = v.toString(exec);
     76  ValueImp *v = thisObj->get(exec, namePropertyName);
     77  if (!v->isUndefined()) {
     78    s = v->toString(exec);
    8179  }
    8280
    83   v = thisObj.get(exec, messagePropertyName);
    84   if (v.type() != UndefinedType) {
    85     s += ": " + v.toString(exec); // Mozilla compatible format
     81  v = thisObj->get(exec, messagePropertyName);
     82  if (!v->isUndefined()) {
     83    s += ": " + v->toString(exec); // Mozilla compatible format
    8684  }
    8785
     
    9593  : InternalFunctionImp(funcProto)
    9694{
    97   Value protect(this);
    9895  // ECMA 15.11.3.1 Error.prototype
    9996  putDirect(prototypePropertyName, errorProto, DontEnum|DontDelete|ReadOnly);
    100   putDirect(lengthPropertyName, NumberImp::one(), DontDelete|ReadOnly|DontEnum);
     97  putDirect(lengthPropertyName, jsOne(), DontDelete|ReadOnly|DontEnum);
    10198  //putDirect(namePropertyName, String(n));
    10299}
     
    108105
    109106// ECMA 15.9.3
    110 Object ErrorObjectImp::construct(ExecState *exec, const List &args)
     107ObjectImp *ErrorObjectImp::construct(ExecState *exec, const List &args)
    111108{
    112   Object proto = Object::dynamicCast(exec->lexicalInterpreter()->builtinErrorPrototype());
    113   ObjectImp *imp = new ErrorInstanceImp(proto.imp());
    114   Object obj(imp);
     109  ObjectImp *proto = static_cast<ObjectImp *>(exec->lexicalInterpreter()->builtinErrorPrototype());
     110  ObjectImp *imp = new ErrorInstanceImp(proto);
     111  ObjectImp *obj(imp);
    115112
    116   if (!args.isEmpty() && args[0].type() != UndefinedType) {
    117     imp->putDirect(messagePropertyName, new StringImp(args[0].toString(exec)));
    118   }
     113  if (!args[0]->isUndefined())
     114    imp->putDirect(messagePropertyName, jsString(args[0]->toString(exec)));
    119115
    120116  return obj;
     
    127123
    128124// ECMA 15.9.2
    129 Value ErrorObjectImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
     125ValueImp *ErrorObjectImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
    130126{
    131127  // "Error()" gives the sames result as "new Error()"
     
    139135  : ObjectImp(errorProto)
    140136{
    141   Value protect(this);
    142137  errType = et;
    143   putDirect(namePropertyName, new StringImp(name), 0);
    144   putDirect(messagePropertyName, new StringImp(message), 0);
     138  putDirect(namePropertyName, jsString(name), 0);
     139  putDirect(messagePropertyName, jsString(message), 0);
    145140}
    146141
     
    150145
    151146NativeErrorImp::NativeErrorImp(ExecState *exec, FunctionPrototypeImp *funcProto,
    152                                const Object &prot)
     147                               ObjectImp *prot)
    153148  : InternalFunctionImp(funcProto), proto(0)
    154149{
    155   Value protect(this);
    156   proto = static_cast<ObjectImp*>(prot.imp());
     150  proto = static_cast<ObjectImp*>(prot);
    157151
    158   putDirect(lengthPropertyName, NumberImp::one(), DontDelete|ReadOnly|DontEnum); // ECMA 15.11.7.5
     152  putDirect(lengthPropertyName, jsOne(), DontDelete|ReadOnly|DontEnum); // ECMA 15.11.7.5
    159153  putDirect(prototypePropertyName, proto, DontDelete|ReadOnly|DontEnum);
    160154}
     
    165159}
    166160
    167 Object NativeErrorImp::construct(ExecState *exec, const List &args)
     161ObjectImp *NativeErrorImp::construct(ExecState *exec, const List &args)
    168162{
    169163  ObjectImp *imp = new ErrorInstanceImp(proto);
    170   Object obj(imp);
    171   if (args[0].type() != UndefinedType)
    172     imp->putDirect(messagePropertyName, new StringImp(args[0].toString(exec)));
     164  ObjectImp *obj(imp);
     165  if (!args[0]->isUndefined())
     166    imp->putDirect(messagePropertyName, jsString(args[0]->toString(exec)));
    173167  return obj;
    174168}
     
    179173}
    180174
    181 Value NativeErrorImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
     175ValueImp *NativeErrorImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
    182176{
    183177  return construct(exec,args);
  • trunk/JavaScriptCore/kjs/error_object.h

    r9795 r10084  
    4747    ErrorProtoFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto);
    4848    virtual bool implementsCall() const;
    49     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     49    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    5050  };
    5151
     
    5656
    5757    virtual bool implementsConstruct() const;
    58     virtual Object construct(ExecState *exec, const List &args);
     58    virtual ObjectImp *construct(ExecState *exec, const List &args);
    5959
    6060    virtual bool implementsCall() const;
    61     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     61    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    6262  };
    6363
     
    7373  public:
    7474    NativeErrorImp(ExecState *exec, FunctionPrototypeImp *funcProto,
    75                    const Object &prot);
     75                   ObjectImp *prot);
    7676
    7777    virtual bool implementsConstruct() const;
    78     virtual Object construct(ExecState *exec, const List &args);
     78    virtual ObjectImp *construct(ExecState *exec, const List &args);
    7979    virtual bool implementsCall() const;
    80     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     80    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    8181
    8282    virtual void mark();
  • trunk/JavaScriptCore/kjs/function.cpp

    r10076 r10084  
    5959FunctionImp::FunctionImp(ExecState *exec, const Identifier &n)
    6060  : InternalFunctionImp(
    61       static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype().imp())
     61      static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype())
    6262      ), param(0L), ident(n)
    6363{
     
    7474}
    7575
    76 Value FunctionImp::call(ExecState *exec, Object &thisObj, const List &args)
    77 {
    78   Object &globalObj = exec->dynamicInterpreter()->globalObject();
     76ValueImp *FunctionImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
     77{
     78  ObjectImp *globalObj = exec->dynamicInterpreter()->globalObject();
    7979
    8080  // enter a new execution context
     
    9898    }
    9999
    100     Object func(this);
    101     bool cont = dbg->callEvent(&newExec,sid,lineno,func,args);
     100    bool cont = dbg->callEvent(&newExec,sid,lineno,this,args);
    102101    if (!cont) {
    103102      dbg->imp()->abort();
     
    128127        newExec.setException(comp.value());
    129128
    130     Object func(this);
    131     int cont = dbg->returnEvent(&newExec,sid,lineno,func);
     129    int cont = dbg->returnEvent(&newExec,sid,lineno,this);
    132130    if (!cont) {
    133131      dbg->imp()->abort();
     
    173171void FunctionImp::processParameters(ExecState *exec, const List &args)
    174172{
    175   Object variable = exec->context().imp()->variableObject();
     173  ObjectImp *variable = exec->context().imp()->variableObject();
    176174
    177175#ifdef KJS_VERBOSE
     
    190188        printInfo(exec,"to", *it);
    191189#endif
    192         variable.put(exec, p->name, *it);
     190        variable->put(exec, p->name, *it);
    193191        it++;
    194192      } else
    195         variable.put(exec, p->name, Undefined());
     193        variable->put(exec, p->name, Undefined());
    196194      p = p->next;
    197195    }
     
    209207}
    210208
    211 Value FunctionImp::argumentsGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
     209ValueImp *FunctionImp::argumentsGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
    212210{
    213211  FunctionImp *thisObj = static_cast<FunctionImp *>(slot.slotBase());
     
    222220}
    223221
    224 Value FunctionImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
     222ValueImp *FunctionImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
    225223{
    226224  FunctionImp *thisObj = static_cast<FunctionImp *>(slot.slotBase());
     
    251249}
    252250
    253 void FunctionImp::put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr)
     251void FunctionImp::put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr)
    254252{
    255253    if (propertyName == exec->dynamicInterpreter()->argumentsIdentifier() || propertyName == lengthPropertyName)
     
    306304  : FunctionImp(exec,n), body(b)
    307305{
    308   Value protect(this);
    309306  body->ref();
    310307  setScope(sc);
     
    323320
    324321// ECMA 13.2.2 [[Construct]]
    325 Object DeclaredFunctionImp::construct(ExecState *exec, const List &args)
    326 {
    327   Object proto;
    328   Value p = get(exec,prototypePropertyName);
    329   if (p.type() == ObjectType)
    330     proto = Object(static_cast<ObjectImp*>(p.imp()));
     322ObjectImp *DeclaredFunctionImp::construct(ExecState *exec, const List &args)
     323{
     324  ObjectImp *proto;
     325  ValueImp *p = get(exec,prototypePropertyName);
     326  if (p->isObject())
     327    proto = static_cast<ObjectImp*>(p);
    331328  else
    332329    proto = exec->lexicalInterpreter()->builtinObjectPrototype();
    333330
    334   Object obj(new ObjectImp(proto));
    335 
    336   Value res = call(exec,obj,args);
    337 
    338   if (res.type() == ObjectType)
    339     return Object::dynamicCast(res);
     331  ObjectImp *obj(new ObjectImp(proto));
     332
     333  ValueImp *res = call(exec,obj,args);
     334
     335  if (res->isObject())
     336    return static_cast<ObjectImp *>(res);
    340337  else
    341338    return obj;
     
    434431indexToNameMap(func, args)
    435432{
    436   Value protect(this);
    437433  putDirect(calleePropertyName, func, DontEnum);
    438434  putDirect(lengthPropertyName, args.size(), DontEnum);
     
    454450}
    455451
    456 Value ArgumentsImp::mappedIndexGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
     452ValueImp *ArgumentsImp::mappedIndexGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
    457453{
    458454  ArgumentsImp *thisObj = static_cast<ArgumentsImp *>(slot.slotBase());
     
    470466}
    471467
    472 void ArgumentsImp::put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr)
     468void ArgumentsImp::put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr)
    473469{
    474470  if (indexToNameMap.isMapped(propertyName)) {
     
    501497}
    502498
    503 Value ActivationImp::argumentsGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
     499ValueImp *ActivationImp::argumentsGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
    504500{
    505501  ActivationImp *thisObj = static_cast<ActivationImp *>(slot.slotBase());
     
    509505    thisObj->createArgumentsObject(exec);
    510506 
    511   return Value(thisObj->_argumentsObject);
     507  return thisObj->_argumentsObject;
    512508}
    513509
     
    559555  : InternalFunctionImp(funcProto), id(i)
    560556{
    561   Value protect(this);
    562557  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
    563558}
     
    573568}
    574569
    575 static Value encode(ExecState *exec, const List &args, const char *do_not_escape)
    576 {
    577   UString r = "", s, str = args[0].toString(exec);
     570static ValueImp *encode(ExecState *exec, const List &args, const char *do_not_escape)
     571{
     572  UString r = "", s, str = args[0]->toString(exec);
    578573  CString cstr = str.UTF8String();
    579574  const char *p = cstr.c_str();
     
    591586}
    592587
    593 static Value decode(ExecState *exec, const List &args, const char *do_not_unescape, bool strict)
    594 {
    595   UString s = "", str = args[0].toString(exec);
     588static ValueImp *decode(ExecState *exec, const List &args, const char *do_not_unescape, bool strict)
     589{
     590  UString s = "", str = args[0]->toString(exec);
    596591  int k = 0, len = str.size();
    597592  const UChar *d = str.data();
     
    635630      if (charLen == 0) {
    636631        if (strict) {
    637           Object error = Error::create(exec, URIError);
     632          ObjectImp *error = Error::create(exec, URIError);
    638633          exec->setException(error);
    639634          return error;
     
    768763}
    769764
    770 Value GlobalFuncImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
    771 {
    772   Value res;
     765ValueImp *GlobalFuncImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
     766{
     767  ValueImp *res = jsUndefined();
    773768
    774769  static const char do_not_escape[] =
     
    793788  switch (id) {
    794789    case Eval: { // eval()
    795       Value x = args[0];
    796       if (x.type() != StringType)
     790      ValueImp *x = args[0];
     791      if (!x->isString())
    797792        return x;
    798793      else {
    799         UString s = x.toString(exec);
     794        UString s = x->toString(exec);
    800795       
    801796        int sid;
     
    813808        // no program node means a syntax occurred
    814809        if (!progNode) {
    815           Object err = Error::create(exec,SyntaxError,errMsg.ascii(),errLine);
    816           err.put(exec,"sid",Number(sid));
     810          ObjectImp *err = Error::create(exec,SyntaxError,errMsg.ascii(),errLine);
     811          err->put(exec,"sid",Number(sid));
    817812          exec->setException(err);
    818813          return err;
     
    822817       
    823818        // enter a new execution context
    824         Object thisVal(Object::dynamicCast(exec->context().thisValue()));
     819        ObjectImp *thisVal = static_cast<ObjectImp *>(exec->context().thisValue());
    825820        ContextImp ctx(exec->dynamicInterpreter()->globalObject(),
    826821                       exec->dynamicInterpreter()->imp(),
     
    852847    }
    853848  case ParseInt:
    854     res = Number(parseInt(args[0].toString(exec), args[1].toInt32(exec)));
     849    res = Number(parseInt(args[0]->toString(exec), args[1]->toInt32(exec)));
    855850    break;
    856851  case ParseFloat:
    857     res = Number(parseFloat(args[0].toString(exec)));
     852    res = Number(parseFloat(args[0]->toString(exec)));
    858853    break;
    859854  case IsNaN:
    860     res = Boolean(isNaN(args[0].toNumber(exec)));
     855    res = Boolean(isNaN(args[0]->toNumber(exec)));
    861856    break;
    862857  case IsFinite: {
    863     double n = args[0].toNumber(exec);
     858    double n = args[0]->toNumber(exec);
    864859    res = Boolean(!isNaN(n) && !isInf(n));
    865860    break;
     
    879874  case Escape:
    880875    {
    881       UString r = "", s, str = args[0].toString(exec);
     876      UString r = "", s, str = args[0]->toString(exec);
    882877      const UChar *c = str.data();
    883878      for (int k = 0; k < str.size(); k++, c++) {
     
    901896  case UnEscape:
    902897    {
    903       UString s = "", str = args[0].toString(exec);
     898      UString s = "", str = args[0]->toString(exec);
    904899      int k = 0, len = str.size();
    905900      while (k < len) {
     
    928923#ifndef NDEBUG
    929924  case KJSPrint:
    930     puts(args[0].toString(exec).ascii());
     925    puts(args[0]->toString(exec).ascii());
    931926    break;
    932927#endif
  • trunk/JavaScriptCore/kjs/function.h

    r10076 r10084  
    4444
    4545    virtual bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot&);
    46     virtual void put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr = None);
     46    virtual void put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr = None);
    4747    virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
    4848
    4949    virtual bool implementsCall() const;
    50     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     50    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    5151
    5252    void addParameter(const Identifier &n);
     
    6666
    6767  private:
    68     static Value argumentsGetter(ExecState *, const Identifier &, const PropertySlot&);
    69     static Value lengthGetter(ExecState *, const Identifier &, const PropertySlot&);
     68    static ValueImp *argumentsGetter(ExecState *, const Identifier &, const PropertySlot&);
     69    static ValueImp *lengthGetter(ExecState *, const Identifier &, const PropertySlot&);
    7070
    7171    void processParameters(ExecState *exec, const List &);
     
    8080
    8181    bool implementsConstruct() const;
    82     Object construct(ExecState *exec, const List &args);
     82    ObjectImp *construct(ExecState *exec, const List &args);
    8383
    8484    virtual Completion execute(ExecState *exec);
     
    113113    virtual void mark();
    114114    virtual bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot&);
    115     virtual void put(ExecState *exec, const Identifier &propertyName,
    116                      const Value &value, int attr = None);
     115    virtual void put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr = None);
    117116    virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
    118117    virtual const ClassInfo *classInfo() const { return &info; }
    119118    static const ClassInfo info;
    120119  private:
    121     static Value mappedIndexGetter(ExecState *exec, const Identifier &, const PropertySlot& slot);
     120    static ValueImp *mappedIndexGetter(ExecState *exec, const Identifier &, const PropertySlot& slot);
    122121
    123122    ActivationImp *_activationObject;
     
    139138  private:
    140139    static PropertySlot::GetValueFunc getArgumentsGetter();
    141     static Value argumentsGetter(ExecState *exec, const Identifier &, const PropertySlot& slot);
     140    static ValueImp *argumentsGetter(ExecState *exec, const Identifier &, const PropertySlot& slot);
    142141    void createArgumentsObject(ExecState *exec) const;
    143142   
     
    151150    GlobalFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto, int i, int len);
    152151    virtual bool implementsCall() const;
    153     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     152    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    154153    virtual CodeType codeType() const;
    155154    enum { Eval, ParseInt, ParseFloat, IsNaN, IsFinite, Escape, UnEscape,
  • trunk/JavaScriptCore/kjs/function_object.cpp

    r9929 r10084  
    4141  : InternalFunctionImp(0)
    4242{
    43   Value protect(this);
    44   putDirect(lengthPropertyName,   NumberImp::zero(),                                                       DontDelete|ReadOnly|DontEnum);
     43  putDirect(lengthPropertyName,   jsZero(),                                                       DontDelete|ReadOnly|DontEnum);
    4544  putDirect(toStringPropertyName, new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::ToString, 0), DontEnum);
    4645  static const Identifier applyPropertyName("apply");
     
    6059
    6160// ECMA 15.3.4
    62 Value FunctionPrototypeImp::call(ExecState */*exec*/, Object &/*thisObj*/, const List &/*args*/)
     61ValueImp *FunctionPrototypeImp::callAsFunction(ExecState */*exec*/, ObjectImp */*thisObj*/, const List &/*args*/)
    6362{
    6463  return Undefined();
     
    7170  : InternalFunctionImp(funcProto), id(i)
    7271{
    73   Value protect(this);
    7472  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
    7573}
     
    8179}
    8280
    83 Value FunctionProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &args)
    84 {
    85   Value result;
     81ValueImp *FunctionProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
     82{
     83  ValueImp *result = NULL;
    8684
    8785  switch (id) {
    8886  case ToString: {
    8987    // ### also make this work for internal functions
    90     if (thisObj.isNull() || !thisObj.inherits(&InternalFunctionImp::info)) {
     88    if (!thisObj || !thisObj->inherits(&InternalFunctionImp::info)) {
    9189#ifndef NDEBUG
    9290      fprintf(stderr,"attempted toString() call on null or non-function object\n");
    9391#endif
    94       Object err = Error::create(exec,TypeError);
     92      ObjectImp *err = Error::create(exec,TypeError);
    9593      exec->setException(err);
    9694      return err;
    9795    }
    98     if (thisObj.inherits(&DeclaredFunctionImp::info)) {
     96    if (thisObj->inherits(&DeclaredFunctionImp::info)) {
    9997       DeclaredFunctionImp *fi = static_cast<DeclaredFunctionImp*>
    100                                  (thisObj.imp());
     98                                 (thisObj);
    10199       return String("function " + fi->name().ustring() + "(" +
    102100         fi->parameterString() + ") " + fi->body->toString());
    103     } else if (thisObj.inherits(&FunctionImp::info) &&
    104         !static_cast<FunctionImp*>(thisObj.imp())->name().isNull()) {
    105       result = String("function " + static_cast<FunctionImp*>(thisObj.imp())->name().ustring() + "()");
     101    } else if (thisObj->inherits(&FunctionImp::info) &&
     102        !static_cast<FunctionImp*>(thisObj)->name().isNull()) {
     103      result = String("function " + static_cast<FunctionImp*>(thisObj)->name().ustring() + "()");
    106104    }
    107105    else {
     
    111109    break;
    112110  case Apply: {
    113     Value thisArg = args[0];
    114     Value argArray = args[1];
    115     Object func = thisObj;
    116 
    117     if (!func.implementsCall()) {
    118       Object err = Error::create(exec,TypeError);
     111    ValueImp *thisArg = args[0];
     112    ValueImp *argArray = args[1];
     113    ObjectImp *func = thisObj;
     114
     115    if (!func->implementsCall()) {
     116      ObjectImp *err = Error::create(exec,TypeError);
    119117      exec->setException(err);
    120118      return err;
    121119    }
    122120
    123     Object applyThis;
    124     if (thisArg.isA(NullType) || thisArg.isA(UndefinedType))
     121    ObjectImp *applyThis;
     122    if (thisArg->isUndefinedOrNull())
    125123      applyThis = exec->dynamicInterpreter()->globalObject();
    126124    else
    127       applyThis = thisArg.toObject(exec);
     125      applyThis = thisArg->toObject(exec);
    128126
    129127    List applyArgs;
    130     if (!argArray.isA(NullType) && !argArray.isA(UndefinedType)) {
    131       if (argArray.isA(ObjectType) &&
    132            (Object::dynamicCast(argArray).inherits(&ArrayInstanceImp::info) ||
    133             Object::dynamicCast(argArray).inherits(&ArgumentsImp::info))) {
    134 
    135         Object argArrayObj = Object::dynamicCast(argArray);
    136         unsigned int length = argArrayObj.get(exec,lengthPropertyName).toUInt32(exec);
     128    if (!argArray->isUndefinedOrNull()) {
     129      if (argArray->isObject() &&
     130           (static_cast<ObjectImp *>(argArray)->inherits(&ArrayInstanceImp::info) ||
     131            static_cast<ObjectImp *>(argArray)->inherits(&ArgumentsImp::info))) {
     132
     133        ObjectImp *argArrayObj = static_cast<ObjectImp *>(argArray);
     134        unsigned int length = argArrayObj->get(exec,lengthPropertyName)->toUInt32(exec);
    137135        for (unsigned int i = 0; i < length; i++)
    138           applyArgs.append(argArrayObj.get(exec,i));
     136          applyArgs.append(argArrayObj->get(exec,i));
    139137      }
    140138      else {
    141         Object err = Error::create(exec,TypeError);
     139        ObjectImp *err = Error::create(exec,TypeError);
    142140        exec->setException(err);
    143141        return err;
    144142      }
    145143    }
    146     result = func.call(exec,applyThis,applyArgs);
     144    result = func->call(exec,applyThis,applyArgs);
    147145    }
    148146    break;
    149147  case Call: {
    150     Value thisArg = args[0];
    151     Object func = thisObj;
    152 
    153     if (!func.implementsCall()) {
    154       Object err = Error::create(exec,TypeError);
     148    ValueImp *thisArg = args[0];
     149    ObjectImp *func = thisObj;
     150
     151    if (!func->implementsCall()) {
     152      ObjectImp *err = Error::create(exec,TypeError);
    155153      exec->setException(err);
    156154      return err;
    157155    }
    158156
    159     Object callThis;
    160     if (thisArg.isA(NullType) || thisArg.isA(UndefinedType))
     157    ObjectImp *callThis;
     158    if (thisArg->isUndefinedOrNull())
    161159      callThis = exec->dynamicInterpreter()->globalObject();
    162160    else
    163       callThis = thisArg.toObject(exec);
    164 
    165     result = func.call(exec,callThis,args.copyTail());
     161      callThis = thisArg->toObject(exec);
     162
     163    result = func->call(exec,callThis,args.copyTail());
    166164    }
    167165    break;
     
    176174  : InternalFunctionImp(funcProto)
    177175{
    178   Value protect(this);
    179176  putDirect(prototypePropertyName, funcProto, DontEnum|DontDelete|ReadOnly);
    180177
    181178  // no. of arguments for constructor
    182   putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum);
     179  putDirect(lengthPropertyName, jsOne(), ReadOnly|DontDelete|DontEnum);
    183180}
    184181
     
    193190
    194191// ECMA 15.3.2 The Function Constructor
    195 Object FunctionObjectImp::construct(ExecState *exec, const List &args, const UString &sourceURL, int lineNumber)
     192ObjectImp *FunctionObjectImp::construct(ExecState *exec, const List &args, const UString &sourceURL, int lineNumber)
    196193{
    197194  UString p("");
     
    201198    body = "";
    202199  } else if (argsSize == 1) {
    203     body = args[0].toString(exec);
     200    body = args[0]->toString(exec);
    204201  } else {
    205     p = args[0].toString(exec);
     202    p = args[0]->toString(exec);
    206203    for (int k = 1; k < argsSize - 1; k++)
    207       p += "," + args[k].toString(exec);
    208     body = args[argsSize-1].toString(exec);
     204      p += "," + args[k]->toString(exec);
     205    body = args[argsSize-1]->toString(exec);
    209206  }
    210207
     
    222219    if (!cont) {
    223220      dbg->imp()->abort();
    224       return Object(new ObjectImp());
     221      return new ObjectImp();
    225222    }
    226223  }
     
    228225  // no program node == syntax error - throw a syntax error
    229226  if (!progNode) {
    230     Object err = Error::create(exec,SyntaxError,errMsg.ascii(),errLine);
     227    ObjectImp *err = Error::create(exec,SyntaxError,errMsg.ascii(),errLine);
    231228    // we can't return a Completion(Throw) here, so just set the exception
    232229    // and return it
     
    236233
    237234  ScopeChain scopeChain;
    238   scopeChain.push(exec->dynamicInterpreter()->globalObject().imp());
     235  scopeChain.push(exec->dynamicInterpreter()->globalObject());
    239236  FunctionBodyNode *bodyNode = progNode;
    240237
    241238  FunctionImp *fimp = new DeclaredFunctionImp(exec, Identifier::null(), bodyNode,
    242239                                              scopeChain);
    243   Object ret(fimp); // protect from GC
    244240
    245241  // parse parameter list. throw syntax error on illegal identifiers
     
    272268          } // else error
    273269      }
    274       Object err = Error::create(exec,SyntaxError,
     270      ObjectImp *err = Error::create(exec,SyntaxError,
    275271                                 I18N_NOOP("Syntax error in parameter list"),
    276272                                 -1);
     
    281277  List consArgs;
    282278
    283   Object objCons = exec->lexicalInterpreter()->builtinObject();
    284   Object prototype = objCons.construct(exec,List::empty());
    285   prototype.put(exec, constructorPropertyName, Value(fimp), DontEnum|DontDelete|ReadOnly);
     279  ObjectImp *objCons = exec->lexicalInterpreter()->builtinObject();
     280  ObjectImp *prototype = objCons->construct(exec,List::empty());
     281  prototype->put(exec, constructorPropertyName, fimp, DontEnum|DontDelete|ReadOnly);
    286282  fimp->put(exec, prototypePropertyName, prototype, DontEnum|DontDelete|ReadOnly);
    287   return ret;
     283  return fimp;
    288284}
    289285
    290286// ECMA 15.3.2 The Function Constructor
    291 Object FunctionObjectImp::construct(ExecState *exec, const List &args)
     287ObjectImp *FunctionObjectImp::construct(ExecState *exec, const List &args)
    292288{
    293289  return FunctionObjectImp::construct(exec, args, UString(), 0);
     
    301297
    302298// ECMA 15.3.1 The Function Constructor Called as a Function
    303 Value FunctionObjectImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
     299ValueImp *FunctionObjectImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
    304300{
    305301  return construct(exec,args);
  • trunk/JavaScriptCore/kjs/function_object.h

    r9768 r10084  
    4141
    4242    virtual bool implementsCall() const;
    43     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     43    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    4444  };
    4545
     
    5656
    5757    virtual bool implementsCall() const;
    58     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     58    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    5959
    6060    enum { ToString, Apply, Call };
     
    7474
    7575    virtual bool implementsConstruct() const;
    76     virtual Object construct(ExecState *exec, const List &args, const UString &sourceURL, int lineNumber);
    77     virtual Object construct(ExecState *exec, const List &args);
     76    virtual ObjectImp *construct(ExecState *exec, const List &args, const UString &sourceURL, int lineNumber);
     77    virtual ObjectImp *construct(ExecState *exec, const List &args);
    7878    virtual bool implementsCall() const;
    79     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     79    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    8080  };
    8181
  • trunk/JavaScriptCore/kjs/internal.cpp

    r10076 r10084  
    5454extern int kjsyyparse();
    5555
    56 using namespace KJS;
     56namespace KJS {
    5757
    5858#if !APPLE_CHANGES
    5959
    60 namespace KJS {
    6160#ifdef WORDS_BIGENDIAN
    6261  const unsigned char NaN_Bytes[] = { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 };
     
    7271  const double NaN = *(const double*) NaN_Bytes;
    7372  const double Inf = *(const double*) Inf_Bytes;
    74 };
    7573
    7674#endif // APPLE_CHANGES
     
    108106// ------------------------------ UndefinedImp ---------------------------------
    109107
    110 UndefinedImp *UndefinedImp::staticUndefined = 0;
    111 
    112 Value UndefinedImp::toPrimitive(ExecState */*exec*/, Type) const
    113 {
    114   return Value((ValueImp*)this);
     108ValueImp *UndefinedImp::toPrimitive(ExecState */*exec*/, Type) const
     109{
     110  return const_cast<UndefinedImp *>(this);
    115111}
    116112
     
    130126}
    131127
    132 Object UndefinedImp::toObject(ExecState *exec) const
    133 {
    134   Object err = Error::create(exec, TypeError, I18N_NOOP("Undefined value"));
     128ObjectImp *UndefinedImp::toObject(ExecState *exec) const
     129{
     130  ObjectImp *err = Error::create(exec, TypeError, I18N_NOOP("Undefined value"));
    135131  exec->setException(err);
    136132  return err;
     
    139135// ------------------------------ NullImp --------------------------------------
    140136
    141 NullImp *NullImp::staticNull = 0;
    142 
    143 Value NullImp::toPrimitive(ExecState */*exec*/, Type) const
    144 {
    145   return Value((ValueImp*)this);
     137ValueImp *NullImp::toPrimitive(ExecState */*exec*/, Type) const
     138{
     139  return const_cast<NullImp *>(this);
    146140}
    147141
     
    161155}
    162156
    163 Object NullImp::toObject(ExecState *exec) const
    164 {
    165   Object err = Error::create(exec, TypeError, I18N_NOOP("Null value"));
     157ObjectImp *NullImp::toObject(ExecState *exec) const
     158{
     159  ObjectImp *err = Error::create(exec, TypeError, I18N_NOOP("Null value"));
    166160  exec->setException(err);
    167161  return err;
     
    170164// ------------------------------ BooleanImp -----------------------------------
    171165
    172 BooleanImp* BooleanImp::staticTrue = 0;
    173 BooleanImp* BooleanImp::staticFalse = 0;
    174 
    175 Value BooleanImp::toPrimitive(ExecState */*exec*/, Type) const
    176 {
    177   return Value((ValueImp*)this);
     166ValueImp *BooleanImp::toPrimitive(ExecState */*exec*/, Type) const
     167{
     168  return const_cast<BooleanImp *>(this);
    178169}
    179170
     
    193184}
    194185
    195 Object BooleanImp::toObject(ExecState *exec) const
     186ObjectImp *BooleanImp::toObject(ExecState *exec) const
    196187{
    197188  List args;
    198189  args.append(const_cast<BooleanImp*>(this));
    199   return Object::dynamicCast(exec->lexicalInterpreter()->builtinBoolean().construct(exec,args));
     190  return static_cast<ObjectImp *>(exec->lexicalInterpreter()->builtinBoolean()->construct(exec,args));
    200191}
    201192
    202193// ------------------------------ StringImp ------------------------------------
    203194
    204 Value StringImp::toPrimitive(ExecState */*exec*/, Type) const
    205 {
    206   return Value((ValueImp*)this);
     195ValueImp *StringImp::toPrimitive(ExecState */*exec*/, Type) const
     196{
     197  return const_cast<StringImp *>(this);
    207198}
    208199
     
    222213}
    223214
    224 Object StringImp::toObject(ExecState *exec) const
     215ObjectImp *StringImp::toObject(ExecState *exec) const
    225216{
    226217  List args;
    227218  args.append(const_cast<StringImp*>(this));
    228   return Object(static_cast<ObjectImp *>(exec->lexicalInterpreter()->builtinString().construct(exec, args).imp()));
     219  return static_cast<ObjectImp *>(exec->lexicalInterpreter()->builtinString()->construct(exec, args));
    229220}
    230221
    231222// ------------------------------ NumberImp ------------------------------------
    232223
    233 NumberImp *NumberImp::staticNaN;
    234 
    235 ValueImp *NumberImp::create(int i)
    236 {
    237     if (SimpleNumber::fits(i))
    238         return SimpleNumber::make(i);
    239     return new NumberImp(static_cast<double>(i));
    240 }
    241 
    242 ValueImp *NumberImp::create(double d)
    243 {
    244     if (SimpleNumber::fits(d))
    245         return SimpleNumber::make((int)d);
    246     if (isNaN(d))
    247         return staticNaN;
    248     return new NumberImp(d);
    249 }
    250 
    251 Value NumberImp::toPrimitive(ExecState *, Type) const
    252 {
    253   return Number((NumberImp*)this);
     224ValueImp *NumberImp::toPrimitive(ExecState *, Type) const
     225{
     226  return const_cast<NumberImp *>(this);
    254227}
    255228
     
    271244}
    272245
    273 Object NumberImp::toObject(ExecState *exec) const
     246ObjectImp *NumberImp::toObject(ExecState *exec) const
    274247{
    275248  List args;
    276249  args.append(const_cast<NumberImp*>(this));
    277   return Object::dynamicCast(exec->lexicalInterpreter()->builtinNumber().construct(exec,args));
    278 }
    279 
    280 bool NumberImp::toUInt32(unsigned& uint32) const
    281 {
    282   uint32 = (unsigned)val;
     250  return static_cast<ObjectImp *>(exec->lexicalInterpreter()->builtinNumber()->construct(exec,args));
     251}
     252
     253bool NumberImp::getUInt32(uint32_t& uint32) const
     254{
     255  uint32 = (uint32_t)val;
    283256  return (double)uint32 == val;
    284257}
     
    316289bool LabelStack::push(const Identifier &id)
    317290{
    318   if (id.isEmpty() || contains(id))
     291  if (contains(id))
    319292    return false;
    320293
     
    366339
    367340// ECMA 10.2
    368 ContextImp::ContextImp(Object &glob, InterpreterImp *interpreter, Object &thisV, CodeType type,
     341ContextImp::ContextImp(ObjectImp *glob, InterpreterImp *interpreter, ObjectImp *thisV, CodeType type,
    369342                       ContextImp *callingCon, FunctionImp *func, const List *args)
    370343    : _interpreter(interpreter), _function(func), _arguments(args)
     
    375348  // create and initialize activation object (ECMA 10.1.6)
    376349  if (type == FunctionCode || type == AnonymousCode ) {
    377     activation = Object(new ActivationImp(func, *args));
     350    activation = new ActivationImp(func, *args);
    378351    variable = activation;
    379352  } else {
    380     activation = Object();
     353    activation = NULL;
    381354    variable = glob;
    382355  }
     
    393366    case GlobalCode:
    394367      scope.clear();
    395       scope.push(glob.imp());
    396       thisVal = Object(static_cast<ObjectImp*>(glob.imp()));
     368      scope.push(glob);
     369      thisVal = static_cast<ObjectImp*>(glob);
    397370      break;
    398371    case FunctionCode:
     
    400373      if (type == FunctionCode) {
    401374        scope = func->scope();
    402         scope.push(activation.imp());
     375        scope.push(activation);
    403376      } else {
    404377        scope.clear();
    405         scope.push(glob.imp());
    406         scope.push(activation.imp());
     378        scope.push(glob);
     379        scope.push(activation);
    407380      }
    408381      variable = activation; // TODO: DontDelete ? (ECMA 10.2.3)
     
    479452void InterpreterImp::globalInit()
    480453{
    481   //fprintf( stderr, "InterpreterImp::globalInit()\n" );
    482   UndefinedImp::staticUndefined = new UndefinedImp();
    483   NullImp::staticNull = new NullImp();
    484   BooleanImp::staticTrue = new BooleanImp(true);
    485   BooleanImp::staticFalse = new BooleanImp(false);
    486   NumberImp::staticNaN = new NumberImp(NaN);
     454    ConstantValues::init();
    487455}
    488456
    489457void InterpreterImp::globalClear()
    490458{
    491   //fprintf( stderr, "InterpreterImp::globalClear()\n" );
    492   UndefinedImp::staticUndefined = 0;
    493   NullImp::staticNull = 0;
    494   BooleanImp::staticTrue = 0;
    495   BooleanImp::staticFalse = 0;
    496   NumberImp::staticNaN = 0;
    497 }
    498 
    499 InterpreterImp::InterpreterImp(Interpreter *interp, const Object &glob)
    500   : globExec(interp, 0)
    501   , _context(0)
     459    ConstantValues::clear();
     460}
     461
     462InterpreterImp::InterpreterImp(Interpreter *interp, ObjectImp *glob)
     463    : globExec(interp, 0)
     464    , _context(0)
    502465{
    503466  // add this interpreter to the global chain
     
    516479  }
    517480
    518   InterpreterMap::setInterpreterForGlobalObject(this, glob.imp());
     481  InterpreterMap::setInterpreterForGlobalObject(this, glob);
    519482
    520483  global = glob;
     
    551514
    552515  FunctionPrototypeImp *funcProto = new FunctionPrototypeImp(&globExec);
    553   b_FunctionPrototype = Object(funcProto);
     516  b_FunctionPrototype = funcProto;
    554517  ObjectPrototypeImp *objProto = new ObjectPrototypeImp(&globExec, funcProto);
    555   b_ObjectPrototype = Object(objProto);
     518  b_ObjectPrototype = objProto;
    556519  funcProto->setPrototype(b_ObjectPrototype);
    557520
    558521  ArrayPrototypeImp *arrayProto = new ArrayPrototypeImp(&globExec, objProto);
    559   b_ArrayPrototype = Object(arrayProto);
     522  b_ArrayPrototype = arrayProto;
    560523  StringPrototypeImp *stringProto = new StringPrototypeImp(&globExec, objProto);
    561   b_StringPrototype = Object(stringProto);
     524  b_StringPrototype = stringProto;
    562525  BooleanPrototypeImp *booleanProto = new BooleanPrototypeImp(&globExec, objProto, funcProto);
    563   b_BooleanPrototype = Object(booleanProto);
     526  b_BooleanPrototype = booleanProto;
    564527  NumberPrototypeImp *numberProto = new NumberPrototypeImp(&globExec, objProto, funcProto);
    565   b_NumberPrototype = Object(numberProto);
     528  b_NumberPrototype = numberProto;
    566529  DatePrototypeImp *dateProto = new DatePrototypeImp(&globExec, objProto);
    567   b_DatePrototype = Object(dateProto);
     530  b_DatePrototype = dateProto;
    568531  RegExpPrototypeImp *regexpProto = new RegExpPrototypeImp(&globExec, objProto, funcProto);
    569   b_RegExpPrototype = Object(regexpProto);
     532  b_RegExpPrototype = regexpProto;
    570533  ErrorPrototypeImp *errorProto = new ErrorPrototypeImp(&globExec, objProto, funcProto);
    571   b_ErrorPrototype = Object(errorProto);
    572 
    573   static_cast<ObjectImp*>(global.imp())->setPrototype(b_ObjectPrototype);
     534  b_ErrorPrototype = errorProto;
     535
     536  static_cast<ObjectImp*>(global)->setPrototype(b_ObjectPrototype);
    574537
    575538  // Constructors (Object, Array, etc.)
    576   b_Object = Object(new ObjectObjectImp(&globExec, objProto, funcProto));
    577   b_Function = Object(new FunctionObjectImp(&globExec, funcProto));
    578   b_Array = Object(new ArrayObjectImp(&globExec, funcProto, arrayProto));
    579   b_String = Object(new StringObjectImp(&globExec, funcProto, stringProto));
    580   b_Boolean = Object(new BooleanObjectImp(&globExec, funcProto, booleanProto));
    581   b_Number = Object(new NumberObjectImp(&globExec, funcProto, numberProto));
    582   b_Date = Object(new DateObjectImp(&globExec, funcProto, dateProto));
    583   b_RegExp = Object(new RegExpObjectImp(&globExec, funcProto, regexpProto));
    584   b_Error = Object(new ErrorObjectImp(&globExec, funcProto, errorProto));
     539  b_Object = new ObjectObjectImp(&globExec, objProto, funcProto);
     540  b_Function = new FunctionObjectImp(&globExec, funcProto);
     541  b_Array = new ArrayObjectImp(&globExec, funcProto, arrayProto);
     542  b_String = new StringObjectImp(&globExec, funcProto, stringProto);
     543  b_Boolean = new BooleanObjectImp(&globExec, funcProto, booleanProto);
     544  b_Number = new NumberObjectImp(&globExec, funcProto, numberProto);
     545  b_Date = new DateObjectImp(&globExec, funcProto, dateProto);
     546  b_RegExp = new RegExpObjectImp(&globExec, funcProto, regexpProto);
     547  b_Error = new ErrorObjectImp(&globExec, funcProto, errorProto);
    585548
    586549  // Error object prototypes
    587   b_evalErrorPrototype = Object(new NativeErrorPrototypeImp(&globExec, errorProto, EvalError,
    588                                                             "EvalError", "EvalError"));
    589   b_rangeErrorPrototype = Object(new NativeErrorPrototypeImp(&globExec, errorProto, RangeError,
    590                                                             "RangeError", "RangeError"));
    591   b_referenceErrorPrototype = Object(new NativeErrorPrototypeImp(&globExec, errorProto, ReferenceError,
    592                                                             "ReferenceError", "ReferenceError"));
    593   b_syntaxErrorPrototype = Object(new NativeErrorPrototypeImp(&globExec, errorProto, SyntaxError,
    594                                                             "SyntaxError", "SyntaxError"));
    595   b_typeErrorPrototype = Object(new NativeErrorPrototypeImp(&globExec, errorProto, TypeError,
    596                                                             "TypeError", "TypeError"));
    597   b_uriErrorPrototype = Object(new NativeErrorPrototypeImp(&globExec, errorProto, URIError,
    598                                                             "URIError", "URIError"));
     550  b_evalErrorPrototype = new NativeErrorPrototypeImp(&globExec, errorProto, EvalError, "EvalError", "EvalError");
     551  b_rangeErrorPrototype = new NativeErrorPrototypeImp(&globExec, errorProto, RangeError, "RangeError", "RangeError");
     552  b_referenceErrorPrototype = new NativeErrorPrototypeImp(&globExec, errorProto, ReferenceError, "ReferenceError", "ReferenceError");
     553  b_syntaxErrorPrototype = new NativeErrorPrototypeImp(&globExec, errorProto, SyntaxError, "SyntaxError", "SyntaxError");
     554  b_typeErrorPrototype = new NativeErrorPrototypeImp(&globExec, errorProto, TypeError, "TypeError", "TypeError");
     555  b_uriErrorPrototype = new NativeErrorPrototypeImp(&globExec, errorProto, URIError, "URIError", "URIError");
    599556
    600557  // Error objects
    601   b_evalError = Object(new NativeErrorImp(&globExec, funcProto, b_evalErrorPrototype));
    602   b_rangeError = Object(new NativeErrorImp(&globExec, funcProto, b_rangeErrorPrototype));
    603   b_referenceError = Object(new NativeErrorImp(&globExec, funcProto, b_referenceErrorPrototype));
    604   b_syntaxError = Object(new NativeErrorImp(&globExec, funcProto, b_syntaxErrorPrototype));
    605   b_typeError = Object(new NativeErrorImp(&globExec, funcProto, b_typeErrorPrototype));
    606   b_uriError = Object(new NativeErrorImp(&globExec, funcProto, b_uriErrorPrototype));
     558  b_evalError = new NativeErrorImp(&globExec, funcProto, b_evalErrorPrototype);
     559  b_rangeError = new NativeErrorImp(&globExec, funcProto, b_rangeErrorPrototype);
     560  b_referenceError = new NativeErrorImp(&globExec, funcProto, b_referenceErrorPrototype);
     561  b_syntaxError = new NativeErrorImp(&globExec, funcProto, b_syntaxErrorPrototype);
     562  b_typeError = new NativeErrorImp(&globExec, funcProto, b_typeErrorPrototype);
     563  b_uriError = new NativeErrorImp(&globExec, funcProto, b_uriErrorPrototype);
    607564
    608565  // ECMA 15.3.4.1
    609566  funcProto->put(&globExec, "constructor", b_Function, DontEnum);
    610567
    611   global.put(&globExec, "Object", b_Object, DontEnum);
    612   global.put(&globExec, "Function", b_Function, DontEnum);
    613   global.put(&globExec, "Array", b_Array, DontEnum);
    614   global.put(&globExec, "Boolean", b_Boolean, DontEnum);
    615   global.put(&globExec, "String", b_String, DontEnum);
    616   global.put(&globExec, "Number", b_Number, DontEnum);
    617   global.put(&globExec, "Date", b_Date, DontEnum);
    618   global.put(&globExec, "RegExp", b_RegExp, DontEnum);
    619   global.put(&globExec, "Error", b_Error, DontEnum);
     568  global->put(&globExec, "Object", b_Object, DontEnum);
     569  global->put(&globExec, "Function", b_Function, DontEnum);
     570  global->put(&globExec, "Array", b_Array, DontEnum);
     571  global->put(&globExec, "Boolean", b_Boolean, DontEnum);
     572  global->put(&globExec, "String", b_String, DontEnum);
     573  global->put(&globExec, "Number", b_Number, DontEnum);
     574  global->put(&globExec, "Date", b_Date, DontEnum);
     575  global->put(&globExec, "RegExp", b_RegExp, DontEnum);
     576  global->put(&globExec, "Error", b_Error, DontEnum);
    620577  // Using Internal for those to have something != 0
    621578  // (see kjs_window). Maybe DontEnum would be ok too ?
    622   global.put(&globExec, "EvalError",b_evalError, Internal);
    623   global.put(&globExec, "RangeError",b_rangeError, Internal);
    624   global.put(&globExec, "ReferenceError",b_referenceError, Internal);
    625   global.put(&globExec, "SyntaxError",b_syntaxError, Internal);
    626   global.put(&globExec, "TypeError",b_typeError, Internal);
    627   global.put(&globExec, "URIError",b_uriError, Internal);
     579  global->put(&globExec, "EvalError",b_evalError, Internal);
     580  global->put(&globExec, "RangeError",b_rangeError, Internal);
     581  global->put(&globExec, "ReferenceError",b_referenceError, Internal);
     582  global->put(&globExec, "SyntaxError",b_syntaxError, Internal);
     583  global->put(&globExec, "TypeError",b_typeError, Internal);
     584  global->put(&globExec, "URIError",b_uriError, Internal);
    628585
    629586  // Set the "constructor" property of all builtin constructors
     
    637594  regexpProto->put(&globExec, "constructor", b_RegExp, DontEnum | DontDelete | ReadOnly);
    638595  errorProto->put(&globExec, "constructor", b_Error, DontEnum | DontDelete | ReadOnly);
    639   b_evalErrorPrototype.put(&globExec, "constructor", b_evalError, DontEnum | DontDelete | ReadOnly);
    640   b_rangeErrorPrototype.put(&globExec, "constructor", b_rangeError, DontEnum | DontDelete | ReadOnly);
    641   b_referenceErrorPrototype.put(&globExec, "constructor", b_referenceError, DontEnum | DontDelete | ReadOnly);
    642   b_syntaxErrorPrototype.put(&globExec, "constructor", b_syntaxError, DontEnum | DontDelete | ReadOnly);
    643   b_typeErrorPrototype.put(&globExec, "constructor", b_typeError, DontEnum | DontDelete | ReadOnly);
    644   b_uriErrorPrototype.put(&globExec, "constructor", b_uriError, DontEnum | DontDelete | ReadOnly);
     596  b_evalErrorPrototype->put(&globExec, "constructor", b_evalError, DontEnum | DontDelete | ReadOnly);
     597  b_rangeErrorPrototype->put(&globExec, "constructor", b_rangeError, DontEnum | DontDelete | ReadOnly);
     598  b_referenceErrorPrototype->put(&globExec, "constructor", b_referenceError, DontEnum | DontDelete | ReadOnly);
     599  b_syntaxErrorPrototype->put(&globExec, "constructor", b_syntaxError, DontEnum | DontDelete | ReadOnly);
     600  b_typeErrorPrototype->put(&globExec, "constructor", b_typeError, DontEnum | DontDelete | ReadOnly);
     601  b_uriErrorPrototype->put(&globExec, "constructor", b_uriError, DontEnum | DontDelete | ReadOnly);
    645602
    646603  // built-in values
    647   global.put(&globExec, "NaN",        Number(NaN), DontEnum|DontDelete);
    648   global.put(&globExec, "Infinity",   Number(Inf), DontEnum|DontDelete);
    649   global.put(&globExec, "undefined",  Undefined(), DontEnum|DontDelete);
     604  global->put(&globExec, "NaN",        jsNaN(), DontEnum|DontDelete);
     605  global->put(&globExec, "Infinity",   Number(Inf), DontEnum|DontDelete);
     606  global->put(&globExec, "undefined",  Undefined(), DontEnum|DontDelete);
    650607
    651608  // built-in functions
    652   global.put(&globExec, "eval",       Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::Eval, 1)), DontEnum);
    653   global.put(&globExec, "parseInt",   Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::ParseInt, 2)), DontEnum);
    654   global.put(&globExec, "parseFloat", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::ParseFloat, 1)), DontEnum);
    655   global.put(&globExec, "isNaN",      Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::IsNaN, 1)), DontEnum);
    656   global.put(&globExec, "isFinite",   Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::IsFinite, 1)), DontEnum);
    657   global.put(&globExec, "escape",     Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::Escape, 1)), DontEnum);
    658   global.put(&globExec, "unescape",   Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::UnEscape, 1)), DontEnum);
    659   global.put(&globExec, "decodeURI",  Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::DecodeURI, 1)), DontEnum);
    660   global.put(&globExec, "decodeURIComponent", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::DecodeURIComponent, 1)), DontEnum);
    661   global.put(&globExec, "encodeURI",  Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::EncodeURI, 1)), DontEnum);
    662   global.put(&globExec, "encodeURIComponent", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::EncodeURIComponent, 1)), DontEnum);
     609  global->put(&globExec, "eval",       new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::Eval, 1), DontEnum);
     610  global->put(&globExec, "parseInt",   new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::ParseInt, 2), DontEnum);
     611  global->put(&globExec, "parseFloat", new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::ParseFloat, 1), DontEnum);
     612  global->put(&globExec, "isNaN",      new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::IsNaN, 1), DontEnum);
     613  global->put(&globExec, "isFinite",   new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::IsFinite, 1), DontEnum);
     614  global->put(&globExec, "escape",     new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::Escape, 1), DontEnum);
     615  global->put(&globExec, "unescape",   new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::UnEscape, 1), DontEnum);
     616  global->put(&globExec, "decodeURI",  new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::DecodeURI, 1), DontEnum);
     617  global->put(&globExec, "decodeURIComponent", new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::DecodeURIComponent, 1), DontEnum);
     618  global->put(&globExec, "encodeURI",  new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::EncodeURI, 1), DontEnum);
     619  global->put(&globExec, "encodeURIComponent", new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::EncodeURIComponent, 1), DontEnum);
    663620#ifndef NDEBUG
    664   global.put(&globExec, "kjsprint",   Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::KJSPrint, 1)), DontEnum);
     621  global->put(&globExec, "kjsprint",   new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::KJSPrint, 1), DontEnum);
    665622#endif
    666623
    667624  // built-in objects
    668   global.put(&globExec, "Math", Object(new MathObjectImp(&globExec, objProto)), DontEnum);
     625  global->put(&globExec, "Math", new MathObjectImp(&globExec, objProto), DontEnum);
    669626}
    670627
     
    692649    globalClear();
    693650  }
    694   InterpreterMap::removeInterpreterForGlobalObject(global.imp());
     651  InterpreterMap::removeInterpreterForGlobalObject(global);
    695652
    696653#if APPLE_CHANGES
     
    701658void InterpreterImp::mark()
    702659{
    703   //if (exVal && !exVal->marked())
    704   //  exVal->mark();
    705   //if (retVal && !retVal->marked())
    706   //  retVal->mark();
    707   if (UndefinedImp::staticUndefined && !UndefinedImp::staticUndefined->marked())
    708     UndefinedImp::staticUndefined->mark();
    709   if (NullImp::staticNull && !NullImp::staticNull->marked())
    710     NullImp::staticNull->mark();
    711   if (NumberImp::staticNaN && !NumberImp::staticNaN->marked())
    712     NumberImp::staticNaN->mark();
    713   if (BooleanImp::staticTrue && !BooleanImp::staticTrue->marked())
    714     BooleanImp::staticTrue->mark();
    715   if (BooleanImp::staticFalse && !BooleanImp::staticFalse->marked())
    716     BooleanImp::staticFalse->mark();
    717   //fprintf( stderr, "InterpreterImp::mark this=%p global.imp()=%p\n", this, global.imp() );
     660  ConstantValues::mark();
    718661  if (m_interpreter)
    719662    m_interpreter->mark();
     
    736679}
    737680
    738 Completion InterpreterImp::evaluate(const UString &code, const Value &thisV, const UString &sourceURL, int startingLineNumber)
     681Completion InterpreterImp::evaluate(const UString &code, ValueImp *thisV, const UString &sourceURL, int startingLineNumber)
    739682{
    740683#if APPLE_CHANGES
     
    774717  // no program node means a syntax error occurred
    775718  if (!progNode) {
    776     Object err = Error::create(&globExec, SyntaxError, errMsg.ascii(), errLine, -1, &sourceURL);
    777     err.put(&globExec, "sid", Number(sid));
     719    ObjectImp *err = Error::create(&globExec, SyntaxError, errMsg.ascii(), errLine, -1, &sourceURL);
     720    err->put(&globExec, "sid", Number(sid));
    778721#if APPLE_CHANGES
    779722    unlockInterpreter();
     
    787730  progNode->ref();
    788731
    789   Object &globalObj = globalObject();
    790   Object thisObj = globalObject();
    791 
    792   if (!thisV.isNull()) {
     732  ObjectImp *globalObj = globalObject();
     733  ObjectImp *thisObj = globalObject();
     734
     735  if (thisV) {
    793736    // "this" must be an object... use same rules as Function.prototype.apply()
    794     if (thisV.isA(NullType) || thisV.isA(UndefinedType))
     737    if (thisV->isUndefinedOrNull())
    795738      thisObj = globalObject();
    796739    else {
    797       thisObj = thisV.toObject(&globExec);
     740      thisObj = thisV->toObject(&globExec);
    798741    }
    799742  }
     
    801744  Completion res;
    802745  if (globExec.hadException()) {
    803     // the thisArg.toObject() conversion above might have thrown an exception - if so,
     746    // the thisArg->toObject() conversion above might have thrown an exception - if so,
    804747    // propagate it back
    805748    res = Completion(Throw, globExec.exception());
     
    925868}
    926869
    927 Boolean InternalFunctionImp::hasInstance(ExecState *exec, const Value &value)
    928 {
    929   if (value.type() != ObjectType)
    930     return Boolean(false);
    931 
    932   Value prot = get(exec,prototypePropertyName);
    933   if (prot.type() != ObjectType && prot.type() != NullType) {
    934     Object err = Error::create(exec, TypeError, "Invalid prototype encountered "
     870bool InternalFunctionImp::hasInstance(ExecState *exec, ValueImp *value)
     871{
     872  if (!value->isObject())
     873    return false;
     874
     875  ValueImp *prot = get(exec,prototypePropertyName);
     876  if (!prot->isObject() && !prot->isNull()) {
     877    ObjectImp *err = Error::create(exec, TypeError, "Invalid prototype encountered "
    935878                               "in instanceof operation.");
    936879    exec->setException(err);
    937     return Boolean(false);
    938   }
    939 
    940   Object v = Object(static_cast<ObjectImp*>(value.imp()));
    941   while ((v = Object::dynamicCast(v.prototype())).imp()) {
    942     if (v.imp() == prot.imp())
    943       return Boolean(true);
    944   }
    945   return Boolean(false);
     880    return false;
     881  }
     882
     883  ObjectImp *v = static_cast<ObjectImp *>(value);
     884  while ((v = v->prototype()->getObject())) {
     885    if (v == prot)
     886      return true;
     887  }
     888  return false;
    946889}
    947890
    948891// ------------------------------ global functions -----------------------------
    949892
    950 double KJS::roundValue(ExecState *exec, const Value &v)
    951 {
    952   Number n = v.toNumber(exec);
    953   double d = n.value();
     893double roundValue(ExecState *exec, ValueImp *v)
     894{
     895  double d = v->toNumber(exec);
    954896  double ad = fabs(d);
    955897  if (ad == 0 || isNaN(d) || isInf(d))
     
    960902#ifndef NDEBUG
    961903#include <stdio.h>
    962 void KJS::printInfo(ExecState *exec, const char *s, const Value &o, int lineno)
    963 {
    964   if (o.isNull())
     904void printInfo(ExecState *exec, const char *s, ValueImp *o, int lineno)
     905{
     906  if (!o)
    965907    fprintf(stderr, "KJS: %s: (null)", s);
    966908  else {
    967     Value v = o;
     909    ValueImp *v = o;
    968910
    969911    UString name;
    970     switch ( v.type() ) {
     912    switch (v->type()) {
    971913    case UnspecifiedType:
    972914      name = "Unspecified";
     
    988930      break;
    989931    case ObjectType:
    990       name = Object::dynamicCast(v).className();
     932      name = static_cast<ObjectImp *>(v)->className();
    991933      if (name.isNull())
    992934        name = "(unknown class)";
    993935      break;
    994936    }
    995     UString vString = v.toString(exec);
     937    UString vString = v->toString(exec);
    996938    if ( vString.size() > 50 )
    997939      vString = vString.substr( 0, 50 ) + "...";
     
    1000942
    1001943    fprintf(stderr, "KJS: %s: %s : %s (%p)",
    1002             s, tempString.c_str(), name.ascii(), (void*)v.imp());
     944            s, tempString.c_str(), name.ascii(), (void*)v);
    1003945
    1004946    if (lineno >= 0)
     
    1009951}
    1010952#endif
     953
     954}
  • trunk/JavaScriptCore/kjs/internal.h

    r10076 r10084  
    2323 */
    2424
    25 #ifndef _INTERNAL_H_
    26 #define _INTERNAL_H_
     25#ifndef INTERNAL_H
     26#define INTERNAL_H
    2727
    2828#include "ustring.h"
     
    3838namespace KJS {
    3939
    40   static const double D16 = 65536.0;
    41   static const double D32 = 4294967296.0;
    42 
    4340  class ProgramNode;
    4441  class FunctionBodyNode;
     
    5148  // ---------------------------------------------------------------------------
    5249
    53   class UndefinedImp : public ValueImp {
     50  class UndefinedImp : public AllocatedValueImp {
    5451  public:
    5552    Type type() const { return UndefinedType; }
    5653
    57     Value toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
     54    ValueImp *toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
    5855    bool toBoolean(ExecState *exec) const;
    5956    double toNumber(ExecState *exec) const;
    6057    UString toString(ExecState *exec) const;
    61     Object toObject(ExecState *exec) const;
    62 
    63     static UndefinedImp *staticUndefined;
    64   };
    65 
    66   inline Undefined::Undefined(UndefinedImp *imp) : Value(imp) { }
    67 
    68   class NullImp : public ValueImp {
     58    ObjectImp *toObject(ExecState *exec) const;
     59  };
     60
     61  class NullImp : public AllocatedValueImp {
    6962  public:
    7063    Type type() const { return NullType; }
    7164
    72     Value toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
     65    ValueImp *toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
    7366    bool toBoolean(ExecState *exec) const;
    7467    double toNumber(ExecState *exec) const;
    7568    UString toString(ExecState *exec) const;
    76     Object toObject(ExecState *exec) const;
    77 
    78     static NullImp *staticNull;
    79   };
    80 
    81   inline Null::Null(NullImp *imp) : Value(imp) { }
    82 
    83   class BooleanImp : public ValueImp {
     69    ObjectImp *toObject(ExecState *exec) const;
     70  };
     71
     72  class BooleanImp : public AllocatedValueImp {
    8473  public:
    8574    BooleanImp(bool v = false) : val(v) { }
     
    8877    Type type() const { return BooleanType; }
    8978
    90     Value toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
     79    ValueImp *toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
    9180    bool toBoolean(ExecState *exec) const;
    9281    double toNumber(ExecState *exec) const;
    9382    UString toString(ExecState *exec) const;
    94     Object toObject(ExecState *exec) const;
    95 
    96     static BooleanImp *staticTrue;
    97     static BooleanImp *staticFalse;
     83    ObjectImp *toObject(ExecState *exec) const;
     84
    9885  private:
    9986    bool val;
    10087  };
    10188 
    102   inline Boolean::Boolean(BooleanImp *imp) : Value(imp) { }
    103 
    104   class StringImp : public ValueImp {
     89  class StringImp : public AllocatedValueImp {
    10590  public:
    10691    StringImp(const UString& v) : val(v) { }
     
    10994    Type type() const { return StringType; }
    11095
    111     Value toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
     96    ValueImp *toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
    11297    bool toBoolean(ExecState *exec) const;
    11398    double toNumber(ExecState *exec) const;
    11499    UString toString(ExecState *exec) const;
    115     Object toObject(ExecState *exec) const;
     100    ObjectImp *toObject(ExecState *exec) const;
    116101
    117102  private:
     
    119104  };
    120105
    121   inline String::String(StringImp *imp) : Value(imp) { }
    122 
    123   class NumberImp : public ValueImp {
    124     friend class Value;
    125     friend class Number;
     106  class NumberImp : public AllocatedValueImp {
     107    friend class ConstantValues;
    126108    friend class InterpreterImp;
    127     friend ValueImp *number(int);
    128     friend ValueImp *number(unsigned);
    129     friend ValueImp *number(long);
    130     friend ValueImp *number(unsigned long);
    131     friend ValueImp *number(double);
    132     friend ValueImp *number(double, bool);
    133   public:
    134     static ValueImp *create(int);
    135     static ValueImp *create(double);
    136     static ValueImp *zero() { return SimpleNumber::make(0); }
    137     static ValueImp *one() { return SimpleNumber::make(1); }
    138     static ValueImp *two() { return SimpleNumber::make(2); }
    139    
     109    friend ValueImp *jsNumber(int);
     110    friend ValueImp *jsNumber(unsigned);
     111    friend ValueImp *jsNumber(long);
     112    friend ValueImp *jsNumber(unsigned long);
     113    friend ValueImp *jsNumber(double);
     114    friend ValueImp *jsNumber(double, bool);
     115  public:
    140116    double value() const { return val; }
    141117
    142118    Type type() const { return NumberType; }
    143119
    144     Value toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
     120    ValueImp *toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
    145121    bool toBoolean(ExecState *exec) const;
    146122    double toNumber(ExecState *exec) const;
    147123    UString toString(ExecState *exec) const;
    148     Object toObject(ExecState *exec) const;
    149 
    150     static NumberImp *staticNaN;
     124    ObjectImp *toObject(ExecState *exec) const;
    151125
    152126  private:
    153127    NumberImp(double v) : val(v) { }
    154128
    155     virtual bool toUInt32(unsigned&) const;
     129    virtual bool getUInt32(uint32_t&) const;
    156130
    157131    double val;
    158132  };
    159 
    160   inline Number::Number(NumberImp *imp) : Value(imp) { }
    161133
    162134  /**
     
    207179
    208180  // ---------------------------------------------------------------------------
    209   //                            Parsing & evaluateion
     181  //                            Parsing & evaluation
    210182  // ---------------------------------------------------------------------------
    211183
     
    276248    static void globalClear();
    277249
    278     InterpreterImp(Interpreter *interp, const Object &glob);
     250    InterpreterImp(Interpreter *interp, ObjectImp *glob);
    279251    ~InterpreterImp();
    280252
     
    291263    ExecState *globalExec() { return &globExec; }
    292264    bool checkSyntax(const UString &code);
    293     Completion evaluate(const UString &code, const Value &thisV, const UString &sourceURL, int startingLineNumber);
     265    Completion evaluate(const UString &code, ValueImp *thisV, const UString &sourceURL, int startingLineNumber);
    294266    Debugger *debugger() const { return dbg; }
    295267    void setDebugger(Debugger *d) { dbg = d; }
    296268
    297     Object builtinObject() const { return b_Object; }
    298     Object builtinFunction() const { return b_Function; }
    299     Object builtinArray() const { return b_Array; }
    300     Object builtinBoolean() const { return b_Boolean; }
    301     Object builtinString() const { return b_String; }
    302     Object builtinNumber() const { return b_Number; }
    303     Object builtinDate() const { return b_Date; }
    304     Object builtinRegExp() const { return b_RegExp; }
    305     Object builtinError() const { return b_Error; }
    306 
    307     Object builtinObjectPrototype() const { return b_ObjectPrototype; }
    308     Object builtinFunctionPrototype() const { return b_FunctionPrototype; }
    309     Object builtinArrayPrototype() const { return b_ArrayPrototype; }
    310     Object builtinBooleanPrototype() const { return b_BooleanPrototype; }
    311     Object builtinStringPrototype() const { return b_StringPrototype; }
    312     Object builtinNumberPrototype() const { return b_NumberPrototype; }
    313     Object builtinDatePrototype() const { return b_DatePrototype; }
    314     Object builtinRegExpPrototype() const { return b_RegExpPrototype; }
    315     Object builtinErrorPrototype() const { return b_ErrorPrototype; }
    316 
    317     Object builtinEvalError() const { return b_evalError; }
    318     Object builtinRangeError() const { return b_rangeError; }
    319     Object builtinReferenceError() const { return b_referenceError; }
    320     Object builtinSyntaxError() const { return b_syntaxError; }
    321     Object builtinTypeError() const { return b_typeError; }
    322     Object builtinURIError() const { return b_uriError; }
    323 
    324     Object builtinEvalErrorPrototype() const { return b_evalErrorPrototype; }
    325     Object builtinRangeErrorPrototype() const { return b_rangeErrorPrototype; }
    326     Object builtinReferenceErrorPrototype() const { return b_referenceErrorPrototype; }
    327     Object builtinSyntaxErrorPrototype() const { return b_syntaxErrorPrototype; }
    328     Object builtinTypeErrorPrototype() const { return b_typeErrorPrototype; }
    329     Object builtinURIErrorPrototype() const { return b_uriErrorPrototype; }
     269    ObjectImp *builtinObject() const { return b_Object; }
     270    ObjectImp *builtinFunction() const { return b_Function; }
     271    ObjectImp *builtinArray() const { return b_Array; }
     272    ObjectImp *builtinBoolean() const { return b_Boolean; }
     273    ObjectImp *builtinString() const { return b_String; }
     274    ObjectImp *builtinNumber() const { return b_Number; }
     275    ObjectImp *builtinDate() const { return b_Date; }
     276    ObjectImp *builtinRegExp() const { return b_RegExp; }
     277    ObjectImp *builtinError() const { return b_Error; }
     278
     279    ObjectImp *builtinObjectPrototype() const { return b_ObjectPrototype; }
     280    ObjectImp *builtinFunctionPrototype() const { return b_FunctionPrototype; }
     281    ObjectImp *builtinArrayPrototype() const { return b_ArrayPrototype; }
     282    ObjectImp *builtinBooleanPrototype() const { return b_BooleanPrototype; }
     283    ObjectImp *builtinStringPrototype() const { return b_StringPrototype; }
     284    ObjectImp *builtinNumberPrototype() const { return b_NumberPrototype; }
     285    ObjectImp *builtinDatePrototype() const { return b_DatePrototype; }
     286    ObjectImp *builtinRegExpPrototype() const { return b_RegExpPrototype; }
     287    ObjectImp *builtinErrorPrototype() const { return b_ErrorPrototype; }
     288
     289    ObjectImp *builtinEvalError() const { return b_evalError; }
     290    ObjectImp *builtinRangeError() const { return b_rangeError; }
     291    ObjectImp *builtinReferenceError() const { return b_referenceError; }
     292    ObjectImp *builtinSyntaxError() const { return b_syntaxError; }
     293    ObjectImp *builtinTypeError() const { return b_typeError; }
     294    ObjectImp *builtinURIError() const { return b_uriError; }
     295
     296    ObjectImp *builtinEvalErrorPrototype() const { return b_evalErrorPrototype; }
     297    ObjectImp *builtinRangeErrorPrototype() const { return b_rangeErrorPrototype; }
     298    ObjectImp *builtinReferenceErrorPrototype() const { return b_referenceErrorPrototype; }
     299    ObjectImp *builtinSyntaxErrorPrototype() const { return b_syntaxErrorPrototype; }
     300    ObjectImp *builtinTypeErrorPrototype() const { return b_typeErrorPrototype; }
     301    ObjectImp *builtinURIErrorPrototype() const { return b_uriErrorPrototype; }
    330302
    331303    void setCompatMode(Interpreter::CompatMode mode) { m_compatMode = mode; }
     
    423395    InternalFunctionImp(FunctionPrototypeImp *funcProto);
    424396    bool implementsHasInstance() const;
    425     Boolean hasInstance(ExecState *exec, const Value &value);
     397    bool hasInstance(ExecState *exec, ValueImp *value);
    426398
    427399    virtual const ClassInfo *classInfo() const { return &info; }
     
    430402
    431403  // helper function for toInteger, toInt32, toUInt32 and toUInt16
    432   double roundValue(ExecState *exec, const Value &v);
     404  double roundValue(ExecState *, ValueImp *);
    433405
    434406#ifndef NDEBUG
    435   void printInfo(ExecState *exec, const char *s, const Value &o, int lineno = -1);
     407  void printInfo(ExecState *exec, const char *s, ValueImp *, int lineno = -1);
    436408#endif
    437409
    438410} // namespace
    439411
    440 
    441 #endif //  _INTERNAL_H_
     412#endif //  INTERNAL_H
  • trunk/JavaScriptCore/kjs/interpreter.cpp

    r10076 r10084  
    5151}
    5252
    53 Object Context::variableObject() const
     53ObjectImp *Context::variableObject() const
    5454{
    5555  return rep->variableObject();
    5656}
    5757
    58 Object Context::thisValue() const
     58ObjectImp *Context::thisValue() const
    5959{
    6060  return rep->thisValue();
     
    6868// ------------------------------ Interpreter ----------------------------------
    6969
    70 Interpreter::Interpreter(const Object &global)
     70Interpreter::Interpreter(ObjectImp *global)
    7171  : rep(0)
    7272  , m_argumentsPropertyName(&argumentsPropertyName)
    7373  , m_specialPrototypePropertyName(&specialPrototypePropertyName)
    7474{
    75   rep = new InterpreterImp(this,global);
     75  rep = new InterpreterImp(this, global);
    7676}
    7777
     
    8181  , m_specialPrototypePropertyName(&specialPrototypePropertyName)
    8282{
    83   Object global(new ObjectImp());
    84   rep = new InterpreterImp(this,global);
     83  rep = new InterpreterImp(this, new ObjectImp);
    8584}
    8685
     
    9089}
    9190
    92 Object &Interpreter::globalObject() const
     91ObjectImp *Interpreter::globalObject() const
    9392{
    9493  return rep->globalObject();
     
    125124}
    126125
    127 Completion Interpreter::evaluate(const UString &code, const Value &thisV, const UString &)
     126Completion Interpreter::evaluate(const UString &code, ValueImp *thisV, const UString &)
    128127{
    129128  return evaluate(UString(), 0, code, thisV);
    130129}
    131130
    132 Completion Interpreter::evaluate(const UString &sourceURL, int startingLineNumber, const UString &code, const Value &thisV)
     131Completion Interpreter::evaluate(const UString &sourceURL, int startingLineNumber, const UString &code, ValueImp *thisV)
    133132{
    134133  Completion comp = rep->evaluate(code,thisV, sourceURL, startingLineNumber);
     
    139138    ExecState *exec = rep->globalExec();
    140139    char *f = strdup(sourceURL.ascii());
    141     const char *message = comp.value().toObject(exec).toString(exec).ascii();
     140    const char *message = comp.value()->toObject(exec)->toString(exec).ascii();
    142141    printf("[%d] %s:%s\n", getpid(), f, message);
    143142
     
    150149}
    151150
    152 Object Interpreter::builtinObject() const
     151ObjectImp *Interpreter::builtinObject() const
    153152{
    154153  return rep->builtinObject();
    155154}
    156155
    157 Object Interpreter::builtinFunction() const
     156ObjectImp *Interpreter::builtinFunction() const
    158157{
    159158  return rep->builtinFunction();
    160159}
    161160
    162 Object Interpreter::builtinArray() const
     161ObjectImp *Interpreter::builtinArray() const
    163162{
    164163  return rep->builtinArray();
    165164}
    166165
    167 Object Interpreter::builtinBoolean() const
     166ObjectImp *Interpreter::builtinBoolean() const
    168167{
    169168  return rep->builtinBoolean();
    170169}
    171170
    172 Object Interpreter::builtinString() const
     171ObjectImp *Interpreter::builtinString() const
    173172{
    174173  return rep->builtinString();
    175174}
    176175
    177 Object Interpreter::builtinNumber() const
     176ObjectImp *Interpreter::builtinNumber() const
    178177{
    179178  return rep->builtinNumber();
    180179}
    181180
    182 Object Interpreter::builtinDate() const
     181ObjectImp *Interpreter::builtinDate() const
    183182{
    184183  return rep->builtinDate();
    185184}
    186185
    187 Object Interpreter::builtinRegExp() const
     186ObjectImp *Interpreter::builtinRegExp() const
    188187{
    189188  return rep->builtinRegExp();
    190189}
    191190
    192 Object Interpreter::builtinError() const
     191ObjectImp *Interpreter::builtinError() const
    193192{
    194193  return rep->builtinError();
    195194}
    196195
    197 Object Interpreter::builtinObjectPrototype() const
     196ObjectImp *Interpreter::builtinObjectPrototype() const
    198197{
    199198  return rep->builtinObjectPrototype();
    200199}
    201200
    202 Object Interpreter::builtinFunctionPrototype() const
     201ObjectImp *Interpreter::builtinFunctionPrototype() const
    203202{
    204203  return rep->builtinFunctionPrototype();
    205204}
    206205
    207 Object Interpreter::builtinArrayPrototype() const
     206ObjectImp *Interpreter::builtinArrayPrototype() const
    208207{
    209208  return rep->builtinArrayPrototype();
    210209}
    211210
    212 Object Interpreter::builtinBooleanPrototype() const
     211ObjectImp *Interpreter::builtinBooleanPrototype() const
    213212{
    214213  return rep->builtinBooleanPrototype();
    215214}
    216215
    217 Object Interpreter::builtinStringPrototype() const
     216ObjectImp *Interpreter::builtinStringPrototype() const
    218217{
    219218  return rep->builtinStringPrototype();
    220219}
    221220
    222 Object Interpreter::builtinNumberPrototype() const
     221ObjectImp *Interpreter::builtinNumberPrototype() const
    223222{
    224223  return rep->builtinNumberPrototype();
    225224}
    226225
    227 Object Interpreter::builtinDatePrototype() const
     226ObjectImp *Interpreter::builtinDatePrototype() const
    228227{
    229228  return rep->builtinDatePrototype();
    230229}
    231230
    232 Object Interpreter::builtinRegExpPrototype() const
     231ObjectImp *Interpreter::builtinRegExpPrototype() const
    233232{
    234233  return rep->builtinRegExpPrototype();
    235234}
    236235
    237 Object Interpreter::builtinErrorPrototype() const
     236ObjectImp *Interpreter::builtinErrorPrototype() const
    238237{
    239238  return rep->builtinErrorPrototype();
    240239}
    241240
    242 Object Interpreter::builtinEvalError() const
     241ObjectImp *Interpreter::builtinEvalError() const
    243242{
    244243  return rep->builtinEvalError();
    245244}
    246245
    247 Object Interpreter::builtinRangeError() const
     246ObjectImp *Interpreter::builtinRangeError() const
    248247{
    249248  return rep->builtinRangeError();
    250249}
    251250
    252 Object Interpreter::builtinReferenceError() const
     251ObjectImp *Interpreter::builtinReferenceError() const
    253252{
    254253  return rep->builtinReferenceError();
    255254}
    256255
    257 Object Interpreter::builtinSyntaxError() const
     256ObjectImp *Interpreter::builtinSyntaxError() const
    258257{
    259258  return rep->builtinSyntaxError();
    260259}
    261260
    262 Object Interpreter::builtinTypeError() const
     261ObjectImp *Interpreter::builtinTypeError() const
    263262{
    264263  return rep->builtinTypeError();
    265264}
    266265
    267 Object Interpreter::builtinURIError() const
     266ObjectImp *Interpreter::builtinURIError() const
    268267{
    269268  return rep->builtinURIError();
    270269}
    271270
    272 Object Interpreter::builtinEvalErrorPrototype() const
     271ObjectImp *Interpreter::builtinEvalErrorPrototype() const
    273272{
    274273  return rep->builtinEvalErrorPrototype();
    275274}
    276275
    277 Object Interpreter::builtinRangeErrorPrototype() const
     276ObjectImp *Interpreter::builtinRangeErrorPrototype() const
    278277{
    279278  return rep->builtinRangeErrorPrototype();
    280279}
    281280
    282 Object Interpreter::builtinReferenceErrorPrototype() const
     281ObjectImp *Interpreter::builtinReferenceErrorPrototype() const
    283282{
    284283  return rep->builtinReferenceErrorPrototype();
    285284}
    286285
    287 Object Interpreter::builtinSyntaxErrorPrototype() const
     286ObjectImp *Interpreter::builtinSyntaxErrorPrototype() const
    288287{
    289288  return rep->builtinSyntaxErrorPrototype();
    290289}
    291290
    292 Object Interpreter::builtinTypeErrorPrototype() const
     291ObjectImp *Interpreter::builtinTypeErrorPrototype() const
    293292{
    294293  return rep->builtinTypeErrorPrototype();
    295294}
    296295
    297 Object Interpreter::builtinURIErrorPrototype() const
     296ObjectImp *Interpreter::builtinURIErrorPrototype() const
    298297{
    299298  return rep->builtinURIErrorPrototype();
     
    338337
    339338
    340 void *Interpreter::createLanguageInstanceForValue (ExecState *exec, int language, const Object &value, const Bindings::RootObject *origin, const Bindings::RootObject *current)
     339void *Interpreter::createLanguageInstanceForValue(ExecState *exec, int language, ObjectImp *value, const Bindings::RootObject *origin, const Bindings::RootObject *current)
    341340{
    342341    return Bindings::Instance::createLanguageInstanceForValue (exec, (Bindings::Instance::BindingLanguage)language, value, origin, current);
  • trunk/JavaScriptCore/kjs/interpreter.h

    r10076 r10084  
    2626#define _KJS_INTERPRETER_H_
    2727
    28 #include "object_wrapper.h"
    2928#include "value.h"
    3029#include "types.h"
     
    3534  class InterpreterImp;
    3635  class RuntimeMethodImp;
     36  class ScopeChain;
    3737
    3838  namespace Bindings {
     
    7979     * @return The execution context's variable object
    8080     */
    81     Object variableObject() const;
     81    ObjectImp *variableObject() const;
    8282
    8383    /**
     
    9696     * @return The execution context's "this" value
    9797     */
    98     Object thisValue() const;
     98    ObjectImp *thisValue() const;
    9999
    100100    /**
     
    153153     * @param global The object to use as the global object for this interpreter
    154154     */
    155     Interpreter(const Object &global);
     155    Interpreter(ObjectImp *global);
    156156    /**
    157157     * Creates a new interpreter. A global object will be created and
     
    165165     * execution performed by this interpreter
    166166     */
    167     Object &globalObject() const;
     167    ObjectImp *globalObject() const;
    168168
    169169    void initGlobalObject();
     
    209209     * @return A completion object representing the result of the execution.
    210210     */
    211     Completion evaluate(const UString &sourceURL, int startingLineNumber, const UString &code, const Value &thisV = Value());
     211    Completion evaluate(const UString &sourceURL, int startingLineNumber, const UString &code, ValueImp *thisV = NULL);
    212212
    213213        // Overload of evaluate to keep JavaScriptGlue both source and binary compatible.
    214         Completion evaluate(const UString &code, const Value &thisV = Value(), const UString &sourceFilename = UString());
     214        Completion evaluate(const UString &code, ValueImp *thisV = NULL, const UString &sourceFilename = UString());
    215215
    216216    /**
     
    230230     * @return The builtin "Object" object
    231231     */
    232     Object builtinObject() const;
     232    ObjectImp *builtinObject() const;
    233233
    234234    /**
    235235     * Returns the builtin "Function" object.
    236236     */
    237     Object builtinFunction() const;
     237    ObjectImp *builtinFunction() const;
    238238
    239239    /**
    240240     * Returns the builtin "Array" object.
    241241     */
    242     Object builtinArray() const;
     242    ObjectImp *builtinArray() const;
    243243
    244244    /**
    245245     * Returns the builtin "Boolean" object.
    246246     */
    247     Object builtinBoolean() const;
     247    ObjectImp *builtinBoolean() const;
    248248
    249249    /**
    250250     * Returns the builtin "String" object.
    251251     */
    252     Object builtinString() const;
     252    ObjectImp *builtinString() const;
    253253
    254254    /**
    255255     * Returns the builtin "Number" object.
    256256     */
    257     Object builtinNumber() const;
     257    ObjectImp *builtinNumber() const;
    258258
    259259    /**
    260260     * Returns the builtin "Date" object.
    261261     */
    262     Object builtinDate() const;
     262    ObjectImp *builtinDate() const;
    263263
    264264    /**
    265265     * Returns the builtin "RegExp" object.
    266266     */
    267     Object builtinRegExp() const;
     267    ObjectImp *builtinRegExp() const;
    268268
    269269    /**
    270270     * Returns the builtin "Error" object.
    271271     */
    272     Object builtinError() const;
     272    ObjectImp *builtinError() const;
    273273
    274274    /**
    275275     * Returns the builtin "Object.prototype" object.
    276276     */
    277     Object builtinObjectPrototype() const;
     277    ObjectImp *builtinObjectPrototype() const;
    278278
    279279    /**
    280280     * Returns the builtin "Function.prototype" object.
    281281     */
    282     Object builtinFunctionPrototype() const;
     282    ObjectImp *builtinFunctionPrototype() const;
    283283
    284284    /**
    285285     * Returns the builtin "Array.prototype" object.
    286286     */
    287     Object builtinArrayPrototype() const;
     287    ObjectImp *builtinArrayPrototype() const;
    288288
    289289    /**
    290290     * Returns the builtin "Boolean.prototype" object.
    291291     */
    292     Object builtinBooleanPrototype() const;
     292    ObjectImp *builtinBooleanPrototype() const;
    293293
    294294    /**
    295295     * Returns the builtin "String.prototype" object.
    296296     */
    297     Object builtinStringPrototype() const;
     297    ObjectImp *builtinStringPrototype() const;
    298298
    299299    /**
    300300     * Returns the builtin "Number.prototype" object.
    301301     */
    302     Object builtinNumberPrototype() const;
     302    ObjectImp *builtinNumberPrototype() const;
    303303
    304304    /**
    305305     * Returns the builtin "Date.prototype" object.
    306306     */
    307     Object builtinDatePrototype() const;
     307    ObjectImp *builtinDatePrototype() const;
    308308
    309309    /**
    310310     * Returns the builtin "RegExp.prototype" object.
    311311     */
    312     Object builtinRegExpPrototype() const;
     312    ObjectImp *builtinRegExpPrototype() const;
    313313
    314314    /**
    315315     * Returns the builtin "Error.prototype" object.
    316316     */
    317     Object builtinErrorPrototype() const;
     317    ObjectImp *builtinErrorPrototype() const;
    318318
    319319    /**
    320320     * The initial value of "Error" global property
    321321     */
    322     Object builtinEvalError() const;
    323     Object builtinRangeError() const;
    324     Object builtinReferenceError() const;
    325     Object builtinSyntaxError() const;
    326     Object builtinTypeError() const;
    327     Object builtinURIError() const;
    328 
    329     Object builtinEvalErrorPrototype() const;
    330     Object builtinRangeErrorPrototype() const;
    331     Object builtinReferenceErrorPrototype() const;
    332     Object builtinSyntaxErrorPrototype() const;
    333     Object builtinTypeErrorPrototype() const;
    334     Object builtinURIErrorPrototype() const;
     322    ObjectImp *builtinEvalError() const;
     323    ObjectImp *builtinRangeError() const;
     324    ObjectImp *builtinReferenceError() const;
     325    ObjectImp *builtinSyntaxError() const;
     326    ObjectImp *builtinTypeError() const;
     327    ObjectImp *builtinURIError() const;
     328
     329    ObjectImp *builtinEvalErrorPrototype() const;
     330    ObjectImp *builtinRangeErrorPrototype() const;
     331    ObjectImp *builtinReferenceErrorPrototype() const;
     332    ObjectImp *builtinSyntaxErrorPrototype() const;
     333    ObjectImp *builtinTypeErrorPrototype() const;
     334    ObjectImp *builtinURIErrorPrototype() const;
    335335
    336336    enum CompatMode { NativeMode, IECompat, NetscapeCompat };
     
    381381     * security checks.
    382382     */
    383     virtual bool isGlobalObject(const Value &v) { return false; }
     383    virtual bool isGlobalObject(ValueImp *v) { return false; }
    384384   
    385385    /**
     
    400400    virtual bool isSafeScript (const Interpreter *target) { return true; }
    401401   
    402     virtual void *createLanguageInstanceForValue (ExecState *exec, int language, const Object &value, const Bindings::RootObject *origin, const Bindings::RootObject *current);
     402    virtual void *createLanguageInstanceForValue (ExecState *exec, int language, ObjectImp *value, const Bindings::RootObject *origin, const Bindings::RootObject *current);
    403403#endif
    404404
     
    471471    Context context() const { return _context; }
    472472
    473     void setException(const Value &e) { _exception = e; }
    474     void clearException() { _exception = Value(); }
    475     Value exception() const { return _exception; }
    476     bool hadException() const { return !_exception.isNull(); }
     473    void setException(ValueImp *e) { _exception = e; }
     474    void clearException() { _exception = NULL; }
     475    ValueImp *exception() const { return _exception; }
     476    bool hadException() const { return _exception; }
    477477
    478478  private:
    479479    ExecState(Interpreter *interp, ContextImp *con)
    480         : _interpreter(interp), _context(con) { }
     480        : _interpreter(interp), _context(con), _exception(NULL) { }
    481481    Interpreter *_interpreter;
    482482    ContextImp *_context;
    483     Value _exception;
     483    ValueImp *_exception;
    484484  };
    485485
  • trunk/JavaScriptCore/kjs/list.cpp

    r9768 r10084  
    234234}
    235235
    236 ValueImp *List::impAt(int i) const
     236ValueImp *List::at(int i) const
    237237{
    238238    ListImp *imp = static_cast<ListImp *>(_impBase);
    239239    if ((unsigned)i >= (unsigned)imp->size)
    240         return UndefinedImp::staticUndefined;
     240        return jsUndefined();
    241241    if (i < inlineValuesSize)
    242242        return imp->values[i];
  • trunk/JavaScriptCore/kjs/list.h

    r9768 r10084  
    6363         * @param val Pointer to object.
    6464         */
    65         void append(const Value& val) { append(val.imp()); }
    6665        void append(ValueImp *val);
    6766        /**
     
    105104         * index is out of range.
    106105         */
    107         Value at(int i) const { return Value(impAt(i)); }
     106        ValueImp *at(int i) const;
    108107        /**
    109108         * Equivalent to at.
    110109         */
    111         Value operator[](int i) const { return Value(impAt(i)); }
    112        
    113         ValueImp *impAt(int i) const;
     110        ValueImp *operator[](int i) const { return at(i); }
    114111   
    115112        /**
     
    147144         * @return A pointer to the element the iterator operates on.
    148145         */
    149         ValueImp *operator->() const { return _list->impAt(_i); }
    150         Value operator*() const { return Value(_list->impAt(_i)); }
     146        ValueImp *operator->() const { return _list->at(_i); }
     147        ValueImp *operator*() const { return _list->at(_i); }
    151148        /**
    152149         * Prefix increment operator.
    153150         * @return The element after the increment.
    154151         */
    155         Value operator++() { return Value(_list->impAt(++_i)); }
     152        ValueImp *operator++() { return _list->at(++_i); }
    156153        /**
    157154         * Postfix increment operator.
    158155         */
    159         Value operator++(int) { return Value(_list->impAt(_i++)); }
     156        ValueImp *operator++(int) { return _list->at(_i++); }
    160157        /**
    161158         * Prefix decrement operator.
    162159         */
    163         Value operator--() { return Value(_list->impAt(--_i)); }
     160        ValueImp *operator--() { return _list->at(--_i); }
    164161        /**
    165162         * Postfix decrement operator.
    166163         */
    167         Value operator--(int) { return Value(_list->impAt(_i--)); }
     164        ValueImp *operator--(int) { return _list->at(_i--); }
    168165        /**
    169166         * Compare the iterator with another one.
  • trunk/JavaScriptCore/kjs/lookup.h

    r10076 r10084  
    128128   */
    129129  template <class FuncImp>
    130   inline Value staticFunctionGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
     130  inline ValueImp *staticFunctionGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
    131131  {
    132132      // Look for cached value in dynamic map of properties (in ObjectImp)
     
    134134      ValueImp *cachedVal = thisObj->getDirect(propertyName);
    135135      if (cachedVal)
    136           return Value(cachedVal);
     136        return cachedVal;
    137137
    138138      const HashEntry *entry = slot.staticEntry();
    139       Value val = Value(new FuncImp(exec, entry->value, entry->params));
    140       thisObj->putDirect(propertyName, val.imp(), entry->attr);
     139      ValueImp *val = new FuncImp(exec, entry->value, entry->params);
     140      thisObj->putDirect(propertyName, val, entry->attr);
    141141      return val;
    142142  }
     
    147147   */
    148148  template <class ThisImp>
    149   inline Value staticValueGetter(ExecState *exec, const Identifier&, const PropertySlot& slot)
     149  inline ValueImp *staticValueGetter(ExecState *exec, const Identifier&, const PropertySlot& slot)
    150150  {
    151151      ThisImp *thisObj = static_cast<ThisImp *>(slot.slotBase());
     
    236236  template <class ThisImp, class ParentImp>
    237237  inline void lookupPut(ExecState *exec, const Identifier &propertyName,
    238                         const Value& value, int attr,
     238                        ValueImp *value, int attr,
    239239                        const HashTable* table, ThisImp* thisObj)
    240240  {
     
    265265  inline ObjectImp *cacheGlobalObject(ExecState *exec, const Identifier &propertyName)
    266266  {
    267     ObjectImp *globalObject = static_cast<ObjectImp *>(exec->lexicalInterpreter()->globalObject().imp());
     267    ObjectImp *globalObject = static_cast<ObjectImp *>(exec->lexicalInterpreter()->globalObject());
    268268    ValueImp *obj = globalObject->getDirect(propertyName);
    269269    if (obj) {
     
    272272    }
    273273    ObjectImp *newObject = new ClassCtor(exec);
    274     globalObject->put(exec, propertyName, Value(newObject), Internal);
     274    globalObject->put(exec, propertyName, newObject, Internal);
    275275    return newObject;
    276276  }
     
    298298    static ObjectImp *self(ExecState *exec) \
    299299    { \
    300       return cacheGlobalObject<ClassProto>( exec, "[[" ClassName ".prototype]]" ); \
     300      return cacheGlobalObject<ClassProto>(exec, "[[" ClassName ".prototype]]"); \
    301301    } \
    302302  protected: \
     
    332332       put(exec, lengthPropertyName, Number(len), DontDelete|ReadOnly|DontEnum); \
    333333    } \
    334     /* Macro user needs to implement the call function. */ \
    335     virtual Value call(ExecState *exec, Object &thisObj, const List &args); \
     334    /* Macro user needs to implement the callAsFunction function. */ \
     335    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args); \
    336336  private: \
    337337    int id; \
  • trunk/JavaScriptCore/kjs/math_object.cpp

    r10076 r10084  
    8787}
    8888
    89 Value MathObjectImp::getValueProperty(ExecState *, int token) const
     89ValueImp *MathObjectImp::getValueProperty(ExecState *, int token) const
    9090{
    9191  double d = -42; // ;)
     
    126126MathFuncImp::MathFuncImp(ExecState *exec, int i, int l)
    127127  : InternalFunctionImp(
    128     static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype().imp())
     128    static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype())
    129129    ), id(i)
    130130{
    131   Value protect(this);
    132131  putDirect(lengthPropertyName, l, DontDelete|ReadOnly|DontEnum);
    133132}
     
    138137}
    139138
    140 Value MathFuncImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
    141 {
    142   double arg = args[0].toNumber(exec);
    143   double arg2 = args[1].toNumber(exec);
     139ValueImp *MathFuncImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
     140{
     141  double arg = args[0]->toNumber(exec);
     142  double arg2 = args[1]->toNumber(exec);
    144143  double result;
    145144
     
    179178    result = -Inf;
    180179    for ( unsigned int k = 0 ; k < argsCount ; ++k ) {
    181       double val = args[k].toNumber(exec);
     180      double val = args[k]->toNumber(exec);
    182181      if ( isNaN( val ) )
    183182      {
     
    194193    result = +Inf;
    195194    for ( unsigned int k = 0 ; k < argsCount ; ++k ) {
    196       double val = args[k].toNumber(exec);
     195      double val = args[k]->toNumber(exec);
    197196      if ( isNaN( val ) )
    198197      {
  • trunk/JavaScriptCore/kjs/math_object.h

    r10076 r10084  
    3333                  ObjectPrototypeImp *objProto);
    3434    bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
    35     Value getValueProperty(ExecState *exec, int token) const;
     35    ValueImp *getValueProperty(ExecState *exec, int token) const;
    3636    virtual const ClassInfo *classInfo() const { return &info; }
    3737    static const ClassInfo info;
     
    4545    MathFuncImp(ExecState *exec, int i, int l);
    4646    virtual bool implementsCall() const;
    47     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     47    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    4848  private:
    4949    int id;
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r10076 r10084  
    2525#include "nodes.h"
    2626
    27 //#include <iostream>
    2827#include <math.h>
    2928#include <assert.h>
     
    4544#include "operations.h"
    4645#include "ustring.h"
     46#include "reference_list.h"
    4747
    4848using namespace KJS;
     
    117117Reference Node::evaluateReference(ExecState *exec)
    118118{
    119   Value v = evaluate(exec);
     119  ValueImp *v = evaluate(exec);
    120120  KJS_CHECKEXCEPTIONREFERENCE
    121121  return Reference::makeValueReference(v);
     
    134134#endif
    135135
    136 Value Node::throwError(ExecState *exec, ErrorType e, const char *msg)
    137 {
    138   Object err = Error::create(exec, e, msg, lineNo(), sourceId(), &sourceURL);
     136ValueImp *Node::throwError(ExecState *exec, ErrorType e, const char *msg)
     137{
     138  ObjectImp *err = Error::create(exec, e, msg, lineNo(), sourceId(), &sourceURL);
    139139  exec->setException(err);
    140140  return err;
    141141}
    142142
    143 Value Node::throwError(ExecState *exec, ErrorType e, const char *msg, Value v, Node *expr)
    144 {
    145   char *vStr = strdup(v.toString(exec).ascii());
     143ValueImp *Node::throwError(ExecState *exec, ErrorType e, const char *msg, ValueImp *v, Node *expr)
     144{
     145  char *vStr = strdup(v->toString(exec).ascii());
    146146  char *exprStr = strdup(expr->toString().ascii());
    147147 
     
    152152  free(exprStr);
    153153
    154   Value result = throwError(exec, e, str);
     154  ValueImp *result = throwError(exec, e, str);
    155155  delete [] str;
    156156 
     
    159159
    160160
    161 Value Node::throwError(ExecState *exec, ErrorType e, const char *msg, Identifier label)
     161ValueImp *Node::throwError(ExecState *exec, ErrorType e, const char *msg, Identifier label)
    162162{
    163163  const char *l = label.ascii();
     
    166166  sprintf(message, msg, l);
    167167
    168   Value result = throwError(exec, e, message);
     168  ValueImp *result = throwError(exec, e, message);
    169169  delete [] message;
    170170
     
    175175{
    176176    if (exec->hadException()) {
    177         Object exception = exec->exception().toObject(exec);
    178         if (!exception.hasProperty(exec, "line") &&
    179             !exception.hasProperty(exec, "sourceURL")) {
    180             exception.put(exec, "line", Number(line));
    181             exception.put(exec, "sourceURL", String(sourceURL));
     177        ObjectImp *exception = exec->exception()->toObject(exec);
     178        if (!exception->hasProperty(exec, "line") &&
     179            !exception->hasProperty(exec, "sourceURL")) {
     180            exception->put(exec, "line", Number(line));
     181            exception->put(exec, "sourceURL", String(sourceURL));
    182182        }
    183183    }
     
    223223// ------------------------------ NullNode -------------------------------------
    224224
    225 Value NullNode::evaluate(ExecState */*exec*/)
     225ValueImp *NullNode::evaluate(ExecState */*exec*/)
    226226{
    227227  return Null();
     
    230230// ------------------------------ BooleanNode ----------------------------------
    231231
    232 Value BooleanNode::evaluate(ExecState */*exec*/)
    233 {
    234   return Value(value);
     232ValueImp *BooleanNode::evaluate(ExecState */*exec*/)
     233{
     234  return jsBoolean(value);
    235235}
    236236
    237237// ------------------------------ NumberNode -----------------------------------
    238238
    239 Value NumberNode::evaluate(ExecState */*exec*/)
    240 {
    241   return Value(value);
     239ValueImp *NumberNode::evaluate(ExecState */*exec*/)
     240{
     241  return jsNumber(value);
    242242}
    243243
    244244// ------------------------------ StringNode -----------------------------------
    245245
    246 Value StringNode::evaluate(ExecState */*exec*/)
    247 {
    248   return value;
     246ValueImp *StringNode::evaluate(ExecState */*exec*/)
     247{
     248  return jsString(value);
    249249}
    250250
    251251// ------------------------------ RegExpNode -----------------------------------
    252252
    253 Value RegExpNode::evaluate(ExecState *exec)
     253ValueImp *RegExpNode::evaluate(ExecState *exec)
    254254{
    255255  List list;
    256   String p(pattern);
    257   String f(flags);
    258   list.append(p);
    259   list.append(f);
    260 
    261   Object reg = exec->lexicalInterpreter()->imp()->builtinRegExp();
    262   return reg.construct(exec,list);
     256  list.append(jsString(pattern));
     257  list.append(jsString(flags));
     258
     259  ObjectImp *reg = exec->lexicalInterpreter()->imp()->builtinRegExp();
     260  return reg->construct(exec,list);
    263261}
    264262
     
    266264
    267265// ECMA 11.1.1
    268 Value ThisNode::evaluate(ExecState *exec)
     266ValueImp *ThisNode::evaluate(ExecState *exec)
    269267{
    270268  return exec->context().imp()->thisValue();
     
    274272
    275273// ECMA 11.1.2 & 10.1.4
    276 Value ResolveNode::evaluate(ExecState *exec)
     274ValueImp *ResolveNode::evaluate(ExecState *exec)
    277275{
    278276  ScopeChain chain = exec->context().imp()->scopeChain();
     
    283281  do {
    284282    ObjectImp *o = chain.top();
     283
    285284    if (o->getPropertySlot(exec, ident, slot))
    286285      return slot.getValue(exec, ident);
     
    289288  } while (!chain.isEmpty());
    290289
    291   return Reference(Null(), ident).getValue(exec);
     290  return Reference(ident).getValue(exec);
    292291}
    293292
     
    307306  } while (!chain.isEmpty());
    308307
    309   return Reference(Null(), ident);
    310 }
    311 
     308  return Reference(ident);
     309}
    312310
    313311// ------------------------------ GroupNode ------------------------------------
     
    328326
    329327// ECMA 11.1.6
    330 Value GroupNode::evaluate(ExecState *exec)
     328ValueImp *GroupNode::evaluate(ExecState *exec)
    331329{
    332330  return group->evaluate(exec);
     
    363361
    364362// ECMA 11.1.4
    365 Value ElementNode::evaluate(ExecState *exec)
    366 {
    367   Object array = exec->lexicalInterpreter()->builtinArray().construct(exec, List::empty());
     363ValueImp *ElementNode::evaluate(ExecState *exec)
     364{
     365  ObjectImp *array = exec->lexicalInterpreter()->builtinArray()->construct(exec, List::empty());
    368366  int length = 0;
    369367  for (ElementNode *n = this; n; n = n->list) {
    370     Value val = n->node->evaluate(exec);
     368    ValueImp *val = n->node->evaluate(exec);
    371369    KJS_CHECKEXCEPTIONVALUE
    372370    length += n->elision;
    373     array.put(exec, length++, val);
     371    array->put(exec, length++, val);
    374372  }
    375373  return array;
     
    393391
    394392// ECMA 11.1.4
    395 Value ArrayNode::evaluate(ExecState *exec)
    396 {
    397   Object array;
     393ValueImp *ArrayNode::evaluate(ExecState *exec)
     394{
     395  ObjectImp *array;
    398396  int length;
    399397
    400398  if (element) {
    401     array = Object(static_cast<ObjectImp*>(element->evaluate(exec).imp()));
     399    array = static_cast<ObjectImp*>(element->evaluate(exec));
    402400    KJS_CHECKEXCEPTIONVALUE
    403     length = opt ? array.get(exec,lengthPropertyName).toInt32(exec) : 0;
     401    length = opt ? array->get(exec,lengthPropertyName)->toInt32(exec) : 0;
    404402  } else {
    405     Value newArr = exec->lexicalInterpreter()->builtinArray().construct(exec,List::empty());
    406     array = Object(static_cast<ObjectImp*>(newArr.imp()));
     403    ValueImp *newArr = exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty());
     404    array = static_cast<ObjectImp*>(newArr);
    407405    length = 0;
    408406  }
    409407
    410408  if (opt)
    411     array.put(exec,lengthPropertyName, Value(elision + length), DontEnum | DontDelete);
     409    array->put(exec,lengthPropertyName, jsNumber(elision + length), DontEnum | DontDelete);
    412410
    413411  return array;
     
    431429
    432430// ECMA 11.1.5
    433 Value ObjectLiteralNode::evaluate(ExecState *exec)
     431ValueImp *ObjectLiteralNode::evaluate(ExecState *exec)
    434432{
    435433  if (list)
    436434    return list->evaluate(exec);
    437435
    438   return exec->lexicalInterpreter()->builtinObject().construct(exec,List::empty());
     436  return exec->lexicalInterpreter()->builtinObject()->construct(exec,List::empty());
    439437}
    440438
     
    468466
    469467// ECMA 11.1.5
    470 Value PropertyValueNode::evaluate(ExecState *exec)
    471 {
    472   Object obj = exec->lexicalInterpreter()->builtinObject().construct(exec, List::empty());
     468ValueImp *PropertyValueNode::evaluate(ExecState *exec)
     469{
     470  ObjectImp *obj = exec->lexicalInterpreter()->builtinObject()->construct(exec, List::empty());
    473471 
    474472  for (PropertyValueNode *p = this; p; p = p->list) {
    475     Value n = p->name->evaluate(exec);
     473    ValueImp *n = p->name->evaluate(exec);
    476474    KJS_CHECKEXCEPTIONVALUE
    477     Value v = p->assign->evaluate(exec);
     475    ValueImp *v = p->assign->evaluate(exec);
    478476    KJS_CHECKEXCEPTIONVALUE
    479477
    480     obj.put(exec, Identifier(n.toString(exec)), v);
     478    obj->put(exec, Identifier(n->toString(exec)), v);
    481479  }
    482480
     
    487485
    488486// ECMA 11.1.5
    489 Value PropertyNode::evaluate(ExecState */*exec*/)
    490 {
    491   Value s;
     487ValueImp *PropertyNode::evaluate(ExecState */*exec*/)
     488{
     489  ValueImp *s;
    492490
    493491  if (str.isNull()) {
     
    521519
    522520// ECMA 11.2.1a
    523 Value AccessorNode1::evaluate(ExecState *exec)
    524 {
    525   Value v1 = expr1->evaluate(exec);
    526   KJS_CHECKEXCEPTIONVALUE
    527   Value v2 = expr2->evaluate(exec);
    528   KJS_CHECKEXCEPTIONVALUE
    529   Object o = v1.toObject(exec);
    530   unsigned i;
    531   if (v2.toUInt32(i))
    532     return o.get(exec, i);
    533 
    534   String s = v2.toString(exec);
    535   return o.get(exec, Identifier(s.value()));
     521ValueImp *AccessorNode1::evaluate(ExecState *exec)
     522{
     523  ValueImp *v1 = expr1->evaluate(exec);
     524  KJS_CHECKEXCEPTIONVALUE
     525  ValueImp *v2 = expr2->evaluate(exec);
     526  KJS_CHECKEXCEPTIONVALUE
     527  ObjectImp *o = v1->toObject(exec);
     528  uint32_t i;
     529  if (v2->getUInt32(i))
     530    return o->get(exec, i);
     531  return o->get(exec, Identifier(v2->toString(exec)));
    536532}
    537533
    538534Reference AccessorNode1::evaluateReference(ExecState *exec)
    539535{
    540   Value v1 = expr1->evaluate(exec);
     536  ValueImp *v1 = expr1->evaluate(exec);
    541537  KJS_CHECKEXCEPTIONREFERENCE
    542   Value v2 = expr2->evaluate(exec);
     538  ValueImp *v2 = expr2->evaluate(exec);
    543539  KJS_CHECKEXCEPTIONREFERENCE
    544   Object o = v1.toObject(exec);
    545   unsigned i;
    546   if (v2.toUInt32(i))
     540  ObjectImp *o = v1->toObject(exec);
     541  uint32_t i;
     542  if (v2->getUInt32(i))
    547543    return Reference(o, i);
    548   String s = v2.toString(exec);
    549   return Reference(o, Identifier(s.value()));
    550 }
    551 
     544  return Reference(o, Identifier(v2->toString(exec)));
     545}
    552546
    553547// ------------------------------ AccessorNode2 --------------------------------
     
    568562
    569563// ECMA 11.2.1b
    570 Value AccessorNode2::evaluate(ExecState *exec)
    571 {
    572   Value v = expr->evaluate(exec);
    573   KJS_CHECKEXCEPTIONVALUE
    574   Object o = v.toObject(exec);
    575   return o.get(exec, ident);
     564ValueImp *AccessorNode2::evaluate(ExecState *exec)
     565{
     566  ValueImp *v = expr->evaluate(exec);
     567  KJS_CHECKEXCEPTIONVALUE
     568  return v->toObject(exec)->get(exec, ident);
    576569
    577570}
     
    579572Reference AccessorNode2::evaluateReference(ExecState *exec)
    580573{
    581   Value v = expr->evaluate(exec);
     574  ValueImp *v = expr->evaluate(exec);
    582575  KJS_CHECKEXCEPTIONREFERENCE
    583   Object o = v.toObject(exec);
     576  ObjectImp *o = v->toObject(exec);
    584577  return Reference(o, ident);
    585578}
     
    609602}
    610603
    611 Value ArgumentListNode::evaluate(ExecState */*exec*/)
     604ValueImp *ArgumentListNode::evaluate(ExecState */*exec*/)
    612605{
    613606  assert(0);
    614   return Value(); // dummy, see evaluateList()
     607  return NULL; // dummy, see evaluateList()
    615608}
    616609
     
    621614
    622615  for (ArgumentListNode *n = this; n; n = n->list) {
    623     Value v = n->expr->evaluate(exec);
     616    ValueImp *v = n->expr->evaluate(exec);
    624617    KJS_CHECKEXCEPTIONLIST
    625618    l.append(v);
     
    645638}
    646639
    647 Value ArgumentsNode::evaluate(ExecState */*exec*/)
     640ValueImp *ArgumentsNode::evaluate(ExecState */*exec*/)
    648641{
    649642  assert(0);
    650   return Value(); // dummy, see evaluateList()
     643  return NULL; // dummy, see evaluateList()
    651644}
    652645
     
    682675}
    683676
    684 Value NewExprNode::evaluate(ExecState *exec)
    685 {
    686   Value v = expr->evaluate(exec);
     677ValueImp *NewExprNode::evaluate(ExecState *exec)
     678{
     679  ValueImp *v = expr->evaluate(exec);
    687680  KJS_CHECKEXCEPTIONVALUE
    688681
     
    693686  }
    694687
    695   if (v.type() != ObjectType) {
     688  if (!v->isObject()) {
    696689    return throwError(exec, TypeError, "Value %s (result of expression %s) is not an object. Cannot be used with new.", v, expr);
    697690  }
    698691
    699   Object constr = Object(static_cast<ObjectImp*>(v.imp()));
    700   if (!constr.implementsConstruct()) {
     692  ObjectImp *constr = static_cast<ObjectImp*>(v);
     693  if (!constr->implementsConstruct()) {
    701694    return throwError(exec, TypeError, "Value %s (result of expression %s) is not a constructor. Cannot be used with new.", v, expr);
    702695  }
    703696
    704   Value res = constr.construct(exec,argList);
    705 
    706   return res;
     697  return constr->construct(exec, argList);
    707698}
    708699
     
    728719
    729720// ECMA 11.2.3
    730 Value FunctionCallNode::evaluate(ExecState *exec)
     721ValueImp *FunctionCallNode::evaluate(ExecState *exec)
    731722{
    732723  Reference ref = expr->evaluateReference(exec);
     
    736727  KJS_CHECKEXCEPTIONVALUE
    737728
    738   Value v = ref.getValue(exec);
    739   KJS_CHECKEXCEPTIONVALUE
    740 
    741   if (v.type() != ObjectType) {
     729  ValueImp *v = ref.getValue(exec);
     730  KJS_CHECKEXCEPTIONVALUE
     731 
     732  if (!v->isObject()) {
    742733    return throwError(exec, TypeError, "Value %s (result of expression %s) is not object.", v, expr);
    743734  }
    744 
    745   ObjectImp *func = static_cast<ObjectImp*>(v.imp());
     735 
     736  ObjectImp *func = static_cast<ObjectImp*>(v);
    746737
    747738  if (!func->implementsCall()) {
     
    751742  ObjectImp *thisObjImp = 0;
    752743  ValueImp *thisValImp = ref.baseIfMutable();
    753   if (thisValImp && thisValImp->type() == ObjectType && !static_cast<ObjectImp *>(thisValImp)->inherits(&ActivationImp::info))
     744  if (thisValImp && thisValImp->isObject() && !static_cast<ObjectImp *>(thisValImp)->inherits(&ActivationImp::info))
    754745    thisObjImp = static_cast<ObjectImp *>(thisValImp);
    755746
     
    761752    // of implementation we use the global object anyway here. This guarantees
    762753    // that in host objects you always get a valid object for this.
    763     thisObjImp = exec->dynamicInterpreter()->globalObject().imp();
    764   }
    765 
    766   Object thisObj(thisObjImp);
     754    thisObjImp = exec->dynamicInterpreter()->globalObject();
     755  }
     756
     757  ObjectImp *thisObj(thisObjImp);
    767758  return func->call(exec, thisObj, argList);
    768759}
     
    785776
    786777// ECMA 11.3
    787 Value PostfixNode::evaluate(ExecState *exec)
     778ValueImp *PostfixNode::evaluate(ExecState *exec)
    788779{
    789780  Reference ref = expr->evaluateReference(exec);
    790781  KJS_CHECKEXCEPTIONVALUE
    791   Value v = ref.getValue(exec);
     782  ValueImp *v = ref.getValue(exec);
    792783
    793784  bool knownToBeInteger;
    794   double n = v.toNumber(exec, knownToBeInteger);
     785  double n = v->toNumber(exec, knownToBeInteger);
    795786
    796787  double newValue = (oper == OpPlusPlus) ? n + 1 : n - 1;
    797   ref.putValue(exec, Value(newValue, knownToBeInteger));
    798 
    799   return Value(n, knownToBeInteger);
     788  ref.putValue(exec, jsNumber(newValue, knownToBeInteger));
     789
     790  return jsNumber(n, knownToBeInteger);
    800791}
    801792
     
    817808
    818809// ECMA 11.4.1
    819 Value DeleteNode::evaluate(ExecState *exec)
     810ValueImp *DeleteNode::evaluate(ExecState *exec)
    820811{
    821812  Reference ref = expr->evaluateReference(exec);
    822813  KJS_CHECKEXCEPTIONVALUE
    823   return Value(ref.deleteValue(exec));
     814  return jsBoolean(ref.deleteValue(exec));
    824815}
    825816
     
    841832
    842833// ECMA 11.4.2
    843 Value VoidNode::evaluate(ExecState *exec)
    844 {
    845   Value dummy1 = expr->evaluate(exec);
     834ValueImp *VoidNode::evaluate(ExecState *exec)
     835{
     836  expr->evaluate(exec);
    846837  KJS_CHECKEXCEPTIONVALUE
    847838
     
    866857
    867858// ECMA 11.4.3
    868 Value TypeOfNode::evaluate(ExecState *exec)
     859ValueImp *TypeOfNode::evaluate(ExecState *exec)
    869860{
    870861  const char *s = 0L;
     
    872863  KJS_CHECKEXCEPTIONVALUE
    873864  ValueImp *b = ref.baseIfMutable();
    874   if (b && b->dispatchType() == NullType)
    875     return Value("undefined");
    876   Value v = ref.getValue(exec);
    877   switch (v.type())
     865  if (b && b->isNull())
     866    return jsString("undefined");
     867  ValueImp *v = ref.getValue(exec);
     868  switch (v->type())
    878869    {
    879870    case UndefinedType:
     
    893884      break;
    894885    default:
    895       if (v.type() == ObjectType && static_cast<ObjectImp*>(v.imp())->implementsCall())
     886      if (v->isObject() && static_cast<ObjectImp*>(v)->implementsCall())
    896887        s = "function";
    897888      else
     
    900891    }
    901892
    902   return Value(s);
     893  return jsString(s);
    903894}
    904895
     
    920911
    921912// ECMA 11.4.4 and 11.4.5
    922 Value PrefixNode::evaluate(ExecState *exec)
     913ValueImp *PrefixNode::evaluate(ExecState *exec)
    923914{
    924915  Reference ref = expr->evaluateReference(exec);
    925916  KJS_CHECKEXCEPTIONVALUE
    926   Value v = ref.getValue(exec);
     917  ValueImp *v = ref.getValue(exec);
    927918
    928919  bool knownToBeInteger;
    929   double n = v.toNumber(exec, knownToBeInteger);
     920  double n = v->toNumber(exec, knownToBeInteger);
    930921
    931922  double newValue = (oper == OpPlusPlus) ? n + 1 : n - 1;
    932   Value n2(newValue, knownToBeInteger);
     923  ValueImp *n2 = jsNumber(newValue, knownToBeInteger);
    933924
    934925  ref.putValue(exec, n2);
     
    954945
    955946// ECMA 11.4.6
    956 Value UnaryPlusNode::evaluate(ExecState *exec)
    957 {
    958   Value v = expr->evaluate(exec);
    959   KJS_CHECKEXCEPTIONVALUE
    960 
    961   return Value(v.toNumber(exec)); /* TODO: optimize */
     947ValueImp *UnaryPlusNode::evaluate(ExecState *exec)
     948{
     949  ValueImp *v = expr->evaluate(exec);
     950  KJS_CHECKEXCEPTIONVALUE
     951
     952  return jsNumber(v->toNumber(exec)); /* TODO: optimize */
    962953}
    963954
     
    979970
    980971// ECMA 11.4.7
    981 Value NegateNode::evaluate(ExecState *exec)
    982 {
    983   Value v = expr->evaluate(exec);
     972ValueImp *NegateNode::evaluate(ExecState *exec)
     973{
     974  ValueImp *v = expr->evaluate(exec);
    984975  KJS_CHECKEXCEPTIONVALUE
    985976
    986977  bool knownToBeInteger;
    987   double n = v.toNumber(exec, knownToBeInteger);
    988   return Value(-n, knownToBeInteger && n != 0);
     978  double n = v->toNumber(exec, knownToBeInteger);
     979  return jsNumber(-n, knownToBeInteger && n != 0);
    989980}
    990981
     
    1006997
    1007998// ECMA 11.4.8
    1008 Value BitwiseNotNode::evaluate(ExecState *exec)
    1009 {
    1010   Value v = expr->evaluate(exec);
    1011   KJS_CHECKEXCEPTIONVALUE
    1012   return Value(~v.toInt32(exec));
     999ValueImp *BitwiseNotNode::evaluate(ExecState *exec)
     1000{
     1001  ValueImp *v = expr->evaluate(exec);
     1002  KJS_CHECKEXCEPTIONVALUE
     1003  return jsNumber(~v->toInt32(exec));
    10131004}
    10141005
     
    10301021
    10311022// ECMA 11.4.9
    1032 Value LogicalNotNode::evaluate(ExecState *exec)
    1033 {
    1034   Value v = expr->evaluate(exec);
    1035   KJS_CHECKEXCEPTIONVALUE
    1036   return Value(!v.toBoolean(exec));
     1023ValueImp *LogicalNotNode::evaluate(ExecState *exec)
     1024{
     1025  ValueImp *v = expr->evaluate(exec);
     1026  KJS_CHECKEXCEPTIONVALUE
     1027  return jsBoolean(!v->toBoolean(exec));
    10371028}
    10381029
     
    10581049
    10591050// ECMA 11.5
    1060 Value MultNode::evaluate(ExecState *exec)
    1061 {
    1062   Value v1 = term1->evaluate(exec);
    1063   KJS_CHECKEXCEPTIONVALUE
    1064 
    1065   Value v2 = term2->evaluate(exec);
     1051ValueImp *MultNode::evaluate(ExecState *exec)
     1052{
     1053  ValueImp *v1 = term1->evaluate(exec);
     1054  KJS_CHECKEXCEPTIONVALUE
     1055
     1056  ValueImp *v2 = term2->evaluate(exec);
    10661057  KJS_CHECKEXCEPTIONVALUE
    10671058
     
    10901081
    10911082// ECMA 11.6
    1092 Value AddNode::evaluate(ExecState *exec)
    1093 {
    1094   Value v1 = term1->evaluate(exec);
    1095   KJS_CHECKEXCEPTIONVALUE
    1096 
    1097   Value v2 = term2->evaluate(exec);
     1083ValueImp *AddNode::evaluate(ExecState *exec)
     1084{
     1085  ValueImp *v1 = term1->evaluate(exec);
     1086  KJS_CHECKEXCEPTIONVALUE
     1087
     1088  ValueImp *v2 = term2->evaluate(exec);
    10981089  KJS_CHECKEXCEPTIONVALUE
    10991090
     
    11221113
    11231114// ECMA 11.7
    1124 Value ShiftNode::evaluate(ExecState *exec)
    1125 {
    1126   Value v1 = term1->evaluate(exec);
    1127   KJS_CHECKEXCEPTIONVALUE
    1128   Value v2 = term2->evaluate(exec);
    1129   KJS_CHECKEXCEPTIONVALUE
    1130   unsigned int i2 = v2.toUInt32(exec);
     1115ValueImp *ShiftNode::evaluate(ExecState *exec)
     1116{
     1117  ValueImp *v1 = term1->evaluate(exec);
     1118  KJS_CHECKEXCEPTIONVALUE
     1119  ValueImp *v2 = term2->evaluate(exec);
     1120  KJS_CHECKEXCEPTIONVALUE
     1121  unsigned int i2 = v2->toUInt32(exec);
    11311122  i2 &= 0x1f;
    11321123
    11331124  switch (oper) {
    11341125  case OpLShift:
    1135     return Value(v1.toInt32(exec) << i2);
     1126    return jsNumber(v1->toInt32(exec) << i2);
    11361127  case OpRShift:
    1137     return Value(v1.toInt32(exec) >> i2);
     1128    return jsNumber(v1->toInt32(exec) >> i2);
    11381129  case OpURShift:
    1139     return Value(v1.toUInt32(exec) >> i2);
     1130    return jsNumber(v1->toUInt32(exec) >> i2);
    11401131  default:
    11411132    assert(!"ShiftNode: unhandled switch case");
     
    11651156
    11661157// ECMA 11.8
    1167 Value RelationalNode::evaluate(ExecState *exec)
    1168 {
    1169   Value v1 = expr1->evaluate(exec);
    1170   KJS_CHECKEXCEPTIONVALUE
    1171   Value v2 = expr2->evaluate(exec);
     1158ValueImp *RelationalNode::evaluate(ExecState *exec)
     1159{
     1160  ValueImp *v1 = expr1->evaluate(exec);
     1161  KJS_CHECKEXCEPTIONVALUE
     1162  ValueImp *v2 = expr2->evaluate(exec);
    11721163  KJS_CHECKEXCEPTIONVALUE
    11731164
     
    11871178  } else if (oper == OpIn) {
    11881179      // Is all of this OK for host objects?
    1189       if (v2.type() != ObjectType)
     1180      if (!v2->isObject())
    11901181          return throwError(exec,  TypeError,
    11911182                             "Value %s (result of expression %s) is not an object. Cannot be used with IN expression.", v2, expr2);
    1192       Object o2(static_cast<ObjectImp*>(v2.imp()));
    1193       b = o2.hasProperty(exec, Identifier(v1.toString(exec)));
     1183      ObjectImp *o2(static_cast<ObjectImp*>(v2));
     1184      b = o2->hasProperty(exec, Identifier(v1->toString(exec)));
    11941185  } else {
    1195     if (v2.type() != ObjectType)
     1186    if (!v2->isObject())
    11961187        return throwError(exec,  TypeError,
    11971188                           "Value %s (result of expression %s) is not an object. Cannot be used with instanceof operator.", v2, expr2);
    11981189
    1199     Object o2(static_cast<ObjectImp*>(v2.imp()));
    1200     if (!o2.implementsHasInstance()) {
    1201       // According to the spec, only some types of objects "imlement" the [[HasInstance]] property.
     1190    ObjectImp *o2(static_cast<ObjectImp*>(v2));
     1191    if (!o2->implementsHasInstance()) {
     1192      // According to the spec, only some types of objects "implement" the [[HasInstance]] property.
    12021193      // But we are supposed to throw an exception where the object does not "have" the [[HasInstance]]
    12031194      // property. It seems that all object have the property, but not all implement it, so in this
    12041195      // case we return false (consistent with mozilla)
    1205       return Value(false);
     1196      return jsBoolean(false);
    12061197      //      return throwError(exec, TypeError,
    12071198      //                        "Object does not implement the [[HasInstance]] method." );
    12081199    }
    1209     return o2.hasInstance(exec, v1);
    1210   }
    1211 
    1212   return Value(b);
     1200    return jsBoolean(o2->hasInstance(exec, v1));
     1201  }
     1202
     1203  return jsBoolean(b);
    12131204}
    12141205
     
    12341225
    12351226// ECMA 11.9
    1236 Value EqualNode::evaluate(ExecState *exec)
    1237 {
    1238   Value v1 = expr1->evaluate(exec);
    1239   KJS_CHECKEXCEPTIONVALUE
    1240   Value v2 = expr2->evaluate(exec);
     1227ValueImp *EqualNode::evaluate(ExecState *exec)
     1228{
     1229  ValueImp *v1 = expr1->evaluate(exec);
     1230  KJS_CHECKEXCEPTIONVALUE
     1231  ValueImp *v2 = expr2->evaluate(exec);
    12411232  KJS_CHECKEXCEPTIONVALUE
    12421233
     
    12511242    result = oper == OpStrEq ? eq : !eq;
    12521243  }
    1253   return Value(result);
     1244  return jsBoolean(result);
    12541245}
    12551246
     
    12751266
    12761267// ECMA 11.10
    1277 Value BitOperNode::evaluate(ExecState *exec)
    1278 {
    1279   Value v1 = expr1->evaluate(exec);
    1280   KJS_CHECKEXCEPTIONVALUE
    1281   Value v2 = expr2->evaluate(exec);
    1282   KJS_CHECKEXCEPTIONVALUE
    1283   int i1 = v1.toInt32(exec);
    1284   int i2 = v2.toInt32(exec);
     1268ValueImp *BitOperNode::evaluate(ExecState *exec)
     1269{
     1270  ValueImp *v1 = expr1->evaluate(exec);
     1271  KJS_CHECKEXCEPTIONVALUE
     1272  ValueImp *v2 = expr2->evaluate(exec);
     1273  KJS_CHECKEXCEPTIONVALUE
     1274  int i1 = v1->toInt32(exec);
     1275  int i2 = v2->toInt32(exec);
    12851276  int result;
    12861277  if (oper == OpBitAnd)
     
    12911282    result = i1 | i2;
    12921283
    1293   return Value(result);
     1284  return jsNumber(result);
    12941285}
    12951286
     
    13151306
    13161307// ECMA 11.11
    1317 Value BinaryLogicalNode::evaluate(ExecState *exec)
    1318 {
    1319   Value v1 = expr1->evaluate(exec);
    1320   KJS_CHECKEXCEPTIONVALUE
    1321   bool b1 = v1.toBoolean(exec);
     1308ValueImp *BinaryLogicalNode::evaluate(ExecState *exec)
     1309{
     1310  ValueImp *v1 = expr1->evaluate(exec);
     1311  KJS_CHECKEXCEPTIONVALUE
     1312  bool b1 = v1->toBoolean(exec);
    13221313  if ((!b1 && oper == OpAnd) || (b1 && oper == OpOr))
    13231314    return v1;
    13241315
    1325   Value v2 = expr2->evaluate(exec);
     1316  ValueImp *v2 = expr2->evaluate(exec);
    13261317  KJS_CHECKEXCEPTIONVALUE
    13271318
     
    13541345
    13551346// ECMA 11.12
    1356 Value ConditionalNode::evaluate(ExecState *exec)
    1357 {
    1358   Value v = logical->evaluate(exec);
    1359   KJS_CHECKEXCEPTIONVALUE
    1360   bool b = v.toBoolean(exec);
     1347ValueImp *ConditionalNode::evaluate(ExecState *exec)
     1348{
     1349  ValueImp *v = logical->evaluate(exec);
     1350  KJS_CHECKEXCEPTIONVALUE
     1351  bool b = v->toBoolean(exec);
    13611352
    13621353  if (b)
     
    13901381
    13911382// ECMA 11.13
    1392 Value AssignNode::evaluate(ExecState *exec)
     1383ValueImp *AssignNode::evaluate(ExecState *exec)
    13931384{
    13941385  Reference l = left->evaluateReference(exec);
    13951386  KJS_CHECKEXCEPTIONVALUE
    1396   Value e, v;
     1387  ValueImp *v;
    13971388  if (oper == OpEqual) {
    13981389    v = expr->evaluate(exec);
    13991390    KJS_CHECKEXCEPTIONVALUE
    14001391  } else {
    1401     Value v1 = l.getValue(exec);
    1402     Value v2 = expr->evaluate(exec);
     1392    ValueImp *v1 = l.getValue(exec);
     1393    ValueImp *v2 = expr->evaluate(exec);
    14031394    KJS_CHECKEXCEPTIONVALUE
    14041395    int i1;
     
    14191410      break;
    14201411    case OpLShift:
    1421       i1 = v1.toInt32(exec);
    1422       i2 = v2.toInt32(exec);
    1423       v = Value(i1 << i2);
     1412      i1 = v1->toInt32(exec);
     1413      i2 = v2->toInt32(exec);
     1414      v = jsNumber(i1 << i2);
    14241415      break;
    14251416    case OpRShift:
    1426       i1 = v1.toInt32(exec);
    1427       i2 = v2.toInt32(exec);
    1428       v = Value(i1 >> i2);
     1417      i1 = v1->toInt32(exec);
     1418      i2 = v2->toInt32(exec);
     1419      v = jsNumber(i1 >> i2);
    14291420      break;
    14301421    case OpURShift:
    1431       ui = v1.toUInt32(exec);
    1432       i2 = v2.toInt32(exec);
    1433       v = Value(ui >> i2);
     1422      ui = v1->toUInt32(exec);
     1423      i2 = v2->toInt32(exec);
     1424      v = jsNumber(ui >> i2);
    14341425      break;
    14351426    case OpAndEq:
    1436       i1 = v1.toInt32(exec);
    1437       i2 = v2.toInt32(exec);
    1438       v = Value(i1 & i2);
     1427      i1 = v1->toInt32(exec);
     1428      i2 = v2->toInt32(exec);
     1429      v = jsNumber(i1 & i2);
    14391430      break;
    14401431    case OpXOrEq:
    1441       i1 = v1.toInt32(exec);
    1442       i2 = v2.toInt32(exec);
    1443       v = Value(i1 ^ i2);
     1432      i1 = v1->toInt32(exec);
     1433      i2 = v2->toInt32(exec);
     1434      v = jsNumber(i1 ^ i2);
    14441435      break;
    14451436    case OpOrEq:
    1446       i1 = v1.toInt32(exec);
    1447       i2 = v2.toInt32(exec);
    1448       v = Value(i1 | i2);
     1437      i1 = v1->toInt32(exec);
     1438      i2 = v2->toInt32(exec);
     1439      v = jsNumber(i1 | i2);
    14491440      break;
    14501441    case OpModEq: {
    14511442      bool d1KnownToBeInteger;
    1452       double d1 = v1.toNumber(exec, d1KnownToBeInteger);
     1443      double d1 = v1->toNumber(exec, d1KnownToBeInteger);
    14531444      bool d2KnownToBeInteger;
    1454       double d2 = v2.toNumber(exec, d2KnownToBeInteger);
    1455       v = Value(fmod(d1, d2), d1KnownToBeInteger && d2KnownToBeInteger && d2 != 0);
     1445      double d2 = v2->toNumber(exec, d2KnownToBeInteger);
     1446      v = jsNumber(fmod(d1, d2), d1KnownToBeInteger && d2KnownToBeInteger && d2 != 0);
    14561447    }
    14571448      break;
     
    14881479
    14891480// ECMA 11.14
    1490 Value CommaNode::evaluate(ExecState *exec)
    1491 {
    1492   Value dummy = expr1->evaluate(exec);
    1493   KJS_CHECKEXCEPTIONVALUE
    1494   Value v = expr2->evaluate(exec);
     1481ValueImp *CommaNode::evaluate(ExecState *exec)
     1482{
     1483  expr1->evaluate(exec);
     1484  KJS_CHECKEXCEPTIONVALUE
     1485  ValueImp *v = expr2->evaluate(exec);
    14951486  KJS_CHECKEXCEPTIONVALUE
    14961487
     
    15411532  KJS_ABORTPOINT
    15421533  if (exec->hadException()) {
    1543     Value ex = exec->exception();
     1534    ValueImp *ex = exec->exception();
    15441535    exec->clearException();
    15451536    return Completion(Throw, ex);
     
    15491540    return c;
    15501541 
    1551   Value v = c.value();
     1542  ValueImp *v = c.value();
    15521543 
    15531544  for (StatListNode *n = list; n; n = n->list) {
     
    15581549
    15591550    if (exec->hadException()) {
    1560       Value ex = exec->exception();
     1551      ValueImp *ex = exec->exception();
    15611552      exec->clearException();
    15621553      return Completion(Throw, ex);
     
    15941585
    15951586// ECMA 12.2
    1596 Value AssignExprNode::evaluate(ExecState *exec)
     1587ValueImp *AssignExprNode::evaluate(ExecState *exec)
    15971588{
    15981589  return expr->evaluate(exec);
     
    16221613
    16231614// ECMA 12.2
    1624 Value VarDeclNode::evaluate(ExecState *exec)
    1625 {
    1626   Object variable = exec->context().imp()->variableObject();
    1627 
    1628   Value val;
     1615ValueImp *VarDeclNode::evaluate(ExecState *exec)
     1616{
     1617  ObjectImp *variable = exec->context().imp()->variableObject();
     1618
     1619  ValueImp *val;
    16291620  if (init) {
    16301621      val = init->evaluate(exec);
     
    16331624      // already declared? - check with getDirect so you can override
    16341625      // built-in properties of the global object with var declarations.
    1635       if ( variable.imp()->getDirect(ident) )
    1636           return Value();
     1626      if (variable->getDirect(ident))
     1627          return NULL;
    16371628      val = Undefined();
    16381629  }
     
    16481639  if (varType == VarDeclNode::Constant)
    16491640    flags |= ReadOnly;
    1650   variable.put(exec, ident, val, flags);
    1651 
    1652   return ident.ustring();
     1641  variable->put(exec, ident, val, flags);
     1642
     1643  return jsString(ident.ustring());
    16531644}
    16541645
    16551646void VarDeclNode::processVarDecls(ExecState *exec)
    16561647{
    1657   Object variable = exec->context().imp()->variableObject();
     1648  ObjectImp *variable = exec->context().imp()->variableObject();
    16581649
    16591650  // If a variable by this name already exists, don't clobber it -
    16601651  // it might be a function parameter
    1661   if (!variable.hasProperty(exec, ident)) {
     1652  if (!variable->hasProperty(exec, ident)) {
    16621653    int flags = Internal;
    16631654    if (exec->context().imp()->codeType() != EvalCode)
     
    16651656    if (varType == VarDeclNode::Constant)
    16661657      flags |= ReadOnly;
    1667     variable.put(exec, ident, Undefined(), flags);
     1658    variable->put(exec, ident, Undefined(), flags);
    16681659  }
    16691660}
     
    16951686
    16961687// ECMA 12.2
    1697 Value VarDeclListNode::evaluate(ExecState *exec)
     1688ValueImp *VarDeclListNode::evaluate(ExecState *exec)
    16981689{
    16991690  for (VarDeclListNode *n = this; n; n = n->list) {
     
    18151806  KJS_BREAKPOINT;
    18161807
    1817   Value v = expr->evaluate(exec);
     1808  ValueImp *v = expr->evaluate(exec);
    18181809  KJS_CHECKEXCEPTION
    18191810
     
    18501841  KJS_BREAKPOINT;
    18511842
    1852   Value v = expr->evaluate(exec);
     1843  ValueImp *v = expr->evaluate(exec);
    18531844  KJS_CHECKEXCEPTION
    1854   bool b = v.toBoolean(exec);
     1845  bool b = v->toBoolean(exec);
    18551846
    18561847  // if ... then
     
    18991890  KJS_BREAKPOINT;
    19001891
    1901   Value be, bv;
     1892  ValueImp *bv;
    19021893  Completion c;
    1903   Value value;
    19041894
    19051895  do {
     
    19121902    if (!((c.complType() == Continue) && ls.contains(c.target()))) {
    19131903      if ((c.complType() == Break) && ls.contains(c.target()))
    1914         return Completion(Normal, value);
     1904        return Completion(Normal, NULL);
    19151905      if (c.complType() != Normal)
    19161906        return c;
     
    19181908    bv = expr->evaluate(exec);
    19191909    KJS_CHECKEXCEPTION
    1920   } while (bv.toBoolean(exec));
    1921 
    1922   return Completion(Normal, value);
     1910  } while (bv->toBoolean(exec));
     1911
     1912  return Completion(Normal, NULL);
    19231913}
    19241914
     
    19531943  KJS_BREAKPOINT;
    19541944
    1955   Value be, bv;
     1945  ValueImp *bv;
    19561946  Completion c;
    19571947  bool b(false);
    1958   Value value;
     1948  ValueImp *value = NULL;
    19591949
    19601950  while (1) {
    19611951    bv = expr->evaluate(exec);
    19621952    KJS_CHECKEXCEPTION
    1963     b = bv.toBoolean(exec);
     1953    b = bv->toBoolean(exec);
    19641954
    19651955    // bail out on error
     
    20222012Completion ForNode::execute(ExecState *exec)
    20232013{
    2024   Value v, cval;
     2014  ValueImp *v, *cval = NULL;
    20252015
    20262016  if (expr1) {
     
    20322022      v = expr2->evaluate(exec);
    20332023      KJS_CHECKEXCEPTION
    2034       if (!v.toBoolean(exec))
     2024      if (!v->toBoolean(exec))
    20352025        return Completion(Normal, cval);
    20362026    }
     
    21142104Completion ForInNode::execute(ExecState *exec)
    21152105{
    2116   Value e, retval;
    2117   Object v;
     2106  ValueImp *e;
     2107  ValueImp *retval = NULL;
     2108  ObjectImp *v;
    21182109  Completion c;
    21192110  ReferenceList propList;
     
    21302121  // property list but will throw an exception if you attempt to
    21312122  // access any property.
    2132   if (e.type() == UndefinedType || e.type() == NullType) {
    2133     return Completion(Normal, retval);
     2123  if (e->isUndefinedOrNull()) {
     2124    return Completion(Normal, NULL);
    21342125  }
    21352126
    21362127  KJS_CHECKEXCEPTION
    2137   v = e.toObject(exec);
    2138   propList = v.propList(exec);
     2128  v = e->toObject(exec);
     2129  propList = v->propList(exec);
    21392130
    21402131  ReferenceListIterator propIt = propList.begin();
     
    21422133  while (propIt != propList.end()) {
    21432134    Identifier name = propIt->getPropertyName(exec);
    2144     if (!v.hasProperty(exec,name)) {
     2135    if (!v->hasProperty(exec,name)) {
    21452136      propIt++;
    21462137      continue;
     
    21862177  KJS_BREAKPOINT;
    21872178
    2188   Value dummy;
    2189 
    21902179  if (ident.isEmpty() && !exec->context().imp()->seenLabels()->inIteration())
    21912180    return Completion(Throw,
     
    21952184                      throwError(exec, SyntaxError, "Label %s not found.", ident));
    21962185  else
    2197     return Completion(Continue, dummy, ident);
     2186    return Completion(Continue, NULL, ident);
    21982187}
    21992188
     
    22042193{
    22052194  KJS_BREAKPOINT;
    2206 
    2207   Value dummy;
    22082195
    22092196  if (ident.isEmpty() && !exec->context().imp()->seenLabels()->inIteration() &&
     
    22152202                      throwError(exec, SyntaxError, "Label %s not found.", ident));
    22162203  else
    2217     return Completion(Break, dummy, ident);
     2204    return Completion(Break, NULL, ident);
    22182205}
    22192206
     
    22472234    return Completion(ReturnValue, Undefined());
    22482235
    2249   Value v = value->evaluate(exec);
     2236  ValueImp *v = value->evaluate(exec);
    22502237  KJS_CHECKEXCEPTION
    22512238
     
    22782265  KJS_BREAKPOINT;
    22792266
    2280   Value v = expr->evaluate(exec);
     2267  ValueImp *v = expr->evaluate(exec);
    22812268  KJS_CHECKEXCEPTION
    2282   Object o = v.toObject(exec);
     2269  ObjectImp *o = v->toObject(exec);
    22832270  KJS_CHECKEXCEPTION
    22842271  exec->context().imp()->pushScope(o);
     
    23152302
    23162303// ECMA 12.11
    2317 Value CaseClauseNode::evaluate(ExecState *exec)
    2318 {
    2319   Value v = expr->evaluate(exec);
     2304ValueImp *CaseClauseNode::evaluate(ExecState *exec)
     2305{
     2306  ValueImp *v = expr->evaluate(exec);
    23202307  KJS_CHECKEXCEPTIONVALUE
    23212308
     
    23622349}
    23632350
    2364 Value ClauseListNode::evaluate(ExecState */*exec*/)
     2351ValueImp *ClauseListNode::evaluate(ExecState */*exec*/)
    23652352{
    23662353  /* should never be called */
    23672354  assert(false);
    2368   return Value();
     2355  return NULL;
    23692356}
    23702357
     
    24212408}
    24222409
    2423 Value CaseBlockNode::evaluate(ExecState */*exec*/)
     2410ValueImp *CaseBlockNode::evaluate(ExecState */*exec*/)
    24242411{
    24252412  /* should never be called */
    24262413  assert(false);
    2427   return Value();
     2414  return NULL;
    24282415}
    24292416
    24302417// ECMA 12.11
    2431 Completion CaseBlockNode::evalBlock(ExecState *exec, const Value& input)
    2432 {
    2433   Value v;
     2418Completion CaseBlockNode::evalBlock(ExecState *exec, ValueImp *input)
     2419{
     2420  ValueImp *v;
    24342421  Completion res;
    24352422  ClauseListNode *a = list1, *b = list2;
     
    25252512  KJS_BREAKPOINT;
    25262513
    2527   Value v = expr->evaluate(exec);
     2514  ValueImp *v = expr->evaluate(exec);
    25282515  KJS_CHECKEXCEPTION
    25292516
     
    26012588  KJS_BREAKPOINT;
    26022589
    2603   Value v = expr->evaluate(exec);
     2590  ValueImp *v = expr->evaluate(exec);
    26042591  KJS_CHECKEXCEPTION
    26052592
     
    26312618
    26322619// ECMA 12.14
    2633 Completion CatchNode::execute(ExecState *exec, const Value &arg)
     2620Completion CatchNode::execute(ExecState *exec, ValueImp *arg)
    26342621{
    26352622  /* TODO: correct ? Not part of the spec */
     
    26372624  exec->clearException();
    26382625
    2639   Object obj(new ObjectImp());
    2640   obj.put(exec, ident, arg, DontDelete);
     2626  ObjectImp *obj(new ObjectImp());
     2627  obj->put(exec, ident, arg, DontDelete);
    26412628  exec->context().imp()->pushScope(obj);
    26422629  Completion c = block->execute(exec);
     
    27182705
    27192706  if (!_catch) {
    2720     Value lastException = exec->exception();
     2707    ValueImp *lastException = exec->exception();
    27212708    exec->clearException();
    27222709   
     
    27652752
    27662753// ECMA 13
    2767 Value ParameterNode::evaluate(ExecState */*exec*/)
     2754ValueImp *ParameterNode::evaluate(ExecState */*exec*/)
    27682755{
    27692756  return Undefined();
     
    28082795void FuncDeclNode::processFuncDecl(ExecState *exec)
    28092796{
     2797  ContextImp *context = exec->context().imp();
     2798
    28102799  // TODO: let this be an object with [[Class]] property "Function"
    2811   FunctionImp *fimp = new DeclaredFunctionImp(exec, ident, body, exec->context().imp()->scopeChain());
    2812   Object func(fimp); // protect from GC
    2813 
    2814   //  Value proto = exec->lexicalInterpreter()->builtinObject().construct(exec,List::empty());
    2815   List empty;
    2816   Object proto = exec->lexicalInterpreter()->builtinObject().construct(exec,empty);
    2817   proto.put(exec, constructorPropertyName, func, ReadOnly|DontDelete|DontEnum);
    2818   func.put(exec, prototypePropertyName, proto, Internal|DontDelete);
     2800  FunctionImp *fimp = new DeclaredFunctionImp(exec, ident, body, context->scopeChain());
     2801  ObjectImp *func(fimp); // protect from GC
     2802
     2803  ObjectImp *proto = exec->lexicalInterpreter()->builtinObject()->construct(exec, List::empty());
     2804  proto->put(exec, constructorPropertyName, func, ReadOnly|DontDelete|DontEnum);
     2805  func->put(exec, prototypePropertyName, proto, Internal|DontDelete);
    28192806
    28202807  int plen = 0;
     
    28222809    fimp->addParameter(p->ident());
    28232810
    2824   func.put(exec, lengthPropertyName, Number(plen), ReadOnly|DontDelete|DontEnum);
    2825 
    2826   if (exec->context().imp()->codeType() == EvalCode) {
    2827     // ECMA 10.2.2
    2828     exec->context().imp()->variableObject().put(exec, ident, func, Internal);
    2829   } else {
    2830     exec->context().imp()->variableObject().put(exec, ident, func, Internal | DontDelete);
    2831   }
     2811  func->put(exec, lengthPropertyName, Number(plen), ReadOnly|DontDelete|DontEnum);
     2812
     2813  // ECMA 10.2.2
     2814  context->variableObject()->put(exec, ident, func, Internal | (context->codeType() == EvalCode ? 0 : DontDelete));
    28322815
    28332816  if (body) {
    28342817    // hack the scope so that the function gets put as a property of func, and it's scope
    28352818    // contains the func as well as our current scope
    2836     Object oldVar = exec->context().imp()->variableObject();
    2837     exec->context().imp()->setVariableObject(func);
    2838     exec->context().imp()->pushScope(func);
     2819    ObjectImp *oldVar = context->variableObject();
     2820    context->setVariableObject(func);
     2821    context->pushScope(func);
    28392822    body->processFuncDecl(exec);
    2840     exec->context().imp()->popScope();
    2841     exec->context().imp()->setVariableObject(oldVar);
     2823    context->popScope();
     2824    context->setVariableObject(oldVar);
    28422825  }
    28432826}
     
    28652848
    28662849// ECMA 13
    2867 Value FuncExprNode::evaluate(ExecState *exec)
     2850ValueImp *FuncExprNode::evaluate(ExecState *exec)
    28682851{
    28692852  FunctionImp *fimp = new DeclaredFunctionImp(exec, Identifier::null(), body, exec->context().imp()->scopeChain());
    2870   Value ret(fimp);
    2871   List empty;
    2872   Value proto = exec->lexicalInterpreter()->builtinObject().construct(exec,empty);
     2853  ValueImp *ret(fimp);
     2854  ValueImp *proto = exec->lexicalInterpreter()->builtinObject()->construct(exec, List::empty());
    28732855  fimp->put(exec, prototypePropertyName, proto, Internal|DontDelete);
    28742856
     
    29332915    // The spec says to return c2 here, but it seems that mozilla returns c1 if
    29342916    // c2 doesn't have a value
    2935     if (!c2.value().isNull())
     2917    if (c2.value())
    29362918      c1 = c2;
    29372919  }
  • trunk/JavaScriptCore/kjs/nodes.h

    r9768 r10084  
    8383    KJS_FAST_ALLOCATED;
    8484
    85     virtual Value evaluate(ExecState *exec) = 0;
     85    virtual ValueImp *evaluate(ExecState *exec) = 0;
    8686    virtual Reference evaluateReference(ExecState *exec);
    8787    UString toString() const;
     
    104104#endif
    105105  protected:
    106     Value throwError(ExecState *exec, ErrorType e, const char *msg);
    107     Value throwError(ExecState *exec, ErrorType e, const char *msg, Value v, Node *expr);
    108     Value throwError(ExecState *exec, ErrorType e, const char *msg, Identifier label);
     106    ValueImp *throwError(ExecState *exec, ErrorType e, const char *msg);
     107    ValueImp *throwError(ExecState *exec, ErrorType e, const char *msg, ValueImp *v, Node *expr);
     108    ValueImp *throwError(ExecState *exec, ErrorType e, const char *msg, Identifier label);
    109109    void setExceptionDetailsIfNeeded(ExecState *exec);
    110110    int line;
     
    137137    LabelStack ls;
    138138  private:
    139     Value evaluate(ExecState */*exec*/) { return Undefined(); }
     139    ValueImp *evaluate(ExecState */*exec*/) { return Undefined(); }
    140140    int l0, l1;
    141141    int sid;
     
    146146  public:
    147147    NullNode() {}
    148     Value evaluate(ExecState *exec);
     148    ValueImp *evaluate(ExecState *exec);
    149149    virtual void streamTo(SourceStream &s) const;
    150150  };
     
    153153  public:
    154154    BooleanNode(bool v) : value(v) {}
    155     Value evaluate(ExecState *exec);
     155    ValueImp *evaluate(ExecState *exec);
    156156    virtual void streamTo(SourceStream &s) const;
    157157  private:
     
    162162  public:
    163163    NumberNode(double v) : value(v) { }
    164     Value evaluate(ExecState *exec);
     164    ValueImp *evaluate(ExecState *exec);
    165165    virtual void streamTo(SourceStream &s) const;
    166166  private:
     
    171171  public:
    172172    StringNode(const UString *v) { value = *v; }
    173     Value evaluate(ExecState *exec);
     173    ValueImp *evaluate(ExecState *exec);
    174174    virtual void streamTo(SourceStream &s) const;
    175175  private:
     
    181181    RegExpNode(const UString &p, const UString &f)
    182182      : pattern(p), flags(f) { }
    183     Value evaluate(ExecState *exec);
     183    ValueImp *evaluate(ExecState *exec);
    184184    virtual void streamTo(SourceStream &s) const;
    185185  private:
     
    190190  public:
    191191    ThisNode() {}
    192     Value evaluate(ExecState *exec);
     192    ValueImp *evaluate(ExecState *exec);
    193193    virtual void streamTo(SourceStream &s) const;
    194194  };
     
    197197  public:
    198198    ResolveNode(const Identifier &s) : ident(s) { }
    199     Value evaluate(ExecState *exec);
     199    ValueImp *evaluate(ExecState *exec);
    200200    virtual Reference evaluateReference(ExecState *exec);
    201201    virtual void streamTo(SourceStream &s) const;
     
    209209    virtual void ref();
    210210    virtual bool deref();
    211     virtual Value evaluate(ExecState *exec);
     211    virtual ValueImp *evaluate(ExecState *exec);
    212212    virtual Reference evaluateReference(ExecState *exec);
    213213    virtual void streamTo(SourceStream &s) const { group->streamTo(s); }
     
    224224    virtual void ref();
    225225    virtual bool deref();
    226     Value evaluate(ExecState *exec);
     226    ValueImp *evaluate(ExecState *exec);
    227227    virtual void streamTo(SourceStream &s) const;
    228228  private:
     
    242242    virtual void ref();
    243243    virtual bool deref();
    244     Value evaluate(ExecState *exec);
     244    ValueImp *evaluate(ExecState *exec);
    245245    virtual void streamTo(SourceStream &s) const;
    246246  private:
     
    259259    virtual void ref();
    260260    virtual bool deref();
    261     Value evaluate(ExecState *exec);
     261    ValueImp *evaluate(ExecState *exec);
    262262    virtual void streamTo(SourceStream &s) const;
    263263  private:
     
    274274    virtual void ref();
    275275    virtual bool deref();
    276     Value evaluate(ExecState *exec);
     276    ValueImp *evaluate(ExecState *exec);
    277277    virtual void streamTo(SourceStream &s) const;
    278278  private:
     
    284284    PropertyNode(double d) : numeric(d) { }
    285285    PropertyNode(const Identifier &s) : str(s) { }
    286     Value evaluate(ExecState *exec);
     286    ValueImp *evaluate(ExecState *exec);
    287287    virtual void streamTo(SourceStream &s) const;
    288288  private:
     
    296296    virtual void ref();
    297297    virtual bool deref();
    298     Value evaluate(ExecState *exec);
     298    ValueImp *evaluate(ExecState *exec);
    299299    virtual Reference evaluateReference(ExecState *exec);
    300300    virtual void streamTo(SourceStream &s) const;
     
    309309    virtual void ref();
    310310    virtual bool deref();
    311     Value evaluate(ExecState *exec);
     311    ValueImp *evaluate(ExecState *exec);
    312312    virtual Reference evaluateReference(ExecState *exec);
    313313    virtual void streamTo(SourceStream &s) const;
     
    325325    virtual void ref();
    326326    virtual bool deref();
    327     Value evaluate(ExecState *exec);
     327    ValueImp *evaluate(ExecState *exec);
    328328    List evaluateList(ExecState *exec);
    329329    virtual void streamTo(SourceStream &s) const;
     
    341341    virtual void ref();
    342342    virtual bool deref();
    343     Value evaluate(ExecState *exec);
     343    ValueImp *evaluate(ExecState *exec);
    344344    List evaluateList(ExecState *exec);
    345345    virtual void streamTo(SourceStream &s) const;
     
    354354    virtual void ref();
    355355    virtual bool deref();
    356     Value evaluate(ExecState *exec);
     356    ValueImp *evaluate(ExecState *exec);
    357357    virtual void streamTo(SourceStream &s) const;
    358358  private:
     
    366366    virtual void ref();
    367367    virtual bool deref();
    368     Value evaluate(ExecState *exec);
     368    ValueImp *evaluate(ExecState *exec);
    369369    virtual void streamTo(SourceStream &s) const;
    370370  private:
     
    378378    virtual void ref();
    379379    virtual bool deref();
    380     Value evaluate(ExecState *exec);
     380    ValueImp *evaluate(ExecState *exec);
    381381    virtual void streamTo(SourceStream &s) const;
    382382  private:
     
    390390    virtual void ref();
    391391    virtual bool deref();
    392     Value evaluate(ExecState *exec);
     392    ValueImp *evaluate(ExecState *exec);
    393393    virtual void streamTo(SourceStream &s) const;
    394394  private:
     
    401401    virtual void ref();
    402402    virtual bool deref();
    403     Value evaluate(ExecState *exec);
     403    ValueImp *evaluate(ExecState *exec);
    404404    virtual void streamTo(SourceStream &s) const;
    405405  private:
     
    412412    virtual void ref();
    413413    virtual bool deref();
    414     Value evaluate(ExecState *exec);
     414    ValueImp *evaluate(ExecState *exec);
    415415    virtual void streamTo(SourceStream &s) const;
    416416  private:
     
    423423    virtual void ref();
    424424    virtual bool deref();
    425     Value evaluate(ExecState *exec);
     425    ValueImp *evaluate(ExecState *exec);
    426426    virtual void streamTo(SourceStream &s) const;
    427427  private:
     
    435435    virtual void ref();
    436436    virtual bool deref();
    437     Value evaluate(ExecState *exec);
     437    ValueImp *evaluate(ExecState *exec);
    438438    virtual void streamTo(SourceStream &s) const;
    439439  private:
     
    446446    virtual void ref();
    447447    virtual bool deref();
    448     Value evaluate(ExecState *exec);
     448    ValueImp *evaluate(ExecState *exec);
    449449    virtual void streamTo(SourceStream &s) const;
    450450  private:
     
    457457    virtual void ref();
    458458    virtual bool deref();
    459     Value evaluate(ExecState *exec);
     459    ValueImp *evaluate(ExecState *exec);
    460460    virtual void streamTo(SourceStream &s) const;
    461461  private:
     
    468468    virtual void ref();
    469469    virtual bool deref();
    470     Value evaluate(ExecState *exec);
     470    ValueImp *evaluate(ExecState *exec);
    471471    virtual void streamTo(SourceStream &s) const;
    472472  private:
     
    479479    virtual void ref();
    480480    virtual bool deref();
    481     Value evaluate(ExecState *exec);
     481    ValueImp *evaluate(ExecState *exec);
    482482    virtual void streamTo(SourceStream &s) const;
    483483  private:
     
    491491    virtual void ref();
    492492    virtual bool deref();
    493     Value evaluate(ExecState *exec);
     493    ValueImp *evaluate(ExecState *exec);
    494494    virtual void streamTo(SourceStream &s) const;
    495495  private:
     
    504504    virtual void ref();
    505505    virtual bool deref();
    506     Value evaluate(ExecState *exec);
     506    ValueImp *evaluate(ExecState *exec);
    507507    virtual void streamTo(SourceStream &s) const;
    508508  private:
     
    517517    virtual void ref();
    518518    virtual bool deref();
    519     Value evaluate(ExecState *exec);
     519    ValueImp *evaluate(ExecState *exec);
    520520    virtual void streamTo(SourceStream &s) const;
    521521  private:
     
    530530    virtual void ref();
    531531    virtual bool deref();
    532     Value evaluate(ExecState *exec);
     532    ValueImp *evaluate(ExecState *exec);
    533533    virtual void streamTo(SourceStream &s) const;
    534534  private:
     
    543543    virtual void ref();
    544544    virtual bool deref();
    545     Value evaluate(ExecState *exec);
     545    ValueImp *evaluate(ExecState *exec);
    546546    virtual void streamTo(SourceStream &s) const;
    547547  private:
     
    559559    virtual void ref();
    560560    virtual bool deref();
    561     Value evaluate(ExecState *exec);
     561    ValueImp *evaluate(ExecState *exec);
    562562    virtual void streamTo(SourceStream &s) const;
    563563  private:
     
    575575    virtual void ref();
    576576    virtual bool deref();
    577     Value evaluate(ExecState *exec);
     577    ValueImp *evaluate(ExecState *exec);
    578578    virtual void streamTo(SourceStream &s) const;
    579579  private:
     
    586586    virtual void ref();
    587587    virtual bool deref();
    588     Value evaluate(ExecState *exec);
     588    ValueImp *evaluate(ExecState *exec);
    589589    virtual void streamTo(SourceStream &s) const;
    590590  private:
     
    599599    virtual void ref();
    600600    virtual bool deref();
    601     Value evaluate(ExecState *exec);
     601    ValueImp *evaluate(ExecState *exec);
    602602    virtual void streamTo(SourceStream &s) const;
    603603  private:
     
    626626    virtual void ref();
    627627    virtual bool deref();
    628     Value evaluate(ExecState *exec);
     628    ValueImp *evaluate(ExecState *exec);
    629629    virtual void streamTo(SourceStream &s) const;
    630630  private:
     
    638638    virtual void ref();
    639639    virtual bool deref();
    640     Value evaluate(ExecState *exec);
     640    ValueImp *evaluate(ExecState *exec);
    641641    virtual void processVarDecls(ExecState *exec);
    642642    virtual void streamTo(SourceStream &s) const;
     
    655655    virtual void ref();
    656656    virtual bool deref();
    657     Value evaluate(ExecState *exec);
     657    ValueImp *evaluate(ExecState *exec);
    658658    virtual void processVarDecls(ExecState *exec);
    659659    virtual void streamTo(SourceStream &s) const;
     
    831831    virtual void ref();
    832832    virtual bool deref();
    833     Value evaluate(ExecState *exec);
     833    ValueImp *evaluate(ExecState *exec);
    834834    Completion evalStatements(ExecState *exec);
    835835    virtual void processVarDecls(ExecState *exec);
     
    848848    virtual void ref();
    849849    virtual bool deref();
    850     Value evaluate(ExecState *exec);
     850    ValueImp *evaluate(ExecState *exec);
    851851    CaseClauseNode *clause() const { return cl; }
    852852    ClauseListNode *next() const { return nx; }
     
    864864    virtual void ref();
    865865    virtual bool deref();
    866     Value evaluate(ExecState *exec);
    867     Completion evalBlock(ExecState *exec, const Value& input);
     866    ValueImp *evaluate(ExecState *exec);
     867    Completion evalBlock(ExecState *exec, ValueImp *input);
    868868    virtual void processVarDecls(ExecState *exec);
    869869    virtual void streamTo(SourceStream &s) const;
     
    917917    virtual bool deref();
    918918    virtual Completion execute(ExecState *exec);
    919     Completion execute(ExecState *exec, const Value &arg);
     919    Completion execute(ExecState *exec, ValueImp *arg);
    920920    virtual void processVarDecls(ExecState *exec);
    921921    virtual void streamTo(SourceStream &s) const;
     
    964964    virtual void ref();
    965965    virtual bool deref();
    966     Value evaluate(ExecState *exec);
     966    ValueImp *evaluate(ExecState *exec);
    967967    Identifier ident() { return id; }
    968968    ParameterNode *nextParam() { return next; }
     
    10071007    virtual void ref();
    10081008    virtual bool deref();
    1009     Value evaluate(ExecState *exec);
     1009    ValueImp *evaluate(ExecState *exec);
    10101010    virtual void streamTo(SourceStream &s) const;
    10111011  private:
  • trunk/JavaScriptCore/kjs/number_object.cpp

    r10076 r10084  
    5353  : NumberInstanceImp(objProto)
    5454{
    55   Value protect(this);
    56   setInternalValue(NumberImp::zero());
     55  setInternalValue(jsZero());
    5756
    5857  // The constructor will be added later, after NumberObjectImp has been constructed
     
    7372  : InternalFunctionImp(funcProto), id(i)
    7473{
    75   Value protect(this);
    7674  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
    7775}
     
    128126
    129127// ECMA 15.7.4.2 - 15.7.4.7
    130 Value NumberProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &args)
    131 {
    132   Value result;
    133 
     128ValueImp *NumberProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
     129{
    134130  // no generic function. "this" has to be a Number object
    135   if (!thisObj.inherits(&NumberInstanceImp::info)) {
    136     Object err = Error::create(exec,TypeError);
     131  if (!thisObj->inherits(&NumberInstanceImp::info)) {
     132    ObjectImp *err = Error::create(exec,TypeError);
    137133    exec->setException(err);
    138134    return err;
    139135  }
    140136
    141   Value v = thisObj.internalValue();
     137  ValueImp *v = thisObj->internalValue();
    142138  switch (id) {
    143139  case ToString: {
    144140    double dradix = 10;
    145141    if (!args.isEmpty())
    146       dradix = args[0].toInteger(exec);
     142      dradix = args[0]->toInteger(exec);
    147143    if (dradix >= 2 && dradix <= 36 && dradix != 10) { // false for NaN
    148144      int radix = static_cast<int>(dradix);
    149       unsigned i = v.toUInt32(exec);
     145      unsigned i = v->toUInt32(exec);
    150146      char s[33];
    151147      char *p = s + sizeof(s);
     
    155151        i /= radix;
    156152      } while (i);
    157       result = String(p);
     153      return String(p);
    158154    } else
    159       result = String(v.toString(exec));
    160     break;
     155      return String(v->toString(exec));
    161156  }
    162157  case ToLocaleString: /* TODO */
    163     result = String(v.toString(exec));
    164     break;
     158    return String(v->toString(exec));
    165159  case ValueOf:
    166     result = Number(v.toNumber(exec));
    167     break;
     160    return Number(v->toNumber(exec));
    168161  case ToFixed:
    169162  {
    170       Value fractionDigits = args[0];
    171       double df = fractionDigits.toInteger(exec);
     163      ValueImp *fractionDigits = args[0];
     164      double df = fractionDigits->toInteger(exec);
    172165      if (!(df >= 0 && df <= 20)) { // true for NaN
    173           Object err = Error::create(exec, RangeError,
     166          ObjectImp *err = Error::create(exec, RangeError,
    174167                                     "toFixed() digits argument must be between 0 and 20");
    175168         
     
    179172      int f = (int)df;
    180173     
    181       double x = v.toNumber(exec);
     174      double x = v->toNumber(exec);
    182175      if (isNaN(x))
    183176          return String("NaN");
     
    213206  }
    214207  case ToExponential: {
    215       double x = v.toNumber(exec);
     208      double x = v->toNumber(exec);
    216209     
    217210      if (isNaN(x) || isInf(x))
    218211          return String(UString::from(x));
    219212     
    220       Value fractionDigits = args[0];
    221       double df = fractionDigits.toInteger(exec);
     213      ValueImp *fractionDigits = args[0];
     214      double df = fractionDigits->toInteger(exec);
    222215      if (!(df >= 0 && df <= 20)) { // true for NaN
    223           Object err = Error::create(exec, RangeError,
     216          ObjectImp *err = Error::create(exec, RangeError,
    224217                                     "toExponential() argument must between 0 and 20");
    225218          exec->setException(err);
     
    229222     
    230223      int decimalAdjust = 0;
    231       if (!fractionDigits.isA(UndefinedType)) {
     224      if (!fractionDigits->isUndefined()) {
    232225          double logx = floor(log10(x));
    233226          x /= pow(10,logx);
     
    264257          buf[i++] = result[0];
    265258         
    266           if (fractionDigits.isA(UndefinedType))
     259          if (fractionDigits->isUndefined())
    267260              f = length-1;
    268261         
     
    311304      UString m;
    312305     
    313       double dp = args[0].toInteger(exec);
    314       double x = v.toNumber(exec);
     306      double dp = args[0]->toInteger(exec);
     307      double x = v->toNumber(exec);
    315308      if (isNaN(dp) || isNaN(x) || isInf(x))
    316           return String(v.toString(exec));
     309          return String(v->toString(exec));
    317310     
    318311      UString s = "";
     
    323316     
    324317      if (dp < 1 || dp > 21) {
    325           Object err = Error::create(exec, RangeError,
     318          ObjectImp *err = Error::create(exec, RangeError,
    326319                                     "toPrecision() argument must be between 1 and 21");
    327320          exec->setException(err);
     
    373366     
    374367 }
    375   return result;
     368  return NULL;
    376369}
    377370
     
    395388  : InternalFunctionImp(funcProto)
    396389{
    397   Value protect(this);
    398390  // Number.Prototype
    399391  putDirect(prototypePropertyName, numberProto,DontEnum|DontDelete|ReadOnly);
    400392
    401393  // no. of arguments for constructor
    402   putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum);
     394  putDirect(lengthPropertyName, jsOne(), ReadOnly|DontDelete|DontEnum);
    403395}
    404396
     
    408400}
    409401
    410 Value NumberObjectImp::getValueProperty(ExecState *, int token) const
     402ValueImp *NumberObjectImp::getValueProperty(ExecState *, int token) const
    411403{
    412404  // ECMA 15.7.3
    413405  switch(token) {
    414406  case NaNValue:
    415     return Number(NaN);
     407    return jsNaN();
    416408  case NegInfinity:
    417409    return Number(-Inf);
     
    433425
    434426// ECMA 15.7.1
    435 Object NumberObjectImp::construct(ExecState *exec, const List &args)
    436 {
    437   ObjectImp *proto = exec->lexicalInterpreter()->builtinNumberPrototype().imp();
    438   Object obj(new NumberInstanceImp(proto));
    439 
    440   Number n;
     427ObjectImp *NumberObjectImp::construct(ExecState *exec, const List &args)
     428{
     429  ObjectImp *proto = exec->lexicalInterpreter()->builtinNumberPrototype();
     430  ObjectImp *obj(new NumberInstanceImp(proto));
     431
     432  double n;
    441433  if (args.isEmpty())
    442     n = Number(0);
     434    n = 0;
    443435  else
    444     n = args[0].toNumber(exec);
    445 
    446   obj.setInternalValue(n);
     436    n = args[0]->toNumber(exec);
     437
     438  obj->setInternalValue(jsNumber(n));
    447439
    448440  return obj;
     
    455447
    456448// ECMA 15.7.2
    457 Value NumberObjectImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
     449ValueImp *NumberObjectImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
    458450{
    459451  if (args.isEmpty())
    460452    return Number(0);
    461453  else
    462     return Number(args[0].toNumber(exec));
    463 }
     454    return Number(args[0]->toNumber(exec));
     455}
  • trunk/JavaScriptCore/kjs/number_object.h

    r10076 r10084  
    6161
    6262    virtual bool implementsCall() const;
    63     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     63    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    6464
    6565    enum { ToString, ToLocaleString, ValueOf, ToFixed, ToExponential, ToPrecision };
     
    8080
    8181    virtual bool implementsConstruct() const;
    82     virtual Object construct(ExecState *exec, const List &args);
     82    virtual ObjectImp *construct(ExecState *exec, const List &args);
    8383
    8484    virtual bool implementsCall() const;
    85     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     85    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    8686
    8787    bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
    88     Value getValueProperty(ExecState *exec, int token) const;
     88    ValueImp *getValueProperty(ExecState *exec, int token) const;
     89
    8990    virtual const ClassInfo *classInfo() const { return &info; }
    9091    static const ClassInfo info;
     
    9293
    9394    Completion execute(const List &);
    94     Object construct(const List &);
     95    ObjectImp *construct(const List &);
    9596  };
    9697
  • trunk/JavaScriptCore/kjs/object.cpp

    r10076 r10084  
    4141
    4242#ifndef NDEBUG
    43 #define JAVASCRIPT_CALL_TRACING Yes
    44 #endif
    45 
    46 #ifdef JAVASCRIPT_CALL_TRACING
     43//#define JAVASCRIPT_CALL_TRACING 1
     44#endif
     45
     46#if JAVASCRIPT_CALL_TRACING
    4747static bool _traceJavaScript = false;
    4848
     
    6464// ------------------------------ Object ---------------------------------------
    6565
    66 Object Object::dynamicCast(const Value &v)
    67 {
    68   if (v.isNull() || v.type() != ObjectType)
    69     return Object(0);
    70 
    71   return Object(static_cast<ObjectImp*>(v.imp()));
    72 }
    73 
    74 
    75 Value Object::call(ExecState *exec, Object &thisObj, const List &args)
    76 {
     66ValueImp *ObjectImp::call(ExecState *exec, ObjectImp *thisObj, const List &args)
     67{
     68  assert(implementsCall());
     69
    7770#if KJS_MAX_STACK > 0
    7871  static int depth = 0; // sum of all concurrent interpreters
    7972
    80 #ifdef JAVASCRIPT_CALL_TRACING
     73#if JAVASCRIPT_CALL_TRACING
    8174    static bool tracing = false;
    8275    if (traceJavaScript() && !tracing) {
     
    8881            for (int i = 0; i < depth; i++)
    8982                putchar (' ');
    90             printf ("*** arg[%d] = %s\n", j, args[j].toString(exec).ascii());
     83            printf ("*** arg[%d] = %s\n", j, args[j]->toString(exec).ascii());
    9184        }
    9285        tracing = false;
     
    9689  if (++depth > KJS_MAX_STACK) {
    9790    --depth;
    98     Object err = Error::create(exec, RangeError,
     91    ObjectImp *err = Error::create(exec, RangeError,
    9992                               "Maximum call stack size exceeded.");
    10093    exec->setException(err);
     
    10396#endif
    10497
    105   Value ret = imp()->call(exec,thisObj,args);
     98  ValueImp *ret = callAsFunction(exec,thisObj,args);
    10699
    107100#if KJS_MAX_STACK > 0
     
    109102#endif
    110103
    111 #ifdef JAVASCRIPT_CALL_TRACING
     104#if JAVASCRIPT_CALL_TRACING
    112105    if (traceJavaScript() && !tracing) {
    113106        tracing = true;
    114107        for (int i = 0; i < depth; i++)
    115108            putchar (' ');
    116         printf ("*** returning:  %s\n", ret.toString(exec).ascii());
     109        printf ("*** returning:  %s\n", ret->toString(exec).ascii());
    117110        tracing = false;
    118111    }
     
    124117// ------------------------------ ObjectImp ------------------------------------
    125118
    126 ObjectImp::ObjectImp(const Object &proto)
    127   : _proto(static_cast<ObjectImp*>(proto.imp())), _internalValue(0L)
    128 {
    129   //fprintf(stderr,"ObjectImp::ObjectImp %p\n",(void*)this);
    130 }
    131 
    132 ObjectImp::ObjectImp(ObjectImp *proto)
    133   : _proto(proto), _internalValue(0L)
    134 {
    135   //fprintf(stderr,"ObjectImp::ObjectImp %p\n",(void*)this);
    136 }
    137 
    138 ObjectImp::ObjectImp()
    139 {
    140   //fprintf(stderr,"ObjectImp::ObjectImp %p\n",(void*)this);
    141   _proto = NullImp::staticNull;
    142   _internalValue = 0L;
    143 }
    144 
    145 ObjectImp::~ObjectImp()
    146 {
    147   //fprintf(stderr,"ObjectImp::~ObjectImp %p\n",(void*)this);
    148 }
    149 
    150119void ObjectImp::mark()
    151120{
    152   //fprintf(stderr,"ObjectImp::mark() %p\n",(void*)this);
    153   ValueImp::mark();
    154 
    155   if (_proto && !_proto->marked())
    156     _proto->mark();
     121  AllocatedValueImp::mark();
     122
     123  ValueImp *proto = _proto;
     124  if (!proto->marked())
     125    proto->mark();
    157126
    158127  _prop.mark();
     
    164133}
    165134
     135Type ObjectImp::type() const
     136{
     137  return ObjectType;
     138}
     139
    166140const ClassInfo *ObjectImp::classInfo() const
    167141{
    168142  return 0;
    169 }
    170 
    171 bool ObjectImp::inherits(const ClassInfo *info) const
    172 {
    173   if (!info)
    174     return false;
    175 
    176   const ClassInfo *ci = classInfo();
    177   if (!ci)
    178     return false;
    179 
    180   while (ci && ci != info)
    181     ci = ci->parentClass;
    182 
    183   return (ci == info);
    184 }
    185 
    186 Type ObjectImp::type() const
    187 {
    188   return ObjectType;
    189 }
    190 
    191 Value ObjectImp::prototype() const
    192 {
    193   return Value(_proto);
    194 }
    195 
    196 void ObjectImp::setPrototype(const Value &proto)
    197 {
    198   _proto = proto.imp();
    199143}
    200144
     
    207151}
    208152
    209 Value ObjectImp::get(ExecState *exec, const Identifier &propertyName) const
     153ValueImp *ObjectImp::get(ExecState *exec, const Identifier &propertyName) const
    210154{
    211155  PropertySlot slot;
     
    217161}
    218162
    219 Value ObjectImp::get(ExecState *exec, unsigned propertyName) const
     163ValueImp *ObjectImp::get(ExecState *exec, unsigned propertyName) const
    220164{
    221165  PropertySlot slot;
     
    226170}
    227171
    228 bool ObjectImp::getProperty(ExecState *exec, const Identifier& propertyName, Value& result) const
     172bool ObjectImp::getProperty(ExecState *exec, const Identifier& propertyName, ValueImp*& result) const
    229173{
    230174  PropertySlot slot;
     
    237181}
    238182
    239 bool ObjectImp::getProperty(ExecState *exec, unsigned propertyName, Value& result) const
     183bool ObjectImp::getProperty(ExecState *exec, unsigned propertyName, ValueImp*& result) const
    240184{
    241185  PropertySlot slot;
     
    257201   
    258202    ValueImp *proto = imp->_proto;
    259     if (proto->dispatchType() != ObjectType)
     203    if (!proto->isObject())
    260204      break;
    261205   
     
    272216
    273217// ECMA 8.6.2.2
    274 void ObjectImp::put(ExecState *exec, const Identifier &propertyName,
    275                      const Value &value, int attr)
    276 {
    277   assert(!value.isNull());
     218void ObjectImp::put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr)
     219{
     220  assert(value);
    278221
    279222  // non-standard netscape extension
     
    295238  }
    296239
    297   _prop.put(propertyName,value.imp(),attr);
     240  _prop.put(propertyName,value,attr);
    298241}
    299242
    300243void ObjectImp::put(ExecState *exec, unsigned propertyName,
    301                      const Value &value, int attr)
     244                     ValueImp *value, int attr)
    302245{
    303246  put(exec, Identifier::from(propertyName), value, attr);
     
    336279
    337280bool ObjectImp::hasOwnProperty(ExecState *exec, const Identifier &propertyName) const
     281{
     282  PropertySlot slot;
     283  return const_cast<ObjectImp *>(this)->getOwnPropertySlot(exec, propertyName, slot);
     284}
     285
     286bool ObjectImp::hasOwnProperty(ExecState *exec, unsigned propertyName) const
    338287{
    339288  PropertySlot slot;
     
    371320
    372321// ECMA 8.6.2.6
    373 Value ObjectImp::defaultValue(ExecState *exec, Type hint) const
     322ValueImp *ObjectImp::defaultValue(ExecState *exec, Type hint) const
    374323{
    375324  if (hint != StringType && hint != NumberType) {
    376325    /* Prefer String for Date objects */
    377     if (_proto == exec->lexicalInterpreter()->builtinDatePrototype().imp())
     326    if (_proto == exec->lexicalInterpreter()->builtinDatePrototype())
    378327      hint = StringType;
    379328    else
     
    381330  }
    382331
    383   Value v;
     332  ValueImp *v;
    384333  if (hint == StringType)
    385334    v = get(exec,toStringPropertyName);
     
    387336    v = get(exec,valueOfPropertyName);
    388337
    389   if (v.type() == ObjectType) {
    390     Object o = Object(static_cast<ObjectImp*>(v.imp()));
    391     if (o.implementsCall()) { // spec says "not primitive type" but ...
    392       Object thisObj = Object(const_cast<ObjectImp*>(this));
    393       Value def = o.call(exec,thisObj,List::empty());
    394       Type defType = def.type();
     338  if (v->isObject()) {
     339    ObjectImp *o = static_cast<ObjectImp*>(v);
     340    if (o->implementsCall()) { // spec says "not primitive type" but ...
     341      ObjectImp *thisObj = const_cast<ObjectImp*>(this);
     342      ValueImp *def = o->call(exec,thisObj,List::empty());
     343      Type defType = def->type();
    395344      if (defType == UnspecifiedType || defType == UndefinedType ||
    396345          defType == NullType || defType == BooleanType ||
     
    406355    v = get(exec,toStringPropertyName);
    407356
    408   if (v.type() == ObjectType) {
    409     Object o = Object(static_cast<ObjectImp*>(v.imp()));
    410     if (o.implementsCall()) { // spec says "not primitive type" but ...
    411       Object thisObj = Object(const_cast<ObjectImp*>(this));
    412       Value def = o.call(exec,thisObj,List::empty());
    413       Type defType = def.type();
     357  if (v->isObject()) {
     358    ObjectImp *o = static_cast<ObjectImp*>(v);
     359    if (o->implementsCall()) { // spec says "not primitive type" but ...
     360      ObjectImp *thisObj = const_cast<ObjectImp*>(this);
     361      ValueImp *def = o->call(exec,thisObj,List::empty());
     362      Type defType = def->type();
    414363      if (defType == UnspecifiedType || defType == UndefinedType ||
    415364          defType == NullType || defType == BooleanType ||
     
    423372    return exec->exception();
    424373
    425   Object err = Error::create(exec, TypeError, I18N_NOOP("No default value"));
     374  ObjectImp *err = Error::create(exec, TypeError, I18N_NOOP("No default value"));
    426375  exec->setException(err);
    427376  return err;
    428377}
    429378
    430 const HashEntry* ObjectImp::findPropertyHashEntry( const Identifier& propertyName ) const
    431 {
    432   const ClassInfo *info = classInfo();
    433   while (info) {
    434     if (info->propHashTable) {
    435       const HashEntry *e = Lookup::findEntry(info->propHashTable, propertyName);
    436       if (e)
     379const HashEntry* ObjectImp::findPropertyHashEntry(const Identifier& propertyName) const
     380{
     381  for (const ClassInfo *info = classInfo(); info; info = info->parentClass) {
     382    if (const HashTable *propHashTable = info->propHashTable) {
     383      if (const HashEntry *e = Lookup::findEntry(propHashTable, propertyName))
    437384        return e;
    438385    }
    439     info = info->parentClass;
    440   }
    441   return 0L;
     386  }
     387  return 0;
    442388}
    443389
     
    447393}
    448394
    449 Object ObjectImp::construct(ExecState */*exec*/, const List &/*args*/)
     395ObjectImp *ObjectImp::construct(ExecState */*exec*/, const List &/*args*/)
    450396{
    451397  assert(false);
    452   return Object(0);
    453 }
    454 
    455 Object ObjectImp::construct(ExecState *exec, const List &args, const UString &/*sourceURL*/, int /*lineNumber*/)
     398  return NULL;
     399}
     400
     401ObjectImp *ObjectImp::construct(ExecState *exec, const List &args, const UString &/*sourceURL*/, int /*lineNumber*/)
    456402{
    457403  return construct(exec, args);
     
    463409}
    464410
    465 Value ObjectImp::call(ExecState */*exec*/, Object &/*thisObj*/, const List &/*args*/)
     411ValueImp *ObjectImp::callAsFunction(ExecState */*exec*/, ObjectImp */*thisObj*/, const List &/*args*/)
    466412{
    467413  assert(false);
    468   return Object(0);
     414  return NULL;
    469415}
    470416
     
    474420}
    475421
    476 Boolean ObjectImp::hasInstance(ExecState */*exec*/, const Value &/*value*/)
     422bool ObjectImp::hasInstance(ExecState */*exec*/, ValueImp */*value*/)
    477423{
    478424  assert(false);
    479   return Boolean(false);
     425  return false;
    480426}
    481427
     
    483429{
    484430  ReferenceList list;
    485   if (_proto && _proto->dispatchType() == ObjectType && recursive)
     431  if (_proto->isObject() && recursive)
    486432    list = static_cast<ObjectImp*>(_proto)->propList(exec,recursive);
    487433
    488   _prop.addEnumerablesToReferenceList(list, Object(this));
     434  _prop.addEnumerablesToReferenceList(list, this);
    489435
    490436  // Add properties from the static hashtable of properties
     
    505451}
    506452
    507 Value ObjectImp::internalValue() const
    508 {
    509   return Value(_internalValue);
    510 }
    511 
    512 void ObjectImp::setInternalValue(const Value &v)
    513 {
    514   _internalValue = v.imp();
    515 }
    516 
    517 void ObjectImp::setInternalValue(ValueImp *v)
    518 {
    519   _internalValue = v;
    520 }
    521 
    522 Value ObjectImp::toPrimitive(ExecState *exec, Type preferredType) const
     453ValueImp *ObjectImp::toPrimitive(ExecState *exec, Type preferredType) const
    523454{
    524455  return defaultValue(exec,preferredType);
     
    532463double ObjectImp::toNumber(ExecState *exec) const
    533464{
    534   Value prim = toPrimitive(exec,NumberType);
     465  ValueImp *prim = toPrimitive(exec,NumberType);
    535466  if (exec->hadException()) // should be picked up soon in nodes.cpp
    536467    return 0.0;
    537   return prim.toNumber(exec);
     468  return prim->toNumber(exec);
    538469}
    539470
    540471UString ObjectImp::toString(ExecState *exec) const
    541472{
    542   Value prim = toPrimitive(exec,StringType);
     473  ValueImp *prim = toPrimitive(exec,StringType);
    543474  if (exec->hadException()) // should be picked up soon in nodes.cpp
    544475    return "";
    545   return prim.toString(exec);
    546 }
    547 
    548 Object ObjectImp::toObject(ExecState */*exec*/) const
    549 {
    550   return Object(const_cast<ObjectImp*>(this));
     476  return prim->toString(exec);
     477}
     478
     479ObjectImp *ObjectImp::toObject(ExecState */*exec*/) const
     480{
     481  return const_cast<ObjectImp*>(this);
    551482}
    552483
     
    558489void ObjectImp::putDirect(const Identifier &propertyName, int value, int attr)
    559490{
    560     _prop.put(propertyName, NumberImp::create(value), attr);
     491    _prop.put(propertyName, jsNumber(value), attr);
    561492}
    562493
     
    575506const char * const * const Error::errorNames = errorNamesArr;
    576507
    577 Object Error::create(ExecState *exec, ErrorType errtype, const char *message,
     508ObjectImp *Error::create(ExecState *exec, ErrorType errtype, const char *message,
    578509                     int lineno, int sourceId, const UString *sourceURL)
    579510{
    580   Object cons;
     511  ObjectImp *cons;
    581512  switch (errtype) {
    582513  case EvalError:
     
    607538  List args;
    608539  args.append(String(message));
    609   Object err = Object::dynamicCast(cons.construct(exec,args));
     540  ObjectImp *err = static_cast<ObjectImp *>(cons->construct(exec,args));
    610541
    611542  if (lineno != -1)
    612     err.put(exec, "line", Number(lineno));
     543    err->put(exec, "line", Number(lineno));
    613544  if (sourceId != -1)
    614     err.put(exec, "sourceId", Number(sourceId));
     545    err->put(exec, "sourceId", Number(sourceId));
    615546
    616547  if(sourceURL)
    617    err.put(exec,"sourceURL", String(*sourceURL));
     548   err->put(exec,"sourceURL", String(*sourceURL));
    618549 
    619550  return err;
     
    621552/*
    622553#ifndef NDEBUG
    623   const char *msg = err.get("message").toString().value().ascii();
     554  const char *msg = err->get("message")->toString().value().ascii();
    624555  if (l >= 0)
    625556      fprintf(stderr, "KJS: %s at line %d. %s\n", estr, l, msg);
     
    634565ObjectImp *error(ExecState *exec, ErrorType type, const char *message, int line, int sourceId, const UString *sourceURL)
    635566{
    636     return Error::create(exec, type, message, line, sourceId, sourceURL).imp();
     567    return Error::create(exec, type, message, line, sourceId, sourceURL);
    637568}
    638569
  • trunk/JavaScriptCore/kjs/object.h

    r10076 r10084  
    2323 */
    2424
    25 
    26 #ifndef _KJS_OBJECT_H_
    27 #define _KJS_OBJECT_H_
     25#ifndef KJS_OBJECT_H
     26#define KJS_OBJECT_H
    2827
    2928// Objects
     
    3938#endif
    4039
    41 #include "types.h"
    4240#include "interpreter.h"
    43 #include "reference_list.h"
    4441#include "property_map.h"
    4542#include "property_slot.h"
     
    5148  class HashEntry;
    5249  class ListImp;
     50
     51  // ECMA 262-3 8.6.1
     52  // Property attributes
     53  enum Attribute { None       = 0,
     54                   ReadOnly   = 1 << 1, // property can be only read, not written
     55                   DontEnum   = 1 << 2, // property doesn't appear in (for .. in ..)
     56                   DontDelete = 1 << 3, // property can't be deleted
     57                   Internal   = 1 << 4, // an internal property, set to bypass checks
     58                   Function   = 1 << 5 }; // property is a function - only used by static hashtables
    5359
    5460  /**
     
    7581  };
    7682 
    77   inline Object Value::toObject(ExecState *exec) const { return rep->dispatchToObject(exec); }
    78  
    79   class ObjectImp : public ValueImp {
     83  class ObjectImp : public AllocatedValueImp {
    8084  public:
    8185    /**
     
    8488     * @param proto The prototype
    8589     */
    86     ObjectImp(const Object &proto);
    8790    ObjectImp(ObjectImp *proto);
    8891
    8992    /**
    9093     * Creates a new ObjectImp with a prototype of Null()
    91      * (that is, the ECMAScript "null" value, not a null Object).
     94     * (that is, the ECMAScript "null" value, not a null object pointer).
    9295     *
    9396     */
    9497    ObjectImp();
    95 
    96     virtual ~ObjectImp();
    9798
    9899    virtual void mark();
     
    170171
    171172    /**
     173     * Returns the prototype of this object. Note that this is not the same as
     174     * the "prototype" property.
     175     *
     176     * See ECMA 8.6.2
     177     *
     178     * @return The object's prototype
     179     */
     180    /**
    172181     * Implementation of the [[Prototype]] internal property (implemented by
    173182     * all Objects)
    174      *
    175      * @see Object::prototype()
    176      */
    177     Value prototype() const;
    178     void setPrototype(const Value &proto);
    179 
     183     */
     184    ValueImp *prototype() const;
     185    void setPrototype(ValueImp *proto);
     186
     187    /**
     188     * Returns the class name of the object
     189     *
     190     * See ECMA 8.6.2
     191     *
     192     * @return The object's class name
     193     */
    180194    /**
    181195     * Implementation of the [[Class]] internal property (implemented by all
     
    186200     * if you simply need a classname, you can reimplement className()
    187201     * instead.
    188      *
    189      * @see Object::className()
    190202     */
    191203    virtual UString className() const;
    192204
     205    /**
     206     * Retrieves the specified property from the object. If neither the object
     207     * or any other object in it's prototype chain have the property, this
     208     * function will return Undefined.
     209     *
     210     * See ECMA 8.6.2.1
     211     *
     212     * @param exec The current execution state
     213     * @param propertyName The name of the property to retrieve
     214     *
     215     * @return The specified property, or Undefined
     216     */
    193217    /**
    194218     * Implementation of the [[Get]] internal property (implemented by all
    195219     * Objects)
    196      *
    197      * @see Object::get()
    198220     */
    199221    // [[Get]] - must be implemented by all Objects
    200     Value get(ExecState *exec, const Identifier &propertyName) const;
    201     Value get(ExecState *exec, unsigned propertyName) const;
    202 
    203     bool getProperty(ExecState *exec, const Identifier& propertyName, Value& result) const;
    204     bool getProperty(ExecState *exec, unsigned propertyName, Value& result) const;
     222    ValueImp *get(ExecState *exec, const Identifier &propertyName) const;
     223    ValueImp *get(ExecState *exec, unsigned propertyName) const;
     224
     225    bool getProperty(ExecState *exec, const Identifier& propertyName, ValueImp*& result) const;
     226    bool getProperty(ExecState *exec, unsigned propertyName, ValueImp*& result) const;
    205227
    206228    bool getPropertySlot(ExecState *, const Identifier&, PropertySlot&);
    207229    bool getPropertySlot(ExecState *, unsigned, PropertySlot&);
     230
    208231    virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
    209232    virtual bool getOwnPropertySlot(ExecState *, unsigned index, PropertySlot&);
    210233
    211234    /**
     235     * Sets the specified property.
     236     *
     237     * See ECMA 8.6.2.2
     238     *
     239     * @param exec The current execution state
     240     * @param propertyName The name of the property to set
     241     * @param propertyValue The value to set
     242     */
     243    /**
    212244     * Implementation of the [[Put]] internal property (implemented by all
    213245     * Objects)
    214      *
    215      * @see Object::put()
    216246     */
    217247    virtual void put(ExecState *exec, const Identifier &propertyName,
    218                      const Value &value, int attr = None);
     248                     ValueImp *value, int attr = None);
    219249    virtual void put(ExecState *exec, unsigned propertyName,
    220                      const Value &value, int attr = None);
    221 
     250                     ValueImp *value, int attr = None);
     251
     252    /**
     253     * Used to check whether or not a particular property is allowed to be set
     254     * on an object
     255     *
     256     * See ECMA 8.6.2.3
     257     *
     258     * @param exec The current execution state
     259     * @param propertyName The name of the property
     260     * @return true if the property can be set, otherwise false
     261     */
    222262    /**
    223263     * Implementation of the [[CanPut]] internal property (implemented by all
    224264     * Objects)
    225      *
    226      * @see Object::canPut()
    227265     */
    228266    virtual bool canPut(ExecState *exec, const Identifier &propertyName) const;
    229267
     268    /**
     269     * Checks to see whether the object (or any object in it's prototype chain)
     270     * has a property with the specified name.
     271     *
     272     * See ECMA 8.6.2.4
     273     *
     274     * @param exec The current execution state
     275     * @param propertyName The name of the property to check for
     276     * @return true if the object has the property, otherwise false
     277     */
    230278    /**
    231279     * Implementation of the [[HasProperty]] internal property (implemented by
    232280     * all Objects)
    233      *
    234      * @see Object::hasProperty()
    235      */
    236     bool hasProperty(ExecState *exec, const Identifier &propertyName) const;
     281     */
     282    bool hasProperty(ExecState *exec,
     283                             const Identifier &propertyName) const;
    237284    bool hasProperty(ExecState *exec, unsigned propertyName) const;
    238285
     286    /**
     287     * Checks to see whether the object has a property with the specified name.
     288     *
     289     * See ECMA 15.2.4.5
     290     *
     291     * @param exec The current execution state
     292     * @param propertyName The name of the property to check for
     293     * @return true if the object has the property, otherwise false
     294     */
    239295    virtual bool hasOwnProperty(ExecState *exec, const Identifier &propertyName) const;
    240 
     296    virtual bool hasOwnProperty(ExecState *exec, unsigned propertyName) const;
     297
     298    /**
     299     * Removes the specified property from the object.
     300     *
     301     * See ECMA 8.6.2.5
     302     *
     303     * @param exec The current execution state
     304     * @param propertyName The name of the property to delete
     305     * @return true if the property was successfully deleted or did not
     306     * exist on the object. false if deleting the specified property is not
     307     * allowed.
     308     */
    241309    /**
    242310     * Implementation of the [[Delete]] internal property (implemented by all
    243311     * Objects)
    244      *
    245      * @see Object::deleteProperty()
    246312     */
    247313    virtual bool deleteProperty(ExecState *exec,
     
    257323
    258324    /**
     325     * Converts the object into a primitive value. The value return may differ
     326     * depending on the supplied hint
     327     *
     328     * See ECMA 8.6.2.6
     329     *
     330     * @param exec The current execution state
     331     * @param hint The desired primitive type to convert to
     332     * @return A primitive value converted from the objetc. Note that the
     333     * type of primitive value returned may not be the same as the requested
     334     * hint.
     335     */
     336    /**
    259337     * Implementation of the [[DefaultValue]] internal property (implemented by
    260338     * all Objects)
    261      *
    262      * @see Object::defaultValue()
    263      */
    264     virtual Value defaultValue(ExecState *exec, Type hint) const;
    265 
     339     */
     340    virtual ValueImp *defaultValue(ExecState *exec, Type hint) const;
     341
     342    /**
     343     * Whether or not the object implements the construct() method. If this
     344     * returns false you should not call the construct() method on this
     345     * object (typically, an assertion will fail to indicate this).
     346     *
     347     * @return true if this object implements the construct() method, otherwise
     348     * false
     349     */
    266350    virtual bool implementsConstruct() const;
     351
     352    /**
     353     * Creates a new object based on this object. Typically this means the
     354     * following:
     355     * 1. A new object is created
     356     * 2. The prototype of the new object is set to the value of this object's
     357     *    "prototype" property
     358     * 3. The call() method of this object is called, with the new object
     359     *    passed as the this value
     360     * 4. The new object is returned
     361     *
     362     * In some cases, Host objects may differ from these semantics, although
     363     * this is discouraged.
     364     *
     365     * If an error occurs during construction, the execution state's exception
     366     * will be set. This can be tested for with ExecState::hadException().
     367     * Under some circumstances, the exception object may also be returned.
     368     *
     369     * Note: This function should not be called if implementsConstruct() returns
     370     * false, in which case it will result in an assertion failure.
     371     *
     372     * @param exec The current execution state
     373     * @param args The arguments to be passed to call() once the new object has
     374     * been created
     375     * @return The newly created &amp; initialized object
     376     */
    267377    /**
    268378     * Implementation of the [[Construct]] internal property
    269      *
    270      * @see Object::construct()
    271      */
    272     virtual Object construct(ExecState *exec, const List &args);
    273     virtual Object construct(ExecState *exec, const List &args, const UString &sourceURL, int lineNumber);
    274 
     379     */
     380    virtual ObjectImp *construct(ExecState *exec, const List &args);
     381    virtual ObjectImp *construct(ExecState *exec, const List &args, const UString &sourceURL, int lineNumber);
     382
     383    /**
     384     * Whether or not the object implements the call() method. If this returns
     385     * false you should not call the call() method on this object (typically,
     386     * an assertion will fail to indicate this).
     387     *
     388     * @return true if this object implements the call() method, otherwise
     389     * false
     390     */
    275391    virtual bool implementsCall() const;
     392
     393    /**
     394     * Calls this object as if it is a function.
     395     *
     396     * Note: This function should not be called if implementsCall() returns
     397     * false, in which case it will result in an assertion failure.
     398     *
     399     * See ECMA 8.6.2.3
     400     *
     401     * @param exec The current execution state
     402     * @param thisObj The obj to be used as "this" within function execution.
     403     * Note that in most cases this will be different from the C++ "this"
     404     * object. For example, if the ECMAScript code "window.location->toString()"
     405     * is executed, call() will be invoked on the C++ object which implements
     406     * the toString method, with the thisObj being window.location
     407     * @param args List of arguments to be passed to the function
     408     * @return The return value from the function
     409     */
    276410    /**
    277411     * Implementation of the [[Call]] internal property
    278      *
    279      * @see Object::call()
    280      */
    281     virtual Value call(ExecState *exec, Object &thisObj,
    282                        const List &args);
    283 
     412     */
     413    ValueImp *call(ExecState *exec, ObjectImp *thisObj, const List &args);
     414    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
     415
     416    /**
     417     * Whether or not the object implements the hasInstance() method. If this
     418     * returns false you should not call the hasInstance() method on this
     419     * object (typically, an assertion will fail to indicate this).
     420     *
     421     * @return true if this object implements the hasInstance() method,
     422     * otherwise false
     423     */
    284424    virtual bool implementsHasInstance() const;
     425
     426    /**
     427     * Checks whether value delegates behavior to this object. Used by the
     428     * instanceof operator.
     429     *
     430     * @param exec The current execution state
     431     * @param value The value to check
     432     * @return true if value delegates behavior to this object, otherwise
     433     * false
     434     */
    285435    /**
    286436     * Implementation of the [[HasInstance]] internal property
    287      *
    288      * @see Object::hasInstance()
    289      */
    290     virtual Boolean hasInstance(ExecState *exec, const Value &value);
    291 
     437     */
     438    virtual bool hasInstance(ExecState *exec, ValueImp *value);
     439
     440    /**
     441     * Returns the scope of this object. This is used when execution declared
     442     * functions - the execution context for the function is initialized with
     443     * extra object in it's scope. An example of this is functions declared
     444     * inside other functions:
     445     *
     446     * \code
     447     * function f() {
     448     *
     449     *   function b() {
     450     *     return prototype;
     451     *   }
     452     *
     453     *   var x = 4;
     454     *   // do some stuff
     455     * }
     456     * f.prototype = new String();
     457     * \endcode
     458     *
     459     * When the function f.b is executed, its scope will include properties of
     460     * f. So in the example above the return value of f.b() would be the new
     461     * String object that was assigned to f.prototype.
     462     *
     463     * @param exec The current execution state
     464     * @return The function's scope
     465     */
    292466    /**
    293467     * Implementation of the [[Scope]] internal property
    294      *
    295      * @see Object::scope()
    296468     */
    297469    const ScopeChain &scope() const { return _scope; }
    298470    void setScope(const ScopeChain &s) { _scope = s; }
    299471
     472    /**
     473     * Returns a List of References to all the properties of the object. Used
     474     * in "for x in y" statements. The list is created new, so it can be freely
     475     * modified without affecting the object's properties. It should be deleted
     476     * by the caller.
     477     *
     478     * Subclasses can override this method in ObjectImpl to provide the
     479     * appearance of
     480     * having extra properties other than those set specifically with put().
     481     *
     482     * @param exec The current execution state
     483     * @param recursive Whether or not properties in the object's prototype
     484     * chain should be
     485     * included in the list.
     486     * @return A List of References to properties of the object.
     487     **/
    300488    virtual ReferenceList propList(ExecState *exec, bool recursive = true);
    301489
    302     Value internalValue() const;
    303     void setInternalValue(const Value &v);
     490    /**
     491     * Returns the internal value of the object. This is used for objects such
     492     * as String and Boolean which are wrappers for native types. The interal
     493     * value is the actual value represented by the wrapper objects.
     494     *
     495     * @see ECMA 8.6.2
     496     * @return The internal value of the object
     497     */
     498    ValueImp *internalValue() const;
     499
     500    /**
     501     * Sets the internal value of the object
     502     *
     503     * @see internalValue()
     504     *
     505     * @param v The new internal value
     506     */
     507
    304508    void setInternalValue(ValueImp *v);
    305509
    306     Value toPrimitive(ExecState *exec,
    307                       Type preferredType = UnspecifiedType) const;
     510    ValueImp *toPrimitive(ExecState *exec, Type preferredType = UnspecifiedType) const;
    308511    bool toBoolean(ExecState *exec) const;
    309512    double toNumber(ExecState *exec) const;
    310513    UString toString(ExecState *exec) const;
    311     Object toObject(ExecState *exec) const;
     514    ObjectImp *toObject(ExecState *exec) const;
    312515
    313516    // This get method only looks at the property map.
     
    345548     
    346549      ValueImp *proto = imp->_proto;
    347       if (proto->dispatchType() != ObjectType)
     550      if (!proto->isObject())
    348551        break;
    349552     
     
    403606     * @param lineno Optional source id.
    404607     */
    405     static Object create(ExecState *exec, ErrorType errtype = GeneralError,
    406                          const char *message = 0, int lineno = -1,
    407                          int sourceId = -1, const UString *sourceURL = 0);
     608    static ObjectImp *create(ExecState *exec, ErrorType errtype = GeneralError,
     609                             const char *message = 0, int lineno = -1,
     610                             int sourceId = -1, const UString *sourceURL = 0);
    408611
    409612    /**
     
    413616  };
    414617
    415   inline bool ValueImp::isObject(const ClassInfo *info) const
    416     { return isObject() && static_cast<const ObjectImp *>(this)->inherits(info); }
    417 
    418   inline ObjectImp *ValueImp::asObject()
    419     { return isObject() ? static_cast<ObjectImp *>(this) : 0; }
    420 
    421   inline Object::Object(ObjectImp *o) : Value(o) { }
    422 
    423   inline ObjectImp *Object::imp() const
    424     { return static_cast<ObjectImp *>(Value::imp()); }
    425 
    426   inline const ClassInfo *Object::classInfo() const
    427     { return imp()->classInfo(); }
    428 
    429   inline bool Object::inherits(const ClassInfo *cinfo) const
    430     { return imp()->inherits(cinfo); }
    431 
    432   inline Value Object::prototype() const
    433     { return Value(imp()->prototype()); }
    434 
    435   inline UString Object::className() const
    436     { return imp()->className(); }
    437 
    438   inline Value Object::get(ExecState *exec, const Identifier &propertyName) const
    439     { return imp()->get(exec,propertyName); }
    440 
    441   inline Value Object::get(ExecState *exec, unsigned propertyName) const
    442     { return imp()->get(exec,propertyName); }
    443 
    444   inline void Object::put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr)
    445     { imp()->put(exec,propertyName,value,attr); }
    446 
    447   inline void Object::put(ExecState *exec, unsigned propertyName, const Value &value, int attr)
    448     { imp()->put(exec,propertyName,value,attr); }
    449 
    450   inline bool Object::canPut(ExecState *exec, const Identifier &propertyName) const
    451     { return imp()->canPut(exec,propertyName); }
    452 
    453   inline bool Object::hasProperty(ExecState *exec, const Identifier &propertyName) const
    454     { return imp()->hasProperty(exec, propertyName); }
    455 
    456   inline bool Object::hasOwnProperty(ExecState *exec, const Identifier &propertyName) const
    457     { return imp()->hasOwnProperty(exec, propertyName); }
    458 
    459   inline bool Object::deleteProperty(ExecState *exec, const Identifier &propertyName)
    460     { return imp()->deleteProperty(exec,propertyName); }
    461 
    462   inline bool Object::deleteProperty(ExecState *exec, unsigned propertyName)
    463     { return imp()->deleteProperty(exec,propertyName); }
    464 
    465   inline Value Object::defaultValue(ExecState *exec, Type hint) const
    466     { return imp()->defaultValue(exec,hint); }
    467 
    468   inline bool Object::implementsConstruct() const
    469     { return imp()->implementsConstruct(); }
    470 
    471   inline Object Object::construct(ExecState *exec, const List &args)
    472     { return imp()->construct(exec,args); }
    473  
    474   inline Object Object::construct(ExecState *exec, const List &args, const UString &sourceURL, int lineNumber)
    475   { return imp()->construct(exec,args,sourceURL,lineNumber); }
    476 
    477   inline bool Object::implementsCall() const
    478     { return imp()->implementsCall(); }
    479 
    480   inline bool Object::implementsHasInstance() const
    481     { return imp()->implementsHasInstance(); }
    482 
    483   inline Boolean Object::hasInstance(ExecState *exec, const Value &value)
    484     { return imp()->hasInstance(exec,value); }
    485 
    486   inline const ScopeChain &Object::scope() const
    487     { return imp()->scope(); }
    488 
    489   inline void Object::setScope(const ScopeChain &s)
    490     { imp()->setScope(s); }
    491 
    492   inline ReferenceList Object::propList(ExecState *exec, bool recursive)
    493     { return imp()->propList(exec,recursive); }
    494 
    495   inline Value Object::internalValue() const
    496     { return imp()->internalValue(); }
    497 
    498   inline void Object::setInternalValue(const Value &v)
    499     { imp()->setInternalValue(v); }
    500 
    501   inline void Object::saveProperties(SavedProperties &p) const
    502     { imp()->saveProperties(p); }
    503   inline void Object::restoreProperties(const SavedProperties &p)
    504     { imp()->restoreProperties(p); }
     618    inline bool AllocatedValueImp::isObject(const ClassInfo *info) const
     619        { return isObject() && static_cast<const ObjectImp *>(this)->inherits(info); }
     620
     621inline ObjectImp::ObjectImp(ObjectImp *proto)
     622    : _proto(proto), _internalValue(0)
     623{
     624}
     625
     626inline ObjectImp::ObjectImp()
     627    : _proto(jsNull()), _internalValue(0)
     628{
     629}
     630
     631inline ValueImp *ObjectImp::internalValue() const
     632{
     633    return _internalValue;
     634}
     635
     636inline void ObjectImp::setInternalValue(ValueImp *v)
     637{
     638    _internalValue = v;
     639}
     640
     641inline ValueImp *ObjectImp::prototype() const
     642{
     643    return _proto;
     644}
     645
     646inline void ObjectImp::setPrototype(ValueImp *proto)
     647{
     648    _proto = proto;
     649}
     650
     651inline bool ObjectImp::inherits(const ClassInfo *info) const
     652{
     653    for (const ClassInfo *ci = classInfo(); ci; ci = ci->parentClass)
     654        if (ci == info)
     655            return true;
     656    return false;
     657}
    505658
    506659} // namespace
    507660
    508 #endif // _KJS_OBJECT_H_
     661#endif // KJS_OBJECT_H
  • trunk/JavaScriptCore/kjs/object_object.cpp

    r9889 r10084  
    3838  : ObjectImp() // [[Prototype]] is Null()
    3939{
    40     Value protect(this);
    4140    putDirect(toStringPropertyName, new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ToString,            0), DontEnum);
    4241    putDirect(toLocaleStringPropertyName, new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ToLocaleString,0), DontEnum);
     
    5352  : InternalFunctionImp(funcProto), id(i)
    5453{
    55   Value protect(this);
    5654  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
    5755}
     
    6563// ECMA 15.2.4.2, 15.2.4.4, 15.2.4.5
    6664
    67 Value ObjectProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &args)
     65ValueImp *ObjectProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
    6866{
    6967    switch (id) {
    7068        case ValueOf:
    7169            return thisObj;
    72         case HasOwnProperty: {
     70        case HasOwnProperty:
    7371            // Same as the in operator but without checking the prototype
    74             Identifier propertyName(args[0].toString(exec));
    75             bool exists = thisObj.hasOwnProperty(exec, propertyName);
    76             return Value(exists ? BooleanImp::staticTrue : BooleanImp::staticFalse);
    77         }
     72            return jsBoolean(thisObj->hasOwnProperty(exec, Identifier(args[0]->toString(exec))));
    7873        case ToLocaleString:
    79           return thisObj.imp()->toString(exec);
     74            return jsString(thisObj->toString(exec));
    8075        case ToString:
    8176        default:
    82             return String("[object " + thisObj.className() + "]");
     77            return String("[object " + thisObj->className() + "]");
    8378    }
    8479}
     
    9186  : InternalFunctionImp(funcProto)
    9287{
    93   Value protect(this);
    9488  // ECMA 15.2.3.1
    9589  putDirect(prototypePropertyName, objProto, DontEnum|DontDelete|ReadOnly);
    9690
    9791  // no. of arguments for constructor
    98   putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum);
     92  putDirect(lengthPropertyName, jsOne(), ReadOnly|DontDelete|DontEnum);
    9993}
    10094
     
    106100
    107101// ECMA 15.2.2
    108 Object ObjectObjectImp::construct(ExecState *exec, const List &args)
     102ObjectImp *ObjectObjectImp::construct(ExecState *exec, const List &args)
    109103{
    110104  // if no arguments have been passed ...
    111105  if (args.isEmpty()) {
    112     Object proto = exec->lexicalInterpreter()->builtinObjectPrototype();
    113     Object result(new ObjectImp(proto));
     106    ObjectImp *proto = exec->lexicalInterpreter()->builtinObjectPrototype();
     107    ObjectImp *result(new ObjectImp(proto));
    114108    return result;
    115109  }
    116110
    117   Value arg = *(args.begin());
    118   Object obj = Object::dynamicCast(arg);
    119   if (!obj.isNull()) {
     111  ValueImp *arg = *(args.begin());
     112  if (ObjectImp *obj = arg->getObject())
    120113    return obj;
    121   }
    122114
    123   switch (arg.type()) {
     115  switch (arg->type()) {
    124116  case StringType:
    125117  case BooleanType:
    126118  case NumberType:
    127     return arg.toObject(exec);
     119    return arg->toObject(exec);
    128120  default:
    129121    assert(!"unhandled switch case in ObjectConstructor");
    130122  case NullType:
    131123  case UndefinedType:
    132     Object proto = exec->lexicalInterpreter()->builtinObjectPrototype();
    133     return Object(new ObjectImp(proto));
     124    return new ObjectImp(exec->lexicalInterpreter()->builtinObjectPrototype());
    134125  }
    135126}
     
    140131}
    141132
    142 Value ObjectObjectImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
     133ValueImp *ObjectObjectImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
    143134{
    144   Value result;
     135  ValueImp *result;
    145136
    146137  List argList;
     
    149140    result = construct(exec,argList);
    150141  } else {
    151     Value arg = args[0];
    152     if (arg.type() == NullType || arg.type() == UndefinedType) {
     142    ValueImp *arg = args[0];
     143    if (arg->isUndefinedOrNull()) {
    153144      argList.append(arg);
    154145      result = construct(exec,argList);
    155146    } else
    156       result = arg.toObject(exec);
     147      result = arg->toObject(exec);
    157148  }
    158149  return result;
  • trunk/JavaScriptCore/kjs/object_object.h

    r9768 r10084  
    4848  class ObjectProtoFuncImp : public InternalFunctionImp {
    4949  public:
    50     ObjectProtoFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto,
    51                        int i, int len);
     50    ObjectProtoFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto, int i, int len);
    5251
    5352    virtual bool implementsCall() const;
    54     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     53    virtual ValueImp *callAsFunction(ExecState *, ObjectImp *, const List &args);
    5554
    5655    enum { ToString, ToLocaleString, ValueOf, HasOwnProperty };
     
    7271
    7372    virtual bool implementsConstruct() const;
    74     virtual Object construct(ExecState *exec, const List &args);
     73    virtual ObjectImp *construct(ExecState *, const List &args);
    7574    virtual bool implementsCall() const;
    76     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     75    virtual ValueImp *callAsFunction(ExecState *, ObjectImp *, const List &args);
    7776  };
    7877
  • trunk/JavaScriptCore/kjs/operations.cpp

    r9768 r10084  
    112112
    113113// ECMA 11.9.3
    114 bool KJS::equal(ExecState *exec, const Value& v1, const Value& v2)
    115 {
    116     Type t1 = v1.type();
    117     Type t2 = v2.type();
     114bool KJS::equal(ExecState *exec, ValueImp *v1, ValueImp *v2)
     115{
     116    Type t1 = v1->type();
     117    Type t2 = v2->type();
    118118
    119119    if (t1 != t2) {
     
    135135        } else {
    136136            if ((t1 == StringType || t1 == NumberType) && t2 >= ObjectType)
    137                 return equal(exec, v1, v2.toPrimitive(exec));
     137                return equal(exec, v1, v2->toPrimitive(exec));
    138138            if (t1 >= ObjectType && (t2 == StringType || t2 == NumberType))
    139                 return equal(exec, v1.toPrimitive(exec), v2);
     139                return equal(exec, v1->toPrimitive(exec), v2);
    140140            if (t1 != t2)
    141141                return false;
     
    147147
    148148    if (t1 == NumberType) {
    149         double d1 = v1.toNumber(exec);
    150         double d2 = v2.toNumber(exec);
     149        double d1 = v1->toNumber(exec);
     150        double d2 = v2->toNumber(exec);
    151151        // FIXME: Isn't this already how NaN behaves?
    152152        // Why the extra line of code?
     
    157157
    158158    if (t1 == StringType)
    159         return v1.toString(exec) == v2.toString(exec);
     159        return v1->toString(exec) == v2->toString(exec);
    160160
    161161    if (t1 == BooleanType)
    162         return v1.toBoolean(exec) == v2.toBoolean(exec);
     162        return v1->toBoolean(exec) == v2->toBoolean(exec);
    163163
    164164    // types are Object
    165     return v1.imp() == v2.imp();
    166 }
    167 
    168 bool KJS::strictEqual(ExecState *exec, const Value &v1, const Value &v2)
    169 {
    170   Type t1 = v1.type();
    171   Type t2 = v2.type();
     165    return v1 == v2;
     166}
     167
     168bool KJS::strictEqual(ExecState *exec, ValueImp *v1, ValueImp *v2)
     169{
     170  Type t1 = v1->type();
     171  Type t2 = v2->type();
    172172
    173173  if (t1 != t2)
     
    176176    return true;
    177177  if (t1 == NumberType) {
    178     double n1 = v1.toNumber(exec);
    179     double n2 = v2.toNumber(exec);
     178    double n1 = v1->toNumber(exec);
     179    double n2 = v2->toNumber(exec);
    180180    // FIXME: Isn't this already how NaN behaves?
    181181    // Why the extra line of code?
     
    187187    return false;
    188188  } else if (t1 == StringType) {
    189     return v1.toString(exec) == v2.toString(exec);
     189    return v1->toString(exec) == v2->toString(exec);
    190190  } else if (t2 == BooleanType) {
    191     return v1.toBoolean(exec) == v2.toBoolean(exec);
     191    return v1->toBoolean(exec) == v2->toBoolean(exec);
    192192  }
    193   if (v1.imp() == v2.imp())
     193  if (v1 == v2)
    194194    return true;
    195195  /* TODO: joined objects */
     
    198198}
    199199
    200 int KJS::relation(ExecState *exec, const Value& v1, const Value& v2)
    201 {
    202   Value p1 = v1.toPrimitive(exec,NumberType);
    203   Value p2 = v2.toPrimitive(exec,NumberType);
    204 
    205   if (p1.type() == StringType && p2.type() == StringType)
    206     return p1.toString(exec) < p2.toString(exec) ? 1 : 0;
    207 
    208   double n1 = p1.toNumber(exec);
    209   double n2 = p2.toNumber(exec);
     200int KJS::relation(ExecState *exec, ValueImp *v1, ValueImp *v2)
     201{
     202  ValueImp *p1 = v1->toPrimitive(exec,NumberType);
     203  ValueImp *p2 = v2->toPrimitive(exec,NumberType);
     204
     205  if (p1->isString() && p2->isString())
     206    return p1->toString(exec) < p2->toString(exec) ? 1 : 0;
     207
     208  double n1 = p1->toNumber(exec);
     209  double n2 = p2->toNumber(exec);
    210210  if (n1 < n2)
    211211    return 1;
     
    226226
    227227// ECMA 11.6
    228 Value KJS::add(ExecState *exec, const Value &v1, const Value &v2, char oper)
     228ValueImp *KJS::add(ExecState *exec, ValueImp *v1, ValueImp *v2, char oper)
    229229{
    230230  // exception for the Date exception in defaultValue()
    231231  Type preferred = oper == '+' ? UnspecifiedType : NumberType;
    232   Value p1 = v1.toPrimitive(exec, preferred);
    233   Value p2 = v2.toPrimitive(exec, preferred);
    234 
    235   if ((p1.type() == StringType || p2.type() == StringType) && oper == '+') {
    236     return p1.toString(exec) + p2.toString(exec);
     232  ValueImp *p1 = v1->toPrimitive(exec, preferred);
     233  ValueImp *p2 = v2->toPrimitive(exec, preferred);
     234
     235  if ((p1->isString() || p2->isString()) && oper == '+') {
     236    return jsString(p1->toString(exec) + p2->toString(exec));
    237237  }
    238238
    239239  bool n1KnownToBeInteger;
    240   double n1 = p1.toNumber(exec, n1KnownToBeInteger);
     240  double n1 = p1->toNumber(exec, n1KnownToBeInteger);
    241241  bool n2KnownToBeInteger;
    242   double n2 = p2.toNumber(exec, n2KnownToBeInteger);
     242  double n2 = p2->toNumber(exec, n2KnownToBeInteger);
    243243
    244244  bool resultKnownToBeInteger = n1KnownToBeInteger && n2KnownToBeInteger;
    245245
    246246  if (oper == '+')
    247     return Value(n1 + n2, resultKnownToBeInteger);
     247    return jsNumber(n1 + n2, resultKnownToBeInteger);
    248248  else
    249     return Value(n1 - n2, resultKnownToBeInteger);
     249    return jsNumber(n1 - n2, resultKnownToBeInteger);
    250250}
    251251
    252252// ECMA 11.5
    253 Value KJS::mult(ExecState *exec, const Value &v1, const Value &v2, char oper)
     253ValueImp *KJS::mult(ExecState *exec, ValueImp *v1, ValueImp *v2, char oper)
    254254{
    255255  bool n1KnownToBeInteger;
    256   double n1 = v1.toNumber(exec, n1KnownToBeInteger);
     256  double n1 = v1->toNumber(exec, n1KnownToBeInteger);
    257257  bool n2KnownToBeInteger;
    258   double n2 = v2.toNumber(exec, n2KnownToBeInteger);
     258  double n2 = v2->toNumber(exec, n2KnownToBeInteger);
    259259
    260260  double result;
     
    272272  }
    273273
    274   return Value(result, resultKnownToBeInteger);
    275 }
     274  return jsNumber(result, resultKnownToBeInteger);
     275}
  • trunk/JavaScriptCore/kjs/operations.h

    r9768 r10084  
    4848#endif
    4949
    50   bool equal(ExecState *exec, const Value& v1, const Value& v2);
    51   bool strictEqual(ExecState *exec, const Value &v1, const Value &v2);
     50  bool equal(ExecState *exec, ValueImp *v1, ValueImp *v2);
     51  bool strictEqual(ExecState *exec, ValueImp *v1, ValueImp *v2);
    5252  /**
    5353   * This operator performs an abstract relational comparison of the two
     
    5858   * equal". -1 if the result is undefined.
    5959   */
    60   int relation(ExecState *exec, const Value& v1, const Value& v2);
     60  int relation(ExecState *exec, ValueImp *v1, ValueImp *v2);
    6161  int maxInt(int d1, int d2);
    6262  int minInt(int d1, int d2);
     
    6767   * @return The result of the operation.
    6868   */
    69   Value add(ExecState *exec, const Value &v1, const Value &v2, char oper);
     69  ValueImp *add(ExecState *exec, ValueImp *v1, ValueImp *v2, char oper);
    7070  /**
    7171   * Multiplicative operator. Either multiplies/divides v1 and v2 or
     
    7575   * @return The result of the operation.
    7676   */
    77   Value mult(ExecState *exec, const Value &v1, const Value &v2, char oper);
     77  ValueImp *mult(ExecState *exec, ValueImp *v1, ValueImp *v2, char oper);
    7878
    7979};
  • trunk/JavaScriptCore/kjs/property_map.cpp

    r10076 r10084  
    546546    int size = _table->size;
    547547    Entry *entries = _table->entries;
    548     for (int i = 0; i != size; ++i) {
     548    for (int i = 0; i < size; i++) {
    549549        ValueImp *v = entries[i].value;
    550550        if (v && !v->marked())
     
    564564}
    565565
    566 void PropertyMap::addEnumerablesToReferenceList(ReferenceList &list, const Object &base) const
     566void PropertyMap::addEnumerablesToReferenceList(ReferenceList &list, ObjectImp *base) const
    567567{
    568568    if (!_table) {
     
    606606}
    607607
    608 void PropertyMap::addSparseArrayPropertiesToReferenceList(ReferenceList &list, const Object &base) const
     608void PropertyMap::addSparseArrayPropertiesToReferenceList(ReferenceList &list, ObjectImp *base) const
    609609{
    610610    if (!_table) {
     
    626626    for (int i = 0; i != size; ++i) {
    627627        UString::Rep *key = entries[i].key;
    628         if (key && key != &UString::Rep::null)
    629         {
     628        if (key && key != &UString::Rep::null) {
    630629            UString k(key);
    631630            bool fitsInUInt32;
     
    671670        if (_singleEntry.key && !(_singleEntry.attributes & (ReadOnly | Function))) {
    672671            prop->key = Identifier(_singleEntry.key);
    673             prop->value = Value(_singleEntry.value);
     672            prop->value = _singleEntry.value;
    674673            prop->attributes = _singleEntry.attributes;
    675674            ++prop;
     
    707706            Entry *e = *q++;
    708707            prop->key = Identifier(e->key);
    709             prop->value = Value(e->value);
     708            prop->value = e->value;
    710709            prop->attributes = e->attributes;
    711710            ++prop;
     
    721720{
    722721    for (int i = 0; i != p._count; ++i)
    723         put(p._properties[i].key, p._properties[i].value.imp(), p._properties[i].attributes);
     722        put(p._properties[i].key, p._properties[i].value, p._properties[i].attributes);
    724723}
    725724
  • trunk/JavaScriptCore/kjs/property_map.h

    r10076 r10084  
    2828namespace KJS {
    2929
    30     class Object;
     30    class ObjectImp;
    3131    class ReferenceList;
    3232    class ValueImp;
     
    8282
    8383        void mark() const;
    84         void addEnumerablesToReferenceList(ReferenceList &, const Object &) const;
    85         void addSparseArrayPropertiesToReferenceList(ReferenceList &, const Object &) const;
     84        void addEnumerablesToReferenceList(ReferenceList &, ObjectImp *) const;
     85        void addSparseArrayPropertiesToReferenceList(ReferenceList &, ObjectImp *) const;
    8686
    8787        void save(SavedProperties &) const;
  • trunk/JavaScriptCore/kjs/property_slot.cpp

    r10076 r10084  
    2626namespace KJS {
    2727
    28 Value PropertySlot::undefinedGetter(ExecState *, const Identifier& propertyName, const PropertySlot& slot)
     28ValueImp *PropertySlot::undefinedGetter(ExecState *, const Identifier& propertyName, const PropertySlot& slot)
    2929{
    3030    return Undefined();
  • trunk/JavaScriptCore/kjs/property_slot.h

    r10076 r10084  
    3737{
    3838public:
    39     typedef Value (*GetValueFunc)(ExecState *, const Identifier&, const PropertySlot&);
     39    typedef ValueImp *(*GetValueFunc)(ExecState *, const Identifier&, const PropertySlot&);
    4040
    4141    bool isSet() { return m_getValue != 0; }
    42     Value getValue(ExecState *exec, const Identifier& propertyName) const
     42    ValueImp *getValue(ExecState *exec, const Identifier& propertyName) const
    4343    {
    4444        if (m_getValue == VALUE_SLOT_MARKER)
     
    4747    }
    4848
    49     Value getValue(ExecState *exec, unsigned propertyName) const
     49    ValueImp *getValue(ExecState *exec, unsigned propertyName) const
    5050    {
    5151        if (m_getValue == VALUE_SLOT_MARKER)
     
    9393
    9494private:
    95     static Value undefinedGetter(ExecState *, const Identifier&, const PropertySlot&);
     95    static ValueImp *undefinedGetter(ExecState *, const Identifier&, const PropertySlot&);
    9696
    9797    GetValueFunc m_getValue;
  • trunk/JavaScriptCore/kjs/protect.h

    r10076 r10084  
    4949        if (val) gcUnprotect(val);
    5050      }
    51 
    5251   
    53     class ProtectedValue : public Value {
    54     public:
    55       ProtectedValue() : Value() {}
    56       ProtectedValue(const Value&v)  : Value(v) { gcProtectNullTolerant(v.imp()); };
    57       ProtectedValue(const ProtectedValue&v)  : Value(v) { gcProtectNullTolerant(v.imp()); };
    58       ~ProtectedValue() { gcUnprotectNullTolerant(imp());}
    59       ProtectedValue& operator=(const Value &v)
    60         {
    61           ValueImp *old = imp();
    62           Value::operator=(v);
    63           gcProtectNullTolerant(v.imp());
    64           gcUnprotectNullTolerant(old);
    65           return *this;
    66         }
    67       ProtectedValue& operator=(const ProtectedValue &v)
    68         {
    69           ValueImp *old = imp();
    70           Value::operator=(v);
    71           gcProtectNullTolerant(v.imp());
    72           gcUnprotectNullTolerant(old);
    73           return *this;
    74         }
    75     private:
    76       explicit ProtectedValue(ValueImp *v);
    77     };
     52class ProtectedValue {
     53public:
     54    ProtectedValue() : m_value(0) { }
     55    ProtectedValue(ValueImp *v) : m_value(v) { gcProtectNullTolerant(v); }
     56    ProtectedValue(const ProtectedValue& v) : m_value(v.m_value) { gcProtectNullTolerant(m_value); }
     57    ~ProtectedValue() { gcUnprotectNullTolerant(m_value); }
     58    ProtectedValue& operator=(ValueImp *v)
     59    {
     60        gcProtectNullTolerant(v);
     61        gcUnprotectNullTolerant(m_value);
     62        m_value = v;
     63        return *this;
     64    }
     65    ProtectedValue& operator=(const ProtectedValue& v) { return *this = v.m_value; }
     66    operator ValueImp *() const { return m_value; }
     67    ValueImp *operator->() const { return m_value; }
     68protected:
     69    ValueImp *m_value;
     70};
    7871
    7972} // namespace
  • trunk/JavaScriptCore/kjs/protected_object.h

    r10076 r10084  
    1 // -*- c-basic-offset: 2 -*-
    21/*
    32 *  This file is part of the KDE libraries
     
    2120 */
    2221
    23 
    24 #ifndef _KJS_PROTECTED_OBJECT_H_
    25 #define _KJS_PROTECTED_OBJECT_H_
     22#ifndef KJS_PROTECTED_OBJECT_H
     23#define KJS_PROTECTED_OBJECT_H
    2624
    2725#include "protect.h"
     
    3129namespace KJS {
    3230
    33     class ProtectedObject : public Object {
    34     public:
    35       ProtectedObject() : Object() {}
    36       ProtectedObject(const Object &o)  : Object(o) { gcProtectNullTolerant(o.imp()); };
    37       ProtectedObject(const ProtectedObject &o)  : Object(o) { gcProtectNullTolerant(o.imp()); };
    38       ~ProtectedObject() { gcUnprotectNullTolerant(imp());}
    39       ProtectedObject& operator=(const Object &o)
    40         {
    41           ValueImp *old = imp();
    42           Object::operator=(o);
    43           gcProtectNullTolerant(o.imp());
    44           gcUnprotectNullTolerant(old);
    45           return *this;
    46         }
    47       ProtectedObject& operator=(const ProtectedObject &o)
    48         {
    49           ValueImp *old = imp();
    50           Object::operator=(o);
    51           gcProtectNullTolerant(o.imp());
    52           gcUnprotectNullTolerant(old);
    53           return *this;
    54         }
    55     private:
    56       explicit ProtectedObject(ObjectImp *o);
    57     };
    58 
     31class ProtectedObject : private ProtectedValue {
     32public:
     33    ProtectedObject() { }
     34    ProtectedObject(ObjectImp *v) : ProtectedValue(v) { }
     35    ProtectedObject(const ProtectedObject& v) : ProtectedValue(v) { }
     36    ProtectedObject& operator=(ObjectImp *v) { ProtectedValue::operator=(v); return *this; }
     37    ProtectedObject& operator=(const ProtectedObject& v) { ProtectedValue::operator=(v); return *this; }
     38    operator ValueImp *() const { return m_value; }
     39    operator ObjectImp *() const { return static_cast<ObjectImp *>(m_value); }
     40    ObjectImp *operator->() const { return static_cast<ObjectImp *>(m_value); }
     41};
    5942
    6043    class ProtectedReference : public Reference {
    6144    public:
    62       ProtectedReference(const Reference&r)  : Reference(r) { gcProtectNullTolerant(r.base.imp()); };
    63       ~ProtectedReference() { gcUnprotectNullTolerant(base.imp());}
     45      ProtectedReference(const Reference& r) : Reference(r) { gcProtectNullTolerant(r.base); };
     46      ~ProtectedReference() { gcUnprotectNullTolerant(base);}
    6447      ProtectedReference& operator=(const Reference &r)
    6548        {
    66           ValueImp *old = base.imp();
     49          ValueImp *old = base;
    6750          Reference::operator=(r);
    68           gcProtectNullTolerant(r.base.imp());
     51          gcProtectNullTolerant(r.base);
    6952          gcUnprotectNullTolerant(old);
    7053          return *this;
     
    7255    private:
    7356      ProtectedReference();
    74       ProtectedReference(const Object& b, const Identifier& p);
    75       ProtectedReference(const Object& b, unsigned p);
    7657      ProtectedReference(ObjectImp *b, const Identifier& p);
    7758      ProtectedReference(ObjectImp *b, unsigned p);
    78       ProtectedReference(const Null& b, const Identifier& p);
    79       ProtectedReference(const Null& b, unsigned p);
     59      ProtectedReference(const Identifier& p);
     60      ProtectedReference(unsigned p);
    8061    };
    8162
  • trunk/JavaScriptCore/kjs/protected_values.cpp

    r9501 r10084  
    2626#include "simple_number.h"
    2727#include <stdint.h>
     28#include "value.h"
    2829
    2930namespace KJS {
     
    4445      return 0;
    4546
    46     unsigned hash = computeHash(k);
     47    unsigned hash = pointerHash(k);
    4748   
    4849    int i = hash & _tableSizeMask;
     
    5152    numCollisions += _table[i].key && _table[i].key != k;
    5253#endif
    53     while (ValueImp *key = _table[i].key) {
     54    while (AllocatedValueImp *key = _table[i].key) {
    5455        if (key == k) {
    5556            return _table[i].value;
     
    7273        expand();
    7374   
    74     unsigned hash = computeHash(k);
     75    unsigned hash = pointerHash(k);
    7576   
    7677    int i = hash & _tableSizeMask;
     
    7980    numCollisions += _table[i].key && _table[i].key != k;
    8081#endif
    81     while (ValueImp *key = _table[i].key) {
     82    while (AllocatedValueImp *key = _table[i].key) {
    8283        if (key == k) {
    8384            _table[i].value++;
     
    8788    }
    8889   
    89     _table[i].key = k;
     90    _table[i].key = k->downcast();
    9091    _table[i].value = 1;
    9192    ++_keyCount;
     
    9596}
    9697
    97 inline void ProtectedValues::insert(ValueImp *k, int v)
     98inline void ProtectedValues::insert(AllocatedValueImp *k, int v)
    9899{
    99     unsigned hash = computeHash(k);
     100    unsigned hash = pointerHash(k);
    100101   
    101102    int i = hash & _tableSizeMask;
     
    118119      return;
    119120
    120     unsigned hash = computeHash(k);
     121    unsigned hash = pointerHash(k);
    121122   
    122     ValueImp *key;
     123    AllocatedValueImp *key;
    123124   
    124125    int i = hash & _tableSizeMask;
     
    187188}
    188189
    189 unsigned ProtectedValues::computeHash(ValueImp *pointer)
    190 {
    191   return pointerHash(pointer);
    192 }
    193 
    194190} // namespace
  • trunk/JavaScriptCore/kjs/protected_values.h

    r9033 r10084  
    2121 */
    2222
    23 
    24 #ifndef _KJS_PROTECTED_VALUES_H_
    25 #define _KJS_PROTECTED_VALUES_H_
     23#ifndef KJS_PROTECTED_VALUES_H
     24#define KJS_PROTECTED_VALUES_H
    2625
    2726namespace KJS {
    2827    class ValueImp;
     28    class AllocatedValueImp;
    2929
    3030    class ProtectedValues {
    31         struct KeyValue {
    32             ValueImp *key;
    33             int value;
    34         };
    35 
    3631    public:
    3732        static void increaseProtectCount(ValueImp *key);
     
    4136
    4237    private:
    43         static void insert(ValueImp *key, int value);
     38        static void insert(AllocatedValueImp *key, int value);
    4439        static void expand();
    4540        static void shrink();
    4641        static void rehash(int newTableSize);
    47         static unsigned computeHash(ValueImp *pointer);
    4842
    4943        // let the collector scan the table directly for protected values
    5044        friend class Collector;
     45
     46        struct KeyValue {
     47            AllocatedValueImp *key;
     48            int value;
     49        };
    5150
    5251        static KeyValue *_table;
  • trunk/JavaScriptCore/kjs/reference.cpp

    r9768 r10084  
    2828// ------------------------------ Reference ------------------------------------
    2929
    30 Reference::Reference(const Object& b, const Identifier& p)
    31   : base(b),
    32     baseIsValue(false),
    33     propertyNameIsNumber(false),
    34     prop(p)
    35 {
    36 }
    37 
    38 Reference::Reference(const Object& b, unsigned p)
    39   : base(b),
    40     propertyNameAsNumber(p),
    41     baseIsValue(false),
    42     propertyNameIsNumber(true)
    43 {
    44 }
    45 
    4630Reference::Reference(ObjectImp *b, const Identifier& p)
    4731  : base(b),
     
    6044}
    6145
    62 Reference::Reference(const Null& b, const Identifier& p)
    63   : base(b),
     46Reference::Reference(const Identifier& p)
     47  : base(jsNull()),
    6448    baseIsValue(false),
    6549    propertyNameIsNumber(false),
     
    6852}
    6953
    70 Reference::Reference(const Null& b, unsigned p)
    71   : base(b),
     54Reference::Reference(unsigned p)
     55  : base(jsNull()),
    7256    propertyNameAsNumber(p),
    7357    baseIsValue(false),
     
    7660}
    7761
    78 Reference Reference::makeValueReference(const Value& v)
     62Reference Reference::makeValueReference(ValueImp *v)
    7963{
    8064  Reference valueRef;
     
    8468}
    8569
    86 Value Reference::getBase(ExecState *exec) const
     70ValueImp *Reference::getBase(ExecState *exec) const
    8771{
    8872  if (baseIsValue) {
    89     Object err = Error::create(exec, ReferenceError, I18N_NOOP("Invalid reference base"));
     73    ObjectImp *err = Error::create(exec, ReferenceError, I18N_NOOP("Invalid reference base"));
    9074    exec->setException(err);
    9175    return err;
     
    10993}
    11094
    111 Value Reference::getValue(ExecState *exec) const
     95ValueImp *Reference::getValue(ExecState *exec) const
    11296{
    11397  if (baseIsValue) {
     
    11599  }
    116100
    117   ValueImp *o = base.imp();
    118   Type t = o ? o->dispatchType() : NullType;
     101  ValueImp *o = base;
     102  Type t = o ? o->type() : NullType;
    119103
    120104  if (t == NullType) {
    121105    UString m = I18N_NOOP("Can't find variable: ") + getPropertyName(exec).ustring();
    122     Object err = Error::create(exec, ReferenceError, m.ascii());
     106    ObjectImp *err = Error::create(exec, ReferenceError, m.ascii());
    123107    exec->setException(err);
    124108    return err;
     
    127111  if (t != ObjectType) {
    128112    UString m = I18N_NOOP("Base is not an object");
    129     Object err = Error::create(exec, ReferenceError, m.ascii());
     113    ObjectImp *err = Error::create(exec, ReferenceError, m.ascii());
    130114    exec->setException(err);
    131115    return err;
     
    137121}
    138122
    139 void Reference::putValue(ExecState *exec, const Value &w)
     123void Reference::putValue(ExecState *exec, ValueImp *w)
    140124{
    141125  if (baseIsValue) {
    142     Object err = Error::create(exec, ReferenceError);
     126    ObjectImp *err = Error::create(exec, ReferenceError);
    143127    exec->setException(err);
    144128    return;
     
    149133#endif
    150134
    151   ValueImp *o = base.imp();
    152   Type t = o ? o->dispatchType() : NullType;
     135  ValueImp *o = base;
     136  Type t = o ? o->type() : NullType;
    153137
    154138  if (t == NullType)
    155     o = exec->lexicalInterpreter()->globalObject().imp();
     139    o = exec->lexicalInterpreter()->globalObject();
    156140
    157141  if (propertyNameIsNumber)
     
    163147{
    164148  if (baseIsValue) {
    165     Object err = Error::create(exec,ReferenceError);
     149    ObjectImp *err = Error::create(exec,ReferenceError);
    166150    exec->setException(err);
    167151    return false;
    168152  }
    169153
    170   ValueImp *o = base.imp();
    171   Type t = o ? o->dispatchType() : NullType;
     154  ValueImp *o = base;
     155  Type t = o ? o->type() : NullType;
    172156
    173157  // The spec doesn't mention what to do if the base is null... just return true
  • trunk/JavaScriptCore/kjs/reference.h

    r10076 r10084  
    2525
    2626#include "identifier.h"
    27 #include "value.h"
     27#include "object.h"
    2828
    2929namespace KJS {
    3030
    31   class Object;
    3231  class ObjectImp;
    3332
     
    3736    friend class ProtectedReference;
    3837  public:
    39     Reference(const Object& b, const Identifier& p);
    40     Reference(const Object& b, unsigned p);
    4138    Reference(ObjectImp *b, const Identifier& p);
    4239    Reference(ObjectImp *b, unsigned p);
    43     Reference(const Null& b, const Identifier& p);
    44     Reference(const Null& b, unsigned p);
    45     static Reference makeValueReference(const Value& v);
     40    Reference(const Identifier& p);
     41    Reference(unsigned p);
     42    static Reference makeValueReference(ValueImp *);
    4643   
    4744    /**
     
    5148     * this method is guaranteed to return either Null() or an Object value.
    5249     */
    53     Value getBase(ExecState *exec) const;
     50    ValueImp *getBase(ExecState *exec) const;
    5451
    5552    /**
     
    6360     * (ECMA 8.7.1)
    6461     */
    65     Value getValue(ExecState *exec) const;
     62    ValueImp *getValue(ExecState *exec) const;
    6663
    6764    /**
     
    6966     * (ECMA 8.7.1)
    7067     */
    71     void putValue(ExecState *exec, const Value &w);
     68    void putValue(ExecState *exec, ValueImp *);
    7269    bool deleteValue(ExecState *exec);
    7370
    74     ValueImp *baseIfMutable() const { return baseIsValue ? 0 : base.imp(); }
     71    ValueImp *baseIfMutable() const { return baseIsValue ? 0 : base; }
    7572
    7673  private:
    7774    Reference() { }
    7875
    79     Value base;
     76    ValueImp *base;
    8077    unsigned propertyNameAsNumber;
    8178    bool baseIsValue;
     
    8380    mutable Identifier prop;
    8481  };
     82
    8583}
    8684
  • trunk/JavaScriptCore/kjs/regexp_object.cpp

    r10076 r10084  
    4646  : ObjectImp(objProto)
    4747{
    48   Value protect(this);
    4948  setInternalValue(String(""));
    5049
     
    6463  : InternalFunctionImp(funcProto), id(i)
    6564{
    66   Value protect(this);
    6765  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
    6866}
     
    7371}
    7472
    75 Value RegExpProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &args)
    76 {
    77   if (!thisObj.inherits(&RegExpImp::info)) {
    78     if (thisObj.inherits(&RegExpPrototypeImp::info)) {
     73ValueImp *RegExpProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
     74{
     75  if (!thisObj->inherits(&RegExpImp::info)) {
     76    if (thisObj->inherits(&RegExpPrototypeImp::info)) {
    7977      switch (id) {
    8078        case ToString: return String("//");
    8179      }
    8280    }
    83     Object err = Error::create(exec,TypeError);
     81    ObjectImp *err = Error::create(exec,TypeError);
    8482    exec->setException(err);
    8583    return err;
    8684  }
    8785
    88   RegExpImp *reimp = static_cast<RegExpImp*>(thisObj.imp());
     86  RegExpImp *reimp = static_cast<RegExpImp*>(thisObj);
    8987  RegExp *re = reimp->regExp();
    90   String s;
     88  UString s;
    9189  UString str;
    9290  switch (id) {
     
    9492  case Test:
    9593  {
    96     s = args[0].toString(exec);
    97     int length = s.value().size();
    98     Value lastIndex = thisObj.get(exec,"lastIndex");
    99     int i = lastIndex.isNull() ? 0 : lastIndex.toInt32(exec);
    100     bool globalFlag = thisObj.get(exec,"global").toBoolean(exec);
     94    s = args[0]->toString(exec);
     95    int length = s.size();
     96    ValueImp *lastIndex = thisObj->get(exec,"lastIndex");
     97    int i = lastIndex->toInt32(exec);
     98    bool globalFlag = thisObj->get(exec,"global")->toBoolean(exec);
    10199    if (!globalFlag)
    102100      i = 0;
    103101    if (i < 0 || i > length) {
    104       thisObj.put(exec,"lastIndex", Number(0), DontDelete | DontEnum);
     102      thisObj->put(exec,"lastIndex", Number(0), DontDelete | DontEnum);
    105103      if (id == Test)
    106104        return Boolean(false);
     
    108106        return Null();
    109107    }
    110     RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->lexicalInterpreter()->builtinRegExp().imp());
    111     int **ovector = regExpObj->registerRegexp( re, s.value() );
    112 
    113     str = re->match(s.value(), i, 0L, ovector);
     108    RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->lexicalInterpreter()->builtinRegExp());
     109    int **ovector = regExpObj->registerRegexp( re, s );
     110
     111    str = re->match(s, i, 0L, ovector);
    114112    regExpObj->setSubPatterns(re->subPatterns());
    115113
     
    120118    {
    121119      if (globalFlag)
    122         thisObj.put(exec,"lastIndex",Number(0), DontDelete | DontEnum);
     120        thisObj->put(exec,"lastIndex",Number(0), DontDelete | DontEnum);
    123121      return Null();
    124122    }
     
    126124    {
    127125      if (globalFlag)
    128         thisObj.put(exec,"lastIndex",Number( (*ovector)[1] ), DontDelete | DontEnum);
     126        thisObj->put(exec,"lastIndex",Number( (*ovector)[1] ), DontDelete | DontEnum);
    129127      return regExpObj->arrayOfMatches(exec,str);
    130128    }
     
    132130  break;
    133131  case ToString:
    134     s = thisObj.get(exec,"source").toString(exec);
     132    s = thisObj->get(exec,"source")->toString(exec);
    135133    str = "/";
    136     str += s.value();
     134    str += s;
    137135    str += "/";
    138     if (thisObj.get(exec,"global").toBoolean(exec)) {
     136    if (thisObj->get(exec,"global")->toBoolean(exec)) {
    139137      str += "g";
    140138    }
    141     if (thisObj.get(exec,"ignoreCase").toBoolean(exec)) {
     139    if (thisObj->get(exec,"ignoreCase")->toBoolean(exec)) {
    142140      str += "i";
    143141    }
    144     if (thisObj.get(exec,"multiline").toBoolean(exec)) {
     142    if (thisObj->get(exec,"multiline")->toBoolean(exec)) {
    145143      str += "m";
    146144    }
     
    173171  : InternalFunctionImp(funcProto), lastOvector(0L), lastNrSubPatterns(0)
    174172{
    175   Value protect(this);
    176173  // ECMA 15.10.5.1 RegExp.prototype
    177174  putDirect(prototypePropertyName, regProto, DontEnum|DontDelete|ReadOnly);
    178175
    179176  // no. of arguments for constructor
    180   putDirect(lengthPropertyName, NumberImp::two(), ReadOnly|DontDelete|DontEnum);
     177  putDirect(lengthPropertyName, jsTwo(), ReadOnly|DontDelete|DontEnum);
    181178}
    182179
     
    195192}
    196193
    197 Object RegExpObjectImp::arrayOfMatches(ExecState *exec, const UString &result) const
     194ObjectImp *RegExpObjectImp::arrayOfMatches(ExecState *exec, const UString &result) const
    198195{
    199196  List list;
     
    205202      int start = lastOvector[2*i];
    206203      if (start == -1)
    207         list.append(UndefinedImp::staticUndefined);
     204        list.append(jsUndefined());
    208205      else {
    209206        UString substring = lastString.substr( start, lastOvector[2*i+1] - start );
     
    211208      }
    212209    }
    213   Object arr = exec->lexicalInterpreter()->builtinArray().construct(exec, list);
    214   arr.put(exec, "index", Number(lastOvector[0]));
    215   arr.put(exec, "input", String(lastString));
     210  ObjectImp *arr = exec->lexicalInterpreter()->builtinArray()->construct(exec, list);
     211  arr->put(exec, "index", Number(lastOvector[0]));
     212  arr->put(exec, "input", String(lastString));
    216213  return arr;
    217214}
    218215
    219 Value RegExpObjectImp::backrefGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
     216ValueImp *RegExpObjectImp::backrefGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
    220217{
    221218  RegExpObjectImp *thisObj = static_cast<RegExpObjectImp *>(slot.slotBase());
     
    254251
    255252// ECMA 15.10.4
    256 Object RegExpObjectImp::construct(ExecState *exec, const List &args)
    257 {
    258   Object o = Object::dynamicCast(args[0]);
    259   if (!o.isNull() && o.inherits(&RegExpImp::info)) {
    260     if (args[1].type() != UndefinedType) {
    261       Object err = Error::create(exec,TypeError);
     253ObjectImp *RegExpObjectImp::construct(ExecState *exec, const List &args)
     254{
     255  ObjectImp *o = args[0]->getObject();
     256  if (o && o->inherits(&RegExpImp::info)) {
     257    if (!args[1]->isUndefined()) {
     258      ObjectImp *err = Error::create(exec,TypeError);
    262259      exec->setException(err);
    263260      return err;
     
    266263  }
    267264 
    268   UString p = args[0].type() == UndefinedType ? UString("") : args[0].toString(exec);
    269   UString flags = args[1].type() == UndefinedType ? UString("") : args[1].toString(exec);
    270 
    271   RegExpPrototypeImp *proto = static_cast<RegExpPrototypeImp*>(exec->lexicalInterpreter()->builtinRegExpPrototype().imp());
     265  UString p = args[0]->isUndefined() ? UString("") : args[0]->toString(exec);
     266  UString flags = args[1]->isUndefined() ? UString("") : args[1]->toString(exec);
     267
     268  RegExpPrototypeImp *proto = static_cast<RegExpPrototypeImp*>(exec->lexicalInterpreter()->builtinRegExpPrototype());
    272269  RegExpImp *dat = new RegExpImp(proto);
    273   Object obj(dat); // protect from GC
    274270
    275271  bool global = (flags.find("g") >= 0);
     
    278274  // TODO: throw a syntax error on invalid flags
    279275
    280   dat->putDirect("global", global ? BooleanImp::staticTrue : BooleanImp::staticFalse, DontDelete | ReadOnly | DontEnum);
    281   dat->putDirect("ignoreCase", ignoreCase ? BooleanImp::staticTrue : BooleanImp::staticFalse, DontDelete | ReadOnly | DontEnum);
    282   dat->putDirect("multiline", multiline ? BooleanImp::staticTrue : BooleanImp::staticFalse, DontDelete | ReadOnly | DontEnum);
    283 
    284   dat->putDirect("source", new StringImp(p), DontDelete | ReadOnly | DontEnum);
    285   dat->putDirect("lastIndex", NumberImp::zero(), DontDelete | DontEnum);
     276  dat->putDirect("global", jsBoolean(global), DontDelete | ReadOnly | DontEnum);
     277  dat->putDirect("ignoreCase", jsBoolean(ignoreCase), DontDelete | ReadOnly | DontEnum);
     278  dat->putDirect("multiline", jsBoolean(multiline), DontDelete | ReadOnly | DontEnum);
     279
     280  dat->putDirect("source", jsString(p), DontDelete | ReadOnly | DontEnum);
     281  dat->putDirect("lastIndex", jsZero(), DontDelete | DontEnum);
    286282
    287283  int reflags = RegExp::None;
     
    294290  dat->setRegExp(new RegExp(p, reflags));
    295291
    296   return obj;
     292  return dat;
    297293}
    298294
     
    303299
    304300// ECMA 15.10.3
    305 Value RegExpObjectImp::call(ExecState *exec, Object &/*thisObj*/,
     301ValueImp *RegExpObjectImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/,
    306302                            const List &args)
    307303{
  • trunk/JavaScriptCore/kjs/regexp_object.h

    r10076 r10084  
    4444
    4545    virtual bool implementsCall() const;
    46     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     46    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    4747
    4848    enum { Exec, Test, ToString };
     
    7171    virtual ~RegExpObjectImp();
    7272    virtual bool implementsConstruct() const;
    73     virtual Object construct(ExecState *exec, const List &args);
     73    virtual ObjectImp *construct(ExecState *exec, const List &args);
    7474    virtual bool implementsCall() const;
    75     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     75    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    7676
    7777    virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
    7878    int ** registerRegexp( const RegExp* re, const UString& s );
    7979    void setSubPatterns(int num) { lastNrSubPatterns = num; }
    80     Object arrayOfMatches(ExecState *exec, const UString &result) const;
     80    ObjectImp *arrayOfMatches(ExecState *exec, const UString &result) const;
    8181  private:
    82     static Value backrefGetter(ExecState *exec, const Identifier&, const PropertySlot& slot);
     82    static ValueImp *backrefGetter(ExecState *exec, const Identifier&, const PropertySlot& slot);
    8383 
    8484    UString lastString;
  • trunk/JavaScriptCore/kjs/string_object.cpp

    r10076 r10084  
    5151}
    5252
    53 Value StringInstanceImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot &slot)
    54 {
    55     return Value(static_cast<StringInstanceImp *>(slot.slotBase())->internalValue().toString(exec).size());
    56 }
    57 
    58 Value StringInstanceImp::indexGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot &slot)
    59 {
    60     const UChar c = static_cast<StringInstanceImp *>(slot.slotBase())->internalValue().toString(exec)[slot.index()];
    61     return Value(UString(&c, 1));
     53ValueImp *StringInstanceImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot &slot)
     54{
     55    return jsNumber(static_cast<StringInstanceImp *>(slot.slotBase())->internalValue()->toString(exec).size());
     56}
     57
     58ValueImp *StringInstanceImp::indexGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot &slot)
     59{
     60    const UChar c = static_cast<StringInstanceImp *>(slot.slotBase())->internalValue()->toString(exec)[slot.index()];
     61    return jsString(UString(&c, 1));
    6262}
    6363
     
    7272  const unsigned index = propertyName.toArrayIndex(&ok);
    7373  if (ok) {
    74     const UString s = internalValue().toString(exec);
     74    const UString s = internalValue()->toString(exec);
    7575    const unsigned length = s.size();
    7676    if (index >= length)
     
    8383}
    8484
    85 void StringInstanceImp::put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr)
     85void StringInstanceImp::put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr)
    8686{
    8787  if (propertyName == lengthPropertyName)
     
    143143  : StringInstanceImp(objProto)
    144144{
    145   Value protect(this);
    146145  // The constructor will be added later, after StringObjectImp has been built
    147   putDirect(lengthPropertyName, NumberImp::zero(), DontDelete|ReadOnly|DontEnum);
    148 
     146  putDirect(lengthPropertyName, jsZero(), DontDelete|ReadOnly|DontEnum);
    149147}
    150148
     
    158156StringProtoFuncImp::StringProtoFuncImp(ExecState *exec, int i, int len)
    159157  : InternalFunctionImp(
    160     static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype().imp())
     158    static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype())
    161159    ), id(i)
    162160{
    163   Value protect(this);
    164161  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
    165162}
     
    172169static inline bool regExpIsGlobal(RegExpImp *regExp, ExecState *exec)
    173170{
    174     Value globalProperty = regExp->get(exec,"global");
    175     return globalProperty.type() != UndefinedType && globalProperty.toBoolean(exec);
     171    ValueImp *globalProperty = regExp->get(exec,"global");
     172    return !globalProperty->isUndefined() && globalProperty->toBoolean(exec);
    176173}
    177174
     
    260257}
    261258
    262 static Value replace(ExecState *exec, const UString &source, const Value &pattern, const Value &replacement)
     259static ValueImp *replace(ExecState *exec, const UString &source, ValueImp *pattern, ValueImp *replacement)
    263260{
    264261  ObjectImp *replacementFunction = 0;
    265262  UString replacementString;
    266263
    267   if (replacement.type() == ObjectType && replacement.toObject(exec).implementsCall())
    268     replacementFunction = replacement.toObject(exec).imp();
     264  if (replacement->isObject() && replacement->toObject(exec)->implementsCall())
     265    replacementFunction = replacement->toObject(exec);
    269266  else
    270     replacementString = replacement.toString(exec);
    271 
    272   if (pattern.type() == ObjectType && pattern.toObject(exec).inherits(&RegExpImp::info)) {
    273     RegExpImp* imp = static_cast<RegExpImp *>( pattern.toObject(exec).imp() );
     267    replacementString = replacement->toString(exec);
     268
     269  if (pattern->isObject() && pattern->toObject(exec)->inherits(&RegExpImp::info)) {
     270    RegExpImp* imp = static_cast<RegExpImp *>( pattern->toObject(exec) );
    274271    RegExp *reg = imp->regExp();
    275272    bool global = regExpIsGlobal(imp, exec);
    276273
    277     RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->lexicalInterpreter()->builtinRegExp().imp());
     274    RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->lexicalInterpreter()->builtinRegExp());
    278275
    279276    int matchIndex = 0;
     
    303300          List args;
    304301
    305           args.append(Value(matchString));
     302          args.append(jsString(matchString));
    306303         
    307304          for (unsigned i = 0; i < reg->subPatterns(); i++) {
     
    309306              int matchLen = (*ovector)[(i + 1) * 2 + 1] - matchStart;
    310307             
    311               args.append(Value(source.substr(matchStart, matchLen)));
     308              args.append(jsString(source.substr(matchStart, matchLen)));
    312309          }
    313310         
    314           args.append(Value(completeMatchStart));
    315           args.append(Value(source));
     311          args.append(jsNumber(completeMatchStart));
     312          args.append(jsString(source));
    316313
    317314          replacementString = replacementFunction->call(exec, exec->dynamicInterpreter()->globalObject(),
    318                                                         args).toString(exec);
     315                                                        args)->toString(exec);
    319316      }
    320317     
     
    345342 
    346343  // First arg is a string
    347   UString patternString = pattern.toString(exec);
     344  UString patternString = pattern->toString(exec);
    348345  int matchPos = source.find(patternString);
    349346  int matchLen = patternString.size();
     
    355352      List args;
    356353     
    357       args.append(Value(source.substr(matchPos, matchLen)));
    358       args.append(Value(matchPos));
    359       args.append(Value(source));
     354      args.append(jsString(source.substr(matchPos, matchLen)));
     355      args.append(jsNumber(matchPos));
     356      args.append(jsString(source));
    360357     
    361358      replacementString = replacementFunction->call(exec, exec->dynamicInterpreter()->globalObject(),
    362                                                     args).toString(exec);
     359                                                    args)->toString(exec);
    363360  }
    364361
     
    367364
    368365// ECMA 15.5.4.2 - 15.5.4.20
    369 Value StringProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &args)
    370 {
    371   Value result;
     366ValueImp *StringProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
     367{
     368  ValueImp *result = NULL;
    372369
    373370  // toString and valueOf are no generic function.
    374371  if (id == ToString || id == ValueOf) {
    375     if (thisObj.isNull() || !thisObj.inherits(&StringInstanceImp::info)) {
    376       Object err = Error::create(exec,TypeError);
     372    if (!thisObj || !thisObj->inherits(&StringInstanceImp::info)) {
     373      ObjectImp *err = Error::create(exec,TypeError);
    377374      exec->setException(err);
    378375      return err;
    379376    }
    380377
    381     return String(thisObj.internalValue().toString(exec));
     378    return String(thisObj->internalValue()->toString(exec));
    382379  }
    383380
     
    387384  double d = 0.0;
    388385
    389   UString s = thisObj.toString(exec);
     386  UString s = thisObj->toString(exec);
    390387
    391388  int len = s.size();
    392   Value a0 = args[0];
    393   Value a1 = args[1];
     389  ValueImp *a0 = args[0];
     390  ValueImp *a1 = args[1];
    394391
    395392  switch (id) {
     
    401398    // Other browsers treat an omitted parameter as 0 rather than NaN.
    402399    // That doesn't match the ECMA standard, but is needed for site compatibility.
    403     dpos = a0.isA(UndefinedType) ? 0 : a0.toInteger(exec);
     400    dpos = a0->isUndefined() ? 0 : a0->toInteger(exec);
    404401    if (dpos >= 0 && dpos < len) // false for NaN
    405402      u = s.substr(static_cast<int>(dpos), 1);
     
    411408    // Other browsers treat an omitted parameter as 0 rather than NaN.
    412409    // That doesn't match the ECMA standard, but is needed for site compatibility.
    413     dpos = a0.isA(UndefinedType) ? 0 : a0.toInteger(exec);
     410    dpos = a0->isUndefined() ? 0 : a0->toInteger(exec);
    414411    if (dpos >= 0 && dpos < len) // false for NaN
    415412      result = Number(s[static_cast<int>(dpos)].unicode());
    416413    else
    417       result = Number(NaN);
     414      result = jsNaN();
    418415    break;
    419416  case Concat: {
    420417    ListIterator it = args.begin();
    421418    for ( ; it != args.end() ; ++it) {
    422         s += it->dispatchToString(exec);
     419        s += it->toString(exec);
    423420    }
    424421    result = String(s);
     
    426423  }
    427424  case IndexOf:
    428     u2 = a0.toString(exec);
    429     if (a1.type() == UndefinedType)
     425    u2 = a0->toString(exec);
     426    if (a1->isUndefined())
    430427      dpos = 0;
    431428    else {
    432       dpos = a1.toInteger(exec);
     429      dpos = a1->toInteger(exec);
    433430      if (dpos >= 0) { // false for NaN
    434431        if (dpos > len)
     
    440437    break;
    441438  case LastIndexOf:
    442     u2 = a0.toString(exec);
    443     d = a1.toNumber(exec);
    444     if (a1.type() == UndefinedType || KJS::isNaN(d))
     439    u2 = a0->toString(exec);
     440    d = a1->toNumber(exec);
     441    if (a1->isUndefined() || KJS::isNaN(d))
    445442      dpos = len;
    446443    else {
    447       dpos = a1.toInteger(exec);
     444      dpos = a1->toInteger(exec);
    448445      if (dpos >= 0) { // false for NaN
    449446        if (dpos > len)
     
    459456    RegExp *reg, *tmpReg = 0;
    460457    RegExpImp *imp = 0;
    461     if (a0.isA(ObjectType) && a0.toObject(exec).inherits(&RegExpImp::info))
     458    if (a0->isObject() && a0->getObject()->inherits(&RegExpImp::info))
    462459    {
    463       imp = static_cast<RegExpImp *>( a0.toObject(exec).imp() );
     460      imp = static_cast<RegExpImp *>(a0);
    464461      reg = imp->regExp();
    465462    }
     
    470467       *  replaced with the result of the expression new RegExp(regexp).
    471468       */
    472       reg = tmpReg = new RegExp(a0.toString(exec), RegExp::None);
    473     }
    474     RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->lexicalInterpreter()->builtinRegExp().imp());
     469      reg = tmpReg = new RegExp(a0->toString(exec), RegExp::None);
     470    }
     471    RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->lexicalInterpreter()->builtinRegExp());
    475472    int **ovector = regExpObj->registerRegexp(reg, u);
    476473    UString mstr = reg->match(u, -1, &pos, ovector);
     
    493490        while (pos >= 0) {
    494491          if (mstr.isNull())
    495             list.append(UndefinedImp::staticUndefined);
     492            list.append(jsUndefined());
    496493          else
    497494            list.append(String(mstr));
     
    509506          result = Null();
    510507        } else {
    511           result = exec->lexicalInterpreter()->builtinArray().construct(exec, list);
     508          result = exec->lexicalInterpreter()->builtinArray()->construct(exec, list);
    512509        }
    513510      }
     
    522519    {
    523520        // The arg processing is very much like ArrayProtoFunc::Slice
    524         double begin = args[0].toInteger(exec);
     521        double begin = args[0]->toInteger(exec);
    525522        if (begin >= 0) { // false for NaN
    526523          if (begin > len)
     
    532529        }
    533530        double end = len;
    534         if (args[1].type() != UndefinedType) {
    535           end = args[1].toInteger(exec);
     531        if (!args[1]->isUndefined()) {
     532          end = args[1]->toInteger(exec);
    536533          if (end >= 0) { // false for NaN
    537534            if (end > len)
     
    548545    }
    549546    case Split: {
    550     Object constructor = exec->lexicalInterpreter()->builtinArray();
    551     Object res = Object::dynamicCast(constructor.construct(exec,List::empty()));
     547    ObjectImp *constructor = exec->lexicalInterpreter()->builtinArray();
     548    ObjectImp *res = static_cast<ObjectImp *>(constructor->construct(exec,List::empty()));
    552549    result = res;
    553550    u = s;
    554551    i = p0 = 0;
    555     uint32_t limit = a1.type() == UndefinedType ? 0xFFFFFFFFU : a1.toUInt32(exec);
    556     if (a0.type() == ObjectType && Object::dynamicCast(a0).inherits(&RegExpImp::info)) {
    557       Object obj0 = Object::dynamicCast(a0);
    558       RegExp reg(obj0.get(exec,"source").toString(exec));
     552    uint32_t limit = a1->isUndefined() ? 0xFFFFFFFFU : a1->toUInt32(exec);
     553    if (a0->isObject() && static_cast<ObjectImp *>(a0)->inherits(&RegExpImp::info)) {
     554      ObjectImp *obj0 = static_cast<ObjectImp *>(a0);
     555      RegExp reg(obj0->get(exec,"source")->toString(exec));
    559556      if (u.isEmpty() && !reg.match(u, 0).isNull()) {
    560557        // empty string matched by regexp -> empty array
    561         res.put(exec,lengthPropertyName, Number(0));
     558        res->put(exec,lengthPropertyName, Number(0));
    562559        break;
    563560      }
     
    573570        pos = mpos + (mstr.isEmpty() ? 1 : mstr.size());
    574571        if (mpos != p0 || !mstr.isEmpty()) {
    575           res.put(exec,i, String(u.substr(p0, mpos-p0)));
     572          res->put(exec,i, String(u.substr(p0, mpos-p0)));
    576573          p0 = mpos + mstr.size();
    577574          i++;
     
    579576      }
    580577    } else {
    581       u2 = a0.toString(exec);
     578      u2 = a0->toString(exec);
    582579      if (u2.isEmpty()) {
    583580        if (u.isEmpty()) {
     
    587584        } else {
    588585          while (static_cast<uint32_t>(i) != limit && i < u.size()-1)
    589             res.put(exec, i++, String(u.substr(p0++, 1)));
     586            res->put(exec, i++, String(u.substr(p0++, 1)));
    590587        }
    591588      } else {
    592589        while (static_cast<uint32_t>(i) != limit && (pos = u.find(u2, p0)) >= 0) {
    593           res.put(exec, i, String(u.substr(p0, pos-p0)));
     590          res->put(exec, i, String(u.substr(p0, pos-p0)));
    594591          p0 = pos + u2.size();
    595592          i++;
     
    599596    // add remaining string, if any
    600597    if (static_cast<uint32_t>(i) != limit)
    601       res.put(exec, i++, String(u.substr(p0)));
    602     res.put(exec,lengthPropertyName, Number(i));
     598      res->put(exec, i++, String(u.substr(p0)));
     599    res->put(exec,lengthPropertyName, Number(i));
    603600    }
    604601    break;
    605602  case Substr: {
    606     double d = a0.toInteger(exec);
    607     double d2 = a1.toInteger(exec);
     603    double d = a0->toInteger(exec);
     604    double d2 = a1->toInteger(exec);
    608605    if (!(d >= 0)) { // true for NaN
    609606      d += len;
     
    623620  }
    624621  case Substring: {
    625     double start = a0.toNumber(exec);
    626     double end = a1.toNumber(exec);
     622    double start = a0->toNumber(exec);
     623    double end = a1->toNumber(exec);
    627624    if (KJS::isNaN(start))
    628625      start = 0;
     
    637634    if (end > len)
    638635      end = len;
    639     if (a1.type() == UndefinedType)
     636    if (a1->isUndefined())
    640637      end = len;
    641638    if (start > end) {
     
    690687    break;
    691688  case Fontcolor:
    692     result = String("<font color=\"" + a0.toString(exec) + "\">" + s + "</font>");
     689    result = String("<font color=\"" + a0->toString(exec) + "\">" + s + "</font>");
    693690    break;
    694691  case Fontsize:
    695     result = String("<font size=\"" + a0.toString(exec) + "\">" + s + "</font>");
     692    result = String("<font size=\"" + a0->toString(exec) + "\">" + s + "</font>");
    696693    break;
    697694  case Anchor:
    698     result = String("<a name=\"" + a0.toString(exec) + "\">" + s + "</a>");
     695    result = String("<a name=\"" + a0->toString(exec) + "\">" + s + "</a>");
    699696    break;
    700697  case Link:
    701     result = String("<a href=\"" + a0.toString(exec) + "\">" + s + "</a>");
     698    result = String("<a href=\"" + a0->toString(exec) + "\">" + s + "</a>");
    702699    break;
    703700#endif
     
    714711  : InternalFunctionImp(funcProto)
    715712{
    716   Value protect(this);
    717713  // ECMA 15.5.3.1 String.prototype
    718714  putDirect(prototypePropertyName, stringProto, DontEnum|DontDelete|ReadOnly);
     
    722718
    723719  // no. of arguments for constructor
    724   putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum);
     720  putDirect(lengthPropertyName, jsOne(), ReadOnly|DontDelete|DontEnum);
    725721}
    726722
     
    732728
    733729// ECMA 15.5.2
    734 Object StringObjectImp::construct(ExecState *exec, const List &args)
    735 {
    736   ObjectImp *proto = exec->lexicalInterpreter()->builtinStringPrototype().imp();
     730ObjectImp *StringObjectImp::construct(ExecState *exec, const List &args)
     731{
     732  ObjectImp *proto = exec->lexicalInterpreter()->builtinStringPrototype();
    737733  if (args.size() == 0)
    738     return Object(new StringInstanceImp(proto));
    739   return Object(new StringInstanceImp(proto, args.begin()->dispatchToString(exec)));
     734    return new StringInstanceImp(proto);
     735  return new StringInstanceImp(proto, args.begin()->toString(exec));
    740736}
    741737
     
    746742
    747743// ECMA 15.5.1
    748 Value StringObjectImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
     744ValueImp *StringObjectImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
    749745{
    750746  if (args.isEmpty())
    751747    return String("");
    752748  else {
    753     Value v = args[0];
    754     return String(v.toString(exec));
     749    ValueImp *v = args[0];
     750    return String(v->toString(exec));
    755751  }
    756752}
     
    762758  : InternalFunctionImp(funcProto)
    763759{
    764   Value protect(this);
    765   putDirect(lengthPropertyName, NumberImp::one(), DontDelete|ReadOnly|DontEnum);
     760  putDirect(lengthPropertyName, jsOne(), DontDelete|ReadOnly|DontEnum);
    766761}
    767762
     
    771766}
    772767
    773 Value StringObjectFuncImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
     768ValueImp *StringObjectFuncImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
    774769{
    775770  UString s;
  • trunk/JavaScriptCore/kjs/string_object.h

    r10076 r10084  
    3434
    3535    virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
    36     virtual void put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr = None);
     36    virtual void put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr = None);
    3737    virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
    3838
     
    4040    static const ClassInfo info;
    4141  private:
    42     static Value lengthGetter(ExecState *exec, const Identifier&, const PropertySlot &slot);
    43     static Value indexGetter(ExecState *exec, const Identifier&, const PropertySlot &slot);
     42    static ValueImp *lengthGetter(ExecState *exec, const Identifier&, const PropertySlot &slot);
     43    static ValueImp *indexGetter(ExecState *exec, const Identifier&, const PropertySlot &slot);
    4444  };
    4545
     
    7070
    7171    virtual bool implementsCall() const;
    72     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     72    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    7373
    7474    enum { ToString, ValueOf, CharAt, CharCodeAt, Concat, IndexOf, LastIndexOf,
     
    9797
    9898    virtual bool implementsConstruct() const;
    99     virtual Object construct(ExecState *exec, const List &args);
     99    virtual ObjectImp *construct(ExecState *exec, const List &args);
    100100    virtual bool implementsCall() const;
    101     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     101    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    102102  };
    103103
     
    112112    StringObjectFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto);
    113113    virtual bool implementsCall() const;
    114     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     114    virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    115115  };
    116116
  • trunk/JavaScriptCore/kjs/testkjs.cpp

    r9781 r10084  
    3838  TestFunctionImp(int i, int length);
    3939  virtual bool implementsCall() const { return true; }
    40   virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     40  virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    4141
    4242  enum { Print, Debug, Quit, GC };
     
    5151}
    5252
    53 Value TestFunctionImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
     53ValueImp *TestFunctionImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
    5454{
    5555  switch (id) {
    5656  case Print:
    5757  case Debug:
    58     fprintf(stderr,"--> %s\n",args[0].toString(exec).ascii());
     58    fprintf(stderr,"--> %s\n",args[0]->toString(exec).ascii());
    5959    return Undefined();
    6060  case Quit:
     
    7777  VersionFunctionImp() : ObjectImp() {}
    7878  virtual bool implementsCall() const { return true; }
    79   virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     79  virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    8080};
    8181
    82 Value VersionFunctionImp::call(ExecState */*exec*/, Object &/*thisObj*/, const List &/*args*/)
     82ValueImp *VersionFunctionImp::callAsFunction(ExecState */*exec*/, ObjectImp */*thisObj*/, const List &/*args*/)
    8383{
    8484  // We need this function for compatibility with the Mozilla JS tests but for now
     
    104104    Interpreter::lock();
    105105
    106     Object global(new GlobalImp());
     106    ObjectImp *global(new GlobalImp());
    107107
    108108    // create interpreter
    109109    Interpreter interp(global);
    110110    // add debug() function
    111     global.put(interp.globalExec(), "debug", Object(new TestFunctionImp(TestFunctionImp::Debug,1)));
     111    global->put(interp.globalExec(), "debug", new TestFunctionImp(TestFunctionImp::Debug, 1));
    112112    // add "print" for compatibility with the mozilla js shell
    113     global.put(interp.globalExec(), "print", Object(new TestFunctionImp(TestFunctionImp::Print,1)));
     113    global->put(interp.globalExec(), "print", new TestFunctionImp(TestFunctionImp::Print, 1));
    114114    // add "quit" for compatibility with the mozilla js shell
    115     global.put(interp.globalExec(), "quit", Object(new TestFunctionImp(TestFunctionImp::Quit,0)));
     115    global->put(interp.globalExec(), "quit", new TestFunctionImp(TestFunctionImp::Quit, 0));
    116116    // add "gc" for compatibility with the mozilla js shell
    117     global.put(interp.globalExec(), "gc", Object(new TestFunctionImp(TestFunctionImp::GC,0)));
     117    global->put(interp.globalExec(), "gc", new TestFunctionImp(TestFunctionImp::GC, 0));
    118118    // add "version" for compatibility with the mozilla js shell
    119     global.put(interp.globalExec(), "version", Object(new VersionFunctionImp()));
     119    global->put(interp.globalExec(), "version", new VersionFunctionImp());
    120120
    121121    for (int i = 1; i < argc; i++) {
     
    151151      if (comp.complType() == Throw) {
    152152        ExecState *exec = interp.globalExec();
    153         Value exVal = comp.value();
    154         char *msg = exVal.toString(exec).ascii();
     153        ValueImp *exVal = comp.value();
     154        char *msg = exVal->toString(exec).ascii();
    155155        int lineno = -1;
    156         if (exVal.type() == ObjectType) {
    157           Value lineVal = Object::dynamicCast(exVal).get(exec,"line");
    158           if (lineVal.type() == NumberType)
    159             lineno = int(lineVal.toNumber(exec));
     156        if (exVal->isObject()) {
     157          ValueImp *lineVal = static_cast<ObjectImp *>(exVal)->get(exec,"line");
     158          if (lineVal->isNumber())
     159            lineno = int(lineVal->toNumber(exec));
    160160        }
    161161        if (lineno != -1)
     
    166166      }
    167167      else if (comp.complType() == ReturnValue) {
    168         char *msg = comp.value().toString(interp.globalExec()).ascii();
     168        char *msg = comp.value()->toString(interp.globalExec()).ascii();
    169169        fprintf(stderr,"Return value: %s\n",msg);
    170170      }
  • trunk/JavaScriptCore/kjs/value.cpp

    r9768 r10084  
    1 // -*- c-basic-offset: 2 -*-
    21/*
    32 *  This file is part of the KDE libraries
     
    2423
    2524#include "value.h"
     25
    2626#include "object.h"
    2727#include "types.h"
    2828#include "interpreter.h"
    2929
    30 #include <assert.h>
    3130#include <math.h>
    3231#include <stdio.h>
     
    3837#include "error_object.h"
    3938#include "nodes.h"
    40 #include "simple_number.h"
    4139
    4240namespace KJS {
    4341
    44 // ----------------------------- ValueImp -------------------------------------
    45 
    46 void ValueImp::mark()
    47 {
    48   _marked = true;
    49 }
    50 
    51 void* ValueImp::operator new(size_t s)
    52 {
    53   return Collector::allocate(s);
    54 }
    55 
    56 void ValueImp::operator delete(void*)
    57 {
    58   // Do nothing. So far.
    59 }
    60 
    61 bool ValueImp::toUInt32(unsigned&) const
    62 {
    63   return false;
     42AllocatedValueImp *ConstantValues::undefined = NULL;
     43AllocatedValueImp *ConstantValues::null = NULL;
     44AllocatedValueImp *ConstantValues::jsTrue = NULL;
     45AllocatedValueImp *ConstantValues::jsFalse = NULL;
     46AllocatedValueImp *ConstantValues::NaN = NULL;
     47
     48static const double D16 = 65536;
     49static const double D32 = 4294967296.0;
     50
     51void *AllocatedValueImp::operator new(size_t size)
     52{
     53    return Collector::allocate(size);
     54}
     55
     56bool AllocatedValueImp::getUInt32(unsigned&) const
     57{
     58    return false;
    6459}
    6560
     
    6762double ValueImp::toInteger(ExecState *exec) const
    6863{
    69   uint32_t i;
    70   if (dispatchToUInt32(i))
    71     return i;
    72   return roundValue(exec, Value(const_cast<ValueImp*>(this)));
     64    uint32_t i;
     65    if (getUInt32(i))
     66        return i;
     67    return roundValue(exec, const_cast<ValueImp*>(this));
    7368}
    7469
    7570int32_t ValueImp::toInt32(ExecState *exec) const
    7671{
    77   uint32_t i;
    78   if (dispatchToUInt32(i))
    79     return i;
    80 
    81   double d = roundValue(exec, Value(const_cast<ValueImp*>(this)));
    82   if (isNaN(d) || isInf(d))
    83     return 0;
    84   double d32 = fmod(d, D32);
    85 
    86   if (d32 >= D32 / 2.0)
    87     d32 -= D32;
    88   else if (d32 < -D32 / 2.0)
    89     d32 += D32;
    90 
    91   return static_cast<int32_t>(d32);
     72    uint32_t i;
     73    if (getUInt32(i))
     74        return i;
     75
     76    double d = roundValue(exec, const_cast<ValueImp*>(this));
     77    if (isNaN(d) || isInf(d))
     78        return 0;
     79    double d32 = fmod(d, D32);
     80
     81    if (d32 >= D32 / 2)
     82        d32 -= D32;
     83    else if (d32 < -D32 / 2)
     84        d32 += D32;
     85
     86    return static_cast<int32_t>(d32);
    9287}
    9388
    9489uint32_t ValueImp::toUInt32(ExecState *exec) const
    9590{
    96   uint32_t i;
    97   if (dispatchToUInt32(i))
    98     return i;
    99 
    100   double d = roundValue(exec, Value(const_cast<ValueImp*>(this)));
    101   if (isNaN(d) || isInf(d))
    102     return 0;
    103   double d32 = fmod(d, D32);
    104 
    105   if (d32 < 0)
    106     d32 += D32;
    107 
    108   return static_cast<uint32_t>(d32);
     91    uint32_t i;
     92    if (getUInt32(i))
     93        return i;
     94
     95    double d = roundValue(exec, const_cast<ValueImp*>(this));
     96    if (isNaN(d) || isInf(d))
     97        return 0;
     98    double d32 = fmod(d, D32);
     99
     100    if (d32 < 0)
     101        d32 += D32;
     102
     103    return static_cast<uint32_t>(d32);
    109104}
    110105
    111106uint16_t ValueImp::toUInt16(ExecState *exec) const
    112107{
    113   uint32_t i;
    114   if (dispatchToUInt32(i))
    115     return i;
    116 
    117   double d = roundValue(exec, Value(const_cast<ValueImp*>(this)));
    118   if (isNaN(d) || isInf(d))
    119     return 0;
    120   double d16 = fmod(d, D16);
    121 
    122   if (d16 < 0)
    123     d16 += D16;
    124 
    125   return static_cast<uint16_t>(d16);
    126 }
    127 
    128 Object ValueImp::dispatchToObject(ExecState *exec) const
    129 {
    130   if (SimpleNumber::is(this))
    131     return static_cast<const NumberImp *>(this)->NumberImp::toObject(exec);
    132   return toObject(exec);
    133 }
    134 
    135 bool ValueImp::isUndefinedOrNull() const
    136 {
    137     switch (dispatchType()) {
    138         case BooleanType:
    139         case NumberType:
    140         case ObjectType:
    141         case StringType:
    142             break;
    143         case NullType:
    144         case UndefinedType:
    145             return true;
    146         case UnspecifiedType:
    147             assert(false);
    148             break;
    149     }
    150     return false;
    151 }
    152 
    153 bool ValueImp::isBoolean(bool &booleanValue) const
     108    uint32_t i;
     109    if (getUInt32(i))
     110        return i;
     111
     112    double d = roundValue(exec, const_cast<ValueImp*>(this));
     113    if (isNaN(d) || isInf(d))
     114        return 0;
     115    double d16 = fmod(d, D16);
     116
     117    if (d16 < 0)
     118        d16 += D16;
     119
     120    return static_cast<uint16_t>(d16);
     121}
     122
     123ObjectImp *ValueImp::toObject(ExecState *exec) const
     124{
     125    if (SimpleNumber::is(this))
     126        return static_cast<const NumberImp *>(this)->NumberImp::toObject(exec);
     127    return downcast()->toObject(exec);
     128}
     129
     130bool AllocatedValueImp::getBoolean(bool &booleanValue) const
    154131{
    155132    if (!isBoolean())
     
    159136}
    160137
    161 bool ValueImp::isNumber(double &numericValue) const
     138bool AllocatedValueImp::getNumber(double &numericValue) const
    162139{
    163140    if (!isNumber())
     
    167144}
    168145
    169 bool ValueImp::isString(UString &stringValue) const
     146double AllocatedValueImp::getNumber() const
     147{
     148    return isNumber() ? static_cast<const NumberImp *>(this)->value() : NaN;
     149}
     150
     151bool AllocatedValueImp::getString(UString &stringValue) const
    170152{
    171153    if (!isString())
     
    175157}
    176158
    177 UString ValueImp::asString() const
     159UString AllocatedValueImp::getString() const
    178160{
    179161    return isString() ? static_cast<const StringImp *>(this)->value() : UString();
    180162}
    181163
    182 bool ValueImp::isObject(ObjectImp *&object)
    183 {
    184     if (!isObject())
    185         return false;
    186     object = static_cast<ObjectImp *>(this);
    187     return true;
    188 }
    189 
    190 // ------------------------------ Value ----------------------------------------
    191 
    192 Value::Value(bool b) : rep(b ? BooleanImp::staticTrue : BooleanImp::staticFalse) { }
    193 
    194 Value::Value(int i)
    195     : rep(SimpleNumber::fits(i) ? SimpleNumber::make(i) : new NumberImp(static_cast<double>(i))) { }
    196 
    197 Value::Value(unsigned u)
    198     : rep(SimpleNumber::fits(u) ? SimpleNumber::make(u) : new NumberImp(static_cast<double>(u))) { }
    199 
    200 Value::Value(double d)
    201     : rep(SimpleNumber::fits(d)
    202         ? SimpleNumber::make(static_cast<long>(d))
    203         : (KJS::isNaN(d) ? NumberImp::staticNaN : new NumberImp(d)))
    204 { }
    205 
    206 Value::Value(double d, bool knownToBeInteger)
    207     : rep((knownToBeInteger ? SimpleNumber::integerFits(d) : SimpleNumber::fits(d))
    208         ? SimpleNumber::make(static_cast<long>(d))
    209         : ((!knownToBeInteger && KJS::isNaN(d)) ? NumberImp::staticNaN : new NumberImp(d)))
    210 { }
    211 
    212 Value::Value(long l)
    213     : rep(SimpleNumber::fits(l) ? SimpleNumber::make(l) : new NumberImp(static_cast<double>(l))) { }
    214 
    215 Value::Value(unsigned long l)
    216     : rep(SimpleNumber::fits(l) ? SimpleNumber::make(l) : new NumberImp(static_cast<double>(l))) { }
    217 
    218 Value::Value(const char *s) : rep(new StringImp(s)) { }
    219 
    220 Value::Value(const UString &s) : rep(new StringImp(s)) { }
    221 
    222 // ------------------------------ Undefined ------------------------------------
    223 
    224 Undefined::Undefined() : Value(UndefinedImp::staticUndefined)
    225 {
    226 }
    227 
    228 Undefined Undefined::dynamicCast(const Value &v)
    229 {
    230   if (v.isNull() || v.type() != UndefinedType)
    231     return Undefined(0);
    232 
    233   return Undefined();
    234 }
    235 
    236 // ------------------------------ Null -----------------------------------------
    237 
    238 Null::Null() : Value(NullImp::staticNull)
    239 {
    240 }
    241 
    242 Null Null::dynamicCast(const Value &v)
    243 {
    244   if (v.isNull() || v.type() != NullType)
    245     return Null(0);
    246 
    247   return Null();
    248 }
    249 
    250 // ------------------------------ Boolean --------------------------------------
    251 
    252 Boolean::Boolean(bool b)
    253   : Value(b ? BooleanImp::staticTrue : BooleanImp::staticFalse)
    254 {
    255 }
    256 
    257 bool Boolean::value() const
    258 {
    259   assert(rep);
    260   return ((BooleanImp*)rep)->value();
    261 }
    262 
    263 Boolean Boolean::dynamicCast(const Value &v)
    264 {
    265   if (v.isNull() || v.type() != BooleanType)
    266     return static_cast<BooleanImp*>(0);
    267 
    268   return static_cast<BooleanImp*>(v.imp());
    269 }
    270 
    271 // ------------------------------ String ---------------------------------------
    272 
    273 String::String(const UString &s) : Value(new StringImp(s))
    274 {
    275 }
    276 
    277 UString String::value() const
    278 {
    279   assert(rep);
    280   return ((StringImp*)rep)->value();
    281 }
    282 
    283 String String::dynamicCast(const Value &v)
    284 {
    285   if (v.isNull() || v.type() != StringType)
    286     return String(0);
    287 
    288   return String(static_cast<StringImp*>(v.imp()));
    289 }
    290 
    291 // ------------------------------ Number ---------------------------------------
    292 
    293 Number::Number(int i)
    294   : Value(SimpleNumber::fits(i) ? SimpleNumber::make(i) : new NumberImp(static_cast<double>(i))) { }
    295 
    296 Number::Number(unsigned int u)
    297   : Value(SimpleNumber::fits(u) ? SimpleNumber::make(u) : new NumberImp(static_cast<double>(u))) { }
    298 
    299 Number::Number(double d)
    300   : Value(SimpleNumber::fits(d)
    301         ? SimpleNumber::make(static_cast<long>(d))
    302         : (KJS::isNaN(d) ? NumberImp::staticNaN : new NumberImp(d)))
    303 { }
    304 
    305 Number::Number(double d, bool knownToBeInteger)
    306   : Value((knownToBeInteger ? SimpleNumber::integerFits(d) : SimpleNumber::fits(d))
    307         ? SimpleNumber::make(static_cast<long>(d))
    308         : ((!knownToBeInteger && KJS::isNaN(d)) ? NumberImp::staticNaN : new NumberImp(d)))
    309 { }
    310 
    311 Number::Number(long int l)
    312   : Value(SimpleNumber::fits(l) ? SimpleNumber::make(l) : new NumberImp(static_cast<double>(l))) { }
    313 
    314 Number::Number(long unsigned int l)
    315   : Value(SimpleNumber::fits(l) ? SimpleNumber::make(l) : new NumberImp(static_cast<double>(l))) { }
    316 
    317 Number Number::dynamicCast(const Value &v)
    318 {
    319   if (v.isNull() || v.type() != NumberType)
    320     return Number((NumberImp*)0);
    321 
    322   return Number(static_cast<NumberImp*>(v.imp()));
    323 }
    324 
    325 double Number::value() const
    326 {
    327   if (SimpleNumber::is(rep))
    328     return (double)SimpleNumber::value(rep);
    329   assert(rep);
    330   return ((NumberImp*)rep)->value();
    331 }
    332 
    333 int Number::intValue() const
    334 {
    335   if (SimpleNumber::is(rep))
    336     return SimpleNumber::value(rep);
    337   return (int)((NumberImp*)rep)->value();
    338 }
    339 
    340 bool Number::isNaN() const
    341 {
    342   return rep == NumberImp::staticNaN;
    343 }
    344 
    345 bool Number::isInf() const
    346 {
    347   if (SimpleNumber::is(rep))
    348     return false;
    349   return KJS::isInf(((NumberImp*)rep)->value());
    350 }
    351 
    352 ValueImp *undefined()
    353 {
    354     return UndefinedImp::staticUndefined;
    355 }
    356 
    357 ValueImp *null()
    358 {
    359     return NullImp::staticNull;
    360 }
    361 
    362 ValueImp *boolean(bool b)
    363 {
    364     return b ? BooleanImp::staticTrue : BooleanImp::staticFalse;
    365 }
    366 
    367 ValueImp *string(const char *s)
     164ObjectImp *AllocatedValueImp::getObject()
     165{
     166    return isObject() ? static_cast<ObjectImp *>(this) : 0;
     167}
     168
     169const ObjectImp *AllocatedValueImp::getObject() const
     170{
     171    return isObject() ? static_cast<const ObjectImp *>(this) : 0;
     172}
     173
     174AllocatedValueImp *jsString(const char *s)
    368175{
    369176    return new StringImp(s ? s : "");
    370177}
    371178
    372 ValueImp *string(const UString &s)
     179AllocatedValueImp *jsString(const UString &s)
    373180{
    374181    return s.isNull() ? new StringImp("") : new StringImp(s);
    375182}
    376183
    377 ValueImp *zero()
    378 {
    379     return SimpleNumber::make(0);
    380 }
    381 
    382 ValueImp *one()
    383 {
    384     return SimpleNumber::make(1);
    385 }
    386 
    387 ValueImp *two()
    388 {
    389     return SimpleNumber::make(2);
    390 }
    391 
    392 ValueImp *number(int i)
    393 {
    394     return SimpleNumber::fits(i) ? SimpleNumber::make(i) : new NumberImp(static_cast<double>(i));
    395 }
    396 
    397 ValueImp *number(unsigned i)
    398 {
    399     return SimpleNumber::fits(i) ? SimpleNumber::make(i) : new NumberImp(static_cast<double>(i));
    400 }
    401 
    402 ValueImp *number(long i)
    403 {
    404     return SimpleNumber::fits(i) ? SimpleNumber::make(i) : new NumberImp(static_cast<double>(i));
    405 }
    406 
    407 ValueImp *number(unsigned long i)
    408 {
    409     return SimpleNumber::fits(i) ? SimpleNumber::make(i) : new NumberImp(static_cast<double>(i));
    410 }
    411 
    412 ValueImp *number(double d)
     184ValueImp *jsNumber(int i)
     185{
     186    return SimpleNumber::fits(i) ? SimpleNumber::make(i) : new NumberImp(static_cast<double>(i));
     187}
     188
     189ValueImp *jsNumber(unsigned i)
     190{
     191    return SimpleNumber::fits(i) ? SimpleNumber::make(i) : new NumberImp(static_cast<double>(i));
     192}
     193
     194ValueImp *jsNumber(long i)
     195{
     196    return SimpleNumber::fits(i) ? SimpleNumber::make(i) : new NumberImp(static_cast<double>(i));
     197}
     198
     199ValueImp *jsNumber(unsigned long i)
     200{
     201    return SimpleNumber::fits(i) ? SimpleNumber::make(i) : new NumberImp(static_cast<double>(i));
     202}
     203
     204ValueImp *jsNumber(double d)
    413205{
    414206    return SimpleNumber::fits(d)
    415207        ? SimpleNumber::make(static_cast<long>(d))
    416         : (isNaN(d) ? NumberImp::staticNaN : new NumberImp(d));
    417 }
    418 
    419 ValueImp *number(double d, bool knownToBeInteger)
     208        : (isNaN(d) ? jsNaN() : new NumberImp(d));
     209}
     210
     211ValueImp *jsNumber(double d, bool knownToBeInteger)
    420212{
    421213    return (knownToBeInteger ? SimpleNumber::integerFits(d) : SimpleNumber::fits(d))
    422214        ? SimpleNumber::make(static_cast<long>(d))
    423         : ((!knownToBeInteger && isNaN(d)) ? NumberImp::staticNaN : new NumberImp(d));
    424 }
    425 
    426 }
     215        : ((!knownToBeInteger && isNaN(d)) ? jsNaN() : new NumberImp(d));
     216}
     217
     218void ConstantValues::init()
     219{
     220    undefined = new UndefinedImp();
     221    null = new NullImp();
     222    jsTrue = new BooleanImp(true);
     223    jsFalse = new BooleanImp(false);
     224    NaN = new NumberImp(::KJS::NaN);
     225}
     226
     227void ConstantValues::clear()
     228{
     229    undefined = NULL;
     230    null = NULL;
     231    jsTrue = NULL;
     232    jsFalse = NULL;
     233    NaN = NULL;
     234}
     235
     236void ConstantValues::mark()
     237{
     238    if (AllocatedValueImp *v = undefined)
     239        if (!v->marked())
     240            v->mark();
     241    if (AllocatedValueImp *v = null)
     242        if (!v->marked())
     243            v->mark();
     244    if (AllocatedValueImp *v = jsTrue)
     245        if (!v->marked())
     246            v->mark();
     247    if (AllocatedValueImp *v = jsFalse)
     248        if (!v->marked())
     249            v->mark();
     250    if (AllocatedValueImp *v = NaN)
     251        if (!v->marked())
     252            v->mark();
     253}
     254
     255}
  • trunk/JavaScriptCore/kjs/value.h

    r9768 r10084  
    1 // -*- c-basic-offset: 2 -*-
    21/*
    32 *  This file is part of the KDE libraries
    43 *  Copyright (C) 1999-2001 Harri Porten ([email protected])
    54 *  Copyright (C) 2001 Peter Kelly ([email protected])
    6  *  Copyright (C) 2003 Apple Computer, Inc.
     5 *  Copyright (C) 2003-2005 Apple Computer, Inc.
    76 *
    87 *  This library is free software; you can redistribute it and/or
     
    2322 */
    2423
    25 #ifndef _KJS_VALUE_H_
    26 #define _KJS_VALUE_H_
     24#ifndef KJS_VALUE_H
     25#define KJS_VALUE_H
    2726
    2827#ifndef NDEBUG // protection against problems if committing with KJS_VERBOSE on
     
    3534#endif
    3635
    37 #include <stdlib.h> // Needed for size_t
    38 
     36#include <assert.h>
     37#include <stdlib.h> // for size_t
     38#include "simple_number.h"
    3939#include "ustring.h"
    4040
    41 #include "simple_number.h"
    42 
    43 // Primitive data types
    44 
    4541namespace KJS {
    4642
    47   class Value;
    48   class ValueImp;
    49   class ValueImpPrivate;
    50   class Undefined;
    51   class UndefinedImp;
    52   class Null;
    53   class NullImp;
    54   class Boolean;
    55   class BooleanImp;
    56   class String;
    57   class StringImp;
    58   class Number;
    59   class NumberImp;
    60   class Object;
    61   class ObjectImp;
    62   class Reference;
    63   class ReferenceImp;
    64   class List;
    65   class ListImp;
    66   class Completion;
    67   class ExecState;
    68   class ClassInfo;
    69 
    70   /**
    71    * Primitive types
    72    */
    73   enum Type {
     43class ClassInfo;
     44class ExecState;
     45class ObjectImp;
     46
     47/**
     48 * Primitive types
     49 */
     50enum Type {
    7451    UnspecifiedType   = 0,
    7552    UndefinedType     = 1,
     
    7956    NumberType        = 5,
    8057    ObjectType        = 6
    81   };
    82 
    83   /**
    84    * ValueImp is the base type for all primitives (Undefined, Null, Boolean,
    85    * String, Number) and objects in ECMAScript.
    86    *
    87    * Note: you should never inherit from ValueImp as it is for primitive types
    88    * only (all of which are provided internally by KJS). Instead, inherit from
    89    * ObjectImp.
    90    */
    91   class ValueImp {
    92     friend class Collector;
    93     friend class Value;
    94     friend class ContextImp;
    95     friend class FunctionCallNode;
    96   public:
    97     ValueImp() : _marked(false) { }
    98     virtual ~ValueImp() { }
    99 
    100     virtual void mark();
    101     bool marked() const;
    102     void* operator new(size_t);
    103     void operator delete(void*);
    104 
     58};
     59
     60/**
     61 * ValueImp is the base type for all primitives (Undefined, Null, Boolean,
     62 * String, Number) and objects in ECMAScript.
     63 *
     64 * Note: you should never inherit from ValueImp as it is for primitive types
     65 * only (all of which are provided internally by KJS). Instead, inherit from
     66 * ObjectImp.
     67 */
     68class ValueImp {
     69    friend class AllocatedValueImp; // so it can derive from this class
     70    friend class ProtectedValues; // so it can call downcast()
     71
     72private:
     73    ValueImp();
     74    ~ValueImp();
     75
     76public:
     77    // Querying the type.
     78    Type type() const;
     79    bool isUndefined() const;
     80    bool isNull() const;
     81    bool isUndefinedOrNull() const;
     82    bool isBoolean() const;
     83    bool isNumber() const;
     84    bool isString() const;
     85    bool isObject() const;
     86    bool isObject(const ClassInfo *) const;
     87
     88    // Extracting the value.
     89    bool getBoolean(bool&) const;
     90    bool getNumber(double&) const;
     91    double getNumber() const; // NaN if not a number
     92    bool getString(UString&) const;
     93    UString getString() const; // null string if not a string
     94    ObjectImp *getObject(); // NULL if not an object
     95    const ObjectImp *getObject() const; // NULL if not an object
     96
     97    // Extracting integer values.
     98    bool getUInt32(uint32_t&) const;
     99
     100    // Basic conversions.
     101    ValueImp *toPrimitive(ExecState *exec, Type preferredType = UnspecifiedType) const;
     102    bool toBoolean(ExecState *exec) const;
     103    double toNumber(ExecState *exec) const;
     104    double toNumber(ExecState *exec, bool& knownToBeInteger) const;
     105    UString toString(ExecState *exec) const;
     106    ObjectImp *toObject(ExecState *exec) const;
     107
     108    // Integer conversions.
    105109    double toInteger(ExecState *exec) const;
    106110    int32_t toInt32(ExecState *exec) const;
     
    108112    uint16_t toUInt16(ExecState *exec) const;
    109113
    110     // Dispatch wrappers that handle the special small number case
    111 
    112     Type dispatchType() const;
    113     Value dispatchToPrimitive(ExecState *exec, Type preferredType = UnspecifiedType) const;
    114     bool dispatchToBoolean(ExecState *exec) const;
    115     double dispatchToNumber(ExecState *exec) const;
    116     double dispatchToNumber(ExecState *exec, bool &knownToBeInteger) const;
    117     UString dispatchToString(ExecState *exec) const;
    118     bool dispatchToUInt32(uint32_t&) const;
    119     Object dispatchToObject(ExecState *exec) const;
    120 
    121     bool isUndefined() const { return dispatchType() == UndefinedType; }
    122     bool isNull() const { return dispatchType() == NullType; }
    123     bool isUndefinedOrNull() const;
    124 
    125     bool isBoolean() const { return dispatchType() == BooleanType; }
    126     bool isBoolean(bool &booleanValue) const;
    127 
    128     bool isNumber() const { return dispatchType() == NumberType; }
    129     bool isNumber(double &numericValue) const;
    130 
    131     bool isString() const { return dispatchType() == StringType; }
    132     bool isString(UString &stringValue) const;
    133     UString asString() const; // null string if not a string
    134 
    135     bool isObject() const { return dispatchType() == ObjectType; }
    136     bool isObject(ObjectImp *&object);
    137     ObjectImp *asObject(); // 0 if not an object
    138     bool isObject(const ClassInfo *) const; // combine an isObject check with an inherits check
    139 
    140   private:
    141     virtual Type type() const = 0;
    142 
    143     // The conversion operations
    144 
    145     virtual Value toPrimitive(ExecState *exec, Type preferredType = UnspecifiedType) const = 0;
    146     virtual bool toBoolean(ExecState *exec) const = 0;
    147     virtual double toNumber(ExecState *exec) const = 0;
    148     virtual UString toString(ExecState *exec) const = 0;
    149     virtual Object toObject(ExecState *exec) const = 0;
    150     virtual bool toUInt32(unsigned&) const;
    151 
    152     bool _marked;
     114    // Garbage collection.
     115    void mark();
     116    bool marked() const;
     117
     118private:
     119    // Implementation details.
     120    AllocatedValueImp *downcast();
     121    const AllocatedValueImp *downcast() const;
    153122
    154123    // Give a compile time error if we try to copy one of these.
    155124    ValueImp(const ValueImp&);
    156125    ValueImp& operator=(const ValueImp&);
    157   };
    158  
    159   ValueImp *undefined();
    160   ValueImp *null();
    161 
    162   ValueImp *boolean(bool = false);
    163 
    164   ValueImp *string(const char * = ""); // returns empty string if passed 0
    165   ValueImp *string(const UString &); // returns empty string if passed null string
    166 
    167   ValueImp *zero();
    168   ValueImp *one();
    169   ValueImp *two();
    170   ValueImp *number(int);
    171   ValueImp *number(unsigned);
    172   ValueImp *number(long);
    173   ValueImp *number(unsigned long);
    174   ValueImp *number(double);
    175   ValueImp *number(double, bool knownToBeInteger);
    176 
    177   /**
    178    * FIXME: Now that we have conservative GC, we will be deprecating the
    179    * Value wrappers and programming in terms of the ValueImp objects.
    180    * Eventually we will remove Value and rename ValueImp to Value.
    181    * We'll need to move the comments from Value to ValueImp too.
    182    */
    183   /**
    184    * Value objects are act as wrappers ("smart pointers") around ValueImp
    185    * objects and their descendents. Instead of using ValueImps
    186    * (and derivatives) during normal program execution, you should use a
    187    * Value-derived class.
    188    *
    189    * Value maintains a pointer to a ValueImp object and uses a reference
    190    * counting scheme to ensure that the ValueImp object is not deleted or
    191    * garbage collected.
    192    *
    193    * Note: The conversion operations all return values of various types -
    194    * if an error occurs during conversion, an error object will instead
    195    * be returned (where possible), and the execution state's exception
    196    * will be set appropriately.
    197    */
    198   class Value {
    199   public:
    200     Value() : rep(0) { }
    201     Value(ValueImp *v) : rep(v) { }
    202     operator ValueImp *() const { return rep; }
    203 
    204     explicit Value(bool);
    205 
    206     explicit Value(int);
    207     explicit Value(unsigned);
    208     explicit Value(double);
    209     explicit Value(long);
    210     explicit Value(unsigned long);
    211     Value(double, bool knownToBeInteger);
    212 
    213     explicit Value(const char *);
    214     Value(const UString &);
    215    
    216     /**
    217      * Returns whether or not this is a valid value. An invalid value
    218      * has a 0 implementation pointer and should not be used for
    219      * any other operation than this check. Current use: as a
    220      * distinct return value signalling failing dynamicCast() calls.
    221      */
    222     bool isValid() const { return rep != 0; }
    223     /**
    224      * @deprecated
    225      * Use !isValid() instead.
    226      */
    227     bool isNull() const { return rep == 0; }
    228     ValueImp *imp() const { return rep; }
    229 
    230     /**
    231      * Returns the type of value. This is one of UndefinedType, NullType,
    232      * BooleanType, StringType, NumberType, or ObjectType.
    233      *
    234      * @return The type of value
    235      */
    236     Type type() const { return rep->dispatchType(); }
    237 
    238     /**
    239      * Checks whether or not the value is of a particular tpye
    240      *
    241      * @param t The type to compare with
    242      * @return true if the value is of the specified type, otherwise false
    243      */
    244     bool isA(Type t) const { return rep->dispatchType() == t; }
    245 
    246     /**
    247      * Performs the ToPrimitive type conversion operation on this value
    248      * (ECMA 9.1)
    249      */
    250     Value toPrimitive(ExecState *exec,
    251                       Type preferredType = UnspecifiedType) const
    252       { return rep->dispatchToPrimitive(exec, preferredType); }
    253 
    254     /**
    255      * Performs the ToBoolean type conversion operation on this value (ECMA 9.2)
    256      */
    257     bool toBoolean(ExecState *exec) const { return rep->dispatchToBoolean(exec); }
    258 
    259     /**
    260      * Performs the ToNumber type conversion operation on this value (ECMA 9.3)
    261      */
    262     double toNumber(ExecState *exec) const { return rep->dispatchToNumber(exec); }
    263     double toNumber(ExecState *exec, bool &knownToBeInteger) const { return rep->dispatchToNumber(exec, knownToBeInteger); }
    264 
    265     /**
    266      * Performs the ToInteger type conversion operation on this value (ECMA 9.4)
    267      */
    268     double toInteger(ExecState *exec) const { return rep->toInteger(exec); }
    269 
    270     /**
    271      * Performs the ToInt32 type conversion operation on this value (ECMA 9.5)
    272      */
    273     int32_t toInt32(ExecState *exec) const { return rep->toInt32(exec); }
    274 
    275     /**
    276      * Performs the ToUint32 type conversion operation on this value (ECMA 9.6)
    277      */
    278     uint32_t toUInt32(ExecState *exec) const { return rep->toUInt32(exec); }
    279 
    280     /**
    281      * Performs the ToUint16 type conversion operation on this value (ECMA 9.7)
    282      */
    283     uint16_t toUInt16(ExecState *exec) const { return rep->toUInt16(exec); }
    284 
    285     /**
    286      * Performs the ToString type conversion operation on this value (ECMA 9.8)
    287      */
    288     UString toString(ExecState *exec) const { return rep->dispatchToString(exec); }
    289 
    290     /**
    291      * Performs the ToObject type conversion operation on this value (ECMA 9.9)
    292      */
    293     Object toObject(ExecState *exec) const;
    294 
    295     /**
    296      * Checks if we can do a lossless conversion to UInt32.
    297      */
    298     bool toUInt32(uint32_t& i) const { return rep->dispatchToUInt32(i); }
    299 
    300   protected:
    301     ValueImp *rep;
    302   };
    303 
    304   // Primitive types
    305 
    306   /**
    307    * Represents an primitive Undefined value. All instances of this class
    308    * share the same implementation object, so == will always return true
    309    * for any comparison between two Undefined objects.
    310    */
    311   class Undefined : public Value {
    312   public:
    313     Undefined();
    314 
    315     /**
    316      * Converts a Value into an Undefined. If the value's type is not
    317      * UndefinedType, a null object will be returned (i.e. one with it's
    318      * internal pointer set to 0). If you do not know for sure whether the
    319      * value is of type UndefinedType, you should check the isValid()
    320      * methods afterwards before calling any methods on the returned value.
    321      *
    322      * @return The value converted to an Undefined
    323      */
    324     static Undefined dynamicCast(const Value &v);
    325   private:
     126};
     127
     128class AllocatedValueImp : public ValueImp {
     129    friend class Collector;
    326130    friend class UndefinedImp;
    327     explicit Undefined(UndefinedImp *v);
    328 
    329   };
    330 
    331   /**
    332    * Represents an primitive Null value. All instances of this class
    333    * share the same implementation object, so == will always return true
    334    * for any comparison between two Null objects.
    335    */
    336   class Null : public Value {
    337   public:
    338     Null();
    339 
    340     /**
    341      * Converts a Value into an Null. If the value's type is not NullType,
    342      * a null object will be returned (i.e. one with it's internal pointer set
    343      * to 0). If you do not know for sure whether the value is of type
    344      * NullType, you should check the isValid() methods afterwards before
    345      * calling any methods on the returned value.
    346      *
    347      * @return The value converted to a Null
    348      */
    349     static Null dynamicCast(const Value &v);
    350   private:
    351131    friend class NullImp;
    352     explicit Null(NullImp *v);
    353   };
    354 
    355   /**
    356    * Represents an primitive Boolean value
    357    */
    358   class Boolean : public Value {
    359   public:
    360     Boolean(bool b = false);
    361 
    362     /**
    363      * Converts a Value into an Boolean. If the value's type is not BooleanType,
    364      * a null object will be returned (i.e. one with it's internal pointer set
    365      * to 0). If you do not know for sure whether the value is of type
    366      * BooleanType, you should check the isValid() methods afterwards before
    367      * calling any methods on the returned value.
    368      *
    369      * @return The value converted to a Boolean
    370      */
    371     static Boolean dynamicCast(const Value &v);
    372 
    373     bool value() const;
    374   private:
    375132    friend class BooleanImp;
    376     explicit Boolean(BooleanImp *v);
    377   };
    378 
    379   /**
    380    * Represents an primitive String value
    381    */
    382   class String : public Value {
    383   public:
    384     String(const UString &s = "");
    385 
    386     /**
    387      * Converts a Value into an String. If the value's type is not StringType,
    388      * a null object will be returned (i.e. one with it's internal pointer set
    389      * to 0). If you do not know for sure whether the value is of type
    390      * StringType, you should check the isValid() methods afterwards before
    391      * calling any methods on the returned value.
    392      *
    393      * @return The value converted to a String
    394      */
    395     static String dynamicCast(const Value &v);
    396 
    397     UString value() const;
    398   private:
     133    friend class NumberImp;
    399134    friend class StringImp;
    400     explicit String(StringImp *v);
    401   };
    402 
    403   extern const double NaN;
    404   extern const double Inf;
    405 
    406   /**
    407    * Represents an primitive Number value
    408    */
    409   class Number : public Value {
    410     friend class ValueImp;
    411   public:
    412     Number(int i);
    413     Number(unsigned int u);
    414     Number(double d = 0.0);
    415     Number(long int l);
    416     Number(long unsigned int l);
    417     Number(double d, bool knownToBeInteger);
    418 
    419     double value() const;
    420     int intValue() const;
    421 
    422     bool isNaN() const;
    423     bool isInf() const;
    424 
    425     /**
    426      * Converts a Value into an Number. If the value's type is not NumberType,
    427      * a null object will be returned (i.e. one with it's internal pointer set
    428      * to 0). If you do not know for sure whether the value is of type
    429      * NumberType, you should check the isNull() methods afterwards before
    430      * calling any methods on the returned value.
    431      *
    432      * @return The value converted to a Number
    433      */
    434     static Number dynamicCast(const Value &v);
    435   private:
    436     friend class NumberImp;
    437     explicit Number(NumberImp *v);
    438   };
     135    friend class ObjectImp;
     136private:
     137    AllocatedValueImp();
     138    virtual ~AllocatedValueImp();
     139public:
     140    // Querying the type.
     141    virtual Type type() const = 0;
     142    bool isBoolean() const;
     143    bool isNumber() const;
     144    bool isString() const;
     145    bool isObject() const;
     146    bool isObject(const ClassInfo *) const;
     147
     148    // Extracting the value.
     149    bool getBoolean(bool&) const;
     150    bool getNumber(double&) const;
     151    double getNumber() const; // NaN if not a number
     152    bool getString(UString&) const;
     153    UString getString() const; // null string if not a string
     154    ObjectImp *getObject(); // NULL if not an object
     155    const ObjectImp *getObject() const; // NULL if not an object
     156
     157    // Extracting integer values.
     158    virtual bool getUInt32(uint32_t&) const;
     159
     160    // Basic conversions.
     161    virtual ValueImp *toPrimitive(ExecState *exec, Type preferredType = UnspecifiedType) const = 0;
     162    virtual bool toBoolean(ExecState *exec) const = 0;
     163    virtual double toNumber(ExecState *exec) const = 0;
     164    double toNumber(ExecState *exec, bool& knownToBeInteger) const;
     165    virtual UString toString(ExecState *exec) const = 0;
     166    virtual ObjectImp *toObject(ExecState *exec) const = 0;
     167
     168    // Garbage collection.
     169    void *operator new(size_t);
     170    virtual void mark();
     171    bool marked() const;
     172
     173private:
     174    bool m_marked;
     175};
     176
     177AllocatedValueImp *jsUndefined();
     178AllocatedValueImp *jsNull();
     179
     180AllocatedValueImp *jsBoolean(bool = false);
     181
     182ValueImp *jsNumber(double);
     183ValueImp *jsNumber(double, bool knownToBeInteger);
     184AllocatedValueImp *jsNaN();
     185ValueImp *jsZero();
     186ValueImp *jsOne();
     187ValueImp *jsTwo();
     188ValueImp *jsNumber(int);
     189ValueImp *jsNumber(unsigned);
     190ValueImp *jsNumber(long);
     191ValueImp *jsNumber(unsigned long);
     192
     193AllocatedValueImp *jsString(const UString &); // returns empty string if passed null string
     194AllocatedValueImp *jsString(const char * = ""); // returns empty string if passed 0
     195
     196extern const double NaN;
     197extern const double Inf;
     198
     199class ConstantValues {
     200public:
     201    static AllocatedValueImp *undefined;
     202    static AllocatedValueImp *null;
     203    static AllocatedValueImp *jsFalse;
     204    static AllocatedValueImp *jsTrue;
     205    static AllocatedValueImp *NaN;
     206
     207    static void init();
     208    static void clear();
     209    static void mark();
     210};
     211
     212inline AllocatedValueImp *jsUndefined()
     213{
     214    return ConstantValues::undefined;
     215}
     216
     217inline AllocatedValueImp *jsNull()
     218{
     219    return ConstantValues::null;
     220}
     221
     222inline AllocatedValueImp *jsBoolean(bool b)
     223{
     224    return b ? ConstantValues::jsTrue : ConstantValues::jsFalse;
     225}
     226
     227inline AllocatedValueImp *jsNaN()
     228{
     229    return ConstantValues::NaN;
     230}
     231
     232inline ValueImp::ValueImp()
     233{
     234}
     235
     236inline ValueImp::~ValueImp()
     237{
     238}
     239
     240inline AllocatedValueImp::AllocatedValueImp()
     241    : m_marked(false)
     242{
     243}
     244
     245inline AllocatedValueImp::~AllocatedValueImp()
     246{
     247}
     248
     249inline bool AllocatedValueImp::isBoolean() const
     250{
     251    return type() == BooleanType;
     252}
     253
     254inline bool AllocatedValueImp::isNumber() const
     255{
     256    return type() == NumberType;
     257}
     258
     259inline bool AllocatedValueImp::isString() const
     260{
     261    return type() == StringType;
     262}
     263
     264inline bool AllocatedValueImp::isObject() const
     265{
     266    return type() == ObjectType;
     267}
     268
     269inline bool AllocatedValueImp::marked() const
     270{
     271    return m_marked;
     272}
     273
     274inline void AllocatedValueImp::mark()
     275{
     276    m_marked = true;
     277}
     278
     279inline AllocatedValueImp *ValueImp::downcast()
     280{
     281    assert(!SimpleNumber::is(this));
     282    return static_cast<AllocatedValueImp *>(this);
     283}
     284
     285inline const AllocatedValueImp *ValueImp::downcast() const
     286{
     287    assert(!SimpleNumber::is(this));
     288    return static_cast<const AllocatedValueImp *>(this);
     289}
     290
     291inline bool ValueImp::isUndefined() const
     292{
     293    return this == jsUndefined();
     294}
     295
     296inline bool ValueImp::isNull() const
     297{
     298    return this == jsNull();
     299}
     300
     301inline bool ValueImp::isUndefinedOrNull() const
     302{
     303    return this == jsUndefined() || this == jsNull();
     304}
     305
     306inline bool ValueImp::isBoolean() const
     307{
     308    return !SimpleNumber::is(this) && downcast()->isBoolean();
     309}
     310
     311inline bool ValueImp::isNumber() const
     312{
     313    return SimpleNumber::is(this) || downcast()->isNumber();
     314}
     315
     316inline bool ValueImp::isString() const
     317{
     318    return !SimpleNumber::is(this) && downcast()->isString();
     319}
     320
     321inline bool ValueImp::isObject() const
     322{
     323    return !SimpleNumber::is(this) && downcast()->isObject();
     324}
     325
     326inline bool ValueImp::isObject(const ClassInfo *c) const
     327{
     328    return !SimpleNumber::is(this) && downcast()->isObject(c);
     329}
     330
     331inline bool ValueImp::getBoolean(bool& v) const
     332{
     333    return !SimpleNumber::is(this) && downcast()->getBoolean(v);
     334}
     335
     336inline bool ValueImp::getNumber(double& v) const
     337{
     338    if (SimpleNumber::is(this)) {
     339        v = SimpleNumber::value(this);
     340        return true;
     341    }
     342    return downcast()->getNumber(v);
     343}
     344
     345inline double ValueImp::getNumber() const
     346{
     347    return SimpleNumber::is(this) ? SimpleNumber::value(this) : downcast()->getNumber();
     348}
     349
     350inline bool ValueImp::getString(UString& s) const
     351{
     352    return !SimpleNumber::is(this) && downcast()->getString(s);
     353}
     354
     355inline UString ValueImp::getString() const
     356{
     357    return SimpleNumber::is(this) ? UString() : downcast()->getString();
     358}
     359
     360inline ObjectImp *ValueImp::getObject()
     361{
     362    return SimpleNumber::is(this) ? 0 : downcast()->getObject();
     363}
     364
     365inline const ObjectImp *ValueImp::getObject() const
     366{
     367    return SimpleNumber::is(this) ? 0 : downcast()->getObject();
     368}
     369
     370inline bool ValueImp::getUInt32(uint32_t& v) const
     371{
     372    if (SimpleNumber::is(this)) {
     373        long i = SimpleNumber::value(this);
     374        if (i < 0)
     375            return false;
     376        v = i;
     377        return true;
     378    }
     379    return downcast()->getUInt32(v);
     380}
     381
     382inline void ValueImp::mark()
     383{
     384    if (!SimpleNumber::is(this))
     385        downcast()->mark();
     386}
    439387
    440388inline bool ValueImp::marked() const
    441389{
    442   // Simple numbers are always considered marked.
    443   return SimpleNumber::is(this) || _marked;
    444 }
    445 
    446 // Dispatchers for virtual functions, to special-case simple numbers which
    447 // won't be real pointers.
    448 
    449 inline Type ValueImp::dispatchType() const
    450 {
    451   if (SimpleNumber::is(this))
    452     return NumberType;
    453   return type();
    454 }
    455 
    456 inline Value ValueImp::dispatchToPrimitive(ExecState *exec, Type preferredType) const
    457 {
    458     if (SimpleNumber::is(this))
    459         return Value(const_cast<ValueImp *>(this));
    460     return toPrimitive(exec, preferredType);
    461 }
    462 
    463 inline bool ValueImp::dispatchToBoolean(ExecState *exec) const
    464 {
    465     if (SimpleNumber::is(this))
    466         return SimpleNumber::value(this);
    467     return toBoolean(exec);
    468 }
    469 
    470 inline double ValueImp::dispatchToNumber(ExecState *exec) const
    471 {
    472     if (SimpleNumber::is(this))
    473         return SimpleNumber::value(this);
    474     return toNumber(exec);
    475 }
    476 
    477 inline double ValueImp::dispatchToNumber(ExecState *exec, bool &knownToBeInteger) const
     390    return SimpleNumber::is(this) || downcast()->marked();
     391}
     392
     393inline Type ValueImp::type() const
     394{
     395    return SimpleNumber::is(this) ? NumberType : downcast()->type();
     396}
     397
     398inline ValueImp *ValueImp::toPrimitive(ExecState *exec, Type preferredType) const
     399{
     400    return SimpleNumber::is(this) ? const_cast<ValueImp *>(this) : downcast()->toPrimitive(exec, preferredType);
     401}
     402
     403inline bool ValueImp::toBoolean(ExecState *exec) const
     404{
     405    return SimpleNumber::is(this) ? SimpleNumber::value(this) : downcast()->toBoolean(exec);
     406}
     407
     408inline double ValueImp::toNumber(ExecState *exec) const
     409{
     410    return SimpleNumber::is(this) ? SimpleNumber::value(this) : downcast()->toNumber(exec);
     411}
     412
     413inline double ValueImp::toNumber(ExecState *exec, bool& knownToBeInteger) const
    478414{
    479415    if (SimpleNumber::is(this)) {
     
    482418    }
    483419    knownToBeInteger = false;
    484     return toNumber(exec);
    485 }
    486 
    487 inline UString ValueImp::dispatchToString(ExecState *exec) const
    488 {
    489     if (SimpleNumber::is(this))
    490         return UString::from(SimpleNumber::value(this));
    491     return toString(exec);
    492 }
    493 
    494 inline bool ValueImp::dispatchToUInt32(uint32_t& result) const
    495 {
    496     if (SimpleNumber::is(this)) {
    497         long i = SimpleNumber::value(this);
    498         if (i < 0)
    499             return false;
    500         result = i;
    501         return true;
    502     }
    503     return toUInt32(result);
    504 }
     420    return downcast()->toNumber(exec);
     421}
     422
     423inline UString ValueImp::toString(ExecState *exec) const
     424{
     425   return SimpleNumber::is(this) ? UString::from(SimpleNumber::value(this)) : downcast()->toString(exec);
     426}
     427
     428inline ValueImp *jsZero()
     429{
     430    return SimpleNumber::make(0);
     431}
     432
     433inline ValueImp *jsOne()
     434{
     435    return SimpleNumber::make(1);
     436}
     437
     438inline ValueImp *jsTwo()
     439{
     440    return SimpleNumber::make(2);
     441}
     442
     443// compatibility names so we don't have to change so much code
     444
     445inline AllocatedValueImp *Undefined() { return jsUndefined(); }
     446inline AllocatedValueImp *Null() { return jsNull(); }
     447inline AllocatedValueImp *Boolean(bool b) { return jsBoolean(b); }
     448inline ValueImp *Number(double n) { return jsNumber(n); }
     449inline ValueImp *Number(int n) { return jsNumber(n); }
     450inline ValueImp *Number(unsigned n) { return jsNumber(n); }
     451inline ValueImp *Number(long n) { return jsNumber(n); }
     452inline ValueImp *Number(unsigned long n) { return jsNumber(n); }
     453inline AllocatedValueImp *String(const UString& s) { return jsString(s); }
     454inline AllocatedValueImp *String(const char *s) { return jsString(s); }
    505455
    506456} // namespace
    507457
    508 #endif // _KJS_VALUE_H_
     458#endif // KJS_VALUE_H
Note: See TracChangeset for help on using the changeset viewer.