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 '../common.dart'; | 7 import '../common.dart'; |
8 import '../common/names.dart' show Identifiers; | 8 import '../common/names.dart' show Identifiers; |
9 import '../common/resolution.dart' show Resolution, ParsingContext; | 9 import '../common/resolution.dart' show Resolution, ParsingContext; |
10 import '../compiler.dart' show Compiler; | 10 import '../compiler.dart' show Compiler; |
(...skipping 2465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2476 constructorResolvedAst.element.implementation; | 2476 constructorResolvedAst.element.implementation; |
2477 assert(constructor.isGenerativeConstructor); | 2477 assert(constructor.isGenerativeConstructor); |
2478 if (constructorResolvedAst.kind != ResolvedAstKind.PARSED) return null; | 2478 if (constructorResolvedAst.kind != ResolvedAstKind.PARSED) return null; |
2479 | 2479 |
2480 FunctionExpression node = constructorResolvedAst.node; | 2480 FunctionExpression node = constructorResolvedAst.node; |
2481 // If we know the body doesn't have any code, we don't generate it. | 2481 // If we know the body doesn't have any code, we don't generate it. |
2482 if (!node.hasBody) return null; | 2482 if (!node.hasBody) return null; |
2483 if (node.hasEmptyBody) return null; | 2483 if (node.hasEmptyBody) return null; |
2484 ClassElement classElement = constructor.enclosingClass; | 2484 ClassElement classElement = constructor.enclosingClass; |
2485 ConstructorBodyElement bodyElement; | 2485 ConstructorBodyElement bodyElement; |
2486 classElement.forEachBackendMember((Element backendMember) { | 2486 classElement.forEachBackendMember((ConstructorBodyElement body) { |
2487 if (backendMember.isGenerativeConstructorBody) { | 2487 if (body.constructor == constructor) { |
2488 ConstructorBodyElement body = backendMember; | 2488 // TODO(kasperl): Find a way of stopping the iteration |
2489 if (body.constructor == constructor) { | 2489 // through the backend members. |
2490 // TODO(kasperl): Find a way of stopping the iteration | 2490 bodyElement = body; |
2491 // through the backend members. | |
2492 bodyElement = backendMember; | |
2493 } | |
2494 } | 2491 } |
2495 }); | 2492 }); |
2496 if (bodyElement == null) { | 2493 if (bodyElement == null) { |
2497 bodyElement = | 2494 bodyElement = |
2498 new ConstructorBodyElementX(constructorResolvedAst, constructor); | 2495 new ConstructorBodyElementX(constructorResolvedAst, constructor); |
2499 classElement.addBackendMember(bodyElement); | 2496 classElement.addBackendMember(bodyElement); |
2500 | 2497 |
2501 if (constructor.isPatch) { | 2498 if (constructor.isPatch) { |
2502 // Create origin body element for patched constructors. | 2499 // Create origin body element for patched constructors. |
2503 ConstructorBodyElementX patch = bodyElement; | 2500 ConstructorBodyElementX patch = bodyElement; |
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3517 body = node.asFunctionExpression().body; | 3514 body = node.asFunctionExpression().body; |
3518 } | 3515 } |
3519 return new ParsedResolvedAst( | 3516 return new ParsedResolvedAst( |
3520 declaration, | 3517 declaration, |
3521 node, | 3518 node, |
3522 body, | 3519 body, |
3523 definingElement.treeElements, | 3520 definingElement.treeElements, |
3524 definingElement.compilationUnit.script.resourceUri); | 3521 definingElement.compilationUnit.script.resourceUri); |
3525 } | 3522 } |
3526 } | 3523 } |
OLD | NEW |