| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 abstract Type computeType(Compiler compiler, Types types); | 50 abstract Type computeType(Compiler compiler, Types types); |
| 51 Modifiers get modifiers() => null; | 51 Modifiers get modifiers() => null; |
| 52 | 52 |
| 53 bool isFunction() => kind == ElementKind.FUNCTION; | 53 bool isFunction() => kind == ElementKind.FUNCTION; |
| 54 bool isMember() => | 54 bool isMember() => |
| 55 enclosingElement !== null && enclosingElement.kind == ElementKind.CLASS; | 55 enclosingElement !== null && enclosingElement.kind == ElementKind.CLASS; |
| 56 bool isInstanceMember() => false; | 56 bool isInstanceMember() => false; |
| 57 bool isFactoryConstructor() => modifiers != null && modifiers.isFactory(); | 57 bool isFactoryConstructor() => modifiers != null && modifiers.isFactory(); |
| 58 bool isGenerativeConstructor() => kind == ElementKind.GENERATIVE_CONSTRUCTOR; | 58 bool isGenerativeConstructor() => kind == ElementKind.GENERATIVE_CONSTRUCTOR; |
| 59 bool isCompilationUnit() => kind == ElementKind.COMPILATION_UNIT; | 59 bool isCompilationUnit() => kind == ElementKind.COMPILATION_UNIT; |
| 60 bool isVariable() => kind == ElementKind.VARIABLE; |
| 61 bool isParameter() => kind == ElementKind.PARAMETER; |
| 60 | 62 |
| 61 bool isAssignable() { | 63 bool isAssignable() { |
| 62 if (modifiers != null && modifiers.isFinal()) return false; | 64 if (modifiers != null && modifiers.isFinal()) return false; |
| 63 if (isFunction() || isGenerativeConstructor()) return false; | 65 if (isFunction() || isGenerativeConstructor()) return false; |
| 64 return true; | 66 return true; |
| 65 } | 67 } |
| 66 | 68 |
| 67 const Element(this.name, this.kind, this.enclosingElement); | 69 const Element(this.name, this.kind, this.enclosingElement); |
| 68 | 70 |
| 69 // TODO(kasperl): This is a very bad hash code for the element and | 71 // TODO(kasperl): This is a very bad hash code for the element and |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 return (element != null) | 364 return (element != null) |
| 363 && !element.isInstanceMember() | 365 && !element.isInstanceMember() |
| 364 && (element.kind === ElementKind.FIELD); | 366 && (element.kind === ElementKind.FIELD); |
| 365 } | 367 } |
| 366 | 368 |
| 367 static bool isInstanceMethod(Element element) { | 369 static bool isInstanceMethod(Element element) { |
| 368 return (element != null) | 370 return (element != null) |
| 369 && element.isInstanceMember() | 371 && element.isInstanceMember() |
| 370 && (element.kind === ElementKind.FUNCTION); | 372 && (element.kind === ElementKind.FUNCTION); |
| 371 } | 373 } |
| 374 |
| 375 static bool isClosureSend(Send send, TreeElements elements) { |
| 376 if (send.isPropertyAccess) return false; |
| 377 if (send.receiver !== null) return false; |
| 378 Element element = elements[send]; |
| 379 // (o)() or foo()(). |
| 380 if (element === null && send.selector.asIdentifier() === null) return true; |
| 381 // foo() with foo a local or a parameter. |
| 382 return element.isVariable() || element.isParameter(); |
| 383 } |
| 372 } | 384 } |
| OLD | NEW |