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

Side by Side Diff: pkg/compiler/lib/src/mirrors/dart2js_member_mirrors.dart

Issue 1919143002: Store constant variable initializers in elements. (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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of dart2js.mirrors; 5 part of dart2js.mirrors;
6 6
7 //------------------------------------------------------------------------------ 7 //------------------------------------------------------------------------------
8 // Member mirrors implementation. 8 // Member mirrors implementation.
9 //------------------------------------------------------------------------------ 9 //------------------------------------------------------------------------------
10 10
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 183
184 bool get isFinal => false; 184 bool get isFinal => false;
185 185
186 bool get isConst => false; 186 bool get isConst => false;
187 187
188 InstanceMirror get defaultValue { 188 InstanceMirror get defaultValue {
189 if (hasDefaultValue) { 189 if (hasDefaultValue) {
190 // TODO(johnniwinther): Get the constant from the [TreeElements] 190 // TODO(johnniwinther): Get the constant from the [TreeElements]
191 // associated with the enclosing method. 191 // associated with the enclosing method.
192 ParameterElement parameter = _element; 192 ParameterElement parameter = _element;
193 ConstantExpression constant = 193 ConstantExpression constant = parameter.constant;
194 mirrorSystem.compiler.constants.getConstantForVariable(parameter);
195 assert(invariant(parameter, constant != null, 194 assert(invariant(parameter, constant != null,
196 message: "Missing constant for parameter " 195 message: "Missing constant for parameter "
197 "$parameter with default value.")); 196 "$parameter with default value."));
198 return _convertConstantToInstanceMirror(mirrorSystem, constant, 197 return _convertConstantToInstanceMirror(mirrorSystem, constant,
199 mirrorSystem.compiler.constants.getConstantValue(constant)); 198 mirrorSystem.compiler.constants.getConstantValue(constant));
200 } 199 }
201 return null; 200 return null;
202 } 201 }
203 202
204 bool get hasDefaultValue { 203 bool get hasDefaultValue {
(...skipping 14 matching lines...) Expand all
219 InitializingFormalElement element, bool isOptional, bool isNamed) 218 InitializingFormalElement element, bool isOptional, bool isNamed)
220 : super._normal(method, element, isOptional, isNamed); 219 : super._normal(method, element, isOptional, isNamed);
221 220
222 InitializingFormalElement get _fieldParameterElement => _element; 221 InitializingFormalElement get _fieldParameterElement => _element;
223 222
224 bool get isInitializingFormal => true; 223 bool get isInitializingFormal => true;
225 224
226 VariableMirror get initializedField => 225 VariableMirror get initializedField =>
227 new Dart2JsFieldMirror(owner.owner, _fieldParameterElement.fieldElement); 226 new Dart2JsFieldMirror(owner.owner, _fieldParameterElement.fieldElement);
228 } 227 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698