OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 'dart:collection'; | 5 import 'dart:collection'; |
6 | 6 |
7 import 'package:js_runtime/shared/embedded_names.dart'; | 7 import 'package:js_runtime/shared/embedded_names.dart'; |
8 | 8 |
9 import '../closure.dart'; | 9 import '../closure.dart'; |
10 import '../common.dart'; | 10 import '../common.dart'; |
(...skipping 5597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5608 .hasAnonymousAnnotation(element.contextClass)) { | 5608 .hasAnonymousAnnotation(element.contextClass)) { |
5609 // Factory constructor that is syntactic sugar for creating a JavaScript | 5609 // Factory constructor that is syntactic sugar for creating a JavaScript |
5610 // object literal. | 5610 // object literal. |
5611 ConstructorElement constructor = element; | 5611 ConstructorElement constructor = element; |
5612 FunctionSignature params = constructor.functionSignature; | 5612 FunctionSignature params = constructor.functionSignature; |
5613 int i = 0; | 5613 int i = 0; |
5614 int positions = 0; | 5614 int positions = 0; |
5615 var filteredArguments = <HInstruction>[]; | 5615 var filteredArguments = <HInstruction>[]; |
5616 var parameterNameMap = new Map<String, js.Expression>(); | 5616 var parameterNameMap = new Map<String, js.Expression>(); |
5617 params.orderedForEachParameter((ParameterElement parameter) { | 5617 params.orderedForEachParameter((ParameterElement parameter) { |
5618 // TODO(jacobr): throw if parameter names do not match names of property | 5618 // TODO(jacobr): consider throwing if parameter names do not match |
5619 // names in the class. | 5619 // names of properties in the class. |
5620 assert(parameter.isNamed); | 5620 assert(parameter.isNamed); |
5621 HInstruction argument = arguments[i]; | 5621 HInstruction argument = arguments[i]; |
5622 if (argument != null) { | 5622 if (argument != null) { |
5623 filteredArguments.add(argument); | 5623 filteredArguments.add(argument); |
5624 parameterNameMap[parameter.name] = | 5624 var jsName = |
5625 new js.InterpolatedExpression(positions++); | 5625 backend.nativeData.getUnescapedJSInteropName(parameter.name); |
| 5626 parameterNameMap[jsName] = new js.InterpolatedExpression(positions++); |
5626 } | 5627 } |
5627 i++; | 5628 i++; |
5628 }); | 5629 }); |
5629 var codeTemplate = | 5630 var codeTemplate = |
5630 new js.Template(null, js.objectLiteral(parameterNameMap)); | 5631 new js.Template(null, js.objectLiteral(parameterNameMap)); |
5631 | 5632 |
5632 var nativeBehavior = new native.NativeBehavior() | 5633 var nativeBehavior = new native.NativeBehavior() |
5633 ..codeTemplate = codeTemplate; | 5634 ..codeTemplate = codeTemplate; |
5634 if (compiler.options.trustJSInteropTypeAnnotations) { | 5635 if (compiler.options.trustJSInteropTypeAnnotations) { |
5635 nativeBehavior.typesReturned.add(constructor.enclosingClass.thisType); | 5636 nativeBehavior.typesReturned.add(constructor.enclosingClass.thisType); |
(...skipping 2990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8626 const _LoopTypeVisitor(); | 8627 const _LoopTypeVisitor(); |
8627 int visitNode(ast.Node node) => HLoopBlockInformation.NOT_A_LOOP; | 8628 int visitNode(ast.Node node) => HLoopBlockInformation.NOT_A_LOOP; |
8628 int visitWhile(ast.While node) => HLoopBlockInformation.WHILE_LOOP; | 8629 int visitWhile(ast.While node) => HLoopBlockInformation.WHILE_LOOP; |
8629 int visitFor(ast.For node) => HLoopBlockInformation.FOR_LOOP; | 8630 int visitFor(ast.For node) => HLoopBlockInformation.FOR_LOOP; |
8630 int visitDoWhile(ast.DoWhile node) => HLoopBlockInformation.DO_WHILE_LOOP; | 8631 int visitDoWhile(ast.DoWhile node) => HLoopBlockInformation.DO_WHILE_LOOP; |
8631 int visitAsyncForIn(ast.AsyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; | 8632 int visitAsyncForIn(ast.AsyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; |
8632 int visitSyncForIn(ast.SyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; | 8633 int visitSyncForIn(ast.SyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; |
8633 int visitSwitchStatement(ast.SwitchStatement node) => | 8634 int visitSwitchStatement(ast.SwitchStatement node) => |
8634 HLoopBlockInformation.SWITCH_CONTINUE_LOOP; | 8635 HLoopBlockInformation.SWITCH_CONTINUE_LOOP; |
8635 } | 8636 } |
OLD | NEW |