本文整理汇总了C++中AsmJSModule::globalVarIndexToGlobalDatum方法的典型用法代码示例。如果您正苦于以下问题:C++ AsmJSModule::globalVarIndexToGlobalDatum方法的具体用法?C++ AsmJSModule::globalVarIndexToGlobalDatum怎么用?C++ AsmJSModule::globalVarIndexToGlobalDatum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AsmJSModule
的用法示例。
在下文中一共展示了AsmJSModule::globalVarIndexToGlobalDatum方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: field
static bool
ValidateGlobalVariable(JSContext *cx, const AsmJSModule &module, AsmJSModule::Global &global,
HandleValue importVal)
{
JS_ASSERT(global.which() == AsmJSModule::Global::Variable);
void *datum = module.globalVarIndexToGlobalDatum(global.varIndex());
switch (global.varInitKind()) {
case AsmJSModule::Global::InitConstant: {
const Value &v = global.varInitConstant();
switch (global.varInitCoercion()) {
case AsmJS_ToInt32:
*(int32_t *)datum = v.toInt32();
break;
case AsmJS_ToNumber:
*(double *)datum = v.toDouble();
break;
case AsmJS_FRound:
*(float *)datum = static_cast<float>(v.toDouble());
break;
}
break;
}
case AsmJSModule::Global::InitImport: {
RootedPropertyName field(cx, global.varImportField());
RootedValue v(cx);
if (!GetDataProperty(cx, importVal, field, &v))
return false;
switch (global.varInitCoercion()) {
case AsmJS_ToInt32:
if (!ToInt32(cx, v, (int32_t *)datum))
return false;
break;
case AsmJS_ToNumber:
if (!ToNumber(cx, v, (double *)datum))
return false;
break;
case AsmJS_FRound:
if (!RoundFloat32(cx, v, (float *)datum))
return false;
break;
}
break;
}
}
return true;
}