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

Unified Diff: lib/compiler/implementation/native_emitter.dart

Issue 10202018: Fix bug http://code.google.com/p/dart/issues/detail?id=2718: methods that are implemented by the ht… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/tests/client/client-leg.status ('k') | lib/compiler/implementation/native_handler.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/native_emitter.dart
===================================================================
--- lib/compiler/implementation/native_emitter.dart (revision 7015)
+++ lib/compiler/implementation/native_emitter.dart (working copy)
@@ -26,12 +26,17 @@
// to its subclass if it sees an instance whose class is a subclass.
Set<FunctionElement> overriddenMethods;
+ // Caches the methods that should just call a native JS
+ // implementation.
+ Set<FunctionElement> nativeMethods;
+
NativeEmitter(this.compiler)
: classesWithDynamicDispatch = new Set<ClassElement>(),
nativeClasses = new Set<ClassElement>(),
subtypes = new Map<ClassElement, List<ClassElement>>(),
directSubtypes = new Map<ClassElement, List<ClassElement>>(),
overriddenMethods = new Set<FunctionElement>(),
+ nativeMethods = new Set<FunctionElement>(),
buffer = new StringBuffer();
String get dynamicName() {
@@ -179,8 +184,16 @@
StringBuffer code = new StringBuffer();
potentiallyConvertDartClosuresToJs(code, member);
- String name = member.name.slowToString();
- code.add(' return this.$name($nativeArguments);');
+ if (!nativeMethods.contains(member)) {
+ // When calling a method that has a native body, we call it
+ // with our calling conventions.
+ String arguments = Strings.join(argumentsBuffer, ",");
+ code.add(' return this.${compiler.namer.getName(member)}($arguments)');
+ } else {
+ // When calling a JS method, we call it with the native name.
+ String name = member.name.slowToString();
+ code.add(' return this.$name($nativeArguments);');
+ }
if (isNativeLiteral(nativeName) || !overriddenMethods.contains(member)) {
// Call the method directly.
« no previous file with comments | « client/tests/client/client-leg.status ('k') | lib/compiler/implementation/native_handler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698