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

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

Issue 2854013002: Make JavaScriptBackend.processAnnotations element-model agnostic (Closed)
Patch Set: Fix and check declaration invariant. 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 4921f94ee7dd2a283a472e0e7f472c1ee23f9f26..78a78f60ad6cdace4852308ac01a502bb5431efa 100644
--- a/pkg/compiler/lib/src/js_backend/annotations.dart
+++ b/pkg/compiler/lib/src/js_backend/annotations.dart
@@ -4,22 +4,19 @@
library js_backend.backend.annotations;
-import '../common.dart';
-import '../common_elements.dart' show CommonElements;
-import '../compiler.dart' show Compiler;
+import '../common_elements.dart' show CommonElements, ElementEnvironment;
import '../constants/values.dart';
-import '../elements/elements.dart';
+import '../elements/entities.dart';
/// Handling of special annotations for tests.
class OptimizerHintsForTests {
- final Compiler _compiler;
+ final ElementEnvironment _elementEnvironment;
+ final CommonElements _commonElements;
- OptimizerHintsForTests(this._compiler);
-
- CommonElements get _commonElements => _compiler.commonElements;
+ OptimizerHintsForTests(this._elementEnvironment, this._commonElements);
/// Returns `true` if inlining is disabled for [element].
- bool noInline(Element element) {
+ bool noInline(MemberEntity element) {
if (_hasAnnotation(element, _commonElements.expectNoInlineClass)) {
// TODO(floitsch): restrict to elements from the test directory.
return true;
@@ -29,33 +26,28 @@ class OptimizerHintsForTests {
/// Returns `true` if parameter and returns types should be trusted for
/// [element].
- bool trustTypeAnnotations(Element element) {
+ bool trustTypeAnnotations(MemberEntity element) {
return _hasAnnotation(
element, _commonElements.expectTrustTypeAnnotationsClass);
}
/// Returns `true` if inference of parameter types is disabled for [element].
- bool assumeDynamic(Element element) {
+ bool assumeDynamic(MemberEntity element) {
return _hasAnnotation(element, _commonElements.expectAssumeDynamicClass);
}
/// Returns `true` if [element] is annotated with [annotationClass].
- bool _hasAnnotation(Element element, ClassElement annotationClass) {
+ bool _hasAnnotation(MemberEntity element, ClassEntity annotationClass) {
if (annotationClass == null) return false;
- 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;
- }
+ for (ConstantValue value
+ in _elementEnvironment.getMemberMetadata(element)) {
+ 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