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

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

Issue 2013883003: Migrate UnlinkedVariable.constExpr to UnlinkedExecutable.bodyExpr. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix a comment 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
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 serialization.elements; 5 library serialization.elements;
6 6
7 import 'dart:convert'; 7 import 'dart:convert';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/element/element.dart'; 10 import 'package:analyzer/dart/element/element.dart';
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 b.name = variable.name; 1126 b.name = variable.name;
1127 b.nameOffset = variable.nameOffset; 1127 b.nameOffset = variable.nameOffset;
1128 if (!variable.hasImplicitType) { 1128 if (!variable.hasImplicitType) {
1129 b.type = serializeTypeRef(variable.type, variable); 1129 b.type = serializeTypeRef(variable.type, variable);
1130 } 1130 }
1131 b.isStatic = variable.isStatic && variable.enclosingElement is ClassElement; 1131 b.isStatic = variable.isStatic && variable.enclosingElement is ClassElement;
1132 b.isFinal = variable.isFinal; 1132 b.isFinal = variable.isFinal;
1133 b.isConst = variable.isConst; 1133 b.isConst = variable.isConst;
1134 b.documentationComment = serializeDocumentation(variable); 1134 b.documentationComment = serializeDocumentation(variable);
1135 b.annotations = serializeAnnotations(variable); 1135 b.annotations = serializeAnnotations(variable);
1136 // TODO(scheglov) VariableMember.initializer is not implemented
1137 if (variable is! VariableMember && variable.initializer != null) {
1138 b.initializer = serializeExecutable(variable.initializer);
1139 }
1136 if (variable is ConstVariableElement) { 1140 if (variable is ConstVariableElement) {
1137 ConstVariableElement constVariable = variable as ConstVariableElement; 1141 ConstVariableElement constVariable = variable as ConstVariableElement;
1138 Expression initializer = constVariable.constantInitializer; 1142 Expression initializer = constVariable.constantInitializer;
1139 if (initializer != null) { 1143 if (initializer != null) {
1140 b.constExpr = 1144 b.initializer?.bodyExpr =
1141 serializeConstExpr(variable, variable.initializer, initializer); 1145 serializeConstExpr(variable, variable.initializer, initializer);
1142 } 1146 }
1143 } 1147 }
1144 if (variable is PropertyInducingElement) { 1148 if (variable is PropertyInducingElement) {
1145 if (b.isFinal || b.isConst) { 1149 if (b.isFinal || b.isConst) {
1146 b.propagatedTypeSlot = 1150 b.propagatedTypeSlot =
1147 storeLinkedType(variable.propagatedType, variable); 1151 storeLinkedType(variable.propagatedType, variable);
1148 } else { 1152 } else {
1149 // Variable is not propagable. 1153 // Variable is not propagable.
1150 assert(variable.propagatedType == null); 1154 assert(variable.propagatedType == null);
1151 } 1155 }
1152 } 1156 }
1153 if (variable.hasImplicitType && 1157 if (variable.hasImplicitType &&
1154 (variable.initializer != null || !variable.isStatic)) { 1158 (variable.initializer != null || !variable.isStatic)) {
1155 b.inferredTypeSlot = storeInferredType(variable.type, variable); 1159 b.inferredTypeSlot = storeInferredType(variable.type, variable);
1156 } 1160 }
1157 b.codeRange = serializeCodeRange(variable); 1161 b.codeRange = serializeCodeRange(variable);
1158 if (variable is LocalVariableElement) { 1162 if (variable is LocalVariableElement) {
1159 SourceRange visibleRange = variable.visibleRange; 1163 SourceRange visibleRange = variable.visibleRange;
1160 if (visibleRange != null) { 1164 if (visibleRange != null) {
1161 b.visibleOffset = visibleRange.offset; 1165 b.visibleOffset = visibleRange.offset;
1162 b.visibleLength = visibleRange.length; 1166 b.visibleLength = visibleRange.length;
1163 } 1167 }
1164 } 1168 }
1165 // TODO(scheglov) VariableMember.initializer is not implemented
1166 if (variable is! VariableMember && variable.initializer != null) {
1167 b.initializer = serializeExecutable(variable.initializer);
1168 }
1169 return b; 1169 return b;
1170 } 1170 }
1171 1171
1172 /** 1172 /**
1173 * Create a new slot id and return it. If [hasCycle] is `true`, arrange for 1173 * Create a new slot id and return it. If [hasCycle] is `true`, arrange for
1174 * the slot id to be included in [LinkedUnit.constCycles]. 1174 * the slot id to be included in [LinkedUnit.constCycles].
1175 */ 1175 */
1176 int storeConstCycle(bool hasCycle) { 1176 int storeConstCycle(bool hasCycle) {
1177 int slot = ++numSlots; 1177 int slot = ++numSlots;
1178 if (hasCycle) { 1178 if (hasCycle) {
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
1675 exportNames.add(new LinkedExportNameBuilder( 1675 exportNames.add(new LinkedExportNameBuilder(
1676 name: name, 1676 name: name,
1677 dependency: serializeDependency(dependentLibrary), 1677 dependency: serializeDependency(dependentLibrary),
1678 unit: unit, 1678 unit: unit,
1679 kind: kind)); 1679 kind: kind));
1680 } 1680 }
1681 pb.exportNames = exportNames; 1681 pb.exportNames = exportNames;
1682 return pb; 1682 return pb;
1683 } 1683 }
1684 } 1684 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_ast.dart ('k') | pkg/analyzer/test/src/summary/summary_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698