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

Side by Side Diff: lib/compiler/implementation/js_backend/native_emitter.dart

Issue 10911006: Collect the types used in is-checks in the resolver phase. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix last upload. Created 8 years, 3 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 class NativeEmitter { 5 class NativeEmitter {
6 6
7 CodeEmitterTask emitter; 7 CodeEmitterTask emitter;
8 CodeBuffer nativeBuffer; 8 CodeBuffer nativeBuffer;
9 9
10 // Classes that participate in dynamic dispatch. These are the 10 // Classes that participate in dynamic dispatch. These are the
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 } 376 }
377 377
378 bool requiresNativeIsCheck(Element element) { 378 bool requiresNativeIsCheck(Element element) {
379 if (!element.isClass()) return false; 379 if (!element.isClass()) return false;
380 ClassElement cls = element; 380 ClassElement cls = element;
381 if (cls.isNative()) return true; 381 if (cls.isNative()) return true;
382 return isSupertypeOfNativeClass(element); 382 return isSupertypeOfNativeClass(element);
383 } 383 }
384 384
385 void emitIsChecks(Map<String, String> objectProperties) { 385 void emitIsChecks(Map<String, String> objectProperties) {
386 for (Element type in compiler.codegenWorld.isChecks) { 386 for (Element element in compiler.codegenWorld.checkedClasses) {
387 if (!requiresNativeIsCheck(type)) continue; 387 if (!requiresNativeIsCheck(element)) continue;
388 String name = compiler.namer.operatorIs(type); 388 String name = compiler.namer.operatorIs(element);
389 objectProperties[name] = 'function() { return false; }'; 389 objectProperties[name] = 'function() { return false; }';
390 } 390 }
391 } 391 }
392 392
393 void assembleCode(CodeBuffer targetBuffer) { 393 void assembleCode(CodeBuffer targetBuffer) {
394 if (nativeClasses.isEmpty()) return; 394 if (nativeClasses.isEmpty()) return;
395 emitDynamicDispatchMetadata(); 395 emitDynamicDispatchMetadata();
396 targetBuffer.add('$defineNativeClassName = ' 396 targetBuffer.add('$defineNativeClassName = '
397 '$defineNativeClassFunction;\n\n'); 397 '$defineNativeClassFunction;\n\n');
398 398
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 if (!first) targetBuffer.add(",\n"); 432 if (!first) targetBuffer.add(",\n");
433 targetBuffer.add(" $name: $function"); 433 targetBuffer.add(" $name: $function");
434 first = false; 434 first = false;
435 }); 435 });
436 targetBuffer.add("\n});\n\n"); 436 targetBuffer.add("\n});\n\n");
437 } 437 }
438 targetBuffer.add('$nativeBuffer'); 438 targetBuffer.add('$nativeBuffer');
439 targetBuffer.add('\n'); 439 targetBuffer.add('\n');
440 } 440 }
441 } 441 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698