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

Unified Diff: frog/leg/native_handler.dart

Issue 9633015: Map typeName getter to the global typeNameOf. This is a unspoken rule from the native interface :) (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « frog/leg/elements/elements.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/native_handler.dart
===================================================================
--- frog/leg/native_handler.dart (revision 5159)
+++ frog/leg/native_handler.dart (working copy)
@@ -137,10 +137,28 @@
compiler.registerStaticUse(
compiler.findHelper(new SourceString('captureStackTrace')));
+ FunctionElement element = builder.work.element;
+ NativeEmitter nativeEmitter = compiler.emitter.nativeEmitter;
+ // If what we're compiling is a getter named 'typeName' and the native
+ // class is named 'DOMType', we generate a call to the typeNameOf
+ // function attached on the isolate.
+ // The DOM classes assume that their 'typeName' property, which is
+ // not a JS property on the DOM types, returns the type name.
+ if (element.name == const SourceString('typeName')
+ && element.isGetter()
+ && nativeEmitter.toNativeName(element.enclosingElement) == 'DOMType') {
+ DartString jsCode = new DartString.literal(
+ '${nativeEmitter.typeNameOfName}(\$0)');
+ List<HInstruction> inputs =
+ <HInstruction>[builder.localsHandler.readThis()];
+ builder.push(new HForeign(
+ jsCode, const LiteralDartString('String'), inputs));
+ return;
+ }
+
if (node.arguments.isEmpty()) {
List<String> arguments = <String>[];
List<HInstruction> inputs = <HInstruction>[];
- FunctionElement element = builder.work.element;
FunctionParameters parameters = element.computeParameters(builder.compiler);
int i = 0;
String receiver = '';
« no previous file with comments | « frog/leg/elements/elements.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698