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 '../constants/expressions.dart'; | 7 import '../constants/expressions.dart'; |
8 import '../common.dart'; | 8 import '../common.dart'; |
9 import '../common/names.dart'; | 9 import '../common/names.dart'; |
10 import '../compiler.dart'; | 10 import '../compiler.dart'; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 SideEffects getSideEffects(ir.Node node) { | 120 SideEffects getSideEffects(ir.Node node) { |
121 return _compiler.closedWorld.getSideEffectsOfElement(getElement(node)); | 121 return _compiler.closedWorld.getSideEffectsOfElement(getElement(node)); |
122 } | 122 } |
123 | 123 |
124 CallStructure getCallStructure(ir.Arguments arguments) { | 124 CallStructure getCallStructure(ir.Arguments arguments) { |
125 int argumentCount = arguments.positional.length + arguments.named.length; | 125 int argumentCount = arguments.positional.length + arguments.named.length; |
126 List<String> namedArguments = arguments.named.map((e) => e.name).toList(); | 126 List<String> namedArguments = arguments.named.map((e) => e.name).toList(); |
127 return new CallStructure(argumentCount, namedArguments); | 127 return new CallStructure(argumentCount, namedArguments); |
128 } | 128 } |
129 | 129 |
| 130 FunctionSignature getFunctionSignature(ir.FunctionNode function) { |
| 131 return getElement(function).asFunctionElement().functionSignature; |
| 132 } |
| 133 |
130 Name getName(ir.Name name) { | 134 Name getName(ir.Name name) { |
131 return new Name( | 135 return new Name( |
132 name.name, name.isPrivate ? getElement(name.library) : null); | 136 name.name, name.isPrivate ? getElement(name.library) : null); |
133 } | 137 } |
134 | 138 |
| 139 ir.Field getFieldFromElement(FieldElement field) { |
| 140 return kernel.fields[field]; |
| 141 } |
| 142 |
135 Selector getSelector(ir.Expression node) { | 143 Selector getSelector(ir.Expression node) { |
136 if (node is ir.PropertyGet) return getGetterSelector(node); | 144 if (node is ir.PropertyGet) return getGetterSelector(node); |
137 if (node is ir.InvocationExpression) return getInvocationSelector(node); | 145 if (node is ir.InvocationExpression) return getInvocationSelector(node); |
138 _compiler.reporter.internalError(getNode(node), | 146 _compiler.reporter.internalError(getNode(node), |
139 "Can only get the selector for a property get or an invocation."); | 147 "Can only get the selector for a property get or an invocation."); |
140 return null; | 148 return null; |
141 } | 149 } |
142 | 150 |
143 Selector getInvocationSelector(ir.InvocationExpression invocation) { | 151 Selector getInvocationSelector(ir.InvocationExpression invocation) { |
144 Name name = getName(invocation.name); | 152 Name name = getName(invocation.name); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 | 288 |
281 TypeMask get assertTestReturnType => TypeMaskFactory | 289 TypeMask get assertTestReturnType => TypeMaskFactory |
282 .inferredReturnTypeForElement(_backend.helpers.assertTest, _compiler); | 290 .inferredReturnTypeForElement(_backend.helpers.assertTest, _compiler); |
283 | 291 |
284 ir.Procedure get assertThrow => | 292 ir.Procedure get assertThrow => |
285 kernel.functions[_backend.helpers.assertThrow]; | 293 kernel.functions[_backend.helpers.assertThrow]; |
286 | 294 |
287 TypeMask get assertThrowReturnType => TypeMaskFactory | 295 TypeMask get assertThrowReturnType => TypeMaskFactory |
288 .inferredReturnTypeForElement(_backend.helpers.assertThrow, _compiler); | 296 .inferredReturnTypeForElement(_backend.helpers.assertThrow, _compiler); |
289 | 297 |
| 298 ir.Class get objectClass => kernel.classes[_compiler.coreClasses.objectClass]; |
| 299 |
290 DartType getDartType(ir.DartType type) { | 300 DartType getDartType(ir.DartType type) { |
291 return type.accept(_typeConverter); | 301 return type.accept(_typeConverter); |
292 } | 302 } |
293 | 303 |
294 List<DartType> getDartTypes(List<ir.DartType> types) { | 304 List<DartType> getDartTypes(List<ir.DartType> types) { |
295 return types.map(getDartType).toList(); | 305 return types.map(getDartType).toList(); |
296 } | 306 } |
297 | 307 |
298 DartType getFunctionReturnType(ir.FunctionNode node) { | 308 DartType getFunctionReturnType(ir.FunctionNode node) { |
299 return getDartType(node.returnType); | 309 return getDartType(node.returnType); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 if (constant == null) { | 341 if (constant == null) { |
332 throw new UnsupportedError( | 342 throw new UnsupportedError( |
333 'No constant for ${DebugPrinter.prettyPrint(node)}'); | 343 'No constant for ${DebugPrinter.prettyPrint(node)}'); |
334 } | 344 } |
335 metadata.add(constant); | 345 metadata.add(constant); |
336 }); | 346 }); |
337 return metadata; | 347 return metadata; |
338 } | 348 } |
339 | 349 |
340 /// Compute the kind of foreign helper function called by [node], if any. | 350 /// Compute the kind of foreign helper function called by [node], if any. |
341 @override | |
342 ForeignKind getForeignKind(ir.StaticInvocation node) { | 351 ForeignKind getForeignKind(ir.StaticInvocation node) { |
343 if (isForeignLibrary(node.target.enclosingLibrary)) { | 352 if (isForeignLibrary(node.target.enclosingLibrary)) { |
344 switch (node.target.name.name) { | 353 switch (node.target.name.name) { |
345 case BackendHelpers.JS: | 354 case BackendHelpers.JS: |
346 return ForeignKind.JS; | 355 return ForeignKind.JS; |
347 case BackendHelpers.JS_BUILTIN: | 356 case BackendHelpers.JS_BUILTIN: |
348 return ForeignKind.JS_BUILTIN; | 357 return ForeignKind.JS_BUILTIN; |
349 case BackendHelpers.JS_EMBEDDED_GLOBAL: | 358 case BackendHelpers.JS_EMBEDDED_GLOBAL: |
350 return ForeignKind.JS_EMBEDDED_GLOBAL; | 359 return ForeignKind.JS_EMBEDDED_GLOBAL; |
351 case BackendHelpers.JS_INTERCEPTOR_CONSTANT: | 360 case BackendHelpers.JS_INTERCEPTOR_CONSTANT: |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 astAdapter.reporter.internalError( | 681 astAdapter.reporter.internalError( |
673 CURRENT_ELEMENT_SPANNABLE, "Unexpected constant target: $element."); | 682 CURRENT_ELEMENT_SPANNABLE, "Unexpected constant target: $element."); |
674 return null; | 683 return null; |
675 } | 684 } |
676 | 685 |
677 @override | 686 @override |
678 ConstantExpression visitStringLiteral(ir.StringLiteral node) { | 687 ConstantExpression visitStringLiteral(ir.StringLiteral node) { |
679 return new StringConstantExpression(node.value); | 688 return new StringConstantExpression(node.value); |
680 } | 689 } |
681 } | 690 } |
OLD | NEW |