Commit b784a5cf authored by Dong-hee,Na's avatar Dong-hee,Na

last commit before return to base :-)

parent 4fc24442
...@@ -34,13 +34,8 @@ Box* dictRepr(BoxedDict* self) { ...@@ -34,13 +34,8 @@ Box* dictRepr(BoxedDict* self) {
std::vector<char> chars; std::vector<char> chars;
int status = Py_ReprEnter((PyObject*)self); int status = Py_ReprEnter((PyObject*)self);
if (status != 0) { if (status != 0) {
try {
if (status < 0) if (status < 0)
throwCAPIException(); throwCAPIException();
} catch (ExcInfo e) {
Py_ReprLeave((PyObject*)self);
throw e;
}
chars.push_back('{'); chars.push_back('{');
chars.push_back('.'); chars.push_back('.');
...@@ -50,6 +45,7 @@ Box* dictRepr(BoxedDict* self) { ...@@ -50,6 +45,7 @@ Box* dictRepr(BoxedDict* self) {
return boxString(llvm::StringRef(&chars[0], chars.size())); return boxString(llvm::StringRef(&chars[0], chars.size()));
} }
try {
chars.push_back('{'); chars.push_back('{');
bool first = true; bool first = true;
for (const auto& p : self->d) { for (const auto& p : self->d) {
...@@ -58,19 +54,18 @@ Box* dictRepr(BoxedDict* self) { ...@@ -58,19 +54,18 @@ Box* dictRepr(BoxedDict* self) {
chars.push_back(' '); chars.push_back(' ');
} }
first = false; first = false;
try {
BoxedString* k = static_cast<BoxedString*>(repr(p.first)); BoxedString* k = static_cast<BoxedString*>(repr(p.first));
BoxedString* v = static_cast<BoxedString*>(repr(p.second)); BoxedString* v = static_cast<BoxedString*>(repr(p.second));
chars.insert(chars.end(), k->s().begin(), k->s().end()); chars.insert(chars.end(), k->s().begin(), k->s().end());
chars.push_back(':'); chars.push_back(':');
chars.push_back(' '); chars.push_back(' ');
chars.insert(chars.end(), v->s().begin(), v->s().end()); chars.insert(chars.end(), v->s().begin(), v->s().end());
}
chars.push_back('}');
} catch (ExcInfo e) { } catch (ExcInfo e) {
Py_ReprLeave((PyObject*)self); Py_ReprLeave((PyObject*)self);
throw e; throw e;
} }
}
chars.push_back('}');
Py_ReprLeave((PyObject*)self); Py_ReprLeave((PyObject*)self);
return boxString(llvm::StringRef(&chars[0], chars.size())); return boxString(llvm::StringRef(&chars[0], chars.size()));
} }
......
...@@ -65,13 +65,9 @@ extern "C" Box* listRepr(BoxedList* self) { ...@@ -65,13 +65,9 @@ extern "C" Box* listRepr(BoxedList* self) {
int status = Py_ReprEnter((PyObject*)self); int status = Py_ReprEnter((PyObject*)self);
if (status != 0) { if (status != 0) {
try {
if (status < 0) if (status < 0)
throwCAPIException(); throwCAPIException();
} catch (ExcInfo e) {
Py_ReprLeave((PyObject*)self);
throw e;
}
chars.push_back('['); chars.push_back('[');
chars.push_back('.'); chars.push_back('.');
chars.push_back('.'); chars.push_back('.');
...@@ -79,8 +75,8 @@ extern "C" Box* listRepr(BoxedList* self) { ...@@ -79,8 +75,8 @@ extern "C" Box* listRepr(BoxedList* self) {
chars.push_back(']'); chars.push_back(']');
return boxString(llvm::StringRef(&chars[0], chars.size())); return boxString(llvm::StringRef(&chars[0], chars.size()));
} }
try {
chars.push_back('['); chars.push_back('[');
for (int i = 0; i < self->size; i++) { for (int i = 0; i < self->size; i++) {
if (i > 0) { if (i > 0) {
...@@ -93,8 +89,11 @@ extern "C" Box* listRepr(BoxedList* self) { ...@@ -93,8 +89,11 @@ extern "C" Box* listRepr(BoxedList* self) {
chars.insert(chars.end(), s->s().begin(), s->s().end()); chars.insert(chars.end(), s->s().begin(), s->s().end());
} }
chars.push_back(']'); chars.push_back(']');
} catch (ExcInfo e) {
Py_ReprLeave((PyObject*)self);
throw e;
}
Py_ReprLeave((PyObject*)self); Py_ReprLeave((PyObject*)self);
return boxString(llvm::StringRef(&chars[0], chars.size())); return boxString(llvm::StringRef(&chars[0], chars.size()));
} }
......
...@@ -99,13 +99,8 @@ static Box* _setRepr(BoxedSet* self, const char* type_name) { ...@@ -99,13 +99,8 @@ static Box* _setRepr(BoxedSet* self, const char* type_name) {
int status = Py_ReprEnter((PyObject*)self); int status = Py_ReprEnter((PyObject*)self);
if (status != 0) { if (status != 0) {
try {
if (status < 0) if (status < 0)
throwCAPIException(); throwCAPIException();
} catch (ExcInfo e) {
Py_ReprLeave((PyObject*)self);
throw e;
}
std::string ty = std::string(type_name); std::string ty = std::string(type_name);
chars.insert(chars.end(), ty.begin(), ty.end()); chars.insert(chars.end(), ty.begin(), ty.end());
...@@ -118,6 +113,7 @@ static Box* _setRepr(BoxedSet* self, const char* type_name) { ...@@ -118,6 +113,7 @@ static Box* _setRepr(BoxedSet* self, const char* type_name) {
return boxString(llvm::StringRef(&chars[0], chars.size())); return boxString(llvm::StringRef(&chars[0], chars.size()));
} }
try {
std::string ty = std::string(type_name); std::string ty = std::string(type_name);
chars.insert(chars.end(), ty.begin(), ty.end()); chars.insert(chars.end(), ty.begin(), ty.end());
...@@ -131,18 +127,17 @@ static Box* _setRepr(BoxedSet* self, const char* type_name) { ...@@ -131,18 +127,17 @@ static Box* _setRepr(BoxedSet* self, const char* type_name) {
chars.push_back(','); chars.push_back(',');
chars.push_back(' '); chars.push_back(' ');
} }
try {
BoxedString* str = static_cast<BoxedString*>(repr(elt)); BoxedString* str = static_cast<BoxedString*>(repr(elt));
chars.insert(chars.end(), str->s().begin(), str->s().end()); chars.insert(chars.end(), str->s().begin(), str->s().end());
} catch (ExcInfo e) {
Py_ReprLeave((PyObject*)self);
throw e;
}
first = false; first = false;
} }
chars.push_back(']'); chars.push_back(']');
chars.push_back(')'); chars.push_back(')');
} catch (ExcInfo e) {
Py_ReprLeave((PyObject*)self);
throw e;
}
Py_ReprLeave((PyObject*)self); Py_ReprLeave((PyObject*)self);
return boxString(llvm::StringRef(&chars[0], chars.size())); return boxString(llvm::StringRef(&chars[0], chars.size()));
} }
......
...@@ -212,13 +212,8 @@ Box* tupleRepr(BoxedTuple* t) { ...@@ -212,13 +212,8 @@ Box* tupleRepr(BoxedTuple* t) {
} }
if (status != 0) { if (status != 0) {
try {
if (status < 0) if (status < 0)
throwCAPIException(); throwCAPIException();
} catch (ExcInfo e) {
Py_ReprLeave((PyObject*)t);
throw e;
}
chars.push_back('('); chars.push_back('(');
chars.push_back('.'); chars.push_back('.');
chars.push_back('.'); chars.push_back('.');
...@@ -227,26 +222,26 @@ Box* tupleRepr(BoxedTuple* t) { ...@@ -227,26 +222,26 @@ Box* tupleRepr(BoxedTuple* t) {
return boxString(llvm::StringRef(&chars[0], chars.size())); return boxString(llvm::StringRef(&chars[0], chars.size()));
} }
chars.push_back('(');
try {
chars.push_back('(');
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
if (i) { if (i) {
chars.push_back(','); chars.push_back(',');
chars.push_back(' '); chars.push_back(' ');
} }
try {
BoxedString* elt_repr = static_cast<BoxedString*>(repr(t->elts[i])); BoxedString* elt_repr = static_cast<BoxedString*>(repr(t->elts[i]));
chars.insert(chars.end(), elt_repr->s().begin(), elt_repr->s().end()); chars.insert(chars.end(), elt_repr->s().begin(), elt_repr->s().end());
} catch (ExcInfo e) {
Py_ReprLeave((PyObject*)t);
throw e;
}
} }
if (n == 1) if (n == 1)
chars.push_back(','); chars.push_back(',');
chars.push_back(')'); chars.push_back(')');
} catch (ExcInfo e) {
Py_ReprLeave((PyObject*)t);
throw e;
}
Py_ReprLeave((PyObject*)t); Py_ReprLeave((PyObject*)t);
return boxString(llvm::StringRef(&chars[0], chars.size())); return boxString(llvm::StringRef(&chars[0], chars.size()));
......
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