i have linked list pretty printer takes input command prompt. e.g., print xyz
my code below:
class randomcalss: def __init__(self, val): self.val = int(val) def to_string(self): return "printing linked list:" def children(self): field in self.val.type.fields(): key = field.name val = self.val[key] yield key,val.dereference()
it work expected, , prints:
printing linked list:= {head = {next = 0x625590, prev = 0x623c70}}
but if want traverse linked list , proceed further do. because every time try access head['next'] says head string , string indices must integers.
cant self.val[key] access next node of head too?
you can val.dereference()['next'] , give address of next member of list. can cast value obtained(if required) , traverse further.
Comments
Post a Comment