Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
8095521e
Commit
8095521e
authored
Jul 28, 2015
by
Dong-hee,Na
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement recursive printing of set and tuples.
w:
parent
eb8e5c4d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletion
+27
-1
src/runtime/set.cpp
src/runtime/set.cpp
+9
-0
src/runtime/tuple.cpp
src/runtime/tuple.cpp
+18
-1
No files found.
src/runtime/set.cpp
View file @
8095521e
...
...
@@ -99,6 +99,14 @@ static Box* _setRepr(BoxedSet* self, const char* type_name) {
std
::
string
O
(
""
);
llvm
::
raw_string_ostream
os
(
O
);
int
status
=
Py_ReprEnter
((
PyObject
*
)
self
);
if
(
status
!=
0
)
{
if
(
status
<
0
)
return
boxString
(
os
.
str
());
os
<<
type_name
<<
"(...)"
;
return
boxString
(
os
.
str
());
}
os
<<
type_name
<<
"(["
;
bool
first
=
true
;
for
(
Box
*
elt
:
self
->
s
)
{
...
...
@@ -109,6 +117,7 @@ static Box* _setRepr(BoxedSet* self, const char* type_name) {
first
=
false
;
}
os
<<
"])"
;
Py_ReprLeave
((
PyObject
*
)
self
);
return
boxString
(
os
.
str
());
}
...
...
src/runtime/tuple.cpp
View file @
8095521e
...
...
@@ -203,11 +203,27 @@ extern "C" Py_ssize_t PyTuple_Size(PyObject* op) noexcept {
Box
*
tupleRepr
(
BoxedTuple
*
t
)
{
assert
(
isSubclass
(
t
->
cls
,
tuple_cls
));
int
n
;
std
::
string
O
(
""
);
llvm
::
raw_string_ostream
os
(
O
);
n
=
t
->
size
();
if
(
n
==
0
)
{
os
<<
"()"
;
return
boxString
(
os
.
str
());
}
int
status
=
Py_ReprEnter
((
PyObject
*
)
t
);
if
(
status
!=
0
)
{
if
(
status
<
0
)
return
boxString
(
os
.
str
());
os
<<
"(...)"
;
return
boxString
(
os
.
str
());
}
os
<<
"("
;
int
n
=
t
->
size
();
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
if
(
i
)
os
<<
", "
;
...
...
@@ -219,6 +235,7 @@ Box* tupleRepr(BoxedTuple* t) {
os
<<
","
;
os
<<
")"
;
Py_ReprLeave
((
PyObject
*
)
t
);
return
boxString
(
os
.
str
());
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment