def __init__(self, frame, anchor, value): from pyntch.basic_types import BoolType self.value = value ExpressionNode.__init__(self, frame, anchor) BoolType.get_object().connect(self.recv) self.value.connect(self.recv) return
def __init__(self, frame, anchor, op, nodes): from pyntch.basic_types import BoolType self.op = op self.nodes = nodes ExpressionNode.__init__(self, frame, anchor) if op == 'Or' and not [ 1 for node in nodes if isinstance(node, SimpleTypeNode) ]: BoolType.get_object().connect(self.recv) for node in self.nodes: node.connect(self.recv) return
def __init__(self, frame, anchor, op, left, right): from pyntch.basic_types import BoolType self.op = op self.left = left self.right = right self.received = set() ExpressionNode.__init__(self, frame, anchor) BoolType.get_object().connect(self.recv) if op not in ('is', 'is not'): self.left.connect(self.recv_left) return
def create_attr(self, frame, anchor, name): if name == 'copy': setobj = self.get_type().create_copy(frame, anchor, self) return BuiltinConstMethod('set.copy', setobj) elif name == 'difference': setobj = self.get_type().create_copy(frame, anchor, self) return BuiltinConstMethod('set.difference', setobj, [[ANY]]) elif name == 'intersection': return SetObject.Intersection('set.intersection', self) elif name == 'issubset': return BuiltinConstMethod('set.issubset', BoolType.get_object(), [[ANY]]) elif name == 'issuperset': return BuiltinConstMethod('set.issuperset', BoolType.get_object(), [[ANY]]) elif name == 'symmetric_difference': setobj = self.get_type().create_copy(frame, anchor, self) return self.SequenceExtender('set.symmetric_difference', setobj, setobj, [ANY]) elif name == 'union': setobj = self.get_type().create_copy(frame, anchor, self) return self.SequenceExtender('set.union', setobj, setobj, [ANY]) raise NodeAttrError(name)
def create_attr(self, frame, anchor, name): if name == 'clear': return BuiltinConstMethod('dict.clear', NoneType.get_object()) elif name == 'copy': dictobj = self.get_type().create_copy(frame, anchor, self) return BuiltinConstMethod('dict.copy', dictobj) elif name == 'fromkeys': return DictType.FromKeys('dict.fromkeys') elif name == 'get': return DictObject.Get(self, 'dict.get') elif name == 'has_key': return BuiltinConstMethod('dict.has_key', BoolType.get_object(), [ANY]) elif name == 'keys': return BuiltinConstMethod('dict.keys', ListType.create_list(self.key)) elif name == 'values': return BuiltinConstMethod('dict.values', ListType.create_list(self.value)) elif name == 'items': return BuiltinConstMethod( 'dict.items', ListType.create_list( TupleType.create_tuple([self.key, self.value]))) elif name == 'iterkeys': return BuiltinConstMethod('dict.iterkeys', IterType.create_iter(self.key)) elif name == 'itervalues': return BuiltinConstMethod('dict.itervalues', IterType.create_iter(self.value)) elif name == 'iteritems': return BuiltinConstMethod( 'dict.iteritems', IterType.create_iter( TupleType.create_tuple([self.key, self.value]))) elif name == 'pop': return DictObject.Pop(self, 'dict.pop') elif name == 'popitem': return BuiltinConstMethod( 'dict.popitem', TupleType.create_tuple([self.key, self.value]), expts=[ErrorConfig.MaybeElementNotFound()]) elif name == 'setdefault': return DictObject.SetDefault(self, 'dict.setdefault') elif name == 'update': return DictObject.Update(self, 'dict.update') raise NodeAttrError(name)
def create_attr(self, frame, anchor, name): if name == 'clear': return BuiltinConstMethod('dict.clear', NoneType.get_object()) elif name == 'copy': dictobj = self.get_type().create_copy(frame, anchor, self) return BuiltinConstMethod('dict.copy', dictobj) elif name == 'fromkeys': return DictType.FromKeys('dict.fromkeys') elif name == 'get': return DictObject.Get(self, 'dict.get') elif name == 'has_key': return BuiltinConstMethod('dict.has_key', BoolType.get_object(), [ANY]) elif name == 'keys': return BuiltinConstMethod('dict.keys', ListType.create_list(self.key)) elif name == 'values': return BuiltinConstMethod('dict.values', ListType.create_list(self.value)) elif name == 'items': return BuiltinConstMethod('dict.items', ListType.create_list(TupleType.create_tuple([self.key, self.value]))) elif name == 'iterkeys': return BuiltinConstMethod('dict.iterkeys', IterType.create_iter(self.key)) elif name == 'itervalues': return BuiltinConstMethod('dict.itervalues', IterType.create_iter(self.value)) elif name == 'iteritems': return BuiltinConstMethod('dict.iteritems', IterType.create_iter(TupleType.create_tuple([self.key, self.value]))) elif name == 'pop': return DictObject.Pop(self, 'dict.pop') elif name == 'popitem': return BuiltinConstMethod('dict.popitem', TupleType.create_tuple([self.key, self.value]), expts=[ErrorConfig.MaybeElementNotFound()]) elif name == 'setdefault': return DictObject.SetDefault(self, 'dict.setdefault') elif name == 'update': return DictObject.Update(self, 'dict.update') raise NodeAttrError(name)
def __init__(self): BuiltinConstFunc.__init__(self, 'issubclass', BoolType.get_object(), [TypeType, ANY]) return
def __init__(self): BuiltinConstFunc.__init__(self, 'isinstance', BoolType.get_object(), [ANY, ANY]) return
def __init__(self): BuiltinConstFunc.__init__(self, 'callable', BoolType.get_object(), [ANY]) return
def __init__(self, name='all'): BuiltinConstFunc.__init__(self, name, BoolType.get_object(), [ANY]) return