@@ -462,8 +462,8 @@ def find(self,key, d=None) :
462462 If a key is an instance of Tid class, then a term with
463463 corresponding tid is returned.
464464
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.
467467
468468 Example
469469 -------
@@ -475,24 +475,26 @@ def find(self,key, d=None) :
475475 >>> main = proj.program.subs.find('main')
476476 >>> main = proj.program.subs.find(main.id)
477477 >>> main = proj.program.subs.find(main.id.name)
478+
478479 """
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
483484 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 ) :
486487 value = t .attrs .get ('address' , None )
487488 if value is not None :
488489 return parse_addr (value ) == key
489490
490491 test = by_addr
491492 if isinstance (key ,str ):
492493 test = by_name
493- elif isinstance (key ,Tid ):
494+ elif hasattr (key ,'constr' ) and key .constr == 'Tid' :
495+ key = key .number
494496 test = by_id
495- elif isinstance (key ,Int ) :
497+ elif hasattr (key ,'constr' ) and key . constr == 'Int' :
496498 key = key .value
497499 test = by_addr
498500
0 commit comments