Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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.modelx; | 5 library elements.modelx; |
| 6 | 6 |
| 7 import 'elements.dart'; | 7 import 'elements.dart'; |
| 8 import '../constants/expressions.dart'; | 8 import '../constants/expressions.dart'; |
| 9 import '../helpers/helpers.dart'; // Included for debug helpers. | 9 import '../helpers/helpers.dart'; // Included for debug helpers. |
| 10 import '../tree/tree.dart'; | 10 import '../tree/tree.dart'; |
| (...skipping 2026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2037 * A constructor that is not defined in the source code but rather implied by | 2037 * A constructor that is not defined in the source code but rather implied by |
| 2038 * the language semantics. | 2038 * the language semantics. |
| 2039 * | 2039 * |
| 2040 * This class is used to represent default constructors and forwarding | 2040 * This class is used to represent default constructors and forwarding |
| 2041 * constructors for mixin applications. | 2041 * constructors for mixin applications. |
| 2042 */ | 2042 */ |
| 2043 class SynthesizedConstructorElementX extends ConstructorElementX { | 2043 class SynthesizedConstructorElementX extends ConstructorElementX { |
| 2044 final ConstructorElement definingConstructor; | 2044 final ConstructorElement definingConstructor; |
| 2045 final bool isDefaultConstructor; | 2045 final bool isDefaultConstructor; |
| 2046 | 2046 |
| 2047 SynthesizedConstructorElementX(String name, | 2047 SynthesizedConstructorElementX.notForDefault(String name, |
| 2048 this.definingConstructor, | 2048 this.definingConstructor, |
|
Johnni Winther
2015/04/10 13:37:16
Bad indent.
sigurdm
2015/04/13 07:35:17
Done.
| |
| 2049 Element enclosing, | 2049 Element enclosing) |
| 2050 this.isDefaultConstructor) | 2050 : isDefaultConstructor = false, |
| 2051 : super(name, | 2051 super(name, |
| 2052 ElementKind.GENERATIVE_CONSTRUCTOR, | 2052 ElementKind.GENERATIVE_CONSTRUCTOR, |
| 2053 Modifiers.EMPTY, | 2053 Modifiers.EMPTY, |
| 2054 enclosing); | 2054 enclosing) ; |
| 2055 | 2055 |
| 2056 SynthesizedConstructorElementX.forDefault(superMember, Element enclosing) | 2056 SynthesizedConstructorElementX.forDefault(this.definingConstructor, |
| 2057 : this('', superMember, enclosing, true); | 2057 Element enclosing) |
| 2058 : isDefaultConstructor = true, | |
| 2059 super('', | |
| 2060 ElementKind.GENERATIVE_CONSTRUCTOR, | |
| 2061 Modifiers.EMPTY, | |
| 2062 enclosing) { | |
| 2063 typeCache = new FunctionType.synthesized(enclosingClass.thisType); | |
| 2064 } | |
| 2058 | 2065 |
| 2059 FunctionExpression parseNode(DiagnosticListener listener) => null; | 2066 FunctionExpression parseNode(DiagnosticListener listener) => null; |
| 2060 | 2067 |
| 2061 bool get hasNode => false; | 2068 bool get hasNode => false; |
| 2062 | 2069 |
| 2063 FunctionExpression get node => null; | 2070 FunctionExpression get node => null; |
| 2064 | 2071 |
| 2065 Token get position => enclosingElement.position; | 2072 Token get position => enclosingElement.position; |
| 2066 | 2073 |
| 2067 bool get isSynthesized => true; | 2074 bool get isSynthesized => true; |
| 2068 | 2075 |
| 2076 DartType get type { | |
| 2077 if (isDefaultConstructor) { | |
| 2078 return super.type; | |
| 2079 } else { | |
| 2080 // TODO(johnniwinther): Ensure that the function type substitutes type | |
| 2081 // variables correctly. | |
| 2082 return definingConstructor.type; | |
| 2083 } | |
| 2084 } | |
| 2085 | |
| 2069 FunctionSignature computeSignature(compiler) { | 2086 FunctionSignature computeSignature(compiler) { |
| 2070 if (functionSignatureCache != null) return functionSignatureCache; | 2087 if (functionSignatureCache != null) return functionSignatureCache; |
| 2071 if (isDefaultConstructor) { | 2088 if (isDefaultConstructor) { |
| 2072 return functionSignatureCache = new FunctionSignatureX( | 2089 return functionSignatureCache = new FunctionSignatureX( |
| 2073 type: new FunctionType(this, enclosingClass.thisType)); | 2090 type: type); |
| 2074 } | 2091 } |
| 2075 if (definingConstructor.isErroneous) { | 2092 if (definingConstructor.isErroneous) { |
| 2076 return functionSignatureCache = | 2093 return functionSignatureCache = |
| 2077 compiler.objectClass.localLookup('').computeSignature(compiler); | 2094 compiler.objectClass.localLookup('').computeSignature(compiler); |
| 2078 } | 2095 } |
| 2079 // TODO(johnniwinther): Ensure that the function signature (and with it the | 2096 // TODO(johnniwinther): Ensure that the function signature (and with it the |
| 2080 // function type) substitutes type variables correctly. | 2097 // function type) substitutes type variables correctly. |
| 2081 return functionSignatureCache = | 2098 return functionSignatureCache = |
| 2082 definingConstructor.computeSignature(compiler); | 2099 definingConstructor.computeSignature(compiler); |
| 2083 } | 2100 } |
| (...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3060 AstElement get definingElement; | 3077 AstElement get definingElement; |
| 3061 | 3078 |
| 3062 bool get hasResolvedAst => definingElement.hasTreeElements; | 3079 bool get hasResolvedAst => definingElement.hasTreeElements; |
| 3063 | 3080 |
| 3064 ResolvedAst get resolvedAst { | 3081 ResolvedAst get resolvedAst { |
| 3065 return new ResolvedAst(declaration, | 3082 return new ResolvedAst(declaration, |
| 3066 definingElement.node, definingElement.treeElements); | 3083 definingElement.node, definingElement.treeElements); |
| 3067 } | 3084 } |
| 3068 | 3085 |
| 3069 } | 3086 } |
| OLD | NEW |