OLD | NEW |
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 library dart2js_incremental.library_updater; | 5 library dart2js_incremental.library_updater; |
6 | 6 |
7 import 'dart:async' show | 7 import 'dart:async' show |
8 Future; | 8 Future; |
9 | 9 |
10 import 'package:compiler/compiler.dart' as api; | 10 import 'package:compiler/compiler.dart' as api; |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 | 676 |
677 /// Returns true if function [before] can be reused to reflect the changes in | 677 /// Returns true if function [before] can be reused to reflect the changes in |
678 /// [after]. | 678 /// [after]. |
679 /// | 679 /// |
680 /// If [before] can be reused, an update (patch) is added to [updates]. | 680 /// If [before] can be reused, an update (patch) is added to [updates]. |
681 bool canReuseFunction( | 681 bool canReuseFunction( |
682 Token diffToken, | 682 Token diffToken, |
683 PartialFunctionElement before, | 683 PartialFunctionElement before, |
684 PartialFunctionElement after) { | 684 PartialFunctionElement after) { |
685 FunctionExpression node = | 685 FunctionExpression node = |
686 after.parseNode(compiler.parsing).asFunctionExpression(); | 686 after.parseNode(compiler.parsingContext).asFunctionExpression(); |
687 if (node == null) { | 687 if (node == null) { |
688 return cannotReuse(after, "Not a function expression: '$node'"); | 688 return cannotReuse(after, "Not a function expression: '$node'"); |
689 } | 689 } |
690 Token last = after.endToken; | 690 Token last = after.endToken; |
691 if (node.body != null) { | 691 if (node.body != null) { |
692 last = node.body.getBeginToken(); | 692 last = node.body.getBeginToken(); |
693 } | 693 } |
694 if (isTokenBetween(diffToken, after.beginToken, last)) { | 694 if (isTokenBetween(diffToken, after.beginToken, last)) { |
695 removeFunction(before); | 695 removeFunction(before); |
696 addFunction(after, before.enclosingElement); | 696 addFunction(after, before.enclosingElement); |
697 return true; | 697 return true; |
698 } | 698 } |
699 logVerbose('Simple modification of ${after} detected'); | 699 logVerbose('Simple modification of ${after} detected'); |
700 updates.add(new FunctionUpdate(compiler, before, after)); | 700 updates.add(new FunctionUpdate(compiler, before, after)); |
701 return true; | 701 return true; |
702 } | 702 } |
703 | 703 |
704 bool canReuseClass( | 704 bool canReuseClass( |
705 Token diffToken, | 705 Token diffToken, |
706 PartialClassElement before, | 706 PartialClassElement before, |
707 PartialClassElement after) { | 707 PartialClassElement after) { |
708 ClassNode node = after.parseNode(compiler.parsing).asClassNode(); | 708 ClassNode node = after.parseNode(compiler.parsingContext).asClassNode(); |
709 if (node == null) { | 709 if (node == null) { |
710 return cannotReuse(after, "Not a ClassNode: '$node'"); | 710 return cannotReuse(after, "Not a ClassNode: '$node'"); |
711 } | 711 } |
712 NodeList body = node.body; | 712 NodeList body = node.body; |
713 if (body == null) { | 713 if (body == null) { |
714 return cannotReuse(after, "Class has no body."); | 714 return cannotReuse(after, "Class has no body."); |
715 } | 715 } |
716 if (isTokenBetween(diffToken, node.beginToken, body.beginToken)) { | 716 if (isTokenBetween(diffToken, node.beginToken, body.beginToken)) { |
717 logVerbose('Class header modified in ${after}'); | 717 logVerbose('Class header modified in ${after}'); |
718 updates.add(new ClassUpdate(compiler, before, after)); | 718 updates.add(new ClassUpdate(compiler, before, after)); |
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1512 .buildFieldsHackForIncrementalCompilation(classElement); | 1512 .buildFieldsHackForIncrementalCompilation(classElement); |
1513 // TODO(ahe): Rewrite for new emitter. | 1513 // TODO(ahe): Rewrite for new emitter. |
1514 ClassBuilder builder = new ClassBuilder(classElement, namer); | 1514 ClassBuilder builder = new ClassBuilder(classElement, namer); |
1515 classEmitter.emitFields(cls, builder); | 1515 classEmitter.emitFields(cls, builder); |
1516 return builder.fields; | 1516 return builder.fields; |
1517 } | 1517 } |
1518 } | 1518 } |
1519 | 1519 |
1520 // TODO(ahe): Remove this method. | 1520 // TODO(ahe): Remove this method. |
1521 NO_WARN(x) => x; | 1521 NO_WARN(x) => x; |
OLD | NEW |