| OLD | NEW |
| 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 Loading... |
| 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 positionalParameterCount; | 364 int requiredParameterCount; |
| 365 int optionalParameterCount; |
| 365 String namedArguments = ''; | 366 String namedArguments = ''; |
| 366 bool isConstructor = false; | 367 bool isConstructor = false; |
| 367 if (elementOrSelector is Selector) { | 368 if (elementOrSelector is Selector) { |
| 368 Selector selector = elementOrSelector; | 369 Selector selector = elementOrSelector; |
| 369 positionalParameterCount = selector.positionalArgumentCount; | 370 requiredParameterCount = selector.argumentCount; |
| 371 optionalParameterCount = 0; |
| 370 namedArguments = namedParametersAsReflectionNames(selector); | 372 namedArguments = namedParametersAsReflectionNames(selector); |
| 371 } else { | 373 } else { |
| 372 FunctionElement function = elementOrSelector; | 374 FunctionElement function = elementOrSelector; |
| 373 if (function.isConstructor) { | 375 if (function.isConstructor) { |
| 374 isConstructor = true; | 376 isConstructor = true; |
| 375 name = Elements.reconstructConstructorName(function); | 377 name = Elements.reconstructConstructorName(function); |
| 376 } | 378 } |
| 377 FunctionSignature signature = function.functionSignature; | 379 FunctionSignature signature = function.functionSignature; |
| 378 positionalParameterCount = signature.requiredParameterCount; | 380 requiredParameterCount = signature.requiredParameterCount; |
| 381 optionalParameterCount = signature.optionalParameterCount; |
| 379 if (signature.optionalParametersAreNamed) { | 382 if (signature.optionalParametersAreNamed) { |
| 380 var names = []; | 383 var names = []; |
| 381 for (Element e in signature.optionalParameters) { | 384 for (Element e in signature.optionalParameters) { |
| 382 names.add(e.name); | 385 names.add(e.name); |
| 383 } | 386 } |
| 384 Selector selector = new Selector.call( | 387 Selector selector = new Selector.call( |
| 385 function.name, | 388 function.name, |
| 386 function.library, | 389 function.library, |
| 387 positionalParameterCount, | 390 requiredParameterCount, |
| 388 names); | 391 names); |
| 389 namedArguments = namedParametersAsReflectionNames(selector); | 392 namedArguments = namedParametersAsReflectionNames(selector); |
| 390 } else { | 393 } else { |
| 391 // Named parameters are handled differently by mirrors. For unnamed | 394 // Named parameters are handled differently by mirrors. For unnamed |
| 392 // parameters, they are actually required if invoked | 395 // parameters, they are actually required if invoked |
| 393 // reflectively. Also, if you have a method c(x) and c([x]) they both | 396 // reflectively. Also, if you have a method c(x) and c([x]) they both |
| 394 // get the same mangled name, so they must have the same reflection | 397 // get the same mangled name, so they must have the same reflection |
| 395 // name. | 398 // name. |
| 396 positionalParameterCount += signature.optionalParameterCount; | 399 requiredParameterCount += optionalParameterCount; |
| 400 optionalParameterCount = 0; |
| 397 } | 401 } |
| 398 } | 402 } |
| 399 String suffix = '$name:$positionalParameterCount$namedArguments'; | 403 String suffix = |
| 404 // TODO(ahe): We probably don't need optionalParameterCount in the |
| 405 // reflection name. |
| 406 '$name:$requiredParameterCount:$optionalParameterCount' |
| 407 '$namedArguments'; |
| 400 return (isConstructor) ? 'new $suffix' : suffix; | 408 return (isConstructor) ? 'new $suffix' : suffix; |
| 401 } | 409 } |
| 402 Element element = elementOrSelector; | 410 Element element = elementOrSelector; |
| 403 if (element.isGenerativeConstructorBody) { | 411 if (element.isGenerativeConstructorBody) { |
| 404 return null; | 412 return null; |
| 405 } else if (element.isClass) { | 413 } else if (element.isClass) { |
| 406 ClassElement cls = element; | 414 ClassElement cls = element; |
| 407 if (cls.isUnnamedMixinApplication) return null; | 415 if (cls.isUnnamedMixinApplication) return null; |
| 408 return cls.name; | 416 return cls.name; |
| 409 } else if (element.isTypedef) { | 417 } else if (element.isTypedef) { |
| (...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1796 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { | 1804 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { |
| 1797 if (element.isInstanceMember) { | 1805 if (element.isInstanceMember) { |
| 1798 cachedClassBuilders.remove(element.enclosingClass); | 1806 cachedClassBuilders.remove(element.enclosingClass); |
| 1799 | 1807 |
| 1800 nativeEmitter.cachedBuilders.remove(element.enclosingClass); | 1808 nativeEmitter.cachedBuilders.remove(element.enclosingClass); |
| 1801 | 1809 |
| 1802 } | 1810 } |
| 1803 } | 1811 } |
| 1804 } | 1812 } |
| 1805 } | 1813 } |
| OLD | NEW |