本文整理汇总了C++中PutPropertySlot::thisValue方法的典型用法代码示例。如果您正苦于以下问题:C++ PutPropertySlot::thisValue方法的具体用法?C++ PutPropertySlot::thisValue怎么用?C++ PutPropertySlot::thisValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PutPropertySlot
的用法示例。
在下文中一共展示了PutPropertySlot::thisValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: putToPrimitive
// ECMA 8.7.2
bool JSValue::putToPrimitive(ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
if (Optional<uint32_t> index = parseIndex(propertyName))
return putToPrimitiveByIndex(exec, index.value(), value, slot.isStrictMode());
// Check if there are any setters or getters in the prototype chain
JSObject* obj = synthesizePrototype(exec);
if (UNLIKELY(!obj))
return false;
JSValue prototype;
if (propertyName != exec->propertyNames().underscoreProto) {
for (; !obj->structure()->hasReadOnlyOrGetterSetterPropertiesExcludingProto(); obj = asObject(prototype)) {
prototype = obj->getPrototypeDirect();
if (prototype.isNull()) {
if (slot.isStrictMode())
throwTypeError(exec, scope, StrictModeReadonlyPropertyWriteError);
return false;
}
}
}
for (; ; obj = asObject(prototype)) {
unsigned attributes;
PropertyOffset offset = obj->structure()->get(vm, propertyName, attributes);
if (offset != invalidOffset) {
if (attributes & ReadOnly) {
if (slot.isStrictMode())
throwTypeError(exec, scope, StrictModeReadonlyPropertyWriteError);
return false;
}
JSValue gs = obj->getDirect(offset);
if (gs.isGetterSetter())
return callSetter(exec, *this, gs, value, slot.isStrictMode() ? StrictMode : NotStrictMode);
if (gs.isCustomGetterSetter())
return callCustomSetter(exec, gs, attributes & CustomAccessor, obj, slot.thisValue(), value);
// If there's an existing property on the object or one of its
// prototypes it should be replaced, so break here.
break;
}
prototype = obj->getPrototype(vm, exec);
if (vm.exception())
return false;
if (prototype.isNull())
break;
}
if (slot.isStrictMode())
throwTypeError(exec, scope, StrictModeReadonlyPropertyWriteError);
return false;
}
示例2: put
bool JSArrayBufferView::put(
JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value,
PutPropertySlot& slot)
{
JSArrayBufferView* thisObject = jsCast<JSArrayBufferView*>(cell);
if (UNLIKELY(isThisValueAltered(slot, thisObject)))
return ordinarySetSlow(exec, thisObject, propertyName, value, slot.thisValue(), slot.isStrictMode());
return Base::put(thisObject, exec, propertyName, value, slot);
}
示例3: put
bool JSArrayBuffer::put(
JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value,
PutPropertySlot& slot)
{
JSArrayBuffer* thisObject = jsCast<JSArrayBuffer*>(cell);
if (UNLIKELY(isThisValueAltered(slot, thisObject)))
return ordinarySetSlow(exec, thisObject, propertyName, value, slot.thisValue(), slot.isStrictMode());
if (propertyName == exec->propertyNames().byteLength)
return reject(exec, slot.isStrictMode(), "Attempting to write to a read-only array buffer property.");
return Base::put(thisObject, exec, propertyName, value, slot);
}
示例4: put
bool RegExpObject::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
{
RegExpObject* thisObject = jsCast<RegExpObject*>(cell);
if (UNLIKELY(isThisValueAltered(slot, thisObject)))
return ordinarySetSlow(exec, thisObject, propertyName, value, slot.thisValue(), slot.isStrictMode());
if (propertyName == exec->propertyNames().lastIndex) {
bool result = asRegExpObject(cell)->setLastIndex(exec, value, slot.isStrictMode());
slot.setCustomValue(asRegExpObject(cell), slot.isStrictMode()
? regExpObjectSetLastIndexStrict
: regExpObjectSetLastIndexNonStrict);
return result;
}
return Base::put(cell, exec, propertyName, value, slot);
}
示例5: put
bool StringObject::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
StringObject* thisObject = jsCast<StringObject*>(cell);
if (UNLIKELY(isThisValueAltered(slot, thisObject)))
return ordinarySetSlow(exec, thisObject, propertyName, value, slot.thisValue(), slot.isStrictMode());
if (propertyName == vm.propertyNames->length)
return typeError(exec, scope, slot.isStrictMode(), ASCIILiteral(ReadonlyPropertyWriteError));
if (Optional<uint32_t> index = parseIndex(propertyName))
return putByIndex(cell, exec, index.value(), value, slot.isStrictMode());
return JSObject::put(cell, exec, propertyName, value, slot);
}