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
b22043a4
Commit
b22043a4
authored
May 21, 2016
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
binopInternal: make inplace a template argument
parent
5816b3df
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
11 deletions
+13
-11
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+1
-1
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+10
-8
src/runtime/objmodel.h
src/runtime/objmodel.h
+2
-2
No files found.
src/runtime/builtin_modules/builtins.cpp
View file @
b22043a4
...
...
@@ -1404,7 +1404,7 @@ Box* ellipsisRepr(Box* self) {
return
boxString
(
"Ellipsis"
);
}
Box
*
divmod
(
Box
*
lhs
,
Box
*
rhs
)
{
return
binopInternal
<
NOT_REWRITABLE
>
(
lhs
,
rhs
,
AST_TYPE
::
DivMod
,
false
,
NULL
);
return
binopInternal
<
NOT_REWRITABLE
,
false
>
(
lhs
,
rhs
,
AST_TYPE
::
DivMod
,
NULL
);
}
Box
*
powFunc
(
Box
*
x
,
Box
*
y
,
Box
*
z
)
{
...
...
src/runtime/objmodel.cpp
View file @
b22043a4
...
...
@@ -5469,8 +5469,8 @@ static Box* binopInternalHelper(BinopRewriteArgs*& rewrite_args, BoxedString* op
return
rtn
;
}
template
<
Rewritable
rewritable
>
Box
*
binopInternal
(
Box
*
lhs
,
Box
*
rhs
,
int
op_type
,
bool
inplace
,
BinopRewriteArgs
*
rewrite_args
)
{
template
<
Rewritable
rewritable
,
bool
inplace
>
Box
*
binopInternal
(
Box
*
lhs
,
Box
*
rhs
,
int
op_type
,
BinopRewriteArgs
*
rewrite_args
)
{
if
(
rewritable
==
NOT_REWRITABLE
)
{
assert
(
!
rewrite_args
);
rewrite_args
=
NULL
;
...
...
@@ -5612,8 +5612,10 @@ Box* binopInternal(Box* lhs, Box* rhs, int op_type, bool inplace, BinopRewriteAr
raiseExcHelper
(
TypeError
,
"unsupported operand type(s) for %s%s: '%s' and '%s'"
,
op_sym
.
data
(),
op_sym_suffix
,
getTypeName
(
lhs
),
getTypeName
(
rhs
));
}
template
Box
*
binopInternal
<
REWRITABLE
>(
Box
*
,
Box
*
,
int
,
bool
,
BinopRewriteArgs
*
);
template
Box
*
binopInternal
<
NOT_REWRITABLE
>(
Box
*
,
Box
*
,
int
,
bool
,
BinopRewriteArgs
*
);
template
Box
*
binopInternal
<
REWRITABLE
,
true
>(
Box
*
,
Box
*
,
int
,
BinopRewriteArgs
*
);
template
Box
*
binopInternal
<
REWRITABLE
,
false
>(
Box
*
,
Box
*
,
int
,
BinopRewriteArgs
*
);
template
Box
*
binopInternal
<
NOT_REWRITABLE
,
true
>(
Box
*
,
Box
*
,
int
,
BinopRewriteArgs
*
);
template
Box
*
binopInternal
<
NOT_REWRITABLE
,
false
>(
Box
*
,
Box
*
,
int
,
BinopRewriteArgs
*
);
extern
"C"
Box
*
binop
(
Box
*
lhs
,
Box
*
rhs
,
int
op_type
)
{
STAT_TIMER
(
t0
,
"us_timer_slowpath_binop"
,
10
);
...
...
@@ -5640,7 +5642,7 @@ extern "C" Box* binop(Box* lhs, Box* rhs, int op_type) {
BinopRewriteArgs
rewrite_args
(
rewriter
.
get
(),
rewriter
->
getArg
(
0
)
->
setType
(
RefType
::
BORROWED
),
rewriter
->
getArg
(
1
)
->
setType
(
RefType
::
BORROWED
),
rewriter
->
getReturnDestination
());
rtn
=
binopInternal
<
REWRITABLE
>
(
lhs
,
rhs
,
op_type
,
fals
e
,
&
rewrite_args
);
rtn
=
binopInternal
<
REWRITABLE
,
false
/*not inplace*/
>
(
lhs
,
rhs
,
op_typ
e
,
&
rewrite_args
);
assert
(
rtn
);
if
(
!
rewrite_args
.
out_success
)
{
rewriter
.
reset
(
NULL
);
...
...
@@ -5648,7 +5650,7 @@ extern "C" Box* binop(Box* lhs, Box* rhs, int op_type) {
rewriter
->
commitReturning
(
rewrite_args
.
out_rtn
);
}
}
else
{
rtn
=
binopInternal
<
NOT_REWRITABLE
>
(
lhs
,
rhs
,
op_type
,
fals
e
,
NULL
);
rtn
=
binopInternal
<
NOT_REWRITABLE
,
false
/*not inplace*/
>
(
lhs
,
rhs
,
op_typ
e
,
NULL
);
}
// XXX
...
...
@@ -5676,14 +5678,14 @@ extern "C" Box* augbinop(Box* lhs, Box* rhs, int op_type) {
if
(
rewriter
.
get
())
{
BinopRewriteArgs
rewrite_args
(
rewriter
.
get
(),
rewriter
->
getArg
(
0
),
rewriter
->
getArg
(
1
),
rewriter
->
getReturnDestination
());
rtn
=
binopInternal
<
REWRITABLE
>
(
lhs
,
rhs
,
op_type
,
tru
e
,
&
rewrite_args
);
rtn
=
binopInternal
<
REWRITABLE
,
true
/*inplace*/
>
(
lhs
,
rhs
,
op_typ
e
,
&
rewrite_args
);
if
(
!
rewrite_args
.
out_success
)
{
rewriter
.
reset
(
NULL
);
}
else
{
rewriter
->
commitReturning
(
rewrite_args
.
out_rtn
);
}
}
else
{
rtn
=
binopInternal
<
NOT_REWRITABLE
>
(
lhs
,
rhs
,
op_type
,
tru
e
,
NULL
);
rtn
=
binopInternal
<
NOT_REWRITABLE
,
true
/*inplace*/
>
(
lhs
,
rhs
,
op_typ
e
,
NULL
);
}
return
rtn
;
...
...
src/runtime/objmodel.h
View file @
b22043a4
...
...
@@ -113,8 +113,8 @@ template <Rewritable rewritable>
void
setattrGeneric
(
Box
*
obj
,
BoxedString
*
attr
,
STOLEN
(
Box
*
)
val
,
SetattrRewriteArgs
*
rewrite_args
);
struct
BinopRewriteArgs
;
template
<
Rewritable
rewritable
>
Box
*
binopInternal
(
Box
*
lhs
,
Box
*
rhs
,
int
op_type
,
bool
inplace
,
BinopRewriteArgs
*
rewrite_args
);
template
<
Rewritable
rewritable
,
bool
inplace
>
Box
*
binopInternal
(
Box
*
lhs
,
Box
*
rhs
,
int
op_type
,
BinopRewriteArgs
*
rewrite_args
);
struct
CallRewriteArgs
;
template
<
ExceptionStyle
S
,
Rewritable
rewritable
>
...
...
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