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

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

Issue 12342036: Emit substitution functions on Object. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Emit substitutions on Object. Created 7 years, 9 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
« no previous file with comments | « no previous file | tests/html/html.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 NativeEmitter { 7 class NativeEmitter {
8 8
9 CodeEmitterTask emitter; 9 CodeEmitterTask emitter;
10 CodeBuffer nativeBuffer; 10 CodeBuffer nativeBuffer;
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 // Because of native classes, we have to generate some is checks 469 // Because of native classes, we have to generate some is checks
470 // by calling a method, instead of accessing a property. So we 470 // by calling a method, instead of accessing a property. So we
471 // attach to the JS Object prototype these methods that return 471 // attach to the JS Object prototype these methods that return
472 // false, and will be overridden by subclasses when they have to 472 // false, and will be overridden by subclasses when they have to
473 // return true. 473 // return true.
474 void emitIsChecks() { 474 void emitIsChecks() {
475 for (ClassElement element in 475 for (ClassElement element in
476 Elements.sortedByPosition(emitter.checkedClasses)) { 476 Elements.sortedByPosition(emitter.checkedClasses)) {
477 if (!requiresNativeIsCheck(element)) continue; 477 if (!requiresNativeIsCheck(element)) continue;
478 if (element.isObject(compiler)) continue; 478 if (element.isObject(compiler)) continue;
479 // Add function for the is-test.
479 String name = backend.namer.operatorIs(element); 480 String name = backend.namer.operatorIs(element);
480 addProperty(name, 481 addProperty(name,
481 js.fun([], js.return_(js['false']))); 482 js.fun([], js.return_(js['false'])));
483 // Add a function for the (trivial) substitution.
484 addProperty(backend.namer.substitutionName(element),
485 js.fun([], js.return_(js['null'])));
482 } 486 }
483 } 487 }
484 emitIsChecks(); 488 emitIsChecks();
485 489
486 jsAst.Expression makeCallOnThis(String functionName) { 490 jsAst.Expression makeCallOnThis(String functionName) {
487 // Because we know the function is intercepted, we need an extra 491 // Because we know the function is intercepted, we need an extra
488 // parameter. 492 // parameter.
489 return js.fun(['_'], js.return_(js['$functionName(this)'])); 493 return js.fun(['_'], js.return_(js['$functionName(this)']));
490 } 494 }
491 495
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 if (emitter.compiler.enableMinification) targetBuffer.add(';'); 536 if (emitter.compiler.enableMinification) targetBuffer.add(';');
533 targetBuffer.add(jsAst.prettyPrint( 537 targetBuffer.add(jsAst.prettyPrint(
534 new jsAst.ExpressionStatement(init), compiler)); 538 new jsAst.ExpressionStatement(init), compiler));
535 targetBuffer.add('\n'); 539 targetBuffer.add('\n');
536 } 540 }
537 541
538 targetBuffer.add(nativeBuffer); 542 targetBuffer.add(nativeBuffer);
539 targetBuffer.add('\n'); 543 targetBuffer.add('\n');
540 } 544 }
541 } 545 }
OLDNEW
« no previous file with comments | « no previous file | tests/html/html.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698