Support static array of tuples

This commit is contained in:
Johan B.W. de Vries 2023-11-15 11:40:24 +01:00
parent fcbd32a880
commit 4a4c62c728
3 changed files with 6 additions and 8 deletions

View File

@ -39,7 +39,7 @@ def type3(inp: Type3OrPlaceholder) -> str:
assert isinstance(inp.args[0], Type3), TYPE3_ASSERTION_ERROR
assert isinstance(inp.args[1], type3types.IntType3), TYPE3_ASSERTION_ERROR
return inp.args[0].name + '[' + inp.args[1].name + ']'
return type3(inp.args[0]) + '[' + inp.args[1].name + ']'
return inp.name

View File

@ -644,8 +644,6 @@ class OurVisitor:
_raise_static_error(node, f'Unrecognized type {node.id}')
if isinstance(node, ast.Subscript):
if not isinstance(node.value, ast.Name):
_raise_static_error(node, 'Must be name')
if isinstance(node.slice, ast.Slice):
_raise_static_error(node, 'Must subscript using an index')
if not isinstance(node.slice, ast.Constant):
@ -655,11 +653,6 @@ class OurVisitor:
if not isinstance(node.ctx, ast.Load):
_raise_static_error(node, 'Must be load context')
if (
node.value.id not in type3types.LOOKUP_TABLE
and node.value.id not in module.struct_definitions): # FIXME: Tuple of tuples?
_raise_static_error(node, f'Unrecognized type {node.value.id}')
return type3types.AppliedType3(
type3types.static_array,
[self.visit_type(module, node.value), type3types.IntType3(node.slice.value)],

View File

@ -0,0 +1,5 @@
{
"TYPE_NAME": "static_array_tuple_u32_u32_3",
"TYPE": "(u32, u32, )[3]",
"VAL0": "((1, 100, ), (2, 200, ), (3, 300, ), )"
}