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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart

Issue 1040623002: Clean up naming scheme for reflection names. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Exclude methods that are not reflectable Created 5 years, 9 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 | « no previous file | pkg/compiler/lib/src/js_emitter/old_emitter/setup_program_builder.dart » ('j') | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 part of dart2js.js_emitter; 5 part of dart2js.js_emitter;
6 6
7 7
8 class OldEmitter implements Emitter { 8 class OldEmitter implements Emitter {
9 final Compiler compiler; 9 final Compiler compiler;
10 final CodeEmitterTask task; 10 final CodeEmitterTask task;
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 } 354 }
355 if (elementOrSelector is Element && elementOrSelector.isClosure) { 355 if (elementOrSelector is Element && elementOrSelector.isClosure) {
356 // Closures are synthesized and their name might conflict with existing 356 // Closures are synthesized and their name might conflict with existing
357 // globals. Assign an illegal name, and make sure they don't clash 357 // globals. Assign an illegal name, and make sure they don't clash
358 // with each other. 358 // with each other.
359 return " $mangledName"; 359 return " $mangledName";
360 } 360 }
361 if (elementOrSelector is Selector 361 if (elementOrSelector is Selector
362 || elementOrSelector.isFunction 362 || elementOrSelector.isFunction
363 || elementOrSelector.isConstructor) { 363 || elementOrSelector.isConstructor) {
364 int requiredParameterCount; 364 int positionalParameterCount;
365 int optionalParameterCount;
366 String namedArguments = ''; 365 String namedArguments = '';
367 bool isConstructor = false; 366 bool isConstructor = false;
368 if (elementOrSelector is Selector) { 367 if (elementOrSelector is Selector) {
369 Selector selector = elementOrSelector; 368 Selector selector = elementOrSelector;
370 requiredParameterCount = selector.argumentCount; 369 positionalParameterCount = selector.positionalArgumentCount;
371 optionalParameterCount = 0;
372 namedArguments = namedParametersAsReflectionNames(selector); 370 namedArguments = namedParametersAsReflectionNames(selector);
373 } else { 371 } else {
374 FunctionElement function = elementOrSelector; 372 FunctionElement function = elementOrSelector;
375 if (function.isConstructor) { 373 if (function.isConstructor) {
376 isConstructor = true; 374 isConstructor = true;
377 name = Elements.reconstructConstructorName(function); 375 name = Elements.reconstructConstructorName(function);
378 } 376 }
379 FunctionSignature signature = function.functionSignature; 377 FunctionSignature signature = function.functionSignature;
380 requiredParameterCount = signature.requiredParameterCount; 378 positionalParameterCount = signature.requiredParameterCount;
381 optionalParameterCount = signature.optionalParameterCount;
382 if (signature.optionalParametersAreNamed) { 379 if (signature.optionalParametersAreNamed) {
383 var names = []; 380 var names = [];
384 for (Element e in signature.optionalParameters) { 381 for (Element e in signature.optionalParameters) {
385 names.add(e.name); 382 names.add(e.name);
386 } 383 }
387 Selector selector = new Selector.call( 384 Selector selector = new Selector.call(
388 function.name, 385 function.name,
389 function.library, 386 function.library,
390 requiredParameterCount, 387 positionalParameterCount,
391 names); 388 names);
392 namedArguments = namedParametersAsReflectionNames(selector); 389 namedArguments = namedParametersAsReflectionNames(selector);
393 } else { 390 } else {
394 // Named parameters are handled differently by mirrors. For unnamed 391 // Named parameters are handled differently by mirrors. For unnamed
395 // parameters, they are actually required if invoked 392 // parameters, they are actually required if invoked
396 // reflectively. Also, if you have a method c(x) and c([x]) they both 393 // reflectively. Also, if you have a method c(x) and c([x]) they both
397 // get the same mangled name, so they must have the same reflection 394 // get the same mangled name, so they must have the same reflection
398 // name. 395 // name.
399 requiredParameterCount += optionalParameterCount; 396 positionalParameterCount += signature.optionalParameterCount;
400 optionalParameterCount = 0;
401 } 397 }
402 } 398 }
403 String suffix = 399 String suffix = '$name:$positionalParameterCount$namedArguments';
404 // TODO(ahe): We probably don't need optionalParameterCount in the
405 // reflection name.
406 '$name:$requiredParameterCount:$optionalParameterCount'
407 '$namedArguments';
408 return (isConstructor) ? 'new $suffix' : suffix; 400 return (isConstructor) ? 'new $suffix' : suffix;
409 } 401 }
410 Element element = elementOrSelector; 402 Element element = elementOrSelector;
411 if (element.isGenerativeConstructorBody) { 403 if (element.isGenerativeConstructorBody) {
412 return null; 404 return null;
413 } else if (element.isClass) { 405 } else if (element.isClass) {
414 ClassElement cls = element; 406 ClassElement cls = element;
415 if (cls.isUnnamedMixinApplication) return null; 407 if (cls.isUnnamedMixinApplication) return null;
416 return cls.name; 408 return cls.name;
417 } else if (element.isTypedef) { 409 } else if (element.isTypedef) {
(...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { 1796 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) {
1805 if (element.isInstanceMember) { 1797 if (element.isInstanceMember) {
1806 cachedClassBuilders.remove(element.enclosingClass); 1798 cachedClassBuilders.remove(element.enclosingClass);
1807 1799
1808 nativeEmitter.cachedBuilders.remove(element.enclosingClass); 1800 nativeEmitter.cachedBuilders.remove(element.enclosingClass);
1809 1801
1810 } 1802 }
1811 } 1803 }
1812 } 1804 }
1813 } 1805 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/old_emitter/setup_program_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698