Changeset 196868 in webkit for trunk/Source/JavaScriptCore/runtime/ProxyObject.cpp
- Timestamp:
- Feb 20, 2016, 3:51:33 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/ProxyObject.cpp
r196836 r196868 66 66 } 67 67 68 CallData ignored;69 68 JSObject* targetAsObject = jsCast<JSObject*>(target); 70 m_isCallable = targetAsObject->methodTable(vm)->getCallData(targetAsObject, ignored) != CallTypeNone; 69 70 CallData ignoredCallData; 71 m_isCallable = targetAsObject->methodTable(vm)->getCallData(targetAsObject, ignoredCallData) != CallTypeNone; 72 73 ConstructData ignoredConstructData; 74 m_isConstructible = jsCast<JSObject*>(target)->methodTable(vm)->getConstructData(jsCast<JSObject*>(target), ignoredConstructData) != ConstructTypeNone; 71 75 72 76 m_target.set(vm, this, targetAsObject); … … 352 356 } 353 357 358 static EncodedJSValue JSC_HOST_CALL performProxyConstruct(ExecState* exec) 359 { 360 VM& vm = exec->vm(); 361 ProxyObject* proxy = jsCast<ProxyObject*>(exec->callee()); 362 JSValue handlerValue = proxy->handler(); 363 if (handlerValue.isNull()) 364 return throwVMTypeError(exec, ASCIILiteral("Proxy 'handler' is null. It should be an Object.")); 365 366 JSObject* handler = jsCast<JSObject*>(handlerValue); 367 CallData callData; 368 CallType callType; 369 JSValue constructMethod = handler->getMethod(exec, callData, callType, makeIdentifier(vm, "construct"), ASCIILiteral("'construct' property of a Proxy's handler should be constructible.")); 370 if (exec->hadException()) 371 return JSValue::encode(jsUndefined()); 372 JSObject* target = proxy->target(); 373 if (constructMethod.isUndefined()) { 374 ConstructData constructData; 375 ConstructType constructType = target->methodTable(vm)->getConstructData(target, constructData); 376 RELEASE_ASSERT(constructType != ConstructTypeNone); 377 return JSValue::encode(construct(exec, target, constructType, constructData, ArgList(exec), exec->newTarget())); 378 } 379 380 JSArray* argArray = constructArray(exec, static_cast<ArrayAllocationProfile*>(nullptr), ArgList(exec)); 381 if (exec->hadException()) 382 return JSValue::encode(jsUndefined()); 383 MarkedArgumentBuffer arguments; 384 arguments.append(target); 385 arguments.append(argArray); 386 arguments.append(exec->newTarget()); 387 JSValue result = call(exec, constructMethod, callType, callData, handler, arguments); 388 if (exec->hadException()) 389 return JSValue::encode(jsUndefined()); 390 if (!result.isObject()) 391 return throwVMTypeError(exec, ASCIILiteral("Result from Proxy handler's 'construct' method should be an object.")); 392 return JSValue::encode(result); 393 } 394 395 ConstructType ProxyObject::getConstructData(JSCell* cell, ConstructData& constructData) 396 { 397 ProxyObject* proxy = jsCast<ProxyObject*>(cell); 398 if (!proxy->m_isConstructible) { 399 constructData.js.functionExecutable = nullptr; 400 constructData.js.scope = nullptr; 401 return ConstructTypeNone; 402 } 403 404 constructData.native.function = performProxyConstruct; 405 return ConstructTypeHost; 406 } 407 354 408 } // namespace JSC
Note:
See TracChangeset
for help on using the changeset viewer.