Repository navigation
Add float opcode handlers - #1127
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## ion11 #1127 +/- ##
========================================
Coverage ? 68.79%
Complexity ? 6060
========================================
Files ? 196
Lines ? 24837
Branches ? 4346
========================================
Hits ? 17087
Misses ? 6424
Partials ? 1326 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
popematt
left a comment
There was a problem hiding this comment.
While the overall code looks correct, I'd like to suggest a slightly different factoring that has a cleaner separation of concerns and will make it easier to re-use some of the code.
I'd recommend creating a utility function such as Short.asHalfToFloat(), and then in the opcode handlers, you have something like this:
val floatValue = byteArray.readShort(position).asHalfToFloat()
BytecodeEmitter.emitFloatValue(destination, floatValue)
return 2Why? This keeps the float conversion logic separated from the concerns of reading from the byte array, and it means that all of our utility functions are focused with a single responsibility. And when we implement bytecode generators for e.g. ByteBuffer or InputStream, we can read an integer value from those, and then re-use the same conversion logic to get the respective float or double values.
| p += hourValueAndLength.toInt() and 0xFF | ||
| hour = (hourValueAndLength shr 8).toInt() | ||
| if (p >= end) { | ||
| // TODO: ion-java#1114 |
There was a problem hiding this comment.
It's okay that you've included this change, but don't go out of your way to find things like this that are not directly related to the code you're working on. It's good to keep the PRs focused.
Good suggestion, definitely more organized this way |
Description of changes:
0x6a-0x6d)By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.