Changeset 2792 in webkit for trunk/JavaScriptCore/kjs/function.cpp
- Timestamp:
- Nov 20, 2002, 4:55:08 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/function.cpp
r2786 r2792 66 66 } 67 67 68 void FunctionImp::mark()69 {70 InternalFunctionImp::mark();71 }72 73 68 bool FunctionImp::implementsCall() const 74 69 { … … 99 94 // enter a new execution context 100 95 ContextImp ctx(globalObj, exec, thisObj, codeType(), 101 exec->context().imp(), this, args);96 exec->context().imp(), this, &args); 102 97 ExecState newExec(exec->interpreter(), &ctx); 103 98 newExec.setException(exec->exception()); // could be null … … 211 206 ContextImp *context = exec->_context; 212 207 while (context) { 213 ActivationImp *activation = static_cast<ActivationImp *>(context->activationObject());214 if (activation->function() == this)215 return activation->get(exec, propertyName);208 if (context->function() == this) 209 return static_cast<ActivationImp *> 210 (context->activationObject())->get(exec, propertyName); 216 211 context = context->callingContext(); 217 212 } … … 318 313 319 314 // ECMA 10.1.8 315 ArgumentsImp::ArgumentsImp(ExecState *exec, FunctionImp *func) 316 : ArrayInstanceImp(exec->interpreter()->builtinObjectPrototype().imp(), 0) 317 { 318 Value protect(this); 319 putDirect(calleePropertyName, func, DontEnum); 320 } 321 320 322 ArgumentsImp::ArgumentsImp(ExecState *exec, FunctionImp *func, const List &args) 321 323 : ArrayInstanceImp(exec->interpreter()->builtinObjectPrototype().imp(), args) … … 330 332 331 333 // ECMA 10.1.6 332 ActivationImp::ActivationImp(ExecState *exec, FunctionImp *f, const List &args) 333 : _function(f), _arguments(true) 334 { 335 Value protect(this); 336 _arguments = args; 337 _argumentsObject = new ArgumentsImp(exec, f, args); 338 putDirect(argumentsPropertyName, _argumentsObject, Internal|DontDelete); 334 ActivationImp::ActivationImp(ExecState *exec) 335 : _context(exec->context().imp()), _argumentsObject(0) 336 { 337 // FIXME: Do we need to support enumerating the arguments property? 338 } 339 340 Value ActivationImp::get(ExecState *exec, const Identifier &propertyName) const 341 { 342 if (propertyName == argumentsPropertyName) { 343 if (!_argumentsObject) 344 createArgumentsObject(exec); 345 return Value(_argumentsObject); 346 } 347 return ObjectImp::get(exec, propertyName); 348 } 349 350 void ActivationImp::put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr) 351 { 352 if (propertyName == argumentsPropertyName) { 353 // FIXME: Do we need to allow overwriting this? 354 return; 355 } 356 ObjectImp::put(exec, propertyName, value, attr); 357 } 358 359 bool ActivationImp::hasProperty(ExecState *exec, const Identifier &propertyName) const 360 { 361 if (propertyName == argumentsPropertyName) 362 return true; 363 return ObjectImp::hasProperty(exec, propertyName); 364 } 365 366 bool ActivationImp::deleteProperty(ExecState *exec, const Identifier &propertyName) 367 { 368 if (propertyName == argumentsPropertyName) 369 return false; 370 return ObjectImp::deleteProperty(exec, propertyName); 371 } 372 373 void ActivationImp::mark() 374 { 375 if (_argumentsObject && !_argumentsObject->marked()) 376 _argumentsObject->mark(); 377 ObjectImp::mark(); 378 } 379 380 void ActivationImp::createArgumentsObject(ExecState *exec) const 381 { 382 FunctionImp *function = _context->function(); 383 const ArgumentList *arguments = _context->arguments(); 384 if (arguments) 385 _argumentsObject = new ArgumentsImp(exec, function, *arguments); 386 else 387 _argumentsObject = new ArgumentsImp(exec, function); 339 388 } 340 389 … … 392 441 // enter a new execution context 393 442 Object thisVal(Object::dynamicCast(exec->context().thisValue())); 394 ContextImp *ctx = new ContextImp(exec->interpreter()->globalObject(),395 396 397 398 399 400 ExecState *newExec = new ExecState(exec->interpreter(),ctx);401 newExec ->setException(exec->exception()); // could be null443 ContextImp ctx(exec->interpreter()->globalObject(), 444 exec, 445 thisVal, 446 EvalCode, 447 exec->context().imp()); 448 449 ExecState newExec(exec->interpreter(), &ctx); 450 newExec.setException(exec->exception()); // could be null 402 451 403 452 // execute the code 404 Completion c = progNode->execute( newExec);453 Completion c = progNode->execute(&newExec); 405 454 406 455 // if an exception occured, propogate it back to the previous execution object 407 if (newExec->hadException()) 408 exec->setException(newExec->exception()); 409 delete newExec; 410 delete ctx; 456 if (newExec.hadException()) 457 exec->setException(newExec.exception()); 411 458 412 459 if ( progNode->deref() )
Note:
See TracChangeset
for help on using the changeset viewer.