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

Unified Diff: pkg/compiler/lib/src/kernel/element_map.dart

Issue 2992863002: Support forEachClassMember on closure classes (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/js_model/elements.dart ('k') | pkg/compiler/lib/src/kernel/element_map_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/kernel/element_map.dart
diff --git a/pkg/compiler/lib/src/kernel/element_map.dart b/pkg/compiler/lib/src/kernel/element_map.dart
index dfa6ae18ec7d54f3d1aecd30be165109367538d8..bf1dd2787cdc7cf1cbd139944f1ae8b22f4e6078 100644
--- a/pkg/compiler/lib/src/kernel/element_map.dart
+++ b/pkg/compiler/lib/src/kernel/element_map.dart
@@ -231,7 +231,7 @@ abstract class MemberDefinition {
/// The canonical location of [member]. This is used for sorting the members
/// in the emitted code.
- ir.Location get location;
+ SourceSpan get location;
}
enum ClassKind {
@@ -246,7 +246,7 @@ class RegularMemberDefinition implements MemberDefinition {
RegularMemberDefinition(this.member, this.node);
- ir.Location get location => node.location;
+ SourceSpan get location => computeSourceSpanFromTreeNode(node);
MemberKind get kind => MemberKind.regular;
@@ -262,7 +262,7 @@ class SpecialMemberDefinition implements MemberDefinition {
SpecialMemberDefinition(this.member, this.node, this.kind);
- ir.Location get location => node.location;
+ SourceSpan get location => computeSourceSpanFromTreeNode(node);
String toString() => 'SpecialMemberDefinition(kind:$kind,member:$member,'
'node:$node,location:$location)';
@@ -281,7 +281,7 @@ abstract class ClassDefinition {
/// The canonical location of [cls]. This is used for sorting the classes
/// in the emitted code.
- ir.Location get location;
+ SourceSpan get location;
}
/// A class directly defined by its [ir.Class] node.
@@ -291,7 +291,7 @@ class RegularClassDefinition implements ClassDefinition {
RegularClassDefinition(this.cls, this.node);
- ir.Location get location => node.location;
+ SourceSpan get location => computeSourceSpanFromTreeNode(node);
ClassKind get kind => ClassKind.regular;
@@ -431,3 +431,21 @@ abstract class KernelToLocalsMap {
int namedOrdering(ir.VariableDeclaration a, ir.VariableDeclaration b) {
return a.name.compareTo(b.name);
}
+
+SourceSpan computeSourceSpanFromTreeNode(ir.TreeNode node) {
+ // TODO(johnniwinther): Use [ir.Location] directly as a [SourceSpan].
+ Uri uri;
+ int offset;
+ while (node != null) {
+ if (node.fileOffset != ir.TreeNode.noOffset) {
+ offset = node.fileOffset;
+ uri = Uri.parse(node.location.file);
+ break;
+ }
+ node = node.parent;
+ }
+ if (uri != null) {
+ return new SourceSpan(uri, offset, offset + 1);
+ }
+ return null;
+}
« no previous file with comments | « pkg/compiler/lib/src/js_model/elements.dart ('k') | pkg/compiler/lib/src/kernel/element_map_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698