neo-project / neo-debugger

Neo Smart Contract Debugger for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=ngd-seattle.neo-contract-debug
MIT License
24 stars 17 forks source link

Add support for closure record parameters/variables #198

Open devhawk opened 1 year ago

devhawk commented 1 year ago

In the TS compiler, closure variables/parameters can live inside a NeoVM array. In order to display them correctly in the debugger, the TS compiler is adopting a dotted index syntax to provide enough details to the debugger. This change will be documented in NEP-19 when it has been implemented / tested in both the TS compiler and debugger.

A DebugInfo Variable has three fields: name, type and index. Index is an optional field - if not specified, the index of the variable instance inside the containing array is used as the index. current, Index is a numeric field indicating the index of the collection in question (parameters, variables, staticVariables) is associated with the specified name/type.

With this change, the index field will support a dotted syntax such as 0.1. The values before and after the dot MUST be integers. The value before the dot represents the index into the specified collection, similar to how the index is specified today. The value after the dot represents the index into the array at the location specified by the first dot. If the value in the specified collection is not an array, the debugger will fail to resolve the variable.

Note, this scheme is potentially extensible to support nested collections (i.e. 0.1.2) and maps (i.e. 0.somekey). It is not expected this will be needed for the TS compiler, so we are constraining the design to a single numeric value after the dot.