| 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 '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/names.dart'; |
| 8 import '../compiler.dart'; | 9 import '../compiler.dart'; |
| 9 import '../constants/values.dart'; | 10 import '../constants/values.dart'; |
| 10 import '../dart_types.dart'; | 11 import '../dart_types.dart'; |
| 11 import '../elements/elements.dart'; | 12 import '../elements/elements.dart'; |
| 12 import '../js_backend/js_backend.dart'; | 13 import '../js_backend/js_backend.dart'; |
| 13 import '../resolution/tree_elements.dart'; | 14 import '../resolution/tree_elements.dart'; |
| 14 import '../tree/tree.dart' as ast; | 15 import '../tree/tree.dart' as ast; |
| 15 import '../types/masks.dart'; | 16 import '../types/masks.dart'; |
| 16 import '../universe/call_structure.dart'; | 17 import '../universe/call_structure.dart'; |
| 17 import '../universe/selector.dart'; | 18 import '../universe/selector.dart'; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 SideEffects getSideEffects(ir.Node node) { | 91 SideEffects getSideEffects(ir.Node node) { |
| 91 return _compiler.world.getSideEffectsOfElement(getElement(node)); | 92 return _compiler.world.getSideEffectsOfElement(getElement(node)); |
| 92 } | 93 } |
| 93 | 94 |
| 94 CallStructure getCallStructure(ir.Arguments arguments) { | 95 CallStructure getCallStructure(ir.Arguments arguments) { |
| 95 int argumentCount = arguments.positional.length + arguments.named.length; | 96 int argumentCount = arguments.positional.length + arguments.named.length; |
| 96 List<String> namedArguments = arguments.named.map((e) => e.name).toList(); | 97 List<String> namedArguments = arguments.named.map((e) => e.name).toList(); |
| 97 return new CallStructure(argumentCount, namedArguments); | 98 return new CallStructure(argumentCount, namedArguments); |
| 98 } | 99 } |
| 99 | 100 |
| 101 Name getName(ir.Name name) { |
| 102 return new Name( |
| 103 name.name, name.isPrivate ? getElement(name.library) : null); |
| 104 } |
| 105 |
| 100 // TODO(het): Create the selector directly from the invocation | 106 // TODO(het): Create the selector directly from the invocation |
| 101 Selector getSelector(ir.MethodInvocation invocation) { | 107 Selector getSelector(ir.MethodInvocation invocation) { |
| 102 SelectorKind kind = Elements.isOperatorName(invocation.name.name) | 108 Name name = getName(invocation.name); |
| 103 ? SelectorKind.OPERATOR | 109 SelectorKind kind; |
| 104 : SelectorKind.CALL; | 110 if (Elements.isOperatorName(invocation.name.name)) { |
| 111 if (name == Names.INDEX_NAME || name == Names.INDEX_SET_NAME) { |
| 112 kind = SelectorKind.INDEX; |
| 113 } else { |
| 114 kind = SelectorKind.OPERATOR; |
| 115 } |
| 116 } else { |
| 117 kind = SelectorKind.CALL; |
| 118 } |
| 105 | 119 |
| 106 ir.Name irName = invocation.name; | |
| 107 Name name = new Name( | |
| 108 irName.name, irName.isPrivate ? getElement(irName.library) : null); | |
| 109 CallStructure callStructure = getCallStructure(invocation.arguments); | 120 CallStructure callStructure = getCallStructure(invocation.arguments); |
| 110 | 121 |
| 111 return new Selector(kind, name, callStructure); | 122 return new Selector(kind, name, callStructure); |
| 112 } | 123 } |
| 113 | 124 |
| 114 TypeMask typeOfInvocation(ir.MethodInvocation invocation) { | 125 TypeMask typeOfInvocation(ir.MethodInvocation invocation) { |
| 115 return _compiler.globalInference.results | 126 return _compiler.globalInference.results |
| 116 .typeOfSend(getNode(invocation), _elements); | 127 .typeOfSend(getNode(invocation), _elements); |
| 117 } | 128 } |
| 118 | 129 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 @override | 175 @override |
| 165 DartType visitDynamicType(ir.DynamicType node) { | 176 DartType visitDynamicType(ir.DynamicType node) { |
| 166 return const DynamicType(); | 177 return const DynamicType(); |
| 167 } | 178 } |
| 168 | 179 |
| 169 @override | 180 @override |
| 170 DartType visitInvalidType(ir.InvalidType node) { | 181 DartType visitInvalidType(ir.InvalidType node) { |
| 171 throw new UnimplementedError("Invalid types not currently supported"); | 182 throw new UnimplementedError("Invalid types not currently supported"); |
| 172 } | 183 } |
| 173 } | 184 } |
| OLD | NEW |