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

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

Issue 10108013: Fix for issue 2433: for stubs on native classes, only call a method with a non-mangled name when th… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/
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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dart/lib/compiler/implementation/emitter.dart ('k') | no next file » | 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 class NativeEmitter { 5 class NativeEmitter {
6 6
7 Compiler compiler; 7 Compiler compiler;
8 StringBuffer buffer; 8 StringBuffer buffer;
9 9
10 // Classes that participate in dynamic dispatch. These are the 10 // Classes that participate in dynamic dispatch. These are the
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 String className = compiler.namer.getName(classElement); 66 String className = compiler.namer.getName(classElement);
67 buffer.add(className); 67 buffer.add(className);
68 buffer.add(' = '); 68 buffer.add(' = ');
69 buffer.add(nativeCode); 69 buffer.add(nativeCode);
70 buffer.add(';\n'); 70 buffer.add(';\n');
71 71
72 String attachTo(name) => "$className.$name"; 72 String attachTo(name) => "$className.$name";
73 73
74 for (Element member in classElement.members) { 74 for (Element member in classElement.members) {
75 if (member.isInstanceMember()) { 75 if (member.isInstanceMember()) {
76 compiler.emitter.addInstanceMember( 76 compiler.emitter.addInstanceMember(member, attachTo, buffer);
77 member, attachTo, buffer, isNative: true);
78 } 77 }
79 } 78 }
80 } 79 }
81 80
82 bool isNativeLiteral(String quotedName) { 81 bool isNativeLiteral(String quotedName) {
83 return quotedName[1] === '='; 82 return quotedName[1] === '=';
84 } 83 }
85 84
86 bool isNativeGlobal(String quotedName) { 85 bool isNativeGlobal(String quotedName) {
87 return quotedName[1] === '@'; 86 return quotedName[1] === '@';
(...skipping 24 matching lines...) Expand all
112 String nativeName = toNativeName(classElement); 111 String nativeName = toNativeName(classElement);
113 bool hasUsedSelectors = false; 112 bool hasUsedSelectors = false;
114 113
115 String attachTo(String name) { 114 String attachTo(String name) {
116 hasUsedSelectors = true; 115 hasUsedSelectors = true;
117 return "$dynamicName('$name').$nativeName"; 116 return "$dynamicName('$name').$nativeName";
118 } 117 }
119 118
120 for (Element member in classElement.members) { 119 for (Element member in classElement.members) {
121 if (member.isInstanceMember()) { 120 if (member.isInstanceMember()) {
122 compiler.emitter.addInstanceMember( 121 compiler.emitter.addInstanceMember(member, attachTo, buffer);
123 member, attachTo, buffer, isNative: true);
124 } 122 }
125 } 123 }
126 124
127 compiler.emitter.generateTypeTests(classElement, (Element other) { 125 compiler.emitter.generateTypeTests(classElement, (Element other) {
128 assert(requiresNativeIsCheck(other)); 126 assert(requiresNativeIsCheck(other));
129 buffer.add('${attachTo(compiler.namer.operatorIs(other))} = '); 127 buffer.add('${attachTo(compiler.namer.operatorIs(other))} = ');
130 buffer.add('function() { return true; };\n'); 128 buffer.add('function() { return true; };\n');
131 }); 129 });
132 130
133 if (hasUsedSelectors) classesWithDynamicDispatch.add(classElement); 131 if (hasUsedSelectors) classesWithDynamicDispatch.add(classElement);
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 String toStringName = compiler.namer.instanceMethodName( 332 String toStringName = compiler.namer.instanceMethodName(
335 null, const SourceString('toString'), 0); 333 null, const SourceString('toString'), 0);
336 objectProperties.add("$defPropName(Object.prototype, '$toStringName', "); 334 objectProperties.add("$defPropName(Object.prototype, '$toStringName', ");
337 objectProperties.add( 335 objectProperties.add(
338 'function() { return $toStringHelperName(this); });\n'); 336 'function() { return $toStringHelperName(this); });\n');
339 337
340 // Finally, emit the code in the main buffer. 338 // Finally, emit the code in the main buffer.
341 targetBuffer.add('(function() {\n$objectProperties$buffer\n})();\n'); 339 targetBuffer.add('(function() {\n$objectProperties$buffer\n})();\n');
342 } 340 }
343 } 341 }
OLDNEW
« no previous file with comments | « dart/lib/compiler/implementation/emitter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698