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

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

Issue 10363003: Compute function types together with the parameters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 #library('native'); 5 #library('native');
6 #import('dart:uri'); 6 #import('dart:uri');
7 #import('leg.dart'); 7 #import('leg.dart');
8 #import('elements/elements.dart'); 8 #import('elements/elements.dart');
9 #import('scanner/scannerlib.dart'); 9 #import('scanner/scannerlib.dart');
10 #import('ssa/ssa.dart'); 10 #import('ssa/ssa.dart');
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 isRedirecting = true; 243 isRedirecting = true;
244 } else { 244 } else {
245 hasBody = true; 245 hasBody = true;
246 } 246 }
247 } 247 }
248 248
249 if (!hasBody) { 249 if (!hasBody) {
250 compiler.emitter.nativeEmitter.nativeMethods.add(element); 250 compiler.emitter.nativeEmitter.nativeMethods.add(element);
251 } 251 }
252 252
253 FunctionParameters parameters = element.computeParameters(builder.compiler); 253 FunctionSignature parameters = element.computeSignature(builder.compiler);
254 if (!hasBody) { 254 if (!hasBody) {
255 List<String> arguments = <String>[]; 255 List<String> arguments = <String>[];
256 List<HInstruction> inputs = <HInstruction>[]; 256 List<HInstruction> inputs = <HInstruction>[];
257 String receiver = ''; 257 String receiver = '';
258 if (element.isInstanceMember()) { 258 if (element.isInstanceMember()) {
259 receiver = '#.'; 259 receiver = '#.';
260 inputs.add(builder.localsHandler.readThis()); 260 inputs.add(builder.localsHandler.readThis());
261 } 261 }
262 parameters.forEachParameter((Element parameter) { 262 parameters.forEachParameter((Element parameter) {
263 Type type = parameter.computeType(compiler); 263 Type type = parameter.computeType(compiler);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 } 310 }
311 311
312 void generateMethodWithPrototypeCheckForElement(Compiler compiler, 312 void generateMethodWithPrototypeCheckForElement(Compiler compiler,
313 StringBuffer buffer, 313 StringBuffer buffer,
314 FunctionElement element, 314 FunctionElement element,
315 String code, 315 String code,
316 String parameters) { 316 String parameters) {
317 String methodName; 317 String methodName;
318 Namer namer = compiler.namer; 318 Namer namer = compiler.namer;
319 if (element.kind == ElementKind.FUNCTION) { 319 if (element.kind == ElementKind.FUNCTION) {
320 FunctionParameters computedParameters = 320 FunctionSignature signature = element.computeSignature(compiler);
321 element.computeParameters(compiler);
322 methodName = namer.instanceMethodName( 321 methodName = namer.instanceMethodName(
323 element.getLibrary(), element.name, computedParameters.parameterCount); 322 element.getLibrary(), element.name, signature.parameterCount);
324 } else if (element.kind == ElementKind.GETTER) { 323 } else if (element.kind == ElementKind.GETTER) {
325 methodName = namer.getterName(element.getLibrary(), element.name); 324 methodName = namer.getterName(element.getLibrary(), element.name);
326 } else if (element.kind == ElementKind.SETTER) { 325 } else if (element.kind == ElementKind.SETTER) {
327 methodName = namer.setterName(element.getLibrary(), element.name); 326 methodName = namer.setterName(element.getLibrary(), element.name);
328 } else { 327 } else {
329 compiler.internalError('unexpected kind: "${element.kind}"', 328 compiler.internalError('unexpected kind: "${element.kind}"',
330 element: element); 329 element: element);
331 } 330 }
332 331
333 generateMethodWithPrototypeCheck( 332 generateMethodWithPrototypeCheck(
(...skipping 13 matching lines...) Expand all
347 String parameters) { 346 String parameters) {
348 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); 347 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty");
349 buffer.add("('$methodName')) {\n"); 348 buffer.add("('$methodName')) {\n");
350 buffer.add(" $code"); 349 buffer.add(" $code");
351 buffer.add(" } else {\n"); 350 buffer.add(" } else {\n");
352 buffer.add(" return Object.prototype.$methodName.call(this"); 351 buffer.add(" return Object.prototype.$methodName.call(this");
353 buffer.add(parameters == '' ? '' : ', $parameters'); 352 buffer.add(parameters == '' ? '' : ', $parameters');
354 buffer.add(");\n"); 353 buffer.add(");\n");
355 buffer.add(" }\n"); 354 buffer.add(" }\n");
356 } 355 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698