Ejemplo n.º 1
0
 def visit_For(self, node):
     self.generic_visit(node)
     
     match = node.match
     ssym = match.id
     
     if isfield(ssym) or isfieldaux(ssym):
         return node
     
     if isforwardmember(ssym):
         newmatch = dha.PatMatch(match.target, match.key)
     else:
         newmatch = dha.patmatchToNormal(node.match)
     
     return dha.For(newmatch, node.body, node.orelse)
Ejemplo n.º 2
0
 def visit_For(self, node):
     self.generic_visit(node)
     
     match = node.match
     if dka.hasnodetype(match, dha.PatMatch):
         return
     ssym = match.id
     
     if isfield(ssym):
         attr = ssym.attr
     elif isfieldaux(ssym):
         attr = ssym.host.attr
     else: assert()
     
     if isforwardfield(ssym):
         cont, val = match.key, match.target
         has = dha.HasAttr(cont, attr)
         bind = dha.Assign(val, dha.Attribute(dka.copy(cont), attr))
         newbody = dha.Block([bind] + node.body.stmtlist)
         return dha.If([dha.CondCase(has, newbody)], node.orelse)
     else:
         newmatch = dha.patmatchToNormal(node.match)
         return dha.For(newmatch, node.body, node.orelse)