Lines Matching refs:decl
23 for decl in typedecls:
24 if decl.shortkey not in typespecs:
25 typespecs[decl.shortkey] = [decl]
27 typespecs[decl.shortkey].append(decl)
31 def analyze_decl(decl, typespecs, knowntypespecs, types, knowntypes, *,
33 resolved = resolve_decl(decl, typespecs, knowntypespecs, types)
35 # The decl is supposed to be skipped or ignored.
39 return analyze_resolved(resolved, decl, types, knowntypes)
49 for decl in unresolved:
50 resolved = analyze_decl(decl)
52 # The decl should be skipped or ignored.
53 types[decl] = IGNORED
54 updated.append(decl)
58 raise NotImplementedError(decl)
60 # At least one dependency is unknown, so this decl
62 types[decl] = UNKNOWN
63 updated.append(decl)
69 if decl.kind is KIND.STRUCT or decl.kind is KIND.UNION:
72 for member, dep in zip(decl.members, typedeps):
74 if member.vartype.typespec != decl.shortkey:
77 typedeps[i] = decl
82 types[decl] = resolved
83 updated.append(decl)
85 for decl in updated:
86 unresolved.remove(decl)
100 def resolve_decl(decl, typespecs, knowntypespecs, types):
101 if decl.kind is KIND.ENUM:
104 if decl.kind is KIND.VARIABLE:
105 vartypes = [decl.vartype]
106 elif decl.kind is KIND.FUNCTION:
107 vartypes = [decl.signature.returntype]
108 elif decl.kind is KIND.TYPEDEF:
109 vartypes = [decl.vartype]
110 elif decl.kind is KIND.STRUCT or decl.kind is KIND.UNION:
111 vartypes = [m.vartype for m in decl.members]
126 typedecl = find_typedecl(decl, typespec, typespecs)
128 typedecl = find_typedecl(decl, typespec, knowntypespecs)
149 def find_typedecl(decl, typespec, typespecs):
154 filename = decl.filename
171 raise NotImplementedError((decl, samefile, typedecl))
174 # If the decl is in a source file then we expect the
191 raise NotImplementedError((decl, candidates))
214 for decl in types: # Preserve the original order.
215 if decl not in unresolved:
216 assert types[decl] is not None, decl
217 if types[decl] in (UNKNOWN, IGNORED):
218 unresolved.add(decl)
220 _dump_unresolved(decl, types, analyze_decl)
223 assert types[decl][0] is not None, (decl, types[decl])
224 assert None not in types[decl][0], (decl, types[decl])
226 assert types[decl] is None
228 _dump_unresolved(decl, types, analyze_decl)
232 for decl in unresolved:
233 types[decl] = ([_SKIPPED], None)
235 for decl in types:
236 assert types[decl]
239 def _dump_unresolved(decl, types, analyze_decl):
240 if isinstance(decl, str):
241 typespec = decl
242 decl, = (d for d in types if d.shortkey == typespec)
243 elif type(decl) is tuple:
244 filename, typespec = decl
249 # raise NotImplementedError(decl)
250 decl, = found
256 #raise NotImplementedError(decl)
258 decl, = found
259 resolved = analyze_decl(decl)
263 if decl.kind is KIND.STRUCT or decl.kind is KIND.UNION:
264 print(f'*** {decl.shortkey} {decl.filename}')
265 for member, mtype in zip(decl.members, typedeps):
267 if typespec == decl.shortkey:
281 and d.filename == decl.filename]
305 print(f'*** {decl} ({decl.vartype!r})')
306 if decl.vartype.typespec.startswith('struct ') or is_funcptr(decl):
308 (decl.filename, decl.vartype.typespec),