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

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

Issue 10832136: Skeleton typedef type implementation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased and updated cf. comments Created 8 years, 4 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 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
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); 187 Type 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
190 // typedef(s).
189 int arity = type.computeArity(); 191 int arity = type.computeArity();
190 code.add(' $name = $closureConverter($name, $arity);\n'); 192 code.add(' $name = $closureConverter($name, $arity);\n');
191 } 193 }
192 }); 194 });
193 } 195 }
194 196
195 String generateParameterStub(Element member, 197 String generateParameterStub(Element member,
196 String invocationName, 198 String invocationName,
197 String stubParameters, 199 String stubParameters,
198 List<String> argumentsBuffer, 200 List<String> argumentsBuffer,
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 354
353 nativeBuffer.add('})();\n'); 355 nativeBuffer.add('})();\n');
354 } 356 }
355 } 357 }
356 358
357 bool isSupertypeOfNativeClass(Element element) { 359 bool isSupertypeOfNativeClass(Element element) {
358 if (element.isTypeVariable()) { 360 if (element.isTypeVariable()) {
359 compiler.cancel("Is check for type variable", element: element); 361 compiler.cancel("Is check for type variable", element: element);
360 return false; 362 return false;
361 } 363 }
362 if (element.computeType(compiler) is FunctionType) return false; 364 if (element.computeType(compiler).unalias(compiler) is FunctionType) {
365 // The element type is a function type either directly or through
366 // typedef(s).
367 return false;
368 }
363 369
364 if (!element.isClass()) { 370 if (!element.isClass()) {
365 compiler.cancel("Is check does not handle element", element: element); 371 compiler.cancel("Is check does not handle element", element: element);
366 return false; 372 return false;
367 } 373 }
368 374
369 return subtypes[element] !== null; 375 return subtypes[element] !== null;
370 } 376 }
371 377
372 bool requiresNativeIsCheck(Element element) { 378 bool requiresNativeIsCheck(Element element) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 if (!first) targetBuffer.add(",\n"); 432 if (!first) targetBuffer.add(",\n");
427 targetBuffer.add(" $name: $function"); 433 targetBuffer.add(" $name: $function");
428 first = false; 434 first = false;
429 }); 435 });
430 targetBuffer.add("\n});\n\n"); 436 targetBuffer.add("\n});\n\n");
431 } 437 }
432 targetBuffer.add('$nativeBuffer'); 438 targetBuffer.add('$nativeBuffer');
433 targetBuffer.add('\n'); 439 targetBuffer.add('\n');
434 } 440 }
435 } 441 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/elements/elements.dart ('k') | lib/compiler/implementation/native_handler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698