Commit 09160163 authored by Boxiang Sun's avatar Boxiang Sun

In order to get the content of sequence datatye easier, add some Repr APIs

parent 2c9e575d
...@@ -384,23 +384,23 @@ static void pickGlobalsAndLocals(Box*& globals, Box*& locals) { ...@@ -384,23 +384,23 @@ static void pickGlobalsAndLocals(Box*& globals, Box*& locals) {
RELEASE_ASSERT(globals && (globals->cls == module_cls || globals->cls == dict_cls), "Unspported globals type: %s", RELEASE_ASSERT(globals && (globals->cls == module_cls || globals->cls == dict_cls), "Unspported globals type: %s",
globals ? globals->cls->tp_name : "NULL"); globals ? globals->cls->tp_name : "NULL");
//
if (globals) { // if (globals) {
// From CPython (they set it to be f->f_builtins): // // From CPython (they set it to be f->f_builtins):
Box* globals_dict; // Box* globals_dict;
if (globals->cls == module_cls) // if (globals->cls == module_cls)
globals_dict = globals->getAttrWrapper(); // globals_dict = globals->getAttrWrapper();
else // else
globals_dict = globals; // globals_dict = globals;
//
auto requested_builtins = PyDict_GetItemString(globals_dict, "__builtins__"); // auto requested_builtins = PyDict_GetItemString(globals_dict, "__builtins__");
if (requested_builtins == NULL) // if (requested_builtins == NULL)
PyDict_SetItemString(globals_dict, "__builtins__", PyEval_GetBuiltins()); // PyDict_SetItemString(globals_dict, "__builtins__", PyEval_GetBuiltins());
else // else
RELEASE_ASSERT(requested_builtins == builtins_module // RELEASE_ASSERT(requested_builtins == builtins_module
|| requested_builtins == builtins_module->getAttrWrapper(), // || requested_builtins == builtins_module->getAttrWrapper(),
"we don't support overriding __builtins__"); // "we don't support overriding __builtins__");
} // }
} }
extern "C" PyObject* PyEval_EvalCode(PyCodeObject* co, PyObject* globals, PyObject* locals) noexcept { extern "C" PyObject* PyEval_EvalCode(PyCodeObject* co, PyObject* globals, PyObject* locals) noexcept {
......
...@@ -118,6 +118,11 @@ Box* dictRepr(BoxedDict* self) { ...@@ -118,6 +118,11 @@ Box* dictRepr(BoxedDict* self) {
return boxString(llvm::StringRef(&chars[0], chars.size())); return boxString(llvm::StringRef(&chars[0], chars.size()));
} }
extern "C" void PyDict_Repr(BoxedDict* self) {
BoxedString* result = (BoxedString*)dictRepr(self);
fprintf(stderr, std::string(result->s()).c_str());
}
Box* dictCopy(BoxedDict* self) { Box* dictCopy(BoxedDict* self) {
if (!PyDict_Check(self)) if (!PyDict_Check(self))
raiseExcHelper(TypeError, "descriptor 'copy' requires a 'dict' object but received a '%s'", getTypeName(self)); raiseExcHelper(TypeError, "descriptor 'copy' requires a 'dict' object but received a '%s'", getTypeName(self));
......
...@@ -51,7 +51,7 @@ Box* dictIterHasnext(Box* self); ...@@ -51,7 +51,7 @@ Box* dictIterHasnext(Box* self);
llvm_compat_bool dictIterHasnextUnboxed(Box* self); llvm_compat_bool dictIterHasnextUnboxed(Box* self);
Box* dictiter_next(Box* self) noexcept; Box* dictiter_next(Box* self) noexcept;
Box* dictIterNext(Box* self); Box* dictIterNext(Box* self);
void _PyDict_Repr(Box* self);
void dictMerge(BoxedDict* self, Box* other); void dictMerge(BoxedDict* self, Box* other);
Box* dictUpdate(BoxedDict* self, BoxedTuple* args, BoxedDict* kwargs); Box* dictUpdate(BoxedDict* self, BoxedTuple* args, BoxedDict* kwargs);
......
...@@ -104,6 +104,11 @@ extern "C" Box* listRepr(Box* _self) { ...@@ -104,6 +104,11 @@ extern "C" Box* listRepr(Box* _self) {
return boxString(llvm::StringRef(&chars[0], chars.size())); return boxString(llvm::StringRef(&chars[0], chars.size()));
} }
extern "C" void PyList_Repr(Box* self) {
BoxedString* result = (BoxedString*)listRepr(self);
fprintf(stderr, std::string(result->s()).c_str());
}
Box* list_repr(Box* self) noexcept { Box* list_repr(Box* self) noexcept {
return callCXXFromStyle<CAPI>(listRepr, self); return callCXXFromStyle<CAPI>(listRepr, self);
} }
......
...@@ -51,6 +51,7 @@ Box* listreviterHasnext(Box* self); ...@@ -51,6 +51,7 @@ Box* listreviterHasnext(Box* self);
llvm_compat_bool listreviterHasnextUnboxed(Box* self); llvm_compat_bool listreviterHasnextUnboxed(Box* self);
Box* listreviterNext(Box* self); Box* listreviterNext(Box* self);
Box* listreviter_next(Box* s) noexcept; Box* listreviter_next(Box* s) noexcept;
extern "C" void PyList_Repr(Box* self);
extern "C" Box* listAppend(Box* self, Box* v); extern "C" Box* listAppend(Box* self, Box* v);
} }
......
...@@ -309,6 +309,12 @@ Box* tupleRepr(Box* _t) { ...@@ -309,6 +309,12 @@ Box* tupleRepr(Box* _t) {
return boxString(llvm::StringRef(&chars[0], chars.size())); return boxString(llvm::StringRef(&chars[0], chars.size()));
} }
extern "C" void PyTuple_Repr(Box* self) {
BoxedString* result = (BoxedString*)tupleRepr(self);
fprintf(stderr, std::string(result->s()).c_str());
}
static Box* tuple_repr(Box* v) noexcept { static Box* tuple_repr(Box* v) noexcept {
return callCXXFromStyle<CAPI>(tupleRepr, v); return callCXXFromStyle<CAPI>(tupleRepr, v);
} }
......
...@@ -47,6 +47,7 @@ Box* tupleiterHasnext(Box* self); ...@@ -47,6 +47,7 @@ Box* tupleiterHasnext(Box* self);
llvm_compat_bool tupleiterHasnextUnboxed(Box* self); llvm_compat_bool tupleiterHasnextUnboxed(Box* self);
Box* tupleiter_next(Box* self) noexcept; Box* tupleiter_next(Box* self) noexcept;
Box* tupleiterNext(Box* self); Box* tupleiterNext(Box* self);
extern "C" void PyTuple_Repr(Box* self);
} }
#endif #endif
...@@ -71,7 +71,7 @@ modified_list = [ ...@@ -71,7 +71,7 @@ modified_list = [
("zope.container-3.11.2", "https://lab.nexedi.com/Daetalus/zope.container-3.11.2/repository/archive.zip?ref=pyston_patch"), ("zope.container-3.11.2", "https://lab.nexedi.com/Daetalus/zope.container-3.11.2/repository/archive.zip?ref=pyston_patch"),
("zope.proxy-3.6.1", "https://lab.nexedi.com/Daetalus/zope.proxy-3.6.1/repository/archive.zip?ref=pyston_patch"), ("zope.proxy-3.6.1", "https://lab.nexedi.com/Daetalus/zope.proxy-3.6.1/repository/archive.zip?ref=pyston_patch"),
("zope.security-3.7.4", "https://lab.nexedi.com/Daetalus/zope.security-3.7.4/repository/archive.zip?ref=pyston_patch"), ("zope.security-3.7.4", "https://lab.nexedi.com/Daetalus/zope.security-3.7.4/repository/archive.zip?ref=pyston_patch"),
("DocumentTemplate-2.13.2", "https://lab.nexedi.com/Daetalus/DocumentTemplate-2.13.2/repository/archive.zip?ref=pyston_implementation"), ("DocumentTemplate-2.13.2", "https://lab.nexedi.com/Daetalus/DocumentTemplate-2.13.2/repository/archive.zip?ref=pyston_patch"),
("RestrictedPython-3.6.0", "https://lab.nexedi.com/Daetalus/RestrictedPython-3.6.0/repository/archive.zip?ref=pyston_patch"), ("RestrictedPython-3.6.0", "https://lab.nexedi.com/Daetalus/RestrictedPython-3.6.0/repository/archive.zip?ref=pyston_patch"),
("ZODB3-3.10.5", "https://lab.nexedi.com/Daetalus/ZODB3-3.10.5/repository/archive.zip?ref=pyston_patch"), ("ZODB3-3.10.5", "https://lab.nexedi.com/Daetalus/ZODB3-3.10.5/repository/archive.zip?ref=pyston_patch"),
("Zope2-2.13.24", "https://lab.nexedi.com/Daetalus/Zope2-2.13.24/repository/archive.zip?ref=python_implementation"),] ("Zope2-2.13.24", "https://lab.nexedi.com/Daetalus/Zope2-2.13.24/repository/archive.zip?ref=python_implementation"),]
......
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