OLD | NEW |
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 CodeBuffer nativeBuffer; | 8 CodeBuffer nativeBuffer; |
9 | 9 |
10 // Classes that participate in dynamic dispatch. These are the | 10 // Classes that participate in dynamic dispatch. These are the |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 List<String> argumentsBuffer) { | 177 List<String> argumentsBuffer) { |
178 FunctionSignature parameters = member.computeSignature(compiler); | 178 FunctionSignature parameters = member.computeSignature(compiler); |
179 Element converter = | 179 Element converter = |
180 compiler.findHelper(const SourceString('convertDartClosureToJS')); | 180 compiler.findHelper(const SourceString('convertDartClosureToJS')); |
181 String closureConverter = compiler.namer.isolateAccess(converter); | 181 String closureConverter = compiler.namer.isolateAccess(converter); |
182 parameters.forEachParameter((Element parameter) { | 182 parameters.forEachParameter((Element parameter) { |
183 String name = parameter.name.slowToString(); | 183 String name = parameter.name.slowToString(); |
184 // If [name] is not in [argumentsBuffer], then the parameter is | 184 // If [name] is not in [argumentsBuffer], then the parameter is |
185 // an optional parameter that was not provided for that stub. | 185 // an optional parameter that was not provided for that stub. |
186 if (argumentsBuffer.indexOf(name) == -1) return; | 186 if (argumentsBuffer.indexOf(name) == -1) return; |
187 Type type = parameter.computeType(compiler).unalias(compiler); | 187 DartType type = parameter.computeType(compiler).unalias(compiler); |
188 if (type is FunctionType) { | 188 if (type is FunctionType) { |
189 // The parameter type is a function type either directly or through | 189 // The parameter type is a function type either directly or through |
190 // typedef(s). | 190 // typedef(s). |
191 int arity = type.computeArity(); | 191 int arity = type.computeArity(); |
192 code.add(' $name = $closureConverter($name, $arity);\n'); | 192 code.add(' $name = $closureConverter($name, $arity);\n'); |
193 } | 193 } |
194 }); | 194 }); |
195 } | 195 } |
196 | 196 |
197 String generateParameterStub(Element member, | 197 String generateParameterStub(Element member, |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 if (!first) targetBuffer.add(",\n"); | 432 if (!first) targetBuffer.add(",\n"); |
433 targetBuffer.add(" $name: $function"); | 433 targetBuffer.add(" $name: $function"); |
434 first = false; | 434 first = false; |
435 }); | 435 }); |
436 targetBuffer.add("\n});\n\n"); | 436 targetBuffer.add("\n});\n\n"); |
437 } | 437 } |
438 targetBuffer.add('$nativeBuffer'); | 438 targetBuffer.add('$nativeBuffer'); |
439 targetBuffer.add('\n'); | 439 targetBuffer.add('\n'); |
440 } | 440 } |
441 } | 441 } |
OLD | NEW |