Changeset 10084 in webkit for trunk/JavaScriptCore/kjs/bool_object.cpp
- Timestamp:
- Aug 7, 2005, 9:07:46 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/bool_object.cpp
r9768 r10084 51 51 : BooleanInstanceImp(objectProto) 52 52 { 53 Value protect(this);54 53 // The constructor will be added later by InterpreterImp::InterpreterImp() 55 54 … … 66 65 : InternalFunctionImp(funcProto), id(i) 67 66 { 68 Value protect(this);69 67 putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum); 70 68 } … … 78 76 79 77 // ECMA 15.6.4.2 + 15.6.4.3 80 Value BooleanProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &/*args*/)78 ValueImp *BooleanProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &/*args*/) 81 79 { 82 80 // no generic function. "this" has to be a Boolean object 83 if (!thisObj .inherits(&BooleanInstanceImp::info)) {84 Object 81 if (!thisObj->inherits(&BooleanInstanceImp::info)) { 82 ObjectImp *err = Error::create(exec,TypeError); 85 83 exec->setException(err); 86 84 return err; … … 89 87 // execute "toString()" or "valueOf()", respectively 90 88 91 Value v = thisObj.internalValue();92 assert( !v.isNull());89 ValueImp *v = thisObj->internalValue(); 90 assert(v); 93 91 94 92 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 */ 97 95 } 98 96 … … 104 102 : InternalFunctionImp(funcProto) 105 103 { 106 Value protect(this);107 104 putDirect(prototypePropertyName, booleanProto, DontEnum|DontDelete|ReadOnly); 108 105 109 106 // no. of arguments for constructor 110 putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum);107 putDirect(lengthPropertyName, jsOne(), ReadOnly|DontDelete|DontEnum); 111 108 } 112 109 … … 118 115 119 116 // ECMA 15.6.2 120 Object 117 ObjectImp *BooleanObjectImp::construct(ExecState *exec, const List &args) 121 118 { 122 Object obj(new BooleanInstanceImp(exec->lexicalInterpreter()->builtinBooleanPrototype().imp()));119 ObjectImp *obj(new BooleanInstanceImp(exec->lexicalInterpreter()->builtinBooleanPrototype())); 123 120 124 Booleanb;121 bool b; 125 122 if (args.size() > 0) 126 b = args.begin()-> dispatchToBoolean(exec);123 b = args.begin()->toBoolean(exec); 127 124 else 128 b = Boolean(false);125 b = false; 129 126 130 obj .setInternalValue(b);127 obj->setInternalValue(jsBoolean(b)); 131 128 132 129 return obj; … … 139 136 140 137 // ECMA 15.6.1 141 Value BooleanObjectImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)138 ValueImp *BooleanObjectImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args) 142 139 { 143 140 if (args.isEmpty()) 144 141 return Boolean(false); 145 142 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 */ 147 144 } 148 145
Note:
See TracChangeset
for help on using the changeset viewer.