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

Side by Side Diff: pkg/compiler/lib/src/compile_time_constants.dart

Issue 1979613002: Use ResolvedAst in constant initializers (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 4 years, 7 months 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 | « no previous file | tests/compiler/dart2js/serialization/test_data.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 library dart2js.compile_time_constant_evaluator; 5 library dart2js.compile_time_constant_evaluator;
6 6
7 import 'common.dart'; 7 import 'common.dart';
8 import 'common/resolution.dart' show Resolution; 8 import 'common/resolution.dart' show Resolution;
9 import 'common/tasks.dart' show CompilerTask; 9 import 'common/tasks.dart' show CompilerTask;
10 import 'compiler.dart' show Compiler; 10 import 'compiler.dart' show Compiler;
(...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 // No need to go through [updateFieldValue] because the 1180 // No need to go through [updateFieldValue] because the
1181 // assignments have already been checked in checked mode. 1181 // assignments have already been checked in checked mode.
1182 evaluator.fieldValues.forEach((key, value) => fieldValues[key] = value); 1182 evaluator.fieldValues.forEach((key, value) => fieldValues[key] = value);
1183 } 1183 }
1184 1184
1185 /** 1185 /**
1186 * Runs through the initializers of the given [constructor] and updates 1186 * Runs through the initializers of the given [constructor] and updates
1187 * the [fieldValues] map. 1187 * the [fieldValues] map.
1188 */ 1188 */
1189 void evaluateConstructorInitializers() { 1189 void evaluateConstructorInitializers() {
1190 if (constructor.isSynthesized) { 1190 ResolvedAst resolvedAst = constructor.resolvedAst;
1191 if (resolvedAst.kind != ResolvedAstKind.PARSED) {
1191 List<AstConstant> compiledArguments = <AstConstant>[]; 1192 List<AstConstant> compiledArguments = <AstConstant>[];
1192 1193
1193 Function compileArgument = (element) => definitions[element]; 1194 Function compileArgument = (element) => definitions[element];
1194 Function compileConstant = handler.compileConstant; 1195 Function compileConstant = handler.compileConstant;
1195 FunctionElement target = constructor.definingConstructor.implementation; 1196 FunctionElement target = constructor.definingConstructor.implementation;
1196 CallStructure.addForwardingElementArgumentsToList(constructor, 1197 CallStructure.addForwardingElementArgumentsToList(constructor,
1197 compiledArguments, target, compileArgument, compileConstant); 1198 compiledArguments, target, compileArgument, compileConstant);
1198 evaluateSuperOrRedirectSend(compiledArguments, target); 1199 evaluateSuperOrRedirectSend(compiledArguments, target);
1199 return; 1200 return;
1200 } 1201 }
1201 FunctionExpression functionNode = constructor.node; 1202 FunctionExpression functionNode = resolvedAst.node;
1202 NodeList initializerList = functionNode.initializers; 1203 NodeList initializerList = functionNode.initializers;
1203 1204
1204 bool foundSuperOrRedirect = false; 1205 bool foundSuperOrRedirect = false;
1205 1206
1206 if (initializerList != null) { 1207 if (initializerList != null) {
1207 for (Link<Node> link = initializerList.nodes; 1208 for (Link<Node> link = initializerList.nodes;
1208 !link.isEmpty; 1209 !link.isEmpty;
1209 link = link.tail) { 1210 link = link.tail) {
1210 assert(link.head is Send); 1211 assert(link.head is Send);
1211 if (link.head is! SendSet) { 1212 if (link.head is! SendSet) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 class _CompilerEnvironment implements Environment { 1343 class _CompilerEnvironment implements Environment {
1343 final Compiler compiler; 1344 final Compiler compiler;
1344 1345
1345 _CompilerEnvironment(this.compiler); 1346 _CompilerEnvironment(this.compiler);
1346 1347
1347 @override 1348 @override
1348 String readFromEnvironment(String name) { 1349 String readFromEnvironment(String name) {
1349 return compiler.fromEnvironment(name); 1350 return compiler.fromEnvironment(name);
1350 } 1351 }
1351 } 1352 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/serialization/test_data.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698