| 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 library fasta.fasta_accessors; | 5 library fasta.fasta_accessors; |
| 6 | 6 |
| 7 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart' | 7 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart' |
| 8 show | 8 show |
| 9 KernelArguments, | 9 KernelArguments, |
| 10 KernelComplexAssignment, | 10 KernelComplexAssignment, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 import 'package:front_end/src/scanner/token.dart' show Token; | 21 import 'package:front_end/src/scanner/token.dart' show Token; |
| 22 | 22 |
| 23 import 'frontend_accessors.dart' show Accessor; | 23 import 'frontend_accessors.dart' show Accessor; |
| 24 | 24 |
| 25 import 'package:front_end/src/fasta/type_inference/type_promotion.dart' | 25 import 'package:front_end/src/fasta/type_inference/type_promotion.dart' |
| 26 show TypePromoter; | 26 show TypePromoter; |
| 27 | 27 |
| 28 import 'package:kernel/ast.dart' | 28 import 'package:kernel/ast.dart' |
| 29 hide InvalidExpression, InvalidInitializer, InvalidStatement; | 29 hide InvalidExpression, InvalidInitializer, InvalidStatement; |
| 30 | 30 |
| 31 import '../errors.dart' show internalError; | 31 import '../deprecated_problems.dart' show deprecated_internalProblem; |
| 32 | 32 |
| 33 import '../scope.dart' show AccessErrorBuilder, ProblemBuilder, Scope; | 33 import '../scope.dart' |
| 34 show deprecated_AccessErrorBuilder, ProblemBuilder, Scope; |
| 34 | 35 |
| 35 import 'frontend_accessors.dart' as kernel | 36 import 'frontend_accessors.dart' as kernel |
| 36 show | 37 show |
| 37 IndexAccessor, | 38 IndexAccessor, |
| 38 NullAwarePropertyAccessor, | 39 NullAwarePropertyAccessor, |
| 39 PropertyAccessor, | 40 PropertyAccessor, |
| 40 ReadOnlyAccessor, | 41 ReadOnlyAccessor, |
| 41 StaticAccessor, | 42 StaticAccessor, |
| 42 SuperIndexAccessor, | 43 SuperIndexAccessor, |
| 43 SuperPropertyAccessor, | 44 SuperPropertyAccessor, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 73 | 74 |
| 74 Expression toValue(node); | 75 Expression toValue(node); |
| 75 | 76 |
| 76 Member lookupSuperMember(Name name, {bool isSetter}); | 77 Member lookupSuperMember(Name name, {bool isSetter}); |
| 77 | 78 |
| 78 scopeLookup(Scope scope, String name, Token token, | 79 scopeLookup(Scope scope, String name, Token token, |
| 79 {bool isQualified: false, PrefixBuilder prefix}); | 80 {bool isQualified: false, PrefixBuilder prefix}); |
| 80 | 81 |
| 81 finishSend(Object receiver, Arguments arguments, int offset); | 82 finishSend(Object receiver, Arguments arguments, int offset); |
| 82 | 83 |
| 83 Expression buildCompileTimeError(error, [int offset]); | 84 Expression deprecated_buildCompileTimeError(error, [int offset]); |
| 84 | 85 |
| 85 Initializer buildInvalidInitializer(Expression expression, [int offset]); | 86 Initializer buildInvalidInitializer(Expression expression, [int offset]); |
| 86 | 87 |
| 87 Initializer buildFieldInitializer( | 88 Initializer buildFieldInitializer( |
| 88 String name, int offset, Expression expression); | 89 String name, int offset, Expression expression); |
| 89 | 90 |
| 90 Initializer buildSuperInitializer( | 91 Initializer buildSuperInitializer( |
| 91 Constructor constructor, Arguments arguments, | 92 Constructor constructor, Arguments arguments, |
| 92 [int offset]); | 93 [int offset]); |
| 93 | 94 |
| 94 Initializer buildRedirectingInitializer( | 95 Initializer buildRedirectingInitializer( |
| 95 Constructor constructor, Arguments arguments, | 96 Constructor constructor, Arguments arguments, |
| 96 [int charOffset = -1]); | 97 [int charOffset = -1]); |
| 97 | 98 |
| 98 Expression buildStaticInvocation(Procedure target, Arguments arguments); | 99 Expression buildStaticInvocation(Procedure target, Arguments arguments); |
| 99 | 100 |
| 100 Expression buildProblemExpression(ProblemBuilder builder, int offset); | 101 Expression buildProblemExpression(ProblemBuilder builder, int offset); |
| 101 | 102 |
| 102 Expression throwNoSuchMethodError( | 103 Expression throwNoSuchMethodError( |
| 103 Expression receiver, String name, Arguments arguments, int offset, | 104 Expression receiver, String name, Arguments arguments, int offset, |
| 104 {bool isSuper, bool isGetter, bool isSetter, bool isStatic}); | 105 {bool isSuper, bool isGetter, bool isSetter, bool isStatic}); |
| 105 | 106 |
| 106 bool checkArguments(FunctionNode function, Arguments arguments, | 107 bool checkArguments(FunctionNode function, Arguments arguments, |
| 107 List<TypeParameter> typeParameters); | 108 List<TypeParameter> typeParameters); |
| 108 | 109 |
| 109 StaticGet makeStaticGet(Member readTarget, Token token); | 110 StaticGet makeStaticGet(Member readTarget, Token token); |
| 110 | 111 |
| 111 dynamic addCompileTimeError(int charOffset, String message, {bool silent}); | 112 dynamic deprecated_addCompileTimeError(int charOffset, String message, |
| 113 {bool silent}); |
| 112 | 114 |
| 113 bool isIdentical(Member member); | 115 bool isIdentical(Member member); |
| 114 | 116 |
| 115 Expression buildMethodInvocation( | 117 Expression buildMethodInvocation( |
| 116 Expression receiver, Name name, Arguments arguments, int offset, | 118 Expression receiver, Name name, Arguments arguments, int offset, |
| 117 {bool isConstantExpression, bool isNullAware, bool isImplicitCall}); | 119 {bool isConstantExpression, bool isNullAware, bool isImplicitCall}); |
| 118 | 120 |
| 119 DartType validatedTypeVariableUse( | 121 DartType validatedTypeVariableUse( |
| 120 TypeParameterType type, int offset, bool nonInstanceAccessIsError); | 122 TypeParameterType type, int offset, bool nonInstanceAccessIsError); |
| 121 | 123 |
| 122 void warning(String message, [int charOffset]); | 124 void deprecated_warning(String message, [int charOffset]); |
| 123 | 125 |
| 124 void warnUnresolvedSuperGet(Name name, int charOffset); | 126 void warnUnresolvedSuperGet(Name name, int charOffset); |
| 125 | 127 |
| 126 void warnUnresolvedSuperSet(Name name, int charOffset); | 128 void warnUnresolvedSuperSet(Name name, int charOffset); |
| 127 | 129 |
| 128 void warnUnresolvedSuperMethod(Name name, int charOffset); | 130 void warnUnresolvedSuperMethod(Name name, int charOffset); |
| 129 } | 131 } |
| 130 | 132 |
| 131 abstract class FastaAccessor implements Accessor { | 133 abstract class FastaAccessor implements Accessor { |
| 132 BuilderHelper get helper; | 134 BuilderHelper get helper; |
| 133 | 135 |
| 134 String get plainNameForRead; | 136 String get plainNameForRead; |
| 135 | 137 |
| 136 Uri get uri => helper.uri; | 138 Uri get uri => helper.uri; |
| 137 | 139 |
| 138 String get plainNameForWrite => plainNameForRead; | 140 String get plainNameForWrite => plainNameForRead; |
| 139 | 141 |
| 140 bool get isInitializer => false; | 142 bool get isInitializer => false; |
| 141 | 143 |
| 142 Expression buildForEffect() => buildSimpleRead(); | 144 Expression buildForEffect() => buildSimpleRead(); |
| 143 | 145 |
| 144 Initializer buildFieldInitializer(Map<String, int> initializedFields) { | 146 Initializer buildFieldInitializer(Map<String, int> initializedFields) { |
| 145 int offset = offsetForToken(token); | 147 int offset = offsetForToken(token); |
| 146 return helper.buildInvalidInitializer( | 148 return helper.buildInvalidInitializer( |
| 147 helper.buildCompileTimeError( | 149 helper.deprecated_buildCompileTimeError( |
| 148 // TODO(ahe): This error message is really bad. | 150 // TODO(ahe): This error message is really bad. |
| 149 "Can't use $plainNameForRead here.", | 151 "Can't use $plainNameForRead here.", |
| 150 offset), | 152 offset), |
| 151 offset); | 153 offset); |
| 152 } | 154 } |
| 153 | 155 |
| 154 Expression makeInvalidRead() { | 156 Expression makeInvalidRead() { |
| 155 return buildThrowNoSuchMethodError( | 157 return buildThrowNoSuchMethodError( |
| 156 new NullLiteral()..fileOffset = offsetForToken(token), | 158 new NullLiteral()..fileOffset = offsetForToken(token), |
| 157 new Arguments.empty(), | 159 new Arguments.empty(), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 169 int offset, Arguments arguments); | 171 int offset, Arguments arguments); |
| 170 | 172 |
| 171 /* Expression | FastaAccessor */ buildPropertyAccess( | 173 /* Expression | FastaAccessor */ buildPropertyAccess( |
| 172 IncompleteSend send, int operatorOffset, bool isNullAware) { | 174 IncompleteSend send, int operatorOffset, bool isNullAware) { |
| 173 if (send is SendAccessor) { | 175 if (send is SendAccessor) { |
| 174 return helper.buildMethodInvocation(buildSimpleRead(), send.name, | 176 return helper.buildMethodInvocation(buildSimpleRead(), send.name, |
| 175 send.arguments, offsetForToken(send.token), | 177 send.arguments, offsetForToken(send.token), |
| 176 isNullAware: isNullAware); | 178 isNullAware: isNullAware); |
| 177 } else { | 179 } else { |
| 178 if (helper.constantExpressionRequired && send.name != lengthName) { | 180 if (helper.constantExpressionRequired && send.name != lengthName) { |
| 179 helper.addCompileTimeError( | 181 helper.deprecated_addCompileTimeError( |
| 180 offsetForToken(token), "Not a constant expression."); | 182 offsetForToken(token), "Not a constant expression."); |
| 181 } | 183 } |
| 182 return PropertyAccessor.make(helper, send.token, buildSimpleRead(), | 184 return PropertyAccessor.make(helper, send.token, buildSimpleRead(), |
| 183 send.name, null, null, isNullAware); | 185 send.name, null, null, isNullAware); |
| 184 } | 186 } |
| 185 } | 187 } |
| 186 | 188 |
| 187 /* Expression | FastaAccessor */ buildThrowNoSuchMethodError( | 189 /* Expression | FastaAccessor */ buildThrowNoSuchMethodError( |
| 188 Expression receiver, Arguments arguments, | 190 Expression receiver, Arguments arguments, |
| 189 {bool isSuper: false, | 191 {bool isSuper: false, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 207 new KernelIllegalAssignment(rhs); | 209 new KernelIllegalAssignment(rhs); |
| 208 } | 210 } |
| 209 | 211 |
| 210 abstract class ErrorAccessor implements FastaAccessor { | 212 abstract class ErrorAccessor implements FastaAccessor { |
| 211 /// Pass [arguments] that must be evaluated before throwing an error. At | 213 /// Pass [arguments] that must be evaluated before throwing an error. At |
| 212 /// most one of [isGetter] and [isSetter] should be true and they're passed | 214 /// most one of [isGetter] and [isSetter] should be true and they're passed |
| 213 /// to [BuilderHelper.buildThrowNoSuchMethodError] if it is used. | 215 /// to [BuilderHelper.buildThrowNoSuchMethodError] if it is used. |
| 214 Expression buildError(Arguments arguments, | 216 Expression buildError(Arguments arguments, |
| 215 {bool isGetter: false, bool isSetter: false, int offset}); | 217 {bool isGetter: false, bool isSetter: false, int offset}); |
| 216 | 218 |
| 217 Name get name => internalError("Unsupported operation."); | 219 Name get name => deprecated_internalProblem("Unsupported operation."); |
| 218 | 220 |
| 219 @override | 221 @override |
| 220 String get plainNameForRead => name.name; | 222 String get plainNameForRead => name.name; |
| 221 | 223 |
| 222 withReceiver(Object receiver, int operatorOffset, {bool isNullAware}) => this; | 224 withReceiver(Object receiver, int operatorOffset, {bool isNullAware}) => this; |
| 223 | 225 |
| 224 @override | 226 @override |
| 225 Initializer buildFieldInitializer(Map<String, int> initializedFields) { | 227 Initializer buildFieldInitializer(Map<String, int> initializedFields) { |
| 226 return helper.buildInvalidInitializer( | 228 return helper.buildInvalidInitializer( |
| 227 buildError(new Arguments.empty(), isSetter: true)); | 229 buildError(new Arguments.empty(), isSetter: true)); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 | 309 |
| 308 final Token token; | 310 final Token token; |
| 309 | 311 |
| 310 final bool isInitializer; | 312 final bool isInitializer; |
| 311 | 313 |
| 312 final bool isSuper; | 314 final bool isSuper; |
| 313 | 315 |
| 314 ThisAccessor(this.helper, this.token, this.isInitializer, | 316 ThisAccessor(this.helper, this.token, this.isInitializer, |
| 315 {this.isSuper: false}); | 317 {this.isSuper: false}); |
| 316 | 318 |
| 317 String get plainNameForRead => internalError(isSuper ? "super" : "this"); | 319 String get plainNameForRead => |
| 320 deprecated_internalProblem(isSuper ? "super" : "this"); |
| 318 | 321 |
| 319 Expression buildSimpleRead() { | 322 Expression buildSimpleRead() { |
| 320 if (!isSuper) { | 323 if (!isSuper) { |
| 321 return new KernelThisExpression(); | 324 return new KernelThisExpression(); |
| 322 } else { | 325 } else { |
| 323 return helper.buildCompileTimeError( | 326 return helper.deprecated_buildCompileTimeError( |
| 324 "Can't use `super` as an expression.", offsetForToken(token)); | 327 "Can't use `super` as an expression.", offsetForToken(token)); |
| 325 } | 328 } |
| 326 } | 329 } |
| 327 | 330 |
| 328 @override | 331 @override |
| 329 Initializer buildFieldInitializer(Map<String, int> initializedFields) { | 332 Initializer buildFieldInitializer(Map<String, int> initializedFields) { |
| 330 String keyword = isSuper ? "super" : "this"; | 333 String keyword = isSuper ? "super" : "this"; |
| 331 int offset = offsetForToken(token); | 334 int offset = offsetForToken(token); |
| 332 return helper.buildInvalidInitializer( | 335 return helper.buildInvalidInitializer( |
| 333 helper.buildCompileTimeError( | 336 helper.deprecated_buildCompileTimeError( |
| 334 "Can't use '$keyword' here, did you mean '$keyword()'?", offset), | 337 "Can't use '$keyword' here, did you mean '$keyword()'?", offset), |
| 335 offset); | 338 offset); |
| 336 } | 339 } |
| 337 | 340 |
| 338 buildPropertyAccess( | 341 buildPropertyAccess( |
| 339 IncompleteSend send, int operatorOffset, bool isNullAware) { | 342 IncompleteSend send, int operatorOffset, bool isNullAware) { |
| 340 if (isInitializer && send is SendAccessor) { | 343 if (isInitializer && send is SendAccessor) { |
| 341 if (isNullAware) { | 344 if (isNullAware) { |
| 342 helper.addCompileTimeError( | 345 helper.deprecated_addCompileTimeError( |
| 343 operatorOffset, "Expected '.'\nTry removing '?'."); | 346 operatorOffset, "Expected '.'\nTry removing '?'."); |
| 344 } | 347 } |
| 345 return buildConstructorInitializer( | 348 return buildConstructorInitializer( |
| 346 offsetForToken(send.token), send.name, send.arguments); | 349 offsetForToken(send.token), send.name, send.arguments); |
| 347 } | 350 } |
| 348 if (send is SendAccessor) { | 351 if (send is SendAccessor) { |
| 349 // Notice that 'this' or 'super' can't be null. So we can ignore the | 352 // Notice that 'this' or 'super' can't be null. So we can ignore the |
| 350 // value of [isNullAware]. | 353 // value of [isNullAware]. |
| 351 MethodInvocation result = helper.buildMethodInvocation( | 354 MethodInvocation result = helper.buildMethodInvocation( |
| 352 new KernelThisExpression(), | 355 new KernelThisExpression(), |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 Expression buildPostfixIncrement(Name binaryOperator, | 426 Expression buildPostfixIncrement(Name binaryOperator, |
| 424 {int offset: TreeNode.noOffset, | 427 {int offset: TreeNode.noOffset, |
| 425 bool voidContext: false, | 428 bool voidContext: false, |
| 426 Procedure interfaceTarget}) { | 429 Procedure interfaceTarget}) { |
| 427 return buildAssignmentError(); | 430 return buildAssignmentError(); |
| 428 } | 431 } |
| 429 | 432 |
| 430 Expression buildAssignmentError() { | 433 Expression buildAssignmentError() { |
| 431 String message = | 434 String message = |
| 432 isSuper ? "Can't assign to 'super'." : "Can't assign to 'this'."; | 435 isSuper ? "Can't assign to 'super'." : "Can't assign to 'this'."; |
| 433 return helper.buildCompileTimeError(message, offsetForToken(token)); | 436 return helper.deprecated_buildCompileTimeError( |
| 437 message, offsetForToken(token)); |
| 434 } | 438 } |
| 435 | 439 |
| 436 toString() { | 440 toString() { |
| 437 int offset = offsetForToken(token); | 441 int offset = offsetForToken(token); |
| 438 return "ThisAccessor($offset${isSuper ? ', super' : ''})"; | 442 return "ThisAccessor($offset${isSuper ? ', super' : ''})"; |
| 439 } | 443 } |
| 440 } | 444 } |
| 441 | 445 |
| 442 abstract class IncompleteSend extends FastaAccessor { | 446 abstract class IncompleteSend extends FastaAccessor { |
| 443 final BuilderHelper helper; | 447 final BuilderHelper helper; |
| 444 | 448 |
| 445 @override | 449 @override |
| 446 final Token token; | 450 final Token token; |
| 447 | 451 |
| 448 final Name name; | 452 final Name name; |
| 449 | 453 |
| 450 IncompleteSend(this.helper, this.token, this.name); | 454 IncompleteSend(this.helper, this.token, this.name); |
| 451 | 455 |
| 452 withReceiver(Object receiver, int operatorOffset, {bool isNullAware}); | 456 withReceiver(Object receiver, int operatorOffset, {bool isNullAware}); |
| 453 | 457 |
| 454 Arguments get arguments => null; | 458 Arguments get arguments => null; |
| 455 } | 459 } |
| 456 | 460 |
| 457 class IncompleteError extends IncompleteSend with ErrorAccessor { | 461 class deprecated_IncompleteError extends IncompleteSend with ErrorAccessor { |
| 458 final Object error; | 462 final Object error; |
| 459 | 463 |
| 460 IncompleteError(BuilderHelper helper, Token token, this.error) | 464 deprecated_IncompleteError(BuilderHelper helper, Token token, this.error) |
| 461 : super(helper, token, null); | 465 : super(helper, token, null); |
| 462 | 466 |
| 463 @override | 467 @override |
| 464 Expression buildError(Arguments arguments, | 468 Expression buildError(Arguments arguments, |
| 465 {bool isGetter: false, bool isSetter: false, int offset}) { | 469 {bool isGetter: false, bool isSetter: false, int offset}) { |
| 466 return helper.buildCompileTimeError( | 470 return helper.deprecated_buildCompileTimeError( |
| 467 error, offset ?? offsetForToken(this.token)); | 471 error, offset ?? offsetForToken(this.token)); |
| 468 } | 472 } |
| 469 | 473 |
| 470 @override | 474 @override |
| 471 doInvocation(int offset, Arguments arguments) => this; | 475 doInvocation(int offset, Arguments arguments) => this; |
| 472 } | 476 } |
| 473 | 477 |
| 474 class SendAccessor extends IncompleteSend { | 478 class SendAccessor extends IncompleteSend { |
| 475 @override | 479 @override |
| 476 final Arguments arguments; | 480 final Arguments arguments; |
| 477 | 481 |
| 478 SendAccessor(BuilderHelper helper, Token token, Name name, this.arguments) | 482 SendAccessor(BuilderHelper helper, Token token, Name name, this.arguments) |
| 479 : super(helper, token, name) { | 483 : super(helper, token, name) { |
| 480 assert(arguments != null); | 484 assert(arguments != null); |
| 481 } | 485 } |
| 482 | 486 |
| 483 String get plainNameForRead => name.name; | 487 String get plainNameForRead => name.name; |
| 484 | 488 |
| 485 Expression buildSimpleRead() { | 489 Expression buildSimpleRead() { |
| 486 return internalError("Unhandled"); | 490 return deprecated_internalProblem("Unhandled"); |
| 487 } | 491 } |
| 488 | 492 |
| 489 Expression buildAssignment(Expression value, {bool voidContext: false}) { | 493 Expression buildAssignment(Expression value, {bool voidContext: false}) { |
| 490 return internalError("Unhandled"); | 494 return deprecated_internalProblem("Unhandled"); |
| 491 } | 495 } |
| 492 | 496 |
| 493 withReceiver(Object receiver, int operatorOffset, {bool isNullAware: false}) { | 497 withReceiver(Object receiver, int operatorOffset, {bool isNullAware: false}) { |
| 494 if (receiver is FastaAccessor) { | 498 if (receiver is FastaAccessor) { |
| 495 return receiver.buildPropertyAccess(this, operatorOffset, isNullAware); | 499 return receiver.buildPropertyAccess(this, operatorOffset, isNullAware); |
| 496 } | 500 } |
| 497 if (receiver is PrefixBuilder) { | 501 if (receiver is PrefixBuilder) { |
| 498 PrefixBuilder prefix = receiver; | 502 PrefixBuilder prefix = receiver; |
| 499 if (isNullAware) { | 503 if (isNullAware) { |
| 500 helper.addCompileTimeError( | 504 helper.deprecated_addCompileTimeError( |
| 501 offsetForToken(token), | 505 offsetForToken(token), |
| 502 "Library prefix '${prefix.name}' can't be used with null-aware " | 506 "Library prefix '${prefix.name}' can't be used with null-aware " |
| 503 "operator.\nTry removing '?'."); | 507 "operator.\nTry removing '?'."); |
| 504 } | 508 } |
| 505 receiver = helper.scopeLookup(prefix.exports, name.name, token, | 509 receiver = helper.scopeLookup(prefix.exports, name.name, token, |
| 506 isQualified: true, prefix: prefix); | 510 isQualified: true, prefix: prefix); |
| 507 return helper.finishSend(receiver, arguments, offsetForToken(token)); | 511 return helper.finishSend(receiver, arguments, offsetForToken(token)); |
| 508 } | 512 } |
| 509 return helper.buildMethodInvocation( | 513 return helper.buildMethodInvocation( |
| 510 helper.toValue(receiver), name, arguments, offsetForToken(token), | 514 helper.toValue(receiver), name, arguments, offsetForToken(token), |
| 511 isNullAware: isNullAware); | 515 isNullAware: isNullAware); |
| 512 } | 516 } |
| 513 | 517 |
| 514 Expression buildNullAwareAssignment( | 518 Expression buildNullAwareAssignment( |
| 515 Expression value, DartType type, int offset, | 519 Expression value, DartType type, int offset, |
| 516 {bool voidContext: false}) { | 520 {bool voidContext: false}) { |
| 517 return internalError("Unhandled"); | 521 return deprecated_internalProblem("Unhandled"); |
| 518 } | 522 } |
| 519 | 523 |
| 520 Expression buildCompoundAssignment(Name binaryOperator, Expression value, | 524 Expression buildCompoundAssignment(Name binaryOperator, Expression value, |
| 521 {int offset, | 525 {int offset, |
| 522 bool voidContext: false, | 526 bool voidContext: false, |
| 523 Procedure interfaceTarget, | 527 Procedure interfaceTarget, |
| 524 bool isPreIncDec: false}) { | 528 bool isPreIncDec: false}) { |
| 525 return internalError("Unhandled"); | 529 return deprecated_internalProblem("Unhandled"); |
| 526 } | 530 } |
| 527 | 531 |
| 528 Expression buildPrefixIncrement(Name binaryOperator, | 532 Expression buildPrefixIncrement(Name binaryOperator, |
| 529 {int offset, bool voidContext: false, Procedure interfaceTarget}) { | 533 {int offset, bool voidContext: false, Procedure interfaceTarget}) { |
| 530 return internalError("Unhandled"); | 534 return deprecated_internalProblem("Unhandled"); |
| 531 } | 535 } |
| 532 | 536 |
| 533 Expression buildPostfixIncrement(Name binaryOperator, | 537 Expression buildPostfixIncrement(Name binaryOperator, |
| 534 {int offset, bool voidContext: false, Procedure interfaceTarget}) { | 538 {int offset, bool voidContext: false, Procedure interfaceTarget}) { |
| 535 return internalError("Unhandled"); | 539 return deprecated_internalProblem("Unhandled"); |
| 536 } | 540 } |
| 537 | 541 |
| 538 Expression doInvocation(int offset, Arguments arguments) { | 542 Expression doInvocation(int offset, Arguments arguments) { |
| 539 return internalError("Unhandled"); | 543 return deprecated_internalProblem("Unhandled"); |
| 540 } | 544 } |
| 541 | 545 |
| 542 toString() { | 546 toString() { |
| 543 int offset = offsetForToken(token); | 547 int offset = offsetForToken(token); |
| 544 return "SendAccessor($offset, $name, $arguments)"; | 548 return "SendAccessor($offset, $name, $arguments)"; |
| 545 } | 549 } |
| 546 } | 550 } |
| 547 | 551 |
| 548 class IncompletePropertyAccessor extends IncompleteSend { | 552 class IncompletePropertyAccessor extends IncompleteSend { |
| 549 IncompletePropertyAccessor(BuilderHelper helper, Token token, Name name) | 553 IncompletePropertyAccessor(BuilderHelper helper, Token token, Name name) |
| 550 : super(helper, token, name); | 554 : super(helper, token, name); |
| 551 | 555 |
| 552 String get plainNameForRead => name.name; | 556 String get plainNameForRead => name.name; |
| 553 | 557 |
| 554 Expression buildSimpleRead() => internalError("Unhandled"); | 558 Expression buildSimpleRead() => deprecated_internalProblem("Unhandled"); |
| 555 | 559 |
| 556 Expression buildAssignment(Expression value, {bool voidContext: false}) { | 560 Expression buildAssignment(Expression value, {bool voidContext: false}) { |
| 557 return internalError("Unhandled"); | 561 return deprecated_internalProblem("Unhandled"); |
| 558 } | 562 } |
| 559 | 563 |
| 560 withReceiver(Object receiver, int operatorOffset, {bool isNullAware: false}) { | 564 withReceiver(Object receiver, int operatorOffset, {bool isNullAware: false}) { |
| 561 if (receiver is FastaAccessor) { | 565 if (receiver is FastaAccessor) { |
| 562 return receiver.buildPropertyAccess(this, operatorOffset, isNullAware); | 566 return receiver.buildPropertyAccess(this, operatorOffset, isNullAware); |
| 563 } | 567 } |
| 564 if (receiver is PrefixBuilder) { | 568 if (receiver is PrefixBuilder) { |
| 565 PrefixBuilder prefix = receiver; | 569 PrefixBuilder prefix = receiver; |
| 566 if (isNullAware) { | 570 if (isNullAware) { |
| 567 helper.addCompileTimeError( | 571 helper.deprecated_addCompileTimeError( |
| 568 offsetForToken(token), | 572 offsetForToken(token), |
| 569 "Library prefix '${prefix.name}' can't be used with null-aware " | 573 "Library prefix '${prefix.name}' can't be used with null-aware " |
| 570 "operator.\nTry removing '?'."); | 574 "operator.\nTry removing '?'."); |
| 571 } | 575 } |
| 572 return helper.scopeLookup(prefix.exports, name.name, token, | 576 return helper.scopeLookup(prefix.exports, name.name, token, |
| 573 isQualified: true, prefix: prefix); | 577 isQualified: true, prefix: prefix); |
| 574 } | 578 } |
| 575 | 579 |
| 576 return PropertyAccessor.make( | 580 return PropertyAccessor.make( |
| 577 helper, token, helper.toValue(receiver), name, null, null, isNullAware); | 581 helper, token, helper.toValue(receiver), name, null, null, isNullAware); |
| 578 } | 582 } |
| 579 | 583 |
| 580 Expression buildNullAwareAssignment( | 584 Expression buildNullAwareAssignment( |
| 581 Expression value, DartType type, int offset, | 585 Expression value, DartType type, int offset, |
| 582 {bool voidContext: false}) { | 586 {bool voidContext: false}) { |
| 583 return internalError("Unhandled"); | 587 return deprecated_internalProblem("Unhandled"); |
| 584 } | 588 } |
| 585 | 589 |
| 586 Expression buildCompoundAssignment(Name binaryOperator, Expression value, | 590 Expression buildCompoundAssignment(Name binaryOperator, Expression value, |
| 587 {int offset, | 591 {int offset, |
| 588 bool voidContext: false, | 592 bool voidContext: false, |
| 589 Procedure interfaceTarget, | 593 Procedure interfaceTarget, |
| 590 bool isPreIncDec: false}) { | 594 bool isPreIncDec: false}) { |
| 591 return internalError("Unhandled"); | 595 return deprecated_internalProblem("Unhandled"); |
| 592 } | 596 } |
| 593 | 597 |
| 594 Expression buildPrefixIncrement(Name binaryOperator, | 598 Expression buildPrefixIncrement(Name binaryOperator, |
| 595 {int offset, bool voidContext: false, Procedure interfaceTarget}) { | 599 {int offset, bool voidContext: false, Procedure interfaceTarget}) { |
| 596 return internalError("Unhandled"); | 600 return deprecated_internalProblem("Unhandled"); |
| 597 } | 601 } |
| 598 | 602 |
| 599 Expression buildPostfixIncrement(Name binaryOperator, | 603 Expression buildPostfixIncrement(Name binaryOperator, |
| 600 {int offset, bool voidContext: false, Procedure interfaceTarget}) { | 604 {int offset, bool voidContext: false, Procedure interfaceTarget}) { |
| 601 return internalError("Unhandled"); | 605 return deprecated_internalProblem("Unhandled"); |
| 602 } | 606 } |
| 603 | 607 |
| 604 Expression doInvocation(int offset, Arguments arguments) { | 608 Expression doInvocation(int offset, Arguments arguments) { |
| 605 return internalError("Unhandled"); | 609 return deprecated_internalProblem("Unhandled"); |
| 606 } | 610 } |
| 607 | 611 |
| 608 toString() { | 612 toString() { |
| 609 int offset = offsetForToken(token); | 613 int offset = offsetForToken(token); |
| 610 return "IncompletePropertyAccessor($offset, $name)"; | 614 return "IncompletePropertyAccessor($offset, $name)"; |
| 611 } | 615 } |
| 612 } | 616 } |
| 613 | 617 |
| 614 class IndexAccessor extends kernel.IndexAccessor with FastaAccessor { | 618 class IndexAccessor extends kernel.IndexAccessor with FastaAccessor { |
| 615 final BuilderHelper helper; | 619 final BuilderHelper helper; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 | 697 |
| 694 class StaticAccessor extends kernel.StaticAccessor with FastaAccessor { | 698 class StaticAccessor extends kernel.StaticAccessor with FastaAccessor { |
| 695 StaticAccessor( | 699 StaticAccessor( |
| 696 BuilderHelper helper, Token token, Member readTarget, Member writeTarget) | 700 BuilderHelper helper, Token token, Member readTarget, Member writeTarget) |
| 697 : super(helper, readTarget, writeTarget, token) { | 701 : super(helper, readTarget, writeTarget, token) { |
| 698 assert(readTarget != null || writeTarget != null); | 702 assert(readTarget != null || writeTarget != null); |
| 699 } | 703 } |
| 700 | 704 |
| 701 factory StaticAccessor.fromBuilder(BuilderHelper helper, Builder builder, | 705 factory StaticAccessor.fromBuilder(BuilderHelper helper, Builder builder, |
| 702 Token token, Builder builderSetter) { | 706 Token token, Builder builderSetter) { |
| 703 if (builder is AccessErrorBuilder) { | 707 if (builder is deprecated_AccessErrorBuilder) { |
| 704 AccessErrorBuilder error = builder; | 708 deprecated_AccessErrorBuilder error = builder; |
| 705 builder = error.builder; | 709 builder = error.builder; |
| 706 // We should only see an access error here if we've looked up a setter | 710 // We should only see an access error here if we've looked up a setter |
| 707 // when not explicitly looking for a setter. | 711 // when not explicitly looking for a setter. |
| 708 assert(builder.isSetter); | 712 assert(builder.isSetter); |
| 709 } else if (builder.target == null) { | 713 } else if (builder.target == null) { |
| 710 return internalError("Unhandled: ${builder}"); | 714 return deprecated_internalProblem("Unhandled: ${builder}"); |
| 711 } | 715 } |
| 712 Member getter = builder.target.hasGetter ? builder.target : null; | 716 Member getter = builder.target.hasGetter ? builder.target : null; |
| 713 Member setter = builder.target.hasSetter ? builder.target : null; | 717 Member setter = builder.target.hasSetter ? builder.target : null; |
| 714 if (setter == null) { | 718 if (setter == null) { |
| 715 if (builderSetter?.target?.hasSetter ?? false) { | 719 if (builderSetter?.target?.hasSetter ?? false) { |
| 716 setter = builderSetter.target; | 720 setter = builderSetter.target; |
| 717 } | 721 } |
| 718 } | 722 } |
| 719 return new StaticAccessor(helper, token, getter, setter); | 723 return new StaticAccessor(helper, token, getter, setter); |
| 720 } | 724 } |
| 721 | 725 |
| 722 String get plainNameForRead => (readTarget ?? writeTarget).name.name; | 726 String get plainNameForRead => (readTarget ?? writeTarget).name.name; |
| 723 | 727 |
| 724 Expression doInvocation(int offset, Arguments arguments) { | 728 Expression doInvocation(int offset, Arguments arguments) { |
| 725 if (helper.constantExpressionRequired && !helper.isIdentical(readTarget)) { | 729 if (helper.constantExpressionRequired && !helper.isIdentical(readTarget)) { |
| 726 helper.addCompileTimeError(offset, "Not a constant expression."); | 730 helper.deprecated_addCompileTimeError( |
| 731 offset, "Not a constant expression."); |
| 727 } | 732 } |
| 728 if (readTarget == null || isFieldOrGetter(readTarget)) { | 733 if (readTarget == null || isFieldOrGetter(readTarget)) { |
| 729 return helper.buildMethodInvocation(buildSimpleRead(), callName, | 734 return helper.buildMethodInvocation(buildSimpleRead(), callName, |
| 730 arguments, offset + (readTarget?.name?.name?.length ?? 0), | 735 arguments, offset + (readTarget?.name?.name?.length ?? 0), |
| 731 // This isn't a constant expression, but we have checked if a | 736 // This isn't a constant expression, but we have checked if a |
| 732 // constant expression error should be emitted already. | 737 // constant expression error should be emitted already. |
| 733 isConstantExpression: true, | 738 isConstantExpression: true, |
| 734 isImplicitCall: true); | 739 isImplicitCall: true); |
| 735 } else { | 740 } else { |
| 736 return helper.buildStaticInvocation(readTarget, arguments) | 741 return helper.buildStaticInvocation(readTarget, arguments) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 748 class SuperPropertyAccessor extends kernel.SuperPropertyAccessor | 753 class SuperPropertyAccessor extends kernel.SuperPropertyAccessor |
| 749 with FastaAccessor { | 754 with FastaAccessor { |
| 750 SuperPropertyAccessor(BuilderHelper helper, Token token, Name name, | 755 SuperPropertyAccessor(BuilderHelper helper, Token token, Name name, |
| 751 Member getter, Member setter) | 756 Member getter, Member setter) |
| 752 : super(helper, name, getter, setter, token); | 757 : super(helper, name, getter, setter, token); |
| 753 | 758 |
| 754 String get plainNameForRead => name.name; | 759 String get plainNameForRead => name.name; |
| 755 | 760 |
| 756 Expression doInvocation(int offset, Arguments arguments) { | 761 Expression doInvocation(int offset, Arguments arguments) { |
| 757 if (helper.constantExpressionRequired) { | 762 if (helper.constantExpressionRequired) { |
| 758 helper.addCompileTimeError(offset, "Not a constant expression."); | 763 helper.deprecated_addCompileTimeError( |
| 764 offset, "Not a constant expression."); |
| 759 } | 765 } |
| 760 if (getter == null || isFieldOrGetter(getter)) { | 766 if (getter == null || isFieldOrGetter(getter)) { |
| 761 return helper.buildMethodInvocation( | 767 return helper.buildMethodInvocation( |
| 762 buildSimpleRead(), callName, arguments, offset, | 768 buildSimpleRead(), callName, arguments, offset, |
| 763 // This isn't a constant expression, but we have checked if a | 769 // This isn't a constant expression, but we have checked if a |
| 764 // constant expression error should be emitted already. | 770 // constant expression error should be emitted already. |
| 765 isConstantExpression: true, | 771 isConstantExpression: true, |
| 766 isImplicitCall: true); | 772 isImplicitCall: true); |
| 767 } else { | 773 } else { |
| 768 // TODO(ahe): This could be something like "super.property(...)" where | 774 // TODO(ahe): This could be something like "super.property(...)" where |
| 769 // property is a setter. | 775 // property is a setter. |
| 770 return internalError("Unhandled invocation ${getter.runtimeType}.", | 776 return deprecated_internalProblem( |
| 771 helper.uri, offsetForToken(token)); | 777 "Unhandled invocation ${getter.runtimeType}.", |
| 778 helper.uri, |
| 779 offsetForToken(token)); |
| 772 } | 780 } |
| 773 } | 781 } |
| 774 | 782 |
| 775 toString() => "SuperPropertyAccessor()"; | 783 toString() => "SuperPropertyAccessor()"; |
| 776 | 784 |
| 777 @override | 785 @override |
| 778 KernelComplexAssignment startComplexAssignment(Expression rhs) => | 786 KernelComplexAssignment startComplexAssignment(Expression rhs) => |
| 779 new KernelPropertyAssign(null, rhs, isSuper: true); | 787 new KernelPropertyAssign(null, rhs, isSuper: true); |
| 780 } | 788 } |
| 781 | 789 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 with FastaAccessor { | 865 with FastaAccessor { |
| 858 final BuilderHelper helper; | 866 final BuilderHelper helper; |
| 859 | 867 |
| 860 NullAwarePropertyAccessor(this.helper, Token token, Expression receiver, | 868 NullAwarePropertyAccessor(this.helper, Token token, Expression receiver, |
| 861 Name name, Member getter, Member setter, DartType type) | 869 Name name, Member getter, Member setter, DartType type) |
| 862 : super(helper, receiver, name, getter, setter, type, token); | 870 : super(helper, receiver, name, getter, setter, type, token); |
| 863 | 871 |
| 864 String get plainNameForRead => name.name; | 872 String get plainNameForRead => name.name; |
| 865 | 873 |
| 866 Expression doInvocation(int offset, Arguments arguments) { | 874 Expression doInvocation(int offset, Arguments arguments) { |
| 867 return internalError("Not implemented yet."); | 875 return deprecated_internalProblem("Not implemented yet."); |
| 868 } | 876 } |
| 869 | 877 |
| 870 toString() => "NullAwarePropertyAccessor()"; | 878 toString() => "NullAwarePropertyAccessor()"; |
| 871 | 879 |
| 872 @override | 880 @override |
| 873 KernelComplexAssignment startComplexAssignment(Expression rhs) => | 881 KernelComplexAssignment startComplexAssignment(Expression rhs) => |
| 874 new KernelPropertyAssign(receiverExpression, rhs); | 882 new KernelPropertyAssign(receiverExpression, rhs); |
| 875 } | 883 } |
| 876 | 884 |
| 877 int adjustForImplicitCall(String name, int offset) { | 885 int adjustForImplicitCall(String name, int offset) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 914 isImplicitCall: true); | 922 isImplicitCall: true); |
| 915 } | 923 } |
| 916 } | 924 } |
| 917 | 925 |
| 918 class ParenthesizedExpression extends ReadOnlyAccessor { | 926 class ParenthesizedExpression extends ReadOnlyAccessor { |
| 919 ParenthesizedExpression( | 927 ParenthesizedExpression( |
| 920 BuilderHelper helper, Expression expression, Token token) | 928 BuilderHelper helper, Expression expression, Token token) |
| 921 : super(helper, expression, null, token); | 929 : super(helper, expression, null, token); |
| 922 | 930 |
| 923 Expression makeInvalidWrite(Expression value) { | 931 Expression makeInvalidWrite(Expression value) { |
| 924 return helper.buildCompileTimeError( | 932 return helper.deprecated_buildCompileTimeError( |
| 925 "Can't assign to a parenthesized expression.", offsetForToken(token)); | 933 "Can't assign to a parenthesized expression.", offsetForToken(token)); |
| 926 } | 934 } |
| 927 } | 935 } |
| 928 | 936 |
| 929 class TypeDeclarationAccessor extends ReadOnlyAccessor { | 937 class TypeDeclarationAccessor extends ReadOnlyAccessor { |
| 930 final TypeDeclarationBuilder declaration; | 938 final TypeDeclarationBuilder declaration; |
| 931 | 939 |
| 932 TypeDeclarationAccessor(BuilderHelper helper, this.declaration, | 940 TypeDeclarationAccessor(BuilderHelper helper, this.declaration, |
| 933 String plainNameForRead, Token token) | 941 String plainNameForRead, Token token) |
| 934 : super(helper, null, plainNameForRead, token); | 942 : super(helper, null, plainNameForRead, token); |
| 935 | 943 |
| 936 Expression get expression { | 944 Expression get expression { |
| 937 if (super.expression == null) { | 945 if (super.expression == null) { |
| 938 int offset = offsetForToken(token); | 946 int offset = offsetForToken(token); |
| 939 if (declaration is KernelInvalidTypeBuilder) { | 947 if (declaration is KernelInvalidTypeBuilder) { |
| 940 KernelInvalidTypeBuilder declaration = this.declaration; | 948 KernelInvalidTypeBuilder declaration = this.declaration; |
| 941 String message = declaration.message; | 949 String message = declaration.message; |
| 942 helper.library.addWarning(declaration.charOffset, message, | 950 helper.library.deprecated_addWarning(declaration.charOffset, message, |
| 943 fileUri: declaration.fileUri); | 951 fileUri: declaration.fileUri); |
| 944 helper.warning(message, offset); | 952 helper.deprecated_warning(message, offset); |
| 945 super.expression = new Throw( | 953 super.expression = new Throw( |
| 946 new StringLiteral(message)..fileOffset = offsetForToken(token)) | 954 new StringLiteral(message)..fileOffset = offsetForToken(token)) |
| 947 ..fileOffset = offset; | 955 ..fileOffset = offset; |
| 948 } else { | 956 } else { |
| 949 super.expression = new KernelTypeLiteral( | 957 super.expression = new KernelTypeLiteral( |
| 950 buildType(null, nonInstanceAccessIsError: true)) | 958 buildType(null, nonInstanceAccessIsError: true)) |
| 951 ..fileOffset = offsetForToken(token); | 959 ..fileOffset = offsetForToken(token); |
| 952 } | 960 } |
| 953 } | 961 } |
| 954 return super.expression; | 962 return super.expression; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 971 Name name = send.name; | 979 Name name = send.name; |
| 972 Arguments arguments = send.arguments; | 980 Arguments arguments = send.arguments; |
| 973 | 981 |
| 974 if (declaration is KernelClassBuilder) { | 982 if (declaration is KernelClassBuilder) { |
| 975 KernelClassBuilder declaration = this.declaration; | 983 KernelClassBuilder declaration = this.declaration; |
| 976 Builder builder = declaration.findStaticBuilder( | 984 Builder builder = declaration.findStaticBuilder( |
| 977 name.name, offsetForToken(token), uri, helper.library); | 985 name.name, offsetForToken(token), uri, helper.library); |
| 978 | 986 |
| 979 FastaAccessor accessor; | 987 FastaAccessor accessor; |
| 980 if (builder == null) { | 988 if (builder == null) { |
| 981 // If we find a setter, [builder] is an [AccessErrorBuilder], not null. | 989 // If we find a setter, [builder] is an |
| 990 // [deprecated_AccessErrorBuilder], not null. |
| 982 accessor = new UnresolvedAccessor(helper, name, token); | 991 accessor = new UnresolvedAccessor(helper, name, token); |
| 983 } else { | 992 } else { |
| 984 Builder setter; | 993 Builder setter; |
| 985 if (builder.isSetter) { | 994 if (builder.isSetter) { |
| 986 setter = builder; | 995 setter = builder; |
| 987 } else if (builder.isGetter) { | 996 } else if (builder.isGetter) { |
| 988 setter = declaration.findStaticBuilder( | 997 setter = declaration.findStaticBuilder( |
| 989 name.name, offsetForToken(token), uri, helper.library, | 998 name.name, offsetForToken(token), uri, helper.library, |
| 990 isSetter: true); | 999 isSetter: true); |
| 991 } else if (builder.isField && !builder.isFinal) { | 1000 } else if (builder.isField && !builder.isFinal) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 offset ??= offsetForToken(this.token); | 1046 offset ??= offsetForToken(this.token); |
| 1038 return helper.throwNoSuchMethodError(new NullLiteral()..fileOffset = offset, | 1047 return helper.throwNoSuchMethodError(new NullLiteral()..fileOffset = offset, |
| 1039 plainNameForRead, arguments, offset, | 1048 plainNameForRead, arguments, offset, |
| 1040 isGetter: isGetter, isSetter: isSetter); | 1049 isGetter: isGetter, isSetter: isSetter); |
| 1041 } | 1050 } |
| 1042 } | 1051 } |
| 1043 | 1052 |
| 1044 bool isFieldOrGetter(Member member) { | 1053 bool isFieldOrGetter(Member member) { |
| 1045 return member is Field || (member is Procedure && member.isGetter); | 1054 return member is Field || (member is Procedure && member.isGetter); |
| 1046 } | 1055 } |
| OLD | NEW |