Commit 89ab8838 authored by Joris Vankerschaver's avatar Joris Vankerschaver

Fix formatting.

parent 38f2aef8
...@@ -48,12 +48,12 @@ Box* _tupleSlice(BoxedTuple* self, i64 start, i64 stop, i64 step) { ...@@ -48,12 +48,12 @@ Box* _tupleSlice(BoxedTuple* self, i64 start, i64 stop, i64 step) {
// This is adapted from CPython's PySlice_GetIndicesEx. // This is adapted from CPython's PySlice_GetIndicesEx.
i64 slicelength; i64 slicelength;
if (step < 0) if (step < 0)
slicelength = (stop-start+1)/(step)+1; slicelength = (stop - start + 1) / (step)+1;
else else
slicelength = (stop-start-1)/(step)+1; slicelength = (stop - start - 1) / (step)+1;
if (slicelength < 0) if (slicelength < 0)
slicelength = 0; slicelength = 0;
// FIXME: No need to initialize with 0. // FIXME: No need to initialize with 0.
BoxedTuple::GCVector velts(slicelength, 0); BoxedTuple::GCVector velts(slicelength, 0);
...@@ -78,7 +78,7 @@ Box* tupleGetitemInt(BoxedTuple* self, BoxedInt* slice) { ...@@ -78,7 +78,7 @@ Box* tupleGetitemInt(BoxedTuple* self, BoxedInt* slice) {
Box* rtn = self->elts[n]; Box* rtn = self->elts[n];
return rtn; return rtn;
} }
Box* tupleGetitemSlice(BoxedTuple* self, BoxedSlice* slice) { Box* tupleGetitemSlice(BoxedTuple* self, BoxedSlice* slice) {
assert(self->cls == tuple_cls); assert(self->cls == tuple_cls);
...@@ -97,8 +97,7 @@ Box* tupleGetitem(BoxedTuple* self, Box* slice) { ...@@ -97,8 +97,7 @@ Box* tupleGetitem(BoxedTuple* self, Box* slice) {
else if (slice->cls == slice_cls) else if (slice->cls == slice_cls)
return tupleGetitemSlice(self, static_cast<BoxedSlice*>(slice)); return tupleGetitemSlice(self, static_cast<BoxedSlice*>(slice));
else else
raiseExcHelper(TypeError, raiseExcHelper(TypeError, "tuple indices must be integers, not %s", getTypeName(slice)->c_str());
"tuple indices must be integers, not %s", getTypeName(slice)->c_str());
} }
Box* tupleAdd(BoxedTuple* self, Box* rhs) { Box* tupleAdd(BoxedTuple* self, Box* rhs) {
...@@ -261,7 +260,8 @@ void setupTuple() { ...@@ -261,7 +260,8 @@ void setupTuple() {
tuple_cls->giveAttr("__name__", boxStrConstant("tuple")); tuple_cls->giveAttr("__name__", boxStrConstant("tuple"));
CLFunction* getitem = createRTFunction(2, 0, 0, 0); CLFunction* getitem = createRTFunction(2, 0, 0, 0);
addRTFunction(getitem, (void*)tupleGetitemInt, UNKNOWN, std::vector<ConcreteCompilerType*>{ BOXED_TUPLE, BOXED_INT }); addRTFunction(getitem, (void*)tupleGetitemInt, UNKNOWN,
std::vector<ConcreteCompilerType*>{ BOXED_TUPLE, BOXED_INT });
addRTFunction(getitem, (void*)tupleGetitemSlice, SLICE, std::vector<ConcreteCompilerType*>{ BOXED_TUPLE, SLICE }); addRTFunction(getitem, (void*)tupleGetitemSlice, SLICE, std::vector<ConcreteCompilerType*>{ BOXED_TUPLE, SLICE });
addRTFunction(getitem, (void*)tupleGetitem, UNKNOWN, std::vector<ConcreteCompilerType*>{ BOXED_TUPLE, UNKNOWN }); addRTFunction(getitem, (void*)tupleGetitem, UNKNOWN, std::vector<ConcreteCompilerType*>{ BOXED_TUPLE, UNKNOWN });
tuple_cls->giveAttr("__getitem__", new BoxedFunction(getitem)); tuple_cls->giveAttr("__getitem__", new BoxedFunction(getitem));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment