| 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 part of resolution; | 5 part of resolution; |
| 6 | 6 |
| 7 /// The state of constants in resolutions. | 7 /// The state of constants in resolutions. |
| 8 enum ConstantState { | 8 enum ConstantState { |
| 9 /// Expressions are not required to be constants. | 9 /// Expressions are not required to be constants. |
| 10 NON_CONSTANT, | 10 NON_CONSTANT, |
| (...skipping 1961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1972 } | 1972 } |
| 1973 | 1973 |
| 1974 /// Handle a [Send] that resolves to a [prefix]. Like `prefix` in | 1974 /// Handle a [Send] that resolves to a [prefix]. Like `prefix` in |
| 1975 /// `prefix.Class` or `prefix` in `prefix()`, the latter being a compile time | 1975 /// `prefix.Class` or `prefix` in `prefix()`, the latter being a compile time |
| 1976 /// error. | 1976 /// error. |
| 1977 ResolutionResult handleLibraryPrefix( | 1977 ResolutionResult handleLibraryPrefix( |
| 1978 Send node, | 1978 Send node, |
| 1979 Name name, | 1979 Name name, |
| 1980 PrefixElement prefix) { | 1980 PrefixElement prefix) { |
| 1981 if ((ElementCategory.PREFIX & allowedCategory) == 0) { | 1981 if ((ElementCategory.PREFIX & allowedCategory) == 0) { |
| 1982 compiler.reportError( | 1982 ErroneousElement error = reportAndCreateErroneousElement( |
| 1983 node, | 1983 node, |
| 1984 name.text, |
| 1984 MessageKind.PREFIX_AS_EXPRESSION, | 1985 MessageKind.PREFIX_AS_EXPRESSION, |
| 1985 {'prefix': name}); | 1986 {'prefix': name}, |
| 1986 return const NoneResult(); | 1987 isError: true); |
| 1988 return handleErroneousAccess( |
| 1989 node, name, error, new StaticAccess.invalid(error)); |
| 1987 } | 1990 } |
| 1988 if (prefix.isDeferred) { | 1991 if (prefix.isDeferred) { |
| 1989 // TODO(johnniwinther): Remove this when deferred access is detected | 1992 // TODO(johnniwinther): Remove this when deferred access is detected |
| 1990 // through a [SendStructure]. | 1993 // through a [SendStructure]. |
| 1991 registry.useElement(node.selector, prefix); | 1994 registry.useElement(node.selector, prefix); |
| 1992 } | 1995 } |
| 1993 registry.useElement(node, prefix); | 1996 registry.useElement(node, prefix); |
| 1994 return new PrefixResult(prefix, null); | 1997 return new PrefixResult(prefix, null); |
| 1995 } | 1998 } |
| 1996 | 1999 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2055 return handleDynamicAccessSemantics(node, name, semantics); | 2058 return handleDynamicAccessSemantics(node, name, semantics); |
| 2056 } | 2059 } |
| 2057 | 2060 |
| 2058 /// Handle `this` as a qualified property, like `a.this`. | 2061 /// Handle `this` as a qualified property, like `a.this`. |
| 2059 ResolutionResult handleQualifiedThisAccess(Send node, Name name) { | 2062 ResolutionResult handleQualifiedThisAccess(Send node, Name name) { |
| 2060 ErroneousElement error = reportAndCreateErroneousElement( | 2063 ErroneousElement error = reportAndCreateErroneousElement( |
| 2061 node.selector, | 2064 node.selector, |
| 2062 name.text, | 2065 name.text, |
| 2063 MessageKind.THIS_PROPERTY, {}, | 2066 MessageKind.THIS_PROPERTY, {}, |
| 2064 isError: true); | 2067 isError: true); |
| 2065 // TODO(johnniwinther): Support `this` as property as an [AccessSemantics]. | 2068 AccessSemantics accessSemantics = new StaticAccess.invalid(error); |
| 2066 AccessSemantics accessSemantics = new StaticAccess.unresolved(error); | |
| 2067 return handleErroneousAccess(node, name, error, accessSemantics); | 2069 return handleErroneousAccess(node, name, error, accessSemantics); |
| 2068 } | 2070 } |
| 2069 | 2071 |
| 2070 /// Handle a qualified [Send], that is where the receiver is non-null, like | 2072 /// Handle a qualified [Send], that is where the receiver is non-null, like |
| 2071 /// `a.b`, `a.b()`, `this.a()` and `super.a()`. | 2073 /// `a.b`, `a.b()`, `this.a()` and `super.a()`. |
| 2072 ResolutionResult handleQualifiedSend(Send node) { | 2074 ResolutionResult handleQualifiedSend(Send node) { |
| 2073 Identifier selector = node.selector.asIdentifier(); | 2075 Identifier selector = node.selector.asIdentifier(); |
| 2074 String text = selector.source; | 2076 String text = selector.source; |
| 2075 Name name = new Name(text, enclosingElement.library); | 2077 Name name = new Name(text, enclosingElement.library); |
| 2076 if (text == 'this') { | 2078 if (text == 'this') { |
| (...skipping 1742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3819 } | 3821 } |
| 3820 return const NoneResult(); | 3822 return const NoneResult(); |
| 3821 } | 3823 } |
| 3822 } | 3824 } |
| 3823 | 3825 |
| 3824 /// Looks up [name] in [scope] and unwraps the result. | 3826 /// Looks up [name] in [scope] and unwraps the result. |
| 3825 Element lookupInScope(Compiler compiler, Node node, | 3827 Element lookupInScope(Compiler compiler, Node node, |
| 3826 Scope scope, String name) { | 3828 Scope scope, String name) { |
| 3827 return Elements.unwrap(scope.lookup(name), compiler, node); | 3829 return Elements.unwrap(scope.lookup(name), compiler, node); |
| 3828 } | 3830 } |
| OLD | NEW |