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

Side by Side Diff: pkg/kernel/lib/frontend/super_initializers.dart

Issue 2561723003: Merge kernel closure conversion into the Dart SDK (Closed)
Patch Set: Remove path constraint Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/kernel/lib/clone.dart ('k') | pkg/kernel/lib/kernel.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// A library to help move super calls last in the initializer list. 5 /// A library to help move super calls last in the initializer list.
6 library kernel.frontend.super_calls; 6 library kernel.frontend.super_calls;
7 7
8 import '../ast.dart'; 8 import '../ast.dart';
9 9
10 /// Mutates the initializer list of [node] so that its super initializer occurs 10 /// Mutates the initializer list of [node] so that its super initializer occurs
(...skipping 15 matching lines...) Expand all
26 if (superIndex == -1) return; 26 if (superIndex == -1) return;
27 SuperInitializer superCall = initializers[superIndex]; 27 SuperInitializer superCall = initializers[superIndex];
28 Arguments arguments = superCall.arguments; 28 Arguments arguments = superCall.arguments;
29 int argumentCount = arguments.positional.length + arguments.named.length; 29 int argumentCount = arguments.positional.length + arguments.named.length;
30 30
31 // We move all initializers after the super call to the place where the super 31 // We move all initializers after the super call to the place where the super
32 // call was, but reserve [argumentCount] slots before that for 32 // call was, but reserve [argumentCount] slots before that for
33 // [LocalInitializer]s. 33 // [LocalInitializer]s.
34 initializers.length += argumentCount; 34 initializers.length += argumentCount;
35 initializers.setRange( 35 initializers.setRange(
36 superIndex + argumentCount, // desination start (inclusive) 36 superIndex + argumentCount, // desination start (inclusive)
37 initializers.length - 1, // desination end (exclusive) 37 initializers.length - 1, // desination end (exclusive)
38 initializers, // source list 38 initializers, // source list
39 superIndex + 1); // source start index 39 superIndex + 1); // source start index
40 initializers[initializers.length - 1] = superCall; 40 initializers[initializers.length - 1] = superCall;
41 41
42 // Fill in the [argumentCount] reserved slots with the evaluation expressions 42 // Fill in the [argumentCount] reserved slots with the evaluation expressions
43 // of the arguments to the super constructor call. 43 // of the arguments to the super constructor call.
44 int storeIndex = superIndex; 44 int storeIndex = superIndex;
45 for (int i = 0; i < arguments.positional.length; ++i) { 45 for (int i = 0; i < arguments.positional.length; ++i) {
46 var variable = new VariableDeclaration.forValue(arguments.positional[i]); 46 var variable = new VariableDeclaration.forValue(arguments.positional[i]);
47 arguments.positional[i] = new VariableGet(variable)..parent = arguments; 47 arguments.positional[i] = new VariableGet(variable)..parent = arguments;
48 initializers[storeIndex++] = new LocalInitializer(variable)..parent = node; 48 initializers[storeIndex++] = new LocalInitializer(variable)..parent = node;
49 } 49 }
50 for (int i = 0; i < arguments.named.length; ++i) { 50 for (int i = 0; i < arguments.named.length; ++i) {
51 NamedExpression argument = arguments.named[i]; 51 NamedExpression argument = arguments.named[i];
52 var variable = new VariableDeclaration.forValue(argument.value); 52 var variable = new VariableDeclaration.forValue(argument.value);
53 arguments.named[i].value = new VariableGet(variable)..parent = argument; 53 arguments.named[i].value = new VariableGet(variable)..parent = argument;
54 initializers[storeIndex++] = new LocalInitializer(variable)..parent = node; 54 initializers[storeIndex++] = new LocalInitializer(variable)..parent = node;
55 } 55 }
56 } 56 }
OLDNEW
« no previous file with comments | « pkg/kernel/lib/clone.dart ('k') | pkg/kernel/lib/kernel.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698