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

Trap on incorrect callbacktype signature #175

Closed carllocos closed 1 year ago

carllocos commented 1 year ago

Currently, a callback of any type signature can be subscribed via primitive subscribe_interrupt. This is a problem because the callback handler expects registered callbacks to take 5 arguments given that the callback handler pushes 5 stack values prior setting up the call see resolve_event.

On top of my head, we could throw a trap when registering the callback via the subscribe_interrupt primitive. This avoids an out-of-context type mismatch fatal that the VM throws when

tolauwae commented 1 year ago

This is exactly this feature request: https://github.com/TOPLLab/WARDuino/issues/86 And this TODO: https://github.com/TOPLLab/WARDuino/blob/6cd2bf610d8b1cb87b0178f886360cf3cd6435de/src/WARDuino/CallbackHandler.cpp#L210-L212