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

Method valueToString

valdi/src/valdi/hermes/HermesJavaScriptContext.cpp:810–826  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

808}
809
810StringBox HermesJavaScriptContext::valueToString(const JSValue& value, JSExceptionTracker& exceptionTracker) {
811 hermes::vm::GCScope gcScope(*_runtime);
812 auto result = toString(*_runtime, toHermesValue(value));
813
814 if (!checkException(result.getStatus(), exceptionTracker)) {
815 return StringBox();
816 }
817
818 auto stringView =
819 hermes::vm::StringPrimitive::createStringView(*_runtime, _runtime->makeHandle(std::move(result.getValue())));
820
821 if (stringView.isASCII()) {
822 return StringCache::getGlobal().makeString(stringView.castToCharPtr(), stringView.length());
823 } else {
824 return StringCache::getGlobal().makeStringFromUTF16(stringView.castToChar16Ptr(), stringView.length());
825 }
826}
827
828Ref<StaticString> HermesJavaScriptContext::valueToStaticString(const JSValue& value,
829 JSExceptionTracker& exceptionTracker) {

Callers

nothing calls this directly

Calls 8

getGlobalFunction · 0.85
getStatusMethod · 0.80
makeStringMethod · 0.80
makeStringFromUTF16Method · 0.80
toStringFunction · 0.70
getValueMethod · 0.65
StringBoxClass · 0.50
lengthMethod · 0.45

Tested by

no test coverage detected