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 getFieldFromNode(FieldElement field) { | |
Siggi Cherem (dart-lang)
2016/11/14 18:22:25
FromNode => FromElement? or simply getField?
Harry Terkelsen
2016/11/14 23:23:40
Switched to FromElement. I didn't want to do getFi
| |
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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
278 | 286 |
279 TypeMask get assertTestReturnType => TypeMaskFactory | 287 TypeMask get assertTestReturnType => TypeMaskFactory |
280 .inferredReturnTypeForElement(_backend.helpers.assertTest, _compiler); | 288 .inferredReturnTypeForElement(_backend.helpers.assertTest, _compiler); |
281 | 289 |
282 ir.Procedure get assertThrow => | 290 ir.Procedure get assertThrow => |
283 kernel.functions[_backend.helpers.assertThrow]; | 291 kernel.functions[_backend.helpers.assertThrow]; |
284 | 292 |
285 TypeMask get assertThrowReturnType => TypeMaskFactory | 293 TypeMask get assertThrowReturnType => TypeMaskFactory |
286 .inferredReturnTypeForElement(_backend.helpers.assertThrow, _compiler); | 294 .inferredReturnTypeForElement(_backend.helpers.assertThrow, _compiler); |
287 | 295 |
296 ir.Class get objectClass => kernel.classes[_compiler.coreClasses.objectClass]; | |
297 | |
288 DartType getDartType(ir.DartType type) { | 298 DartType getDartType(ir.DartType type) { |
289 return type.accept(_typeConverter); | 299 return type.accept(_typeConverter); |
290 } | 300 } |
291 | 301 |
292 List<DartType> getDartTypes(List<ir.DartType> types) { | 302 List<DartType> getDartTypes(List<ir.DartType> types) { |
293 return types.map(getDartType).toList(); | 303 return types.map(getDartType).toList(); |
294 } | 304 } |
295 | 305 |
296 /// Computes the function type corresponding the signature of [node]. | 306 /// Computes the function type corresponding the signature of [node]. |
297 FunctionType getFunctionType(ir.FunctionNode node) { | 307 FunctionType getFunctionType(ir.FunctionNode node) { |
(...skipping 27 matching lines...) Expand all Loading... | |
325 if (constant == null) { | 335 if (constant == null) { |
326 throw new UnsupportedError( | 336 throw new UnsupportedError( |
327 'No constant for ${DebugPrinter.prettyPrint(node)}'); | 337 'No constant for ${DebugPrinter.prettyPrint(node)}'); |
328 } | 338 } |
329 metadata.add(constant); | 339 metadata.add(constant); |
330 }); | 340 }); |
331 return metadata; | 341 return metadata; |
332 } | 342 } |
333 | 343 |
334 /// Compute the kind of foreign helper function called by [node], if any. | 344 /// Compute the kind of foreign helper function called by [node], if any. |
335 @override | |
336 ForeignKind getForeignKind(ir.StaticInvocation node) { | 345 ForeignKind getForeignKind(ir.StaticInvocation node) { |
337 if (isForeignLibrary(node.target.enclosingLibrary)) { | 346 if (isForeignLibrary(node.target.enclosingLibrary)) { |
338 switch (node.target.name.name) { | 347 switch (node.target.name.name) { |
339 case BackendHelpers.JS: | 348 case BackendHelpers.JS: |
340 return ForeignKind.JS; | 349 return ForeignKind.JS; |
341 case BackendHelpers.JS_BUILTIN: | 350 case BackendHelpers.JS_BUILTIN: |
342 return ForeignKind.JS_BUILTIN; | 351 return ForeignKind.JS_BUILTIN; |
343 case BackendHelpers.JS_EMBEDDED_GLOBAL: | 352 case BackendHelpers.JS_EMBEDDED_GLOBAL: |
344 return ForeignKind.JS_EMBEDDED_GLOBAL; | 353 return ForeignKind.JS_EMBEDDED_GLOBAL; |
345 case BackendHelpers.JS_INTERCEPTOR_CONSTANT: | 354 case BackendHelpers.JS_INTERCEPTOR_CONSTANT: |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
666 astAdapter.reporter.internalError( | 675 astAdapter.reporter.internalError( |
667 CURRENT_ELEMENT_SPANNABLE, "Unexpected constant target: $element."); | 676 CURRENT_ELEMENT_SPANNABLE, "Unexpected constant target: $element."); |
668 return null; | 677 return null; |
669 } | 678 } |
670 | 679 |
671 @override | 680 @override |
672 ConstantExpression visitStringLiteral(ir.StringLiteral node) { | 681 ConstantExpression visitStringLiteral(ir.StringLiteral node) { |
673 return new StringConstantExpression(node.value); | 682 return new StringConstantExpression(node.value); |
674 } | 683 } |
675 } | 684 } |
OLD | NEW |