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
79b6133a
Commit
79b6133a
authored
Jul 28, 2015
by
Dong-hee,Na
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implementation of dictionary's recursive printing
parent
ded39f2a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
src/runtime/dict.cpp
src/runtime/dict.cpp
+16
-0
test/tests/dict.py
test/tests/dict.py
+6
-0
No files found.
src/runtime/dict.cpp
View file @
79b6133a
...
...
@@ -31,7 +31,22 @@ using namespace pyston::ExceptionStyle;
using
pyston
::
ExceptionStyle
::
ExceptionStyle
;
Box
*
dictRepr
(
BoxedDict
*
self
)
{
int
status
=
Py_ReprEnter
((
PyObject
*
)
self
);
std
::
vector
<
char
>
chars
;
if
(
status
!=
0
)
{
if
(
status
<
0
)
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
chars
.
push_back
(
'{'
);
chars
.
push_back
(
'.'
);
chars
.
push_back
(
'.'
);
chars
.
push_back
(
'.'
);
chars
.
push_back
(
'}'
);
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
}
chars
.
push_back
(
'{'
);
bool
first
=
true
;
for
(
const
auto
&
p
:
self
->
d
)
{
...
...
@@ -49,6 +64,7 @@ Box* dictRepr(BoxedDict* self) {
chars
.
insert
(
chars
.
end
(),
v
->
s
().
begin
(),
v
->
s
().
end
());
}
chars
.
push_back
(
'}'
);
Py_ReprLeave
((
PyObject
*
)
self
);
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
}
...
...
test/tests/dict.py
View file @
79b6133a
...
...
@@ -230,3 +230,9 @@ while True:
except
StopIteration
:
break
print
sorted
(
l
)
#recursive printing test
d
=
dict
()
d
[
'one'
]
=
'1'
d
[
'two'
]
=
d
print
d
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