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

Side by Side Diff: pkg/compiler/lib/src/js_backend/annotations.dart

Issue 2860893003: Revert "Make JavaScriptBackend.processAnnotations element-model agnostic" (Closed)
Patch Set: Created 3 years, 7 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 js_backend.backend.annotations; 5 library js_backend.backend.annotations;
6 6
7 import '../common_elements.dart' show CommonElements, ElementEnvironment; 7 import '../common.dart';
8 import '../common_elements.dart' show CommonElements;
9 import '../compiler.dart' show Compiler;
8 import '../constants/values.dart'; 10 import '../constants/values.dart';
9 import '../elements/entities.dart'; 11 import '../elements/elements.dart';
10 12
11 /// Handling of special annotations for tests. 13 /// Handling of special annotations for tests.
12 class OptimizerHintsForTests { 14 class OptimizerHintsForTests {
13 final ElementEnvironment _elementEnvironment; 15 final Compiler _compiler;
14 final CommonElements _commonElements;
15 16
16 OptimizerHintsForTests(this._elementEnvironment, this._commonElements); 17 OptimizerHintsForTests(this._compiler);
18
19 CommonElements get _commonElements => _compiler.commonElements;
17 20
18 /// Returns `true` if inlining is disabled for [element]. 21 /// Returns `true` if inlining is disabled for [element].
19 bool noInline(MemberEntity element) { 22 bool noInline(Element element) {
20 if (_hasAnnotation(element, _commonElements.expectNoInlineClass)) { 23 if (_hasAnnotation(element, _commonElements.expectNoInlineClass)) {
21 // TODO(floitsch): restrict to elements from the test directory. 24 // TODO(floitsch): restrict to elements from the test directory.
22 return true; 25 return true;
23 } 26 }
24 return _hasAnnotation(element, _commonElements.noInlineClass); 27 return _hasAnnotation(element, _commonElements.noInlineClass);
25 } 28 }
26 29
27 /// Returns `true` if parameter and returns types should be trusted for 30 /// Returns `true` if parameter and returns types should be trusted for
28 /// [element]. 31 /// [element].
29 bool trustTypeAnnotations(MemberEntity element) { 32 bool trustTypeAnnotations(Element element) {
30 return _hasAnnotation( 33 return _hasAnnotation(
31 element, _commonElements.expectTrustTypeAnnotationsClass); 34 element, _commonElements.expectTrustTypeAnnotationsClass);
32 } 35 }
33 36
34 /// Returns `true` if inference of parameter types is disabled for [element]. 37 /// Returns `true` if inference of parameter types is disabled for [element].
35 bool assumeDynamic(MemberEntity element) { 38 bool assumeDynamic(Element element) {
36 return _hasAnnotation(element, _commonElements.expectAssumeDynamicClass); 39 return _hasAnnotation(element, _commonElements.expectAssumeDynamicClass);
37 } 40 }
38 41
39 /// Returns `true` if [element] is annotated with [annotationClass]. 42 /// Returns `true` if [element] is annotated with [annotationClass].
40 bool _hasAnnotation(MemberEntity element, ClassEntity annotationClass) { 43 bool _hasAnnotation(Element element, ClassElement annotationClass) {
41 if (annotationClass == null) return false; 44 if (annotationClass == null) return false;
42 for (ConstantValue value 45 return _compiler.reporter.withCurrentElement(element, () {
43 in _elementEnvironment.getMemberMetadata(element)) { 46 for (MetadataAnnotation metadata in element.metadata) {
44 if (value.isConstructedObject) { 47 assert(invariant(metadata, metadata.constant != null,
45 ConstructedConstantValue constructedConstant = value; 48 message: "Unevaluated metadata constant."));
46 if (constructedConstant.type.element == annotationClass) { 49 ConstantValue value =
47 return true; 50 _compiler.constants.getConstantValue(metadata.constant);
51 if (value.isConstructedObject) {
52 ConstructedConstantValue constructedConstant = value;
53 if (constructedConstant.type.element == annotationClass) {
54 return true;
55 }
48 } 56 }
49 } 57 }
50 } 58 return false;
51 return false; 59 });
52 } 60 }
53 } 61 }
OLDNEW
« 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