本文整理汇总了C++中JSValue::isMachineInt方法的典型用法代码示例。如果您正苦于以下问题:C++ JSValue::isMachineInt方法的具体用法?C++ JSValue::isMachineInt怎么用?C++ JSValue::isMachineInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSValue
的用法示例。
在下文中一共展示了JSValue::isMachineInt方法的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: null
static RefPtr<InspectorValue> jsToInspectorValue(ExecState* scriptState, JSValue value, int maxDepth)
{
if (!value) {
ASSERT_NOT_REACHED();
return nullptr;
}
if (!maxDepth)
return nullptr;
maxDepth--;
if (value.isNull() || value.isUndefined())
return InspectorValue::null();
if (value.isBoolean())
return InspectorValue::create(value.asBoolean());
if (value.isNumber() && value.isDouble())
return InspectorValue::create(value.asNumber());
if (value.isNumber() && value.isMachineInt())
return InspectorValue::create(static_cast<int>(value.asMachineInt()));
if (value.isString())
return InspectorValue::create(value.getString(scriptState));
if (value.isObject()) {
if (isJSArray(value)) {
Ref<InspectorArray> inspectorArray = InspectorArray::create();
JSArray* array = asArray(value);
unsigned length = array->length();
for (unsigned i = 0; i < length; i++) {
JSValue element = array->getIndex(scriptState, i);
RefPtr<InspectorValue> elementValue = jsToInspectorValue(scriptState, element, maxDepth);
if (!elementValue)
return nullptr;
inspectorArray->pushValue(WTFMove(elementValue));
}
return WTFMove(inspectorArray);
}
Ref<InspectorObject> inspectorObject = InspectorObject::create();
JSObject* object = value.getObject();
PropertyNameArray propertyNames(scriptState, PropertyNameMode::Strings);
object->methodTable()->getOwnPropertyNames(object, scriptState, propertyNames, EnumerationMode());
for (size_t i = 0; i < propertyNames.size(); i++) {
const Identifier& name = propertyNames[i];
JSValue propertyValue = object->get(scriptState, name);
RefPtr<InspectorValue> inspectorValue = jsToInspectorValue(scriptState, propertyValue, maxDepth);
if (!inspectorValue)
return nullptr;
inspectorObject->setValue(name.string(), WTFMove(inspectorValue));
}
return WTFMove(inspectorObject);
}
ASSERT_NOT_REACHED();
return nullptr;
}
示例3: speculationFromValue
SpeculatedType speculationFromValue(JSValue value)
{
if (value.isEmpty())
return SpecEmpty;
if (value.isInt32())
return SpecInt32;
if (value.isDouble()) {
double number = value.asNumber();
if (number != number)
return SpecDoubleNaN;
if (value.isMachineInt())
return SpecInt52AsDouble;
return SpecNonIntAsDouble;
}
if (value.isCell())
return speculationFromCell(value.asCell());
if (value.isBoolean())
return SpecBoolean;
ASSERT(value.isUndefinedOrNull());
return SpecOther;
}