本文整理汇总了C++中JSPropertyNameIterator::setCachedPrototypeChain方法的典型用法代码示例。如果您正苦于以下问题:C++ JSPropertyNameIterator::setCachedPrototypeChain方法的具体用法?C++ JSPropertyNameIterator::setCachedPrototypeChain怎么用?C++ JSPropertyNameIterator::setCachedPrototypeChain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSPropertyNameIterator
的用法示例。
在下文中一共展示了JSPropertyNameIterator::setCachedPrototypeChain方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create
JSPropertyNameIterator* JSPropertyNameIterator::create(ExecState* exec, JSObject* o)
{
ASSERT(!o->structure()->enumerationCache() ||
o->structure()->enumerationCache()->cachedStructure() != o->structure() ||
o->structure()->enumerationCache()->cachedPrototypeChain() != o->structure()->prototypeChain(exec));
PropertyNameArray propertyNames(exec);
o->getPropertyNames(exec, propertyNames);
size_t numCacheableSlots = 0;
if (!o->structure()->hasNonEnumerableProperties() && !o->structure()->hasAnonymousSlots() &&
!o->structure()->isUncacheableDictionary() && !o->structure()->typeInfo().overridesGetPropertyNames())
numCacheableSlots = o->structure()->propertyStorageSize();
JSPropertyNameIterator* jsPropertyNameIterator = new (exec) JSPropertyNameIterator(exec, propertyNames.data(), numCacheableSlots);
if (o->structure()->isDictionary())
return jsPropertyNameIterator;
if (o->structure()->typeInfo().overridesGetPropertyNames())
return jsPropertyNameIterator;
size_t count = normalizePrototypeChain(exec, o);
StructureChain* structureChain = o->structure()->prototypeChain(exec);
RefPtr<Structure>* structure = structureChain->head();
for (size_t i = 0; i < count; ++i) {
if (structure[i]->typeInfo().overridesGetPropertyNames())
return jsPropertyNameIterator;
}
jsPropertyNameIterator->setCachedPrototypeChain(structureChain);
jsPropertyNameIterator->setCachedStructure(o->structure());
o->structure()->setEnumerationCache(jsPropertyNameIterator);
return jsPropertyNameIterator;
}