@@ -462,8 +462,8 @@ def find(self,key, d=None) :
462
462
If a key is an instance of Tid class, then a term with
463
463
corresponding tid is returned.
464
464
465
- If a key is a number, or an instance of `bil.Int' class, then
466
- a term with a matching address is returned.
465
+ If a key is a number, or an instance of `bil.Int' class or is
466
+ an integer, then a term with a matching address is returned.
467
467
468
468
Example
469
469
-------
@@ -475,24 +475,26 @@ def find(self,key, d=None) :
475
475
>>> main = proj.program.subs.find('main')
476
476
>>> main = proj.program.subs.find(main.id)
477
477
>>> main = proj.program.subs.find(main.id.name)
478
+
478
479
"""
479
- def by_id (t ,key ) : return t .id == key
480
- def by_name (t ,key ) :
481
- if key .startswith (('@' ,'%' )):
482
- return t .id .name == key
480
+ def by_id (t , k ) : return t .id . number == k
481
+ def by_name (t ,k ) :
482
+ if k .startswith (('@' ,'%' )):
483
+ return t .id .name == k
483
484
else :
484
- return hasattr (t ,'name' ) and t .name == key
485
- def by_addr (t ,key ) :
485
+ return hasattr (t , 'name' ) and t .name == k
486
+ def by_addr (t ,k ) :
486
487
value = t .attrs .get ('address' , None )
487
488
if value is not None :
488
489
return parse_addr (value ) == key
489
490
490
491
test = by_addr
491
492
if isinstance (key ,str ):
492
493
test = by_name
493
- elif isinstance (key ,Tid ):
494
+ elif hasattr (key ,'constr' ) and key .constr == 'Tid' :
495
+ key = key .number
494
496
test = by_id
495
- elif isinstance (key ,Int ) :
497
+ elif hasattr (key ,'constr' ) and key . constr == 'Int' :
496
498
key = key .value
497
499
test = by_addr
498
500
0 commit comments