| 808 | } |
| 809 | |
| 810 | StringBox 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 | |
| 828 | Ref<StaticString> HermesJavaScriptContext::valueToStaticString(const JSValue& value, |
| 829 | JSExceptionTracker& exceptionTracker) { |
nothing calls this directly
no test coverage detected