@@ -1075,7 +1075,7 @@ def to_yaml(scfg: "SCFG") -> str:
1075
1075
return ys
1076
1076
1077
1077
@staticmethod
1078
- def to_dict (scfg : "SCFG" ) -> Dict [str , Dict [str , BasicBlock ]]:
1078
+ def to_dict (scfg : "SCFG" ) -> Dict [str , Dict [str , Any ]]:
1079
1079
"""Helper method to convert the SCFG object to a dictionary
1080
1080
representation.
1081
1081
@@ -1109,7 +1109,8 @@ def reverse_lookup(value: type) -> str:
1109
1109
# Order of elements doesn't matter since they're going to
1110
1110
# be sorted at the end.
1111
1111
graph_dict = {}
1112
- q .update (set (scfg .graph .keys ()))
1112
+ all_keys : set [str ] = set (scfg .graph .keys ())
1113
+ q .update (all_keys )
1113
1114
graph_dict .update (scfg .graph )
1114
1115
1115
1116
while q :
@@ -1119,18 +1120,20 @@ def reverse_lookup(value: type) -> str:
1119
1120
continue
1120
1121
seen .add (key )
1121
1122
1122
- block_type = reverse_lookup (type (value ))
1123
+ block_type : str = reverse_lookup (type (value ))
1123
1124
blocks [key ] = {"type" : block_type }
1124
1125
if isinstance (value , RegionBlock ):
1125
- q .update (value .subregion .graph .keys ())
1126
- graph_dict .update (value .subregion .graph )
1126
+ inner_graph = value .subregion .graph # type: ignore
1127
+ q .update (inner_graph .keys ())
1128
+ graph_dict .update (inner_graph )
1127
1129
blocks [key ]["kind" ] = value .kind
1128
1130
blocks [key ]["contains" ] = sorted (
1129
- [idx .name for idx in value . subregion . graph .values ()]
1131
+ [idx .name for idx in inner_graph .values ()]
1130
1132
)
1131
1133
blocks [key ]["header" ] = value .header
1132
1134
blocks [key ]["exiting" ] = value .exiting
1133
- blocks [key ]["parent_region" ] = value .parent_region .name
1135
+ parent_name = value .parent_region .name # type: ignore
1136
+ blocks [key ]["parent_region" ] = parent_name
1134
1137
elif isinstance (value , SyntheticBranch ):
1135
1138
blocks [key ]["branch_value_table" ] = value .branch_value_table
1136
1139
blocks [key ]["variable" ] = value .variable
@@ -1142,9 +1145,13 @@ def reverse_lookup(value: type) -> str:
1142
1145
edges [key ] = sorted ([i for i in value ._jump_targets ])
1143
1146
backedges [key ] = sorted ([i for i in value .backedges ])
1144
1147
1145
- graph_dict = {"blocks" : blocks , "edges" : edges , "backedges" : backedges }
1148
+ graph_dict = {
1149
+ "blocks" : blocks , # type: ignore
1150
+ "edges" : edges , # type: ignore
1151
+ "backedges" : backedges , # type: ignore
1152
+ }
1146
1153
1147
- return graph_dict
1154
+ return graph_dict # type: ignore
1148
1155
1149
1156
@staticmethod
1150
1157
def find_outer_graph (graph_dict : Dict [str , Dict [str , Any ]]) -> Set [str ]:
@@ -1179,7 +1186,7 @@ def extract_block_info(
1179
1186
block_ref_dict : Dict [str , str ],
1180
1187
edges : Dict [str , List [str ]],
1181
1188
backedges : Dict [str , List [str ]],
1182
- ) -> Tuple [Dict [str , Any ], str , Tuple [str , ... ], Tuple [str , ... ]]:
1189
+ ) -> Tuple [Dict [str , Any ], str , list [str ], list [str ]]:
1183
1190
"""Helper method to extract information from various components of
1184
1191
an `SCFG` graph.
1185
1192
0 commit comments