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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_backend/emitter_no_eval.dart

Issue 11492006: Minify methods, classes and fields. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Responses to Nicolas' late comments and restore missing '!' from last commit. Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of js_backend; 5 part of js_backend;
6 6
7 class CodeEmitterNoEvalTask extends CodeEmitterTask { 7 class CodeEmitterNoEvalTask extends CodeEmitterTask {
8 CodeEmitterNoEvalTask(Compiler compiler, 8 CodeEmitterNoEvalTask(Compiler compiler,
9 Namer namer, 9 Namer namer,
10 bool generateSourceMap) 10 bool generateSourceMap)
(...skipping 21 matching lines...) Expand all
32 } 32 }
33 33
34 String get finishIsolateConstructorFunction { 34 String get finishIsolateConstructorFunction {
35 // We replace the old Isolate function with a new one that initializes 35 // We replace the old Isolate function with a new one that initializes
36 // all its field with the initial (and often final) value of all globals. 36 // all its field with the initial (and often final) value of all globals.
37 // 37 //
38 // We also copy over old values like the prototype, and the 38 // We also copy over old values like the prototype, and the
39 // isolateProperties themselves. 39 // isolateProperties themselves.
40 return """ 40 return """
41 function(oldIsolate) { 41 function(oldIsolate) {
42 var isolateProperties = oldIsolate.${namer.ISOLATE_PROPERTIES}; 42 var isolateProperties = oldIsolate.${namer.isolatePropertiesName};
43 function Isolate() { 43 function Isolate() {
44 for (var staticName in isolateProperties) { 44 for (var staticName in isolateProperties) {
45 if (Object.prototype.hasOwnProperty.call(isolateProperties, staticName)) { 45 if (Object.prototype.hasOwnProperty.call(isolateProperties, staticName)) {
46 this[staticName] = isolateProperties[staticName]; 46 this[staticName] = isolateProperties[staticName];
47 } 47 }
48 } 48 }
49 // Use the newly created object as prototype. In Chrome this creates a 49 // Use the newly created object as prototype. In Chrome this creates a
50 // hidden class for the object and makes sure it is fast to access. 50 // hidden class for the object and makes sure it is fast to access.
51 function ForceEfficientMap() {} 51 function ForceEfficientMap() {}
52 ForceEfficientMap.prototype = this; 52 ForceEfficientMap.prototype = this;
53 new ForceEfficientMap; 53 new ForceEfficientMap;
54 } 54 }
55 Isolate.prototype = oldIsolate.prototype; 55 Isolate.prototype = oldIsolate.prototype;
56 Isolate.prototype.constructor = Isolate; 56 Isolate.prototype.constructor = Isolate;
57 Isolate.${namer.ISOLATE_PROPERTIES} = isolateProperties; 57 Isolate.${namer.isolatePropertiesName} = isolateProperties;
58 return Isolate; 58 return Isolate;
59 }"""; 59 }""";
60 } 60 }
61 61
62 String get lazyInitializerFunction { 62 String get lazyInitializerFunction {
63 return """ 63 return """
64 function(prototype, staticName, fieldName, getterName, lazyValue, getter) { 64 function(prototype, staticName, fieldName, getterName, lazyValue, getter) {
65 $lazyInitializerLogic 65 $lazyInitializerLogic
66 }"""; 66 }""";
67 } 67 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // d needs both a getter and a setter. Then we produce: 99 // d needs both a getter and a setter. Then we produce:
100 // - a constructor (directly into the given [buffer]): 100 // - a constructor (directly into the given [buffer]):
101 // function A(b, c, d) { this.b = b, this.c = c, this.d = d; } 101 // function A(b, c, d) { this.b = b, this.c = c, this.d = d; }
102 // - getters and setters (stored in the [explicitGettersSetters] list): 102 // - getters and setters (stored in the [explicitGettersSetters] list):
103 // get$c : function() { return this.c; } 103 // get$c : function() { return this.c; }
104 // get$d : function() { return this.d; } 104 // get$d : function() { return this.d; }
105 // set$d : function(x) { this.d = x; } 105 // set$d : function(x) { this.d = x; }
106 List<String> fields = <String>[]; 106 List<String> fields = <String>[];
107 visitClassFields(classElement, (Element member, 107 visitClassFields(classElement, (Element member,
108 String name, 108 String name,
109 String accessorName,
109 bool needsGetter, 110 bool needsGetter,
110 bool needsSetter, 111 bool needsSetter,
111 bool needsCheckedSetter) { 112 bool needsCheckedSetter) {
112 fields.add(name); 113 fields.add(name);
113 }); 114 });
114 String constructorName = namer.safeName(classElement.name.slowToString()); 115 String constructorName = namer.safeName(classElement.name.slowToString());
115 buffer.add("'': "); 116 buffer.add("'': ");
116 buffer.add( 117 buffer.add(
117 js.prettyPrint(buildConstructor(constructorName, fields), compiler)); 118 js.prettyPrint(buildConstructor(constructorName, fields), compiler));
118 } 119 }
(...skipping 12 matching lines...) Expand all
131 if (emitEndingComma) buffer.add(', '); 132 if (emitEndingComma) buffer.add(', ');
132 } 133 }
133 134
134 bool getterAndSetterCanBeImplementedByFieldSpec(Element member, 135 bool getterAndSetterCanBeImplementedByFieldSpec(Element member,
135 String name, 136 String name,
136 bool needsGetter, 137 bool needsGetter,
137 bool needsSetter) { 138 bool needsSetter) {
138 return false; 139 return false;
139 } 140 }
140 } 141 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698