| 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:js_runtime/shared/embedded_names.dart'; | 5 import 'package:js_runtime/shared/embedded_names.dart'; |
| 6 import 'package:kernel/ast.dart' as ir; | 6 import 'package:kernel/ast.dart' as ir; |
| 7 | 7 |
| 8 import '../closure.dart'; | 8 import '../closure.dart'; |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../compiler.dart'; | 10 import '../compiler.dart'; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 _typeConverter = new DartTypeConverter(this); | 84 _typeConverter = new DartTypeConverter(this); |
| 85 } | 85 } |
| 86 | 86 |
| 87 @override | 87 @override |
| 88 ConstantValue computeConstantValue(ConstantExpression constant) { | 88 ConstantValue computeConstantValue(ConstantExpression constant) { |
| 89 return _compiler.constants.getConstantValue(constant); | 89 return _compiler.constants.getConstantValue(constant); |
| 90 } | 90 } |
| 91 | 91 |
| 92 /// Called to find the corresponding Kernel element for a particular Element | 92 /// Called to find the corresponding Kernel element for a particular Element |
| 93 /// before traversing over it with a Kernel visitor. | 93 /// before traversing over it with a Kernel visitor. |
| 94 ir.Node getInitialKernelNode(Element originTarget) { | 94 ir.Node getInitialKernelNode(MemberElement originTarget) { |
| 95 ir.Node target; | 95 ir.Node target; |
| 96 if (originTarget.isPatch) { | 96 if (originTarget.isPatch) { |
| 97 originTarget = originTarget.origin; | 97 originTarget = originTarget.origin; |
| 98 } | 98 } |
| 99 if (originTarget is FunctionElement) { | 99 if (originTarget is MethodElement) { |
| 100 if (originTarget is ConstructorBodyElement) { | 100 if (originTarget is ConstructorBodyElement) { |
| 101 ConstructorBodyElement body = originTarget; | 101 ConstructorBodyElement body = originTarget; |
| 102 originTarget = body.constructor; | 102 originTarget = body.constructor; |
| 103 } | 103 } |
| 104 target = kernel.functions[originTarget]; | 104 target = kernel.functions[originTarget]; |
| 105 // Closures require a lookup one level deeper in the closure class mapper. | 105 // Closures require a lookup one level deeper in the closure class mapper. |
| 106 if (target == null) { | 106 if (target == null) { |
| 107 FunctionElement originTargetFunction = originTarget; | 107 MethodElement originTargetFunction = originTarget; |
| 108 ClosureClassMap classMap = _compiler.closureToClassMapper | 108 ClosureClassMap classMap = _compiler.closureToClassMapper |
| 109 .getClosureToClassMapping(originTargetFunction.resolvedAst); | 109 .getClosureToClassMapping(originTargetFunction.resolvedAst); |
| 110 if (classMap.closureElement != null) { | 110 if (classMap.closureElement != null) { |
| 111 target = kernel.localFunctions[classMap.closureElement]; | 111 target = kernel.localFunctions[classMap.closureElement]; |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 } else if (originTarget is FieldElement) { | 114 } else if (originTarget is FieldElement) { |
| 115 target = kernel.fields[originTarget]; | 115 target = kernel.fields[originTarget]; |
| 116 } | 116 } |
| 117 assert(target != null); | 117 assert(target != null); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 void assertNodeIsSynthetic(ir.Node node) { | 218 void assertNodeIsSynthetic(ir.Node node) { |
| 219 assert(invariant( | 219 assert(invariant( |
| 220 CURRENT_ELEMENT_SPANNABLE, kernel.syntheticNodes.contains(node), | 220 CURRENT_ELEMENT_SPANNABLE, kernel.syntheticNodes.contains(node), |
| 221 message: "No synthetic marker found for $node")); | 221 message: "No synthetic marker found for $node")); |
| 222 } | 222 } |
| 223 | 223 |
| 224 Local getLocal(ir.VariableDeclaration variable) { | 224 Local getLocal(ir.VariableDeclaration variable) { |
| 225 // If this is a synthetic local, return the synthetic local | 225 // If this is a synthetic local, return the synthetic local |
| 226 if (variable.name == null) { | 226 if (variable.name == null) { |
| 227 return _syntheticLocals.putIfAbsent( | 227 return _syntheticLocals.putIfAbsent( |
| 228 variable, () => new SyntheticLocal("x", null)); | 228 variable, () => new SyntheticLocal("x", null, null)); |
| 229 } | 229 } |
| 230 return getElement(variable) as LocalElement; | 230 return getElement(variable) as LocalElement; |
| 231 } | 231 } |
| 232 | 232 |
| 233 TypeMask getReturnTypeOf(FunctionEntity function) { | 233 TypeMask getReturnTypeOf(FunctionEntity function) { |
| 234 return TypeMaskFactory.inferredReturnTypeForElement( | 234 return TypeMaskFactory.inferredReturnTypeForElement( |
| 235 function, _globalInferenceResults); | 235 function, _globalInferenceResults); |
| 236 } | 236 } |
| 237 | 237 |
| 238 FunctionSignature getFunctionSignature(ir.FunctionNode function) { | 238 FunctionSignature getFunctionSignature(ir.FunctionNode function) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 260 | 260 |
| 261 TypeMask typeOfSet(ir.PropertySet setter, ClosedWorld closedWorld) { | 261 TypeMask typeOfSet(ir.PropertySet setter, ClosedWorld closedWorld) { |
| 262 return closedWorld.commonMasks.dynamicType; | 262 return closedWorld.commonMasks.dynamicType; |
| 263 } | 263 } |
| 264 | 264 |
| 265 TypeMask typeOfSend(ir.Expression send) { | 265 TypeMask typeOfSend(ir.Expression send) { |
| 266 assert(send is ir.InvocationExpression || send is ir.PropertyGet); | 266 assert(send is ir.InvocationExpression || send is ir.PropertyGet); |
| 267 return _resultOf(_target).typeOfSend(getNode(send)); | 267 return _resultOf(_target).typeOfSend(getNode(send)); |
| 268 } | 268 } |
| 269 | 269 |
| 270 TypeMask typeOfListLiteral( | 270 TypeMask typeOfListLiteral(MemberElement owner, ir.ListLiteral listLiteral, |
| 271 Element owner, ir.ListLiteral listLiteral, ClosedWorld closedWorld) { | 271 ClosedWorld closedWorld) { |
| 272 ast.Node node = getNodeOrNull(listLiteral); | 272 ast.Node node = getNodeOrNull(listLiteral); |
| 273 if (node == null) { | 273 if (node == null) { |
| 274 assertNodeIsSynthetic(listLiteral); | 274 assertNodeIsSynthetic(listLiteral); |
| 275 return closedWorld.commonMasks.growableListType; | 275 return closedWorld.commonMasks.growableListType; |
| 276 } | 276 } |
| 277 return _resultOf(owner).typeOfListLiteral(getNode(listLiteral)) ?? | 277 return _resultOf(owner).typeOfListLiteral(getNode(listLiteral)) ?? |
| 278 closedWorld.commonMasks.dynamicType; | 278 closedWorld.commonMasks.dynamicType; |
| 279 } | 279 } |
| 280 | 280 |
| 281 TypeMask typeOfIterator(ir.ForInStatement forInStatement) { | 281 TypeMask typeOfIterator(ir.ForInStatement forInStatement) { |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 JumpTarget continueTarget = | 698 JumpTarget continueTarget = |
| 699 astAdapter.getJumpTarget(switchCase, isContinueTarget: true); | 699 astAdapter.getJumpTarget(switchCase, isContinueTarget: true); |
| 700 assert(continueTarget is KernelJumpTarget); | 700 assert(continueTarget is KernelJumpTarget); |
| 701 targetIndexMap[continueTarget] = switchIndex; | 701 targetIndexMap[continueTarget] = switchIndex; |
| 702 assert(builder.jumpTargets[continueTarget] == null); | 702 assert(builder.jumpTargets[continueTarget] == null); |
| 703 builder.jumpTargets[continueTarget] = this; | 703 builder.jumpTargets[continueTarget] = this; |
| 704 switchIndex++; | 704 switchIndex++; |
| 705 } | 705 } |
| 706 } | 706 } |
| 707 } | 707 } |
| OLD | NEW |