| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
| 6 | 6 |
| 7 import '../closure.dart'; | 7 import '../closure.dart'; |
| 8 import '../common.dart'; | 8 import '../common.dart'; |
| 9 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; | 9 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; |
| 10 import '../common/names.dart'; | 10 import '../common/names.dart'; |
| 11 import '../common/tasks.dart' show CompilerTask; | 11 import '../common/tasks.dart' show CompilerTask; |
| 12 import '../compiler.dart'; | 12 import '../compiler.dart'; |
| 13 import '../constants/values.dart' | 13 import '../constants/values.dart' |
| 14 show | 14 show |
| 15 ConstantValue, | 15 ConstantValue, |
| 16 InterceptorConstantValue, | 16 InterceptorConstantValue, |
| 17 StringConstantValue, | 17 StringConstantValue, |
| 18 TypeConstantValue; | 18 TypeConstantValue; |
| 19 import '../elements/elements.dart'; | 19 import '../elements/elements.dart'; |
| 20 import '../elements/entities.dart'; | 20 import '../elements/entities.dart'; |
| 21 import '../elements/resolution_types.dart'; | 21 import '../elements/resolution_types.dart'; |
| 22 import '../elements/types.dart'; |
| 22 import '../io/source_information.dart'; | 23 import '../io/source_information.dart'; |
| 23 import '../js/js.dart' as js; | 24 import '../js/js.dart' as js; |
| 24 import '../js_backend/backend.dart' show JavaScriptBackend; | 25 import '../js_backend/backend.dart' show JavaScriptBackend; |
| 25 import '../kernel/kernel.dart'; | 26 import '../kernel/kernel.dart'; |
| 26 import '../native/native.dart' as native; | 27 import '../native/native.dart' as native; |
| 27 import '../resolution/tree_elements.dart'; | 28 import '../resolution/tree_elements.dart'; |
| 28 import '../tree/dartstring.dart'; | 29 import '../tree/dartstring.dart'; |
| 29 import '../tree/nodes.dart' show Node; | 30 import '../tree/nodes.dart' show Node; |
| 30 import '../types/masks.dart'; | 31 import '../types/masks.dart'; |
| 31 import '../universe/selector.dart'; | 32 import '../universe/selector.dart'; |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 constructorArguments.add(value); | 268 constructorArguments.add(value); |
| 268 }, includeSuperAndInjectedMembers: true); | 269 }, includeSuperAndInjectedMembers: true); |
| 269 | 270 |
| 270 // TODO(het): If the class needs runtime type information, add it as a | 271 // TODO(het): If the class needs runtime type information, add it as a |
| 271 // constructor argument. | 272 // constructor argument. |
| 272 HInstruction newObject = new HCreate( | 273 HInstruction newObject = new HCreate( |
| 273 astAdapter.getClass(constructor.enclosingClass), | 274 astAdapter.getClass(constructor.enclosingClass), |
| 274 constructorArguments, | 275 constructorArguments, |
| 275 new TypeMask.nonNullExact( | 276 new TypeMask.nonNullExact( |
| 276 astAdapter.getClass(constructor.enclosingClass), closedWorld), | 277 astAdapter.getClass(constructor.enclosingClass), closedWorld), |
| 277 instantiatedTypes: <ResolutionDartType>[ | 278 instantiatedTypes: <DartType>[ |
| 278 astAdapter.getClass(constructor.enclosingClass).thisType | 279 astAdapter.getClass(constructor.enclosingClass).thisType |
| 279 ], | 280 ], |
| 280 hasRtiInput: false); | 281 hasRtiInput: false); |
| 281 | 282 |
| 282 add(newObject); | 283 add(newObject); |
| 283 | 284 |
| 284 // Generate calls to the constructor bodies. | 285 // Generate calls to the constructor bodies. |
| 285 | 286 |
| 286 for (ir.Constructor body in constructorChain.reversed) { | 287 for (ir.Constructor body in constructorChain.reversed) { |
| 287 if (_isEmptyStatement(body.function.body)) continue; | 288 if (_isEmptyStatement(body.function.body)) continue; |
| (...skipping 2209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2497 astAdapter.getNode(invocation), MessageKind.JS_PLACEHOLDER_CAPTURE); | 2498 astAdapter.getNode(invocation), MessageKind.JS_PLACEHOLDER_CAPTURE); |
| 2498 } | 2499 } |
| 2499 | 2500 |
| 2500 TypeMask ssaType = | 2501 TypeMask ssaType = |
| 2501 astAdapter.typeFromNativeBehavior(nativeBehavior, closedWorld); | 2502 astAdapter.typeFromNativeBehavior(nativeBehavior, closedWorld); |
| 2502 | 2503 |
| 2503 SourceInformation sourceInformation = null; | 2504 SourceInformation sourceInformation = null; |
| 2504 push(new HForeignCode(nativeBehavior.codeTemplate, ssaType, inputs, | 2505 push(new HForeignCode(nativeBehavior.codeTemplate, ssaType, inputs, |
| 2505 isStatement: !nativeBehavior.codeTemplate.isExpression, | 2506 isStatement: !nativeBehavior.codeTemplate.isExpression, |
| 2506 effects: nativeBehavior.sideEffects, | 2507 effects: nativeBehavior.sideEffects, |
| 2507 nativeBehavior: nativeBehavior)..sourceInformation = sourceInformation); | 2508 nativeBehavior: nativeBehavior) |
| 2509 ..sourceInformation = sourceInformation); |
| 2508 } | 2510 } |
| 2509 | 2511 |
| 2510 void handleJsStringConcat(ir.StaticInvocation invocation) { | 2512 void handleJsStringConcat(ir.StaticInvocation invocation) { |
| 2511 if (_unexpectedForeignArguments(invocation, 2, 2)) { | 2513 if (_unexpectedForeignArguments(invocation, 2, 2)) { |
| 2512 // Result expected on stack. | 2514 // Result expected on stack. |
| 2513 stack.add(graph.addConstantNull(closedWorld)); | 2515 stack.add(graph.addConstantNull(closedWorld)); |
| 2514 return; | 2516 return; |
| 2515 } | 2517 } |
| 2516 List<HInstruction> inputs = _visitPositionalArguments(invocation.arguments); | 2518 List<HInstruction> inputs = _visitPositionalArguments(invocation.arguments); |
| 2517 push(new HStringConcat(inputs[0], inputs[1], commonMasks.stringType)); | 2519 push(new HStringConcat(inputs[0], inputs[1], commonMasks.stringType)); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2601 void visitMethodInvocation(ir.MethodInvocation invocation) { | 2603 void visitMethodInvocation(ir.MethodInvocation invocation) { |
| 2602 // Handle `x == null` specially. When these come from null-aware operators, | 2604 // Handle `x == null` specially. When these come from null-aware operators, |
| 2603 // there is no mapping in the astAdapter. | 2605 // there is no mapping in the astAdapter. |
| 2604 if (_handleEqualsNull(invocation)) return; | 2606 if (_handleEqualsNull(invocation)) return; |
| 2605 invocation.receiver.accept(this); | 2607 invocation.receiver.accept(this); |
| 2606 HInstruction receiver = pop(); | 2608 HInstruction receiver = pop(); |
| 2607 Selector selector = astAdapter.getSelector(invocation); | 2609 Selector selector = astAdapter.getSelector(invocation); |
| 2608 _pushDynamicInvocation( | 2610 _pushDynamicInvocation( |
| 2609 invocation, | 2611 invocation, |
| 2610 astAdapter.typeOfInvocation(invocation, closedWorld), | 2612 astAdapter.typeOfInvocation(invocation, closedWorld), |
| 2611 <HInstruction>[receiver] | 2613 <HInstruction>[receiver]..addAll( |
| 2612 ..addAll( | 2614 _visitArgumentsForDynamicTarget(selector, invocation.arguments))); |
| 2613 _visitArgumentsForDynamicTarget(selector, invocation.arguments))); | |
| 2614 } | 2615 } |
| 2615 | 2616 |
| 2616 bool _handleEqualsNull(ir.MethodInvocation invocation) { | 2617 bool _handleEqualsNull(ir.MethodInvocation invocation) { |
| 2617 if (invocation.name.name == '==') { | 2618 if (invocation.name.name == '==') { |
| 2618 ir.Arguments arguments = invocation.arguments; | 2619 ir.Arguments arguments = invocation.arguments; |
| 2619 if (arguments.types.isEmpty && | 2620 if (arguments.types.isEmpty && |
| 2620 arguments.positional.length == 1 && | 2621 arguments.positional.length == 1 && |
| 2621 arguments.named.isEmpty) { | 2622 arguments.named.isEmpty) { |
| 2622 bool finish(ir.Expression comparand) { | 2623 bool finish(ir.Expression comparand) { |
| 2623 comparand.accept(this); | 2624 comparand.accept(this); |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3226 enterBlock.setBlockFlow( | 3227 enterBlock.setBlockFlow( |
| 3227 new HTryBlockInformation( | 3228 new HTryBlockInformation( |
| 3228 kernelBuilder.wrapStatementGraph(bodyGraph), | 3229 kernelBuilder.wrapStatementGraph(bodyGraph), |
| 3229 exception, | 3230 exception, |
| 3230 kernelBuilder.wrapStatementGraph(catchGraph), | 3231 kernelBuilder.wrapStatementGraph(catchGraph), |
| 3231 kernelBuilder.wrapStatementGraph(finallyGraph)), | 3232 kernelBuilder.wrapStatementGraph(finallyGraph)), |
| 3232 exitBlock); | 3233 exitBlock); |
| 3233 kernelBuilder.inTryStatement = previouslyInTryStatement; | 3234 kernelBuilder.inTryStatement = previouslyInTryStatement; |
| 3234 } | 3235 } |
| 3235 } | 3236 } |
| OLD | NEW |