Skip to content

Commit 33bb4df

Browse files
committed
Fix indentation of IteratorBuiltins.ReduceNode
1 parent aa43a90 commit 33bb4df

File tree

1 file changed

+118
-119
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator

1 file changed

+118
-119
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorBuiltins.java

Lines changed: 118 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -415,145 +415,144 @@ static int lengthHint(VirtualFrame frame, PSequenceIterator self,
415415
int len = sizeNode.execute(frame, inliningTarget, self.getObject()) - self.getIndex();
416416
return len < 0 ? 0 : len;
417417
}
418+
}
418419

419-
@Builtin(name = J___REDUCE__, minNumOfPositionalArgs = 1)
420-
@GenerateNodeFactory
421-
public abstract static class ReduceNode extends PythonUnaryBuiltinNode {
420+
@Builtin(name = J___REDUCE__, minNumOfPositionalArgs = 1)
421+
@GenerateNodeFactory
422+
public abstract static class ReduceNode extends PythonUnaryBuiltinNode {
422423

423-
@Specialization
424-
Object reduce(VirtualFrame frame, PArrayIterator self,
425-
@Bind("this") Node inliningTarget,
426-
@Shared @Cached InlinedConditionProfile exhaustedProfile,
427-
@Shared @Cached PyObjectGetAttr getAttrNode,
428-
@Shared @Cached PythonObjectFactory factory) {
429-
PythonContext context = PythonContext.get(this);
430-
if (!exhaustedProfile.profile(inliningTarget, self.isExhausted())) {
431-
return reduceInternal(frame, inliningTarget, self.array, self.getIndex(), context, getAttrNode, factory);
432-
} else {
433-
return reduceInternal(frame, inliningTarget, factory.createEmptyTuple(), context, getAttrNode, factory);
434-
}
424+
@Specialization
425+
Object reduce(VirtualFrame frame, PArrayIterator self,
426+
@Bind("this") Node inliningTarget,
427+
@Shared @Cached InlinedConditionProfile exhaustedProfile,
428+
@Shared @Cached PyObjectGetAttr getAttrNode,
429+
@Shared @Cached PythonObjectFactory factory) {
430+
PythonContext context = PythonContext.get(this);
431+
if (!exhaustedProfile.profile(inliningTarget, self.isExhausted())) {
432+
return reduceInternal(frame, inliningTarget, self.array, self.getIndex(), context, getAttrNode, factory);
433+
} else {
434+
return reduceInternal(frame, inliningTarget, factory.createEmptyTuple(), context, getAttrNode, factory);
435435
}
436+
}
436437

437-
@Specialization
438-
Object reduce(VirtualFrame frame, PHashingStorageIterator self,
439-
@Bind("this") Node inliningTarget,
440-
@Cached SequenceStorageNodes.CreateStorageFromIteratorNode storageNode,
441-
// unused profile to avoid mixing shared and non-shared inlined nodes
442-
@SuppressWarnings("unused") @Shared @Cached InlinedConditionProfile exhaustedProfile,
443-
@Shared @Cached PyObjectGetAttr getAttrNode,
444-
@Shared @Cached PythonObjectFactory factory) {
445-
int index = self.index;
446-
boolean isExhausted = self.isExhausted();
447-
int state = self.getIterator().getState();
448-
PList list = factory.createList(storageNode.execute(frame, self));
449-
self.getIterator().setState(state);
450-
self.setExhausted(isExhausted);
451-
self.index = index;
452-
return reduceInternal(frame, inliningTarget, list, PythonContext.get(this), getAttrNode, factory);
453-
}
438+
@Specialization
439+
Object reduce(VirtualFrame frame, PHashingStorageIterator self,
440+
@Bind("this") Node inliningTarget,
441+
@Cached SequenceStorageNodes.CreateStorageFromIteratorNode storageNode,
442+
// unused profile to avoid mixing shared and non-shared inlined nodes
443+
@SuppressWarnings("unused") @Shared @Cached InlinedConditionProfile exhaustedProfile,
444+
@Shared @Cached PyObjectGetAttr getAttrNode,
445+
@Shared @Cached PythonObjectFactory factory) {
446+
int index = self.index;
447+
boolean isExhausted = self.isExhausted();
448+
int state = self.getIterator().getState();
449+
PList list = factory.createList(storageNode.execute(frame, self));
450+
self.getIterator().setState(state);
451+
self.setExhausted(isExhausted);
452+
self.index = index;
453+
return reduceInternal(frame, inliningTarget, list, PythonContext.get(this), getAttrNode, factory);
454+
}
454455

455-
@Specialization
456-
Object reduce(VirtualFrame frame, PIntegerSequenceIterator self,
457-
@Bind("this") Node inliningTarget,
458-
@Shared @Cached PyObjectGetAttr getAttrNode,
459-
@Shared @Cached PythonObjectFactory factory) {
460-
PythonContext context = PythonContext.get(this);
461-
if (self.isExhausted()) {
462-
return reduceInternal(frame, inliningTarget, factory.createList(), null, context, getAttrNode, factory);
463-
}
464-
return reduceInternal(frame, inliningTarget, self.getObject(), self.getIndex(), context, getAttrNode, factory);
456+
@Specialization
457+
Object reduce(VirtualFrame frame, PIntegerSequenceIterator self,
458+
@Bind("this") Node inliningTarget,
459+
@Shared @Cached PyObjectGetAttr getAttrNode,
460+
@Shared @Cached PythonObjectFactory factory) {
461+
PythonContext context = PythonContext.get(this);
462+
if (self.isExhausted()) {
463+
return reduceInternal(frame, inliningTarget, factory.createList(), null, context, getAttrNode, factory);
465464
}
465+
return reduceInternal(frame, inliningTarget, self.getObject(), self.getIndex(), context, getAttrNode, factory);
466+
}
466467

467-
@Specialization
468-
Object reduce(VirtualFrame frame, PPrimitiveIterator self,
469-
@Bind("this") Node inliningTarget,
470-
@Shared @Cached PyObjectGetAttr getAttrNode,
471-
@Shared @Cached PythonObjectFactory factory) {
472-
PythonContext context = PythonContext.get(this);
473-
if (self.isExhausted()) {
474-
return reduceInternal(frame, inliningTarget, factory.createList(), null, context, getAttrNode, factory);
475-
}
476-
return reduceInternal(frame, inliningTarget, self.getObject(), self.getIndex(), context, getAttrNode, factory);
468+
@Specialization
469+
Object reduce(VirtualFrame frame, PPrimitiveIterator self,
470+
@Bind("this") Node inliningTarget,
471+
@Shared @Cached PyObjectGetAttr getAttrNode,
472+
@Shared @Cached PythonObjectFactory factory) {
473+
PythonContext context = PythonContext.get(this);
474+
if (self.isExhausted()) {
475+
return reduceInternal(frame, inliningTarget, factory.createList(), null, context, getAttrNode, factory);
477476
}
477+
return reduceInternal(frame, inliningTarget, self.getObject(), self.getIndex(), context, getAttrNode, factory);
478+
}
478479

479-
@Specialization
480-
Object reduce(VirtualFrame frame, PStringIterator self,
481-
@Bind("this") Node inliningTarget,
482-
@Shared @Cached PyObjectGetAttr getAttrNode,
483-
@Shared @Cached PythonObjectFactory factory) {
484-
PythonContext context = PythonContext.get(this);
485-
if (self.isExhausted()) {
486-
return reduceInternal(frame, inliningTarget, T_EMPTY_STRING, null, context, getAttrNode, factory);
487-
}
488-
return reduceInternal(frame, inliningTarget, self.value, self.getIndex(), context, getAttrNode, factory);
480+
@Specialization
481+
Object reduce(VirtualFrame frame, PStringIterator self,
482+
@Bind("this") Node inliningTarget,
483+
@Shared @Cached PyObjectGetAttr getAttrNode,
484+
@Shared @Cached PythonObjectFactory factory) {
485+
PythonContext context = PythonContext.get(this);
486+
if (self.isExhausted()) {
487+
return reduceInternal(frame, inliningTarget, T_EMPTY_STRING, null, context, getAttrNode, factory);
489488
}
489+
return reduceInternal(frame, inliningTarget, self.value, self.getIndex(), context, getAttrNode, factory);
490+
}
490491

491-
@Specialization
492-
Object reduce(VirtualFrame frame, PIntRangeIterator self,
493-
@Bind("this") Node inliningTarget,
494-
@Shared @Cached PyObjectGetAttr getAttrNode,
495-
@Shared @Cached PythonObjectFactory factory) {
496-
int start = self.getStart();
497-
int stop = self.getStop();
498-
int step = self.getStep();
499-
int len = self.getLen();
500-
return reduceInternal(frame, inliningTarget, factory.createIntRange(start, stop, step, len), self.getIndex(), PythonContext.get(this), getAttrNode, factory);
501-
}
492+
@Specialization
493+
Object reduce(VirtualFrame frame, PIntRangeIterator self,
494+
@Bind("this") Node inliningTarget,
495+
@Shared @Cached PyObjectGetAttr getAttrNode,
496+
@Shared @Cached PythonObjectFactory factory) {
497+
int start = self.getStart();
498+
int stop = self.getStop();
499+
int step = self.getStep();
500+
int len = self.getLen();
501+
return reduceInternal(frame, inliningTarget, factory.createIntRange(start, stop, step, len), self.getIndex(), PythonContext.get(this), getAttrNode, factory);
502+
}
502503

503-
@Specialization
504-
Object reduce(VirtualFrame frame, PBigRangeIterator self,
505-
@Bind("this") Node inliningTarget,
506-
@Shared @Cached PyObjectGetAttr getAttrNode,
507-
@Shared @Cached PythonObjectFactory factory) {
508-
PInt start = self.getStart();
509-
PInt stop = self.getStop();
510-
PInt step = self.getStep();
511-
PInt len = self.getLen();
512-
return reduceInternal(frame, inliningTarget, factory.createBigRange(start, stop, step, len), self.getLongIndex(factory), PythonContext.get(this), getAttrNode, factory);
513-
}
504+
@Specialization
505+
Object reduce(VirtualFrame frame, PBigRangeIterator self,
506+
@Bind("this") Node inliningTarget,
507+
@Shared @Cached PyObjectGetAttr getAttrNode,
508+
@Shared @Cached PythonObjectFactory factory) {
509+
PInt start = self.getStart();
510+
PInt stop = self.getStop();
511+
PInt step = self.getStep();
512+
PInt len = self.getLen();
513+
return reduceInternal(frame, inliningTarget, factory.createBigRange(start, stop, step, len), self.getLongIndex(factory), PythonContext.get(this), getAttrNode, factory);
514+
}
514515

515-
@Specialization(guards = "self.isPSequence()")
516-
Object reduce(VirtualFrame frame, PSequenceIterator self,
517-
@Bind("this") Node inliningTarget,
518-
@Shared @Cached PyObjectGetAttr getAttrNode,
519-
@Shared @Cached PythonObjectFactory factory) {
520-
PythonContext context = PythonContext.get(this);
521-
if (self.isExhausted()) {
522-
return reduceInternal(frame, inliningTarget, factory.createTuple(new Object[0]), null, context, getAttrNode, factory);
523-
}
524-
return reduceInternal(frame, inliningTarget, self.getPSequence(), self.getIndex(), context, getAttrNode, factory);
516+
@Specialization(guards = "self.isPSequence()")
517+
Object reduce(VirtualFrame frame, PSequenceIterator self,
518+
@Bind("this") Node inliningTarget,
519+
@Shared @Cached PyObjectGetAttr getAttrNode,
520+
@Shared @Cached PythonObjectFactory factory) {
521+
PythonContext context = PythonContext.get(this);
522+
if (self.isExhausted()) {
523+
return reduceInternal(frame, inliningTarget, factory.createTuple(new Object[0]), null, context, getAttrNode, factory);
525524
}
525+
return reduceInternal(frame, inliningTarget, self.getPSequence(), self.getIndex(), context, getAttrNode, factory);
526+
}
526527

527-
@Specialization(guards = "!self.isPSequence()")
528-
Object reduceNonSeq(@SuppressWarnings({"unused"}) VirtualFrame frame, PSequenceIterator self,
529-
@Bind("this") Node inliningTarget,
530-
@Shared @Cached PyObjectGetAttr getAttrNode,
531-
@Shared @Cached PythonObjectFactory factory) {
532-
PythonContext context = PythonContext.get(this);
533-
if (!self.isExhausted()) {
534-
return reduceInternal(frame, inliningTarget, self.getObject(), self.getIndex(), context, getAttrNode, factory);
535-
} else {
536-
return reduceInternal(frame, inliningTarget, factory.createTuple(new Object[0]), null, context, getAttrNode, factory);
537-
}
528+
@Specialization(guards = "!self.isPSequence()")
529+
Object reduceNonSeq(@SuppressWarnings({"unused"}) VirtualFrame frame, PSequenceIterator self,
530+
@Bind("this") Node inliningTarget,
531+
@Shared @Cached PyObjectGetAttr getAttrNode,
532+
@Shared @Cached PythonObjectFactory factory) {
533+
PythonContext context = PythonContext.get(this);
534+
if (!self.isExhausted()) {
535+
return reduceInternal(frame, inliningTarget, self.getObject(), self.getIndex(), context, getAttrNode, factory);
536+
} else {
537+
return reduceInternal(frame, inliningTarget, factory.createTuple(new Object[0]), null, context, getAttrNode, factory);
538538
}
539+
}
539540

540-
private static PTuple reduceInternal(VirtualFrame frame, Node inliningTarget, Object arg, PythonContext context, PyObjectGetAttr getAttrNode, PythonObjectFactory factory) {
541-
return reduceInternal(frame, inliningTarget, arg, null, context, getAttrNode, factory);
542-
}
541+
private static PTuple reduceInternal(VirtualFrame frame, Node inliningTarget, Object arg, PythonContext context, PyObjectGetAttr getAttrNode, PythonObjectFactory factory) {
542+
return reduceInternal(frame, inliningTarget, arg, null, context, getAttrNode, factory);
543+
}
543544

544-
private static PTuple reduceInternal(VirtualFrame frame, Node inliningTarget, Object arg, Object state, PythonContext context, PyObjectGetAttr getAttrNode, PythonObjectFactory factory) {
545-
PythonModule builtins = context.getBuiltins();
546-
Object iter = getAttrNode.execute(frame, inliningTarget, builtins, T_ITER);
547-
PTuple args = factory.createTuple(new Object[]{arg});
548-
// callable, args, state (optional)
549-
if (state != null) {
550-
return factory.createTuple(new Object[]{iter, args, state});
551-
} else {
552-
return factory.createTuple(new Object[]{iter, args});
553-
}
545+
private static PTuple reduceInternal(VirtualFrame frame, Node inliningTarget, Object arg, Object state, PythonContext context, PyObjectGetAttr getAttrNode, PythonObjectFactory factory) {
546+
PythonModule builtins = context.getBuiltins();
547+
Object iter = getAttrNode.execute(frame, inliningTarget, builtins, T_ITER);
548+
PTuple args = factory.createTuple(new Object[]{arg});
549+
// callable, args, state (optional)
550+
if (state != null) {
551+
return factory.createTuple(new Object[]{iter, args, state});
552+
} else {
553+
return factory.createTuple(new Object[]{iter, args});
554554
}
555555
}
556-
557556
}
558557

559558
@Builtin(name = J___SETSTATE__, minNumOfPositionalArgs = 2)

0 commit comments

Comments
 (0)