| 399 | } |
| 400 | return toRetainedJSValueRef(IndirectV8Persistent::make(_isolate, result)); |
| 401 | } |
| 402 | |
| 403 | Ref<BigInt> V8JavaScriptContext::valueToBigInt(const JSValue& value, JSExceptionTracker& exceptionTracker) { |
| 404 | v8::HandleScope handleScope(_isolate); |
| 405 | auto jsValue = fromValdiJSValue(_isolate, value, exceptionTracker); |
| 406 | if (!exceptionTracker) { |
| 407 | return nullptr; |
| 408 | } |
| 409 | if (!jsValue->IsBigInt()) { |
| 410 | exceptionTracker.onError("Expected bigint"); |
| 411 | return nullptr; |
| 412 | } |
| 413 | bool lossless; |
| 414 | auto integer = jsValue.As<v8::BigInt>()->Int64Value(&lossless); |
| 415 | if (lossless) { |
| 416 | return BigInt::make(integer); |
| 417 | } |
| 418 | |
| 419 | v8::TryCatch catcher(_isolate); |
| 420 | auto context = _context.Get(_isolate); |
| 421 | v8::Context::Scope contextScope(context); |