Chromium Code Reviews| 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 class Interceptors { | 5 class Interceptors { |
| 6 Compiler compiler; | 6 Compiler compiler; |
| 7 Interceptors(Compiler this.compiler); | 7 Interceptors(Compiler this.compiler); |
| 8 | 8 |
| 9 SourceString mapOperatorToMethodName(Operator op) { | 9 SourceString mapOperatorToMethodName(Operator op) { |
| 10 String name = op.source.stringValue; | 10 String name = op.source.stringValue; |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 704 // block is closed. | 704 // block is closed. |
| 705 HBasicBlock lastOpenedBlock; | 705 HBasicBlock lastOpenedBlock; |
| 706 | 706 |
| 707 // Linked list of active break-handlers. Will be removed in the order | 707 // Linked list of active break-handlers. Will be removed in the order |
| 708 // they are added. | 708 // they are added. |
| 709 BreakHandler currentBreakHandler = const NullBreakHandler(); | 709 BreakHandler currentBreakHandler = const NullBreakHandler(); |
| 710 // The break handler to use for an upcoming loop statement (temporarily set | 710 // The break handler to use for an upcoming loop statement (temporarily set |
| 711 // if a labeled statement is labeling a loop). | 711 // if a labeled statement is labeling a loop). |
| 712 BreakHandler loopBreakHandler = null; | 712 BreakHandler loopBreakHandler = null; |
| 713 | 713 |
| 714 LibraryElement get currentLibrary() => work.element.getLibrary(); | |
| 715 | |
| 714 SsaBuilder(Compiler compiler, WorkItem work) | 716 SsaBuilder(Compiler compiler, WorkItem work) |
| 715 : this.compiler = compiler, | 717 : this.compiler = compiler, |
| 716 this.work = work, | 718 this.work = work, |
| 717 interceptors = compiler.builder.interceptors, | 719 interceptors = compiler.builder.interceptors, |
| 718 methodInterceptionEnabled = true, | 720 methodInterceptionEnabled = true, |
| 719 elements = work.resolutionTree, | 721 elements = work.resolutionTree, |
| 720 graph = new HGraph(), | 722 graph = new HGraph(), |
| 721 stack = new List<HInstruction>(), | 723 stack = new List<HInstruction>(), |
| 722 breakTargets = new Map<StatementElement, BreakHandler>() { | 724 breakTargets = new Map<StatementElement, BreakHandler>() { |
| 723 localsHandler = new LocalsHandler(this); | 725 localsHandler = new LocalsHandler(this); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 889 // TODO(floitsch): find better way to detect that constructor body is | 891 // TODO(floitsch): find better way to detect that constructor body is |
| 890 // empty. | 892 // empty. |
| 891 if (constructor is SynthesizedConstructorElement) continue; | 893 if (constructor is SynthesizedConstructorElement) continue; |
| 892 ConstructorBodyElement body = getConstructorBody(classElement, | 894 ConstructorBodyElement body = getConstructorBody(classElement, |
| 893 constructor); | 895 constructor); |
| 894 List bodyCallInputs = <HInstruction>[]; | 896 List bodyCallInputs = <HInstruction>[]; |
| 895 bodyCallInputs.add(newObject); | 897 bodyCallInputs.add(newObject); |
| 896 body.functionParameters.forEachParameter((parameter) { | 898 body.functionParameters.forEachParameter((parameter) { |
| 897 bodyCallInputs.add(localsHandler.readLocal(parameter)); | 899 bodyCallInputs.add(localsHandler.readLocal(parameter)); |
| 898 }); | 900 }); |
| 899 SourceString methodName = body.name; | 901 SourceString methodName; |
| 902 if (body.name.isPrivate()) { | |
|
ngeoffray
2012/03/13 12:47:11
Why do you need to do this and avoid it in codegen
floitsch
2012/03/13 13:28:56
I'm don't think this is necessary at all.
Construc
ahe
2012/03/17 22:19:44
I'm not sure how to invoke a statically resolved m
| |
| 903 methodName = new SourceString(compiler.namer.instanceMethodName( | |
| 904 constructor.getLibrary(), body.name, bodyCallInputs.length - 1)); | |
| 905 } else { | |
| 906 methodName = body.name; | |
| 907 } | |
| 900 add(new HInvokeDynamicMethod(null, methodName, bodyCallInputs)); | 908 add(new HInvokeDynamicMethod(null, methodName, bodyCallInputs)); |
| 901 } | 909 } |
| 902 close(new HReturn(newObject)).addSuccessor(graph.exit); | 910 close(new HReturn(newObject)).addSuccessor(graph.exit); |
| 903 return closeFunction(); | 911 return closeFunction(); |
| 904 } | 912 } |
| 905 | 913 |
| 906 void openFunction(FunctionElement functionElement, | 914 void openFunction(FunctionElement functionElement, |
| 907 FunctionExpression node) { | 915 FunctionExpression node) { |
| 908 HBasicBlock block = graph.addNewBlock(); | 916 HBasicBlock block = graph.addNewBlock(); |
| 909 open(graph.entry); | 917 open(graph.entry); |
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1754 visit(expression); | 1762 visit(expression); |
| 1755 enableMethodInterception(); | 1763 enableMethodInterception(); |
| 1756 break; | 1764 break; |
| 1757 case "JS_HAS_EQUALS": | 1765 case "JS_HAS_EQUALS": |
| 1758 List<HInstruction> inputs = <HInstruction>[]; | 1766 List<HInstruction> inputs = <HInstruction>[]; |
| 1759 if (!node.arguments.tail.isEmpty()) { | 1767 if (!node.arguments.tail.isEmpty()) { |
| 1760 compiler.cancel('More than one expression in JS_HAS_EQUALS()'); | 1768 compiler.cancel('More than one expression in JS_HAS_EQUALS()'); |
| 1761 } | 1769 } |
| 1762 addGenericSendArgumentsToList(node.arguments, inputs); | 1770 addGenericSendArgumentsToList(node.arguments, inputs); |
| 1763 String name = compiler.namer.instanceMethodName( | 1771 String name = compiler.namer.instanceMethodName( |
| 1764 Namer.OPERATOR_EQUALS, 1); | 1772 currentLibrary, Namer.OPERATOR_EQUALS, 1); |
| 1765 push(new HForeign(new DartString.literal('\$0.$name'), | 1773 push(new HForeign(new DartString.literal('\$0.$name'), |
| 1766 const LiteralDartString('bool'), | 1774 const LiteralDartString('bool'), |
| 1767 inputs)); | 1775 inputs)); |
| 1768 break; | 1776 break; |
| 1769 case "native": | 1777 case "native": |
| 1770 native.handleSsaNative(this, node); | 1778 native.handleSsaNative(this, node); |
| 1771 break; | 1779 break; |
| 1772 default: | 1780 default: |
| 1773 throw "Unknown foreign: ${node.selector}"; | 1781 throw "Unknown foreign: ${node.selector}"; |
| 1774 } | 1782 } |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2493 buildBody() { | 2501 buildBody() { |
| 2494 // TODO(lrn): Make sure to take continue into account. | 2502 // TODO(lrn): Make sure to take continue into account. |
| 2495 visit(body); | 2503 visit(body); |
| 2496 if (isAborted()) { | 2504 if (isAborted()) { |
| 2497 compiler.reportWarning(body, "aborting loop body"); | 2505 compiler.reportWarning(body, "aborting loop body"); |
| 2498 } | 2506 } |
| 2499 } | 2507 } |
| 2500 handleIf(buildBody, null); | 2508 handleIf(buildBody, null); |
| 2501 } | 2509 } |
| 2502 } | 2510 } |
| OLD | NEW |