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 3554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3565 | 3565 |
3566 E get implementation => isPatched ? patch : this; | 3566 E get implementation => isPatched ? patch : this; |
3567 E get declaration => isPatch ? origin : this; | 3567 E get declaration => isPatch ? origin : this; |
3568 | 3568 |
3569 /// Applies a patch to this element. This method must be called at most once. | 3569 /// Applies a patch to this element. This method must be called at most once. |
3570 void applyPatch(PatchMixin<E> patch) { | 3570 void applyPatch(PatchMixin<E> patch) { |
3571 assert(this.patch == null, failedAt(this, "Element is patched twice.")); | 3571 assert(this.patch == null, failedAt(this, "Element is patched twice.")); |
3572 assert(this.origin == null, failedAt(this, "Origin element is a patch.")); | 3572 assert(this.origin == null, failedAt(this, "Origin element is a patch.")); |
3573 assert(patch.origin == null, failedAt(patch, "Element is patched twice.")); | 3573 assert(patch.origin == null, failedAt(patch, "Element is patched twice.")); |
3574 assert(patch.patch == null, failedAt(patch, "Patch element is patched.")); | 3574 assert(patch.patch == null, failedAt(patch, "Patch element is patched.")); |
3575 // ignore: INVALID_ASSIGNMENT | 3575 this.patch = patch as E; |
3576 this.patch = patch; | 3576 patch.origin = this as E; |
3577 // ignore: INVALID_ASSIGNMENT | |
3578 patch.origin = this; | |
3579 } | 3577 } |
3580 } | 3578 } |
3581 | 3579 |
3582 /// Abstract implementation of the [AstElement] interface. | 3580 /// Abstract implementation of the [AstElement] interface. |
3583 abstract class AstElementMixin implements AstElement { | 3581 abstract class AstElementMixin implements AstElement { |
3584 /// The element whose node defines this element. | 3582 /// The element whose node defines this element. |
3585 /// | 3583 /// |
3586 /// For patched functions the defining element is the patch element found | 3584 /// For patched functions the defining element is the patch element found |
3587 /// through [implementation] since its node define the implementation of the | 3585 /// through [implementation] since its node define the implementation of the |
3588 /// function. For patched classes the defining element is the origin element | 3586 /// function. For patched classes the defining element is the origin element |
(...skipping 16 matching lines...) Expand all Loading... |
3605 body = node.asFunctionExpression().body; | 3603 body = node.asFunctionExpression().body; |
3606 } | 3604 } |
3607 return new ParsedResolvedAst( | 3605 return new ParsedResolvedAst( |
3608 declaration, | 3606 declaration, |
3609 node, | 3607 node, |
3610 body, | 3608 body, |
3611 definingElement.treeElements, | 3609 definingElement.treeElements, |
3612 definingElement.compilationUnit.script.resourceUri); | 3610 definingElement.compilationUnit.script.resourceUri); |
3613 } | 3611 } |
3614 } | 3612 } |
OLD | NEW |