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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_backend/backend.dart

Issue 23045004: Throw when reflecting on elements not covered by a `MirrorsUsed` annotation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address Nicolas' comments. Created 7 years, 3 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
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of js_backend; 5 part of js_backend;
6 6
7 class JavaScriptItemCompilationContext extends ItemCompilationContext { 7 class JavaScriptItemCompilationContext extends ItemCompilationContext {
8 final Set<HInstruction> boundsChecked; 8 final Set<HInstruction> boundsChecked;
9 9
10 JavaScriptItemCompilationContext() 10 JavaScriptItemCompilationContext()
(...skipping 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 targetsUsed.add(field.getter); 1548 targetsUsed.add(field.getter);
1549 targetsUsed.add(field.setter); 1549 targetsUsed.add(field.setter);
1550 } else { 1550 } else {
1551 targetsUsed.add(target); 1551 targetsUsed.add(target);
1552 } 1552 }
1553 } 1553 }
1554 } 1554 }
1555 if (metaTargets != null) metaTargetsUsed.addAll(metaTargets); 1555 if (metaTargets != null) metaTargetsUsed.addAll(metaTargets);
1556 } 1556 }
1557 1557
1558 /**
1559 * Returns `true` if [element] can be accessed through reflection, that is,
1560 * is in the set of elements covered by a `MirrorsUsed` annotation.
1561 *
1562 * This property is used to tag emitted elements with a marker which is
1563 * checked by the runtime system to throw an exception if an element is
1564 * accessed (invoked, get, set) that is not accessible for the reflective
1565 * system.
1566 */
1567 bool isAccessibleByReflection(Element element) {
1568 if (hasInsufficientMirrorsUsed) return true;
1569 return isNeededForReflection(element);
1570 }
1571
1572 /**
1573 * Returns `true` if the emitter must emit the element even though there
1574 * is no direct use in the program, but because the reflective system may
1575 * need to access it.
1576 */
1558 bool isNeededForReflection(Element element) { 1577 bool isNeededForReflection(Element element) {
1559 if (hasInsufficientMirrorsUsed) return isTreeShakingDisabled; 1578 if (hasInsufficientMirrorsUsed) return isTreeShakingDisabled;
1560 /// Record the name of [element] in [symbolsUsed]. Return true for 1579 /// Record the name of [element] in [symbolsUsed]. Return true for
1561 /// convenience. 1580 /// convenience.
1562 bool registerNameOf(Element element) { 1581 bool registerNameOf(Element element) {
1563 symbolsUsed.add(element.name.slowToString()); 1582 symbolsUsed.add(element.name.slowToString());
1564 if (element.isConstructor()) { 1583 if (element.isConstructor()) {
1565 symbolsUsed.add(element.getEnclosingClass().name.slowToString()); 1584 symbolsUsed.add(element.getEnclosingClass().name.slowToString());
1566 } 1585 }
1567 return true; 1586 return true;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 copy(constant.values); 1661 copy(constant.values);
1643 copy(constant.protoValue); 1662 copy(constant.protoValue);
1644 copy(constant); 1663 copy(constant);
1645 } 1664 }
1646 1665
1647 void visitConstructed(ConstructedConstant constant) { 1666 void visitConstructed(ConstructedConstant constant) {
1648 copy(constant.fields); 1667 copy(constant.fields);
1649 copy(constant); 1668 copy(constant);
1650 } 1669 }
1651 } 1670 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698