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

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

Issue 1881013002: Expand ResolvedAst to handle synthetic constructors. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments + fix test, cps and compilation units for injected members. Created 4 years, 8 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 | « pkg/compiler/lib/src/common/codegen.dart ('k') | pkg/compiler/lib/src/compiler.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 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 // compile-time compilation. 1085 // compile-time compilation.
1086 return null; 1086 return null;
1087 } 1087 }
1088 } 1088 }
1089 1089
1090 class ConstructorEvaluator extends CompileTimeConstantEvaluator { 1090 class ConstructorEvaluator extends CompileTimeConstantEvaluator {
1091 final InterfaceType constructedType; 1091 final InterfaceType constructedType;
1092 final ConstructorElement constructor; 1092 final ConstructorElement constructor;
1093 final Map<Element, AstConstant> definitions; 1093 final Map<Element, AstConstant> definitions;
1094 final Map<Element, AstConstant> fieldValues; 1094 final Map<Element, AstConstant> fieldValues;
1095 final ResolvedAst resolvedAst;
1095 1096
1096 /** 1097 /**
1097 * Documentation wanted -- johnniwinther 1098 * Documentation wanted -- johnniwinther
1098 * 1099 *
1099 * Invariant: [constructor] must be an implementation element. 1100 * Invariant: [constructor] must be an implementation element.
1100 */ 1101 */
1101 ConstructorEvaluator(InterfaceType this.constructedType, 1102 ConstructorEvaluator(InterfaceType this.constructedType,
1102 FunctionElement constructor, ConstantCompiler handler, Compiler compiler) 1103 FunctionElement constructor, ConstantCompiler handler, Compiler compiler)
1103 : this.constructor = constructor, 1104 : this.constructor = constructor,
1104 this.definitions = new Map<Element, AstConstant>(), 1105 this.definitions = new Map<Element, AstConstant>(),
1105 this.fieldValues = new Map<Element, AstConstant>(), 1106 this.fieldValues = new Map<Element, AstConstant>(),
1106 super(handler, _analyzeElementEagerly(compiler, constructor), compiler, 1107 this.resolvedAst = _analyzeElementEagerly(compiler, constructor),
1107 isConst: true) { 1108 super(handler, null, compiler, isConst: true) {
1108 assert(invariant(constructor, constructor.isImplementation)); 1109 assert(invariant(constructor, constructor.isImplementation));
1109 } 1110 }
1110 1111
1112 @override
1113 TreeElements get elements => resolvedAst.elements;
1114
1111 AstConstant visitSend(Send send) { 1115 AstConstant visitSend(Send send) {
1112 Element element = elements[send]; 1116 Element element = elements[send];
1113 if (Elements.isLocal(element)) { 1117 if (Elements.isLocal(element)) {
1114 AstConstant constant = definitions[element]; 1118 AstConstant constant = definitions[element];
1115 if (constant == null) { 1119 if (constant == null) {
1116 reporter.internalError(send, "Local variable without value."); 1120 reporter.internalError(send, "Local variable without value.");
1117 } 1121 }
1118 return constant; 1122 return constant;
1119 } 1123 }
1120 return super.visitSend(send); 1124 return super.visitSend(send);
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 ErroneousAstConstant(Element element, Node node) 1330 ErroneousAstConstant(Element element, Node node)
1327 : super( 1331 : super(
1328 element, 1332 element,
1329 node, 1333 node,
1330 // TODO(johnniwinther): Return a [NonConstantValue] instead. 1334 // TODO(johnniwinther): Return a [NonConstantValue] instead.
1331 new ErroneousConstantExpression(), 1335 new ErroneousConstantExpression(),
1332 new NullConstantValue()); 1336 new NullConstantValue());
1333 } 1337 }
1334 1338
1335 // TODO(johnniwinther): Clean this up. 1339 // TODO(johnniwinther): Clean this up.
1336 TreeElements _analyzeElementEagerly(Compiler compiler, AstElement element) { 1340 ResolvedAst _analyzeElementEagerly(Compiler compiler, AstElement element) {
1337 compiler.resolution.computeWorldImpact(element.declaration); 1341 compiler.resolution.computeWorldImpact(element.declaration);
1338 return element.resolvedAst.elements; 1342 return element.resolvedAst;
1339 } 1343 }
1340 1344
1341 class _CompilerEnvironment implements Environment { 1345 class _CompilerEnvironment implements Environment {
1342 final Compiler compiler; 1346 final Compiler compiler;
1343 1347
1344 _CompilerEnvironment(this.compiler); 1348 _CompilerEnvironment(this.compiler);
1345 1349
1346 @override 1350 @override
1347 String readFromEnvironment(String name) { 1351 String readFromEnvironment(String name) {
1348 return compiler.fromEnvironment(name); 1352 return compiler.fromEnvironment(name);
1349 } 1353 }
1350 } 1354 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/common/codegen.dart ('k') | pkg/compiler/lib/src/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698