| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 abstract Node parseNode(Canceler canceler, Logger logger); | 47 abstract Node parseNode(Canceler canceler, Logger logger); |
| 48 abstract Type computeType(Compiler compiler, Types types); | 48 abstract Type computeType(Compiler compiler, Types types); |
| 49 Modifiers get modifiers() => null; | 49 Modifiers get modifiers() => null; |
| 50 | 50 |
| 51 bool isFunction() => kind == ElementKind.FUNCTION; | 51 bool isFunction() => kind == ElementKind.FUNCTION; |
| 52 bool isMember() => | 52 bool isMember() => |
| 53 enclosingElement !== null && enclosingElement.kind == ElementKind.CLASS; | 53 enclosingElement !== null && enclosingElement.kind == ElementKind.CLASS; |
| 54 bool isInstanceMember() => false; | 54 bool isInstanceMember() => false; |
| 55 bool isFactoryConstructor() => modifiers != null && modifiers.isFactory(); | 55 bool isFactoryConstructor() => modifiers != null && modifiers.isFactory(); |
| 56 bool isGenerativeConstructor() => kind == ElementKind.GENERATIVE_CONSTRUCTOR; | 56 bool isGenerativeConstructor() => kind == ElementKind.GENERATIVE_CONSTRUCTOR; |
| 57 bool isVariable() => kind == ElementKind.VARIABLE; |
| 58 bool isParameter() => kind == ElementKind.PARAMETER; |
| 57 | 59 |
| 58 bool isAssignable() { | 60 bool isAssignable() { |
| 59 if (modifiers != null && modifiers.isFinal()) return false; | 61 if (modifiers != null && modifiers.isFinal()) return false; |
| 60 if (isFunction() || isGenerativeConstructor()) return false; | 62 if (isFunction() || isGenerativeConstructor()) return false; |
| 61 return true; | 63 return true; |
| 62 } | 64 } |
| 63 | 65 |
| 64 const Element(this.name, this.kind, this.enclosingElement); | 66 const Element(this.name, this.kind, this.enclosingElement); |
| 65 | 67 |
| 66 // TODO(kasperl): This is a very bad hash code for the element and | 68 // TODO(kasperl): This is a very bad hash code for the element and |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 return (element != null) | 351 return (element != null) |
| 350 && !element.isInstanceMember() | 352 && !element.isInstanceMember() |
| 351 && (element.kind === ElementKind.FIELD); | 353 && (element.kind === ElementKind.FIELD); |
| 352 } | 354 } |
| 353 | 355 |
| 354 static bool isInstanceMethod(Element element) { | 356 static bool isInstanceMethod(Element element) { |
| 355 return (element != null) | 357 return (element != null) |
| 356 && element.isInstanceMember() | 358 && element.isInstanceMember() |
| 357 && (element.kind === ElementKind.FUNCTION); | 359 && (element.kind === ElementKind.FUNCTION); |
| 358 } | 360 } |
| 361 |
| 362 static bool isClosureSend(Send send, TreeElements elements) { |
| 363 if (send.isPropertyAccess) return false; |
| 364 if (send.receiver !== null) return false; |
| 365 Element element = elements[send]; |
| 366 // (o)() or foo()(). |
| 367 if (element === null && send.selector.asIdentifier() === null) return true; |
| 368 // foo() with foo a local or a parameter. |
| 369 return element.isVariable() || element.isParameter(); |
| 370 } |
| 359 } | 371 } |
| OLD | NEW |