| 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 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 // ids are meaningful (or even deterministic), but in the current | 614 // ids are meaningful (or even deterministic), but in the current |
| 615 // implementation they are increasing within a source file. | 615 // implementation they are increasing within a source file. |
| 616 return class1.id - class2.id; | 616 return class1.id - class2.id; |
| 617 }); | 617 }); |
| 618 | 618 |
| 619 // If we need noSuchMethod support, we run through all needed | 619 // If we need noSuchMethod support, we run through all needed |
| 620 // classes to figure out if we need the support on any native | 620 // classes to figure out if we need the support on any native |
| 621 // class. If so, we let the native emitter deal with it. | 621 // class. If so, we let the native emitter deal with it. |
| 622 if (compiler.enabledNoSuchMethod) { | 622 if (compiler.enabledNoSuchMethod) { |
| 623 SourceString noSuchMethodName = Compiler.NO_SUCH_METHOD; | 623 SourceString noSuchMethodName = Compiler.NO_SUCH_METHOD; |
| 624 Selector noSuchMethodSelector = new Selector.noSuchMethod(); |
| 624 for (ClassElement element in sortedClasses) { | 625 for (ClassElement element in sortedClasses) { |
| 625 if (!element.isNative()) continue; | 626 if (!element.isNative()) continue; |
| 626 Element member = element.lookupLocalMember(noSuchMethodName); | 627 Element member = element.lookupLocalMember(noSuchMethodName); |
| 627 if (member === null) continue; | 628 if (member === null) continue; |
| 628 if (Selector.INVOCATION_2.applies(member, compiler)) { | 629 if (noSuchMethodSelector.applies(member, compiler)) { |
| 629 nativeEmitter.handleNoSuchMethod = true; | 630 nativeEmitter.handleNoSuchMethod = true; |
| 630 break; | 631 break; |
| 631 } | 632 } |
| 632 } | 633 } |
| 633 } | 634 } |
| 634 | 635 |
| 635 for (ClassElement element in sortedClasses) { | 636 for (ClassElement element in sortedClasses) { |
| 636 generateClass(element, buffer); | 637 generateClass(element, buffer); |
| 637 } | 638 } |
| 638 | 639 |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1045 | 1046 |
| 1046 String buildIsolateSetup(CodeBuffer buffer, | 1047 String buildIsolateSetup(CodeBuffer buffer, |
| 1047 Element appMain, | 1048 Element appMain, |
| 1048 Element isolateMain) { | 1049 Element isolateMain) { |
| 1049 String mainAccess = "${namer.isolateAccess(appMain)}"; | 1050 String mainAccess = "${namer.isolateAccess(appMain)}"; |
| 1050 String currentIsolate = "${namer.CURRENT_ISOLATE}"; | 1051 String currentIsolate = "${namer.CURRENT_ISOLATE}"; |
| 1051 String mainEnsureGetter = ''; | 1052 String mainEnsureGetter = ''; |
| 1052 // Since we pass the closurized version of the main method to | 1053 // Since we pass the closurized version of the main method to |
| 1053 // the isolate method, we must make sure that it exists. | 1054 // the isolate method, we must make sure that it exists. |
| 1054 if (!compiler.codegenWorld.staticFunctionsNeedingGetter.contains(appMain)) { | 1055 if (!compiler.codegenWorld.staticFunctionsNeedingGetter.contains(appMain)) { |
| 1055 String invocationName = | 1056 Selector selector = new Selector.callAny(0); |
| 1056 "${namer.closureInvocationName(Selector.INVOCATION_0)}"; | 1057 String invocationName = "${namer.closureInvocationName(selector)}"; |
| 1057 mainEnsureGetter = "$mainAccess.$invocationName = $mainAccess"; | 1058 mainEnsureGetter = "$mainAccess.$invocationName = $mainAccess"; |
| 1058 } | 1059 } |
| 1059 | 1060 |
| 1060 // TODO(ngeoffray): These globals are currently required by the isolate | 1061 // TODO(ngeoffray): These globals are currently required by the isolate |
| 1061 // library, but since leg already generates code on an Isolate object, they | 1062 // library, but since leg already generates code on an Isolate object, they |
| 1062 // are not really needed. We should remove them once Leg replaces Frog. | 1063 // are not really needed. We should remove them once Leg replaces Frog. |
| 1063 buffer.add(""" | 1064 buffer.add(""" |
| 1064 var \$globalThis = $currentIsolate; | 1065 var \$globalThis = $currentIsolate; |
| 1065 var \$globalState; | 1066 var \$globalState; |
| 1066 var \$globals; | 1067 var \$globals; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1173 sourceName = token.slowToString(); | 1174 sourceName = token.slowToString(); |
| 1174 } | 1175 } |
| 1175 int totalOffset = bufferOffset + offset; | 1176 int totalOffset = bufferOffset + offset; |
| 1176 sourceMapBuilder.addMapping( | 1177 sourceMapBuilder.addMapping( |
| 1177 sourceFile, token.charOffset, sourceName, totalOffset); | 1178 sourceFile, token.charOffset, sourceName, totalOffset); |
| 1178 }); | 1179 }); |
| 1179 } | 1180 } |
| 1180 } | 1181 } |
| 1181 | 1182 |
| 1182 typedef void DefineMemberFunction(String invocationName, CodeBuffer definition); | 1183 typedef void DefineMemberFunction(String invocationName, CodeBuffer definition); |
| OLD | NEW |