TOPLLab / WARDuino-VSCode

🕵️ A VSCode debugger plugin for WARDuino.
Mozilla Public License 2.0
2 stars 2 forks source link

Hard to distinguish between locals and arguments of a function in the source mapping #114

Closed carllocos closed 1 year ago

carllocos commented 1 year ago

The locals property of FunctionInfo is an array where the elements are either parameters and/or names of the locals declared in the corresponding function.

For instance, the locals for f in the code snippet are p1 and p2; for g the values are g1 and g2


(type $t0 (func (param i32 i32)))

(func $f (param $p1 i32) (param $p2 i32)
   ...
 )

(func $g (type $t0)
  (local $g1 i32)
 (local $g2 i32)
   ...
 )

Currently, the plugin was implemented with the idea that locals only contain locally declared values and thus not parameters, which can thus result in out-of-range exceptions or in the display of redundant information in the variables view of the plugin.

The easiest fix, in my opinion, is to let the wat2wasm tool print alongside the local name also the index of that local name. Thanks to the index we could easily distinguish between the parameters and locals declared within the function. I made a PR for these changes in the tool.