| 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 import 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
| 6 | 6 |
| 7 import "../dart_types.dart" show DartType, InterfaceType; | 7 import "../dart_types.dart" show DartType, InterfaceType; |
| 8 import "../elements/elements.dart" | 8 import "../elements/elements.dart" |
| 9 show | 9 show |
| 10 AstElement, | 10 AstElement, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 /// is possible through the public interface of NoSuchMethodError. | 50 /// is possible through the public interface of NoSuchMethodError. |
| 51 /// | 51 /// |
| 52 /// Note that [callArguments] are the arguments as they occur in the attempted | 52 /// Note that [callArguments] are the arguments as they occur in the attempted |
| 53 /// call in user code -- they are not the arguments to [exceptionBuilder]. | 53 /// call in user code -- they are not the arguments to [exceptionBuilder]. |
| 54 /// | 54 /// |
| 55 /// If [candidateTarget] is given, it will provide the expected parameter | 55 /// If [candidateTarget] is given, it will provide the expected parameter |
| 56 /// names. | 56 /// names. |
| 57 ir.Expression buildThrowNoSuchMethodError(ir.Procedure exceptionBuilder, | 57 ir.Expression buildThrowNoSuchMethodError(ir.Procedure exceptionBuilder, |
| 58 ir.Expression receiver, String memberName, ir.Arguments callArguments, | 58 ir.Expression receiver, String memberName, ir.Arguments callArguments, |
| 59 [Element candidateTarget]) { | 59 [Element candidateTarget]) { |
| 60 ir.Expression memberNameArg = new ir.SymbolLiteral(memberName); | 60 ir.Expression memberNameArg = |
| 61 ir.Expression positional = new ir.ListLiteral(callArguments.positional); | 61 markSynthetic(new ir.SymbolLiteral(memberName)); |
| 62 ir.Expression named = new ir.MapLiteral(callArguments.named.map((e) { | 62 ir.Expression positional = |
| 63 return new ir.MapEntry(new ir.SymbolLiteral(e.name), e.value); | 63 markSynthetic(new ir.ListLiteral(callArguments.positional)); |
| 64 }).toList()); | 64 ir.Expression named = |
| 65 markSynthetic(new ir.MapLiteral(callArguments.named.map((e) { |
| 66 return new ir.MapEntry( |
| 67 markSynthetic(new ir.SymbolLiteral(e.name)), e.value); |
| 68 }).toList())); |
| 65 if (candidateTarget is FunctionElement) { | 69 if (candidateTarget is FunctionElement) { |
| 66 // Ensure [candidateTarget] has been resolved. | 70 // Ensure [candidateTarget] has been resolved. |
| 67 possiblyErroneousFunctionToIr(candidateTarget); | 71 possiblyErroneousFunctionToIr(candidateTarget); |
| 68 } | 72 } |
| 69 ir.Expression existingArguments; | 73 ir.Expression existingArguments; |
| 70 if (candidateTarget is FunctionElement && | 74 if (candidateTarget is FunctionElement && |
| 71 !kernel.isSyntheticError(candidateTarget) && | 75 !kernel.isSyntheticError(candidateTarget) && |
| 72 candidateTarget.hasFunctionSignature) { | 76 candidateTarget.hasFunctionSignature) { |
| 73 List<ir.Expression> existingArgumentsList = <ir.Expression>[]; | 77 List<ir.Expression> existingArgumentsList = <ir.Expression>[]; |
| 74 candidateTarget.functionSignature.forEachParameter((param) { | 78 candidateTarget.functionSignature.forEachParameter((param) { |
| 75 existingArgumentsList.add(new ir.StringLiteral(param.name)); | 79 existingArgumentsList |
| 80 .add(markSynthetic(new ir.StringLiteral(param.name))); |
| 76 }); | 81 }); |
| 77 existingArguments = new ir.ListLiteral(existingArgumentsList); | 82 existingArguments = |
| 83 markSynthetic(new ir.ListLiteral(existingArgumentsList)); |
| 78 } else { | 84 } else { |
| 79 existingArguments = new ir.NullLiteral(); | 85 existingArguments = new ir.NullLiteral(); |
| 80 } | 86 } |
| 81 return new ir.Throw(new ir.StaticInvocation( | 87 ir.Expression construction = markSynthetic(new ir.StaticInvocation( |
| 82 exceptionBuilder, | 88 exceptionBuilder, |
| 83 new ir.Arguments(<ir.Expression>[ | 89 new ir.Arguments(<ir.Expression>[ |
| 84 receiver, | 90 receiver, |
| 85 memberNameArg, | 91 memberNameArg, |
| 86 positional, | 92 positional, |
| 87 named, | 93 named, |
| 88 existingArguments | 94 existingArguments |
| 89 ]))); | 95 ]))); |
| 96 return new ir.Throw(construction); |
| 97 } |
| 98 |
| 99 ir.Expression markSynthetic(ir.Expression expression) { |
| 100 kernel.syntheticNodes.add(expression); |
| 101 return expression; |
| 90 } | 102 } |
| 91 | 103 |
| 92 /// Throws a NoSuchMethodError for an unresolved getter named [name]. | 104 /// Throws a NoSuchMethodError for an unresolved getter named [name]. |
| 93 ir.Expression buildThrowUnresolvedGetter(String name, | 105 ir.Expression buildThrowUnresolvedGetter(String name, |
| 94 [ir.Procedure exceptionBuilder]) { | 106 [ir.Procedure exceptionBuilder]) { |
| 95 // TODO(asgerf): We should remove this fallback, but in some cases we do | 107 // TODO(asgerf): We should remove this fallback, but in some cases we do |
| 96 // not get sufficient information to determine exactly what kind of | 108 // not get sufficient information to determine exactly what kind of |
| 97 // getter it is. | 109 // getter it is. |
| 98 exceptionBuilder ??= kernel.getGenericNoSuchMethodBuilder(); | 110 exceptionBuilder ??= kernel.getGenericNoSuchMethodBuilder(); |
| 99 return buildThrowNoSuchMethodError( | 111 return buildThrowNoSuchMethodError( |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 return buildUnresolvedSuperIndexAccessor(index, element) | 566 return buildUnresolvedSuperIndexAccessor(index, element) |
| 555 .buildNullAwareAssignment(visitForValue(rhs), null); | 567 .buildNullAwareAssignment(visitForValue(rhs), null); |
| 556 } | 568 } |
| 557 | 569 |
| 558 ir.Expression visitUnresolvedSuperSet( | 570 ir.Expression visitUnresolvedSuperSet( |
| 559 Send node, Element element, Node rhs, _) { | 571 Send node, Element element, Node rhs, _) { |
| 560 return buildThrowUnresolvedSuperSetter( | 572 return buildThrowUnresolvedSuperSetter( |
| 561 '${node.selector}', visitForValue(rhs)); | 573 '${node.selector}', visitForValue(rhs)); |
| 562 } | 574 } |
| 563 } | 575 } |
| OLD | NEW |