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

Unified Diff: compiler/java/com/google/dart/compiler/resolver/ClassElementImplementation.java

Issue 11776037: Initial support for mixins in dartc. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Forgot MixinScope.java Created 7 years, 11 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
Index: compiler/java/com/google/dart/compiler/resolver/ClassElementImplementation.java
diff --git a/compiler/java/com/google/dart/compiler/resolver/ClassElementImplementation.java b/compiler/java/com/google/dart/compiler/resolver/ClassElementImplementation.java
index 64d0528050d6319270dc131424b58b363d7a32a3..65aa64407bed9f11cc17bbf8413804149690d136 100644
--- a/compiler/java/com/google/dart/compiler/resolver/ClassElementImplementation.java
+++ b/compiler/java/com/google/dart/compiler/resolver/ClassElementImplementation.java
@@ -6,6 +6,7 @@ package com.google.dart.compiler.resolver;
import com.google.common.collect.Lists;
import com.google.dart.compiler.ast.DartClass;
+import com.google.dart.compiler.ast.DartClassTypeAlias;
import com.google.dart.compiler.ast.DartDeclaration;
import com.google.dart.compiler.ast.DartIdentifier;
import com.google.dart.compiler.ast.DartObsoleteMetadata;
@@ -30,6 +31,7 @@ class ClassElementImplementation extends AbstractNodeElement implements ClassNod
private InterfaceType supertype;
private InterfaceType defaultClass;
private final List<InterfaceType> interfaces = Lists.newArrayList();
+ private final List<InterfaceType> mixins = Lists.newArrayList();
private final boolean isInterface;
private final String nativeName;
private final DartObsoleteMetadata metadata;
@@ -81,6 +83,30 @@ class ClassElementImplementation extends AbstractNodeElement implements ClassNod
closeBraceOffset = -1;
}
}
+
+ ClassElementImplementation(DartClassTypeAlias node, String name,
+ LibraryElement library) {
+ super(node, name);
+ this.nativeName = null;
+ this.library = library;
+ if (node != null) {
+ isInterface = false;
+ metadata = node.getObsoleteMetadata();
+ modifiers = node.getModifiers();
+ nameLocation = node.getName().getSourceInfo();
+ declarationNameWithTypeParameter = createDeclarationName(node.getName(), node.getTypeParameters());
+ openBraceOffset = -1;
+ closeBraceOffset = -1;
+ } else {
+ isInterface = false;
+ metadata = DartObsoleteMetadata.EMPTY;
+ modifiers = Modifiers.NONE;
+ nameLocation = SourceInfo.UNKNOWN;
+ declarationNameWithTypeParameter = "";
+ openBraceOffset = -1;
+ closeBraceOffset = -1;
+ }
+ }
@Override
public DartDeclaration<?> getNode() {
@@ -162,6 +188,11 @@ class ClassElementImplementation extends AbstractNodeElement implements ClassNod
public List<InterfaceType> getInterfaces() {
return interfaces;
}
+
+ @Override
+ public List<InterfaceType> getMixins() {
+ return mixins;
+ }
@Override
public ElementKind getKind() {
@@ -218,6 +249,10 @@ class ClassElementImplementation extends AbstractNodeElement implements ClassNod
interfaces.add(type);
type.registerSubClass(this);
}
+
+ void addMixin(InterfaceType type) {
+ mixins.add(type);
+ }
Element findElement(String name) {
// Temporary find all strategy to get things working.
@@ -283,6 +318,15 @@ class ClassElementImplementation extends AbstractNodeElement implements ClassNod
String nativeNameString = (nativeName == null ? null : nativeName.getValue());
return new ClassElementImplementation(node, node.getClassName(), nativeNameString, library);
}
+
+ static class ClassAliasElementImplementation extends ClassElementImplementation implements ClassAliasElement {
+ ClassAliasElementImplementation(DartClassTypeAlias node, String name, LibraryElement library) {
+ super(node, name, library);
+ }
+ }
+ public static ClassAliasElement fromNode(DartClassTypeAlias node, LibraryElement library) {
+ return new ClassAliasElementImplementation(node, node.getClassName(), library);
+ }
public static ClassElementImplementation named(String name) {
return new ClassElementImplementation(null, name, null, null);
@@ -325,6 +369,9 @@ class ClassElementImplementation extends AbstractNodeElement implements ClassNod
for (InterfaceType intf : getInterfaces()) {
addInterfaceToSupertypes(interfaces, supertypes, intf);
}
+ for (InterfaceType mix : getMixins()) {
+ addInterfaceToSupertypes(interfaces, supertypes, mix);
+ }
for (InterfaceType intf : getInterfaces()) {
for (InterfaceType t : intf.getElement().getAllSupertypes()) {
if (!t.getElement().isObject()) {

Powered by Google App Engine
This is Rietveld 408576698