Skip to content

Use a decimal representation for all datatypes in Debugger::printValue#319

Merged
tolauwae merged 1 commit intomainfrom
fix/debugger-hex-floats
Dec 3, 2025
Merged

Use a decimal representation for all datatypes in Debugger::printValue#319
tolauwae merged 1 commit intomainfrom
fix/debugger-hex-floats

Conversation

@MaartenS11
Copy link
Copy Markdown
Member

@MaartenS11 MaartenS11 commented Sep 11, 2025

This simplifies the frontend, which no longer has to parse the value of a stack element in hex if it's a float or in decimal if it's an integer. It can just always parse it as a decimal.

Alternatively, we can also represent all of them as hex, but we should be consistent.

MaartenS11 added a commit to TOPLLab/MIO that referenced this pull request Sep 25, 2025
(This assumes they are sent in decimal format see TOPLLab/WARDuino#319)
This simplifies the frontend which no longer has to parse the value of
a stack element in hex if it's a float or in decimal if it's an
integer. It can just always parse it as a decimal.
@tolauwae tolauwae force-pushed the fix/debugger-hex-floats branch from 1ae01d9 to 667abcc Compare December 3, 2025 08:09
@tolauwae tolauwae enabled auto-merge (squash) December 3, 2025 08:10
@tolauwae tolauwae merged commit ef253a2 into main Dec 3, 2025
15 checks passed
@tolauwae tolauwae deleted the fix/debugger-hex-floats branch December 3, 2025 08:13
tolauwae added a commit that referenced this pull request Dec 4, 2025
@tolauwae tolauwae restored the fix/debugger-hex-floats branch December 4, 2025 18:45
@tolauwae
Copy link
Copy Markdown
Member

tolauwae commented Dec 4, 2025

@MaartenS11 This actually broke Latch tests. This can possibly be fixed on the Latch side, but I want to inquire here first what the reason behind this change was?

@MaartenS11
Copy link
Copy Markdown
Member Author

MaartenS11 commented Dec 7, 2025

@MaartenS11 This actually broke Latch tests. This can possibly be fixed on the Latch side, but I want to inquire here first what the reason behind this change was?

The reason for the change is what basically the description of this PR, but let me maybe elaborate a bit more. Basically, the wasm stack values having a different encoding when they are floats requires parsers to use the "type" field to determine how it should parse another part of the datastucture. I argue that it would be more optimal to just always use the same representation. In this case, the decimal representation of the numbers.

Additionally, the hex values are also formatted without a leading 0x causing parsing to fail using standard json libraries like the one used in MIO. Example:

{"idx":0,"type":"f32","value":3e8}

We could technically keep them hex values if we want, but we should at least add the 0x.

@tolauwae
Copy link
Copy Markdown
Member

tolauwae commented Dec 8, 2025

Ok so probably I just need to update the latch parser. Seems simple enough. I will push a new latch version to this branch and merge when the tests work again.

Thanks for the extra info.

@MaartenS11
Copy link
Copy Markdown
Member Author

Ok so probably I just need to update the latch parser. Seems simple enough. I will push a new latch version to this branch and merge when the tests work again.

Thanks for the extra info.

I do wonder, does latch do something special to parse "value" when it's a float without having the 0x prefix? Or does latch just explicitly parse it as a hex number if it's a float?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants