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

Side by Side Diff: dart/pkg/dart2js_incremental/lib/library_updater.dart

Issue 856333003: Rename $dart_unsafe_eval to $dart_unsafe_incremental_support. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r43060. Created 5 years, 11 months 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 | Annotate | Revision Log
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 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 'dart:convert' show 10 import 'dart:convert' show
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 838
839 updates.add( 839 updates.add(
840 js.statement( 840 js.statement(
841 r'# = #', [classAccess, invokeDefineClass(cls)])); 841 r'# = #', [classAccess, invokeDefineClass(cls)]));
842 842
843 ClassElement superclass = cls.superclass; 843 ClassElement superclass = cls.superclass;
844 if (superclass != null) { 844 if (superclass != null) {
845 jsAst.Node superAccess = emitter.constructorAccess(superclass); 845 jsAst.Node superAccess = emitter.constructorAccess(superclass);
846 inherits.add( 846 inherits.add(
847 js.statement( 847 js.statement(
848 r'#.inheritFrom(#, #)', [helper, classAccess, superAccess])); 848 r'this.inheritFrom(#, #)', [classAccess, superAccess]));
849 } 849 }
850 } 850 }
851 851
852 // Call inheritFrom after all classes have been created. This way we don't 852 // Call inheritFrom after all classes have been created. This way we don't
853 // need to sort the classes by having superclasses defined before their 853 // need to sort the classes by having superclasses defined before their
854 // subclasses. 854 // subclasses.
855 updates.addAll(inherits); 855 updates.addAll(inherits);
856 856
857 for (ClassElementX cls in changedClasses) { 857 for (ClassElementX cls in changedClasses) {
858 ClassElement superclass = cls.superclass; 858 ClassElement superclass = cls.superclass;
859 jsAst.Node superAccess = 859 jsAst.Node superAccess =
860 superclass == null ? js('null') 860 superclass == null ? js('null')
861 : emitter.constructorAccess(superclass); 861 : emitter.constructorAccess(superclass);
862 jsAst.Node classAccess = emitter.constructorAccess(cls); 862 jsAst.Node classAccess = emitter.constructorAccess(cls);
863 updates.add( 863 updates.add(
864 js.statement( 864 js.statement(
865 r'# = #.schemaChange(#, #, #)', 865 r'# = this.schemaChange(#, #, #)',
866 [classAccess, helper, 866 [classAccess, invokeDefineClass(cls), classAccess, superAccess]));
867 invokeDefineClass(cls), classAccess, superAccess]));
868 } 867 }
869 868
870 for (RemovalUpdate update in removals) { 869 for (RemovalUpdate update in removals) {
871 update.writeUpdateJsOn(updates); 870 update.writeUpdateJsOn(updates);
872 } 871 }
873 for (Element element in enqueuer.codegen.newlyEnqueuedElements) { 872 for (Element element in enqueuer.codegen.newlyEnqueuedElements) {
874 if (element.isField) { 873 if (element.isField) {
875 updates.addAll(computeFieldUpdateJs(element)); 874 updates.addAll(computeFieldUpdateJs(element));
876 } else { 875 } else {
877 updates.add(computeMethodUpdateJs(element)); 876 updates.add(computeMethodUpdateJs(element));
(...skipping 14 matching lines...) Expand all
892 jsAst.Statement constantInitializer = 891 jsAst.Statement constantInitializer =
893 emitter.oldEmitter.buildConstantInitializer(constant) 892 emitter.oldEmitter.buildConstantInitializer(constant)
894 .toStatement(); 893 .toStatement();
895 updates.add(constantInitializer); 894 updates.add(constantInitializer);
896 } 895 }
897 } 896 }
898 } 897 }
899 } 898 }
900 899
901 updates.add(js.statement(r''' 900 updates.add(js.statement(r'''
902 if (#helper.pendingStubs) { 901 if (this.pendingStubs) {
903 #helper.pendingStubs.map(function(e) { return e(); }); 902 this.pendingStubs.map(function(e) { return e(); });
904 #helper.pendingStubs = void 0; 903 this.pendingStubs = void 0;
905 } 904 }
906 ''', {'helper': helper})); 905 '''));
907 906
908 if (updates.length == 1) { 907 if (updates.length == 1) {
909 return prettyPrintJs(updates.single); 908 return prettyPrintJs(updates.single);
910 } else { 909 } else {
911 return prettyPrintJs(js.statement('{#}', [updates])); 910 return prettyPrintJs(js.statement('{#}', [updates]));
912 } 911 }
913 } 912 }
914 913
915 jsAst.Expression invokeDefineClass(ClassElementX cls) { 914 jsAst.Expression invokeDefineClass(ClassElementX cls) {
916 String name = namer.getNameOfClass(cls); 915 String name = namer.getNameOfClass(cls);
917 var descriptor = js('Object.create(null)'); 916 var descriptor = js('Object.create(null)');
918 return js( 917 return js(
919 r''' 918 r'''
920 (new Function( 919 (new Function(
921 "$collectedClasses", "$desc", 920 "$collectedClasses", "$desc",
922 #helper.defineClass(#name, #computeFields) +"\n;return " + #name))( 921 this.defineClass(#name, #computeFields) +"\n;return " + #name))(
923 {#name: #descriptor})''', 922 {#name: #descriptor})''',
924 {'helper': helper, 923 {'name': js.string(name),
925 'name': js.string(name),
926 'computeFields': js.stringArray(computeFields(cls)), 924 'computeFields': js.stringArray(computeFields(cls)),
927 'descriptor': descriptor}); 925 'descriptor': descriptor});
928 } 926 }
929 927
930 jsAst.Node computeMethodUpdateJs(Element element) { 928 jsAst.Node computeMethodUpdateJs(Element element) {
931 MemberInfo info = containerBuilder.analyzeMemberMethod(element); 929 MemberInfo info = containerBuilder.analyzeMemberMethod(element);
932 if (info == null) { 930 if (info == null) {
933 compiler.internalError(element, '${element.runtimeType}'); 931 compiler.internalError(element, '${element.runtimeType}');
934 } 932 }
935 ClassBuilder builder = new ClassBuilder(element, namer); 933 ClassBuilder builder = new ClassBuilder(element, namer);
(...skipping 12 matching lines...) Expand all
948 if (element.isInstanceMember) { 946 if (element.isInstanceMember) {
949 holder = emitter.prototypeAccess(element.enclosingClass); 947 holder = emitter.prototypeAccess(element.enclosingClass);
950 } else { 948 } else {
951 holder = js('#', namer.globalObjectFor(element)); 949 holder = js('#', namer.globalObjectFor(element));
952 } 950 }
953 951
954 jsAst.Expression globalFunctionsAccess = 952 jsAst.Expression globalFunctionsAccess =
955 emitter.generateEmbeddedGlobalAccess(embeddedNames.GLOBAL_FUNCTIONS); 953 emitter.generateEmbeddedGlobalAccess(embeddedNames.GLOBAL_FUNCTIONS);
956 954
957 return js.statement( 955 return js.statement(
958 r'#.addMethod(#, #, #, #, #)', 956 r'this.addMethod(#, #, #, #, #)',
959 [helper, partialDescriptor, js.string(name), holder, 957 [partialDescriptor, js.string(name), holder,
960 new jsAst.LiteralBool(isStatic), globalFunctionsAccess]); 958 new jsAst.LiteralBool(isStatic), globalFunctionsAccess]);
961 } 959 }
962 960
963 List<jsAst.Statement> computeFieldUpdateJs(FieldElementX element) { 961 List<jsAst.Statement> computeFieldUpdateJs(FieldElementX element) {
964 if (element.isInstanceMember) { 962 if (element.isInstanceMember) {
965 // Any initializers are inlined in factory methods, and the field is 963 // Any initializers are inlined in factory methods, and the field is
966 // declared by adding its class to [_classesWithSchemaChanges]. 964 // declared by adding its class to [_classesWithSchemaChanges].
967 return const <jsAst.Statement>[]; 965 return const <jsAst.Statement>[];
968 } 966 }
969 // A static (or top-level) field. 967 // A static (or top-level) field.
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
1454 1452
1455 JavaScriptBackend get backend => compiler.backend; 1453 JavaScriptBackend get backend => compiler.backend;
1456 1454
1457 Namer get namer => backend.namer; 1455 Namer get namer => backend.namer;
1458 1456
1459 CodeEmitterTask get emitter => backend.emitter; 1457 CodeEmitterTask get emitter => backend.emitter;
1460 1458
1461 ContainerBuilder get containerBuilder => emitter.oldEmitter.containerBuilder; 1459 ContainerBuilder get containerBuilder => emitter.oldEmitter.containerBuilder;
1462 1460
1463 EnqueueTask get enqueuer => compiler.enqueuer; 1461 EnqueueTask get enqueuer => compiler.enqueuer;
1464
1465 jsAst.Expression get helper => namer.accessIncrementalHelper;
1466 } 1462 }
1467 1463
1468 class EmitterHelper extends JsFeatures { 1464 class EmitterHelper extends JsFeatures {
1469 final Compiler compiler; 1465 final Compiler compiler;
1470 1466
1471 EmitterHelper(this.compiler); 1467 EmitterHelper(this.compiler);
1472 1468
1473 ClassEmitter get classEmitter => backend.emitter.oldEmitter.classEmitter; 1469 ClassEmitter get classEmitter => backend.emitter.oldEmitter.classEmitter;
1474 1470
1475 List<String> computeFields(ClassElement cls) { 1471 List<String> computeFields(ClassElement cls) {
1476 // TODO(ahe): Rewrite for new emitter. 1472 // TODO(ahe): Rewrite for new emitter.
1477 ClassBuilder builder = new ClassBuilder(cls, namer); 1473 ClassBuilder builder = new ClassBuilder(cls, namer);
1478 classEmitter.emitFields(cls, builder); 1474 classEmitter.emitFields(cls, builder);
1479 return builder.fields; 1475 return builder.fields;
1480 } 1476 }
1481 } 1477 }
1482 1478
1483 // TODO(ahe): Remove this method. 1479 // TODO(ahe): Remove this method.
1484 NO_WARN(x) => x; 1480 NO_WARN(x) => x;
OLDNEW
« no previous file with comments | « dart/pkg/dart2js_incremental/lib/dart2js_incremental.dart ('k') | dart/tests/try/web/incremental_compilation_update.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698