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
4fc24442
Commit
4fc24442
authored
Jul 31, 2015
by
Dong-hee,Na
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some changing about exception handling and remove blank line
parent
2196761b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
126 additions
and
145 deletions
+126
-145
src/runtime/dict.cpp
src/runtime/dict.cpp
+28
-37
src/runtime/list.cpp
src/runtime/list.cpp
+26
-36
src/runtime/set.cpp
src/runtime/set.cpp
+34
-33
src/runtime/tuple.cpp
src/runtime/tuple.cpp
+38
-39
No files found.
src/runtime/dict.cpp
View file @
4fc24442
...
...
@@ -31,57 +31,48 @@ using namespace pyston::ExceptionStyle;
using
pyston
::
ExceptionStyle
::
ExceptionStyle
;
Box
*
dictRepr
(
BoxedDict
*
self
)
{
try
{
std
::
vector
<
char
>
chars
;
int
status
=
Py_ReprEnter
((
PyObject
*
)
self
);
if
(
status
!=
0
)
{
std
::
vector
<
char
>
chars
;
int
status
=
Py_ReprEnter
((
PyObject
*
)
self
);
if
(
status
!=
0
)
{
try
{
if
(
status
<
0
)
throwCAPIException
();
chars
.
push_back
(
'{'
);
chars
.
push_back
(
'.'
);
chars
.
push_back
(
'.'
);
chars
.
push_back
(
'.'
);
chars
.
push_back
(
'}'
);
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
}
catch
(
ExcInfo
e
)
{
Py_ReprLeave
((
PyObject
*
)
self
);
throw
e
;
}
chars
.
push_back
(
'{'
);
chars
.
push_back
(
'.'
);
chars
.
push_back
(
'.'
);
chars
.
push_back
(
'.'
);
chars
.
push_back
(
'}'
);
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
}
bool
first
=
true
;
for
(
const
auto
&
p
:
self
->
d
)
{
if
(
!
first
)
{
chars
.
push_back
(
','
);
chars
.
push_back
(
' '
);
}
first
=
false
;
chars
.
push_back
(
'{'
);
bool
first
=
true
;
for
(
const
auto
&
p
:
self
->
d
)
{
if
(
!
first
)
{
chars
.
push_back
(
','
);
chars
.
push_back
(
' '
);
}
first
=
false
;
try
{
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
.
insert
(
chars
.
end
(),
v
->
s
().
begin
(),
v
->
s
().
end
());
}
catch
(
ExcInfo
e
)
{
Py_ReprLeave
((
PyObject
*
)
self
);
throw
e
;
}
chars
.
push_back
(
'}'
);
Py_ReprLeave
((
PyObject
*
)
self
);
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
}
catch
(
ExcInfo
e
)
{
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
)
{
...
...
src/runtime/list.cpp
View file @
4fc24442
...
...
@@ -61,51 +61,41 @@ extern "C" PyObject* PyList_AsTuple(PyObject* v) noexcept {
}
extern
"C"
Box
*
listRepr
(
BoxedList
*
self
)
{
std
::
vector
<
char
>
chars
;
int
status
=
Py_ReprEnter
((
PyObject
*
)
self
);
try
{
std
::
vector
<
char
>
chars
;
int
status
=
Py_ReprEnter
((
PyObject
*
)
self
);
if
(
status
!=
0
)
{
if
(
status
!=
0
)
{
try
{
if
(
status
<
0
)
throwCAPIException
();
chars
.
push_back
(
'['
);
chars
.
push_back
(
'.'
);
chars
.
push_back
(
'.'
);
chars
.
push_back
(
'.'
);
chars
.
push_back
(
']'
);
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
}
catch
(
ExcInfo
e
)
{
Py_ReprLeave
((
PyObject
*
)
self
);
throw
e
;
}
chars
.
push_back
(
'['
);
for
(
int
i
=
0
;
i
<
self
->
size
;
i
++
)
{
if
(
i
>
0
)
{
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
());
}
chars
.
push_back
(
'.'
);
chars
.
push_back
(
'.'
);
chars
.
push_back
(
'.'
);
chars
.
push_back
(
']'
);
Py_ReprLeave
((
PyObject
*
)
self
);
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
}
chars
.
push_back
(
'['
);
}
catch
(
ExcInfo
e
)
{
Py_ReprLeave
((
PyObject
*
)
self
);
throw
e
;
for
(
int
i
=
0
;
i
<
self
->
size
;
i
++
)
{
if
(
i
>
0
)
{
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
());
}
chars
.
push_back
(
']'
);
Py_ReprLeave
((
PyObject
*
)
self
);
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
}
extern
"C"
Box
*
listNonzero
(
BoxedList
*
self
)
{
...
...
src/runtime/set.cpp
View file @
4fc24442
...
...
@@ -95,55 +95,56 @@ Box* setNew(Box* _cls, Box* container) {
static
Box
*
_setRepr
(
BoxedSet
*
self
,
const
char
*
type_name
)
{
try
{
std
::
vector
<
char
>
chars
;
int
status
=
Py_ReprEnter
((
PyObject
*
)
self
);
if
(
status
!=
0
)
{
std
::
vector
<
char
>
chars
;
int
status
=
Py_ReprEnter
((
PyObject
*
)
self
);
if
(
status
!=
0
)
{
try
{
if
(
status
<
0
)
throwCAPIException
();
std
::
string
ty
=
std
::
string
(
type_name
);
chars
.
insert
(
chars
.
end
(),
ty
.
begin
(),
ty
.
end
());
chars
.
push_back
(
'('
);
chars
.
push_back
(
'.'
);
chars
.
push_back
(
'.'
);
chars
.
push_back
(
'.'
);
chars
.
push_back
(
')'
);
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
}
catch
(
ExcInfo
e
)
{
Py_ReprLeave
((
PyObject
*
)
self
);
throw
e
;
}
std
::
string
ty
=
std
::
string
(
type_name
);
chars
.
insert
(
chars
.
end
(),
ty
.
begin
(),
ty
.
end
());
chars
.
push_back
(
'('
);
chars
.
push_back
(
'['
);
chars
.
push_back
(
'.'
);
chars
.
push_back
(
'.'
);
chars
.
push_back
(
'.'
);
chars
.
push_back
(
')'
);
bool
first
=
true
;
for
(
Box
*
elt
:
self
->
s
)
{
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()))
;
}
if
(
!
first
)
{
chars
.
push_back
(
','
);
chars
.
push_back
(
' '
);
}
std
::
string
ty
=
std
::
string
(
type_name
);
chars
.
insert
(
chars
.
end
(),
ty
.
begin
(),
ty
.
end
());
chars
.
push_back
(
'('
);
chars
.
push_back
(
'['
);
bool
first
=
true
;
for
(
Box
*
elt
:
self
->
s
)
{
if
(
!
first
)
{
chars
.
push_back
(
','
);
chars
.
push_back
(
' '
);
}
try
{
BoxedString
*
str
=
static_cast
<
BoxedString
*>
(
repr
(
elt
));
chars
.
insert
(
chars
.
end
(),
str
->
s
().
begin
(),
str
->
s
().
end
());
first
=
false
;
}
catch
(
ExcInfo
e
)
{
Py_ReprLeave
((
PyObject
*
)
self
);
throw
e
;
}
chars
.
push_back
(
']'
);
chars
.
push_back
(
')'
);
Py_ReprLeave
((
PyObject
*
)
self
);
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
}
catch
(
ExcInfo
e
)
{
Py_ReprLeave
((
PyObject
*
)
self
);
throw
e
;
first
=
false
;
}
chars
.
push_back
(
']'
);
chars
.
push_back
(
')'
);
Py_ReprLeave
((
PyObject
*
)
self
);
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
}
Box
*
setRepr
(
BoxedSet
*
self
)
{
...
...
src/runtime/tuple.cpp
View file @
4fc24442
...
...
@@ -199,58 +199,57 @@ extern "C" Py_ssize_t PyTuple_Size(PyObject* op) noexcept {
}
Box
*
tupleRepr
(
BoxedTuple
*
t
)
{
assert
(
isSubclass
(
t
->
cls
,
tuple_cls
));
try
{
int
n
;
std
::
vector
<
char
>
chars
;
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
()));
}
assert
(
isSubclass
(
t
->
cls
,
tuple_cls
));
int
n
;
std
::
vector
<
char
>
chars
;
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
)
{
try
{
if
(
status
<
0
)
throwCAPIException
();
chars
.
push_back
(
'('
);
chars
.
push_back
(
'.'
);
chars
.
push_back
(
'.'
);
chars
.
push_back
(
'.'
);
chars
.
push_back
(
')'
);
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
}
catch
(
ExcInfo
e
)
{
Py_ReprLeave
((
PyObject
*
)
t
);
throw
e
;
}
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
(
'('
);
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
if
(
i
)
{
chars
.
push_back
(
','
);
chars
.
push_back
(
' '
);
}
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
if
(
i
)
{
chars
.
push_back
(
','
);
chars
.
push_back
(
' '
);
}
try
{
BoxedString
*
elt_repr
=
static_cast
<
BoxedString
*>
(
repr
(
t
->
elts
[
i
]));
chars
.
insert
(
chars
.
end
(),
elt_repr
->
s
().
begin
(),
elt_repr
->
s
().
end
());
}
catch
(
ExcInfo
e
)
{
Py_ReprLeave
((
PyObject
*
)
t
);
throw
e
;
}
}
if
(
n
==
1
)
chars
.
push_back
(
','
);
chars
.
push_back
(
')'
);
Py_ReprLeave
((
PyObject
*
)
t
);
if
(
n
==
1
)
chars
.
push_back
(
','
);
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
chars
.
push_back
(
')'
);
Py_ReprLeave
((
PyObject
*
)
t
);
}
catch
(
ExcInfo
e
)
{
Py_ReprLeave
((
PyObject
*
)
t
);
throw
e
;
}
return
boxString
(
llvm
::
StringRef
(
&
chars
[
0
],
chars
.
size
()));
}
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