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

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

Issue 11795002: Revert "Retry "Emit more stuff via ASTs"" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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) 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 fieldNames.map((fieldName) => 81 fieldNames.map((fieldName) =>
82 new js.ExpressionStatement( 82 new js.ExpressionStatement(
83 new js.Assignment( 83 new js.Assignment(
84 new js.This().dot(fieldName), 84 new js.This().dot(fieldName),
85 new js.VariableUse(fieldName))))))); 85 new js.VariableUse(fieldName)))))));
86 } 86 }
87 87
88 void emitBoundClosureClassHeader(String mangledName, 88 void emitBoundClosureClassHeader(String mangledName,
89 String superName, 89 String superName,
90 List<String> fieldNames, 90 List<String> fieldNames,
91 ClassBuilder builder) { 91 CodeBuffer buffer) {
92 builder.addProperty('', buildConstructor(mangledName, fieldNames)); 92 buffer.add("$classesCollector.$mangledName = {'': ");
93 builder.addProperty('super', js.string(superName)); 93 buffer.add(
94 js.prettyPrint(buildConstructor(mangledName, fieldNames), compiler));
95 buffer.add(",\n 'super': '$superName',\n");
94 } 96 }
95 97
96 void emitClassConstructor(ClassElement classElement, ClassBuilder builder) { 98 void emitClassConstructor(ClassElement classElement, CodeBuffer buffer) {
97 // Say we have a class A with fields b, c and d, where c needs a getter and 99 // Say we have a class A with fields b, c and d, where c needs a getter and
98 // d needs both a getter and a setter. Then we produce: 100 // d needs both a getter and a setter. Then we produce:
99 // - a constructor (directly into the given [buffer]): 101 // - a constructor (directly into the given [buffer]):
100 // function A(b, c, d) { this.b = b, this.c = c, this.d = d; } 102 // function A(b, c, d) { this.b = b, this.c = c, this.d = d; }
101 // - getters and setters (stored in the [explicitGettersSetters] list): 103 // - getters and setters (stored in the [explicitGettersSetters] list):
102 // get$c : function() { return this.c; } 104 // get$c : function() { return this.c; }
103 // get$d : function() { return this.d; } 105 // get$d : function() { return this.d; }
104 // set$d : function(x) { this.d = x; } 106 // set$d : function(x) { this.d = x; }
105 List<String> fields = <String>[]; 107 List<String> fields = <String>[];
106 visitClassFields(classElement, (Element member, 108 visitClassFields(classElement, (Element member,
107 String name, 109 String name,
108 String accessorName, 110 String accessorName,
109 bool needsGetter, 111 bool needsGetter,
110 bool needsSetter, 112 bool needsSetter,
111 bool needsCheckedSetter) { 113 bool needsCheckedSetter) {
112 fields.add(name); 114 fields.add(name);
113 }); 115 });
114 String constructorName = namer.safeName(classElement.name.slowToString()); 116 String constructorName = namer.safeName(classElement.name.slowToString());
115 117 buffer.add("'': ");
116 builder.addProperty('', buildConstructor(constructorName, fields)); 118 buffer.add(
119 js.prettyPrint(buildConstructor(constructorName, fields), compiler));
117 } 120 }
118 121
119 void emitSuper(String superName, ClassBuilder builder) { 122 void emitSuper(String superName, CodeBuffer buffer) {
120 if (superName != '') { 123 if (superName != '') {
121 builder.addProperty('super', js.string(superName)); 124 buffer.add(",\n 'super': '$superName'");
122 } 125 }
123 } 126 }
124 127
125 void emitClassFields(ClassElement classElement, 128 void emitClassFields(ClassElement classElement,
126 ClassBuilder builder, 129 CodeBuffer buffer,
130 bool emitEndingComma,
127 { String superClass: "", 131 { String superClass: "",
128 bool classIsNative: false}) { 132 bool classIsNative: false}) {
133 if (emitEndingComma) buffer.add(', ');
129 } 134 }
130 135
131 bool get getterAndSetterCanBeImplementedByFieldSpec => false; 136 bool get getterAndSetterCanBeImplementedByFieldSpec => false;
132 } 137 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698