2017-10-16 14:25:06 -04:00
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
import libadalang as lal
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctx = lal.AnalysisContext()
|
|
|
|
|
u = ctx.get_from_file('pkg.ads')
|
|
|
|
|
if u.diagnostics:
|
|
|
|
|
for d in u.diagnostics:
|
|
|
|
|
print('error: {}'.format(d))
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
decls = u.root.findall(lal.ObjectDecl)
|
|
|
|
|
d1, d2 = decls
|
|
|
|
|
n = d2.f_default_expr
|
|
|
|
|
|
2017-10-17 09:40:41 -04:00
|
|
|
node_dict = dict((node, repr(node)) for node in (d1, d2, n))
|
|
|
|
|
|
2020-05-12 17:22:48 +02:00
|
|
|
print('d1: {}'.format(d1))
|
|
|
|
|
print('d2: {}'.format(d2))
|
2017-10-16 14:25:06 -04:00
|
|
|
if not d2.p_resolve_names:
|
|
|
|
|
print('Resolution failed')
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
2018-11-08 19:28:33 +01:00
|
|
|
resolved = n.p_referenced_decl()
|
2020-05-12 17:22:48 +02:00
|
|
|
print('resolved: {}'.format(resolved))
|
2017-10-16 14:25:06 -04:00
|
|
|
|
|
|
|
|
if d1 != d1:
|
|
|
|
|
print('Self comparison failed')
|
|
|
|
|
|
2017-10-17 09:40:41 -04:00
|
|
|
new_d1 = u.root.find(lal.ObjectDecl)
|
|
|
|
|
if d1 != new_d1:
|
2017-10-16 14:25:06 -04:00
|
|
|
print('Simple comparison failed')
|
|
|
|
|
|
|
|
|
|
if d1 == resolved:
|
2017-10-17 09:40:41 -04:00
|
|
|
print('Entity info ignored for comparison')
|
|
|
|
|
|
2020-05-12 17:22:48 +02:00
|
|
|
print('Dict lookup: {}'.format(node_dict[new_d1]))
|
2017-10-16 14:25:06 -04:00
|
|
|
|
|
|
|
|
print('Done.')
|