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

Issue 10873033: Support non-const instance field initializers. (Closed)

Created:
8 years, 4 months ago by ngeoffray
Modified:
8 years, 4 months ago
Reviewers:
karlklose, kasperl
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Support non-const instance field initializers. Committed: https://code.google.com/p/dart/source/detail?r=11305

Patch Set 1 : #

Patch Set 2 : #

Total comments: 6

Patch Set 3 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+127 lines, -13 lines) Patch
M lib/compiler/implementation/elements/elements.dart View 1 2 1 chunk +6 lines, -1 line 0 comments Download
M lib/compiler/implementation/resolver.dart View 1 2 1 chunk +4 lines, -1 line 0 comments Download
M lib/compiler/implementation/ssa/builder.dart View 1 5 chunks +40 lines, -11 lines 0 comments Download
M tests/co19/co19-dart2js.status View 1 1 chunk +7 lines, -0 lines 0 comments Download
A tests/language/field_initialization_order_test.dart View 1 2 1 chunk +70 lines, -0 lines 0 comments Download

Messages

Total messages: 6 (0 generated)
ngeoffray
8 years, 4 months ago (2012-08-23 16:59:37 UTC) #1
kasperl
Please add some tests for this new feature. At least we need to test (1) ...
8 years, 4 months ago (2012-08-24 05:57:05 UTC) #2
ngeoffray
Turns out the initial patch did not handle well initialization order and was dropping some ...
8 years, 4 months ago (2012-08-24 11:26:02 UTC) #3
karlklose
https://chromiumcodereview.appspot.com/10873033/diff/6001/lib/compiler/implementation/resolver.dart File lib/compiler/implementation/resolver.dart (right): https://chromiumcodereview.appspot.com/10873033/diff/6001/lib/compiler/implementation/resolver.dart#newcode933 lib/compiler/implementation/resolver.dart:933: inInstanceContext = (element.isInstanceMember() && !element.isField()) Please add a comment ...
8 years, 4 months ago (2012-08-24 11:46:22 UTC) #4
kasperl
LGTM, but I think you might be able to improve the readability of the tests. ...
8 years, 4 months ago (2012-08-24 11:50:22 UTC) #5
ngeoffray
8 years, 4 months ago (2012-08-24 13:01:41 UTC) #6
Thank you Kasper and Karl.

https://chromiumcodereview.appspot.com/10873033/diff/6001/lib/compiler/implem...
File lib/compiler/implementation/elements/elements.dart (right):

https://chromiumcodereview.appspot.com/10873033/diff/6001/lib/compiler/implem...
lib/compiler/implementation/elements/elements.dart:1306: for (Element element in
classElement.localMembers.reverse()) {
On 2012/08/24 11:50:23, kasperl wrote:
> Add a comment that explain why the order is important.

Done.

https://chromiumcodereview.appspot.com/10873033/diff/6001/lib/compiler/implem...
File lib/compiler/implementation/resolver.dart (right):

https://chromiumcodereview.appspot.com/10873033/diff/6001/lib/compiler/implem...
lib/compiler/implementation/resolver.dart:933: inInstanceContext =
(element.isInstanceMember() && !element.isField())
On 2012/08/24 11:46:22, karlklose wrote:
> Please add a comment explaining why 'fields are not resolved in an instance
> context'.

Done.

https://chromiumcodereview.appspot.com/10873033/diff/6001/tests/language/fiel...
File tests/language/field_initialization_order_test.dart (right):

https://chromiumcodereview.appspot.com/10873033/diff/6001/tests/language/fiel...
tests/language/field_initialization_order_test.dart:6: int counter = 0;
On 2012/08/24 11:50:23, kasperl wrote:
> Counting is fun, but when you're dealing with order it might be better to use
a
> stringbuffer and add different markers. Maybe something like:
> 
> class Mark {
>   static StringBuffer buffer;
>   Mark(String op) {
>     buffer.add("${op}.");
>   }
> }
> 
> String do(callback) {
>   Mark.buffer = new StringBuffer();
>   callback();
>   return Mark.buffer.toString();
> }
> 
> and then: 
> 
> class OneField {
>   var a = new Mark("a");
>   OneField();
>   OneField.init() : a = new Mark("ai");
> }
> 
> and then the tests:
> 
> main() {
>   Expect.equals("a.", do(() => new OneField()));
>   Expect.equals("a.ai.", do(() => new OneField.init()));
>   ...
> }

Thanks for the suggestion. Done.

Powered by Google App Engine
This is Rietveld 408576698