add another bad hack in parser.py which identifies "undefined" slice assignment
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 19 Jun 2020 14:21:15 +0000 (15:21 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 19 Jun 2020 14:21:15 +0000 (15:21 +0100)
src/soc/decoder/pseudo/parser.py

index dae0e4e8df4c8ae0726cc216f3cda1e30235d299..6446a2df822db8e33b92e80a9863b4522ca21caa 100644 (file)
@@ -43,8 +43,13 @@ def Assign(autoassign, assignname, left, right, iea_mode):
         ass_list = [ast.AssName(name, 'OP_ASSIGN') for name in names]
         return ast.Assign([ast.AssTuple(ass_list)], right)
     elif isinstance(left, ast.Subscript):
-        res = ast.Assign([left], right)
         ls = left.slice
+        if (isinstance(ls, ast.Slice) and isinstance(right, ast.Name) and
+            right.id == 'undefined'):
+            # undefined needs to be copied the exact same slice
+            right =  ast.Subscript(right, ls, ast.Load())
+            return ast.Assign([left], right)
+        res = ast.Assign([left], right)
         if autoassign and isinstance(ls, ast.Slice):
             # hack to create a variable pre-declared based on a slice.
             # dividend[0:32] = (RA)[0:32] will create