| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 dart2js.ir_builder_task; | 5 library dart2js.ir_builder_task; |
| 6 | 6 |
| 7 import '../closure.dart' as closurelib; | 7 import '../closure.dart' as closurelib; |
| 8 import '../closure.dart' hide ClosureScope; | 8 import '../closure.dart' hide ClosureScope; |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../common/names.dart' show | 10 import '../common/names.dart' show |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 TypeMask; | 36 TypeMask; |
| 37 import '../universe/call_structure.dart' show | 37 import '../universe/call_structure.dart' show |
| 38 CallStructure; | 38 CallStructure; |
| 39 import '../universe/selector.dart' show | 39 import '../universe/selector.dart' show |
| 40 Selector; | 40 Selector; |
| 41 import '../constants/values.dart' show | 41 import '../constants/values.dart' show |
| 42 ConstantValue; | 42 ConstantValue; |
| 43 import 'cps_ir_nodes.dart' as ir; | 43 import 'cps_ir_nodes.dart' as ir; |
| 44 import 'cps_ir_builder.dart'; | 44 import 'cps_ir_builder.dart'; |
| 45 import '../native/native.dart' show | 45 import '../native/native.dart' show |
| 46 NativeBehavior; | 46 NativeBehavior, |
| 47 HasCapturedPlaceholders; |
| 47 | 48 |
| 48 // TODO(karlklose): remove. | 49 // TODO(karlklose): remove. |
| 49 import '../js/js.dart' as js show js, Template, Expression, Name; | 50 import '../js/js.dart' as js show js, Template, Expression, Name; |
| 50 import '../ssa/ssa.dart' show TypeMaskFactory; | 51 import '../ssa/ssa.dart' show TypeMaskFactory; |
| 51 import '../util/util.dart'; | 52 import '../util/util.dart'; |
| 52 | 53 |
| 53 import 'package:js_runtime/shared/embedded_names.dart' | 54 import 'package:js_runtime/shared/embedded_names.dart' |
| 54 show JsBuiltin, JsGetName; | 55 show JsBuiltin, JsGetName; |
| 55 import '../constants/values.dart'; | 56 import '../constants/values.dart'; |
| 56 import 'type_mask_system.dart' show | 57 import 'type_mask_system.dart' show |
| (...skipping 3425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3482 NativeBehavior behavior = | 3483 NativeBehavior behavior = |
| 3483 compiler.enqueuer.resolution.nativeEnqueuer.getNativeBehaviorOf(node); | 3484 compiler.enqueuer.resolution.nativeEnqueuer.getNativeBehaviorOf(node); |
| 3484 switch (function.name) { | 3485 switch (function.name) { |
| 3485 case 'JS': | 3486 case 'JS': |
| 3486 validateArgumentCount(minimum: 2); | 3487 validateArgumentCount(minimum: 2); |
| 3487 // The first two arguments are the type and the foreign code template, | 3488 // The first two arguments are the type and the foreign code template, |
| 3488 // which already have been analyzed by the resolver and can be retrieved | 3489 // which already have been analyzed by the resolver and can be retrieved |
| 3489 // using [NativeBehavior]. We can ignore these arguments in the backend. | 3490 // using [NativeBehavior]. We can ignore these arguments in the backend. |
| 3490 List<ir.Primitive> arguments = | 3491 List<ir.Primitive> arguments = |
| 3491 argumentNodes.skip(2).mapToList(visit, growable: false); | 3492 argumentNodes.skip(2).mapToList(visit, growable: false); |
| 3493 if (behavior.codeTemplate.positionalArgumentCount != arguments.length) { |
| 3494 reporter.reportErrorMessage( |
| 3495 node, MessageKind.GENERIC, |
| 3496 {'text': |
| 3497 'Mismatch between number of placeholders' |
| 3498 ' and number of arguments.'}); |
| 3499 return irBuilder.buildNullConstant(); |
| 3500 } |
| 3501 |
| 3502 if (HasCapturedPlaceholders.check(behavior.codeTemplate.ast)) { |
| 3503 reporter.reportErrorMessage(node, MessageKind.JS_PLACEHOLDER_CAPTURE); |
| 3504 return irBuilder.buildNullConstant(); |
| 3505 } |
| 3506 |
| 3492 return irBuilder.buildForeignCode(behavior.codeTemplate, arguments, | 3507 return irBuilder.buildForeignCode(behavior.codeTemplate, arguments, |
| 3493 behavior); | 3508 behavior); |
| 3494 | 3509 |
| 3495 case 'DART_CLOSURE_TO_JS': | 3510 case 'DART_CLOSURE_TO_JS': |
| 3496 // TODO(ahe): This should probably take care to wrap the closure in | 3511 // TODO(ahe): This should probably take care to wrap the closure in |
| 3497 // another closure that saves the current isolate. | 3512 // another closure that saves the current isolate. |
| 3498 case 'RAW_DART_FUNCTION_REF': | 3513 case 'RAW_DART_FUNCTION_REF': |
| 3499 validateArgumentCount(exactly: 1); | 3514 validateArgumentCount(exactly: 1); |
| 3500 | 3515 |
| 3501 ast.Node argument = node.arguments.single; | 3516 ast.Node argument = node.arguments.single; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3652 callStructure = translateStaticArguments(argumentsNode, function, | 3667 callStructure = translateStaticArguments(argumentsNode, function, |
| 3653 callStructure, arguments); | 3668 callStructure, arguments); |
| 3654 return irBuilder.buildStaticFunctionInvocation(function, | 3669 return irBuilder.buildStaticFunctionInvocation(function, |
| 3655 callStructure, | 3670 callStructure, |
| 3656 arguments, | 3671 arguments, |
| 3657 sourceInformation: | 3672 sourceInformation: |
| 3658 sourceInformationBuilder.buildCall(node, node.selector)); | 3673 sourceInformationBuilder.buildCall(node, node.selector)); |
| 3659 } | 3674 } |
| 3660 } | 3675 } |
| 3661 } | 3676 } |
| OLD | NEW |