Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Issue 9301038: Support named arguments for statically resolved calls. (Closed)

Created:
8 years, 10 months ago by ngeoffray
Modified:
8 years, 10 months ago
CC:
reviews_dartlang.org, ahe, karlklose, Lasse Reichstein Nielsen
Visibility:
Public.

Description

Support named arguments for statically resolved calls. Committed: https://code.google.com/p/dart/source/detail?r=3735

Patch Set 1 : '' #

Total comments: 8

Patch Set 2 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+246 lines, -69 lines) Patch
M frog/leg/elements/elements.dart View 4 chunks +14 lines, -8 lines 0 comments Download
M frog/leg/emitter.dart View 2 chunks +2 lines, -2 lines 0 comments Download
M frog/leg/lib/core.dart View 1 chunk +5 lines, -12 lines 0 comments Download
M frog/leg/namer.dart View 1 chunk +1 line, -4 lines 0 comments Download
M frog/leg/resolver.dart View 4 chunks +19 lines, -16 lines 0 comments Download
M frog/leg/ssa/builder.dart View 12 chunks +91 lines, -17 lines 0 comments Download
M frog/leg/ssa/codegen.dart View 1 chunk +1 line, -0 lines 0 comments Download
M frog/leg/universe.dart View 1 3 chunks +25 lines, -7 lines 0 comments Download
A frog/tests/leg_only/src/NamedParameterForStaticTest.dart View 1 chunk +88 lines, -0 lines 0 comments Download
M tests/language/language-leg.status View 2 chunks +0 lines, -3 lines 0 comments Download

Messages

Total messages: 4 (0 generated)
ngeoffray
Because builder/emitter/name treat very differently statically resolved invocations compared to dynamic invocations, it felt easier ...
8 years, 10 months ago (2012-01-31 14:11:07 UTC) #1
Lasse Reichstein Nielsen
Drive-by comments. https://chromiumcodereview.appspot.com/9301038/diff/4002/frog/leg/universe.dart File frog/leg/universe.dart (right): https://chromiumcodereview.appspot.com/9301038/diff/4002/frog/leg/universe.dart#newcode114 frog/leg/universe.dart:114: } Remove the name from the set, ...
8 years, 10 months ago (2012-01-31 15:36:05 UTC) #2
floitsch
LGTM. (after Lasse's fix). https://chromiumcodereview.appspot.com/9301038/diff/4002/frog/leg/ssa/builder.dart File frog/leg/ssa/builder.dart (right): https://chromiumcodereview.appspot.com/9301038/diff/4002/frog/leg/ssa/builder.dart#newcode954 frog/leg/ssa/builder.dart:954: // TODO(ngeoffray): Add the default ...
8 years, 10 months ago (2012-01-31 15:52:41 UTC) #3
ngeoffray
8 years, 10 months ago (2012-01-31 16:46:16 UTC) #4
Thanks for the comments!

https://chromiumcodereview.appspot.com/9301038/diff/4002/frog/leg/ssa/builder...
File frog/leg/ssa/builder.dart (right):

https://chromiumcodereview.appspot.com/9301038/diff/4002/frog/leg/ssa/builder...
frog/leg/ssa/builder.dart:954: // TODO(ngeoffray): Add the default value.
On 2012/01/31 15:52:41, floitsch wrote:
> If it is not too difficult I would prefer checking if there actually is a
> default value. Bailing out is still fine, though.
> If it is difficult, don't worry.

We don't support default values for parameters yet. We cancel early in the
pipeline.

https://chromiumcodereview.appspot.com/9301038/diff/4002/frog/leg/universe.dart
File frog/leg/universe.dart (right):

https://chromiumcodereview.appspot.com/9301038/diff/4002/frog/leg/universe.da...
frog/leg/universe.dart:96: argumentCount <= requiredParameterCount +
optionalParameterCount;
On 2012/01/31 15:52:41, floitsch wrote:
> indent by 4?

Done.

https://chromiumcodereview.appspot.com/9301038/diff/4002/frog/leg/universe.da...
frog/leg/universe.dart:114: }
On 2012/01/31 15:36:05, Lasse Reichstein Nielsen wrote:
> Remove the name from the set, so you don't allow duplicate named arguments.

Done. I expect another phase to check that though.

https://chromiumcodereview.appspot.com/9301038/diff/4002/frog/tests/leg_only/...
File frog/tests/leg_only/src/NamedParameterForStaticTest.dart (right):

https://chromiumcodereview.appspot.com/9301038/diff/4002/frog/tests/leg_only/...
frog/tests/leg_only/src/NamedParameterForStaticTest.dart:22:
oneOptionalArgument(1, b: 2);
On 2012/01/31 15:36:05, Lasse Reichstein Nielsen wrote:
> How about adding a negative test (or more) that tests invalid parameters. The
> usual:
>   twoOptionalArguments(1, a:2);
>   twoOptionalArguments(1, 2, a: 1);
>   twoOptionalArguments(a:1, a:1, b:2);
>   etc.
> (Maybe if you can catch a NoSuchMethodException, you can do it in this file
> too).

(We don't have try/catch :))

I have put a cancel in the Ssa builder if the call site does not match the
signature of the statically resolved method. We still need to decide what should
we do in this situation. Not generate code at all, or emit a throw in place of
the call.

Note that NoSuchMethodException only is for instance methods, not
static/top-level methods.

Powered by Google App Engine
This is Rietveld 408576698