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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/full_emitter/nsm_emitter.dart

Issue 2990223002: Reformat untouched files. (Closed)
Patch Set: Created 3 years, 4 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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.js_emitter.full_emitter.nsm_emitter; 5 library dart2js.js_emitter.full_emitter.nsm_emitter;
6 6
7 import '../../elements/entities.dart'; 7 import '../../elements/entities.dart';
8 import '../../js/js.dart' as jsAst; 8 import '../../js/js.dart' as jsAst;
9 import '../../js/js.dart' show js; 9 import '../../js/js.dart' show js;
10 import '../../js_backend/js_backend.dart' show GetterName, SetterName; 10 import '../../js_backend/js_backend.dart' show GetterName, SetterName;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 sorted.map((selector) => selector.invocationMirrorMemberName); 173 sorted.map((selector) => selector.invocationMirrorMemberName);
174 } 174 }
175 } 175 }
176 // Startup code that loops over the method names and puts handlers on the 176 // Startup code that loops over the method names and puts handlers on the
177 // Object class to catch noSuchMethod invocations. 177 // Object class to catch noSuchMethod invocations.
178 ClassEntity objectClass = closedWorld.commonElements.objectClass; 178 ClassEntity objectClass = closedWorld.commonElements.objectClass;
179 jsAst.Expression createInvocationMirror = backend.emitter 179 jsAst.Expression createInvocationMirror = backend.emitter
180 .staticFunctionAccess( 180 .staticFunctionAccess(
181 closedWorld.commonElements.createInvocationMirror); 181 closedWorld.commonElements.createInvocationMirror);
182 if (useDiffEncoding) { 182 if (useDiffEncoding) {
183 statements.add(js.statement( 183 statements.add(js.statement('''{
184 '''{
185 var objectClassObject = processedClasses.collected[#objectClass], 184 var objectClassObject = processedClasses.collected[#objectClass],
186 nameSequences = #diffEncoding.split("."), 185 nameSequences = #diffEncoding.split("."),
187 shortNames = []; 186 shortNames = [];
188 if (objectClassObject instanceof Array) 187 if (objectClassObject instanceof Array)
189 objectClassObject = objectClassObject[1]; 188 objectClassObject = objectClassObject[1];
190 for (var j = 0; j < nameSequences.length; ++j) { 189 for (var j = 0; j < nameSequences.length; ++j) {
191 var sequence = nameSequences[j].split(","), 190 var sequence = nameSequences[j].split(","),
192 nameNumber = 0; 191 nameNumber = 0;
193 // If we are loading a deferred library the object class will not be 192 // If we are loading a deferred library the object class will not be
194 // in the collectedClasses so objectClassObject is undefined, and we 193 // in the collectedClasses so objectClassObject is undefined, and we
(...skipping 19 matching lines...) Expand all
214 remaining = (remaining / 88) | 0) { 213 remaining = (remaining / 88) | 0) {
215 codes.unshift(${$HASH} + remaining % 88); 214 codes.unshift(${$HASH} + remaining % 88);
216 } 215 }
217 shortNames.push( 216 shortNames.push(
218 String.fromCharCode.apply(String, codes)); 217 String.fromCharCode.apply(String, codes));
219 } 218 }
220 if (sequence.length > 1) { 219 if (sequence.length > 1) {
221 Array.prototype.push.apply(shortNames, sequence.shift()); 220 Array.prototype.push.apply(shortNames, sequence.shift());
222 } 221 }
223 } 222 }
224 }''', 223 }''', {
225 { 224 'objectClass': js.quoteName(namer.className(objectClass)),
226 'objectClass': js.quoteName(namer.className(objectClass)), 225 'diffEncoding': sortedShorts
227 'diffEncoding': sortedShorts 226 }));
228 }));
229 } else { 227 } else {
230 // No useDiffEncoding version. 228 // No useDiffEncoding version.
231 statements.add(js.statement( 229 statements.add(js.statement(
232 'var objectClassObject = processedClasses.collected[#objectClass],' 230 'var objectClassObject = processedClasses.collected[#objectClass],'
233 ' shortNames = #diffEncoding.split(",")', 231 ' shortNames = #diffEncoding.split(",")',
234 { 232 {
235 'objectClass': js.quoteName(namer.className(objectClass)), 233 'objectClass': js.quoteName(namer.className(objectClass)),
236 'diffEncoding': sortedShorts 234 'diffEncoding': sortedShorts
237 })); 235 }));
238 if (!minify) { 236 if (!minify) {
239 statements.add(js.statement('var longNames = #longs.split(",")', 237 statements.add(js.statement('var longNames = #longs.split(",")',
240 {'longs': js.string(sortedLongs.join(','))})); 238 {'longs': js.string(sortedLongs.join(','))}));
241 } 239 }
242 statements.add(js.statement('if (objectClassObject instanceof Array)' 240 statements.add(js.statement('if (objectClassObject instanceof Array)'
243 ' objectClassObject = objectClassObject[1];')); 241 ' objectClassObject = objectClassObject[1];'));
244 } 242 }
245 243
246 dynamic isIntercepted = // jsAst.Expression or bool. 244 dynamic isIntercepted = // jsAst.Expression or bool.
247 interceptedSelectors.isEmpty 245 interceptedSelectors.isEmpty
248 ? false 246 ? false
249 : ordinarySelectors.isEmpty 247 : ordinarySelectors.isEmpty
250 ? true 248 ? true
251 : js('j < #', js.number(interceptedSelectors.length)); 249 : js('j < #', js.number(interceptedSelectors.length));
252 250
253 statements.add(js.statement( 251 statements.add(js.statement('''
254 '''
255 // If we are loading a deferred library the object class will not be in 252 // If we are loading a deferred library the object class will not be in
256 // the collectedClasses so objectClassObject is undefined, and we skip 253 // the collectedClasses so objectClassObject is undefined, and we skip
257 // setting up the names. 254 // setting up the names.
258 if (objectClassObject) { 255 if (objectClassObject) {
259 for (var j = 0; j < shortNames.length; j++) { 256 for (var j = 0; j < shortNames.length; j++) {
260 var type = 0; 257 var type = 0;
261 var shortName = shortNames[j]; 258 var shortName = shortNames[j];
262 if (shortName.indexOf("${namer.getterPrefix}") == 0) type = 1; 259 if (shortName.indexOf("${namer.getterPrefix}") == 0) type = 1;
263 if (shortName.indexOf("${namer.setterPrefix}") == 0) type = 2; 260 if (shortName.indexOf("${namer.setterPrefix}") == 0) type = 2;
264 // Generate call to: 261 // Generate call to:
(...skipping 26 matching lines...) Expand all
291 // argument. We could pass anything in place of [this]. 288 // argument. We could pass anything in place of [this].
292 this, 289 this,
293 #createInvocationMirror(name, shortName, type, 290 #createInvocationMirror(name, shortName, type,
294 // Create proper Array with all arguments. 291 // Create proper Array with all arguments.
295 Array.prototype.slice.call(arguments, 0), 292 Array.prototype.slice.call(arguments, 0),
296 [])); 293 []));
297 } 294 }
298 })(#names[j], shortName, type); 295 })(#names[j], shortName, type);
299 } 296 }
300 } 297 }
301 }''', 298 }''', {
302 { 299 'noSuchMethodName': namer.noSuchMethodName,
303 'noSuchMethodName': namer.noSuchMethodName, 300 'createInvocationMirror': createInvocationMirror,
304 'createInvocationMirror': createInvocationMirror, 301 'names': minify ? 'shortNames' : 'longNames',
305 'names': minify ? 'shortNames' : 'longNames', 302 'isIntercepted': isIntercepted
306 'isIntercepted': isIntercepted 303 }));
307 }));
308 304
309 return statements; 305 return statements;
310 } 306 }
311 } 307 }
312 308
313 /// When pretty printed, this node computes a diff-encoded string for the list 309 /// When pretty printed, this node computes a diff-encoded string for the list
314 /// of given names. 310 /// of given names.
315 /// 311 ///
316 /// See [buildTrivialNsmHandlers]. 312 /// See [buildTrivialNsmHandlers].
317 class _DiffEncodedListOfNames extends jsAst.DeferredString 313 class _DiffEncodedListOfNames extends jsAst.DeferredString
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 } 401 }
406 402
407 String get value { 403 String get value {
408 if (_cachedValue == null) { 404 if (_cachedValue == null) {
409 _cachedValue = _computeDiffEncoding(); 405 _cachedValue = _computeDiffEncoding();
410 } 406 }
411 407
412 return _cachedValue; 408 return _cachedValue;
413 } 409 }
414 } 410 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698