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
280146ff
Commit
280146ff
authored
Feb 09, 2015
by
Chris Toshok
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move getreversed from objmodel.cpp to builtin_module/builtins.cpp
parent
b131d40c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
16 deletions
+18
-16
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+18
-0
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+0
-15
src/runtime/objmodel.h
src/runtime/objmodel.h
+0
-1
No files found.
src/runtime/builtin_modules/builtins.cpp
View file @
280146ff
...
...
@@ -32,6 +32,7 @@
#include "runtime/ics.h"
#include "runtime/import.h"
#include "runtime/inline/xrange.h"
#include "runtime/iterobject.h"
#include "runtime/list.h"
#include "runtime/long.h"
#include "runtime/objmodel.h"
...
...
@@ -830,6 +831,23 @@ Box* print(BoxedTuple* args, BoxedDict* kwargs) {
return
None
;
}
Box
*
getreversed
(
Box
*
o
)
{
static
const
std
::
string
reversed_str
(
"__reversed__"
);
static
const
std
::
string
getitem_str
(
"__getitem__"
);
// TODO add rewriting to this? probably want to try to avoid this path though
Box
*
r
=
callattr
(
o
,
&
reversed_str
,
CallattrFlags
({.
cls_only
=
true
,
.
null_on_nonexistent
=
true
}),
ArgPassSpec
(
0
),
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
if
(
r
)
return
r
;
if
(
!
typeLookup
(
o
->
cls
,
getitem_str
,
NULL
))
{
raiseExcHelper
(
TypeError
,
"'%s' object is not iterable"
,
getTypeName
(
o
));
}
int64_t
len
=
unboxedLen
(
o
);
// this will throw an exception if __len__ isn't there
return
new
(
seqreviter_cls
)
BoxedSeqIter
(
o
,
len
-
1
);
}
Box
*
pydump
(
void
*
p
)
{
dump
(
p
);
return
None
;
...
...
src/runtime/objmodel.cpp
View file @
280146ff
...
...
@@ -77,7 +77,6 @@ static const std::string get_str("__get__");
static
const
std
::
string
hasnext_str
(
"__hasnext__"
);
static
const
std
::
string
init_str
(
"__init__"
);
static
const
std
::
string
iter_str
(
"__iter__"
);
static
const
std
::
string
reversed_str
(
"__reversed__"
);
static
const
std
::
string
new_str
(
"__new__"
);
static
const
std
::
string
none_str
(
"None"
);
static
const
std
::
string
repr_str
(
"__repr__"
);
...
...
@@ -3444,20 +3443,6 @@ Box* getiter(Box* o) {
raiseExcHelper
(
TypeError
,
"'%s' object is not iterable"
,
getTypeName
(
o
));
}
Box
*
getreversed
(
Box
*
o
)
{
// TODO add rewriting to this? probably want to try to avoid this path though
Box
*
r
=
callattrInternal0
(
o
,
&
reversed_str
,
LookupScope
::
CLASS_ONLY
,
NULL
,
ArgPassSpec
(
0
));
if
(
r
)
return
r
;
if
(
!
typeLookup
(
o
->
cls
,
getitem_str
,
NULL
))
{
raiseExcHelper
(
TypeError
,
"'%s' object is not iterable"
,
getTypeName
(
o
));
}
int64_t
len
=
unboxedLen
(
o
);
// this will throw an exception if __len__ isn't there
return
new
(
seqreviter_cls
)
BoxedSeqIter
(
o
,
len
-
1
);
}
llvm
::
iterator_range
<
BoxIterator
>
Box
::
pyElements
()
{
// TODO: this should probably call getPystonIter
Box
*
iter
=
getiter
(
this
);
...
...
src/runtime/objmodel.h
View file @
280146ff
...
...
@@ -89,7 +89,6 @@ extern "C" bool isSubclass(BoxedClass* child, BoxedClass* parent);
extern
"C"
BoxedClosure
*
createClosure
(
BoxedClosure
*
parent_closure
);
Box
*
getiter
(
Box
*
o
);
Box
*
getreversed
(
Box
*
o
);
extern
"C"
Box
*
getPystonIter
(
Box
*
o
);
extern
"C"
void
dump
(
void
*
p
);
...
...
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