Exemplo n.º 1
0
 def matchNotList(self):
     if not self.isFinal:
         # preprocess unions
         if ErlType.isUnion(self.typ):
             inner_types = cc.get_inner_types_from_union(self.typ)
             isCnd = lambda x: not ErlType.isList(x) and not ErlType.isNil(x) and not ErlType.isNonemptyList(x)
             candidates = [tp for tp in inner_types if isCnd(tp)]
             if len(candidates) > 0:
                 cc.set_inner_types_to_union(self.typ, candidates)
             else:
                 # TODO Log inconsistency
                 pass
         if ErlType.isList(self.typ) or ErlType.isNil(self.typ) or ErlType.isNonemptyList(self.typ):
             # TODO Log inconsistency
             pass
Exemplo n.º 2
0
 def notMatchTuple(self):
     if not self.isFinal:
         # preprocess unions
         if ErlType.isUnion(self.typ):
             inner_types = cc.get_inner_types_from_union(self.typ)
             isCnd = lambda x: not ErlType.isTupleDet(x) and not ErlType.isTuple(x)
             candidates = [tp for tp in inner_types if isCnd(tp)]
             if len(candidates) > 0:
                 cc.set_inner_types_to_union(self.typ, candidates)
             else:
                 # TODO Log inconsistency
                 pass
         # actual type elaborations
         if ErlType.isTupleDet(self.typ) or ErlType.isTuple(self.typ):
             # TODO Log inconsistency
             pass
Exemplo n.º 3
0
 def matchNotNil(self):
     if not self.isFinal:
         # preprocess unions
         if ErlType.isUnion(self.typ):
             inner_types = cc.get_inner_types_from_union(self.typ)
             candidates = [tp for tp in inner_types if not ErlType.isNil(tp)]
             for cnd in candidates:
                 if ErlType.isList(cnd):
                     ErlType.setNonEmptyListType(cnd)
             if len(candidates) > 0:
                 cc.set_inner_types_to_union(self.typ, candidates)
             else:
                 # TODO Log inconsistency
                 pass
         elif ErlType.isList(self.typ):
             self.matchCons()
Exemplo n.º 4
0
 def revMatchCons(self):
     if not self.isFinal:
         # preprocess unions
         if ErlType.isUnion(self.typ):
             inner_types = cc.get_inner_types_from_union(self.typ)
             candidates = [tp for tp in inner_types if not ErlType.isNonemptyList(tp)]
             if len(candidates) > 0:
                 cc.set_inner_types_to_union(self.typ, candidates)
                 new_inner_types = cc.get_inner_types_from_union(self.typ)
                 for tp in new_inner_types:
                     if ErlType.isList(tp):
                         ErlType.setNilType(tp)
         # actual type elaborations
         if ErlType.isList(self.typ):
             ErlType.setNilType(self.typ)
             self.isFinal = True
Exemplo n.º 5
0
 def unifyWithAtom(self, tp):
     if tp.isAtom():
         return True
     if tp.isAtomLit():
         self.takenOverByType(tp)
         return True
     if tp.isUnion():
         isCnd = lambda x: ErlType.isAtom(x)
         inner_types = cc.get_inner_types_from_union(tp.typ)
         candidates = [t for t in inner_types if isCnd(t)]
         if len(candidates) > 0:
             return True
         isCnd = lambda x: ErlType.isAtomLit(x)
         candidates = [t for t in inner_types if isCnd(t)]
         if len(candidates) > 0:
             cc.set_inner_types_to_union(tp, candidates)
             self.takenOverByType(tp)
             return True
     return False