| 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 library analyzer2dart.cps_generator; | 5 library analyzer2dart.cps_generator; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 | 8 |
| 9 import 'package:compiler/src/dart_types.dart' as dart2js; | 9 import 'package:compiler/src/dart_types.dart' as dart2js; |
| 10 import 'package:compiler/src/elements/elements.dart' as dart2js; | 10 import 'package:compiler/src/elements/elements.dart' as dart2js; |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 } | 196 } |
| 197 | 197 |
| 198 @override | 198 @override |
| 199 ir.Primitive visitStaticMethodInvocation(MethodInvocation node, | 199 ir.Primitive visitStaticMethodInvocation(MethodInvocation node, |
| 200 AccessSemantics semantics) { | 200 AccessSemantics semantics) { |
| 201 analyzer.Element staticElement = semantics.element; | 201 analyzer.Element staticElement = semantics.element; |
| 202 dart2js.Element element = converter.convertElement(staticElement); | 202 dart2js.Element element = converter.convertElement(staticElement); |
| 203 List<ir.Primitive> arguments = visitArguments(node.argumentList); | 203 List<ir.Primitive> arguments = visitArguments(node.argumentList); |
| 204 return irBuilder.buildStaticFunctionInvocation( | 204 return irBuilder.buildStaticFunctionInvocation( |
| 205 element, | 205 element, |
| 206 createSelectorFromMethodInvocation( | 206 createCallStructureFromMethodInvocation(node.argumentList), |
| 207 node.argumentList, node.methodName.name), | |
| 208 arguments); | 207 arguments); |
| 209 } | 208 } |
| 210 | 209 |
| 211 @override | 210 @override |
| 212 ir.Node visitLocalFunctionAccess(AstNode node, AccessSemantics semantics) { | 211 ir.Node visitLocalFunctionAccess(AstNode node, AccessSemantics semantics) { |
| 213 return handleLocalAccess(node, semantics); | 212 return handleLocalAccess(node, semantics); |
| 214 } | 213 } |
| 215 | 214 |
| 216 ir.Primitive handleLocalInvocation(MethodInvocation node, | 215 ir.Primitive handleLocalInvocation(MethodInvocation node, |
| 217 AccessSemantics semantics) { | 216 AccessSemantics semantics) { |
| 218 analyzer.Element staticElement = semantics.element; | 217 analyzer.Element staticElement = semantics.element; |
| 219 dart2js.Element element = converter.convertElement(staticElement); | 218 dart2js.Element element = converter.convertElement(staticElement); |
| 220 List<ir.Definition> arguments = visitArguments(node.argumentList); | 219 List<ir.Definition> arguments = visitArguments(node.argumentList); |
| 221 Selector selector = createSelectorFromMethodInvocation( | 220 CallStructure callStructure = createCallStructureFromMethodInvocation( |
| 222 node.argumentList, node.methodName.name); | 221 node.argumentList); |
| 223 if (semantics.kind == AccessKind.LOCAL_FUNCTION) { | 222 if (semantics.kind == AccessKind.LOCAL_FUNCTION) { |
| 224 return irBuilder.buildLocalFunctionInvocation( | 223 return irBuilder.buildLocalFunctionInvocation( |
| 225 element, selector, arguments); | 224 element, callStructure, arguments); |
| 226 } else { | 225 } else { |
| 227 return irBuilder.buildLocalVariableInvocation( | 226 return irBuilder.buildLocalVariableInvocation( |
| 228 element, selector, arguments); | 227 element, callStructure, arguments); |
| 229 } | 228 } |
| 230 } | 229 } |
| 231 | 230 |
| 232 @override | 231 @override |
| 233 ir.Node visitLocalVariableInvocation(MethodInvocation node, | 232 ir.Node visitLocalVariableInvocation(MethodInvocation node, |
| 234 AccessSemantics semantics) { | 233 AccessSemantics semantics) { |
| 235 return handleLocalInvocation(node, semantics); | 234 return handleLocalInvocation(node, semantics); |
| 236 } | 235 } |
| 237 | 236 |
| 238 @override | 237 @override |
| 239 ir.Primitive visitLocalFunctionInvocation(MethodInvocation node, | 238 ir.Primitive visitLocalFunctionInvocation(MethodInvocation node, |
| 240 AccessSemantics semantics) { | 239 AccessSemantics semantics) { |
| 241 return handleLocalInvocation(node, semantics); | 240 return handleLocalInvocation(node, semantics); |
| 242 } | 241 } |
| 243 | 242 |
| 244 @override | 243 @override |
| 245 ir.Primitive visitFunctionExpressionInvocation( | 244 ir.Primitive visitFunctionExpressionInvocation( |
| 246 FunctionExpressionInvocation node) { | 245 FunctionExpressionInvocation node) { |
| 247 ir.Primitive target = build(node.function); | 246 ir.Primitive target = build(node.function); |
| 248 List<ir.Definition> arguments = visitArguments(node.argumentList); | 247 List<ir.Definition> arguments = visitArguments(node.argumentList); |
| 249 return irBuilder.buildCallInvocation( | 248 return irBuilder.buildCallInvocation( |
| 250 target, | 249 target, |
| 251 createSelectorFromMethodInvocation(node.argumentList, 'call'), | 250 createCallStructureFromMethodInvocation(node.argumentList), |
| 252 arguments); | 251 arguments); |
| 253 } | 252 } |
| 254 | 253 |
| 255 @override | 254 @override |
| 256 ir.Primitive visitInstanceCreationExpression( | 255 ir.Primitive visitInstanceCreationExpression( |
| 257 InstanceCreationExpression node) { | 256 InstanceCreationExpression node) { |
| 258 analyzer.Element staticElement = node.staticElement; | 257 analyzer.Element staticElement = node.staticElement; |
| 259 if (staticElement != null) { | 258 if (staticElement != null) { |
| 260 dart2js.Element element = converter.convertElement(staticElement); | 259 dart2js.Element element = converter.convertElement(staticElement); |
| 261 dart2js.DartType type = converter.convertType(node.staticType); | 260 dart2js.DartType type = converter.convertType(node.staticType); |
| 262 List<ir.Primitive> arguments = visitArguments(node.argumentList); | 261 List<ir.Primitive> arguments = visitArguments(node.argumentList); |
| 263 String name = ''; | |
| 264 if (node.constructorName.name != null) { | |
| 265 name = node.constructorName.name.name; | |
| 266 } | |
| 267 return irBuilder.buildConstructorInvocation( | 262 return irBuilder.buildConstructorInvocation( |
| 268 element, | 263 element, |
| 269 createSelectorFromMethodInvocation(node.argumentList, name), | 264 createCallStructureFromMethodInvocation(node.argumentList), |
| 270 type, | 265 type, |
| 271 arguments); | 266 arguments); |
| 272 } | 267 } |
| 273 return giveUp(node, "Unresolved constructor invocation."); | 268 return giveUp(node, "Unresolved constructor invocation."); |
| 274 } | 269 } |
| 275 | 270 |
| 276 @override | 271 @override |
| 277 ir.Constant visitNullLiteral(NullLiteral node) { | 272 ir.Constant visitNullLiteral(NullLiteral node) { |
| 278 return irBuilder.buildNullLiteral(); | 273 return irBuilder.buildNullLiteral(); |
| 279 } | 274 } |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 catchClause.exceptionParameter.staticElement), | 581 catchClause.exceptionParameter.staticElement), |
| 587 buildCatchBlock: subbuild(catchClause.body))); | 582 buildCatchBlock: subbuild(catchClause.body))); |
| 588 | 583 |
| 589 } | 584 } |
| 590 irBuilder.buildTry( | 585 irBuilder.buildTry( |
| 591 tryStatementInfo: new TryStatementInfo(), | 586 tryStatementInfo: new TryStatementInfo(), |
| 592 buildTryBlock: subbuild(node.body), | 587 buildTryBlock: subbuild(node.body), |
| 593 catchClauseInfos: catchClauseInfos); | 588 catchClauseInfos: catchClauseInfos); |
| 594 } | 589 } |
| 595 } | 590 } |
| OLD | NEW |