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
f2fcdc4f
Commit
f2fcdc4f
authored
Mar 05, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
List tuple slice assignment
Also make some of the functions work correctly with list subclasses.
parent
4945dd64
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
4 deletions
+15
-4
src/runtime/list.cpp
src/runtime/list.cpp
+8
-4
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+1
-0
test/tests/list.py
test/tests/list.py
+4
-0
test/tests/list_subclassing.py
test/tests/list_subclassing.py
+2
-0
No files found.
src/runtime/list.cpp
View file @
f2fcdc4f
...
...
@@ -283,8 +283,12 @@ extern "C" Box* listSetitemSlice(BoxedList* self, BoxedSlice* slice, Box* v) {
BoxedList
*
lv
=
static_cast
<
BoxedList
*>
(
v
);
v_size
=
lv
->
size
;
v_elts
=
lv
->
elts
->
elts
;
}
else
if
(
isSubclass
(
v
->
cls
,
tuple_cls
))
{
BoxedTuple
*
tv
=
static_cast
<
BoxedTuple
*>
(
v
);
v_size
=
tv
->
elts
.
size
();
v_elts
=
&
tv
->
elts
[
0
];
}
else
{
RELEASE_ASSERT
(
0
,
"unsupported
value to assign to slice %s
"
,
getTypeName
(
v
));
RELEASE_ASSERT
(
0
,
"unsupported
type for list slice assignment: '%s'
"
,
getTypeName
(
v
));
}
RELEASE_ASSERT
(
!
v_elts
||
self
->
elts
->
elts
!=
v_elts
,
"Slice self-assignment currently unsupported"
);
...
...
@@ -786,7 +790,7 @@ void setupList() {
CLFunction
*
getitem
=
createRTFunction
(
2
,
0
,
0
,
0
);
addRTFunction
(
getitem
,
(
void
*
)
listGetitemInt
,
UNKNOWN
,
std
::
vector
<
ConcreteCompilerType
*>
{
LIST
,
BOXED_INT
});
addRTFunction
(
getitem
,
(
void
*
)
listGetitemSlice
,
LIST
,
std
::
vector
<
ConcreteCompilerType
*>
{
LIST
,
SLICE
});
addRTFunction
(
getitem
,
(
void
*
)
listGetitem
,
UNKNOWN
,
std
::
vector
<
ConcreteCompilerType
*>
{
LIST
,
UNKNOWN
});
addRTFunction
(
getitem
,
(
void
*
)
listGetitem
,
UNKNOWN
,
std
::
vector
<
ConcreteCompilerType
*>
{
UNKNOWN
,
UNKNOWN
});
list_cls
->
giveAttr
(
"__getitem__"
,
new
BoxedFunction
(
getitem
));
list_cls
->
giveAttr
(
"__iter__"
,
...
...
@@ -809,13 +813,13 @@ void setupList() {
CLFunction
*
setitem
=
createRTFunction
(
3
,
0
,
false
,
false
);
addRTFunction
(
setitem
,
(
void
*
)
listSetitemInt
,
NONE
,
std
::
vector
<
ConcreteCompilerType
*>
{
LIST
,
BOXED_INT
,
UNKNOWN
});
addRTFunction
(
setitem
,
(
void
*
)
listSetitemSlice
,
NONE
,
std
::
vector
<
ConcreteCompilerType
*>
{
LIST
,
SLICE
,
UNKNOWN
});
addRTFunction
(
setitem
,
(
void
*
)
listSetitem
,
NONE
,
std
::
vector
<
ConcreteCompilerType
*>
{
LIST
,
UNKNOWN
,
UNKNOWN
});
addRTFunction
(
setitem
,
(
void
*
)
listSetitem
,
NONE
,
std
::
vector
<
ConcreteCompilerType
*>
{
UNKNOWN
,
UNKNOWN
,
UNKNOWN
});
list_cls
->
giveAttr
(
"__setitem__"
,
new
BoxedFunction
(
setitem
));
CLFunction
*
delitem
=
createRTFunction
(
2
,
0
,
false
,
false
);
addRTFunction
(
delitem
,
(
void
*
)
listDelitemInt
,
NONE
,
std
::
vector
<
ConcreteCompilerType
*>
{
LIST
,
BOXED_INT
});
addRTFunction
(
delitem
,
(
void
*
)
listDelitemSlice
,
NONE
,
std
::
vector
<
ConcreteCompilerType
*>
{
LIST
,
SLICE
});
addRTFunction
(
delitem
,
(
void
*
)
listDelitem
,
NONE
,
std
::
vector
<
ConcreteCompilerType
*>
{
LIST
,
UNKNOWN
});
addRTFunction
(
delitem
,
(
void
*
)
listDelitem
,
NONE
,
std
::
vector
<
ConcreteCompilerType
*>
{
UNKNOWN
,
UNKNOWN
});
list_cls
->
giveAttr
(
"__delitem__"
,
new
BoxedFunction
(
delitem
));
list_cls
->
giveAttr
(
"insert"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
listInsert
,
NONE
,
3
)));
...
...
src/runtime/objmodel.cpp
View file @
f2fcdc4f
...
...
@@ -2417,6 +2417,7 @@ static CompiledFunction* pickVersion(CLFunction* f, int num_output_args, Box* oa
if
(
f
->
source
==
NULL
)
{
// TODO I don't think this should be happening any more?
printf
(
"Error: couldn't find suitable function version and no source to recompile!
\n
"
);
printf
(
"(First version: %p)
\n
"
,
f
->
versions
[
0
]
->
code
);
abort
();
}
...
...
test/tests/list.py
View file @
f2fcdc4f
...
...
@@ -140,3 +140,7 @@ for i1 in idxs:
l
=
[]
del
l
[:]
print
l
l
=
range
(
5
)
l
[
2
:
4
]
=
tuple
(
range
(
2
))
print
l
test/tests/list_subclassing.py
View file @
f2fcdc4f
...
...
@@ -10,3 +10,5 @@ print l.foo
print
l
print
len
(
MyList
.
__new__
(
MyList
))
l
[:]
=
l
[:]
print
l
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