本文整理汇总了C++中JSGlobalObject::mapStructure方法的典型用法代码示例。如果您正苦于以下问题:C++ JSGlobalObject::mapStructure方法的具体用法?C++ JSGlobalObject::mapStructure怎么用?C++ JSGlobalObject::mapStructure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSGlobalObject
的用法示例。
在下文中一共展示了JSGlobalObject::mapStructure方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: encode
static EncodedJSValue JSC_HOST_CALL constructMap(ExecState* exec)
{
// Until we have iterators we throw if we've been given
// any arguments that could require us to throw.
if (!exec->argument(0).isUndefinedOrNull())
return JSValue::encode(throwTypeError(exec, ASCIILiteral("Map constructor does not accept arguments")));
if (!exec->argument(1).isUndefined())
return throwVMError(exec, createRangeError(exec, WTF::ASCIILiteral("Invalid comparator function")));
JSGlobalObject* globalObject = asInternalFunction(exec->callee())->globalObject();
Structure* mapStructure = globalObject->mapStructure();
return JSValue::encode(JSMap::create(exec, mapStructure));
}
示例2: encode
static EncodedJSValue JSC_HOST_CALL constructMap(ExecState* exec)
{
JSValue prototype = JSValue();
JSValue newTarget = exec->newTarget();
if (newTarget != exec->callee())
prototype = newTarget.get(exec, exec->propertyNames().prototype);
JSGlobalObject* globalObject = asInternalFunction(exec->callee())->globalObject();
Structure* mapStructure = Structure::createSubclassStructure(exec->vm(), globalObject->mapStructure(), prototype);
JSMap* map = JSMap::create(exec, mapStructure);
JSValue iterable = exec->argument(0);
if (iterable.isUndefinedOrNull())
return JSValue::encode(map);
JSValue adderFunction = map->JSObject::get(exec, exec->propertyNames().set);
if (exec->hadException())
return JSValue::encode(jsUndefined());
CallData adderFunctionCallData;
CallType adderFunctionCallType = getCallData(adderFunction, adderFunctionCallData);
if (adderFunctionCallType == CallTypeNone)
return JSValue::encode(throwTypeError(exec));
JSValue iteratorFunction = iterable.get(exec, exec->propertyNames().iteratorSymbol);
if (exec->hadException())
return JSValue::encode(jsUndefined());
CallData iteratorFunctionCallData;
CallType iteratorFunctionCallType = getCallData(iteratorFunction, iteratorFunctionCallData);
if (iteratorFunctionCallType == CallTypeNone)
return JSValue::encode(throwTypeError(exec));
ArgList iteratorFunctionArguments;
JSValue iterator = call(exec, iteratorFunction, iteratorFunctionCallType, iteratorFunctionCallData, iterable, iteratorFunctionArguments);
if (exec->hadException())
return JSValue::encode(jsUndefined());
if (!iterator.isObject())
return JSValue::encode(throwTypeError(exec));
while (true) {
JSValue next = iteratorStep(exec, iterator);
if (exec->hadException())
return JSValue::encode(jsUndefined());
if (next.isFalse())
return JSValue::encode(map);
JSValue nextItem = iteratorValue(exec, next);
if (exec->hadException())
return JSValue::encode(jsUndefined());
if (!nextItem.isObject()) {
throwTypeError(exec);
iteratorClose(exec, iterator);
return JSValue::encode(jsUndefined());
}
JSValue key = nextItem.get(exec, 0);
if (exec->hadException()) {
iteratorClose(exec, iterator);
return JSValue::encode(jsUndefined());
}
JSValue value = nextItem.get(exec, 1);
if (exec->hadException()) {
iteratorClose(exec, iterator);
return JSValue::encode(jsUndefined());
}
MarkedArgumentBuffer arguments;
arguments.append(key);
arguments.append(value);
call(exec, adderFunction, adderFunctionCallType, adderFunctionCallData, map, arguments);
if (exec->hadException()) {
iteratorClose(exec, iterator);
return JSValue::encode(jsUndefined());
}
}
RELEASE_ASSERT_NOT_REACHED();
return JSValue::encode(map);
}