Changeset 10084 in webkit for trunk/JavaScriptCore/kjs/object_object.cpp
- Timestamp:
- Aug 7, 2005, 9:07:46 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/object_object.cpp
r9889 r10084 38 38 : ObjectImp() // [[Prototype]] is Null() 39 39 { 40 Value protect(this);41 40 putDirect(toStringPropertyName, new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ToString, 0), DontEnum); 42 41 putDirect(toLocaleStringPropertyName, new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ToLocaleString,0), DontEnum); … … 53 52 : InternalFunctionImp(funcProto), id(i) 54 53 { 55 Value protect(this);56 54 putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum); 57 55 } … … 65 63 // ECMA 15.2.4.2, 15.2.4.4, 15.2.4.5 66 64 67 Value ObjectProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &args)65 ValueImp *ObjectProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args) 68 66 { 69 67 switch (id) { 70 68 case ValueOf: 71 69 return thisObj; 72 case HasOwnProperty: {70 case HasOwnProperty: 73 71 // 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)))); 78 73 case ToLocaleString: 79 return thisObj.imp()->toString(exec);74 return jsString(thisObj->toString(exec)); 80 75 case ToString: 81 76 default: 82 return String("[object " + thisObj .className() + "]");77 return String("[object " + thisObj->className() + "]"); 83 78 } 84 79 } … … 91 86 : InternalFunctionImp(funcProto) 92 87 { 93 Value protect(this);94 88 // ECMA 15.2.3.1 95 89 putDirect(prototypePropertyName, objProto, DontEnum|DontDelete|ReadOnly); 96 90 97 91 // no. of arguments for constructor 98 putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum);92 putDirect(lengthPropertyName, jsOne(), ReadOnly|DontDelete|DontEnum); 99 93 } 100 94 … … 106 100 107 101 // ECMA 15.2.2 108 Object 102 ObjectImp *ObjectObjectImp::construct(ExecState *exec, const List &args) 109 103 { 110 104 // if no arguments have been passed ... 111 105 if (args.isEmpty()) { 112 Object 113 Object 106 ObjectImp *proto = exec->lexicalInterpreter()->builtinObjectPrototype(); 107 ObjectImp *result(new ObjectImp(proto)); 114 108 return result; 115 109 } 116 110 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()) 120 113 return obj; 121 }122 114 123 switch (arg .type()) {115 switch (arg->type()) { 124 116 case StringType: 125 117 case BooleanType: 126 118 case NumberType: 127 return arg .toObject(exec);119 return arg->toObject(exec); 128 120 default: 129 121 assert(!"unhandled switch case in ObjectConstructor"); 130 122 case NullType: 131 123 case UndefinedType: 132 Object proto = exec->lexicalInterpreter()->builtinObjectPrototype(); 133 return Object(new ObjectImp(proto)); 124 return new ObjectImp(exec->lexicalInterpreter()->builtinObjectPrototype()); 134 125 } 135 126 } … … 140 131 } 141 132 142 Value ObjectObjectImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)133 ValueImp *ObjectObjectImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args) 143 134 { 144 Value 135 ValueImp *result; 145 136 146 137 List argList; … … 149 140 result = construct(exec,argList); 150 141 } else { 151 Value 152 if (arg .type() == NullType || arg.type() == UndefinedType) {142 ValueImp *arg = args[0]; 143 if (arg->isUndefinedOrNull()) { 153 144 argList.append(arg); 154 145 result = construct(exec,argList); 155 146 } else 156 result = arg .toObject(exec);147 result = arg->toObject(exec); 157 148 } 158 149 return result;
Note:
See TracChangeset
for help on using the changeset viewer.