Commit 96cc5efa authored by Kevin Modzelewski's avatar Kevin Modzelewski

some minor changes

parent a950719f
...@@ -444,7 +444,7 @@ private: ...@@ -444,7 +444,7 @@ private:
virtual void visit_delete(AST_Delete* node) { virtual void visit_delete(AST_Delete* node) {
for (AST_expr* target : node->targets) { for (AST_expr* target : node->targets) {
RELEASE_ASSERT(target->type == AST_TYPE::Subscript, ""); RELEASE_ASSERT(target->type == AST_TYPE::Subscript, "");
getType(target); getType(ast_cast<AST_Subscript>(target)->value);
} }
} }
......
...@@ -1351,12 +1351,6 @@ private: ...@@ -1351,12 +1351,6 @@ private:
case AST_TYPE::Subscript: case AST_TYPE::Subscript:
_doDelitem(static_cast<AST_Subscript*>(target), exc_info); _doDelitem(static_cast<AST_Subscript*>(target), exc_info);
break; break;
case AST_TYPE::Attribute:
// delete an attribute
case AST_TYPE::Name:
// delete a instance
RELEASE_ASSERT(target->type == AST_TYPE::Subscript, "");
break;
default: default:
ASSERT(0, "UnSupported del target: %d", target->type); ASSERT(0, "UnSupported del target: %d", target->type);
abort(); abort();
......
...@@ -950,10 +950,6 @@ public: ...@@ -950,10 +950,6 @@ public:
target = astsubs; target = astsubs;
break; break;
} }
case AST_TYPE::Name:
case AST_TYPE::Attribute:
RELEASE_ASSERT(t->type == AST_TYPE::Subscript, "");
default: default:
RELEASE_ASSERT(0, "UnSupported del target: %d", t->type); RELEASE_ASSERT(0, "UnSupported del target: %d", t->type);
} }
......
...@@ -386,13 +386,11 @@ Box* listRemove(BoxedList* self, Box* elt) { ...@@ -386,13 +386,11 @@ Box* listRemove(BoxedList* self, Box* elt) {
Box* listReverse(BoxedList* self) { Box* listReverse(BoxedList* self) {
assert(self->cls == list_cls); assert(self->cls == list_cls);
if (self->size > 0) {
for (int i = 0, j = self->size - 1; i < j; i++, j--) { for (int i = 0, j = self->size - 1; i < j; i++, j--) {
Box* e = self->elts->elts[i]; Box* e = self->elts->elts[i];
self->elts->elts[i] = self->elts->elts[j]; self->elts->elts[i] = self->elts->elts[j];
self->elts->elts[j] = e; self->elts->elts[j] = e;
} }
}
return None; return None;
} }
......
...@@ -44,5 +44,19 @@ except ValueError, e: ...@@ -44,5 +44,19 @@ except ValueError, e:
print "ok" print "ok"
print l print l
l.reverse() for i in xrange(5):
print l l = range(i)
l.reverse()
print l
# growing and shrinking a list:
l = []
for i in xrange(100):
l.append(i)
while l:
del l[0]
print l
for i in xrange(100):
l.append(i)
while l:
del l[0]
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