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
d99f473e
Commit
d99f473e
authored
Jul 30, 2015
by
Dong-hee,Na
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify exeception handling during repr
parent
86096848
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
112 additions
and
96 deletions
+112
-96
src/runtime/dict.cpp
src/runtime/dict.cpp
+30
-23
src/runtime/list.cpp
src/runtime/list.cpp
+29
-21
src/runtime/set.cpp
src/runtime/set.cpp
+25
-23
src/runtime/tuple.cpp
src/runtime/tuple.cpp
+28
-29
No files found.
src/runtime/dict.cpp
View file @
d99f473e
...
@@ -32,10 +32,11 @@ using pyston::ExceptionStyle::ExceptionStyle;
...
@@ -32,10 +32,11 @@ using pyston::ExceptionStyle::ExceptionStyle;
Box
*
dictRepr
(
BoxedDict
*
self
)
{
Box
*
dictRepr
(
BoxedDict
*
self
)
{
std
::
vector
<
char
>
chars
;
try
{
try
{
std
::
vector
<
char
>
chars
;
int
status
=
Py_ReprEnter
((
PyObject
*
)
self
);
int
status
=
Py_ReprEnter
((
PyObject
*
)
self
);
if
(
status
!=
0
)
{
if
(
status
!=
0
)
{
if
(
status
<
0
)
if
(
status
<
0
)
throwCAPIException
();
throwCAPIException
();
...
@@ -49,32 +50,38 @@ Box* dictRepr(BoxedDict* self) {
...
@@ -49,32 +50,38 @@ Box* dictRepr(BoxedDict* self) {
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
}
}
}
catch
(
ExcInfo
e
)
{
setCAPIException
(
e
);
Py_ReprLeave
((
PyObject
*
)
self
);
return
NULL
;
}
chars
.
push_back
(
'{'
);
chars
.
push_back
(
'{'
);
bool
first
=
true
;
bool
first
=
true
;
for
(
const
auto
&
p
:
self
->
d
)
{
if
(
!
first
)
{
for
(
const
auto
&
p
:
self
->
d
)
{
chars
.
push_back
(
','
);
if
(
!
first
)
{
chars
.
push_back
(
','
);
chars
.
push_back
(
' '
);
}
first
=
false
;
BoxedString
*
k
=
static_cast
<
BoxedString
*>
(
repr
(
p
.
first
));
BoxedString
*
v
=
static_cast
<
BoxedString
*>
(
repr
(
p
.
second
));
chars
.
insert
(
chars
.
end
(),
k
->
s
().
begin
(),
k
->
s
().
end
());
chars
.
push_back
(
':'
);
chars
.
push_back
(
' '
);
chars
.
push_back
(
' '
);
chars
.
insert
(
chars
.
end
(),
v
->
s
().
begin
(),
v
->
s
().
end
());
}
}
first
=
false
;
chars
.
push_back
(
'}'
);
BoxedString
*
k
=
static_cast
<
BoxedString
*>
(
repr
(
p
.
first
));
Py_ReprLeave
((
PyObject
*
)
self
);
BoxedString
*
v
=
static_cast
<
BoxedString
*>
(
repr
(
p
.
second
));
chars
.
insert
(
chars
.
end
(),
k
->
s
().
begin
(),
k
->
s
().
end
());
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
chars
.
push_back
(
':'
);
chars
.
push_back
(
' '
);
}
catch
(
ExcInfo
e
)
{
chars
.
insert
(
chars
.
end
(),
v
->
s
().
begin
(),
v
->
s
().
end
());
Py_ReprLeave
((
PyObject
*
)
self
);
}
throw
e
;
chars
.
push_back
(
'}'
);
}
Py_ReprLeave
((
PyObject
*
)
self
);
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
}
}
Box
*
dictClear
(
BoxedDict
*
self
)
{
Box
*
dictClear
(
BoxedDict
*
self
)
{
...
...
src/runtime/list.cpp
View file @
d99f473e
...
@@ -62,12 +62,13 @@ extern "C" PyObject* PyList_AsTuple(PyObject* v) noexcept {
...
@@ -62,12 +62,13 @@ extern "C" PyObject* PyList_AsTuple(PyObject* v) noexcept {
extern
"C"
Box
*
listRepr
(
BoxedList
*
self
)
{
extern
"C"
Box
*
listRepr
(
BoxedList
*
self
)
{
std
::
vector
<
char
>
chars
;
// Implementing Recursive Print of list in same way from Cpython
try
{
try
{
std
::
vector
<
char
>
chars
;
int
status
=
Py_ReprEnter
((
PyObject
*
)
self
);
int
status
=
Py_ReprEnter
((
PyObject
*
)
self
);
if
(
status
!=
0
)
{
if
(
status
!=
0
)
{
if
(
status
<
0
)
if
(
status
<
0
)
throwCAPIException
();
throwCAPIException
();
...
@@ -79,28 +80,35 @@ extern "C" Box* listRepr(BoxedList* self) {
...
@@ -79,28 +80,35 @@ extern "C" Box* listRepr(BoxedList* self) {
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
}
}
}
catch
(
ExcInfo
e
)
{
setCAPIException
(
e
);
chars
.
push_back
(
'['
);
Py_ReprLeave
((
PyObject
*
)
self
);
return
NULL
;
for
(
int
i
=
0
;
i
<
self
->
size
;
i
++
)
{
}
chars
.
push_back
(
'['
);
if
(
i
>
0
)
{
for
(
int
i
=
0
;
i
<
self
->
size
;
i
++
)
{
chars
.
push_back
(
','
);
if
(
i
>
0
)
{
chars
.
push_back
(
' '
);
chars
.
push_back
(
','
);
}
chars
.
push_back
(
' '
);
Box
*
r
=
self
->
elts
->
elts
[
i
]
->
reprICAsString
();
assert
(
r
->
cls
==
str_cls
);
BoxedString
*
s
=
static_cast
<
BoxedString
*>
(
r
);
chars
.
insert
(
chars
.
end
(),
s
->
s
().
begin
(),
s
->
s
().
end
());
}
}
Box
*
r
=
self
->
elts
->
elts
[
i
]
->
reprICAsString
(
);
chars
.
push_back
(
']'
);
assert
(
r
->
cls
==
str_cls
);
Py_ReprLeave
((
PyObject
*
)
self
);
BoxedString
*
s
=
static_cast
<
BoxedString
*>
(
r
);
chars
.
insert
(
chars
.
end
(),
s
->
s
().
begin
(),
s
->
s
().
end
());
}
chars
.
push_back
(
']'
);
Py_ReprLeave
((
PyObject
*
)
self
);
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
}
catch
(
ExcInfo
e
)
{
Py_ReprLeave
((
PyObject
*
)
self
);
throw
e
;
}
}
}
extern
"C"
Box
*
listNonzero
(
BoxedList
*
self
)
{
extern
"C"
Box
*
listNonzero
(
BoxedList
*
self
)
{
...
...
src/runtime/set.cpp
View file @
d99f473e
...
@@ -95,11 +95,13 @@ Box* setNew(Box* _cls, Box* container) {
...
@@ -95,11 +95,13 @@ Box* setNew(Box* _cls, Box* container) {
static
Box
*
_setRepr
(
BoxedSet
*
self
,
const
char
*
type_name
)
{
static
Box
*
_setRepr
(
BoxedSet
*
self
,
const
char
*
type_name
)
{
std
::
vector
<
char
>
chars
;
try
{
try
{
std
::
vector
<
char
>
chars
;
int
status
=
Py_ReprEnter
((
PyObject
*
)
self
);
int
status
=
Py_ReprEnter
((
PyObject
*
)
self
);
if
(
status
!=
0
)
{
if
(
status
!=
0
)
{
if
(
status
<
0
)
if
(
status
<
0
)
throwCAPIException
();
throwCAPIException
();
...
@@ -114,34 +116,34 @@ static Box* _setRepr(BoxedSet* self, const char* type_name) {
...
@@ -114,34 +116,34 @@ 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
()));
}
}
}
catch
(
ExcInfo
e
)
{
setCAPIException
(
e
);
Py_ReprLeave
((
PyObject
*
)
self
);
return
NULL
;
}
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
());
chars
.
push_back
(
'('
);
chars
.
push_back
(
'('
);
chars
.
push_back
(
'['
);
chars
.
push_back
(
'['
);
bool
first
=
true
;
bool
first
=
true
;
for
(
Box
*
elt
:
self
->
s
)
{
for
(
Box
*
elt
:
self
->
s
)
{
if
(
!
first
)
{
chars
.
push_back
(
','
);
chars
.
push_back
(
' '
);
}
if
(
!
first
)
{
BoxedString
*
str
=
static_cast
<
BoxedString
*>
(
repr
(
elt
));
chars
.
push_back
(
','
);
chars
.
insert
(
chars
.
end
(),
str
->
s
().
begin
(),
str
->
s
().
end
()
);
chars
.
push_back
(
' '
)
;
first
=
false
;
}
}
chars
.
push_back
(
']'
);
chars
.
push_back
(
')'
);
Py_ReprLeave
((
PyObject
*
)
self
);
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
BoxedString
*
str
=
static_cast
<
BoxedString
*>
(
repr
(
elt
));
}
catch
(
ExcInfo
e
)
{
chars
.
insert
(
chars
.
end
(),
str
->
s
().
begin
(),
str
->
s
().
end
()
);
Py_ReprLeave
((
PyObject
*
)
self
);
first
=
fals
e
;
throw
e
;
}
}
chars
.
push_back
(
']'
);
chars
.
push_back
(
')'
);
Py_ReprLeave
((
PyObject
*
)
self
);
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
}
}
Box
*
setRepr
(
BoxedSet
*
self
)
{
Box
*
setRepr
(
BoxedSet
*
self
)
{
...
...
src/runtime/tuple.cpp
View file @
d99f473e
...
@@ -201,18 +201,19 @@ extern "C" Py_ssize_t PyTuple_Size(PyObject* op) noexcept {
...
@@ -201,18 +201,19 @@ extern "C" Py_ssize_t PyTuple_Size(PyObject* op) noexcept {
Box
*
tupleRepr
(
BoxedTuple
*
t
)
{
Box
*
tupleRepr
(
BoxedTuple
*
t
)
{
assert
(
isSubclass
(
t
->
cls
,
tuple_cls
));
assert
(
isSubclass
(
t
->
cls
,
tuple_cls
));
int
n
;
std
::
vector
<
char
>
chars
;
n
=
t
->
size
();
if
(
n
==
0
)
{
chars
.
push_back
(
'('
);
chars
.
push_back
(
')'
);
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
}
try
{
try
{
int
n
;
std
::
vector
<
char
>
chars
;
int
status
=
Py_ReprEnter
((
PyObject
*
)
t
);
int
status
=
Py_ReprEnter
((
PyObject
*
)
t
);
n
=
t
->
size
();
if
(
n
==
0
)
{
chars
.
push_back
(
'('
);
chars
.
push_back
(
')'
);
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
}
if
(
status
!=
0
)
{
if
(
status
!=
0
)
{
if
(
status
<
0
)
if
(
status
<
0
)
throwCAPIException
();
throwCAPIException
();
...
@@ -226,32 +227,30 @@ Box* tupleRepr(BoxedTuple* t) {
...
@@ -226,32 +227,30 @@ Box* tupleRepr(BoxedTuple* t) {
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
}
}
}
catch
(
ExcInfo
e
)
{
setCAPIException
(
e
);
Py_ReprLeave
((
PyObject
*
)
t
);
return
NULL
;
chars
.
push_back
(
'('
);
}
chars
.
push_back
(
'('
);
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
if
(
i
)
{
chars
.
push_back
(
','
);
chars
.
push_back
(
' '
);
}
BoxedString
*
elt_repr
=
static_cast
<
BoxedString
*>
(
repr
(
t
->
elts
[
i
]));
chars
.
insert
(
chars
.
end
(),
elt_repr
->
s
().
begin
(),
elt_repr
->
s
().
end
());
}
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
if
(
n
==
1
)
if
(
i
)
{
chars
.
push_back
(
','
);
chars
.
push_back
(
','
);
chars
.
push_back
(
' '
);
}
BoxedString
*
elt_repr
=
static_cast
<
BoxedString
*>
(
repr
(
t
->
elts
[
i
]));
chars
.
insert
(
chars
.
end
(),
elt_repr
->
s
().
begin
(),
elt_repr
->
s
().
end
());
}
if
(
n
==
1
)
chars
.
push_back
(
')'
);
chars
.
push_back
(
','
);
Py_ReprLeave
((
PyObject
*
)
t
);
chars
.
push_back
(
')'
);
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
Py_ReprLeave
((
PyObject
*
)
t
);
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
}
catch
(
ExcInfo
e
)
{
Py_ReprLeave
((
PyObject
*
)
t
);
throw
e
;
}
}
}
Box
*
tupleNonzero
(
BoxedTuple
*
self
)
{
Box
*
tupleNonzero
(
BoxedTuple
*
self
)
{
...
...
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