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
6d8b2e91
Commit
6d8b2e91
authored
May 15, 2014
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add pyElements method.
parent
0cf0c7fe
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
11 deletions
+15
-11
src/core/types.h
src/core/types.h
+4
-4
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+3
-3
src/runtime/list.cpp
src/runtime/list.cpp
+1
-1
src/runtime/set.cpp
src/runtime/set.cpp
+1
-1
src/runtime/types.cpp
src/runtime/types.cpp
+6
-2
No files found.
src/core/types.h
View file @
6d8b2e91
...
...
@@ -19,6 +19,8 @@
// over having them spread randomly in different files, this should probably be split again
// but in a way that makes more sense.
#include <llvm/ADT/iterator_range.h>
#include "core/common.h"
#include "core/stats.h"
...
...
@@ -283,7 +285,7 @@ public:
};
class
Box
;
class
BoxIterator
:
public
std
::
iterator
<
std
::
forward_iterator_tag
,
Box
*>
{
class
BoxIterator
{
public:
BoxIterator
(
Box
*
iter
)
:
iter
(
iter
),
value
(
nullptr
)
{}
...
...
@@ -291,7 +293,6 @@ public:
bool
operator
!=
(
BoxIterator
const
&
rhs
)
const
{
return
!
(
*
this
==
rhs
);
}
BoxIterator
&
operator
++
();
BoxIterator
operator
++
(
int
)
{
BoxIterator
tmp
(
*
this
);
operator
++
();
...
...
@@ -313,8 +314,7 @@ class Box : public GCObject {
public:
BoxedClass
*
cls
;
BoxIterator
begin
()
const
;
BoxIterator
end
()
const
{
return
BoxIterator
(
nullptr
);
}
llvm
::
iterator_range
<
BoxIterator
>
pyElements
();
constexpr
Box
(
const
ObjectFlavor
*
flavor
,
BoxedClass
*
c
)
__attribute__
((
visibility
(
"default"
)))
:
GCObject
(
flavor
),
cls
(
c
)
{
...
...
src/runtime/builtin_modules/builtins.cpp
View file @
6d8b2e91
...
...
@@ -51,7 +51,7 @@ extern "C" Box* abs_(Box* x) {
extern
"C"
Box
*
min1
(
Box
*
container
)
{
Box
*
minElement
=
nullptr
;
for
(
Box
*
e
:
*
container
)
{
for
(
Box
*
e
:
container
->
pyElements
()
)
{
if
(
!
minElement
)
{
minElement
=
e
;
}
else
{
...
...
@@ -80,7 +80,7 @@ extern "C" Box* min2(Box* o0, Box* o1) {
extern
"C"
Box
*
max1
(
Box
*
container
)
{
Box
*
maxElement
=
nullptr
;
for
(
Box
*
e
:
*
container
)
{
for
(
Box
*
e
:
container
->
pyElements
()
)
{
if
(
!
maxElement
)
{
maxElement
=
e
;
}
else
{
...
...
@@ -266,7 +266,7 @@ Box* getattr3(Box* obj, Box* _str, Box* default_value) {
Box
*
map2
(
Box
*
f
,
Box
*
container
)
{
Box
*
rtn
=
new
BoxedList
();
for
(
Box
*
e
:
*
container
)
{
for
(
Box
*
e
:
container
->
pyElements
()
)
{
listAppendInternal
(
rtn
,
runtimeCall
(
f
,
1
,
e
,
NULL
,
NULL
,
NULL
));
}
return
rtn
;
...
...
src/runtime/list.cpp
View file @
6d8b2e91
...
...
@@ -355,7 +355,7 @@ extern "C" Box* listNew2(Box* cls, Box* container) {
assert
(
cls
==
list_cls
);
BoxedList
*
rtn
=
new
BoxedList
();
for
(
Box
*
e
:
*
container
)
{
for
(
Box
*
e
:
container
->
pyElements
()
)
{
listAppendInternal
(
rtn
,
e
);
}
return
rtn
;
...
...
src/runtime/set.cpp
View file @
6d8b2e91
...
...
@@ -73,7 +73,7 @@ Box* setNew2(Box* cls, Box* container) {
assert
(
cls
==
set_cls
);
Box
*
rtn
=
new
BoxedSet
();
for
(
Box
*
e
:
*
container
)
{
for
(
Box
*
e
:
container
->
pyElements
()
)
{
setAdd2
(
rtn
,
e
);
}
...
...
src/runtime/types.cpp
View file @
6d8b2e91
...
...
@@ -50,10 +50,14 @@ BoxIterator& BoxIterator::operator++() {
return
*
this
;
}
BoxIterator
Box
::
begin
()
const
{
llvm
::
iterator_range
<
BoxIterator
>
Box
::
pyElements
()
{
static
std
::
string
iter_str
(
"__iter__"
);
Box
*
iter
=
callattr
(
const_cast
<
Box
*>
(
this
),
&
iter_str
,
true
,
0
,
NULL
,
NULL
,
NULL
,
NULL
);
return
++
BoxIterator
(
iter
);
if
(
iter
)
{
return
llvm
::
iterator_range
<
BoxIterator
>
(
++
BoxIterator
(
iter
),
BoxIterator
(
nullptr
));
}
return
llvm
::
iterator_range
<
BoxIterator
>
(
BoxIterator
(
nullptr
),
BoxIterator
(
nullptr
));
}
extern
"C"
BoxedFunction
::
BoxedFunction
(
CLFunction
*
f
)
:
HCBox
(
&
function_flavor
,
function_cls
),
f
(
f
)
{
...
...
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