Open
Conversation
8c78983 to
cdcbb9f
Compare
| if (cur->type() == tok_colon) { | ||
| puts("!!!!!!!"); | ||
| next_cur(); | ||
| VertexPtr value = get_expression(); |
There was a problem hiding this comment.
You should probably add kphp_error (...) here.
VertexPtr value = get_expression();
kphp_error (value, "...");
compiler/gentree.cpp
Outdated
| // name.debugPrint(); | ||
| // assert(name->type() == op_func_name); | ||
| if (cur->type() == tok_colon) { | ||
| puts("!!!!!!!"); |
| }; | ||
|
|
||
| // at first, convert f(1, ...[2, ...[3]], ...$all, ...[5]) to f(1,2,3,...$all,5) | ||
| std::vector<VertexPtr> flatten_call_args(VertexRange args, VertexRange func_params) { |
There was a problem hiding this comment.
It seems that here you can pass arguments by reference and make them const.
std::vector<VertexPtr> flatten_call_args(const VertexRange& args, const VertexRange& func_params) {
Contributor
Author
There was a problem hiding this comment.
VertexRange is just a pair of two pointers, so I think it's better to pass-by-value than pass-by-reference
| @@ -104,21 +119,29 @@ VertexAdaptor<op_func_call> CheckFuncCallsAndVarargPass::process_varargs(VertexA | |||
| variadic_args_passed.emplace_back(VertexUtil::create_conv_to(tp_array, unpack_as_varg->array())); | |||
| needs_wrap_array_merge = true; | |||
| } | |||
There was a problem hiding this comment.
Can be simplified.
if (...) {
is_just_single_arg_forwarded = true;
} else {
needs_wrap_array_merge = true;
}
variadic_args_passed.emplace_back(VertexUtil::create_conv_to(tp_array, unpack_as_varg->array()));| int vararg_idx = call_arg_idx; | ||
| while (call_arg_idx < call_args.size()) { | ||
| call_arg_to_func_param[call_arg_idx] = f_called_params[vararg_idx].as<op_func_param>(); | ||
| call_arg_idx++; |
There was a problem hiding this comment.
Maybe it's better to use prefix addition here? Why do we need an extra copy?
++call_arg_idx;Below also.
Contributor
Author
There was a problem hiding this comment.
I do mapping call arg --> func arg to call patch_call_arg_on_func_call on corresponding expressions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implementation of https://wiki.php.net/rfc/named_params