| 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 2398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2409 } | 2409 } |
| 2410 | 2410 |
| 2411 void handleForeignJsGetFlag(ir.StaticInvocation invocation) { | 2411 void handleForeignJsGetFlag(ir.StaticInvocation invocation) { |
| 2412 if (_unexpectedForeignArguments(invocation, 1, 1)) { | 2412 if (_unexpectedForeignArguments(invocation, 1, 1)) { |
| 2413 stack.add( | 2413 stack.add( |
| 2414 // Result expected on stack. | 2414 // Result expected on stack. |
| 2415 graph.addConstantBool(false, closedWorld)); | 2415 graph.addConstantBool(false, closedWorld)); |
| 2416 return; | 2416 return; |
| 2417 } | 2417 } |
| 2418 String name = _foreignConstantStringArgument(invocation, 0, 'JS_GET_FLAG'); | 2418 String name = _foreignConstantStringArgument(invocation, 0, 'JS_GET_FLAG'); |
| 2419 bool value = false; | 2419 bool value = getFlagValue(name); |
| 2420 switch (name) { | 2420 if (value == null) { |
| 2421 case 'MUST_RETAIN_METADATA': | 2421 reporter.reportErrorMessage( |
| 2422 value = mirrorsData.mustRetainMetadata; | 2422 astAdapter.getNode(invocation), |
| 2423 break; | 2423 MessageKind.GENERIC, |
| 2424 case 'USE_CONTENT_SECURITY_POLICY': | 2424 {'text': 'Error: Unknown internal flag "$name".'}); |
| 2425 value = options.useContentSecurityPolicy; | 2425 } else { |
| 2426 break; | 2426 stack.add(graph.addConstantBool(value, closedWorld)); |
| 2427 default: | |
| 2428 reporter.reportErrorMessage( | |
| 2429 astAdapter.getNode(invocation), | |
| 2430 MessageKind.GENERIC, | |
| 2431 {'text': 'Error: Unknown internal flag "$name".'}); | |
| 2432 } | 2427 } |
| 2433 stack.add(graph.addConstantBool(value, closedWorld)); | |
| 2434 } | 2428 } |
| 2435 | 2429 |
| 2436 void handleJsInterceptorConstant(ir.StaticInvocation invocation) { | 2430 void handleJsInterceptorConstant(ir.StaticInvocation invocation) { |
| 2437 // Single argument must be a TypeConstant which is converted into a | 2431 // Single argument must be a TypeConstant which is converted into a |
| 2438 // InterceptorConstant. | 2432 // InterceptorConstant. |
| 2439 if (_unexpectedForeignArguments(invocation, 1, 1)) { | 2433 if (_unexpectedForeignArguments(invocation, 1, 1)) { |
| 2440 // Result expected on stack. | 2434 // Result expected on stack. |
| 2441 stack.add(graph.addConstantNull(closedWorld)); | 2435 stack.add(graph.addConstantNull(closedWorld)); |
| 2442 return; | 2436 return; |
| 2443 } | 2437 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2496 astAdapter.getNode(invocation), MessageKind.JS_PLACEHOLDER_CAPTURE); | 2490 astAdapter.getNode(invocation), MessageKind.JS_PLACEHOLDER_CAPTURE); |
| 2497 } | 2491 } |
| 2498 | 2492 |
| 2499 TypeMask ssaType = | 2493 TypeMask ssaType = |
| 2500 astAdapter.typeFromNativeBehavior(nativeBehavior, closedWorld); | 2494 astAdapter.typeFromNativeBehavior(nativeBehavior, closedWorld); |
| 2501 | 2495 |
| 2502 SourceInformation sourceInformation = null; | 2496 SourceInformation sourceInformation = null; |
| 2503 push(new HForeignCode(nativeBehavior.codeTemplate, ssaType, inputs, | 2497 push(new HForeignCode(nativeBehavior.codeTemplate, ssaType, inputs, |
| 2504 isStatement: !nativeBehavior.codeTemplate.isExpression, | 2498 isStatement: !nativeBehavior.codeTemplate.isExpression, |
| 2505 effects: nativeBehavior.sideEffects, | 2499 effects: nativeBehavior.sideEffects, |
| 2506 nativeBehavior: nativeBehavior) | 2500 nativeBehavior: nativeBehavior)..sourceInformation = sourceInformation); |
| 2507 ..sourceInformation = sourceInformation); | |
| 2508 } | 2501 } |
| 2509 | 2502 |
| 2510 void handleJsStringConcat(ir.StaticInvocation invocation) { | 2503 void handleJsStringConcat(ir.StaticInvocation invocation) { |
| 2511 if (_unexpectedForeignArguments(invocation, 2, 2)) { | 2504 if (_unexpectedForeignArguments(invocation, 2, 2)) { |
| 2512 // Result expected on stack. | 2505 // Result expected on stack. |
| 2513 stack.add(graph.addConstantNull(closedWorld)); | 2506 stack.add(graph.addConstantNull(closedWorld)); |
| 2514 return; | 2507 return; |
| 2515 } | 2508 } |
| 2516 List<HInstruction> inputs = _visitPositionalArguments(invocation.arguments); | 2509 List<HInstruction> inputs = _visitPositionalArguments(invocation.arguments); |
| 2517 push(new HStringConcat(inputs[0], inputs[1], commonMasks.stringType)); | 2510 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) { | 2594 void visitMethodInvocation(ir.MethodInvocation invocation) { |
| 2602 // Handle `x == null` specially. When these come from null-aware operators, | 2595 // Handle `x == null` specially. When these come from null-aware operators, |
| 2603 // there is no mapping in the astAdapter. | 2596 // there is no mapping in the astAdapter. |
| 2604 if (_handleEqualsNull(invocation)) return; | 2597 if (_handleEqualsNull(invocation)) return; |
| 2605 invocation.receiver.accept(this); | 2598 invocation.receiver.accept(this); |
| 2606 HInstruction receiver = pop(); | 2599 HInstruction receiver = pop(); |
| 2607 Selector selector = astAdapter.getSelector(invocation); | 2600 Selector selector = astAdapter.getSelector(invocation); |
| 2608 _pushDynamicInvocation( | 2601 _pushDynamicInvocation( |
| 2609 invocation, | 2602 invocation, |
| 2610 astAdapter.typeOfInvocation(invocation, closedWorld), | 2603 astAdapter.typeOfInvocation(invocation, closedWorld), |
| 2611 <HInstruction>[receiver]..addAll( | 2604 <HInstruction>[receiver] |
| 2612 _visitArgumentsForDynamicTarget(selector, invocation.arguments))); | 2605 ..addAll( |
| 2606 _visitArgumentsForDynamicTarget(selector, invocation.arguments))); |
| 2613 } | 2607 } |
| 2614 | 2608 |
| 2615 bool _handleEqualsNull(ir.MethodInvocation invocation) { | 2609 bool _handleEqualsNull(ir.MethodInvocation invocation) { |
| 2616 if (invocation.name.name == '==') { | 2610 if (invocation.name.name == '==') { |
| 2617 ir.Arguments arguments = invocation.arguments; | 2611 ir.Arguments arguments = invocation.arguments; |
| 2618 if (arguments.types.isEmpty && | 2612 if (arguments.types.isEmpty && |
| 2619 arguments.positional.length == 1 && | 2613 arguments.positional.length == 1 && |
| 2620 arguments.named.isEmpty) { | 2614 arguments.named.isEmpty) { |
| 2621 bool finish(ir.Expression comparand) { | 2615 bool finish(ir.Expression comparand) { |
| 2622 comparand.accept(this); | 2616 comparand.accept(this); |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3225 enterBlock.setBlockFlow( | 3219 enterBlock.setBlockFlow( |
| 3226 new HTryBlockInformation( | 3220 new HTryBlockInformation( |
| 3227 kernelBuilder.wrapStatementGraph(bodyGraph), | 3221 kernelBuilder.wrapStatementGraph(bodyGraph), |
| 3228 exception, | 3222 exception, |
| 3229 kernelBuilder.wrapStatementGraph(catchGraph), | 3223 kernelBuilder.wrapStatementGraph(catchGraph), |
| 3230 kernelBuilder.wrapStatementGraph(finallyGraph)), | 3224 kernelBuilder.wrapStatementGraph(finallyGraph)), |
| 3231 exitBlock); | 3225 exitBlock); |
| 3232 kernelBuilder.inTryStatement = previouslyInTryStatement; | 3226 kernelBuilder.inTryStatement = previouslyInTryStatement; |
| 3233 } | 3227 } |
| 3234 } | 3228 } |
| OLD | NEW |