gpdaniels / spike-prime

Experiments with the LEGO Mindstorms (51515) and SPIKE Prime (45678)
MIT License
282 stars 39 forks source link

Prevent exceptions when parsing hub mpy code #18

Closed markbush closed 3 years ago

markbush commented 3 years ago

The decompiler throws exceptions on a number of the mpy files from the 51515.

One type is due to parsing of the enum keys and values. Some values have curly brackets which causes the simple splitting on these characters to fail. This change replaces the use of split() with a line by line approach.

There is also a situation where stage4_lbd() can be called with i==4 which is used as an index into a list of size 4 causing an index error. The array has been extended by one, but it is not clear if the value used is always correct. The exception is avoided, nonetheless.