MCPcopy Create free account
hub / github.com/Snapchat/Valdi / getValueType

Method getValueType

valdi/src/valdi/hermes/HermesJavaScriptContext.cpp:1028–1072  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1026 return;
1027 }
1028 auto symbolId = hermes::vm::stringToSymbolID(*_runtime, std::move(strResult.getValue()));
1029 if (!checkException(symbolId.getStatus(), exceptionTracker)) {
1030 return;
1031 }
1032
1033 propertyName = toPropertyNameRef(symbolId.getValue());
1034 }
1035
1036 if (!propertyName.empty()) {
1037 if (!visitor.visitPropertyName(*this, object, propertyName.get(), exceptionTracker)) {
1038 return;
1039 }
1040 }
1041 }
1042}
1043
1044static hermes::vm::CallResult<hermes::vm::PseudoHandle<hermes::vm::StringPrimitive>> toString(
1045 hermes::vm::Runtime& runtime, const hermes::vm::HermesValue& value) {
1046 return hermes::vm::toString_RJS(runtime, runtime.makeHandle(value));
1047}
1048
1049StringBox HermesJavaScriptContext::valueToString(const JSValue& value, JSExceptionTracker& exceptionTracker) {
1050 hermes::vm::GCScope gcScope(*_runtime);
1051 auto result = toString(*_runtime, toHermesValue(value));
1052
1053 if (!checkException(result.getStatus(), exceptionTracker)) {
1054 return StringBox();
1055 }
1056
1057 auto stringView =
1058 hermes::vm::StringPrimitive::createStringView(*_runtime, _runtime->makeHandle(std::move(result.getValue())));
1059
1060 if (stringView.isASCII()) {
1061 return StringCache::getGlobal().makeString(stringView.castToCharPtr(), stringView.length());
1062 } else {
1063 return StringCache::getGlobal().makeStringFromUTF16(stringView.castToChar16Ptr(), stringView.length());
1064 }
1065}
1066
1067Ref<StaticString> HermesJavaScriptContext::valueToStaticString(const JSValue& value,
1068 JSExceptionTracker& exceptionTracker) {
1069 hermes::vm::GCScope gcScope(*_runtime);
1070 auto result = toString(*_runtime, toHermesValue(value));
1071
1072 if (!checkException(result.getStatus(), exceptionTracker)) {
1073 return nullptr;
1074 }
1075

Callers

nothing calls this directly

Calls 10

hasNativeStateFunction · 0.85
isInstanceOfFunction · 0.85
isBoolMethod · 0.80
getMethod · 0.65
isUndefinedMethod · 0.45
isNullMethod · 0.45
isNumberMethod · 0.45
isStringMethod · 0.45
isObjectMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected