本文整理汇总了C++中JSValue::isPrimitive方法的典型用法代码示例。如果您正苦于以下问题:C++ JSValue::isPrimitive方法的具体用法?C++ JSValue::isPrimitive怎么用?C++ JSValue::isPrimitive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSValue
的用法示例。
在下文中一共展示了JSValue::isPrimitive方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getRuntimeTypeForValue
RuntimeType TypeSet::getRuntimeTypeForValue(JSValue v)
{
RuntimeType ret;
if (v.isFunction())
ret = TypeFunction;
else if (v.isUndefined())
ret = TypeUndefined;
else if (v.isNull())
ret = TypeNull;
else if (v.isBoolean())
ret = TypeBoolean;
else if (v.isMachineInt())
ret = TypeMachineInt;
else if (v.isNumber())
ret = TypeNumber;
else if (v.isString())
ret = TypeString;
else if (v.isPrimitive())
ret = TypePrimitive;
else if (v.isObject())
ret = TypeObject;
else
CRASH();
return ret;
}
示例2: setPrimitive
void JSWeakValue::setPrimitive(JSValue primitive)
{
ASSERT(!isSet());
ASSERT(!m_value.primitive);
ASSERT(primitive.isPrimitive());
m_tag = WeakTypeTag::Primitive;
m_value.primitive = primitive;
}
示例3: parseGlobalSection
void WASMModuleParser::parseGlobalSection(ExecState* exec)
{
uint32_t numberOfInternalI32GlobalVariables;
uint32_t numberOfInternalF32GlobalVariables;
uint32_t numberOfInternalF64GlobalVariables;
uint32_t numberOfImportedI32GlobalVariables;
uint32_t numberOfImportedF32GlobalVariables;
uint32_t numberOfImportedF64GlobalVariables;
READ_COMPACT_UINT32_OR_FAIL(numberOfInternalI32GlobalVariables, "Cannot read the number of internal int32 global variables.");
READ_COMPACT_UINT32_OR_FAIL(numberOfInternalF32GlobalVariables, "Cannot read the number of internal float32 global variables.");
READ_COMPACT_UINT32_OR_FAIL(numberOfInternalF64GlobalVariables, "Cannot read the number of internal float64 global variables.");
READ_COMPACT_UINT32_OR_FAIL(numberOfImportedI32GlobalVariables, "Cannot read the number of imported int32 global variables.");
READ_COMPACT_UINT32_OR_FAIL(numberOfImportedF32GlobalVariables, "Cannot read the number of imported float32 global variables.");
READ_COMPACT_UINT32_OR_FAIL(numberOfImportedF64GlobalVariables, "Cannot read the number of imported float64 global variables.");
uint32_t numberOfGlobalVariables = numberOfInternalI32GlobalVariables + numberOfInternalF32GlobalVariables + numberOfInternalF64GlobalVariables +
numberOfImportedI32GlobalVariables + numberOfImportedF32GlobalVariables + numberOfImportedF64GlobalVariables;
Vector<WASMType>& globalVariableTypes = m_module->globalVariableTypes();
globalVariableTypes.reserveInitialCapacity(numberOfGlobalVariables);
Vector<JSWASMModule::GlobalVariable>& globalVariables = m_module->globalVariables();
globalVariables.reserveInitialCapacity(numberOfGlobalVariables);
for (uint32_t i = 0; i < numberOfInternalI32GlobalVariables; ++i) {
globalVariableTypes.uncheckedAppend(WASMType::I32);
globalVariables.uncheckedAppend(JSWASMModule::GlobalVariable(0));
}
for (uint32_t i = 0; i < numberOfInternalF32GlobalVariables; ++i) {
globalVariableTypes.uncheckedAppend(WASMType::F32);
globalVariables.uncheckedAppend(JSWASMModule::GlobalVariable(0.0f));
}
for (uint32_t i = 0; i < numberOfInternalF64GlobalVariables; ++i) {
globalVariableTypes.uncheckedAppend(WASMType::F64);
globalVariables.uncheckedAppend(JSWASMModule::GlobalVariable(0.0));
}
for (uint32_t i = 0; i < numberOfImportedI32GlobalVariables; ++i) {
String importName;
READ_STRING_OR_FAIL(importName, "Cannot read the import name of an int32 global variable.");
globalVariableTypes.uncheckedAppend(WASMType::I32);
JSValue value;
getImportedValue(exec, importName, value);
PROPAGATE_ERROR();
FAIL_IF_FALSE(value.isPrimitive() && !value.isSymbol(), "\"" + importName + "\" is not a primitive or is a Symbol.");
globalVariables.uncheckedAppend(JSWASMModule::GlobalVariable(value.toInt32(exec)));
}
for (uint32_t i = 0; i < numberOfImportedF32GlobalVariables; ++i) {
String importName;
READ_STRING_OR_FAIL(importName, "Cannot read the import name of a float32 global variable.");
globalVariableTypes.uncheckedAppend(WASMType::F32);
JSValue value;
getImportedValue(exec, importName, value);
PROPAGATE_ERROR();
FAIL_IF_FALSE(value.isPrimitive() && !value.isSymbol(), "\"" + importName + "\" is not a primitive or is a Symbol.");
globalVariables.uncheckedAppend(JSWASMModule::GlobalVariable(static_cast<float>(value.toNumber(exec))));
}
for (uint32_t i = 0; i < numberOfImportedF64GlobalVariables; ++i) {
String importName;
READ_STRING_OR_FAIL(importName, "Cannot read the import name of a float64 global variable.");
globalVariableTypes.uncheckedAppend(WASMType::F64);
JSValue value;
getImportedValue(exec, importName, value);
PROPAGATE_ERROR();
FAIL_IF_FALSE(value.isPrimitive() && !value.isSymbol(), "\"" + importName + "\" is not a primitive or is a Symbol.");
globalVariables.uncheckedAppend(JSWASMModule::GlobalVariable(value.toNumber(exec)));
}
}