Skip to content

Commit

Permalink
feat: Improve recursion error
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKevinWeiss committed Nov 3, 2022
1 parent a36b77e commit 5439bd2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions memory_map_manager/mmm_config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ def _resolve_typedef_order(self, typedefs):
known_types = list(self.PRIMARIES.keys())
kbfe = list(self._bfs.keys())
kbfe.extend(self._enums.keys())
unresolved_types = []
while True:
type_count = len(known_types)
finished = True
Expand All @@ -652,17 +653,22 @@ def _resolve_typedef_order(self, typedefs):
r_type = ele.get('type', self.default_type)
if r_type not in known_types and r_type not in kbfe:
finished = False
unresolved_types.append(r_type)
break
else:
known_types.append(td_name)
if td_name in unresolved_types:
unresolved_types.remove(td_name)

if finished:
break
if type_count == len(known_types):
missing_deps = set(typedefs.keys()) - set(known_types)
raise RecursionError(f'Cannot resolve {missing_deps} types '
unresolved_types = list(set(unresolved_types))
missing_deps = list(set(typedefs.keys()) - set(known_types))
raise RecursionError(f'Cannot resolve {missing_deps} typedefs '
'due to missing definition/circular '
'dependency')
f'dependency/typo. {unresolved_types} '
'types are not resolved.')
return [x for x in known_types if x not in self.PRIMARIES]

def _calc_rtype(self, bit_total, r_type):
Expand Down

0 comments on commit 5439bd2

Please sign in to comment.