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

Side by Side Diff: pkg/fletchc/lib/incremental/library_updater.dart

Issue 1450393002: Roll sdk dependency to 34357cdad108dcba734949bd13bd28c76ea285e0 (Closed) Base URL: git@github.com:dart-lang/fletch.git@master
Patch Set: Update status files Created 5 years 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
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 library fletchc_incremental.library_updater; 5 library fletchc_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_new.dart' show 10 import 'package:compiler/compiler_new.dart' show
11 CompilerDiagnostics, 11 CompilerDiagnostics,
12 Diagnostic; 12 Diagnostic;
13 13
14 import 'package:compiler/compiler.dart' as api; 14 import 'package:compiler/compiler.dart' as api;
15 15
16 import 'package:compiler/src/dart2jslib.dart' show 16 import 'package:compiler/src/compiler.dart' show
17 Compiler, 17 Compiler;
18 EnqueueTask, 18
19 MessageKind, 19 import 'package:compiler/src/enqueue.dart' show
20 EnqueueTask;
21
22 import 'package:compiler/src/diagnostics/messages.dart' show
23 MessageKind;
24
25 import 'package:compiler/src/script.dart' show
20 Script; 26 Script;
21 27
22 import 'package:compiler/src/elements/elements.dart' show 28 import 'package:compiler/src/elements/elements.dart' show
23 AstElement, 29 AstElement,
24 ClassElement, 30 ClassElement,
25 CompilationUnitElement, 31 CompilationUnitElement,
26 Element, 32 Element,
27 FieldElement, 33 FieldElement,
28 FunctionElement, 34 FunctionElement,
29 LibraryElement, 35 LibraryElement,
30 STATE_NOT_STARTED, 36 STATE_NOT_STARTED,
31 ScopeContainerElement, 37 ScopeContainerElement,
32 TypeDeclarationElement; 38 TypeDeclarationElement;
33 39
34 import 'package:compiler/src/scanner/scannerlib.dart' show 40 import 'package:compiler/src/tokens/token_constants.dart' show
35 EOF_TOKEN, 41 EOF_TOKEN;
36 Listener, 42
37 NodeListener, 43 import 'package:compiler/src/tokens/token.dart' show
38 Parser, 44 Token;
45
46 import 'package:compiler/src/parser/partial_elements.dart' show
39 PartialClassElement, 47 PartialClassElement,
40 PartialElement, 48 PartialElement,
41 PartialFieldList, 49 PartialFieldList,
42 PartialFunctionElement, 50 PartialFunctionElement;
43 Scanner, 51
44 Token; 52 import 'package:compiler/src/scanner/scanner.dart' show
53 Scanner;
54
55 import 'package:compiler/src/parser/parser.dart' show
56 Parser;
57
58 import 'package:compiler/src/parser/listener.dart' show
59 Listener;
60
61 import 'package:compiler/src/parser/node_listener.dart' show
62 NodeListener;
45 63
46 import 'package:compiler/src/io/source_file.dart' show 64 import 'package:compiler/src/io/source_file.dart' show
47 CachingUtf8BytesSourceFile, 65 CachingUtf8BytesSourceFile,
48 SourceFile, 66 SourceFile,
49 StringSourceFile; 67 StringSourceFile;
50 68
51 import 'package:compiler/src/tree/tree.dart' show 69 import 'package:compiler/src/tree/tree.dart' show
52 ClassNode, 70 ClassNode,
53 FunctionExpression, 71 FunctionExpression,
54 LibraryTag, 72 LibraryTag,
(...skipping 30 matching lines...) Expand all
85 LinkBuilder; 103 LinkBuilder;
86 104
87 import 'package:compiler/src/elements/modelx.dart' show 105 import 'package:compiler/src/elements/modelx.dart' show
88 ClassElementX, 106 ClassElementX,
89 CompilationUnitElementX, 107 CompilationUnitElementX,
90 DeclarationSite, 108 DeclarationSite,
91 ElementX, 109 ElementX,
92 FieldElementX, 110 FieldElementX,
93 LibraryElementX; 111 LibraryElementX;
94 112
95 import 'package:compiler/src/universe/universe.dart' show
96 Selector,
97 UniverseSelector;
98
99 import 'package:compiler/src/constants/values.dart' show 113 import 'package:compiler/src/constants/values.dart' show
100 ConstantValue; 114 ConstantValue;
101 115
102 import 'package:compiler/src/library_loader.dart' show 116 import 'package:compiler/src/library_loader.dart' show
103 TagState; 117 TagState;
104 118
105 import 'diff.dart' show 119 import 'diff.dart' show
106 Difference, 120 Difference,
107 computeDifference; 121 computeDifference;
108 122
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 return _readUri(before.resourceUri).then((bytes) { 338 return _readUri(before.resourceUri).then((bytes) {
325 Uri uri = before.file.uri; 339 Uri uri = before.file.uri;
326 String filename = before.file.filename; 340 String filename = before.file.filename;
327 SourceFile sourceFile = bytes is String 341 SourceFile sourceFile = bytes is String
328 ? new StringSourceFile(uri, filename, bytes) 342 ? new StringSourceFile(uri, filename, bytes)
329 : new CachingUtf8BytesSourceFile(uri, filename, bytes); 343 : new CachingUtf8BytesSourceFile(uri, filename, bytes);
330 return before.copyWithFile(sourceFile); 344 return before.copyWithFile(sourceFile);
331 }); 345 });
332 } 346 }
333 347
334 Future<bool> _haveTagsChanged(LibraryElement library) { 348 Future<bool> _haveTagsChanged(LibraryElementX library) {
335 Script before = library.entryCompilationUnit.script; 349 Script before = library.entryCompilationUnit.script;
336 if (!_context._uriHasUpdate(before.resourceUri)) { 350 if (!_context._uriHasUpdate(before.resourceUri)) {
337 // The entry compilation unit hasn't been updated. So the tags aren't 351 // The entry compilation unit hasn't been updated. So the tags aren't
338 // changed. 352 // changed.
339 return new Future<bool>.value(false); 353 return new Future<bool>.value(false);
340 } 354 }
341 355
342 return _updatedScript(before, library).then((Script script) { 356 return _updatedScript(before, library).then((Script script) {
343 _entrySourceFiles[library] = script.file; 357 _entrySourceFiles[library] = script.file;
344 Token token = new Scanner(_entrySourceFiles[library]).tokenize(); 358 Token token = new Scanner(_entrySourceFiles[library]).tokenize();
345 _entryUnitTokens[library] = token; 359 _entryUnitTokens[library] = token;
346 // Using two parsers to only create the nodes we want ([LibraryTag]). 360 // Using two parsers to only create the nodes we want ([LibraryTag]).
347 Parser parser = new Parser(new Listener()); 361 Parser parser = new Parser(new Listener());
362 Element entryCompilationUnit = library.entryCompilationUnit;
348 NodeListener listener = new NodeListener( 363 NodeListener listener = new NodeListener(
349 compiler, library.entryCompilationUnit); 364 compiler.resolution.parsing
365 .getScannerOptionsFor(entryCompilationUnit),
366 compiler.reporter, entryCompilationUnit);
350 Parser nodeParser = new Parser(listener); 367 Parser nodeParser = new Parser(listener);
351 Iterator<LibraryTag> tags = library.tags.iterator; 368 Iterator<LibraryTag> tags = library.tags.iterator;
352 while (token.kind != EOF_TOKEN) { 369 while (token.kind != EOF_TOKEN) {
353 token = parser.parseMetadataStar(token); 370 token = parser.parseMetadataStar(token);
354 if (parser.optional('library', token) || 371 if (parser.optional('library', token) ||
355 parser.optional('import', token) || 372 parser.optional('import', token) ||
356 parser.optional('export', token) || 373 parser.optional('export', token) ||
357 parser.optional('part', token)) { 374 parser.optional('part', token)) {
358 if (!tags.moveNext()) return true; 375 if (!tags.moveNext()) return true;
359 token = nodeParser.parseTopLevelDeclaration(token); 376 token = nodeParser.parseTopLevelDeclaration(token);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 if (_entryUnitTokens.containsKey(library)) { 415 if (_entryUnitTokens.containsKey(library)) {
399 compiler.dietParser.dietParse( 416 compiler.dietParser.dietParse(
400 newLibrary.entryCompilationUnit, _entryUnitTokens[library]); 417 newLibrary.entryCompilationUnit, _entryUnitTokens[library]);
401 } else { 418 } else {
402 compiler.scanner.scanLibrary(newLibrary); 419 compiler.scanner.scanLibrary(newLibrary);
403 } 420 }
404 421
405 TagState tagState = new TagState(); 422 TagState tagState = new TagState();
406 for (LibraryTag tag in newLibrary.tags) { 423 for (LibraryTag tag in newLibrary.tags) {
407 if (tag.isImport) { 424 if (tag.isImport) {
408 tagState.checkTag(TagState.IMPORT_OR_EXPORT, tag, compiler); 425 tagState.checkTag(TagState.IMPORT_OR_EXPORT, tag, compiler.reporter);
409 } else if (tag.isExport) { 426 } else if (tag.isExport) {
410 tagState.checkTag(TagState.IMPORT_OR_EXPORT, tag, compiler); 427 tagState.checkTag(TagState.IMPORT_OR_EXPORT, tag, compiler.reporter);
411 } else if (tag.isLibraryName) { 428 } else if (tag.isLibraryName) {
412 tagState.checkTag(TagState.LIBRARY, tag, compiler); 429 tagState.checkTag(TagState.LIBRARY, tag, compiler.reporter);
413 if (newLibrary.libraryTag == null) { 430 if (newLibrary.libraryTag == null) {
414 // Use the first if there are multiple (which is reported as an 431 // Use the first if there are multiple (which is reported as an
415 // error in [TagState.checkTag]). 432 // error in [TagState.checkTag]).
416 newLibrary.libraryTag = tag; 433 newLibrary.libraryTag = tag;
417 } 434 }
418 } else if (tag.isPart) { 435 } else if (tag.isPart) {
419 tagState.checkTag(TagState.PART, tag, compiler); 436 tagState.checkTag(TagState.PART, tag, compiler.reporter);
420 } 437 }
421 } 438 }
422 439
423 // TODO(ahe): Process tags using TagState, not 440 // TODO(ahe): Process tags using TagState, not
424 // LibraryLoaderTask.processLibraryTags. 441 // LibraryLoaderTask.processLibraryTags.
425 Link<CompilationUnitElement> units = library.compilationUnits; 442 Link<CompilationUnitElement> units = library.compilationUnits;
426 for (Script script in scripts) { 443 for (Script script in scripts) {
427 CompilationUnitElementX unit = units.head; 444 CompilationUnitElementX unit = units.head;
428 units = units.tail; 445 units = units.tail;
429 if (script != entryScript) { 446 if (script != entryScript) {
430 // TODO(ahe): Copied from library_loader. 447 // TODO(ahe): Copied from library_loader.
431 CompilationUnitElement newUnit = 448 CompilationUnitElement newUnit =
432 new CompilationUnitElementX(script, newLibrary); 449 new CompilationUnitElementX(script, newLibrary);
433 compiler.withCurrentElement(newUnit, () { 450 compiler.reporter.withCurrentElement(newUnit, () {
434 compiler.scanner.scan(newUnit); 451 compiler.scanner.scan(newUnit);
435 if (unit.partTag == null) { 452 if (unit.partTag == null) {
436 compiler.reportError(unit, MessageKind.MISSING_PART_OF_TAG); 453 compiler.reporter
454 .reportErrorMessage(unit, MessageKind.MISSING_PART_OF_TAG);
437 } 455 }
438 }); 456 });
439 } 457 }
440 } 458 }
441 459
442 logTime('New library synthesized.'); 460 logTime('New library synthesized.');
443 return canReuseScopeContainerElement(library, newLibrary); 461 return canReuseScopeContainerElement(library, newLibrary);
444 } 462 }
445 463
446 bool cannotReuse(context, String message) { 464 bool cannotReuse(context, String message) {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 664
647 updates.add(new RemovedFieldUpdate(compiler, element)); 665 updates.add(new RemovedFieldUpdate(compiler, element));
648 } 666 }
649 667
650 /// Returns true if [element] has generic types (or if we cannot rule out 668 /// Returns true if [element] has generic types (or if we cannot rule out
651 /// that it has generic types). 669 /// that it has generic types).
652 bool checkForGenericTypes(Element element) { 670 bool checkForGenericTypes(Element element) {
653 if (element is TypeDeclarationElement) { 671 if (element is TypeDeclarationElement) {
654 if (!element.isResolved) { 672 if (!element.isResolved) {
655 if (element is PartialClassElement) { 673 if (element is PartialClassElement) {
656 ClassNode node = element.parseNode(compiler).asClassNode(); 674 ClassNode node = element.parseNode(compiler.parsing).asClassNode();
657 if (node == null) { 675 if (node == null) {
658 cannotReuse( 676 cannotReuse(
659 element, "Class body isn't a ClassNode on $element"); 677 element, "Class body isn't a ClassNode on $element");
660 return true; 678 return true;
661 } 679 }
662 bool isGeneric = 680 bool isGeneric =
663 node.typeParameters != null && !node.typeParameters.isEmpty; 681 node.typeParameters != null && !node.typeParameters.isEmpty;
664 if (isGeneric) { 682 if (isGeneric) {
665 // TODO(ahe): Support generic types. 683 // TODO(ahe): Support generic types.
666 cannotReuse( 684 cannotReuse(
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 /* ScopeContainerElement */ container) { 771 /* ScopeContainerElement */ container) {
754 // TODO(ahe): Use library export graph to compute this. 772 // TODO(ahe): Use library export graph to compute this.
755 // TODO(ahe): Should return all user-defined libraries and packages. 773 // TODO(ahe): Should return all user-defined libraries and packages.
756 LibraryElement library = container.library; 774 LibraryElement library = container.library;
757 List<ScopeContainerElement> result = <ScopeContainerElement>[library]; 775 List<ScopeContainerElement> result = <ScopeContainerElement>[library];
758 776
759 if (!container.isClass) return result; 777 if (!container.isClass) return result;
760 778
761 ClassElement cls = container; 779 ClassElement cls = container;
762 780
763 if (!compiler.world.isInstantiated(cls.declaration)) { 781 if (!cls.declaration.isResolved) {
764 // dart2js currently only maintain subclasses for classes that are 782 // TODO(ahe): This test fails otherwise: experimental/add_static_field.
765 // instantiated.
766 throw new IncrementalCompilationFailed( 783 throw new IncrementalCompilationFailed(
767 "Unable to compute subclasses of ${cls.declaration}"); 784 "Unresolved class ${cls.declaration}");
768 } 785 }
769 var externalSubtypes = 786 var externalSubtypes =
770 compiler.world.subclassesOf(cls).where((e) => e.library != library); 787 compiler.world.subclassesOf(cls).where((e) => e.library != library);
771 788
772 return result..addAll(externalSubtypes); 789 return result..addAll(externalSubtypes);
773 } 790 }
774 791
775 /// Returns true if function [before] can be reused to reflect the changes in 792 /// Returns true if function [before] can be reused to reflect the changes in
776 /// [after]. 793 /// [after].
777 /// 794 ///
778 /// If [before] can be reused, an update (patch) is added to [updates]. 795 /// If [before] can be reused, an update (patch) is added to [updates].
779 bool canReuseFunction( 796 bool canReuseFunction(
780 Token diffToken, 797 Token diffToken,
781 PartialFunctionElement before, 798 PartialFunctionElement before,
782 PartialFunctionElement after) { 799 PartialFunctionElement after) {
783 FunctionExpression node = 800 FunctionExpression node =
784 after.parseNode(compiler).asFunctionExpression(); 801 after.parseNode(compiler.parsing).asFunctionExpression();
785 if (node == null) { 802 if (node == null) {
786 return cannotReuse(after, "Not a function expression: '$node'"); 803 return cannotReuse(after, "Not a function expression: '$node'");
787 } 804 }
788 Token last = after.endToken; 805 Token last = after.endToken;
789 if (node.body != null) { 806 if (node.body != null) {
790 last = node.body.getBeginToken(); 807 last = node.body.getBeginToken();
791 } 808 }
792 if (before.isErroneous || 809 if (before.isMalformed ||
793 compiler.elementsWithCompileTimeErrors.contains(before) || 810 compiler.elementsWithCompileTimeErrors.contains(before) ||
794 isTokenBetween(diffToken, after.beginToken, last)) { 811 isTokenBetween(diffToken, after.beginToken, last)) {
795 removeFunction(before); 812 removeFunction(before);
796 addFunction(after, before.enclosingElement); 813 addFunction(after, before.enclosingElement);
797 if (compiler.mainFunction == before) { 814 if (compiler.mainFunction == before) {
798 return cannotReuse( 815 return cannotReuse(
799 after, 816 after,
800 "Unable to handle when signature of '${after.name}' changes"); 817 "Unable to handle when signature of '${after.name}' changes");
801 } 818 }
802 if (!_context.incrementalCompiler.isExperimentalModeEnabled) { 819 if (!_context.incrementalCompiler.isExperimentalModeEnabled) {
803 return cannotReuse( 820 return cannotReuse(
804 after, "Signature change requires 'experimental' mode"); 821 after, "Signature change requires 'experimental' mode");
805 } 822 }
806 return true; 823 return true;
807 } 824 }
808 logVerbose('Simple modification of ${after} detected'); 825 logVerbose('Simple modification of ${after} detected');
809 if (!before.isInstanceMember && 826 if (!before.isInstanceMember &&
810 !_context.incrementalCompiler.isExperimentalModeEnabled) { 827 !_context.incrementalCompiler.isExperimentalModeEnabled) {
811 return cannotReuse( 828 return cannotReuse(
812 after, "Non-instance member requires 'experimental' mode"); 829 after, "Non-instance member requires 'experimental' mode");
813 } 830 }
814 updates.add(new FunctionUpdate(compiler, before, after)); 831 updates.add(new FunctionUpdate(compiler, before, after));
815 return true; 832 return true;
816 } 833 }
817 834
818 bool canReuseClass( 835 bool canReuseClass(
819 Token diffToken, 836 Token diffToken,
820 PartialClassElement before, 837 PartialClassElement before,
821 PartialClassElement after) { 838 PartialClassElement after) {
822 ClassNode node = after.parseNode(compiler).asClassNode(); 839 ClassNode node = after.parseNode(compiler.parsing).asClassNode();
823 if (node == null) { 840 if (node == null) {
824 return cannotReuse(after, "Not a ClassNode: '$node'"); 841 return cannotReuse(after, "Not a ClassNode: '$node'");
825 } 842 }
826 NodeList body = node.body; 843 NodeList body = node.body;
827 if (body == null) { 844 if (body == null) {
828 return cannotReuse(after, "Class has no body."); 845 return cannotReuse(after, "Class has no body.");
829 } 846 }
830 if (isTokenBetween(diffToken, node.beginToken, body.beginToken.next)) { 847 if (isTokenBetween(diffToken, node.beginToken, body.beginToken.next)) {
831 if (!_context.incrementalCompiler.isExperimentalModeEnabled) { 848 if (!_context.incrementalCompiler.isExperimentalModeEnabled) {
832 return cannotReuse( 849 return cannotReuse(
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 946
930 if (compiler.progress != null) { 947 if (compiler.progress != null) {
931 compiler.progress.reset(); 948 compiler.progress.reset();
932 } 949 }
933 950
934 for (Element element in updatedElements) { 951 for (Element element in updatedElements) {
935 if (!element.isClass) { 952 if (!element.isClass) {
936 enqueuer.resolution.addToWorkList(element); 953 enqueuer.resolution.addToWorkList(element);
937 } else { 954 } else {
938 ClassElement cls = element; 955 ClassElement cls = element;
939 cls.ensureResolved(compiler); 956 cls.ensureResolved(compiler.resolution);
940 957
941 // We've told the enqueuer to forget this class, now tell it that it's 958 // We've told the enqueuer to forget this class, now tell it that it's
942 // in use again. TODO(ahe): We only need to do this if [cls] was 959 // in use again. TODO(ahe): We only need to do this if [cls] was
943 // already instantiated. 960 // already instantiated.
944 enqueuer.codegen.registerInstantiatedType(cls.rawType, null); 961 enqueuer.codegen.registerInstantiatedType(cls.rawType);
945 } 962 }
946 } 963 }
947 compiler.processQueue(enqueuer.resolution, null); 964 compiler.processQueue(enqueuer.resolution, null);
948 965
949 compiler.phase = Compiler.PHASE_DONE_RESOLVING; 966 compiler.phase = Compiler.PHASE_DONE_RESOLVING;
950 967
951 // TODO(ahe): Clean this up. Don't call this method in analyze-only mode. 968 // TODO(ahe): Clean this up. Don't call this method in analyze-only mode.
952 if (compiler.analyzeOnly) { 969 if (compiler.analyzeOnly) {
953 return new FletchDelta(currentSystem, currentSystem, <Command>[]); 970 return new FletchDelta(currentSystem, currentSystem, <Command>[]);
954 } 971 }
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 1220
1204 PartialFunctionElement get after => element; 1221 PartialFunctionElement get after => element;
1205 1222
1206 PartialFunctionElement apply(IncrementalBackend backend) { 1223 PartialFunctionElement apply(IncrementalBackend backend) {
1207 Element enclosing = container; 1224 Element enclosing = container;
1208 if (enclosing.isLibrary) { 1225 if (enclosing.isLibrary) {
1209 // TODO(ahe): Reuse compilation unit of element instead? 1226 // TODO(ahe): Reuse compilation unit of element instead?
1210 enclosing = enclosing.compilationUnit; 1227 enclosing = enclosing.compilationUnit;
1211 } 1228 }
1212 PartialFunctionElement copy = element.copyWithEnclosing(enclosing); 1229 PartialFunctionElement copy = element.copyWithEnclosing(enclosing);
1213 container.addMember(copy, compiler); 1230 container.addMember(copy, compiler.reporter);
1214 return copy; 1231 return copy;
1215 } 1232 }
1216 } 1233 }
1217 1234
1218 class AddedClassUpdate extends Update with FletchFeatures { 1235 class AddedClassUpdate extends Update with FletchFeatures {
1219 final PartialClassElement element; 1236 final PartialClassElement element;
1220 1237
1221 final LibraryElementX library; 1238 final LibraryElementX library;
1222 1239
1223 AddedClassUpdate(Compiler compiler, this.element, this.library) 1240 AddedClassUpdate(Compiler compiler, this.element, this.library)
1224 : super(compiler); 1241 : super(compiler);
1225 1242
1226 PartialClassElement get before => null; 1243 PartialClassElement get before => null;
1227 1244
1228 PartialClassElement get after => element; 1245 PartialClassElement get after => element;
1229 1246
1230 PartialClassElement apply(IncrementalBackend backend) { 1247 PartialClassElement apply(IncrementalBackend backend) {
1231 // TODO(ahe): Reuse compilation unit of element instead? 1248 // TODO(ahe): Reuse compilation unit of element instead?
1232 CompilationUnitElementX compilationUnit = library.compilationUnit; 1249 CompilationUnitElementX compilationUnit = library.compilationUnit;
1233 PartialClassElement copy = element.copyWithEnclosing(compilationUnit); 1250 PartialClassElement copy = element.copyWithEnclosing(compilationUnit);
1234 compilationUnit.addMember(copy, compiler); 1251 compilationUnit.addMember(copy, compiler.reporter);
1235 return copy; 1252 return copy;
1236 } 1253 }
1237 } 1254 }
1238 1255
1239 class AddedFieldUpdate extends Update with FletchFeatures { 1256 class AddedFieldUpdate extends Update with FletchFeatures {
1240 final FieldElementX element; 1257 final FieldElementX element;
1241 1258
1242 final /* ScopeContainerElement */ container; 1259 final /* ScopeContainerElement */ container;
1243 1260
1244 AddedFieldUpdate(Compiler compiler, this.element, this.container) 1261 AddedFieldUpdate(Compiler compiler, this.element, this.container)
1245 : super(compiler); 1262 : super(compiler);
1246 1263
1247 PartialFieldList get before => null; 1264 PartialFieldList get before => null;
1248 1265
1249 PartialFieldList get after => element.declarationSite; 1266 PartialFieldList get after => element.declarationSite;
1250 1267
1251 FieldElementX apply(IncrementalBackend backend) { 1268 FieldElementX apply(IncrementalBackend backend) {
1252 Element enclosing = container; 1269 Element enclosing = container;
1253 if (enclosing.isLibrary) { 1270 if (enclosing.isLibrary) {
1254 // TODO(ahe): Reuse compilation unit of element instead? 1271 // TODO(ahe): Reuse compilation unit of element instead?
1255 enclosing = enclosing.compilationUnit; 1272 enclosing = enclosing.compilationUnit;
1256 } 1273 }
1257 FieldElementX copy = element.copyWithEnclosing(enclosing); 1274 FieldElementX copy = element.copyWithEnclosing(enclosing);
1258 container.addMember(copy, compiler); 1275 container.addMember(copy, compiler.reporter);
1259 return copy; 1276 return copy;
1260 } 1277 }
1261 } 1278 }
1262 1279
1263 1280
1264 class ClassUpdate extends Update with FletchFeatures { 1281 class ClassUpdate extends Update with FletchFeatures {
1265 final PartialClassElement before; 1282 final PartialClassElement before;
1266 1283
1267 final PartialClassElement after; 1284 final PartialClassElement after;
1268 1285
1269 ClassUpdate(Compiler compiler, this.before, this.after) 1286 ClassUpdate(Compiler compiler, this.before, this.after)
1270 : super(compiler); 1287 : super(compiler);
1271 1288
1272 PartialClassElement apply(IncrementalBackend backend) { 1289 PartialClassElement apply(IncrementalBackend backend) {
1273 patchElement(); 1290 patchElement();
1274 reuseElement(); 1291 reuseElement();
1275 return before; 1292 return before;
1276 } 1293 }
1277 1294
1278 /// Destructively change the tokens in [before] to match those of [after]. 1295 /// Destructively change the tokens in [before] to match those of [after].
1279 void patchElement() { 1296 void patchElement() {
1280 before.cachedNode = after.cachedNode; 1297 before.cachedNode = after.cachedNode;
1281 before.beginToken = after.beginToken; 1298 before.beginToken = after.beginToken;
1282 before.endToken = after.endToken; 1299 before.endToken = after.endToken;
1283 } 1300 }
1284 1301
1285 void reuseElement() { 1302 void reuseElement() {
1286 before.supertype = null; 1303 before.supertype = null;
1287 before.interfaces = null; 1304 before.interfaces = null;
1288 before.nativeTagInfo = null;
1289 before.supertypeLoadState = STATE_NOT_STARTED; 1305 before.supertypeLoadState = STATE_NOT_STARTED;
1290 before.resolutionState = STATE_NOT_STARTED; 1306 before.resolutionState = STATE_NOT_STARTED;
1291 before.isProxy = false; 1307 before.isProxy = false;
1292 before.hasIncompleteHierarchy = false; 1308 before.hasIncompleteHierarchy = false;
1293 before.backendMembers = const Link<Element>(); 1309 before.backendMembers = const Link<Element>();
1294 before.allSupertypesAndSelf = null; 1310 before.allSupertypesAndSelf = null;
1295 } 1311 }
1296 } 1312 }
1297 1313
1298 /// Returns all qualified names in [element] with less than four identifiers. A 1314 /// Returns all qualified names in [element] with less than four identifiers. A
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 } 1395 }
1380 1396
1381 EnqueueTask get enqueuer => compiler.enqueuer; 1397 EnqueueTask get enqueuer => compiler.enqueuer;
1382 1398
1383 FletchContext get fletchContext => compiler.context; 1399 FletchContext get fletchContext => compiler.context;
1384 1400
1385 FletchFunctionBuilder lookupFletchFunctionBuilder(FunctionElement function) { 1401 FletchFunctionBuilder lookupFletchFunctionBuilder(FunctionElement function) {
1386 return backend.systemBuilder.lookupFunctionBuilderByElement(function); 1402 return backend.systemBuilder.lookupFunctionBuilderByElement(function);
1387 } 1403 }
1388 } 1404 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698