| 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 2036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2047 * A constructor that is not defined in the source code but rather implied by | 2047 * A constructor that is not defined in the source code but rather implied by |
| 2048 * the language semantics. | 2048 * the language semantics. |
| 2049 * | 2049 * |
| 2050 * This class is used to represent default constructors and forwarding | 2050 * This class is used to represent default constructors and forwarding |
| 2051 * constructors for mixin applications. | 2051 * constructors for mixin applications. |
| 2052 */ | 2052 */ |
| 2053 class SynthesizedConstructorElementX extends ConstructorElementX { | 2053 class SynthesizedConstructorElementX extends ConstructorElementX { |
| 2054 final ConstructorElement definingConstructor; | 2054 final ConstructorElement definingConstructor; |
| 2055 final bool isDefaultConstructor; | 2055 final bool isDefaultConstructor; |
| 2056 | 2056 |
| 2057 SynthesizedConstructorElementX.notForDefault(String name, | 2057 SynthesizedConstructorElementX(String name, |
| 2058 this.definingConstructor, | 2058 this.definingConstructor, |
| 2059 Element enclosing) | 2059 Element enclosing, |
| 2060 : isDefaultConstructor = false, | 2060 this.isDefaultConstructor) |
| 2061 super(name, | 2061 : super(name, |
| 2062 ElementKind.GENERATIVE_CONSTRUCTOR, | 2062 ElementKind.GENERATIVE_CONSTRUCTOR, |
| 2063 Modifiers.EMPTY, | 2063 Modifiers.EMPTY, |
| 2064 enclosing) ; | 2064 enclosing); |
| 2065 | 2065 |
| 2066 SynthesizedConstructorElementX.forDefault(this.definingConstructor, | 2066 SynthesizedConstructorElementX.forDefault(superMember, Element enclosing) |
| 2067 Element enclosing) | 2067 : this('', superMember, enclosing, true); |
| 2068 : isDefaultConstructor = true, | |
| 2069 super('', | |
| 2070 ElementKind.GENERATIVE_CONSTRUCTOR, | |
| 2071 Modifiers.EMPTY, | |
| 2072 enclosing) { | |
| 2073 typeCache = new FunctionType.synthesized(enclosingClass.thisType); | |
| 2074 } | |
| 2075 | 2068 |
| 2076 FunctionExpression parseNode(DiagnosticListener listener) => null; | 2069 FunctionExpression parseNode(DiagnosticListener listener) => null; |
| 2077 | 2070 |
| 2078 bool get hasNode => false; | 2071 bool get hasNode => false; |
| 2079 | 2072 |
| 2080 FunctionExpression get node => null; | 2073 FunctionExpression get node => null; |
| 2081 | 2074 |
| 2082 Token get position => enclosingElement.position; | 2075 Token get position => enclosingElement.position; |
| 2083 | 2076 |
| 2084 bool get isSynthesized => true; | 2077 bool get isSynthesized => true; |
| 2085 | 2078 |
| 2086 DartType get type { | |
| 2087 if (isDefaultConstructor) { | |
| 2088 return super.type; | |
| 2089 } else { | |
| 2090 // TODO(johnniwinther): Ensure that the function type substitutes type | |
| 2091 // variables correctly. | |
| 2092 return definingConstructor.type; | |
| 2093 } | |
| 2094 } | |
| 2095 | |
| 2096 FunctionSignature computeSignature(compiler) { | 2079 FunctionSignature computeSignature(compiler) { |
| 2097 if (functionSignatureCache != null) return functionSignatureCache; | 2080 if (functionSignatureCache != null) return functionSignatureCache; |
| 2098 if (isDefaultConstructor) { | 2081 if (isDefaultConstructor) { |
| 2099 return functionSignatureCache = new FunctionSignatureX( | 2082 return functionSignatureCache = new FunctionSignatureX( |
| 2100 type: type); | 2083 type: new FunctionType(this, enclosingClass.thisType)); |
| 2101 } | 2084 } |
| 2102 if (definingConstructor.isErroneous) { | 2085 if (definingConstructor.isErroneous) { |
| 2103 return functionSignatureCache = | 2086 return functionSignatureCache = |
| 2104 compiler.objectClass.localLookup('').computeSignature(compiler); | 2087 compiler.objectClass.localLookup('').computeSignature(compiler); |
| 2105 } | 2088 } |
| 2106 // TODO(johnniwinther): Ensure that the function signature (and with it the | 2089 // TODO(johnniwinther): Ensure that the function signature (and with it the |
| 2107 // function type) substitutes type variables correctly. | 2090 // function type) substitutes type variables correctly. |
| 2108 return functionSignatureCache = | 2091 return functionSignatureCache = |
| 2109 definingConstructor.computeSignature(compiler); | 2092 definingConstructor.computeSignature(compiler); |
| 2110 } | 2093 } |
| (...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3087 AstElement get definingElement; | 3070 AstElement get definingElement; |
| 3088 | 3071 |
| 3089 bool get hasResolvedAst => definingElement.hasTreeElements; | 3072 bool get hasResolvedAst => definingElement.hasTreeElements; |
| 3090 | 3073 |
| 3091 ResolvedAst get resolvedAst { | 3074 ResolvedAst get resolvedAst { |
| 3092 return new ResolvedAst(declaration, | 3075 return new ResolvedAst(declaration, |
| 3093 definingElement.node, definingElement.treeElements); | 3076 definingElement.node, definingElement.treeElements); |
| 3094 } | 3077 } |
| 3095 | 3078 |
| 3096 } | 3079 } |
| OLD | NEW |