Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: pkg/compiler/lib/src/resolution/signatures.dart

Issue 867233004: Support constructor declarations in analyzer2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 /** 7 /**
8 * [SignatureResolver] resolves function signatures. 8 * [SignatureResolver] resolves function signatures.
9 */ 9 */
10 class SignatureResolver extends MappingVisitor<FormalElementX> { 10 class SignatureResolver extends MappingVisitor<FormalElementX> {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // [:this.x:] (where [:x:] represents an instance field). 153 // [:this.x:] (where [:x:] represents an instance field).
154 InitializingFormalElementX visitSend(Send node) { 154 InitializingFormalElementX visitSend(Send node) {
155 return createFieldParameter(node, null); 155 return createFieldParameter(node, null);
156 } 156 }
157 157
158 FormalElementX createParameter(Identifier name, Expression initializer) { 158 FormalElementX createParameter(Identifier name, Expression initializer) {
159 validateName(name); 159 validateName(name);
160 FormalElementX parameter; 160 FormalElementX parameter;
161 if (createRealParameters) { 161 if (createRealParameters) {
162 parameter = new LocalParameterElementX( 162 parameter = new LocalParameterElementX(
163 enclosingElement, currentDefinitions, name, initializer); 163 enclosingElement, currentDefinitions, name, initializer,
164 isOptional: isOptionalParameter, isNamed: optionalParametersAreNamed);
164 } else { 165 } else {
165 parameter = new FormalElementX( 166 parameter = new FormalElementX(
166 ElementKind.PARAMETER, enclosingElement, currentDefinitions, name); 167 ElementKind.PARAMETER, enclosingElement, currentDefinitions, name);
167 } 168 }
168 computeParameterType(parameter); 169 computeParameterType(parameter);
169 return parameter; 170 return parameter;
170 } 171 }
171 172
172 InitializingFormalElementX createFieldParameter(Send node, 173 InitializingFormalElementX createFieldParameter(Send node,
173 Expression initializer) { 174 Expression initializer) {
(...skipping 17 matching lines...) Expand all
191 !identical(fieldElement.kind, ElementKind.FIELD)) { 192 !identical(fieldElement.kind, ElementKind.FIELD)) {
192 error(node, MessageKind.NOT_A_FIELD, {'fieldName': name}); 193 error(node, MessageKind.NOT_A_FIELD, {'fieldName': name});
193 fieldElement = new ErroneousFieldElementX( 194 fieldElement = new ErroneousFieldElementX(
194 name, enclosingElement.enclosingClass); 195 name, enclosingElement.enclosingClass);
195 } else if (!fieldElement.isInstanceMember) { 196 } else if (!fieldElement.isInstanceMember) {
196 error(node, MessageKind.NOT_INSTANCE_FIELD, {'fieldName': name}); 197 error(node, MessageKind.NOT_INSTANCE_FIELD, {'fieldName': name});
197 fieldElement = new ErroneousFieldElementX( 198 fieldElement = new ErroneousFieldElementX(
198 name, enclosingElement.enclosingClass); 199 name, enclosingElement.enclosingClass);
199 } 200 }
200 element = new InitializingFormalElementX(enclosingElement, 201 element = new InitializingFormalElementX(enclosingElement,
201 currentDefinitions, name, initializer, fieldElement); 202 currentDefinitions, name, initializer, fieldElement,
203 isOptional: isOptionalParameter, isNamed: optionalParametersAreNamed);
202 computeParameterType(element, fieldElement); 204 computeParameterType(element, fieldElement);
203 } 205 }
204 return element; 206 return element;
205 } 207 }
206 208
207 /// A [SendSet] node is an optional parameter with a default value. 209 /// A [SendSet] node is an optional parameter with a default value.
208 Element visitSendSet(SendSet node) { 210 Element visitSendSet(SendSet node) {
209 FormalElementX element; 211 FormalElementX element;
210 if (node.receiver != null) { 212 if (node.receiver != null) {
211 element = createFieldParameter(node, node.arguments.first); 213 element = createFieldParameter(node, node.arguments.first);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 380
379 DartType resolveReturnType(TypeAnnotation annotation) { 381 DartType resolveReturnType(TypeAnnotation annotation) {
380 if (annotation == null) return const DynamicType(); 382 if (annotation == null) return const DynamicType();
381 DartType result = resolver.resolveTypeAnnotation(annotation); 383 DartType result = resolver.resolveTypeAnnotation(annotation);
382 if (result == null) { 384 if (result == null) {
383 return const DynamicType(); 385 return const DynamicType();
384 } 386 }
385 return result; 387 return result;
386 } 388 }
387 } 389 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/elements/modelx.dart ('k') | tests/compiler/dart2js/backend_dart/sexpr2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698