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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/elements/modelx.dart

Issue 232563006: Insert checks before deferred calls and accesses. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 | 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 '../tree/tree.dart'; 8 import '../tree/tree.dart';
9 import '../util/util.dart'; 9 import '../util/util.dart';
10 import '../resolution/resolution.dart'; 10 import '../resolution/resolution.dart';
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 class ErroneousElementX extends ElementX implements ErroneousElement { 324 class ErroneousElementX extends ElementX implements ErroneousElement {
325 final MessageKind messageKind; 325 final MessageKind messageKind;
326 final Map messageArguments; 326 final Map messageArguments;
327 327
328 ErroneousElementX(this.messageKind, this.messageArguments, 328 ErroneousElementX(this.messageKind, this.messageArguments,
329 String name, Element enclosing) 329 String name, Element enclosing)
330 : super(name, ElementKind.ERROR, enclosing); 330 : super(name, ElementKind.ERROR, enclosing);
331 331
332 isErroneous() => true; 332 isErroneous() => true;
333 333
334 AbstractFieldElement abstractField;
335
334 unsupported() { 336 unsupported() {
335 throw 'unsupported operation on erroneous element'; 337 throw 'unsupported operation on erroneous element';
336 } 338 }
337 339
338 Link<MetadataAnnotation> get metadata => unsupported(); 340 Link<MetadataAnnotation> get metadata => unsupported();
339 get node => unsupported(); 341 get node => unsupported();
340 get type => unsupported(); 342 get type => unsupported();
341 get cachedNode => unsupported(); 343 get cachedNode => unsupported();
342 get functionSignature => unsupported(); 344 get functionSignature => unsupported();
343 get patch => null; 345 get patch => null;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 * and a setter. 535 * and a setter.
534 * 536 *
535 * The abstract field is added once, for the first getter or setter, and 537 * The abstract field is added once, for the first getter or setter, and
536 * reused if the other one is also added. 538 * reused if the other one is also added.
537 * The abstract field should not be treated as a proper member of the 539 * The abstract field should not be treated as a proper member of the
538 * container, it's simply a way to return two results for one lookup. 540 * container, it's simply a way to return two results for one lookup.
539 * That is, the getter or setter does not have the abstract field as enclosing 541 * That is, the getter or setter does not have the abstract field as enclosing
540 * element, they are enclosed by the class or compilation unit, as is the 542 * element, they are enclosed by the class or compilation unit, as is the
541 * abstract field. 543 * abstract field.
542 */ 544 */
543 void addAccessor(Element accessor, 545 void addAccessor(FunctionElementX accessor,
544 Element existing, 546 Element existing,
545 DiagnosticListener listener) { 547 DiagnosticListener listener) {
546 void reportError(Element other) { 548 void reportError(Element other) {
547 listener.reportError(accessor, 549 listener.reportError(accessor,
548 MessageKind.DUPLICATE_DEFINITION, 550 MessageKind.DUPLICATE_DEFINITION,
549 {'name': accessor.name}); 551 {'name': accessor.name});
550 // TODO(johnniwinther): Make this an info instead of a fatal error. 552 // TODO(johnniwinther): Make this an info instead of a fatal error.
551 listener.reportFatalError(other, 553 listener.reportFatalError(other,
552 MessageKind.EXISTING_DEFINITION, 554 MessageKind.EXISTING_DEFINITION,
553 {'name': accessor.name}); 555 {'name': accessor.name});
554 } 556 }
555 557
556 if (existing != null) { 558 if (existing != null) {
557 if (!identical(existing.kind, ElementKind.ABSTRACT_FIELD)) { 559 if (!identical(existing.kind, ElementKind.ABSTRACT_FIELD)) {
558 reportError(existing); 560 reportError(existing);
559 } else { 561 } else {
560 AbstractFieldElementX field = existing; 562 AbstractFieldElementX field = existing;
563 accessor.abstractField = field;
561 if (accessor.isGetter()) { 564 if (accessor.isGetter()) {
562 if (field.getter != null && field.getter != accessor) { 565 if (field.getter != null && field.getter != accessor) {
563 reportError(field.getter); 566 reportError(field.getter);
564 } 567 }
565 field.getter = accessor; 568 field.getter = accessor;
566 } else { 569 } else {
567 assert(accessor.isSetter()); 570 assert(accessor.isSetter());
568 if (field.setter != null && field.setter != accessor) { 571 if (field.setter != null && field.setter != accessor) {
569 reportError(field.setter); 572 reportError(field.setter);
570 } 573 }
571 field.setter = accessor; 574 field.setter = accessor;
572 } 575 }
573 } 576 }
574 } else { 577 } else {
575 Element container = accessor.getEnclosingClassOrCompilationUnit(); 578 Element container = accessor.getEnclosingClassOrCompilationUnit();
576 AbstractFieldElementX field = 579 AbstractFieldElementX field =
577 new AbstractFieldElementX(accessor.name, container); 580 new AbstractFieldElementX(accessor.name, container);
581 accessor.abstractField = field;
578 if (accessor.isGetter()) { 582 if (accessor.isGetter()) {
579 field.getter = accessor; 583 field.getter = accessor;
580 } else { 584 } else {
581 field.setter = accessor; 585 field.setter = accessor;
582 } 586 }
583 add(field, listener); 587 add(field, listener);
584 } 588 }
585 } 589 }
586 } 590 }
587 591
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 /** 1496 /**
1493 * A function declaration that should be parsed instead of the current one. 1497 * A function declaration that should be parsed instead of the current one.
1494 * The patch should be parsed as if it was in the current scope. Its 1498 * The patch should be parsed as if it was in the current scope. Its
1495 * signature must match this function's signature. 1499 * signature must match this function's signature.
1496 */ 1500 */
1497 FunctionElement patch = null; 1501 FunctionElement patch = null;
1498 FunctionElement origin = null; 1502 FunctionElement origin = null;
1499 1503
1500 final bool _hasNoBody; 1504 final bool _hasNoBody;
1501 1505
1506 AbstractFieldElement abstractField;
1507
1502 /** 1508 /**
1503 * If this is a redirecting factory, [defaultImplementation] will be 1509 * If this is a redirecting factory, [defaultImplementation] will be
1504 * changed by the resolver to point to the redirection target. 1510 * changed by the resolver to point to the redirection target.
1505 * Otherwise, [:identical(defaultImplementation, this):]. 1511 * Otherwise, [:identical(defaultImplementation, this):].
1506 */ 1512 */
1507 // TODO(ahe): Rename this field to redirectionTarget. 1513 // TODO(ahe): Rename this field to redirectionTarget.
1508 FunctionElement defaultImplementation; 1514 FunctionElement defaultImplementation;
1509 1515
1510 FunctionElementX(String name, 1516 FunctionElementX(String name,
1511 ElementKind kind, 1517 ElementKind kind,
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after
2618 2624
2619 ParameterMetadataAnnotation(Metadata this.metadata); 2625 ParameterMetadataAnnotation(Metadata this.metadata);
2620 2626
2621 Node parseNode(DiagnosticListener listener) => metadata.expression; 2627 Node parseNode(DiagnosticListener listener) => metadata.expression;
2622 2628
2623 Token get beginToken => metadata.getBeginToken(); 2629 Token get beginToken => metadata.getBeginToken();
2624 2630
2625 Token get endToken => metadata.getEndToken(); 2631 Token get endToken => metadata.getEndToken();
2626 } 2632 }
2627 2633
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698