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
9c5f4985
Commit
9c5f4985
authored
Oct 22, 2015
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add __iter__ runtime IC
parent
67635043
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
5 deletions
+19
-5
from_cpython/Include/object.h
from_cpython/Include/object.h
+1
-1
src/runtime/list.cpp
src/runtime/list.cpp
+1
-1
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+1
-2
src/runtime/types.cpp
src/runtime/types.cpp
+14
-0
src/runtime/types.h
src/runtime/types.h
+2
-1
No files found.
from_cpython/Include/object.h
View file @
9c5f4985
...
...
@@ -456,7 +456,7 @@ struct _typeobject {
void
*
_hcls
;
void
*
_hcattrs
;
char
_ics
[
32
];
char
_ics
[
40
];
void
*
_gcvisit_func
;
int
_attrs_offset
;
char
_flags
[
7
];
// These are bools in C++
...
...
src/runtime/list.cpp
View file @
9c5f4985
...
...
@@ -1273,7 +1273,6 @@ void setupList() {
static
PyMappingMethods
list_as_mapping
;
list_cls
->
tp_as_mapping
=
&
list_as_mapping
;
list_cls
->
tp_iter
=
listIter
;
list_iterator_cls
=
BoxedClass
::
create
(
type_cls
,
object_cls
,
&
BoxedListIterator
::
gcHandler
,
0
,
0
,
sizeof
(
BoxedListIterator
),
false
,
"listiterator"
);
list_reverse_iterator_cls
=
BoxedClass
::
create
(
type_cls
,
object_cls
,
&
BoxedListIterator
::
gcHandler
,
0
,
0
,
...
...
@@ -1356,6 +1355,7 @@ void setupList() {
list_cls
->
giveAttr
(
"__hash__"
,
None
);
list_cls
->
freeze
();
list_cls
->
tp_iter
=
listIter
;
list_cls
->
tp_as_sequence
->
sq_length
=
list_length
;
list_cls
->
tp_as_sequence
->
sq_concat
=
(
binaryfunc
)
list_concat
;
...
...
src/runtime/objmodel.cpp
View file @
9c5f4985
...
...
@@ -5728,8 +5728,7 @@ Box* getiter(Box* o) {
if
(
PyType_HasFeature
(
type
,
Py_TPFLAGS_HAVE_ITER
)
&&
type
->
tp_iter
!=
slot_tp_iter
&&
type
->
tp_iter
)
{
r
=
type
->
tp_iter
(
o
);
}
else
{
static
BoxedString
*
iter_str
=
internStringImmortal
(
"__iter__"
);
r
=
callattrInternal0
<
CXX
,
NOT_REWRITABLE
>
(
o
,
iter_str
,
LookupScope
::
CLASS_ONLY
,
NULL
,
ArgPassSpec
(
0
));
r
=
type
->
callIterIC
(
o
);
}
if
(
r
)
{
if
(
!
PyIter_Check
(
r
))
{
...
...
src/runtime/types.cpp
View file @
9c5f4985
...
...
@@ -290,6 +290,20 @@ Box* BoxedClass::callReprIC(Box* obj) {
return
ic
->
call
(
obj
,
repr_str
,
callattr_flags
,
nullptr
,
nullptr
,
nullptr
,
nullptr
,
nullptr
);
}
Box
*
BoxedClass
::
callIterIC
(
Box
*
obj
)
{
assert
(
obj
->
cls
==
this
);
auto
ic
=
iter_ic
.
get
();
if
(
!
ic
)
{
ic
=
new
CallattrIC
();
iter_ic
.
reset
(
ic
);
}
static
BoxedString
*
iter_str
=
internStringImmortal
(
"__iter__"
);
CallattrFlags
callattr_flags
{.
cls_only
=
true
,
.
null_on_nonexistent
=
true
,
.
argspec
=
ArgPassSpec
(
0
)
};
return
ic
->
call
(
obj
,
iter_str
,
callattr_flags
,
nullptr
,
nullptr
,
nullptr
,
nullptr
,
nullptr
);
}
bool
BoxedClass
::
callNonzeroIC
(
Box
*
obj
)
{
assert
(
obj
->
cls
==
this
);
...
...
src/runtime/types.h
View file @
9c5f4985
...
...
@@ -194,11 +194,12 @@ public:
// TODO: these don't actually get deallocated right now
std
::
unique_ptr
<
CallattrCapiIC
>
next_ic
;
std
::
unique_ptr
<
CallattrIC
>
hasnext_ic
,
repr_ic
;
std
::
unique_ptr
<
CallattrIC
>
hasnext_ic
,
repr_ic
,
iter_ic
;
std
::
unique_ptr
<
NonzeroIC
>
nonzero_ic
;
Box
*
callHasnextIC
(
Box
*
obj
,
bool
null_on_nonexistent
);
Box
*
call_nextIC
(
Box
*
obj
)
noexcept
;
Box
*
callReprIC
(
Box
*
obj
);
Box
*
callIterIC
(
Box
*
obj
);
bool
callNonzeroIC
(
Box
*
obj
);
gcvisit_func
gc_visit
;
...
...
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