本文整理汇总了C++中JSFunction::methodTable方法的典型用法代码示例。如果您正苦于以下问题:C++ JSFunction::methodTable方法的具体用法?C++ JSFunction::methodTable怎么用?C++ JSFunction::methodTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSFunction
的用法示例。
在下文中一共展示了JSFunction::methodTable方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: put
void JSFunction::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
{
JSFunction* thisObject = jsCast<JSFunction*>(cell);
if (thisObject->isHostFunction()) {
Base::put(thisObject, exec, propertyName, value, slot);
return;
}
if (propertyName == exec->propertyNames().prototype) {
// Make sure prototype has been reified, such that it can only be overwritten
// following the rules set out in ECMA-262 8.12.9.
PropertySlot slot;
thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, propertyName, slot);
thisObject->m_allocationProfile.clear();
thisObject->m_allocationProfileWatchpoint.notifyWrite();
// Don't allow this to be cached, since a [[Put]] must clear m_allocationProfile.
PutPropertySlot dontCache;
Base::put(thisObject, exec, propertyName, value, dontCache);
return;
}
if (thisObject->jsExecutable()->isStrictMode() && (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().caller)) {
// This will trigger the property to be reified, if this is not already the case!
bool okay = thisObject->hasProperty(exec, propertyName);
ASSERT_UNUSED(okay, okay);
Base::put(thisObject, exec, propertyName, value, slot);
return;
}
if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length || propertyName == exec->propertyNames().name || propertyName == exec->propertyNames().caller) {
if (slot.isStrictMode())
throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
return;
}
Base::put(thisObject, exec, propertyName, value, slot);
}
示例2: defineOwnProperty
bool JSFunction::defineOwnProperty(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor, bool throwException)
{
JSFunction* thisObject = jsCast<JSFunction*>(object);
if (thisObject->isHostFunction())
return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException);
if (propertyName == exec->propertyNames().prototype) {
// Make sure prototype has been reified, such that it can only be overwritten
// following the rules set out in ECMA-262 8.12.9.
PropertySlot slot;
thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, propertyName, slot);
} else if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length || propertyName == exec->propertyNames().caller) {
if (!object->isExtensible()) {
if (throwException)
throwError(exec, createTypeError(exec, "Attempting to define property on object that is not extensible."));
return false;
}
if (descriptor.configurablePresent() && descriptor.configurable()) {
if (throwException)
throwError(exec, createTypeError(exec, "Attempting to configurable attribute of unconfigurable property."));
return false;
}
if (descriptor.enumerablePresent() && descriptor.enumerable()) {
if (throwException)
throwError(exec, createTypeError(exec, "Attempting to change enumerable attribute of unconfigurable property."));
return false;
}
if (descriptor.isAccessorDescriptor()) {
if (throwException)
throwError(exec, createTypeError(exec, "Attempting to change access mechanism for an unconfigurable property."));
return false;
}
if (descriptor.writablePresent() && descriptor.writable()) {
if (throwException)
throwError(exec, createTypeError(exec, "Attempting to change writable attribute of unconfigurable property."));
return false;
}
if (!descriptor.value())
return true;
if (propertyName == exec->propertyNames().arguments && sameValue(exec, descriptor.value(), exec->interpreter()->retrieveArgumentsFromVMCode(exec, thisObject)))
return true;
if (propertyName == exec->propertyNames().length && sameValue(exec, descriptor.value(), jsNumber(thisObject->jsExecutable()->parameterCount())))
return true;
if (propertyName == exec->propertyNames().caller && sameValue(exec, descriptor.value(), exec->interpreter()->retrieveCallerFromVMCode(exec, thisObject)))
return true;
if (throwException)
throwError(exec, createTypeError(exec, "Attempting to change value of a readonly property."));
return false;
}
return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException);
}
示例3: getOwnPropertyDescriptor
bool JSFunction::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
JSFunction* thisObject = jsCast<JSFunction*>(object);
if (thisObject->isHostFunction())
return Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
if (propertyName == exec->propertyNames().prototype) {
PropertySlot slot;
thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, propertyName, slot);
return Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
}
if (propertyName == exec->propertyNames().arguments) {
if (thisObject->jsExecutable()->isStrictMode()) {
bool result = Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
if (!result) {
thisObject->putDirectAccessor(exec, propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor);
result = Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
ASSERT(result);
}
return result;
}
descriptor.setDescriptor(exec->interpreter()->retrieveArgumentsFromVMCode(exec, thisObject), ReadOnly | DontEnum | DontDelete);
return true;
}
if (propertyName == exec->propertyNames().length) {
descriptor.setDescriptor(jsNumber(thisObject->jsExecutable()->parameterCount()), ReadOnly | DontEnum | DontDelete);
return true;
}
if (propertyName == exec->propertyNames().name) {
descriptor.setDescriptor(thisObject->jsExecutable()->nameValue(), ReadOnly | DontEnum | DontDelete);
return true;
}
if (propertyName == exec->propertyNames().caller) {
if (thisObject->jsExecutable()->isStrictMode()) {
bool result = Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
if (!result) {
thisObject->putDirectAccessor(exec, propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor);
result = Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
ASSERT(result);
}
return result;
}
descriptor.setDescriptor(exec->interpreter()->retrieveCallerFromVMCode(exec, thisObject), ReadOnly | DontEnum | DontDelete);
return true;
}
return Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
}
示例4: getOwnPropertyNames
void JSFunction::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
JSFunction* thisObject = jsCast<JSFunction*>(object);
if (!thisObject->isHostFunction() && (mode == IncludeDontEnumProperties)) {
// Make sure prototype has been reified.
PropertySlot slot;
thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, exec->propertyNames().prototype, slot);
propertyNames.add(exec->propertyNames().arguments);
propertyNames.add(exec->propertyNames().caller);
propertyNames.add(exec->propertyNames().length);
}
Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
}
示例5: getOwnNonIndexPropertyNames
void JSFunction::getOwnNonIndexPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
JSFunction* thisObject = jsCast<JSFunction*>(object);
if (!thisObject->isHostOrBuiltinFunction() && mode.includeDontEnumProperties()) {
VM& vm = exec->vm();
// Make sure prototype has been reified.
PropertySlot slot(thisObject);
thisObject->methodTable(vm)->getOwnPropertySlot(thisObject, exec, vm.propertyNames->prototype, slot);
propertyNames.add(vm.propertyNames->arguments);
propertyNames.add(vm.propertyNames->caller);
propertyNames.add(vm.propertyNames->length);
propertyNames.add(vm.propertyNames->name);
}
Base::getOwnNonIndexPropertyNames(thisObject, exec, propertyNames, mode);
}
示例6: constructEmptyObject
JSCell* DFG_OPERATION operationCreateThis(ExecState* exec, JSCell* prototype)
{
JSFunction* constructor = asFunction(exec->callee());
#if !ASSERT_DISABLED
ConstructData constructData;
ASSERT(constructor->methodTable()->getConstructData(constructor, constructData) == ConstructTypeJS);
#endif
JSGlobalData& globalData = exec->globalData();
Structure* structure;
if (prototype->isObject())
structure = asObject(prototype)->inheritorID(globalData);
else
structure = constructor->scope()->globalObject->emptyObjectStructure();
return constructEmptyObject(exec, structure);
}
示例7: evaluate
JSValue JSInjectedScriptHost::evaluate(ExecState* exec)
{
JSValue expression = exec->argument(0);
if (!expression.isString())
return throwError(exec, createError(exec, "String argument expected."));
JSGlobalObject* globalObject = exec->lexicalGlobalObject();
JSFunction* evalFunction = globalObject->evalFunction();
CallData callData;
CallType callType = evalFunction->methodTable()->getCallData(evalFunction, callData);
if (callType == CallTypeNone)
return jsUndefined();
MarkedArgumentBuffer args;
args.append(expression);
bool wasEvalEnabled = globalObject->evalEnabled();
globalObject->setEvalEnabled(true);
JSValue result = JSC::call(exec, evalFunction, callType, callData, exec->globalThisValue(), args);
globalObject->setEvalEnabled(wasEvalEnabled);
return result;
}
示例8: put
void JSFunction::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
JSFunction* thisObject = jsCast<JSFunction*>(cell);
if (thisObject->isHostFunction()) {
Base::put(thisObject, exec, propertyName, value, slot);
return;
}
if (propertyName == exec->propertyNames().prototype) {
// Make sure prototype has been reified, such that it can only be overwritten
// following the rules set out in ECMA-262 8.12.9.
PropertySlot slot;
thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, propertyName, slot);
}
if (thisObject->jsExecutable()->isStrictMode() && (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().caller)) {
// This will trigger the property to be reified, if this is not already the case!
bool okay = thisObject->hasProperty(exec, propertyName);
ASSERT_UNUSED(okay, okay);
Base::put(thisObject, exec, propertyName, value, slot);
return;
}
if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length)
return;
Base::put(thisObject, exec, propertyName, value, slot);
}
示例9: defineOwnProperty
bool JSFunction::defineOwnProperty(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor, bool throwException)
{
JSFunction* thisObject = jsCast<JSFunction*>(object);
if (thisObject->isHostFunction())
return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException);
if (propertyName == exec->propertyNames().prototype) {
// Make sure prototype has been reified, such that it can only be overwritten
// following the rules set out in ECMA-262 8.12.9.
PropertySlot slot;
thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, propertyName, slot);
thisObject->m_allocationProfile.clear();
thisObject->m_allocationProfileWatchpoint.notifyWrite();
return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException);
}
bool valueCheck;
if (propertyName == exec->propertyNames().arguments) {
if (thisObject->jsExecutable()->isStrictMode()) {
if (!Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor))
thisObject->putDirectAccessor(exec, propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor);
return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException);
}
valueCheck = !descriptor.value() || sameValue(exec, descriptor.value(), exec->interpreter()->retrieveArgumentsFromVMCode(exec, thisObject));
} else if (propertyName == exec->propertyNames().caller) {
if (thisObject->jsExecutable()->isStrictMode()) {
if (!Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor))
thisObject->putDirectAccessor(exec, propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor);
return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException);
}
valueCheck = !descriptor.value() || sameValue(exec, descriptor.value(), exec->interpreter()->retrieveCallerFromVMCode(exec, thisObject));
} else if (propertyName == exec->propertyNames().length)
valueCheck = !descriptor.value() || sameValue(exec, descriptor.value(), jsNumber(thisObject->jsExecutable()->parameterCount()));
else if (propertyName == exec->propertyNames().name)
valueCheck = !descriptor.value() || sameValue(exec, descriptor.value(), thisObject->jsExecutable()->nameValue());
else
return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException);
if (descriptor.configurablePresent() && descriptor.configurable()) {
if (throwException)
throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to configurable attribute of unconfigurable property.")));
return false;
}
if (descriptor.enumerablePresent() && descriptor.enumerable()) {
if (throwException)
throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change enumerable attribute of unconfigurable property.")));
return false;
}
if (descriptor.isAccessorDescriptor()) {
if (throwException)
throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change access mechanism for an unconfigurable property.")));
return false;
}
if (descriptor.writablePresent() && descriptor.writable()) {
if (throwException)
throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change writable attribute of unconfigurable property.")));
return false;
}
if (!valueCheck) {
if (throwException)
throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change value of a readonly property.")));
return false;
}
return true;
}