-
-
Notifications
You must be signed in to change notification settings - Fork 402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix all Value
operations and add unsigned shift right
#520
Conversation
Codecov Report
@@ Coverage Diff @@
## master #520 +/- ##
==========================================
- Coverage 68.10% 67.99% -0.12%
==========================================
Files 169 170 +1
Lines 9942 10322 +380
==========================================
+ Hits 6771 7018 +247
- Misses 3171 3304 +133
Continue to review full report at Codecov.
|
Benchmark for 62e6586Click to view benchmark
|
Benchmark for e586af4Click to view benchmark
|
I would move it. It makes sense having everything that's related working similarly and having the same endpoint. If not, it could get a bit messy. |
Benchmark for 5536c64Click to view benchmark
|
This is needed because the operations need context and in certain cases they can throw, so we need to support it.
- Added tests.
- Optimized `to_uint32` and `to_int32`.
932ba10
to
036c7d1
Compare
Benchmark for 5f3389eClick to view benchmark
|
Benchmark for aceb394Click to view benchmark
|
Benchmark for 6d6afb9Click to view benchmark
|
Benchmark for a5c1d76Click to view benchmark
|
Value
s to_
conversions methodsValue
operations
Value
operationsValue
operations and add unsigned shift right
This PR fixes all The This PR is ready, it would be nice to have fully working operators in |
Benchmark for efe1953Click to view benchmark
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks perfect!
What is the problem with the current implementation of
Value
s operations?The problem is that they are not spec compliant for objects, for example
ToNumber
(to_number
) for objects it is supposed to callto_primitive
and because it does not the codenew Number(6) + 3
is broken and does not give the expected output9
. Also becauseto_number
is called byValue
s operators, this means that theValue
operations can throw exceptions and it requires context and should return aResultValue
.It changes the following:
Value::is_true()
(this is a duplicate ofto_boolean
)to_int32
,to_uint32
andto_length
toInterpreter
to_integer
spec compliantValue
operators => functions (these functions take in anInterpreter
, and can throw in certain cases, see example)Value
operations spec compliant.Value
operationsThe below code is fixed with this PR:
I'm not sure if I should move
to_boolean
toInterpreter
, because it's the only one that can't throw and does not need context