Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #library('elements'); | 5 #library('elements'); |
| 6 | 6 |
| 7 #import('../tree/tree.dart'); | 7 #import('../tree/tree.dart'); |
| 8 #import('../scanner/scannerlib.dart'); | 8 #import('../scanner/scannerlib.dart'); |
| 9 #import('../leg.dart'); // TODO(karlklose): we only need type. | 9 #import('../leg.dart'); // TODO(karlklose): we only need type. |
| 10 #import('../util/util.dart'); | 10 #import('../util/util.dart'); |
| (...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1023 | 1023 |
| 1024 void addMember(Element element, DiagnosticListener listener) { | 1024 void addMember(Element element, DiagnosticListener listener) { |
| 1025 members = members.prepend(element); | 1025 members = members.prepend(element); |
| 1026 if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR || | 1026 if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR || |
| 1027 element.modifiers.isFactory()) { | 1027 element.modifiers.isFactory()) { |
| 1028 constructors[element.name] = element; | 1028 constructors[element.name] = element; |
| 1029 } else if (element.kind == ElementKind.GETTER | 1029 } else if (element.kind == ElementKind.GETTER |
| 1030 || element.kind == ElementKind.SETTER) { | 1030 || element.kind == ElementKind.SETTER) { |
| 1031 addGetterOrSetter(element, localMembers[element.name], listener); | 1031 addGetterOrSetter(element, localMembers[element.name], listener); |
| 1032 } else { | 1032 } else { |
| 1033 localMembers[element.name] = element; | 1033 Element existing = localMembers.putIfAbsent(element.name, () => element); |
| 1034 if (existing !== element) { | |
| 1035 listener.cancel('duplicate definition', token: element.position()); | |
| 1036 listener.cancel('existing definition', token: existing.position()); | |
|
Lasse Reichstein Nielsen
2012/08/14 10:28:24
What's the right way to do this?
| |
| 1037 } | |
| 1034 } | 1038 } |
| 1035 } | 1039 } |
| 1036 | 1040 |
| 1037 InterfaceType computeType(compiler) { | 1041 InterfaceType computeType(compiler) { |
| 1038 if (type == null) { | 1042 if (type == null) { |
| 1039 ClassNode node = parseNode(compiler); | 1043 ClassNode node = parseNode(compiler); |
| 1040 Link<Type> parameters = | 1044 Link<Type> parameters = |
| 1041 TypeDeclarationElement.createTypeVariables(this, node.typeParameters); | 1045 TypeDeclarationElement.createTypeVariables(this, node.typeParameters); |
| 1042 type = new InterfaceType(this, parameters); | 1046 type = new InterfaceType(this, parameters); |
| 1043 } | 1047 } |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1412 Node parseNode(compiler) => cachedNode; | 1416 Node parseNode(compiler) => cachedNode; |
| 1413 | 1417 |
| 1414 String toString() => "${enclosingElement.toString()}.${name.slowToString()}"; | 1418 String toString() => "${enclosingElement.toString()}.${name.slowToString()}"; |
| 1415 | 1419 |
| 1416 TypeVariableElement cloneTo(Element enclosing, DiagnosticListener listener) { | 1420 TypeVariableElement cloneTo(Element enclosing, DiagnosticListener listener) { |
| 1417 TypeVariableElement result = | 1421 TypeVariableElement result = |
| 1418 new TypeVariableElement(name, enclosing, node, type, bound); | 1422 new TypeVariableElement(name, enclosing, node, type, bound); |
| 1419 return result; | 1423 return result; |
| 1420 } | 1424 } |
| 1421 } | 1425 } |
| OLD | NEW |