Пример #1
0
    def visit_List(self, node):
        if not node.elts:  # empty list
            return "pythonic::__builtin__::functor::list{}()"
        else:
            elts = [self.visit(n) for n in node.elts]
            elts_type = [DeclType(elt) for elt in elts]
            elts_type = CombinedTypes(*elts_type)

            # constructor disambiguation, clang++ workaround
            if len(elts) == 1:
                elts.append('pythonic::types::single_value()')

            node_type = ListType(elts_type)
            return "{0}({{{1}}})".format(Assignable(node_type),
                                         ", ".join(elts))
Пример #2
0
 def op(*types):
     if len(types) == 1:
         return types[0]
     else:
         return CombinedTypes(*types)
Пример #3
0
 def op(*types):
     nonweaks = [t for t in types if not t.isweak()]
     if len(nonweaks) == 1:
         return nonweaks[0]
     else:
         return CombinedTypes(*nonweaks)