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

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

Issue 10441071: Use the typedef arity to know how to invoke a closure given by the dom. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 6 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
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 CodeEmitterTask emitter; 7 CodeEmitterTask emitter;
8 StringBuffer nativeBuffer; 8 StringBuffer nativeBuffer;
9 9
10 // Classes that participate in dynamic dispatch. These are the 10 // Classes that participate in dynamic dispatch. These are the
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 void potentiallyConvertDartClosuresToJs(StringBuffer code, 170 void potentiallyConvertDartClosuresToJs(StringBuffer code,
171 FunctionElement member) { 171 FunctionElement member) {
172 FunctionSignature parameters = member.computeSignature(compiler); 172 FunctionSignature parameters = member.computeSignature(compiler);
173 Element converter = 173 Element converter =
174 compiler.findHelper(const SourceString('convertDartClosureToJS')); 174 compiler.findHelper(const SourceString('convertDartClosureToJS'));
175 String closureConverter = compiler.namer.isolateAccess(converter); 175 String closureConverter = compiler.namer.isolateAccess(converter);
176 parameters.forEachParameter((Element parameter) { 176 parameters.forEachParameter((Element parameter) {
177 Type type = parameter.computeType(compiler); 177 Type type = parameter.computeType(compiler);
178 if (type is FunctionType) { 178 if (type is FunctionType) {
179 String name = parameter.name.slowToString(); 179 String name = parameter.name.slowToString();
180 code.add(' $name = $closureConverter($name);\n'); 180 int arity = type.computeArity();
181 code.add(' $name = $closureConverter($name, $arity);\n');
181 } 182 }
182 }); 183 });
183 } 184 }
184 185
185 String generateParameterStub(Element member, 186 String generateParameterStub(Element member,
186 String invocationName, 187 String invocationName,
187 String stubParameters, 188 String stubParameters,
188 List<String> argumentsBuffer, 189 List<String> argumentsBuffer,
189 int indexOfLastOptionalArgumentInParameters, 190 int indexOfLastOptionalArgumentInParameters,
190 StringBuffer buffer) { 191 StringBuffer buffer) {
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 String toStringName = compiler.namer.instanceMethodName( 394 String toStringName = compiler.namer.instanceMethodName(
394 null, const SourceString('toString'), 0); 395 null, const SourceString('toString'), 0);
395 objectProperties.add("$defPropName(Object.prototype, '$toStringName', "); 396 objectProperties.add("$defPropName(Object.prototype, '$toStringName', ");
396 objectProperties.add( 397 objectProperties.add(
397 'function() { return $toStringHelperName(this); });\n'); 398 'function() { return $toStringHelperName(this); });\n');
398 399
399 targetBuffer.add('$defineNativeClassName = $defineNativeClassFunction;\n'); 400 targetBuffer.add('$defineNativeClassName = $defineNativeClassFunction;\n');
400 targetBuffer.add('$objectProperties$nativeBuffer\n'); 401 targetBuffer.add('$objectProperties$nativeBuffer\n');
401 } 402 }
402 } 403 }
OLDNEW
« no previous file with comments | « dart/lib/compiler/implementation/lib/js_helper.dart ('k') | dart/lib/compiler/implementation/native_handler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698