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

Side by Side Diff: pkg/compiler/lib/src/native/resolver.dart

Issue 2998543002: Handle js interop members in impact computation. (Closed)
Patch Set: Updated cf. comments. Created 3 years, 4 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 import 'package:front_end/src/fasta/scanner.dart' show StringToken, Token; 5 import 'package:front_end/src/fasta/scanner.dart' show StringToken, Token;
6 import 'package:front_end/src/fasta/scanner.dart' as Tokens show EOF_TOKEN; 6 import 'package:front_end/src/fasta/scanner.dart' as Tokens show EOF_TOKEN;
7 import 'package:front_end/src/scanner/token.dart' show BeginToken; 7 import 'package:front_end/src/scanner/token.dart' show BeginToken;
8 8
9 import '../common.dart'; 9 import '../common.dart';
10 import '../common_elements.dart' show CommonElements, ElementEnvironment; 10 import '../common_elements.dart' show CommonElements, ElementEnvironment;
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 // Should be at '{', 'with', 'implements', '<' or 'native'. 600 // Should be at '{', 'with', 'implements', '<' or 'native'.
601 return id.lexeme; 601 return id.lexeme;
602 } 602 }
603 603
604 return _reporter.withCurrentElement(classElement, () { 604 return _reporter.withCurrentElement(classElement, () {
605 return scanForExtendsName(classElement.position); 605 return scanForExtendsName(classElement.position);
606 }); 606 });
607 } 607 }
608 } 608 }
609 609
610 /// Returns `true` if [value] is named annotation based on [annotationClass].
611 bool isAnnotation(
612 Spannable spannable, ConstantValue value, ClassEntity annotationClass) {
613 if (!value.isConstructedObject) return null;
614 ConstructedConstantValue constructedObject = value;
615 return constructedObject.type.element == annotationClass;
616 }
617
610 /// Extracts the name if [value] is a named annotation based on 618 /// Extracts the name if [value] is a named annotation based on
611 /// [annotationClass], otherwise returns `null`. 619 /// [annotationClass], otherwise returns `null`.
612 String readAnnotationName( 620 String readAnnotationName(
613 Spannable spannable, ConstantValue value, ClassEntity annotationClass) { 621 Spannable spannable, ConstantValue value, ClassEntity annotationClass,
622 {String defaultValue}) {
614 if (!value.isConstructedObject) return null; 623 if (!value.isConstructedObject) return null;
615 ConstructedConstantValue constructedObject = value; 624 ConstructedConstantValue constructedObject = value;
616 if (constructedObject.type.element != annotationClass) return null; 625 if (constructedObject.type.element != annotationClass) return null;
617 626
618 Iterable<ConstantValue> fields = constructedObject.fields.values; 627 Iterable<ConstantValue> fields = constructedObject.fields.values;
619 // TODO(sra): Better validation of the constant. 628 // TODO(sra): Better validation of the constant.
620 if (fields.length != 1 || fields.single is! StringConstantValue) { 629 if (fields.length != 1) {
621 failedAt( 630 failedAt(
622 spannable, 'Annotations needs one string: ${value.toStructuredText()}'); 631 spannable, 'Annotations needs one string: ${value.toStructuredText()}');
632 return null;
633 } else if (fields.single is StringConstantValue) {
634 StringConstantValue specStringConstant = fields.single;
635 return specStringConstant.primitiveValue;
636 } else if (defaultValue != null && fields.single is NullConstantValue) {
637 return defaultValue;
638 } else {
639 failedAt(
640 spannable, 'Annotations needs one string: ${value.toStructuredText()}');
641 return null;
623 } 642 }
624 StringConstantValue specStringConstant = fields.single;
625 return specStringConstant.primitiveValue;
626 } 643 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/native/behavior.dart ('k') | pkg/compiler/lib/src/resolution/resolution_strategy.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698