def get_for_indexer(self, value): if value.get_size() == 1: single = value.get_item(0) if isinstance(single, Number): number = single[0].get_as_int() if number >= 0 and number < self.get_size(): return StandardSequence([self.get_item(number)]) else: return StandardSequence([]) return utils.flatten([self.get_item(i).get_for_indexer(value) for i in xrange(self.get_size())])
def evaluate(self, static, dynamic, local): sequence = self.left.evaluate(static, dynamic, local) # TODO: need to change this to take into account if the above sequence # is synthetic, and if so, avoid stuffing all the items into a list sequence_size = sequence.get_size() results = [None for s in xrange(sequence_size)] for i in xrange(sequence_size): item = sequence.get_item(i) new_dynamic = dynamic.new(context_size=sequence_size, context_item=item, context_position=i + 1) results[i] = self.right.evaluate(static, new_dynamic, local) return utils.flatten(results)
def get_for_pair_indexer(self, value): return utils.flatten([self.get_item(i).get_for_pair_indexer(value) for i in xrange(self.get_size())])
def get_for_pair_pattern(self, pattern): return utils.flatten([self.get_item(i).get_for_pair_pattern(pattern) for i in xrange(self.get_size())])
def evaluate(self, static, dynamic, local): current = [{}] for construct in self.constructs: current = construct.generate(static, dynamic, local, current) return utils.flatten([self.return_expr.evaluate(static, dynamic, local.new(set_map=var_set)) for var_set in current])
def evaluate(self, static, dynamic, local): return utils.flatten([p.evaluate(static, dynamic, local) for p in self.exprs])