TOPLLab / WARDuino

📟 A dynamic WebAssembly VM for embedded systems
https://topllab.github.io/WARDuino/
Mozilla Public License 2.0
73 stars 7 forks source link

Add update stackvalue message #155

Closed carllocos closed 1 year ago

carllocos commented 1 year ago

This PR adds to WARDuino the ability to update stack values. Concretely what the PR does:

carllocos commented 1 year ago

@tolauwae something to keep in mind regarding this PR. I did not fully follow the same approach as the refactorings that you did in https://github.com/TOPLLab/WARDuino/pull/151#pullrequestreview-1387840940

There are two reasons for this:

  1. I believe that network communication should be minimised between tool clients and the VM as this can drain battery life. Although this is less of an issue in development mode, taking this already into account opens the possibility to still explore our tooling support, with lower source code modifications, in more realistic setups where battery life would be a factor. In theory, printing the last string that specifies what change has been applied suffices for tool clients to confirm that the operation was successful.
  2. And also because I believe that there is a bug in the last print statement: https://github.com/TOPLLab/WARDuino/blob/c586b8ea7ee808011ff6aceec6b3441896b4e41a/src/Debug/debugger.cpp#L1154 I think the format specifier only works if the updated value is of type uint32_t, what if we update a f32, or f64? So to circumvent this potential bug, in my case, the last print statement just prints the index of the value that got updated. This is also found in the local update handler https://github.com/TOPLLab/WARDuino/blob/c586b8ea7ee808011ff6aceec6b3441896b4e41a/src/Debug/debugger.cpp#L653.