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

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

Issue 710343002: Check enums in switch cases. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 | Annotate | Revision Log
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 'elements.dart'; 7 import 'elements.dart';
8 import '../constants/expressions.dart'; 8 import '../constants/expressions.dart';
9 import '../helpers/helpers.dart'; // Included for debug helpers. 9 import '../helpers/helpers.dart'; // Included for debug helpers.
10 import '../tree/tree.dart'; 10 import '../tree/tree.dart';
(...skipping 2396 matching lines...) Expand 10 before | Expand all | Expand 10 after
2407 if (origin != null) { 2407 if (origin != null) {
2408 return 'patch ${super.toString()}'; 2408 return 'patch ${super.toString()}';
2409 } else if (patch != null) { 2409 } else if (patch != null) {
2410 return 'origin ${super.toString()}'; 2410 return 'origin ${super.toString()}';
2411 } else { 2411 } else {
2412 return super.toString(); 2412 return super.toString();
2413 } 2413 }
2414 } 2414 }
2415 } 2415 }
2416 2416
2417 class EnumClassElementX extends ClassElementX { 2417 class EnumClassElementX extends ClassElementX implements EnumClassElement {
2418 final Enum node; 2418 final Enum node;
2419 Iterable<FieldElement> enumValuesCache;
2419 2420
2420 EnumClassElementX(String name, Element enclosing, int id, this.node) 2421 EnumClassElementX(String name, Element enclosing, int id, this.node)
2421 : super(name, enclosing, id, STATE_NOT_STARTED); 2422 : super(name, enclosing, id, STATE_NOT_STARTED);
2422 2423
2423 @override 2424 @override
2424 bool get hasNode => true; 2425 bool get hasNode => true;
2425 2426
2426 @override 2427 @override
2427 Token get position => node.name.token; 2428 Token get position => node.name.token;
2428 2429
2429 @override 2430 @override
2430 bool get isEnumClass => true; 2431 bool get isEnumClass => true;
2431 2432
2432 @override 2433 @override
2433 Node parseNode(Compiler compiler) => node; 2434 Node parseNode(Compiler compiler) => node;
2434 2435
2435 @override 2436 @override
2436 accept(ElementVisitor visitor) => visitor.visitClassElement(this); 2437 accept(ElementVisitor visitor) => visitor.visitEnumClassElement(this);
2437 2438
2438 List<DartType> computeTypeParameters(Compiler compiler) => const <DartType>[]; 2439 List<DartType> computeTypeParameters(Compiler compiler) => const <DartType>[];
2440
2441 Iterable<FieldElement> get enumValues {
2442 assert(invariant(this, enumValuesCache != null,
2443 message: "enumValues has not been computed for $this."));
2444 return enumValuesCache;
2445 }
2446
2447 void set enumValues(Iterable<FieldElement> values) {
2448 assert(invariant(this, enumValuesCache == null,
2449 message: "enumValues has already been computed for $this."));
2450 enumValuesCache = values;
2451 }
2439 } 2452 }
2440 2453
2441 class EnumConstructorElementX extends ConstructorElementX { 2454 class EnumConstructorElementX extends ConstructorElementX {
2442 final FunctionExpression node; 2455 final FunctionExpression node;
2443 2456
2444 EnumConstructorElementX(EnumClassElementX enumClass, 2457 EnumConstructorElementX(EnumClassElementX enumClass,
2445 Modifiers modifiers, 2458 Modifiers modifiers,
2446 this.node) 2459 this.node)
2447 : super('', // Name. 2460 : super('', // Name.
2448 ElementKind.GENERATIVE_CONSTRUCTOR, 2461 ElementKind.GENERATIVE_CONSTRUCTOR,
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
2796 AstElement get definingElement; 2809 AstElement get definingElement;
2797 2810
2798 bool get hasResolvedAst => definingElement.hasTreeElements; 2811 bool get hasResolvedAst => definingElement.hasTreeElements;
2799 2812
2800 ResolvedAst get resolvedAst { 2813 ResolvedAst get resolvedAst {
2801 return new ResolvedAst(declaration, 2814 return new ResolvedAst(declaration,
2802 definingElement.node, definingElement.treeElements); 2815 definingElement.node, definingElement.treeElements);
2803 } 2816 }
2804 2817
2805 } 2818 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698