OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 dart2js.semantics_visitor.resolver; | 5 library dart2js.semantics_visitor.resolver; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../constants/expressions.dart'; | 8 import '../constants/expressions.dart'; |
9 import '../elements/resolution_types.dart'; | 9 import '../elements/resolution_types.dart'; |
10 import '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 node, element, node.parameters, node.initializers, node.body, arg); | 44 node, element, node.parameters, node.initializers, node.body, arg); |
45 case ConstructorKind.REDIRECTING_GENERATIVE: | 45 case ConstructorKind.REDIRECTING_GENERATIVE: |
46 return visitor.visitRedirectingGenerativeConstructorDeclaration( | 46 return visitor.visitRedirectingGenerativeConstructorDeclaration( |
47 node, element, node.parameters, node.initializers, arg); | 47 node, element, node.parameters, node.initializers, arg); |
48 case ConstructorKind.FACTORY: | 48 case ConstructorKind.FACTORY: |
49 return visitor.visitFactoryConstructorDeclaration( | 49 return visitor.visitFactoryConstructorDeclaration( |
50 node, element, node.parameters, node.body, arg); | 50 node, element, node.parameters, node.body, arg); |
51 default: | 51 default: |
52 break; | 52 break; |
53 } | 53 } |
54 throw new SpannableAssertionFailure( | 54 throw failedAt(node, "Unhandled constructor declaration kind: ${kind}"); |
55 node, "Unhandled constructor declaration kind: ${kind}"); | |
56 } | 55 } |
57 } | 56 } |
58 | 57 |
59 class RedirectingFactoryConstructorDeclStructure<R, A> | 58 class RedirectingFactoryConstructorDeclStructure<R, A> |
60 extends DeclStructure<R, A> { | 59 extends DeclStructure<R, A> { |
61 ResolutionInterfaceType redirectionTargetType; | 60 ResolutionInterfaceType redirectionTargetType; |
62 ConstructorElement redirectionTarget; | 61 ConstructorElement redirectionTarget; |
63 | 62 |
64 RedirectingFactoryConstructorDeclStructure(ConstructorElement constructor, | 63 RedirectingFactoryConstructorDeclStructure(ConstructorElement constructor, |
65 this.redirectionTargetType, this.redirectionTarget) | 64 this.redirectionTargetType, this.redirectionTarget) |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 } | 280 } |
282 return list; | 281 return list; |
283 } | 282 } |
284 | 283 |
285 ParameterStructure computeParameterStructure( | 284 ParameterStructure computeParameterStructure( |
286 VariableDefinitions definitions, int index, | 285 VariableDefinitions definitions, int index, |
287 {bool isRequired: true, bool isNamed: false}) { | 286 {bool isRequired: true, bool isNamed: false}) { |
288 Node node = definitions.definitions.nodes.single; | 287 Node node = definitions.definitions.nodes.single; |
289 ParameterElement element = elements[node]; | 288 ParameterElement element = elements[node]; |
290 if (element == null) { | 289 if (element == null) { |
291 throw new SpannableAssertionFailure( | 290 throw failedAt(node, "No parameter structure for $node."); |
292 node, "No parameter structure for $node."); | |
293 } | 291 } |
294 if (isRequired) { | 292 if (isRequired) { |
295 return new RequiredParameterStructure(definitions, node, element, index); | 293 return new RequiredParameterStructure(definitions, node, element, index); |
296 } else { | 294 } else { |
297 // TODO(johnniwinther): Should we differentiate between implicit (null) | 295 // TODO(johnniwinther): Should we differentiate between implicit (null) |
298 // and explicit values? What about optional parameters on redirecting | 296 // and explicit values? What about optional parameters on redirecting |
299 // factories? | 297 // factories? |
300 if (isNamed) { | 298 if (isNamed) { |
301 return new NamedParameterStructure( | 299 return new NamedParameterStructure( |
302 definitions, node, element, element.constant); | 300 definitions, node, element, element.constant); |
(...skipping 26 matching lines...) Expand all Loading... |
329 return internalError(node, "Unexpected variable $element."); | 327 return internalError(node, "Unexpected variable $element."); |
330 } | 328 } |
331 if (element.isConst) { | 329 if (element.isConst) { |
332 ConstantExpression constant = elements.getConstant(element.initializer); | 330 ConstantExpression constant = elements.getConstant(element.initializer); |
333 return new ConstantVariableStructure(kind, node, element, constant); | 331 return new ConstantVariableStructure(kind, node, element, constant); |
334 } else { | 332 } else { |
335 return new NonConstantVariableStructure(kind, node, element); | 333 return new NonConstantVariableStructure(kind, node, element); |
336 } | 334 } |
337 } | 335 } |
338 } | 336 } |
OLD | NEW |