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

Unified Diff: pkg/compiler/lib/src/js_backend/annotations.dart

Issue 2860893003: Revert "Make JavaScriptBackend.processAnnotations element-model agnostic" (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/inferrer/type_graph_nodes.dart ('k') | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_backend/annotations.dart
diff --git a/pkg/compiler/lib/src/js_backend/annotations.dart b/pkg/compiler/lib/src/js_backend/annotations.dart
index 78a78f60ad6cdace4852308ac01a502bb5431efa..4921f94ee7dd2a283a472e0e7f472c1ee23f9f26 100644
--- a/pkg/compiler/lib/src/js_backend/annotations.dart
+++ b/pkg/compiler/lib/src/js_backend/annotations.dart
@@ -4,19 +4,22 @@
library js_backend.backend.annotations;
-import '../common_elements.dart' show CommonElements, ElementEnvironment;
+import '../common.dart';
+import '../common_elements.dart' show CommonElements;
+import '../compiler.dart' show Compiler;
import '../constants/values.dart';
-import '../elements/entities.dart';
+import '../elements/elements.dart';
/// Handling of special annotations for tests.
class OptimizerHintsForTests {
- final ElementEnvironment _elementEnvironment;
- final CommonElements _commonElements;
+ final Compiler _compiler;
- OptimizerHintsForTests(this._elementEnvironment, this._commonElements);
+ OptimizerHintsForTests(this._compiler);
+
+ CommonElements get _commonElements => _compiler.commonElements;
/// Returns `true` if inlining is disabled for [element].
- bool noInline(MemberEntity element) {
+ bool noInline(Element element) {
if (_hasAnnotation(element, _commonElements.expectNoInlineClass)) {
// TODO(floitsch): restrict to elements from the test directory.
return true;
@@ -26,28 +29,33 @@ class OptimizerHintsForTests {
/// Returns `true` if parameter and returns types should be trusted for
/// [element].
- bool trustTypeAnnotations(MemberEntity element) {
+ bool trustTypeAnnotations(Element element) {
return _hasAnnotation(
element, _commonElements.expectTrustTypeAnnotationsClass);
}
/// Returns `true` if inference of parameter types is disabled for [element].
- bool assumeDynamic(MemberEntity element) {
+ bool assumeDynamic(Element element) {
return _hasAnnotation(element, _commonElements.expectAssumeDynamicClass);
}
/// Returns `true` if [element] is annotated with [annotationClass].
- bool _hasAnnotation(MemberEntity element, ClassEntity annotationClass) {
+ bool _hasAnnotation(Element element, ClassElement annotationClass) {
if (annotationClass == null) return false;
- for (ConstantValue value
- in _elementEnvironment.getMemberMetadata(element)) {
- if (value.isConstructedObject) {
- ConstructedConstantValue constructedConstant = value;
- if (constructedConstant.type.element == annotationClass) {
- return true;
+ return _compiler.reporter.withCurrentElement(element, () {
+ for (MetadataAnnotation metadata in element.metadata) {
+ assert(invariant(metadata, metadata.constant != null,
+ message: "Unevaluated metadata constant."));
+ ConstantValue value =
+ _compiler.constants.getConstantValue(metadata.constant);
+ if (value.isConstructedObject) {
+ ConstructedConstantValue constructedConstant = value;
+ if (constructedConstant.type.element == annotationClass) {
+ return true;
+ }
}
}
- }
- return false;
+ return false;
+ });
}
}
« no previous file with comments | « pkg/compiler/lib/src/inferrer/type_graph_nodes.dart ('k') | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698