Changeset 199073 in webkit for trunk/Source/JavaScriptCore/jsc.cpp
- Timestamp:
- Apr 5, 2016, 2:36:25 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/jsc.cpp
r198945 r199073 24 24 25 25 #include "ArrayPrototype.h" 26 #include "BuiltinExecutables.h" 26 27 #include "ButterflyInlines.h" 27 28 #include "BytecodeGenerator.h" … … 33 34 #include "Exception.h" 34 35 #include "ExceptionHelpers.h" 36 #include "GetterSetter.h" 35 37 #include "HeapProfiler.h" 36 38 #include "HeapSnapshotBuilder.h" … … 552 554 static EncodedJSValue JSC_HOST_CALL functionCreateImpureGetter(ExecState*); 553 555 static EncodedJSValue JSC_HOST_CALL functionCreateCustomGetterObject(ExecState*); 556 static EncodedJSValue JSC_HOST_CALL functionCreateBuiltin(ExecState*); 554 557 static EncodedJSValue JSC_HOST_CALL functionSetImpureGetterDelegate(ExecState*); 555 558 … … 572 575 static EncodedJSValue JSC_HOST_CALL functionHeapSize(ExecState*); 573 576 static EncodedJSValue JSC_HOST_CALL functionAddressOf(ExecState*); 577 static EncodedJSValue JSC_HOST_CALL functionGetGetterSetter(ExecState*); 574 578 #ifndef NDEBUG 575 579 static EncodedJSValue JSC_HOST_CALL functionDumpCallFrame(ExecState*); … … 741 745 addFunction(vm, "gcHeapSize", functionHeapSize, 0); 742 746 addFunction(vm, "addressOf", functionAddressOf, 1); 747 addFunction(vm, "getGetterSetter", functionGetGetterSetter, 2); 743 748 #ifndef NDEBUG 744 749 addFunction(vm, "dumpCallFrame", functionDumpCallFrame, 0); … … 789 794 addFunction(vm, "createImpureGetter", functionCreateImpureGetter, 1); 790 795 addFunction(vm, "createCustomGetterObject", functionCreateCustomGetterObject, 0); 796 addFunction(vm, "createBuiltin", functionCreateBuiltin, 2); 791 797 addFunction(vm, "setImpureGetterDelegate", functionSetImpureGetterDelegate, 2); 792 798 … … 1329 1335 } 1330 1336 1337 static EncodedJSValue JSC_HOST_CALL functionGetGetterSetter(ExecState* exec) 1338 { 1339 JSValue value = exec->argument(0); 1340 if (!value.isObject()) 1341 return JSValue::encode(jsUndefined()); 1342 1343 JSValue property = exec->argument(1); 1344 if (!property.isString()) 1345 return JSValue::encode(jsUndefined()); 1346 1347 Identifier ident = Identifier::fromString(&exec->vm(), property.toString(exec)->value(exec)); 1348 1349 PropertySlot slot(value, PropertySlot::InternalMethodType::VMInquiry); 1350 value.getPropertySlot(exec, ident, slot); 1351 1352 JSValue result; 1353 if (slot.isCacheableGetter()) 1354 result = slot.getterSetter(); 1355 else 1356 result = jsNull(); 1357 1358 return JSValue::encode(result); 1359 } 1360 1331 1361 EncodedJSValue JSC_HOST_CALL functionVersion(ExecState*) 1332 1362 { … … 1711 1741 return JSValue::encode(exec->vm().throwException(exec, error)); 1712 1742 return JSValue::encode(jsUndefined()); 1743 } 1744 1745 EncodedJSValue JSC_HOST_CALL functionCreateBuiltin(ExecState* exec) 1746 { 1747 if (exec->argumentCount() < 1 || !exec->argument(0).isString()) 1748 return JSValue::encode(jsUndefined()); 1749 1750 String functionText = exec->argument(0).toString(exec)->value(exec); 1751 if (exec->hadException()) 1752 return JSValue::encode(JSValue()); 1753 1754 VM& vm = exec->vm(); 1755 const SourceCode& source = makeSource(functionText); 1756 JSFunction* func = JSFunction::createBuiltinFunction(vm, BuiltinExecutables::createExecutable(vm, source, Identifier::fromString(&vm, "foo"), ConstructorKind::None, ConstructAbility::CannotConstruct)->link(vm, source), exec->lexicalGlobalObject()); 1757 1758 return JSValue::encode(func); 1713 1759 } 1714 1760
Note:
See TracChangeset
for help on using the changeset viewer.