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

Side by Side Diff: pkg/compiler/lib/src/elements/modelx.dart

Issue 1994613004: Handle use of constant constructors with default values. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. 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) 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 library elements.modelx; 5 library elements.modelx;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/resolution.dart' show Resolution, ParsingContext; 8 import '../common/resolution.dart' show Resolution, ParsingContext;
9 import '../compiler.dart' show Compiler; 9 import '../compiler.dart' show Compiler;
10 import '../constants/constant_constructors.dart'; 10 import '../constants/constant_constructors.dart';
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 get isExternal => unsupported(); 249 get isExternal => unsupported();
250 get constantConstructor => null; 250 get constantConstructor => null;
251 251
252 bool get isRedirectingGenerative => unsupported(); 252 bool get isRedirectingGenerative => unsupported();
253 bool get isRedirectingFactory => unsupported(); 253 bool get isRedirectingFactory => unsupported();
254 254
255 computeType(Resolution resolution) => unsupported(); 255 computeType(Resolution resolution) => unsupported();
256 256
257 bool get hasFunctionSignature => false; 257 bool get hasFunctionSignature => false;
258 258
259 bool get hasEffectiveTarget => true;
260
259 get effectiveTarget => this; 261 get effectiveTarget => this;
260 262
261 computeEffectiveTargetType(InterfaceType newType) => unsupported(); 263 computeEffectiveTargetType(InterfaceType newType) => unsupported();
262 264
263 get definingConstructor => null; 265 get definingConstructor => null;
264 266
265 FunctionElement asFunctionElement() => this; 267 FunctionElement asFunctionElement() => this;
266 268
267 String get message { 269 String get message {
268 return MessageTemplate.TEMPLATES[messageKind] 270 return MessageTemplate.TEMPLATES[messageKind]
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1384 VariableDefinitions parseNode(Element element, ParsingContext parsing) { 1386 VariableDefinitions parseNode(Element element, ParsingContext parsing) {
1385 return definitions; 1387 return definitions;
1386 } 1388 }
1387 1389
1388 DartType computeType(Element element, Resolution resolution) => type; 1390 DartType computeType(Element element, Resolution resolution) => type;
1389 } 1391 }
1390 1392
1391 abstract class ConstantVariableMixin implements VariableElement { 1393 abstract class ConstantVariableMixin implements VariableElement {
1392 ConstantExpression constantCache; 1394 ConstantExpression constantCache;
1393 1395
1396 // TODO(johnniwinther): Update the on `constant = ...` when evaluation of
1397 // constant expression can handle references to unanalyzed constant variables.
1398 @override
1399 bool get hasConstant => false;
1400
1394 ConstantExpression get constant { 1401 ConstantExpression get constant {
1395 if (isPatch) { 1402 if (isPatch) {
1396 ConstantVariableMixin originVariable = origin; 1403 ConstantVariableMixin originVariable = origin;
1397 return originVariable.constant; 1404 return originVariable.constant;
1398 } 1405 }
1399 assert(invariant(this, !isConst || constantCache != null, 1406 assert(invariant(this, !isConst || constantCache != null,
1400 message: "Constant has not been computed for $this.")); 1407 message: "Constant has not been computed for $this."));
1401 return constantCache; 1408 return constantCache;
1402 } 1409 }
1403 1410
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
2192 2199
2193 // TODO(johnniwinther): This should also return true for cyclic redirecting 2200 // TODO(johnniwinther): This should also return true for cyclic redirecting
2194 // generative constructors. 2201 // generative constructors.
2195 bool get isCyclicRedirection => effectiveTarget.isRedirectingFactory; 2202 bool get isCyclicRedirection => effectiveTarget.isRedirectingFactory;
2196 2203
2197 /// These fields are set by the post process queue when checking for cycles. 2204 /// These fields are set by the post process queue when checking for cycles.
2198 ConstructorElement effectiveTargetInternal; 2205 ConstructorElement effectiveTargetInternal;
2199 DartType _effectiveTargetType; 2206 DartType _effectiveTargetType;
2200 bool _isEffectiveTargetMalformed; 2207 bool _isEffectiveTargetMalformed;
2201 2208
2209 bool get hasEffectiveTarget => effectiveTargetInternal != null;
2210
2202 void setEffectiveTarget(ConstructorElement target, DartType type, 2211 void setEffectiveTarget(ConstructorElement target, DartType type,
2203 {bool isMalformed: false}) { 2212 {bool isMalformed: false}) {
2204 assert(invariant(this, target != null, 2213 assert(invariant(this, target != null,
2205 message: 'No effective target provided for $this.')); 2214 message: 'No effective target provided for $this.'));
2206 assert(invariant(this, effectiveTargetInternal == null, 2215 assert(invariant(this, effectiveTargetInternal == null,
2207 message: 'Effective target has already been computed for $this.')); 2216 message: 'Effective target has already been computed for $this.'));
2208 effectiveTargetInternal = target; 2217 effectiveTargetInternal = target;
2209 _effectiveTargetType = type; 2218 _effectiveTargetType = type;
2210 _isEffectiveTargetMalformed = isMalformed; 2219 _isEffectiveTargetMalformed = isMalformed;
2211 } 2220 }
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after
3284 body = node.asFunctionExpression().body; 3293 body = node.asFunctionExpression().body;
3285 } 3294 }
3286 return new ParsedResolvedAst( 3295 return new ParsedResolvedAst(
3287 declaration, 3296 declaration,
3288 node, 3297 node,
3289 body, 3298 body,
3290 definingElement.treeElements, 3299 definingElement.treeElements,
3291 definingElement.compilationUnit.script.resourceUri); 3300 definingElement.compilationUnit.script.resourceUri);
3292 } 3301 }
3293 } 3302 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/elements/elements.dart ('k') | pkg/compiler/lib/src/resolution/resolution.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698