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

Side by Side Diff: pkg/analyzer/lib/src/summary/resynthesize.dart

Issue 2023393003: Move constant expression resynthesis into ConstVariableElement mixin. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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/analyzer/lib/src/dart/element/element.dart ('k') | no next file » | 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 summary_resynthesizer; 5 library summary_resynthesizer;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 2154 matching lines...) Expand 10 before | Expand all | Expand 10 after
2165 UnitExplicitTopLevelVariables buildUnitExplicitTopLevelVariables() { 2165 UnitExplicitTopLevelVariables buildUnitExplicitTopLevelVariables() {
2166 List<UnlinkedVariable> unlinkedVariables = unlinkedUnit.variables; 2166 List<UnlinkedVariable> unlinkedVariables = unlinkedUnit.variables;
2167 int numberOfVariables = unlinkedVariables.length; 2167 int numberOfVariables = unlinkedVariables.length;
2168 UnitExplicitTopLevelVariables variablesData = 2168 UnitExplicitTopLevelVariables variablesData =
2169 new UnitExplicitTopLevelVariables(numberOfVariables); 2169 new UnitExplicitTopLevelVariables(numberOfVariables);
2170 for (int i = 0; i < numberOfVariables; i++) { 2170 for (int i = 0; i < numberOfVariables; i++) {
2171 UnlinkedVariable unlinkedVariable = unlinkedVariables[i]; 2171 UnlinkedVariable unlinkedVariable = unlinkedVariables[i];
2172 TopLevelVariableElementImpl element; 2172 TopLevelVariableElementImpl element;
2173 if (unlinkedVariable.initializer?.bodyExpr != null && 2173 if (unlinkedVariable.initializer?.bodyExpr != null &&
2174 unlinkedVariable.isConst) { 2174 unlinkedVariable.isConst) {
2175 ConstTopLevelVariableElementImpl constElement = 2175 element = new ConstTopLevelVariableElementImpl.forSerialized(
2176 new ConstTopLevelVariableElementImpl.forSerialized( 2176 unlinkedVariable, unit);
2177 unlinkedVariable, unit);
2178 element = constElement;
2179 constElement.constantInitializer =
2180 _buildConstExpression(null, unlinkedVariable.initializer.bodyExpr);
2181 } else { 2177 } else {
2182 element = new TopLevelVariableElementImpl.forSerialized( 2178 element = new TopLevelVariableElementImpl.forSerialized(
2183 unlinkedVariable, unit); 2179 unlinkedVariable, unit);
2184 } 2180 }
2185 variablesData.variables[i] = element; 2181 variablesData.variables[i] = element;
2186 // implicit accessors 2182 // implicit accessors
2187 variablesData.implicitAccessors.add(buildImplicitGetter(element)); 2183 variablesData.implicitAccessors.add(buildImplicitGetter(element));
2188 if (!(element.isConst || element.isFinal)) { 2184 if (!(element.isConst || element.isFinal)) {
2189 variablesData.implicitAccessors.add(buildImplicitSetter(element)); 2185 variablesData.implicitAccessors.add(buildImplicitSetter(element));
2190 } 2186 }
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
2400 static String _getElementIdentifier(String name, ReferenceKind kind) { 2396 static String _getElementIdentifier(String name, ReferenceKind kind) {
2401 if (kind == ReferenceKind.topLevelPropertyAccessor || 2397 if (kind == ReferenceKind.topLevelPropertyAccessor ||
2402 kind == ReferenceKind.propertyAccessor) { 2398 kind == ReferenceKind.propertyAccessor) {
2403 if (!name.endsWith('=')) { 2399 if (!name.endsWith('=')) {
2404 return name + '?'; 2400 return name + '?';
2405 } 2401 }
2406 } 2402 }
2407 return name; 2403 return name;
2408 } 2404 }
2409 } 2405 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698