| 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 1996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2007 | 2007 |
| 2008 HInstruction generateInstanceSendReceiver(Send send) { | 2008 HInstruction generateInstanceSendReceiver(Send send) { |
| 2009 assert(Elements.isInstanceSend(send, elements)); | 2009 assert(Elements.isInstanceSend(send, elements)); |
| 2010 if (send.receiver == null) { | 2010 if (send.receiver == null) { |
| 2011 return localsHandler.readThis(); | 2011 return localsHandler.readThis(); |
| 2012 } | 2012 } |
| 2013 visit(send.receiver); | 2013 visit(send.receiver); |
| 2014 return pop(); | 2014 return pop(); |
| 2015 } | 2015 } |
| 2016 | 2016 |
| 2017 String getTargetName(ErroneousElement error, [String prefix = '']) { | 2017 String getTargetName(ErroneousElement error, [String prefix]) { |
| 2018 return '$prefix${error.targetName.slowToString()}'; | 2018 String result = error.targetName.slowToString(); |
| 2019 if (?prefix) { |
| 2020 result = '$prefix $result'; |
| 2021 } |
| 2022 return result; |
| 2019 } | 2023 } |
| 2020 | 2024 |
| 2021 void generateInstanceGetterWithCompiledReceiver(Send send, | 2025 void generateInstanceGetterWithCompiledReceiver(Send send, |
| 2022 HInstruction receiver) { | 2026 HInstruction receiver) { |
| 2023 assert(Elements.isInstanceSend(send, elements)); | 2027 assert(Elements.isInstanceSend(send, elements)); |
| 2024 // TODO(kasperl): This is a convoluted way of checking if we're | 2028 // TODO(kasperl): This is a convoluted way of checking if we're |
| 2025 // generating code for a compound assignment. If we are, we need | 2029 // generating code for a compound assignment. If we are, we need |
| 2026 // to get the selector from the mapping for the AST selector node. | 2030 // to get the selector from the mapping for the AST selector node. |
| 2027 Selector selector = (send.asSendSet() === null) | 2031 Selector selector = (send.asSendSet() === null) |
| 2028 ? elements.getSelector(send) | 2032 ? elements.getSelector(send) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2065 } else if (Elements.isInstanceSend(send, elements)) { | 2069 } else if (Elements.isInstanceSend(send, elements)) { |
| 2066 HInstruction receiver = generateInstanceSendReceiver(send); | 2070 HInstruction receiver = generateInstanceSendReceiver(send); |
| 2067 generateInstanceGetterWithCompiledReceiver(send, receiver); | 2071 generateInstanceGetterWithCompiledReceiver(send, receiver); |
| 2068 } else if (Elements.isStaticOrTopLevelFunction(element)) { | 2072 } else if (Elements.isStaticOrTopLevelFunction(element)) { |
| 2069 push(new HStatic(element)); | 2073 push(new HStatic(element)); |
| 2070 // TODO(ahe): This should be registered in codegen. | 2074 // TODO(ahe): This should be registered in codegen. |
| 2071 compiler.enqueuer.codegen.registerGetOfStaticFunction(element); | 2075 compiler.enqueuer.codegen.registerGetOfStaticFunction(element); |
| 2072 } else if (Elements.isErroneousElement(element)) { | 2076 } else if (Elements.isErroneousElement(element)) { |
| 2073 // An erroneous element indicates an unresolved static getter. | 2077 // An erroneous element indicates an unresolved static getter. |
| 2074 generateThrowNoSuchMethod(send, | 2078 generateThrowNoSuchMethod(send, |
| 2075 getTargetName(element, 'get '), | 2079 getTargetName(element, 'get'), |
| 2076 const EmptyLink<Node>()); | 2080 const EmptyLink<Node>()); |
| 2077 } else { | 2081 } else { |
| 2078 stack.add(localsHandler.readLocal(element)); | 2082 stack.add(localsHandler.readLocal(element)); |
| 2079 } | 2083 } |
| 2080 } | 2084 } |
| 2081 | 2085 |
| 2082 void generateInstanceSetterWithCompiledReceiver(Send send, | 2086 void generateInstanceSetterWithCompiledReceiver(Send send, |
| 2083 HInstruction receiver, | 2087 HInstruction receiver, |
| 2084 HInstruction value) { | 2088 HInstruction value) { |
| 2085 assert(Elements.isInstanceSend(send, elements)); | 2089 assert(Elements.isInstanceSend(send, elements)); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2112 value = potentiallyCheckType(value, element); | 2116 value = potentiallyCheckType(value, element); |
| 2113 addWithPosition(new HStaticStore(element, value), send); | 2117 addWithPosition(new HStaticStore(element, value), send); |
| 2114 } | 2118 } |
| 2115 stack.add(value); | 2119 stack.add(value); |
| 2116 } else if (element === null || Elements.isInstanceField(element)) { | 2120 } else if (element === null || Elements.isInstanceField(element)) { |
| 2117 HInstruction receiver = generateInstanceSendReceiver(send); | 2121 HInstruction receiver = generateInstanceSendReceiver(send); |
| 2118 generateInstanceSetterWithCompiledReceiver(send, receiver, value); | 2122 generateInstanceSetterWithCompiledReceiver(send, receiver, value); |
| 2119 } else if (Elements.isErroneousElement(element)) { | 2123 } else if (Elements.isErroneousElement(element)) { |
| 2120 // An erroneous element indicates an unresolved static setter. | 2124 // An erroneous element indicates an unresolved static setter. |
| 2121 generateThrowNoSuchMethod(send, | 2125 generateThrowNoSuchMethod(send, |
| 2122 getTargetName(element, 'set '), | 2126 getTargetName(element, 'set'), |
| 2123 send.arguments); | 2127 send.arguments); |
| 2124 } else { | 2128 } else { |
| 2125 stack.add(value); | 2129 stack.add(value); |
| 2126 // If the value does not already have a name, give it here. | 2130 // If the value does not already have a name, give it here. |
| 2127 if (value.sourceElement === null) { | 2131 if (value.sourceElement === null) { |
| 2128 value.sourceElement = element; | 2132 value.sourceElement = element; |
| 2129 } | 2133 } |
| 2130 HInstruction checked = potentiallyCheckType(value, element); | 2134 HInstruction checked = potentiallyCheckType(value, element); |
| 2131 if (checked !== value) { | 2135 if (checked !== value) { |
| 2132 pop(); | 2136 pop(); |
| (...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3195 if (node.declaredIdentifier.asSend() !== null) { | 3199 if (node.declaredIdentifier.asSend() !== null) { |
| 3196 variable = elements[node.declaredIdentifier]; | 3200 variable = elements[node.declaredIdentifier]; |
| 3197 } else { | 3201 } else { |
| 3198 assert(node.declaredIdentifier.asVariableDefinitions() !== null); | 3202 assert(node.declaredIdentifier.asVariableDefinitions() !== null); |
| 3199 VariableDefinitions variableDefinitions = node.declaredIdentifier; | 3203 VariableDefinitions variableDefinitions = node.declaredIdentifier; |
| 3200 variable = elements[variableDefinitions.definitions.nodes.head]; | 3204 variable = elements[variableDefinitions.definitions.nodes.head]; |
| 3201 } | 3205 } |
| 3202 HInstruction oldVariable = pop(); | 3206 HInstruction oldVariable = pop(); |
| 3203 if (variable.isErroneous()) { | 3207 if (variable.isErroneous()) { |
| 3204 generateThrowNoSuchMethod(node, | 3208 generateThrowNoSuchMethod(node, |
| 3205 getTargetName(variable, 'set '), | 3209 getTargetName(variable, 'set'), |
| 3206 argumentValues: <HInstruction>[oldVariable]); | 3210 argumentValues: <HInstruction>[oldVariable]); |
| 3207 pop(); | 3211 pop(); |
| 3208 } else { | 3212 } else { |
| 3209 localsHandler.updateLocal(variable, oldVariable); | 3213 localsHandler.updateLocal(variable, oldVariable); |
| 3210 } | 3214 } |
| 3211 | 3215 |
| 3212 visit(node.body); | 3216 visit(node.body); |
| 3213 } | 3217 } |
| 3214 handleLoop(node, buildInitializer, buildCondition, () {}, buildBody); | 3218 handleLoop(node, buildInitializer, buildCondition, () {}, buildBody); |
| 3215 } | 3219 } |
| (...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4199 new HSubGraphBlockInformation(elseBranch.graph)); | 4203 new HSubGraphBlockInformation(elseBranch.graph)); |
| 4200 | 4204 |
| 4201 HBasicBlock conditionStartBlock = conditionBranch.block; | 4205 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 4202 conditionStartBlock.setBlockFlow(info, joinBlock); | 4206 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 4203 SubGraph conditionGraph = conditionBranch.graph; | 4207 SubGraph conditionGraph = conditionBranch.graph; |
| 4204 HIf branch = conditionGraph.end.last; | 4208 HIf branch = conditionGraph.end.last; |
| 4205 assert(branch is HIf); | 4209 assert(branch is HIf); |
| 4206 branch.blockInformation = conditionStartBlock.blockFlow; | 4210 branch.blockInformation = conditionStartBlock.blockFlow; |
| 4207 } | 4211 } |
| 4208 } | 4212 } |
| OLD | NEW |