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
89ab8838
Commit
89ab8838
authored
Aug 11, 2014
by
Joris Vankerschaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix formatting.
parent
38f2aef8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
src/runtime/tuple.cpp
src/runtime/tuple.cpp
+7
-7
No files found.
src/runtime/tuple.cpp
View file @
89ab8838
...
...
@@ -48,12 +48,12 @@ Box* _tupleSlice(BoxedTuple* self, i64 start, i64 stop, i64 step) {
// This is adapted from CPython's PySlice_GetIndicesEx.
i64
slicelength
;
if
(
step
<
0
)
slicelength
=
(
stop
-
start
+
1
)
/
(
step
)
+
1
;
slicelength
=
(
stop
-
start
+
1
)
/
(
step
)
+
1
;
else
slicelength
=
(
stop
-
start
-
1
)
/
(
step
)
+
1
;
slicelength
=
(
stop
-
start
-
1
)
/
(
step
)
+
1
;
if
(
slicelength
<
0
)
slicelength
=
0
;
slicelength
=
0
;
// FIXME: No need to initialize with 0.
BoxedTuple
::
GCVector
velts
(
slicelength
,
0
);
...
...
@@ -78,7 +78,7 @@ Box* tupleGetitemInt(BoxedTuple* self, BoxedInt* slice) {
Box
*
rtn
=
self
->
elts
[
n
];
return
rtn
;
}
}
Box
*
tupleGetitemSlice
(
BoxedTuple
*
self
,
BoxedSlice
*
slice
)
{
assert
(
self
->
cls
==
tuple_cls
);
...
...
@@ -97,8 +97,7 @@ Box* tupleGetitem(BoxedTuple* self, Box* slice) {
else
if
(
slice
->
cls
==
slice_cls
)
return
tupleGetitemSlice
(
self
,
static_cast
<
BoxedSlice
*>
(
slice
));
else
raiseExcHelper
(
TypeError
,
"tuple indices must be integers, not %s"
,
getTypeName
(
slice
)
->
c_str
());
raiseExcHelper
(
TypeError
,
"tuple indices must be integers, not %s"
,
getTypeName
(
slice
)
->
c_str
());
}
Box
*
tupleAdd
(
BoxedTuple
*
self
,
Box
*
rhs
)
{
...
...
@@ -261,7 +260,8 @@ void setupTuple() {
tuple_cls
->
giveAttr
(
"__name__"
,
boxStrConstant
(
"tuple"
));
CLFunction
*
getitem
=
createRTFunction
(
2
,
0
,
0
,
0
);
addRTFunction
(
getitem
,
(
void
*
)
tupleGetitemInt
,
UNKNOWN
,
std
::
vector
<
ConcreteCompilerType
*>
{
BOXED_TUPLE
,
BOXED_INT
});
addRTFunction
(
getitem
,
(
void
*
)
tupleGetitemInt
,
UNKNOWN
,
std
::
vector
<
ConcreteCompilerType
*>
{
BOXED_TUPLE
,
BOXED_INT
});
addRTFunction
(
getitem
,
(
void
*
)
tupleGetitemSlice
,
SLICE
,
std
::
vector
<
ConcreteCompilerType
*>
{
BOXED_TUPLE
,
SLICE
});
addRTFunction
(
getitem
,
(
void
*
)
tupleGetitem
,
UNKNOWN
,
std
::
vector
<
ConcreteCompilerType
*>
{
BOXED_TUPLE
,
UNKNOWN
});
tuple_cls
->
giveAttr
(
"__getitem__"
,
new
BoxedFunction
(
getitem
));
...
...
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