Changeset 2778 in webkit for trunk/JavaScriptCore/kjs/function.cpp
- Timestamp:
- Nov 20, 2002, 1:11:43 AM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/function.cpp
r2772 r2778 58 58 ), param(0L), ident(n) 59 59 { 60 Value protect(this);61 60 //fprintf(stderr,"FunctionImp::FunctionImp this=%p\n"); 62 put(exec,argumentsPropertyName,Null(),ReadOnly|DontDelete|DontEnum);63 61 } 64 62 … … 105 103 newExec.setException(exec->exception()); // could be null 106 104 107 // In order to maintain our "arguments" property, we save the old108 // value from a possible earlier call. Upon return, we restore the109 // previous arguments object.110 // Note: this does not appear to be part of the spec111 Value oldArgs = get(&newExec, argumentsPropertyName);112 113 if (codeType() == FunctionCode) {114 assert(ctx.activationObject().inherits(&ActivationImp::info));115 Object argsObj = static_cast<ActivationImp*>(ctx.activationObject().imp())->argumentsObject();116 put(&newExec, argumentsPropertyName, argsObj, DontDelete|DontEnum|ReadOnly);117 }118 119 105 // assign user supplied arguments to parameters 120 106 processParameters(&newExec, args); … … 127 113 if (newExec.hadException()) 128 114 exec->setException(newExec.exception()); 129 if (codeType() == FunctionCode)130 put(&newExec, argumentsPropertyName, oldArgs, DontDelete|DontEnum|ReadOnly);131 115 132 116 #ifdef KJS_VERBOSE … … 170 154 { 171 155 UString s; 172 const Parameter * const *p = ¶m;173 while ( *p) {156 const Parameter *p = param; 157 while (p) { 174 158 if (!s.isEmpty()) 175 159 s += ", "; 176 s += (*p)->name.ustring();177 p = &(*p)->next;160 s += p->name.ustring(); 161 p = p->next; 178 162 } 179 163 … … 195 179 if (param) { 196 180 ListIterator it = args.begin(); 197 Parameter * *p = ¶m;198 while ( *p) {181 Parameter *p = param; 182 while (p) { 199 183 if (it != args.end()) { 200 184 #ifdef KJS_VERBOSE 201 fprintf(stderr, "setting parameter %s ", (*p)->name.ascii());185 fprintf(stderr, "setting parameter %s ", p->name.ascii()); 202 186 printInfo(exec,"to", *it); 203 187 #endif 204 variable.put(exec, (*p)->name, *it);188 variable.put(exec, p->name, *it); 205 189 it++; 206 190 } else 207 variable.put(exec, (*p)->name, Undefined());208 p = &(*p)->next;191 variable.put(exec, p->name, Undefined()); 192 p = p->next; 209 193 } 210 194 } … … 219 203 void FunctionImp::processVarDecls(ExecState */*exec*/) 220 204 { 205 } 206 207 Value FunctionImp::get(ExecState *exec, const Identifier &propertyName) const 208 { 209 // Find the arguments from the closest context. 210 if (propertyName == argumentsPropertyName) { 211 ContextImp *context = exec->_context; 212 while (context) { 213 ActivationImp *activation = static_cast<ActivationImp *>(context->activationObject()); 214 if (activation->function() == this) 215 return activation->get(exec, propertyName); 216 context = context->callingContext(); 217 } 218 return Undefined(); 219 } 220 221 // Compute length of parameters. 222 if (propertyName == lengthPropertyName) { 223 const Parameter * p = param; 224 int count = 0; 225 while (p) { 226 ++count; 227 p = p->next; 228 } 229 return Number(count); 230 } 231 232 return InternalFunctionImp::get(exec, propertyName); 233 } 234 235 void FunctionImp::put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr) 236 { 237 if (propertyName == argumentsPropertyName || propertyName == lengthPropertyName) 238 return; 239 InternalFunctionImp::put(exec, propertyName, value, attr); 240 } 241 242 bool FunctionImp::hasProperty(ExecState *exec, const Identifier &propertyName) const 243 { 244 if (propertyName == argumentsPropertyName || propertyName == lengthPropertyName) 245 return true; 246 return InternalFunctionImp::hasProperty(exec, propertyName); 247 } 248 249 bool FunctionImp::deleteProperty(ExecState *exec, const Identifier &propertyName) 250 { 251 if (propertyName == argumentsPropertyName || propertyName == lengthPropertyName) 252 return false; 253 return InternalFunctionImp::deleteProperty(exec, propertyName); 221 254 } 222 255 … … 305 338 // ECMA 10.1.6 306 339 ActivationImp::ActivationImp(ExecState *exec, FunctionImp *f, const List &args) 307 : ObjectImp()340 : _function(f) 308 341 { 309 342 Value protect(this);
Note:
See TracChangeset
for help on using the changeset viewer.