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
0fdabf35
Commit
0fdabf35
authored
Aug 26, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support passing up to 6 elements in varargs
parent
443a4720
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
15 deletions
+26
-15
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+14
-15
src/runtime/types.h
src/runtime/types.h
+12
-0
No files found.
src/runtime/objmodel.cpp
View file @
0fdabf35
...
@@ -2878,7 +2878,7 @@ Box* callattrInternal(Box* obj, BoxedString* attr, LookupScope scope, CallRewrit
...
@@ -2878,7 +2878,7 @@ Box* callattrInternal(Box* obj, BoxedString* attr, LookupScope scope, CallRewrit
rewrite_args
->
out_rtn
=
rewrite_args
->
rewriter
->
call
(
true
,
(
void
*
)
Helper
::
call
,
arg_vec
);
rewrite_args
->
out_rtn
=
rewrite_args
->
rewriter
->
call
(
true
,
(
void
*
)
Helper
::
call
,
arg_vec
);
rewrite_args
->
out_success
=
true
;
rewrite_args
->
out_success
=
true
;
void
*
_args
[
2
]
=
{
args
,
const_cast
<
std
::
vector
<
BoxedString
*>*>
(
keyword_names
)
};
void
*
_args
[
2
]
=
{
args
,
const_cast
<
std
::
vector
<
BoxedString
*>*>
(
keyword_names
)
};
return
Helper
::
call
(
val
,
argspec
,
arg1
,
arg2
,
arg3
,
_args
);
return
Helper
::
call
(
val
,
argspec
,
arg1
,
arg2
,
arg3
,
_args
);
}
}
...
@@ -3243,8 +3243,8 @@ void rearrangeArguments(ParamReceiveSpec paramspec, const ParamNames* param_name
...
@@ -3243,8 +3243,8 @@ void rearrangeArguments(ParamReceiveSpec paramspec, const ParamNames* param_name
rewrite_args
=
NULL
;
rewrite_args
=
NULL
;
}
}
if
(
paramspec
.
takes_varargs
&&
argspec
.
num_args
>
paramspec
.
num_args
+
3
)
{
if
(
paramspec
.
takes_varargs
&&
argspec
.
num_args
>
paramspec
.
num_args
+
6
)
{
// We currently only handle up to
3
arguments into the varargs tuple
// We currently only handle up to
6
arguments into the varargs tuple
rewrite_args
=
NULL
;
rewrite_args
=
NULL
;
}
}
...
@@ -3338,19 +3338,18 @@ void rearrangeArguments(ParamReceiveSpec paramspec, const ParamNames* param_name
...
@@ -3338,19 +3338,18 @@ void rearrangeArguments(ParamReceiveSpec paramspec, const ParamNames* param_name
if
(
varargs_size
==
0
)
{
if
(
varargs_size
==
0
)
{
varargs_val
=
rewrite_args
->
rewriter
->
loadConst
(
varargs_val
=
rewrite_args
->
rewriter
->
loadConst
(
(
intptr_t
)
EmptyTuple
,
varargs_idx
<
3
?
Location
::
forArg
(
varargs_idx
)
:
Location
::
any
());
(
intptr_t
)
EmptyTuple
,
varargs_idx
<
3
?
Location
::
forArg
(
varargs_idx
)
:
Location
::
any
());
}
else
if
(
varargs_size
==
1
)
{
varargs_val
=
rewrite_args
->
rewriter
->
call
(
false
,
(
void
*
)
BoxedTuple
::
create1
,
unused_positional_rvars
[
0
]);
}
else
if
(
varargs_size
==
2
)
{
varargs_val
=
rewrite_args
->
rewriter
->
call
(
false
,
(
void
*
)
BoxedTuple
::
create2
,
unused_positional_rvars
[
0
],
unused_positional_rvars
[
1
]);
}
else
if
(
varargs_size
==
3
)
{
varargs_val
=
rewrite_args
->
rewriter
->
call
(
false
,
(
void
*
)
BoxedTuple
::
create3
,
unused_positional_rvars
[
0
],
unused_positional_rvars
[
1
],
unused_positional_rvars
[
2
]);
}
else
{
}
else
{
// This is too late to abort the rewrite (we should have checked this earlier)
assert
(
varargs_size
<=
6
);
abort
();
void
*
create_ptrs
[]
=
{
NULL
,
//
(
void
*
)
BoxedTuple
::
create1
,
//
(
void
*
)
BoxedTuple
::
create2
,
//
(
void
*
)
BoxedTuple
::
create3
,
//
(
void
*
)
BoxedTuple
::
create4
,
//
(
void
*
)
BoxedTuple
::
create5
,
//
(
void
*
)
BoxedTuple
::
create6
,
//
};
varargs_val
=
rewrite_args
->
rewriter
->
call
(
false
,
create_ptrs
[
varargs_size
],
unused_positional_rvars
);
}
}
if
(
varargs_val
)
{
if
(
varargs_val
)
{
...
...
src/runtime/types.h
View file @
0fdabf35
...
@@ -557,6 +557,18 @@ public:
...
@@ -557,6 +557,18 @@ public:
assert
(
gc
::
isValidGCObject
(
rtn
->
elts
[
i
]));
assert
(
gc
::
isValidGCObject
(
rtn
->
elts
[
i
]));
return
rtn
;
return
rtn
;
}
}
static
BoxedTuple
*
create6
(
Box
*
elt0
,
Box
*
elt1
,
Box
*
elt2
,
Box
*
elt3
,
Box
*
elt4
,
Box
*
elt5
)
{
BoxedTuple
*
rtn
=
new
(
6
)
BoxedTuple
();
rtn
->
elts
[
0
]
=
elt0
;
rtn
->
elts
[
1
]
=
elt1
;
rtn
->
elts
[
2
]
=
elt2
;
rtn
->
elts
[
3
]
=
elt3
;
rtn
->
elts
[
4
]
=
elt4
;
rtn
->
elts
[
5
]
=
elt5
;
for
(
int
i
=
0
;
i
<
rtn
->
size
();
i
++
)
assert
(
gc
::
isValidGCObject
(
rtn
->
elts
[
i
]));
return
rtn
;
}
static
BoxedTuple
*
create
(
std
::
initializer_list
<
Box
*>
members
)
{
static
BoxedTuple
*
create
(
std
::
initializer_list
<
Box
*>
members
)
{
auto
rtn
=
new
(
members
.
size
())
BoxedTuple
(
members
);
auto
rtn
=
new
(
members
.
size
())
BoxedTuple
(
members
);
...
...
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