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

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

Issue 10092012: Fix issue 2358: dart methods on native classes must also check if the current prototype has the met… (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
Index: lib/compiler/implementation/native_emitter.dart
===================================================================
--- lib/compiler/implementation/native_emitter.dart (revision 6616)
+++ lib/compiler/implementation/native_emitter.dart (working copy)
@@ -160,28 +160,15 @@
String nativeName = classElement.nativeName.slowToString();
String nativeArguments = Strings.join(nativeArgumentsBuffer, ",");
+ String name = member.name.slowToString();
+ String code = ' return this.$name($nativeArguments);\n';
if (isNativeLiteral(nativeName) || !overriddenMethods.contains(member)) {
// Call the method directly.
- buffer.add(' return this.${member.name.slowToString()}');
- buffer.add('($nativeArguments)');
- return;
+ buffer.add(code);
+ } else {
+ native.generateMethodWithPrototypeCheck(
+ compiler, buffer, invocationName, code, stubParameters);
}
-
- // If the method is overridden, we must check if the prototype of
- // 'this' has the method available. Otherwise, we may end up
- // calling the method from the super class. If the method is not
- // available, we make a direct call to
- // Object.prototype.$invocationName. This method will patch the
- // prototype of 'this' to the real method.
-
- buffer.add(' if (Object.getPrototypeOf(this).hasOwnProperty(');
- buffer.add("'$invocationName')) {\n");
- buffer.add(' return this.${member.name.slowToString()}');
- buffer.add('($nativeArguments)');
- buffer.add('\n }\n');
- buffer.add(' return Object.prototype.$invocationName.call(this');
- buffer.add(stubParameters == '' ? '' : ', $stubParameters');
- buffer.add(');');
}
void emitDynamicDispatchMetadata() {
« no previous file with comments | « frog/tests/native/src/NativeClassInheritance4FrogTest.dart ('k') | lib/compiler/implementation/native_handler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698