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
4f95e1cc
Commit
4f95e1cc
authored
Jun 24, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor out bindObjIntoArgs
parent
c4ebf05f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
31 deletions
+38
-31
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+28
-0
src/runtime/rewrite_args.h
src/runtime/rewrite_args.h
+4
-0
src/runtime/types.cpp
src/runtime/types.cpp
+6
-31
No files found.
src/runtime/objmodel.cpp
View file @
4f95e1cc
...
@@ -3012,6 +3012,34 @@ static Box* _callFuncHelper(BoxedFunctionBase* func, ArgPassSpec argspec, Box* a
...
@@ -3012,6 +3012,34 @@ static Box* _callFuncHelper(BoxedFunctionBase* func, ArgPassSpec argspec, Box* a
typedef
std
::
function
<
Box
*
(
int
,
int
,
RewriterVar
*&
)
>
GetDefaultFunc
;
typedef
std
::
function
<
Box
*
(
int
,
int
,
RewriterVar
*&
)
>
GetDefaultFunc
;
ArgPassSpec
bindObjIntoArgs
(
Box
*
obj
,
CallRewriteArgs
*
rewrite_args
,
ArgPassSpec
argspec
,
Box
*&
arg1
,
Box
*&
arg2
,
Box
*&
arg3
,
Box
**
args
,
Box
**
new_args
)
{
int
npassed_args
=
argspec
.
totalPassed
();
assert
((
new_args
!=
NULL
)
==
(
npassed_args
>=
3
));
if
(
npassed_args
>=
3
)
{
new_args
[
0
]
=
arg3
;
memcpy
(
new_args
+
1
,
args
,
(
npassed_args
-
3
)
*
sizeof
(
Box
*
));
}
arg3
=
arg2
;
arg2
=
arg1
;
arg1
=
obj
;
if
(
rewrite_args
)
{
if
(
npassed_args
>=
3
)
{
rewrite_args
->
args
=
rewrite_args
->
rewriter
->
allocateAndCopyPlus1
(
rewrite_args
->
arg3
,
npassed_args
==
3
?
NULL
:
rewrite_args
->
args
,
npassed_args
-
3
);
}
rewrite_args
->
arg3
=
rewrite_args
->
arg2
;
rewrite_args
->
arg2
=
rewrite_args
->
arg1
;
rewrite_args
->
arg1
=
rewrite_args
->
obj
;
}
return
ArgPassSpec
(
argspec
.
num_args
+
1
,
argspec
.
num_keywords
,
argspec
.
has_starargs
,
argspec
.
has_kwargs
);
}
void
rearrangeArguments
(
ParamReceiveSpec
paramspec
,
const
ParamNames
*
param_names
,
const
char
*
func_name
,
void
rearrangeArguments
(
ParamReceiveSpec
paramspec
,
const
ParamNames
*
param_names
,
const
char
*
func_name
,
Box
**
defaults
,
CallRewriteArgs
*
rewrite_args
,
bool
&
rewrite_success
,
ArgPassSpec
argspec
,
Box
**
defaults
,
CallRewriteArgs
*
rewrite_args
,
bool
&
rewrite_success
,
ArgPassSpec
argspec
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
,
const
std
::
vector
<
BoxedString
*>*
keyword_names
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
,
const
std
::
vector
<
BoxedString
*>*
keyword_names
,
...
...
src/runtime/rewrite_args.h
View file @
4f95e1cc
...
@@ -130,6 +130,10 @@ void rearrangeArguments(ParamReceiveSpec paramspec, const ParamNames* param_name
...
@@ -130,6 +130,10 @@ void rearrangeArguments(ParamReceiveSpec paramspec, const ParamNames* param_name
Box
**
defaults
,
CallRewriteArgs
*
rewrite_args
,
bool
&
rewrite_success
,
ArgPassSpec
argspec
,
Box
**
defaults
,
CallRewriteArgs
*
rewrite_args
,
bool
&
rewrite_success
,
ArgPassSpec
argspec
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
,
const
std
::
vector
<
BoxedString
*>*
keyword_names
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
,
const
std
::
vector
<
BoxedString
*>*
keyword_names
,
Box
*&
oarg1
,
Box
*&
oarg2
,
Box
*&
oarg3
,
Box
**
oargs
);
Box
*&
oarg1
,
Box
*&
oarg2
,
Box
*&
oarg3
,
Box
**
oargs
);
// new_args should be allocated by the caller if at least three args get passed in
ArgPassSpec
bindObjIntoArgs
(
Box
*
obj
,
CallRewriteArgs
*
rewrite_args
,
ArgPassSpec
argspec
,
Box
*&
arg1
,
Box
*&
arg2
,
Box
*&
arg3
,
Box
**
args
,
Box
**
new_args
);
}
// namespace pyston
}
// namespace pyston
#endif
#endif
src/runtime/types.cpp
View file @
4f95e1cc
...
@@ -537,43 +537,18 @@ static Box* typeTppCall(Box* self, CallRewriteArgs* rewrite_args, ArgPassSpec ar
...
@@ -537,43 +537,18 @@ static Box* typeTppCall(Box* self, CallRewriteArgs* rewrite_args, ArgPassSpec ar
Box
**
args
,
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
{
Box
**
args
,
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
{
int
npassed_args
=
argspec
.
totalPassed
();
int
npassed_args
=
argspec
.
totalPassed
();
Box
**
new_args
;
if
(
npassed_args
>=
3
)
{
new_args
=
(
Box
**
)
alloca
(
sizeof
(
Box
*
)
*
(
npassed_args
+
1
-
3
));
new_args
[
0
]
=
arg3
;
memcpy
(
new_args
+
1
,
args
,
(
npassed_args
-
3
)
*
sizeof
(
Box
*
));
}
if
(
argspec
.
has_starargs
)
{
if
(
argspec
.
has_starargs
)
{
// This would fail in typeCallInner
// This would fail in typeCallInner
rewrite_args
=
NULL
;
rewrite_args
=
NULL
;
}
}
if
(
rewrite_args
)
{
Box
**
new_args
=
NULL
;
CallRewriteArgs
srewrite_args
(
rewrite_args
->
rewriter
,
NULL
,
rewrite_args
->
destination
);
if
(
npassed_args
>=
3
)
{
srewrite_args
.
arg1
=
rewrite_args
->
obj
;
new_args
=
(
Box
**
)
alloca
(
sizeof
(
Box
*
)
*
(
npassed_args
+
1
-
3
));
srewrite_args
.
arg2
=
rewrite_args
->
arg1
;
srewrite_args
.
arg3
=
rewrite_args
->
arg2
;
if
(
npassed_args
>=
3
)
{
srewrite_args
.
args
=
rewrite_args
->
rewriter
->
allocateAndCopyPlus1
(
rewrite_args
->
arg3
,
npassed_args
==
3
?
NULL
:
rewrite_args
->
args
,
npassed_args
-
3
);
}
srewrite_args
.
args_guarded
=
rewrite_args
->
args_guarded
;
srewrite_args
.
func_guarded
=
rewrite_args
->
func_guarded
;
Box
*
rtn
=
typeCallInner
(
&
srewrite_args
,
ArgPassSpec
(
argspec
.
num_args
+
1
,
argspec
.
num_keywords
,
argspec
.
has_starargs
,
argspec
.
has_kwargs
),
self
,
arg1
,
arg2
,
new_args
,
keyword_names
);
rewrite_args
->
out_rtn
=
srewrite_args
.
out_rtn
;
rewrite_args
->
out_success
=
srewrite_args
.
out_success
;
return
rtn
;
}
else
{
return
typeCallInner
(
NULL
,
ArgPassSpec
(
argspec
.
num_args
+
1
,
argspec
.
num_keywords
,
argspec
.
has_starargs
,
argspec
.
has_kwargs
),
self
,
arg1
,
arg2
,
new_args
,
keyword_names
);
}
}
ArgPassSpec
new_argspec
=
bindObjIntoArgs
(
self
,
rewrite_args
,
argspec
,
arg1
,
arg2
,
arg3
,
args
,
new_args
);
return
typeCallInner
(
rewrite_args
,
new_argspec
,
arg1
,
arg2
,
arg3
,
new_args
,
keyword_names
);
}
}
static
Box
*
typeCallInternal
(
BoxedFunctionBase
*
f
,
CallRewriteArgs
*
rewrite_args
,
ArgPassSpec
argspec
,
Box
*
arg1
,
static
Box
*
typeCallInternal
(
BoxedFunctionBase
*
f
,
CallRewriteArgs
*
rewrite_args
,
ArgPassSpec
argspec
,
Box
*
arg1
,
...
...
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