| 1026 | } |
| 1027 | |
| 1028 | ValueType HermesJavaScriptContext::getValueType(const JSValue& value) { |
| 1029 | auto* hermesValue = toPinnedHermesValue(value); |
| 1030 | if (hermesValue->isUndefined()) { |
| 1031 | return ValueType::Undefined; |
| 1032 | } else if (hermesValue->isNull()) { |
| 1033 | return ValueType::Null; |
| 1034 | } else if (hermesValue->isNumber()) { |
| 1035 | return ValueType::Double; |
| 1036 | } else if (hermesValue->isBool()) { |
| 1037 | return ValueType::Bool; |
| 1038 | } else if (hermesValue->isString()) { |
| 1039 | return ValueType::StaticString; |
| 1040 | } else if (hermesValue->isObject()) { |
| 1041 | hermes::vm::GCScope gcScope(*_runtime); |
| 1042 | |
| 1043 | if (hermes::vm::vmisa<hermes::vm::Callable>(*hermesValue)) { |
| 1044 | return ValueType::Function; |
| 1045 | } |
| 1046 | if (hermes::vm::vmisa<hermes::vm::JSArray>(*hermesValue)) { |
| 1047 | return ValueType::Array; |
| 1048 | } |
| 1049 | if (hermes::vm::vmisa<hermes::vm::JSArrayBuffer>(*hermesValue) || |
| 1050 | hermes::vm::vmisa<hermes::vm::JSTypedArrayBase>(*hermesValue)) { |
| 1051 | return ValueType::TypedArray; |
| 1052 | } |
| 1053 | if (hermes::vm::vmisa<hermes::vm::JSError>(*hermesValue)) { |
| 1054 | return ValueType::Error; |
| 1055 | } |
| 1056 | |
| 1057 | auto jsObjectHandle = hermes::vm::Handle<hermes::vm::JSObject>::vmcast(hermesValue); |
| 1058 | |
| 1059 | if (hasNativeState(*_runtime, jsObjectHandle)) { |
| 1060 | return ValueType::ValdiObject; |
| 1061 | } |
| 1062 | |
| 1063 | if (!getLongConstructor().empty() && |
| 1064 | isInstanceOf(*_runtime, jsObjectHandle, toPinnedHermesValue(getLongConstructor().get()))) { |
| 1065 | return Valdi::ValueType::Long; |
| 1066 | } |
| 1067 | |
| 1068 | return ValueType::Map; |
| 1069 | } |
| 1070 | |
| 1071 | return ValueType::Undefined; |
| 1072 | } |
| 1073 | |
| 1074 | bool HermesJavaScriptContext::isValueUndefined(const JSValue& value) { |
| 1075 | return toHermesValue(value).isUndefined(); |
nothing calls this directly
no test coverage detected