| 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 /** | 5 /** |
| 6 * A function element that represents a closure call. The signature is copied | 6 * A function element that represents a closure call. The signature is copied |
| 7 * from the given element. | 7 * from the given element. |
| 8 */ | 8 */ |
| 9 class ClosureInvocationElement extends FunctionElement { | 9 class ClosureInvocationElement extends FunctionElement { |
| 10 ClosureInvocationElement(SourceString name, | 10 ClosureInvocationElement(SourceString name, |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 bool hasOptionalParameters = member.optionalParameterCount(compiler) != 0; | 697 bool hasOptionalParameters = member.optionalParameterCount(compiler) != 0; |
| 698 int parameterCount = member.parameterCount(compiler); | 698 int parameterCount = member.parameterCount(compiler); |
| 699 | 699 |
| 700 String closureClass = | 700 String closureClass = |
| 701 hasOptionalParameters ? null : boundClosureCache[parameterCount]; | 701 hasOptionalParameters ? null : boundClosureCache[parameterCount]; |
| 702 if (closureClass === null) { | 702 if (closureClass === null) { |
| 703 // Either the class was not cached yet, or there are optional parameters. | 703 // Either the class was not cached yet, or there are optional parameters. |
| 704 // Create a new closure class. | 704 // Create a new closure class. |
| 705 SourceString name = const SourceString("BoundClosure"); | 705 SourceString name = const SourceString("BoundClosure"); |
| 706 ClassElement closureClassElement = | 706 ClassElement closureClassElement = |
| 707 new ClosureClassElement(compiler, member.getCompilationUnit()); | 707 new ClosureClassElement(name, compiler, member.getCompilationUnit()); |
| 708 String mangledName = namer.getName(closureClassElement); | 708 String mangledName = namer.getName(closureClassElement); |
| 709 String superName = namer.getName(closureClassElement.superclass); | 709 String superName = namer.getName(closureClassElement.superclass); |
| 710 needsClosureClass = true; | 710 needsClosureClass = true; |
| 711 | 711 |
| 712 // Define the constructor with a name so that Object.toString can | 712 // Define the constructor with a name so that Object.toString can |
| 713 // find the class name of the closure class. | 713 // find the class name of the closure class. |
| 714 boundClosureBuffer.add("$defineClassName('$mangledName', '$superName', "); | 714 boundClosureBuffer.add("$defineClassName('$mangledName', '$superName', "); |
| 715 boundClosureBuffer.add("['self', 'target'], {\n"); | 715 boundClosureBuffer.add("['self', 'target'], {\n"); |
| 716 | 716 |
| 717 // Now add the methods on the closure class. The instance method does not | 717 // Now add the methods on the closure class. The instance method does not |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 null, sourceMap, new api.Diagnostic(-1, 'source map')); | 1055 null, sourceMap, new api.Diagnostic(-1, 'source map')); |
| 1056 } | 1056 } |
| 1057 }); | 1057 }); |
| 1058 return compiler.assembledCode; | 1058 return compiler.assembledCode; |
| 1059 } | 1059 } |
| 1060 } | 1060 } |
| 1061 | 1061 |
| 1062 typedef void DefineMemberFunction(String invocationName, | 1062 typedef void DefineMemberFunction(String invocationName, |
| 1063 String definition, | 1063 String definition, |
| 1064 [List<SourceMappingEntry> sourceMappings]); | 1064 [List<SourceMappingEntry> sourceMappings]); |
| OLD | NEW |