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
61a68d3d
Commit
61a68d3d
authored
Aug 12, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Have rearrangeArguments return in place
parent
be7aae75
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
70 deletions
+55
-70
src/capi/typeobject.cpp
src/capi/typeobject.cpp
+3
-3
src/runtime/capi.cpp
src/runtime/capi.cpp
+7
-10
src/runtime/descr.cpp
src/runtime/descr.cpp
+18
-26
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+18
-21
src/runtime/rewrite_args.h
src/runtime/rewrite_args.h
+2
-2
src/runtime/types.cpp
src/runtime/types.cpp
+7
-8
No files found.
src/capi/typeobject.cpp
View file @
61a68d3d
...
...
@@ -3217,10 +3217,10 @@ static Box* tppProxyToTpCall(Box* self, CallRewriteArgs* rewrite_args, ArgPassSp
}
bool
rewrite_success
=
false
;
Box
*
oarg1
,
*
oarg2
=
NULL
,
*
oarg3
,
*
*
oargs
=
NULL
;
Box
**
oargs
=
NULL
;
try
{
rearrangeArguments
(
paramspec
,
NULL
,
""
,
NULL
,
rewrite_args
,
rewrite_success
,
argspec
,
arg1
,
arg2
,
arg3
,
args
,
keyword_names
,
oarg1
,
oarg2
,
oarg3
,
oarg
s
);
oargs
,
keyword_name
s
);
}
catch
(
ExcInfo
e
)
{
if
(
S
==
CAPI
)
{
setCAPIException
(
e
);
...
...
@@ -3251,7 +3251,7 @@ static Box* tppProxyToTpCall(Box* self, CallRewriteArgs* rewrite_args, ArgPassSp
rewrite_args
->
out_success
=
true
;
}
Box
*
r
=
self
->
cls
->
tp_call
(
self
,
oarg1
,
o
arg2
);
Box
*
r
=
self
->
cls
->
tp_call
(
self
,
arg1
,
arg2
);
if
(
!
r
&&
S
==
CXX
)
throwCAPIException
();
return
r
;
...
...
src/runtime/capi.cpp
View file @
61a68d3d
...
...
@@ -1524,14 +1524,11 @@ Box* BoxedCApiFunction::tppCall(Box* _self, CallRewriteArgs* rewrite_args, ArgPa
RELEASE_ASSERT
(
0
,
"0x%x"
,
flags
);
}
Box
*
oarg1
=
NULL
;
Box
*
oarg2
=
NULL
;
Box
*
oarg3
=
NULL
;
Box
**
oargs
=
NULL
;
bool
rewrite_success
=
false
;
rearrangeArguments
(
paramspec
,
NULL
,
self
->
method_def
->
ml_name
,
NULL
,
rewrite_args
,
rewrite_success
,
argspec
,
arg1
,
arg2
,
arg3
,
args
,
keyword_names
,
oarg1
,
oarg2
,
oarg3
,
oarg
s
);
arg2
,
arg3
,
args
,
oargs
,
keyword_name
s
);
if
(
!
rewrite_success
)
rewrite_args
=
NULL
;
...
...
@@ -1542,11 +1539,11 @@ Box* BoxedCApiFunction::tppCall(Box* _self, CallRewriteArgs* rewrite_args, ArgPa
Box
*
rtn
;
if
(
flags
==
METH_VARARGS
)
{
rtn
=
(
Box
*
)
func
(
self
->
passthrough
,
o
arg1
);
rtn
=
(
Box
*
)
func
(
self
->
passthrough
,
arg1
);
if
(
rewrite_args
)
rewrite_args
->
out_rtn
=
rewrite_args
->
rewriter
->
call
(
true
,
(
void
*
)
func
,
r_passthrough
,
rewrite_args
->
arg1
);
}
else
if
(
flags
==
(
METH_VARARGS
|
METH_KEYWORDS
))
{
rtn
=
(
Box
*
)((
PyCFunctionWithKeywords
)
func
)(
self
->
passthrough
,
oarg1
,
o
arg2
);
rtn
=
(
Box
*
)((
PyCFunctionWithKeywords
)
func
)(
self
->
passthrough
,
arg1
,
arg2
);
if
(
rewrite_args
)
rewrite_args
->
out_rtn
=
rewrite_args
->
rewriter
->
call
(
true
,
(
void
*
)
func
,
r_passthrough
,
rewrite_args
->
arg1
,
rewrite_args
->
arg2
);
...
...
@@ -1556,7 +1553,7 @@ Box* BoxedCApiFunction::tppCall(Box* _self, CallRewriteArgs* rewrite_args, ArgPa
rewrite_args
->
out_rtn
=
rewrite_args
->
rewriter
->
call
(
true
,
(
void
*
)
func
,
r_passthrough
,
rewrite_args
->
rewriter
->
loadConst
(
0
,
Location
::
forArg
(
1
)));
}
else
if
(
flags
==
METH_O
)
{
rtn
=
(
Box
*
)
func
(
self
->
passthrough
,
o
arg1
);
rtn
=
(
Box
*
)
func
(
self
->
passthrough
,
arg1
);
if
(
rewrite_args
)
rewrite_args
->
out_rtn
=
rewrite_args
->
rewriter
->
call
(
true
,
(
void
*
)
func
,
r_passthrough
,
rewrite_args
->
arg1
);
}
else
if
(
flags
==
METH_OLDARGS
)
{
...
...
@@ -1564,10 +1561,10 @@ Box* BoxedCApiFunction::tppCall(Box* _self, CallRewriteArgs* rewrite_args, ArgPa
rewrite_args
=
NULL
;
int
size
=
PyTuple_GET_SIZE
(
o
arg1
);
Box
*
arg
=
o
arg1
;
int
size
=
PyTuple_GET_SIZE
(
arg1
);
Box
*
arg
=
arg1
;
if
(
size
==
1
)
arg
=
PyTuple_GET_ITEM
(
o
arg1
,
0
);
arg
=
PyTuple_GET_ITEM
(
arg1
,
0
);
else
if
(
size
==
0
)
arg
=
NULL
;
rtn
=
func
(
self
->
passthrough
,
arg
);
...
...
src/runtime/descr.cpp
View file @
61a68d3d
...
...
@@ -292,9 +292,6 @@ Box* BoxedMethodDescriptor::tppCall(Box* _self, CallRewriteArgs* rewrite_args, A
RELEASE_ASSERT
(
0
,
"0x%x"
,
call_flags
);
}
Box
*
oarg1
=
NULL
;
Box
*
oarg2
=
NULL
;
Box
*
oarg3
=
NULL
;
Box
**
oargs
=
NULL
;
Box
*
oargs_array
[
1
];
...
...
@@ -305,32 +302,31 @@ Box* BoxedMethodDescriptor::tppCall(Box* _self, CallRewriteArgs* rewrite_args, A
bool
rewrite_success
=
false
;
rearrangeArguments
(
paramspec
,
NULL
,
self
->
method
->
ml_name
,
defaults
,
rewrite_args
,
rewrite_success
,
argspec
,
arg1
,
arg2
,
arg3
,
args
,
keyword_names
,
oarg1
,
oarg2
,
oarg3
,
oarg
s
);
arg2
,
arg3
,
args
,
oargs
,
keyword_name
s
);
if
(
!
rewrite_success
)
rewrite_args
=
NULL
;
if
(
ml_flags
&
METH_CLASS
)
{
rewrite_args
=
NULL
;
if
(
!
isSubclass
(
o
arg1
->
cls
,
type_cls
))
if
(
!
isSubclass
(
arg1
->
cls
,
type_cls
))
raiseExcHelper
(
TypeError
,
"descriptor '%s' requires a type but received a '%s'"
,
self
->
method
->
ml_name
,
getFullTypeName
(
o
arg1
).
c_str
());
getFullTypeName
(
arg1
).
c_str
());
}
else
{
if
(
!
isSubclass
(
oarg1
->
cls
,
self
->
type
))
raiseExcHelper
(
TypeError
,
"descriptor '%s' requires a '%s' oarg1 but received a '%s'"
,
self
->
method
->
ml_name
,
getFullNameOfClass
(
self
->
type
).
c_str
(),
getFullTypeName
(
oarg1
).
c_str
());
if
(
!
isSubclass
(
arg1
->
cls
,
self
->
type
))
raiseExcHelper
(
TypeError
,
"descriptor '%s' requires a '%s' arg1 but received a '%s'"
,
self
->
method
->
ml_name
,
getFullNameOfClass
(
self
->
type
).
c_str
(),
getFullTypeName
(
arg1
).
c_str
());
}
if
(
rewrite_args
)
{
rewrite_args
->
arg1
->
addAttrGuard
(
offsetof
(
Box
,
cls
),
(
intptr_t
)
o
arg1
->
cls
);
rewrite_args
->
arg1
->
addAttrGuard
(
offsetof
(
Box
,
cls
),
(
intptr_t
)
arg1
->
cls
);
}
Box
*
rtn
;
if
(
call_flags
==
METH_NOARGS
)
{
{
UNAVOIDABLE_STAT_TIMER
(
t0
,
"us_timer_in_builtins"
);
rtn
=
(
Box
*
)
self
->
method
->
ml_meth
(
o
arg1
,
NULL
);
rtn
=
(
Box
*
)
self
->
method
->
ml_meth
(
arg1
,
NULL
);
}
if
(
rewrite_args
)
rewrite_args
->
out_rtn
...
...
@@ -339,7 +335,7 @@ Box* BoxedMethodDescriptor::tppCall(Box* _self, CallRewriteArgs* rewrite_args, A
}
else
if
(
call_flags
==
METH_VARARGS
)
{
{
UNAVOIDABLE_STAT_TIMER
(
t0
,
"us_timer_in_builtins"
);
rtn
=
(
Box
*
)
self
->
method
->
ml_meth
(
oarg1
,
o
arg2
);
rtn
=
(
Box
*
)
self
->
method
->
ml_meth
(
arg1
,
arg2
);
}
if
(
rewrite_args
)
rewrite_args
->
out_rtn
=
rewrite_args
->
rewriter
->
call
(
true
,
(
void
*
)
self
->
method
->
ml_meth
,
rewrite_args
->
arg1
,
...
...
@@ -347,7 +343,7 @@ Box* BoxedMethodDescriptor::tppCall(Box* _self, CallRewriteArgs* rewrite_args, A
}
else
if
(
call_flags
==
(
METH_VARARGS
|
METH_KEYWORDS
))
{
{
UNAVOIDABLE_STAT_TIMER
(
t0
,
"us_timer_in_builtins"
);
rtn
=
(
Box
*
)((
PyCFunctionWithKeywords
)
self
->
method
->
ml_meth
)(
oarg1
,
oarg2
,
o
arg3
);
rtn
=
(
Box
*
)((
PyCFunctionWithKeywords
)
self
->
method
->
ml_meth
)(
arg1
,
arg2
,
arg3
);
}
if
(
rewrite_args
)
rewrite_args
->
out_rtn
=
rewrite_args
->
rewriter
->
call
(
true
,
(
void
*
)
self
->
method
->
ml_meth
,
rewrite_args
->
arg1
,
...
...
@@ -355,7 +351,7 @@ Box* BoxedMethodDescriptor::tppCall(Box* _self, CallRewriteArgs* rewrite_args, A
}
else
if
(
call_flags
==
METH_O
)
{
{
UNAVOIDABLE_STAT_TIMER
(
t0
,
"us_timer_in_builtins"
);
rtn
=
(
Box
*
)
self
->
method
->
ml_meth
(
oarg1
,
o
arg2
);
rtn
=
(
Box
*
)
self
->
method
->
ml_meth
(
arg1
,
arg2
);
}
if
(
rewrite_args
)
rewrite_args
->
out_rtn
=
rewrite_args
->
rewriter
->
call
(
true
,
(
void
*
)
self
->
method
->
ml_meth
,
rewrite_args
->
arg1
,
...
...
@@ -363,7 +359,7 @@ Box* BoxedMethodDescriptor::tppCall(Box* _self, CallRewriteArgs* rewrite_args, A
}
else
if
((
call_flags
&
~
(
METH_O3
|
METH_D3
))
==
0
)
{
{
UNAVOIDABLE_STAT_TIMER
(
t0
,
"us_timer_in_builtins"
);
rtn
=
((
Box
*
(
*
)(
Box
*
,
Box
*
,
Box
*
,
Box
**
))
self
->
method
->
ml_meth
)(
oarg1
,
oarg2
,
o
arg3
,
oargs
);
rtn
=
((
Box
*
(
*
)(
Box
*
,
Box
*
,
Box
*
,
Box
**
))
self
->
method
->
ml_meth
)(
arg1
,
arg2
,
arg3
,
oargs
);
}
if
(
rewrite_args
)
{
if
(
paramspec
.
totalReceived
()
==
2
)
...
...
@@ -536,20 +532,16 @@ Box* BoxedWrapperObject::tppCall(Box* _self, CallRewriteArgs* rewrite_args, ArgP
RELEASE_ASSERT
(
0
,
"%d"
,
flags
);
}
Box
*
oarg1
=
NULL
;
Box
*
oarg2
=
NULL
;
Box
*
oarg3
=
NULL
;
Box
**
oargs
=
NULL
;
bool
rewrite_success
=
false
;
rearrangeArguments
(
paramspec
,
NULL
,
self
->
descr
->
wrapper
->
name
.
data
(),
NULL
,
rewrite_args
,
rewrite_success
,
argspec
,
arg1
,
arg2
,
arg3
,
args
,
keyword_names
,
oarg1
,
oarg2
,
oarg3
,
oarg
s
);
arg1
,
arg2
,
arg3
,
args
,
oargs
,
keyword_name
s
);
assert
(
oarg1
&&
o
arg1
->
cls
==
tuple_cls
);
assert
(
arg1
&&
arg1
->
cls
==
tuple_cls
);
if
(
!
paramspec
.
takes_kwargs
)
assert
(
oarg2
==
NULL
);
assert
(
oarg3
==
NULL
);
assert
(
oargs
==
NULL
);
assert
(
arg2
==
NULL
);
assert
(
arg3
==
NULL
);
if
(
!
rewrite_success
)
rewrite_args
=
NULL
;
...
...
@@ -557,7 +549,7 @@ Box* BoxedWrapperObject::tppCall(Box* _self, CallRewriteArgs* rewrite_args, ArgP
Box
*
rtn
;
if
(
flags
==
PyWrapperFlag_KEYWORDS
)
{
wrapperfunc_kwds
wk
=
(
wrapperfunc_kwds
)
wrapper
;
rtn
=
(
*
wk
)(
self
->
obj
,
oarg1
,
self
->
descr
->
wrapped
,
o
arg2
);
rtn
=
(
*
wk
)(
self
->
obj
,
arg1
,
self
->
descr
->
wrapped
,
arg2
);
if
(
rewrite_args
)
{
auto
rewriter
=
rewrite_args
->
rewriter
;
...
...
@@ -569,7 +561,7 @@ Box* BoxedWrapperObject::tppCall(Box* _self, CallRewriteArgs* rewrite_args, ArgP
rewrite_args
->
out_success
=
true
;
}
}
else
if
(
flags
==
PyWrapperFlag_PYSTON
||
flags
==
0
)
{
rtn
=
(
*
wrapper
)(
self
->
obj
,
o
arg1
,
self
->
descr
->
wrapped
);
rtn
=
(
*
wrapper
)(
self
->
obj
,
arg1
,
self
->
descr
->
wrapped
);
if
(
rewrite_args
)
{
auto
rewriter
=
rewrite_args
->
rewriter
;
...
...
src/runtime/objmodel.cpp
View file @
61a68d3d
...
...
@@ -3052,8 +3052,8 @@ ArgPassSpec bindObjIntoArgs(Box* bind_obj, RewriterVar* r_bind_obj, CallRewriteA
void
rearrangeArguments
(
ParamReceiveSpec
paramspec
,
const
ParamNames
*
param_names
,
const
char
*
func_name
,
Box
**
defaults
,
CallRewriteArgs
*
rewrite_args
,
bool
&
rewrite_success
,
ArgPassSpec
argspec
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
,
const
std
::
vector
<
BoxedString
*>*
keyword_name
s
,
Box
*&
oarg1
,
Box
*&
oarg2
,
Box
*&
oarg3
,
Box
**
oarg
s
)
{
Box
*
&
oarg1
,
Box
*&
oarg2
,
Box
*&
oarg3
,
Box
**
args
,
Box
**
oarg
s
,
const
std
::
vector
<
BoxedString
*>*
keyword_name
s
)
{
/*
* Procedure:
* - First match up positional arguments; any extra go to varargs. error if too many.
...
...
@@ -3066,11 +3066,11 @@ void rearrangeArguments(ParamReceiveSpec paramspec, const ParamNames* param_name
int
num_passed_args
=
argspec
.
totalPassed
();
if
(
num_passed_args
>=
1
)
assert
(
gc
::
isValidGCObject
(
arg1
)
||
!
arg1
);
assert
(
gc
::
isValidGCObject
(
oarg1
)
||
!
o
arg1
);
if
(
num_passed_args
>=
2
)
assert
(
gc
::
isValidGCObject
(
arg2
)
||
!
arg2
);
assert
(
gc
::
isValidGCObject
(
oarg2
)
||
!
o
arg2
);
if
(
num_passed_args
>=
3
)
assert
(
gc
::
isValidGCObject
(
arg3
)
||
!
arg3
);
assert
(
gc
::
isValidGCObject
(
oarg3
)
||
!
o
arg3
);
for
(
int
i
=
3
;
i
<
num_passed_args
;
i
++
)
{
assert
(
gc
::
isValidGCObject
(
args
[
i
-
3
])
||
args
[
i
-
3
]
==
NULL
);
}
...
...
@@ -3085,9 +3085,6 @@ void rearrangeArguments(ParamReceiveSpec paramspec, const ParamNames* param_name
if
(
argspec
.
num_keywords
==
0
&&
!
argspec
.
has_starargs
&&
!
paramspec
.
takes_varargs
&&
!
argspec
.
has_kwargs
&&
argspec
.
num_args
==
paramspec
.
num_args
&&
!
paramspec
.
takes_kwargs
)
{
rewrite_success
=
true
;
oarg1
=
arg1
;
oarg2
=
arg2
;
oarg3
=
arg3
;
if
(
num_output_args
>
3
)
memcpy
(
oargs
,
args
,
sizeof
(
Box
*
)
*
(
num_output_args
-
3
));
return
;
...
...
@@ -3103,7 +3100,7 @@ void rearrangeArguments(ParamReceiveSpec paramspec, const ParamNames* param_name
assert
(
num_output_args
==
num_passed_args
+
1
);
int
idx
=
paramspec
.
kwargsIndex
();
assert
(
idx
<
3
);
getArg
(
idx
,
arg1
,
arg2
,
arg3
,
NULL
)
=
NULL
;
// pass NULL for kwargs
getArg
(
idx
,
oarg1
,
oarg2
,
o
arg3
,
NULL
)
=
NULL
;
// pass NULL for kwargs
if
(
rewrite_args
)
{
if
(
idx
==
0
)
rewrite_args
->
arg1
=
rewrite_args
->
rewriter
->
loadConst
(
0
);
...
...
@@ -3123,31 +3120,31 @@ void rearrangeArguments(ParamReceiveSpec paramspec, const ParamNames* param_name
// received by the caller are always tuples).
// This is why we can't pass kwargs here.
if
(
argspec
.
has_starargs
)
{
Box
*
given_varargs
=
getArg
(
argspec
.
num_args
+
argspec
.
num_keywords
,
arg1
,
arg2
,
arg3
,
args
);
Box
*
given_varargs
=
getArg
(
argspec
.
num_args
+
argspec
.
num_keywords
,
oarg1
,
oarg2
,
o
arg3
,
args
);
if
(
given_varargs
->
cls
==
tuple_cls
)
{
if
(
rewrite_args
)
{
getArg
(
argspec
.
num_args
+
argspec
.
num_keywords
,
rewrite_args
)
->
addAttrGuard
(
offsetof
(
Box
,
cls
),
(
intptr_t
)
tuple_cls
);
}
rewrite_success
=
true
;
oarg1
=
arg1
;
oarg2
=
arg2
;
oarg3
=
arg3
;
if
(
num_output_args
>
3
)
memcpy
(
oargs
,
args
,
sizeof
(
Box
*
)
*
(
num_output_args
-
3
));
return
;
}
}
else
{
rewrite_success
=
true
;
oarg1
=
arg1
;
oarg2
=
arg2
;
oarg3
=
arg3
;
if
(
num_output_args
>
3
)
memcpy
(
oargs
,
args
,
sizeof
(
Box
*
)
*
(
num_output_args
-
3
));
return
;
}
}
// Save the original values:
Box
*
arg1
=
oarg1
;
Box
*
arg2
=
oarg2
;
Box
*
arg3
=
oarg3
;
oarg1
=
oarg2
=
oarg3
=
NULL
;
static
StatCounter
slowpath_rearrangeargs_slowpath
(
"slowpath_rearrangeargs_slowpath"
);
slowpath_rearrangeargs_slowpath
.
log
();
...
...
@@ -3422,7 +3419,7 @@ Box* callFunc(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args, ArgPassSpe
}
}
Box
*
oarg1
,
*
oarg2
,
*
oarg3
,
**
oargs
;
Box
*
*
oargs
;
bool
rewrite_success
=
false
;
int
num_output_args
=
paramspec
.
totalReceived
();
...
...
@@ -3443,7 +3440,7 @@ Box* callFunc(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args, ArgPassSpe
try
{
rearrangeArguments
(
paramspec
,
&
f
->
param_names
,
getFunctionName
(
f
).
data
(),
paramspec
.
num_defaults
?
func
->
defaults
->
elts
:
NULL
,
rewrite_args
,
rewrite_success
,
argspec
,
arg1
,
arg2
,
arg3
,
args
,
keyword_names
,
oarg1
,
oarg2
,
oarg3
,
oarg
s
);
arg1
,
arg2
,
arg3
,
args
,
oargs
,
keyword_name
s
);
}
catch
(
ExcInfo
e
)
{
if
(
S
==
CAPI
)
{
setCAPIException
(
e
);
...
...
@@ -3454,7 +3451,7 @@ Box* callFunc(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args, ArgPassSpe
#if 0
for (int i = 0; i < num_output_args; i++) {
auto arg = getArg(i,
oarg1, oarg2, o
arg3, oargs);
auto arg = getArg(i,
arg1, arg2,
arg3, oargs);
RELEASE_ASSERT(!arg || gc::isValidGCObject(arg), "%p", arg);
}
#endif
...
...
@@ -3530,9 +3527,9 @@ Box* callFunc(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args, ArgPassSpe
if
(
f
->
isGenerator
())
{
// TODO: we might not have a lot to gain by rewriting into createGenerator, but we could at least
// rewrite up to the call to it:
res
=
createGenerator
(
func
,
oarg1
,
oarg2
,
o
arg3
,
oargs
);
res
=
createGenerator
(
func
,
arg1
,
arg2
,
arg3
,
oargs
);
}
else
{
res
=
callCLFunc
<
S
>
(
f
,
rewrite_args
,
num_output_args
,
closure
,
NULL
,
func
->
globals
,
oarg1
,
oarg2
,
o
arg3
,
oargs
);
res
=
callCLFunc
<
S
>
(
f
,
rewrite_args
,
num_output_args
,
closure
,
NULL
,
func
->
globals
,
arg1
,
arg2
,
arg3
,
oargs
);
}
return
res
;
...
...
src/runtime/rewrite_args.h
View file @
61a68d3d
...
...
@@ -149,8 +149,8 @@ struct CompareRewriteArgs {
// match anyway. Or maybe it should call a callback function, which could save on the common case.
void
rearrangeArguments
(
ParamReceiveSpec
paramspec
,
const
ParamNames
*
param_names
,
const
char
*
func_name
,
Box
**
defaults
,
CallRewriteArgs
*
rewrite_args
,
bool
&
rewrite_success
,
ArgPassSpec
argspec
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
,
const
std
::
vector
<
BoxedString
*>*
keyword_name
s
,
Box
*&
oarg1
,
Box
*&
oarg2
,
Box
*&
oarg3
,
Box
**
oarg
s
);
Box
*
&
arg1
,
Box
*&
arg2
,
Box
*&
arg3
,
Box
**
args
,
Box
**
oarg
s
,
const
std
::
vector
<
BoxedString
*>*
keyword_name
s
);
// new_args should be allocated by the caller if at least three args get passed in.
// rewrite_args will get modified in place.
...
...
src/runtime/types.cpp
View file @
61a68d3d
...
...
@@ -758,14 +758,13 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
// Special-case unicode for now, maybe there's something about this that can eventually be generalized:
ParamReceiveSpec
paramspec
(
4
,
3
,
false
,
false
);
bool
rewrite_success
=
false
;
Box
*
oarg1
,
*
oarg2
,
*
oarg3
;
static
ParamNames
param_names
({
"string"
,
"encoding"
,
"errors"
},
""
,
""
);
static
Box
*
defaults
[
3
]
=
{
NULL
,
NULL
,
NULL
};
Box
*
oargs
[
1
];
rearrangeArguments
(
paramspec
,
&
param_names
,
"unicode"
,
defaults
,
rewrite_args
,
rewrite_success
,
argspec
,
arg1
,
arg2
,
arg3
,
args
,
keyword_names
,
oarg1
,
oarg2
,
oarg3
,
oarg
s
);
assert
(
o
arg1
==
cls
);
arg2
,
arg3
,
args
,
oargs
,
keyword_name
s
);
assert
(
arg1
==
cls
);
if
(
!
rewrite_success
)
rewrite_args
=
NULL
;
...
...
@@ -778,7 +777,7 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
}
// TODO other encodings could return non-unicode?
return
unicodeNewHelper
(
cls
,
oarg2
,
o
arg3
,
oargs
);
return
unicodeNewHelper
(
cls
,
arg2
,
arg3
,
oargs
);
}
if
(
cls
->
tp_new
!=
object_cls
->
tp_new
&&
cls
->
tp_new
!=
slot_tp_new
&&
S
==
CXX
)
{
...
...
@@ -790,10 +789,10 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
ParamReceiveSpec
paramspec
(
1
,
false
,
true
,
true
);
bool
rewrite_success
=
false
;
Box
*
oarg1
,
*
oarg2
,
*
oarg3
,
*
*
oargs
=
NULL
;
Box
**
oargs
=
NULL
;
rearrangeArguments
(
paramspec
,
NULL
,
""
,
NULL
,
rewrite_args
,
rewrite_success
,
argspec
,
arg1
,
arg2
,
arg3
,
args
,
keyword_names
,
oarg1
,
oarg2
,
oarg3
,
oarg
s
);
assert
(
o
arg1
==
cls
);
oargs
,
keyword_name
s
);
assert
(
arg1
==
cls
);
if
(
!
rewrite_success
)
rewrite_args
=
NULL
;
...
...
@@ -804,7 +803,7 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
rewrite_args
->
out_success
=
true
;
}
return
cpythonTypeCall
(
cls
,
oarg2
,
o
arg3
);
return
cpythonTypeCall
(
cls
,
arg2
,
arg3
);
}
if
(
argspec
.
has_starargs
||
argspec
.
has_kwargs
)
...
...
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