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'; |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 new DartString.literal(prefixElement.deferredImport.uri.toString()), | 577 new DartString.literal(prefixElement.deferredImport.uri.toString()), |
578 closedWorld); | 578 closedWorld); |
579 _pushStaticInvocation(astAdapter.checkDeferredIsLoaded, | 579 _pushStaticInvocation(astAdapter.checkDeferredIsLoaded, |
580 [prefixConstant, uriConstant], astAdapter.checkDeferredIsLoadedType); | 580 [prefixConstant, uriConstant], astAdapter.checkDeferredIsLoadedType); |
581 } | 581 } |
582 | 582 |
583 @override | 583 @override |
584 void visitLoadLibrary(ir.LoadLibrary loadLibrary) { | 584 void visitLoadLibrary(ir.LoadLibrary loadLibrary) { |
585 // TODO(efortuna): Source information! | 585 // TODO(efortuna): Source information! |
586 push(new HInvokeStatic( | 586 push(new HInvokeStatic( |
587 backend.helpers.loadLibraryWrapper, | 587 compiler.commonElements.loadLibraryWrapper, |
588 [ | 588 [ |
589 graph.addConstantString( | 589 graph.addConstantString( |
590 new DartString.literal(loadLibrary.import.name), closedWorld) | 590 new DartString.literal(loadLibrary.import.name), closedWorld) |
591 ], | 591 ], |
592 commonMasks.nonNullType, | 592 commonMasks.nonNullType, |
593 targetCanThrow: false)); | 593 targetCanThrow: false)); |
594 } | 594 } |
595 | 595 |
596 @override | 596 @override |
597 void visitBlock(ir.Block block) { | 597 void visitBlock(ir.Block block) { |
(...skipping 1899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2497 astAdapter.getNode(invocation), MessageKind.JS_PLACEHOLDER_CAPTURE); | 2497 astAdapter.getNode(invocation), MessageKind.JS_PLACEHOLDER_CAPTURE); |
2498 } | 2498 } |
2499 | 2499 |
2500 TypeMask ssaType = | 2500 TypeMask ssaType = |
2501 astAdapter.typeFromNativeBehavior(nativeBehavior, closedWorld); | 2501 astAdapter.typeFromNativeBehavior(nativeBehavior, closedWorld); |
2502 | 2502 |
2503 SourceInformation sourceInformation = null; | 2503 SourceInformation sourceInformation = null; |
2504 push(new HForeignCode(nativeBehavior.codeTemplate, ssaType, inputs, | 2504 push(new HForeignCode(nativeBehavior.codeTemplate, ssaType, inputs, |
2505 isStatement: !nativeBehavior.codeTemplate.isExpression, | 2505 isStatement: !nativeBehavior.codeTemplate.isExpression, |
2506 effects: nativeBehavior.sideEffects, | 2506 effects: nativeBehavior.sideEffects, |
2507 nativeBehavior: nativeBehavior)..sourceInformation = sourceInformation); | 2507 nativeBehavior: nativeBehavior) |
| 2508 ..sourceInformation = sourceInformation); |
2508 } | 2509 } |
2509 | 2510 |
2510 void handleJsStringConcat(ir.StaticInvocation invocation) { | 2511 void handleJsStringConcat(ir.StaticInvocation invocation) { |
2511 if (_unexpectedForeignArguments(invocation, 2, 2)) { | 2512 if (_unexpectedForeignArguments(invocation, 2, 2)) { |
2512 // Result expected on stack. | 2513 // Result expected on stack. |
2513 stack.add(graph.addConstantNull(closedWorld)); | 2514 stack.add(graph.addConstantNull(closedWorld)); |
2514 return; | 2515 return; |
2515 } | 2516 } |
2516 List<HInstruction> inputs = _visitPositionalArguments(invocation.arguments); | 2517 List<HInstruction> inputs = _visitPositionalArguments(invocation.arguments); |
2517 push(new HStringConcat(inputs[0], inputs[1], commonMasks.stringType)); | 2518 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) { | 2602 void visitMethodInvocation(ir.MethodInvocation invocation) { |
2602 // Handle `x == null` specially. When these come from null-aware operators, | 2603 // Handle `x == null` specially. When these come from null-aware operators, |
2603 // there is no mapping in the astAdapter. | 2604 // there is no mapping in the astAdapter. |
2604 if (_handleEqualsNull(invocation)) return; | 2605 if (_handleEqualsNull(invocation)) return; |
2605 invocation.receiver.accept(this); | 2606 invocation.receiver.accept(this); |
2606 HInstruction receiver = pop(); | 2607 HInstruction receiver = pop(); |
2607 Selector selector = astAdapter.getSelector(invocation); | 2608 Selector selector = astAdapter.getSelector(invocation); |
2608 _pushDynamicInvocation( | 2609 _pushDynamicInvocation( |
2609 invocation, | 2610 invocation, |
2610 astAdapter.typeOfInvocation(invocation, closedWorld), | 2611 astAdapter.typeOfInvocation(invocation, closedWorld), |
2611 <HInstruction>[receiver] | 2612 <HInstruction>[receiver]..addAll( |
2612 ..addAll( | 2613 _visitArgumentsForDynamicTarget(selector, invocation.arguments))); |
2613 _visitArgumentsForDynamicTarget(selector, invocation.arguments))); | |
2614 } | 2614 } |
2615 | 2615 |
2616 bool _handleEqualsNull(ir.MethodInvocation invocation) { | 2616 bool _handleEqualsNull(ir.MethodInvocation invocation) { |
2617 if (invocation.name.name == '==') { | 2617 if (invocation.name.name == '==') { |
2618 ir.Arguments arguments = invocation.arguments; | 2618 ir.Arguments arguments = invocation.arguments; |
2619 if (arguments.types.isEmpty && | 2619 if (arguments.types.isEmpty && |
2620 arguments.positional.length == 1 && | 2620 arguments.positional.length == 1 && |
2621 arguments.named.isEmpty) { | 2621 arguments.named.isEmpty) { |
2622 bool finish(ir.Expression comparand) { | 2622 bool finish(ir.Expression comparand) { |
2623 comparand.accept(this); | 2623 comparand.accept(this); |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3226 enterBlock.setBlockFlow( | 3226 enterBlock.setBlockFlow( |
3227 new HTryBlockInformation( | 3227 new HTryBlockInformation( |
3228 kernelBuilder.wrapStatementGraph(bodyGraph), | 3228 kernelBuilder.wrapStatementGraph(bodyGraph), |
3229 exception, | 3229 exception, |
3230 kernelBuilder.wrapStatementGraph(catchGraph), | 3230 kernelBuilder.wrapStatementGraph(catchGraph), |
3231 kernelBuilder.wrapStatementGraph(finallyGraph)), | 3231 kernelBuilder.wrapStatementGraph(finallyGraph)), |
3232 exitBlock); | 3232 exitBlock); |
3233 kernelBuilder.inTryStatement = previouslyInTryStatement; | 3233 kernelBuilder.inTryStatement = previouslyInTryStatement; |
3234 } | 3234 } |
3235 } | 3235 } |
OLD | NEW |