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

Side by Side Diff: compiler/java/com/google/dart/compiler/ast/DartClass.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 unified diff | Download patch | Annotate | Revision Log
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 package com.google.dart.compiler.ast; 5 package com.google.dart.compiler.ast;
6 6
7 import com.google.dart.compiler.resolver.ClassNodeElement; 7 import com.google.dart.compiler.resolver.ClassNodeElement;
8 import com.google.dart.compiler.resolver.Element; 8 import com.google.dart.compiler.resolver.Element;
9 9
10 import java.util.List; 10 import java.util.List;
11 11
12 /** 12 /**
13 * Represents a Dart class. 13 * Represents a Dart class.
14 */ 14 */
15 public class DartClass extends DartDeclaration<DartIdentifier> { 15 public class DartClass extends DartDeclaration<DartIdentifier> {
16 16
17 private ClassNodeElement element; 17 private ClassNodeElement element;
18 18
19 private DartTypeNode superclass; 19 private DartTypeNode superclass;
20 20
21 private final NodeList<DartNode> members = NodeList.create(this); 21 private final NodeList<DartNode> members = NodeList.create(this);
22 private final NodeList<DartTypeParameter> typeParameters = NodeList.create(thi s); 22 private final NodeList<DartTypeParameter> typeParameters = NodeList.create(thi s);
23 private final NodeList<DartTypeNode> interfaces = NodeList.create(this); 23 private final NodeList<DartTypeNode> interfaces = NodeList.create(this);
24 private final NodeList<DartTypeNode> mixins = NodeList.create(this);
24 25
25 private boolean isInterface; 26 private boolean isInterface;
26 private DartParameterizedTypeNode defaultClass; 27 private DartParameterizedTypeNode defaultClass;
27 private final Modifiers modifiers; 28 private final Modifiers modifiers;
28 29
29 // If the Dart class is implemented by a native JS class the nativeName 30 // If the Dart class is implemented by a native JS class the nativeName
30 // points to the JS class. Otherwise it is null. 31 // points to the JS class. Otherwise it is null.
31 private final DartStringLiteral nativeName; 32 private final DartStringLiteral nativeName;
32 33
33 private final int tokenOffset; 34 private final int tokenOffset;
34 private final int tokenLength; 35 private final int tokenLength;
35 private final int defaultTokenOffset; 36 private final int defaultTokenOffset;
36 private final int implementsOffset; 37 private final int implementsOffset;
37 private final int openBraceOffset; 38 private final int openBraceOffset;
38 private final int closeBraceOffset; 39 private final int closeBraceOffset;
39 40
40 public DartClass(int tokenOffset, int tokenLength, DartIdentifier name, 41 public DartClass(int tokenOffset, int tokenLength, DartIdentifier name,
41 DartStringLiteral nativeName, DartTypeNode superclass, int implementsOffse t, 42 DartStringLiteral nativeName, DartTypeNode superclass, int implementsOffse t,
42 List<DartTypeNode> interfaces, int defaultTokenOffset, int openBraceOffset , 43 List<DartTypeNode> interfaces, List<DartTypeNode> mixins, int defaultToken Offset,
43 int closeBraceOffset, List<DartNode> members, List<DartTypeParameter> type Parameters,
44 Modifiers modifiers) {
45 this(tokenOffset, tokenLength, name, nativeName, superclass, implementsOffse t, interfaces,
46 defaultTokenOffset, openBraceOffset, closeBraceOffset, members, typePara meters, null,
47 false, modifiers);
48 }
49
50 public DartClass(int tokenOffset, int tokenLength, DartIdentifier name, DartTy peNode superclass,
51 int implementsOffset, List<DartTypeNode> interfaces, int defaultTokenOffse t,
52 int openBraceOffset, int closeBraceOffset, List<DartNode> members, 44 int openBraceOffset, int closeBraceOffset, List<DartNode> members,
53 List<DartTypeParameter> typeParameters, DartParameterizedTypeNode defaultC lass) { 45 List<DartTypeParameter> typeParameters, DartParameterizedTypeNode defaultC lass,
54 this(tokenOffset, tokenLength, name, null, superclass, implementsOffset, int erfaces, 46 boolean isInterface, Modifiers modifiers) {
55 defaultTokenOffset, openBraceOffset, closeBraceOffset, members, typePara meters,
56 defaultClass, true, Modifiers.NONE);
57 }
58
59 public DartClass(int tokenOffset, int tokenLength, DartIdentifier name,
60 DartStringLiteral nativeName, DartTypeNode superclass, int implementsOffse t,
61 List<DartTypeNode> interfaces, int defaultTokenOffset, int openBraceOffset ,
62 int closeBraceOffset, List<DartNode> members, List<DartTypeParameter> type Parameters,
63 DartParameterizedTypeNode defaultClass, boolean isInterface, Modifiers mod ifiers) {
64 super(name); 47 super(name);
65 this.tokenOffset = tokenOffset; 48 this.tokenOffset = tokenOffset;
66 this.tokenLength = tokenLength; 49 this.tokenLength = tokenLength;
67 this.nativeName = becomeParentOf(nativeName); 50 this.nativeName = becomeParentOf(nativeName);
68 this.superclass = becomeParentOf(superclass); 51 this.superclass = becomeParentOf(superclass);
69 this.defaultTokenOffset = defaultTokenOffset; 52 this.defaultTokenOffset = defaultTokenOffset;
70 this.openBraceOffset = openBraceOffset; 53 this.openBraceOffset = openBraceOffset;
71 this.closeBraceOffset = closeBraceOffset; 54 this.closeBraceOffset = closeBraceOffset;
72 this.members.addAll(members); 55 this.members.addAll(members);
73 this.typeParameters.addAll(typeParameters); 56 this.typeParameters.addAll(typeParameters);
74 this.implementsOffset = implementsOffset; 57 this.implementsOffset = implementsOffset;
75 this.interfaces.addAll(interfaces); 58 this.interfaces.addAll(interfaces);
59 this.mixins.addAll(mixins);
76 this.defaultClass = becomeParentOf(defaultClass); 60 this.defaultClass = becomeParentOf(defaultClass);
77 this.isInterface = isInterface; 61 this.isInterface = isInterface;
78 this.modifiers = modifiers; 62 this.modifiers = modifiers;
79 } 63 }
80 64
81 public boolean isInterface() { 65 public boolean isInterface() {
82 return isInterface; 66 return isInterface;
83 } 67 }
84 68
85 public Modifiers getModifiers() { 69 public Modifiers getModifiers() {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 return typeParameters; 121 return typeParameters;
138 } 122 }
139 123
140 public int getImplementsOffset() { 124 public int getImplementsOffset() {
141 return implementsOffset; 125 return implementsOffset;
142 } 126 }
143 127
144 public List<DartTypeNode> getInterfaces() { 128 public List<DartTypeNode> getInterfaces() {
145 return interfaces; 129 return interfaces;
146 } 130 }
131
132 public NodeList<DartTypeNode> getMixins() {
133 return mixins;
134 }
147 135
148 public String getClassName() { 136 public String getClassName() {
149 if (getName() == null) { 137 if (getName() == null) {
150 return null; 138 return null;
151 } 139 }
152 return getName().getName(); 140 return getName().getName();
153 } 141 }
154 142
155 public DartTypeNode getSuperclass() { 143 public DartTypeNode getSuperclass() {
156 return superclass; 144 return superclass;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 public DartStringLiteral getNativeName() { 185 public DartStringLiteral getNativeName() {
198 return nativeName; 186 return nativeName;
199 } 187 }
200 188
201 @Override 189 @Override
202 public void visitChildren(ASTVisitor<?> visitor) { 190 public void visitChildren(ASTVisitor<?> visitor) {
203 super.visitChildren(visitor); 191 super.visitChildren(visitor);
204 typeParameters.accept(visitor); 192 typeParameters.accept(visitor);
205 safelyVisitChild(superclass, visitor); 193 safelyVisitChild(superclass, visitor);
206 interfaces.accept(visitor); 194 interfaces.accept(visitor);
195 mixins.accept(visitor);
207 safelyVisitChild(defaultClass, visitor); 196 safelyVisitChild(defaultClass, visitor);
208 members.accept(visitor); 197 members.accept(visitor);
209 } 198 }
210 199
211 @Override 200 @Override
212 public <R> R accept(ASTVisitor<R> visitor) { 201 public <R> R accept(ASTVisitor<R> visitor) {
213 return visitor.visitClass(this); 202 return visitor.visitClass(this);
214 } 203 }
215 } 204 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698