diff options
author | 2023-03-22 18:09:51 -0700 | |
---|---|---|
committer | 2023-03-22 18:09:51 -0700 | |
commit | 31c2fea74af66d60dceab608b1cfdd9a3f08a7db (patch) | |
tree | 97f871a571ed2d48d3ef2d92240b3dcc0cdbf6b1 /src/bun.js/bindings/bindings.cpp | |
parent | a5f92224b586289fc72f0abdb68b08eef9f017db (diff) | |
download | bun-31c2fea74af66d60dceab608b1cfdd9a3f08a7db.tar.gz bun-31c2fea74af66d60dceab608b1cfdd9a3f08a7db.tar.zst bun-31c2fea74af66d60dceab608b1cfdd9a3f08a7db.zip |
A couple bug fixes (#2458)
* fix valid status code range
* update path
* highwatermark option
* throw DOMException
* remove extra transpiler output
* more transpiler tests
* comment
* get index not quickly
* replace with `getDirectIndex`
* update abort test
* throw out of range status code
* promisify test fix
* move stdio test instance files
* working crypto tests
* allow duplicate set-cookie headers
* different formatting
* revert, fix will be in different pr
* it is called
* use min buffer size
* fix url tests
* null origin for other protocols
* remove overload
* add very large file test
* await
* coerce to int64
* 64
* no cast
* add todo blob url tests
* use `tryConvertToInt52`
Diffstat (limited to 'src/bun.js/bindings/bindings.cpp')
-rw-r--r-- | src/bun.js/bindings/bindings.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index a5af29128..f43bfd4b8 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -478,12 +478,10 @@ bool Bun__deepEquals(JSC__JSGlobalObject* globalObject, JSValue v1, JSValue v2, } for (uint64_t i = 0; i < length; i++) { - // array holes come back as empty values with tryGetIndexQuickly() JSValue left = o1->canGetIndexQuickly(i) ? o1->getIndexQuickly(i) : o1->tryGetIndexQuickly(i); RETURN_IF_EXCEPTION(*scope, false); - JSValue right = o2->canGetIndexQuickly(i) ? o2->getIndexQuickly(i) : o2->tryGetIndexQuickly(i); @@ -2834,9 +2832,28 @@ int32_t JSC__JSValue__toInt32(JSC__JSValue JSValue0) return JSC::JSValue::decode(JSValue0).asInt32(); } +// truncates values larger than int32 int32_t JSC__JSValue__coerceToInt32(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1) { JSC::JSValue value = JSC::JSValue::decode(JSValue0); + if (value.isCell() && value.isHeapBigInt()) { + return static_cast<int32_t>(value.toBigInt64(arg1)); + } + return value.toInt32(arg1); +} + +int64_t JSC__JSValue__coerceToInt64(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1) +{ + JSValue value = JSValue::decode(JSValue0); + if (value.isCell() && value.isHeapBigInt()) { + return value.toBigInt64(arg1); + } + + int64_t result = tryConvertToInt52(value.asDouble()); + if (result != JSValue::notInt52) { + return result; + } + return value.toInt32(arg1); } |