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
df8ee5c6
Commit
df8ee5c6
authored
Jan 28, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some list functions
parent
ff39eb26
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
16 deletions
+37
-16
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+2
-1
src/runtime/list.cpp
src/runtime/list.cpp
+35
-15
No files found.
src/runtime/builtin_modules/builtins.cpp
View file @
df8ee5c6
...
...
@@ -613,7 +613,7 @@ BoxedClass* BaseException, *Exception, *StandardError, *AssertionError, *Attribu
*
NameError
,
*
KeyError
,
*
IndexError
,
*
IOError
,
*
OSError
,
*
ZeroDivisionError
,
*
ValueError
,
*
UnboundLocalError
,
*
RuntimeError
,
*
ImportError
,
*
StopIteration
,
*
Warning
,
*
SyntaxError
,
*
OverflowError
,
*
DeprecationWarning
,
*
MemoryError
,
*
LookupError
,
*
EnvironmentError
,
*
ArithmeticError
,
*
BufferError
,
*
KeyboardInterrupt
,
*
SystemExit
,
*
SystemError
,
*
NotImplementedError
,
*
PendingDeprecationWarning
;
*
SystemError
,
*
NotImplementedError
,
*
PendingDeprecationWarning
,
*
EOFError
;
Box
*
PyExc_RecursionErrorInst
;
Box
*
PyExc_MemoryErrorInst
;
...
...
@@ -1038,6 +1038,7 @@ void setupBuiltins() {
SystemError
=
makeBuiltinException
(
StandardError
,
"SystemError"
);
NotImplementedError
=
makeBuiltinException
(
RuntimeError
,
"NotImplementedError"
);
PendingDeprecationWarning
=
makeBuiltinException
(
Warning
,
"PendingDeprecationWarning"
);
EOFError
=
makeBuiltinException
(
StandardError
,
"EOFError"
);
EnvironmentError
->
gc_visit
=
BoxedEnvironmentError
::
gcHandler
;
EnvironmentError
->
giveAttr
(
...
...
src/runtime/list.cpp
View file @
df8ee5c6
...
...
@@ -39,10 +39,6 @@ extern "C" int PyList_Append(PyObject* op, PyObject* newitem) noexcept {
return
0
;
}
extern
"C"
int
PyList_SetItem
(
PyObject
*
op
,
Py_ssize_t
i
,
PyObject
*
newitem
)
noexcept
{
Py_FatalError
(
"unimplemented"
);
}
extern
"C"
Box
*
listRepr
(
BoxedList
*
self
)
{
LOCK_REGION
(
self
->
lock
.
asRead
());
...
...
@@ -180,6 +176,16 @@ extern "C" Box* listGetitem(BoxedList* self, Box* slice) {
}
}
static
void
_listSetitem
(
BoxedList
*
self
,
int64_t
n
,
Box
*
v
)
{
if
(
n
<
0
)
n
=
self
->
size
+
n
;
if
(
n
<
0
||
n
>=
self
->
size
)
{
raiseExcHelper
(
IndexError
,
"list index out of range"
);
}
self
->
elts
->
elts
[
n
]
=
v
;
}
extern
"C"
Box
*
listSetitemInt
(
BoxedList
*
self
,
BoxedInt
*
slice
,
Box
*
v
)
{
// I think r lock is ok here, since we don't change the list structure:
...
...
@@ -188,17 +194,22 @@ extern "C" Box* listSetitemInt(BoxedList* self, BoxedInt* slice, Box* v) {
assert
(
self
->
cls
==
list_cls
);
assert
(
isSubclass
(
slice
->
cls
,
int_cls
));
int64_t
n
=
slice
->
n
;
if
(
n
<
0
)
n
=
self
->
size
+
n
;
if
(
n
<
0
||
n
>=
self
->
size
)
{
raiseExcHelper
(
IndexError
,
"list index out of range"
);
}
_listSetitem
(
self
,
n
,
v
);
self
->
elts
->
elts
[
n
]
=
v
;
return
None
;
}
extern
"C"
int
PyList_SetItem
(
PyObject
*
op
,
Py_ssize_t
i
,
PyObject
*
newitem
)
noexcept
{
assert
(
op
->
cls
==
list_cls
);
try
{
_listSetitem
(
static_cast
<
BoxedList
*>
(
op
),
i
,
newitem
);
}
catch
(
ExcInfo
e
)
{
abort
();
}
return
0
;
}
Box
*
listIAdd
(
BoxedList
*
self
,
Box
*
_rhs
);
// Analogue of _PyEval_SliceIndex
...
...
@@ -554,12 +565,21 @@ extern "C" Box* listNew(Box* cls, Box* container) {
}
extern
"C"
PyObject
*
PyList_New
(
Py_ssize_t
size
)
noexcept
{
// This function is supposed to return a list of `size` NULL elements.
// That will probably trip an assert somewhere if we try to create that (ex
// I think the GC will expect them to be real objects so they can be relocated).
RELEASE_ASSERT
(
size
==
0
,
""
);
try
{
return
new
BoxedList
();
BoxedList
*
l
=
new
BoxedList
();
if
(
size
)
{
// This function is supposed to return a list of `size` NULL elements.
// That will probably trip an assert somewhere if we try to create that (ex
// I think the GC will expect them to be real objects so they can be relocated),
// so put None in instead
l
->
ensure
(
size
);
for
(
Py_ssize_t
i
=
0
;
i
<
size
;
i
++
)
{
l
->
elts
->
elts
[
i
]
=
None
;
}
l
->
size
=
size
;
}
return
l
;
}
catch
(
ExcInfo
e
)
{
abort
();
}
...
...
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