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.body_builder; | 5 library fasta.body_builder; |
6 | 6 |
7 import '../fasta_codes.dart' | 7 import '../fasta_codes.dart' |
8 show | 8 show |
9 FastaMessage, | 9 FastaMessage, |
10 codeConstFieldWithoutInitializer, | 10 codeConstFieldWithoutInitializer, |
(...skipping 30 matching lines...) Expand all Loading... |
41 import 'package:kernel/core_types.dart' show CoreTypes; | 41 import 'package:kernel/core_types.dart' show CoreTypes; |
42 | 42 |
43 import 'frontend_accessors.dart' show buildIsNull, makeBinary; | 43 import 'frontend_accessors.dart' show buildIsNull, makeBinary; |
44 | 44 |
45 import '../messages.dart' as messages show getLocationFromUri; | 45 import '../messages.dart' as messages show getLocationFromUri; |
46 | 46 |
47 import '../../scanner/token.dart' show BeginToken, Token; | 47 import '../../scanner/token.dart' show BeginToken, Token; |
48 | 48 |
49 import '../scanner/token.dart' show isBinaryOperator, isMinusOperator; | 49 import '../scanner/token.dart' show isBinaryOperator, isMinusOperator; |
50 | 50 |
51 import '../errors.dart' show InputError, formatUnexpected, internalError; | 51 import '../deprecated_problems.dart' |
| 52 show |
| 53 deprecated_InputError, |
| 54 deprecated_formatUnexpected, |
| 55 deprecated_internalProblem; |
52 | 56 |
53 import '../source/scope_listener.dart' | 57 import '../source/scope_listener.dart' |
54 show JumpTargetKind, NullValue, ScopeListener; | 58 show JumpTargetKind, NullValue, ScopeListener; |
55 | 59 |
56 import '../scope.dart' show ProblemBuilder; | 60 import '../scope.dart' show ProblemBuilder; |
57 | 61 |
58 import 'fasta_accessors.dart'; | 62 import 'fasta_accessors.dart'; |
59 | 63 |
60 import '../quote.dart' | 64 import '../quote.dart' |
61 show | 65 show |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 return value == null ? null : popForValue(); | 222 return value == null ? null : popForValue(); |
219 } | 223 } |
220 | 224 |
221 @override | 225 @override |
222 Expression toValue(Object node) { | 226 Expression toValue(Object node) { |
223 if (node is FastaAccessor) { | 227 if (node is FastaAccessor) { |
224 return node.buildSimpleRead(); | 228 return node.buildSimpleRead(); |
225 } else if (node is Expression) { | 229 } else if (node is Expression) { |
226 return node; | 230 return node; |
227 } else if (node is PrefixBuilder) { | 231 } else if (node is PrefixBuilder) { |
228 return buildCompileTimeError("A library can't be used as an expression."); | 232 return deprecated_buildCompileTimeError( |
| 233 "A library can't be used as an expression."); |
229 } else if (node is ProblemBuilder) { | 234 } else if (node is ProblemBuilder) { |
230 return buildProblemExpression(node, -1); | 235 return buildProblemExpression(node, -1); |
231 } else { | 236 } else { |
232 return internalError("Unhandled: ${node.runtimeType}"); | 237 return deprecated_internalProblem("Unhandled: ${node.runtimeType}"); |
233 } | 238 } |
234 } | 239 } |
235 | 240 |
236 Expression toEffect(Object node) { | 241 Expression toEffect(Object node) { |
237 if (node is FastaAccessor) return node.buildForEffect(); | 242 if (node is FastaAccessor) return node.buildForEffect(); |
238 return toValue(node); | 243 return toValue(node); |
239 } | 244 } |
240 | 245 |
241 List<Expression> popListForValue(int n) { | 246 List<Expression> popListForValue(int n) { |
242 List<Expression> list = | 247 List<Expression> list = |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 push(switchScope ?? NullValue.SwitchScope); | 303 push(switchScope ?? NullValue.SwitchScope); |
299 switchScope = scope; | 304 switchScope = scope; |
300 } | 305 } |
301 | 306 |
302 void exitSwitchScope() { | 307 void exitSwitchScope() { |
303 Scope outerSwitchScope = pop(); | 308 Scope outerSwitchScope = pop(); |
304 if (switchScope.unclaimedForwardDeclarations != null) { | 309 if (switchScope.unclaimedForwardDeclarations != null) { |
305 switchScope.unclaimedForwardDeclarations | 310 switchScope.unclaimedForwardDeclarations |
306 .forEach((String name, Builder builder) { | 311 .forEach((String name, Builder builder) { |
307 if (outerSwitchScope == null) { | 312 if (outerSwitchScope == null) { |
308 addCompileTimeError(-1, "Label not found: '$name'."); | 313 deprecated_addCompileTimeError(-1, "Label not found: '$name'."); |
309 } else { | 314 } else { |
310 outerSwitchScope.forwardDeclareLabel(name, builder); | 315 outerSwitchScope.forwardDeclareLabel(name, builder); |
311 } | 316 } |
312 }); | 317 }); |
313 } | 318 } |
314 switchScope = outerSwitchScope; | 319 switchScope = outerSwitchScope; |
315 } | 320 } |
316 | 321 |
317 void declareVariable(VariableDeclaration variable) { | 322 void declareVariable(VariableDeclaration variable) { |
318 // ignore: UNUSED_LOCAL_VARIABLE | 323 // ignore: UNUSED_LOCAL_VARIABLE |
319 Statement discardedStatement; | 324 Statement discardedStatement; |
320 String name = variable.name; | 325 String name = variable.name; |
321 int offset = variable.fileOffset; | 326 int offset = variable.fileOffset; |
322 if (scope.local[name] != null) { | 327 if (scope.local[name] != null) { |
323 // This reports an error for duplicated declarations in the same scope: | 328 // This reports an error for duplicated declarations in the same scope: |
324 // `{ var x; var x; }` | 329 // `{ var x; var x; }` |
325 discardedStatement = pop(); // TODO(ahe): Issue 29717. | 330 discardedStatement = pop(); // TODO(ahe): Issue 29717. |
326 push(buildCompileTimeErrorStatement( | 331 push(deprecated_buildCompileTimeErrorStatement( |
327 "'$name' already declared in this scope.", offset)); | 332 "'$name' already declared in this scope.", offset)); |
328 return; | 333 return; |
329 } | 334 } |
330 InputError error = scope.declare( | 335 deprecated_InputError error = scope.declare( |
331 variable.name, | 336 variable.name, |
332 new KernelVariableBuilder( | 337 new KernelVariableBuilder( |
333 variable, member ?? classBuilder ?? library, uri), | 338 variable, member ?? classBuilder ?? library, uri), |
334 variable.fileOffset, | 339 variable.fileOffset, |
335 uri); | 340 uri); |
336 if (error != null) { | 341 if (error != null) { |
337 // This case is different from the above error. In this case, the problem | 342 // This case is different from the above error. In this case, the problem |
338 // is using `x` before it's declared: `{ var x; { print(x); var x; | 343 // is using `x` before it's declared: `{ var x; { print(x); var x; |
339 // }}`. In this case, we want two errors, the `x` in `print(x)` and the | 344 // }}`. In this case, we want two errors, the `x` in `print(x)` and the |
340 // second (or innermost declaration) of `x`. | 345 // second (or innermost declaration) of `x`. |
341 discardedStatement = pop(); // TODO(ahe): Issue 29717. | 346 discardedStatement = pop(); // TODO(ahe): Issue 29717. |
342 | 347 |
343 // Reports the error on the last declaration of `x`. | 348 // Reports the error on the last declaration of `x`. |
344 push(buildCompileTimeErrorStatement( | 349 push(deprecated_buildCompileTimeErrorStatement( |
345 "Can't declare '$name' because it was already used in this scope.", | 350 "Can't declare '$name' because it was already used in this scope.", |
346 offset)); | 351 offset)); |
347 | 352 |
348 // Reports the error on `print(x)`. | 353 // Reports the error on `print(x)`. |
349 library.addCompileTimeError(error.charOffset, error.error, | 354 library.deprecated_addCompileTimeError(error.charOffset, error.error, |
350 fileUri: error.uri); | 355 fileUri: error.uri); |
351 } | 356 } |
352 } | 357 } |
353 | 358 |
354 @override | 359 @override |
355 JumpTarget createJumpTarget(JumpTargetKind kind, int charOffset) { | 360 JumpTarget createJumpTarget(JumpTargetKind kind, int charOffset) { |
356 return new JumpTarget(kind, functionNestingLevel, member, charOffset); | 361 return new JumpTarget(kind, functionNestingLevel, member, charOffset); |
357 } | 362 } |
358 | 363 |
359 @override | 364 @override |
(...skipping 26 matching lines...) Expand all Loading... |
386 FastaAccessor accessor = expression; | 391 FastaAccessor accessor = expression; |
387 expression = accessor.buildPropertyAccess( | 392 expression = accessor.buildPropertyAccess( |
388 new IncompletePropertyAccessor( | 393 new IncompletePropertyAccessor( |
389 this, period.next, new Name(name, library.library)), | 394 this, period.next, new Name(name, library.library)), |
390 period.next.offset, | 395 period.next.offset, |
391 false); | 396 false); |
392 } | 397 } |
393 | 398 |
394 bool savedConstantExpressionRequired = pop(); | 399 bool savedConstantExpressionRequired = pop(); |
395 if (expression is! StaticAccessor) { | 400 if (expression is! StaticAccessor) { |
396 push(wrapInCompileTimeError( | 401 push(deprecated_wrapInCompileTimeError( |
397 toValue(expression), | 402 toValue(expression), |
398 "This can't be used as metadata; metadata should be a reference to " | 403 "This can't be used as metadata; metadata should be a reference to " |
399 "a compile-time constant variable, or " | 404 "a compile-time constant variable, or " |
400 "a call to a constant constructor.")); | 405 "a call to a constant constructor.")); |
401 } else { | 406 } else { |
402 push(toValue(expression)); | 407 push(toValue(expression)); |
403 } | 408 } |
404 constantExpressionRequired = savedConstantExpressionRequired; | 409 constantExpressionRequired = savedConstantExpressionRequired; |
405 } | 410 } |
406 } | 411 } |
(...skipping 26 matching lines...) Expand all Loading... |
433 if (classBuilder != null) { | 438 if (classBuilder != null) { |
434 field = classBuilder[name]; | 439 field = classBuilder[name]; |
435 } else { | 440 } else { |
436 field = library[name]; | 441 field = library[name]; |
437 } | 442 } |
438 fields.add(field); | 443 fields.add(field); |
439 if (initializer != null) { | 444 if (initializer != null) { |
440 if (field.next != null) { | 445 if (field.next != null) { |
441 // TODO(ahe): This can happen, for example, if a final field is | 446 // TODO(ahe): This can happen, for example, if a final field is |
442 // combined with a setter. | 447 // combined with a setter. |
443 internalError( | 448 deprecated_internalProblem( |
444 "Unhandled: '${field.name}' has more than one declaration."); | 449 "Unhandled: '${field.name}' has more than one declaration."); |
445 } | 450 } |
446 field.initializer = initializer; | 451 field.initializer = initializer; |
447 _typeInferrer.inferFieldInitializer( | 452 _typeInferrer.inferFieldInitializer( |
448 field.hasImplicitType ? null : field.builtType, initializer); | 453 field.hasImplicitType ? null : field.builtType, initializer); |
449 } | 454 } |
450 } | 455 } |
451 pop(); // Type. | 456 pop(); // Type. |
452 pop(); // Modifiers. | 457 pop(); // Modifiers. |
453 List annotations = pop(); | 458 List annotations = pop(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 push(block); | 490 push(block); |
486 } | 491 } |
487 } | 492 } |
488 | 493 |
489 void prepareInitializers() { | 494 void prepareInitializers() { |
490 ProcedureBuilder member = this.member; | 495 ProcedureBuilder member = this.member; |
491 scope = member.computeFormalParameterInitializerScope(scope); | 496 scope = member.computeFormalParameterInitializerScope(scope); |
492 if (member is KernelConstructorBuilder) { | 497 if (member is KernelConstructorBuilder) { |
493 if (member.isConst && | 498 if (member.isConst && |
494 (classBuilder.cls.superclass?.isMixinApplication ?? false)) { | 499 (classBuilder.cls.superclass?.isMixinApplication ?? false)) { |
495 addCompileTimeError(member.charOffset, | 500 deprecated_addCompileTimeError(member.charOffset, |
496 "Can't extend a mixin application and be 'const'."); | 501 "Can't extend a mixin application and be 'const'."); |
497 } | 502 } |
498 if (member.formals != null) { | 503 if (member.formals != null) { |
499 for (KernelFormalParameterBuilder formal in member.formals) { | 504 for (KernelFormalParameterBuilder formal in member.formals) { |
500 if (formal.hasThis) { | 505 if (formal.hasThis) { |
501 Initializer initializer; | 506 Initializer initializer; |
502 if (member.isExternal) { | 507 if (member.isExternal) { |
503 initializer = buildInvalidInitializer( | 508 initializer = buildInvalidInitializer( |
504 buildCompileTimeError( | 509 deprecated_buildCompileTimeError( |
505 "An external constructor can't initialize fields.", | 510 "An external constructor can't initialize fields.", |
506 formal.charOffset), | 511 formal.charOffset), |
507 formal.charOffset); | 512 formal.charOffset); |
508 } else { | 513 } else { |
509 initializer = buildFieldInitializer(formal.name, | 514 initializer = buildFieldInitializer(formal.name, |
510 formal.charOffset, new VariableGet(formal.declaration)); | 515 formal.charOffset, new VariableGet(formal.declaration)); |
511 } | 516 } |
512 member.addInitializer(initializer); | 517 member.addInitializer(initializer); |
513 } | 518 } |
514 } | 519 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 if (node is Initializer) { | 562 if (node is Initializer) { |
558 initializer = node; | 563 initializer = node; |
559 } else if (node is FastaAccessor) { | 564 } else if (node is FastaAccessor) { |
560 initializer = node.buildFieldInitializer(initializedFields); | 565 initializer = node.buildFieldInitializer(initializedFields); |
561 } else if (node is ConstructorInvocation) { | 566 } else if (node is ConstructorInvocation) { |
562 initializer = | 567 initializer = |
563 buildSuperInitializer(node.target, node.arguments, token.charOffset); | 568 buildSuperInitializer(node.target, node.arguments, token.charOffset); |
564 } else { | 569 } else { |
565 Expression value = toValue(node); | 570 Expression value = toValue(node); |
566 if (node is! Throw) { | 571 if (node is! Throw) { |
567 value = wrapInCompileTimeError(value, "Expected an initializer."); | 572 value = deprecated_wrapInCompileTimeError( |
| 573 value, "Expected an initializer."); |
568 } | 574 } |
569 initializer = buildInvalidInitializer(node, token.charOffset); | 575 initializer = buildInvalidInitializer(node, token.charOffset); |
570 } | 576 } |
571 _typeInferrer.inferInitializer(initializer); | 577 _typeInferrer.inferInitializer(initializer); |
572 if (member is KernelConstructorBuilder && !member.isExternal) { | 578 if (member is KernelConstructorBuilder && !member.isExternal) { |
573 member.addInitializer(initializer); | 579 member.addInitializer(initializer); |
574 } else { | 580 } else { |
575 addCompileTimeError( | 581 deprecated_addCompileTimeError( |
576 token.charOffset, "Can't have initializers: ${member.name}"); | 582 token.charOffset, "Can't have initializers: ${member.name}"); |
577 } | 583 } |
578 } | 584 } |
579 | 585 |
580 DartType _computeReturnTypeContext(MemberBuilder member) { | 586 DartType _computeReturnTypeContext(MemberBuilder member) { |
581 if (member is KernelProcedureBuilder) { | 587 if (member is KernelProcedureBuilder) { |
582 return member.target.function.returnType; | 588 return member.target.function.returnType; |
583 } else { | 589 } else { |
584 assert(member is KernelConstructorBuilder); | 590 assert(member is KernelConstructorBuilder); |
585 return null; | 591 return null; |
(...skipping 26 matching lines...) Expand all Loading... |
612 _typeInferrer.inferParameterInitializer( | 618 _typeInferrer.inferParameterInitializer( |
613 initializer, realParameter.type); | 619 initializer, realParameter.type); |
614 realParameter.initializer = initializer..parent = realParameter; | 620 realParameter.initializer = initializer..parent = realParameter; |
615 } | 621 } |
616 } | 622 } |
617 if (builder is KernelConstructorBuilder) { | 623 if (builder is KernelConstructorBuilder) { |
618 finishConstructor(builder, asyncModifier); | 624 finishConstructor(builder, asyncModifier); |
619 } else if (builder is KernelProcedureBuilder) { | 625 } else if (builder is KernelProcedureBuilder) { |
620 builder.asyncModifier = asyncModifier; | 626 builder.asyncModifier = asyncModifier; |
621 } else { | 627 } else { |
622 internalError("Unhandled: ${builder.runtimeType}"); | 628 deprecated_internalProblem("Unhandled: ${builder.runtimeType}"); |
623 } | 629 } |
624 } | 630 } |
625 | 631 |
626 @override | 632 @override |
627 List<Expression> finishMetadata() { | 633 List<Expression> finishMetadata() { |
628 List<Expression> expressions = pop(); | 634 List<Expression> expressions = pop(); |
629 _typeInferrer.inferMetadata(expressions); | 635 _typeInferrer.inferMetadata(expressions); |
630 return expressions; | 636 return expressions; |
631 } | 637 } |
632 | 638 |
633 void finishConstructor( | 639 void finishConstructor( |
634 KernelConstructorBuilder builder, AsyncMarker asyncModifier) { | 640 KernelConstructorBuilder builder, AsyncMarker asyncModifier) { |
635 /// Quotes below are from [Dart Programming Language Specification, 4th | 641 /// Quotes below are from [Dart Programming Language Specification, 4th |
636 /// Edition]( | 642 /// Edition]( |
637 /// https://ecma-international.org/publications/files/ECMA-ST/ECMA-408.pdf). | 643 /// https://ecma-international.org/publications/files/ECMA-ST/ECMA-408.pdf). |
638 assert(builder == member); | 644 assert(builder == member); |
639 Constructor constructor = builder.constructor; | 645 Constructor constructor = builder.constructor; |
640 if (asyncModifier != AsyncMarker.Sync) { | 646 if (asyncModifier != AsyncMarker.Sync) { |
641 // TODO(ahe): Change this to a null check. | 647 // TODO(ahe): Change this to a null check. |
642 int offset = builder.body?.fileOffset ?? builder.charOffset; | 648 int offset = builder.body?.fileOffset ?? builder.charOffset; |
643 constructor.initializers.add(buildInvalidInitializer( | 649 constructor.initializers.add(buildInvalidInitializer( |
644 buildCompileTimeError( | 650 deprecated_buildCompileTimeError( |
645 "A constructor can't be '${asyncModifier}'.", offset), | 651 "A constructor can't be '${asyncModifier}'.", offset), |
646 offset)); | 652 offset)); |
647 } | 653 } |
648 if (needsImplicitSuperInitializer) { | 654 if (needsImplicitSuperInitializer) { |
649 /// >If no superinitializer is provided, an implicit superinitializer | 655 /// >If no superinitializer is provided, an implicit superinitializer |
650 /// >of the form super() is added at the end of k’s initializer list, | 656 /// >of the form super() is added at the end of k’s initializer list, |
651 /// >unless the enclosing class is class Object. | 657 /// >unless the enclosing class is class Object. |
652 Constructor superTarget = lookupConstructor(emptyName, isSuper: true); | 658 Constructor superTarget = lookupConstructor(emptyName, isSuper: true); |
653 Initializer initializer; | 659 Initializer initializer; |
654 Arguments arguments = new Arguments.empty(); | 660 Arguments arguments = new Arguments.empty(); |
655 if (superTarget == null || | 661 if (superTarget == null || |
656 !checkArguments( | 662 !checkArguments( |
657 superTarget.function, arguments, const <TypeParameter>[])) { | 663 superTarget.function, arguments, const <TypeParameter>[])) { |
658 String superclass = classBuilder.supertype.fullNameForErrors; | 664 String superclass = classBuilder.supertype.fullNameForErrors; |
659 String message = superTarget == null | 665 String message = superTarget == null |
660 ? "'$superclass' doesn't have an unnamed constructor." | 666 ? "'$superclass' doesn't have an unnamed constructor." |
661 : "The unnamed constructor in '$superclass' requires arguments."; | 667 : "The unnamed constructor in '$superclass' requires arguments."; |
662 initializer = buildInvalidInitializer( | 668 initializer = buildInvalidInitializer( |
663 buildCompileTimeError(message, builder.charOffset), | 669 deprecated_buildCompileTimeError(message, builder.charOffset), |
664 builder.charOffset); | 670 builder.charOffset); |
665 } else { | 671 } else { |
666 initializer = | 672 initializer = |
667 buildSuperInitializer(superTarget, arguments, builder.charOffset); | 673 buildSuperInitializer(superTarget, arguments, builder.charOffset); |
668 } | 674 } |
669 constructor.initializers.add(initializer); | 675 constructor.initializers.add(initializer); |
670 } | 676 } |
671 setParents(constructor.initializers, constructor); | 677 setParents(constructor.initializers, constructor); |
672 if (constructor.function.body == null) { | 678 if (constructor.function.body == null) { |
673 /// >If a generative constructor c is not a redirecting constructor | 679 /// >If a generative constructor c is not a redirecting constructor |
(...skipping 18 matching lines...) Expand all Loading... |
692 for (int i = 0; i < arguments.length; i++) { | 698 for (int i = 0; i < arguments.length; i++) { |
693 var node = arguments[i]; | 699 var node = arguments[i]; |
694 if (node is NamedExpression) { | 700 if (node is NamedExpression) { |
695 firstNamedArgumentIndex = | 701 firstNamedArgumentIndex = |
696 i < firstNamedArgumentIndex ? i : firstNamedArgumentIndex; | 702 i < firstNamedArgumentIndex ? i : firstNamedArgumentIndex; |
697 } else { | 703 } else { |
698 arguments[i] = toValue(node); | 704 arguments[i] = toValue(node); |
699 if (i > firstNamedArgumentIndex) { | 705 if (i > firstNamedArgumentIndex) { |
700 arguments[i] = new NamedExpression( | 706 arguments[i] = new NamedExpression( |
701 "#$i", | 707 "#$i", |
702 buildCompileTimeError( | 708 deprecated_buildCompileTimeError( |
703 "Expected named argument.", arguments[i].fileOffset)) | 709 "Expected named argument.", arguments[i].fileOffset)) |
704 ..fileOffset = beginToken.charOffset; | 710 ..fileOffset = beginToken.charOffset; |
705 } | 711 } |
706 } | 712 } |
707 } | 713 } |
708 if (firstNamedArgumentIndex < arguments.length) { | 714 if (firstNamedArgumentIndex < arguments.length) { |
709 List<Expression> positional = new List<Expression>.from( | 715 List<Expression> positional = new List<Expression>.from( |
710 arguments.getRange(0, firstNamedArgumentIndex)); | 716 arguments.getRange(0, firstNamedArgumentIndex)); |
711 List<NamedExpression> named = new List<NamedExpression>.from( | 717 List<NamedExpression> named = new List<NamedExpression>.from( |
712 arguments.getRange(firstNamedArgumentIndex, arguments.length)); | 718 arguments.getRange(firstNamedArgumentIndex, arguments.length)); |
713 if (named.length == 2) { | 719 if (named.length == 2) { |
714 if (named[0].name == named[1].name) { | 720 if (named[0].name == named[1].name) { |
715 named = <NamedExpression>[ | 721 named = <NamedExpression>[ |
716 new NamedExpression( | 722 new NamedExpression( |
717 named[1].name, | 723 named[1].name, |
718 buildCompileTimeError( | 724 deprecated_buildCompileTimeError( |
719 "Duplicated named argument '${named[1].name}'.", | 725 "Duplicated named argument '${named[1].name}'.", |
720 named[1].fileOffset)) | 726 named[1].fileOffset)) |
721 ]; | 727 ]; |
722 } | 728 } |
723 } else if (named.length > 2) { | 729 } else if (named.length > 2) { |
724 Map<String, NamedExpression> seenNames = <String, NamedExpression>{}; | 730 Map<String, NamedExpression> seenNames = <String, NamedExpression>{}; |
725 bool hasProblem = false; | 731 bool hasProblem = false; |
726 for (NamedExpression expression in named) { | 732 for (NamedExpression expression in named) { |
727 if (seenNames.containsKey(expression.name)) { | 733 if (seenNames.containsKey(expression.name)) { |
728 hasProblem = true; | 734 hasProblem = true; |
729 seenNames[expression.name].value = buildCompileTimeError( | 735 seenNames[expression.name].value = deprecated_buildCompileTimeError( |
730 "Duplicated named argument '${expression.name}'.", | 736 "Duplicated named argument '${expression.name}'.", |
731 expression.fileOffset); | 737 expression.fileOffset); |
732 } else { | 738 } else { |
733 seenNames[expression.name] = expression; | 739 seenNames[expression.name] = expression; |
734 } | 740 } |
735 } | 741 } |
736 if (hasProblem) { | 742 if (hasProblem) { |
737 named = new List<NamedExpression>.from(seenNames.values); | 743 named = new List<NamedExpression>.from(seenNames.values); |
738 } | 744 } |
739 } | 745 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 | 858 |
853 Expression buildBinaryOperator( | 859 Expression buildBinaryOperator( |
854 Expression a, Token token, Expression b, bool isSuper) { | 860 Expression a, Token token, Expression b, bool isSuper) { |
855 bool negate = false; | 861 bool negate = false; |
856 String operator = token.stringValue; | 862 String operator = token.stringValue; |
857 if (identical("!=", operator)) { | 863 if (identical("!=", operator)) { |
858 operator = "=="; | 864 operator = "=="; |
859 negate = true; | 865 negate = true; |
860 } | 866 } |
861 if (!isBinaryOperator(operator) && !isMinusOperator(operator)) { | 867 if (!isBinaryOperator(operator) && !isMinusOperator(operator)) { |
862 return buildCompileTimeError( | 868 return deprecated_buildCompileTimeError( |
863 "Not an operator: '$operator'.", token.charOffset); | 869 "Not an operator: '$operator'.", token.charOffset); |
864 } else { | 870 } else { |
865 Expression result = | 871 Expression result = |
866 makeBinary(a, new Name(operator), null, b, offset: token.charOffset); | 872 makeBinary(a, new Name(operator), null, b, offset: token.charOffset); |
867 if (isSuper) { | 873 if (isSuper) { |
868 result = toSuperMethodInvocation(result); | 874 result = toSuperMethodInvocation(result); |
869 } | 875 } |
870 return negate ? new KernelNot(result) : result; | 876 return negate ? new KernelNot(result) : result; |
871 } | 877 } |
872 } | 878 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 } | 911 } |
906 | 912 |
907 @override | 913 @override |
908 Expression toSuperMethodInvocation(MethodInvocation node) { | 914 Expression toSuperMethodInvocation(MethodInvocation node) { |
909 Member target = lookupSuperMember(node.name); | 915 Member target = lookupSuperMember(node.name); |
910 if (target == null || (target is Procedure && !target.isAccessor)) { | 916 if (target == null || (target is Procedure && !target.isAccessor)) { |
911 if (target == null) { | 917 if (target == null) { |
912 warnUnresolvedSuperMethod(node.name, node.fileOffset); | 918 warnUnresolvedSuperMethod(node.name, node.fileOffset); |
913 } else if (!areArgumentsCompatible(target.function, node.arguments)) { | 919 } else if (!areArgumentsCompatible(target.function, node.arguments)) { |
914 target = null; | 920 target = null; |
915 warning( | 921 deprecated_warning( |
916 "Super class doesn't have a method named '${node.name.name}' " | 922 "Super class doesn't have a method named '${node.name.name}' " |
917 "with matching arguments.", | 923 "with matching arguments.", |
918 node.fileOffset); | 924 node.fileOffset); |
919 } | 925 } |
920 Expression result; | 926 Expression result; |
921 if (target != null) { | 927 if (target != null) { |
922 result = new KernelDirectMethodInvocation( | 928 result = new KernelDirectMethodInvocation( |
923 new KernelThisExpression()..fileOffset = node.fileOffset, | 929 new KernelThisExpression()..fileOffset = node.fileOffset, |
924 target, | 930 target, |
925 node.arguments); | 931 node.arguments); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 message = "Getter not found: '$errorName'."; | 967 message = "Getter not found: '$errorName'."; |
962 } else if (isSetter) { | 968 } else if (isSetter) { |
963 message = "Setter not found: '$errorName'."; | 969 message = "Setter not found: '$errorName'."; |
964 } else { | 970 } else { |
965 message = "Method not found: '$errorName'."; | 971 message = "Method not found: '$errorName'."; |
966 } | 972 } |
967 if (constantExpressionRequired) { | 973 if (constantExpressionRequired) { |
968 // TODO(ahe): Use error below instead of building a compile-time error, | 974 // TODO(ahe): Use error below instead of building a compile-time error, |
969 // should be: | 975 // should be: |
970 // return library.loader.throwCompileConstantError(error, charOffset); | 976 // return library.loader.throwCompileConstantError(error, charOffset); |
971 return buildCompileTimeError(message, charOffset); | 977 return deprecated_buildCompileTimeError(message, charOffset); |
972 } else { | 978 } else { |
973 Expression error = library.loader.instantiateNoSuchMethodError( | 979 Expression error = library.loader.instantiateNoSuchMethodError( |
974 receiver, name, arguments, charOffset, | 980 receiver, name, arguments, charOffset, |
975 isMethod: !isGetter && !isSetter, | 981 isMethod: !isGetter && !isSetter, |
976 isGetter: isGetter, | 982 isGetter: isGetter, |
977 isSetter: isSetter, | 983 isSetter: isSetter, |
978 isStatic: isStatic, | 984 isStatic: isStatic, |
979 isTopLevel: !isStatic && !isSuper); | 985 isTopLevel: !isStatic && !isSuper); |
980 warning(message, charOffset); | 986 deprecated_warning(message, charOffset); |
981 return new KernelSyntheticExpression(new Throw(error)); | 987 return new KernelSyntheticExpression(new Throw(error)); |
982 } | 988 } |
983 } | 989 } |
984 | 990 |
985 @override | 991 @override |
986 void warnUnresolvedSuperGet(Name name, int charOffset) { | 992 void warnUnresolvedSuperGet(Name name, int charOffset) { |
987 warning("Super class has no getter named '${name.name}'.", charOffset); | 993 deprecated_warning( |
| 994 "Super class has no getter named '${name.name}'.", charOffset); |
988 } | 995 } |
989 | 996 |
990 @override | 997 @override |
991 void warnUnresolvedSuperSet(Name name, int charOffset) { | 998 void warnUnresolvedSuperSet(Name name, int charOffset) { |
992 warning("Super class has no setter named '${name.name}'.", charOffset); | 999 deprecated_warning( |
| 1000 "Super class has no setter named '${name.name}'.", charOffset); |
993 } | 1001 } |
994 | 1002 |
995 @override | 1003 @override |
996 void warnUnresolvedSuperMethod(Name name, int charOffset) { | 1004 void warnUnresolvedSuperMethod(Name name, int charOffset) { |
997 warning("Super class has no method named '${name.name}'.", charOffset); | 1005 deprecated_warning( |
| 1006 "Super class has no method named '${name.name}'.", charOffset); |
998 } | 1007 } |
999 | 1008 |
1000 @override | 1009 @override |
1001 Member lookupSuperMember(Name name, {bool isSetter: false}) { | 1010 Member lookupSuperMember(Name name, {bool isSetter: false}) { |
1002 Class superclass = classBuilder.cls.superclass; | 1011 Class superclass = classBuilder.cls.superclass; |
1003 return superclass == null | 1012 return superclass == null |
1004 ? null | 1013 ? null |
1005 : hierarchy.getDispatchTarget(superclass, name, setter: isSetter); | 1014 : hierarchy.getDispatchTarget(superclass, name, setter: isSetter); |
1006 } | 1015 } |
1007 | 1016 |
(...skipping 26 matching lines...) Expand all Loading... |
1034 Scope scope = inInitializer ? enclosingScope : this.scope; | 1043 Scope scope = inInitializer ? enclosingScope : this.scope; |
1035 push(scopeLookup(scope, name, token)); | 1044 push(scopeLookup(scope, name, token)); |
1036 return; | 1045 return; |
1037 } else if (context.inDeclaration) { | 1046 } else if (context.inDeclaration) { |
1038 if (context == IdentifierContext.topLevelVariableDeclaration || | 1047 if (context == IdentifierContext.topLevelVariableDeclaration || |
1039 context == IdentifierContext.fieldDeclaration) { | 1048 context == IdentifierContext.fieldDeclaration) { |
1040 constantExpressionRequired = member.isConst; | 1049 constantExpressionRequired = member.isConst; |
1041 } | 1050 } |
1042 } else if (constantExpressionRequired && | 1051 } else if (constantExpressionRequired && |
1043 !context.allowedInConstantExpression) { | 1052 !context.allowedInConstantExpression) { |
1044 addCompileTimeError( | 1053 deprecated_addCompileTimeError( |
1045 token.charOffset, "Not a constant expression: $context"); | 1054 token.charOffset, "Not a constant expression: $context"); |
1046 } | 1055 } |
1047 push(new Identifier(token)); | 1056 push(new Identifier(token)); |
1048 } | 1057 } |
1049 | 1058 |
1050 /// Look up [name] in [scope] using [token] as location information (both to | 1059 /// Look up [name] in [scope] using [token] as location information (both to |
1051 /// report problems and as the file offset in the generated kernel code). | 1060 /// report problems and as the file offset in the generated kernel code). |
1052 /// [isQualified] should be true if [name] is a qualified access | 1061 /// [isQualified] should be true if [name] is a qualified access |
1053 /// (which implies that it shouldn't be turned into a [ThisPropertyAccessor] | 1062 /// (which implies that it shouldn't be turned into a [ThisPropertyAccessor] |
1054 /// if the name doesn't resolve in the scope). | 1063 /// if the name doesn't resolve in the scope). |
1055 @override | 1064 @override |
1056 scopeLookup(Scope scope, String name, Token token, | 1065 scopeLookup(Scope scope, String name, Token token, |
1057 {bool isQualified: false, PrefixBuilder prefix}) { | 1066 {bool isQualified: false, PrefixBuilder prefix}) { |
1058 Builder builder = scope.lookup(name, offsetForToken(token), uri); | 1067 Builder builder = scope.lookup(name, offsetForToken(token), uri); |
1059 if (builder != null && member.isField && builder.isInstanceMember) { | 1068 if (builder != null && member.isField && builder.isInstanceMember) { |
1060 return new IncompleteError(this, token, | 1069 return new deprecated_IncompleteError(this, token, |
1061 "Can't access 'this' in a field initializer to read '$name'."); | 1070 "Can't access 'this' in a field initializer to read '$name'."); |
1062 } | 1071 } |
1063 if (builder == null || (!isInstanceContext && builder.isInstanceMember)) { | 1072 if (builder == null || (!isInstanceContext && builder.isInstanceMember)) { |
1064 Name n = new Name(name, library.library); | 1073 Name n = new Name(name, library.library); |
1065 if (prefix != null && | 1074 if (prefix != null && |
1066 prefix.deferred && | 1075 prefix.deferred && |
1067 builder == null && | 1076 builder == null && |
1068 "loadLibrary" == name) { | 1077 "loadLibrary" == name) { |
1069 int offset = offsetForToken(token); | 1078 int offset = offsetForToken(token); |
1070 const String message = "Deferred loading isn't implemented yet."; | 1079 const String message = "Deferred loading isn't implemented yet."; |
1071 // We report the error twice, the first time silently and marking it as | 1080 // We report the error twice, the first time silently and marking it as |
1072 // unhandled. This ensures that the compile-time error is reported | 1081 // unhandled. This ensures that the compile-time error is reported |
1073 // eagerly by kernel-service, thus preventing any attempts from running | 1082 // eagerly by kernel-service, thus preventing any attempts from running |
1074 // a program that uses deferred loading. Obviously, this is a temporary | 1083 // a program that uses deferred loading. Obviously, this is a temporary |
1075 // solution until we can fully implement deferred loading. | 1084 // solution until we can fully implement deferred loading. |
1076 addCompileTimeError(offset, message, wasHandled: false, silent: true); | 1085 deprecated_addCompileTimeError(offset, message, |
1077 return buildCompileTimeError(message, offset); | 1086 wasHandled: false, silent: true); |
| 1087 return deprecated_buildCompileTimeError(message, offset); |
1078 } else if (!isQualified && isInstanceContext) { | 1088 } else if (!isQualified && isInstanceContext) { |
1079 assert(builder == null); | 1089 assert(builder == null); |
1080 if (constantExpressionRequired || member.isField) { | 1090 if (constantExpressionRequired || member.isField) { |
1081 return new UnresolvedAccessor(this, n, token); | 1091 return new UnresolvedAccessor(this, n, token); |
1082 } | 1092 } |
1083 return new ThisPropertyAccessor(this, token, n, null, null); | 1093 return new ThisPropertyAccessor(this, token, n, null, null); |
1084 } else if (ignoreMainInGetMainClosure && | 1094 } else if (ignoreMainInGetMainClosure && |
1085 name == "main" && | 1095 name == "main" && |
1086 member?.name == "_getMainClosure") { | 1096 member?.name == "_getMainClosure") { |
1087 return new KernelNullLiteral()..fileOffset = offsetForToken(token); | 1097 return new KernelNullLiteral()..fileOffset = offsetForToken(token); |
1088 } else { | 1098 } else { |
1089 return new UnresolvedAccessor(this, n, token); | 1099 return new UnresolvedAccessor(this, n, token); |
1090 } | 1100 } |
1091 } else if (builder.isTypeDeclaration) { | 1101 } else if (builder.isTypeDeclaration) { |
1092 if (constantExpressionRequired && | 1102 if (constantExpressionRequired && |
1093 builder.isTypeVariable && | 1103 builder.isTypeVariable && |
1094 !member.isConstructor) { | 1104 !member.isConstructor) { |
1095 addCompileTimeError( | 1105 deprecated_addCompileTimeError( |
1096 offsetForToken(token), "Not a constant expression."); | 1106 offsetForToken(token), "Not a constant expression."); |
1097 } | 1107 } |
1098 return new TypeDeclarationAccessor(this, builder, name, token); | 1108 return new TypeDeclarationAccessor(this, builder, name, token); |
1099 } else if (builder.isLocal) { | 1109 } else if (builder.isLocal) { |
1100 if (constantExpressionRequired && | 1110 if (constantExpressionRequired && |
1101 !builder.isConst && | 1111 !builder.isConst && |
1102 !member.isConstructor) { | 1112 !member.isConstructor) { |
1103 addCompileTimeError( | 1113 deprecated_addCompileTimeError( |
1104 offsetForToken(token), "Not a constant expression."); | 1114 offsetForToken(token), "Not a constant expression."); |
1105 } | 1115 } |
1106 // An initializing formal parameter might be final without its | 1116 // An initializing formal parameter might be final without its |
1107 // VariableDeclaration being final. See | 1117 // VariableDeclaration being final. See |
1108 // [ProcedureBuilder.computeFormalParameterInitializerScope]. If that | 1118 // [ProcedureBuilder.computeFormalParameterInitializerScope]. If that |
1109 // wasn't the case, we could always use VariableAccessor. | 1119 // wasn't the case, we could always use VariableAccessor. |
1110 if (builder.isFinal) { | 1120 if (builder.isFinal) { |
1111 var fact = | 1121 var fact = |
1112 typePromoter.getFactForAccess(builder.target, functionNestingLevel); | 1122 typePromoter.getFactForAccess(builder.target, functionNestingLevel); |
1113 var scope = typePromoter.currentScope; | 1123 var scope = typePromoter.currentScope; |
1114 return new ReadOnlyAccessor( | 1124 return new ReadOnlyAccessor( |
1115 this, | 1125 this, |
1116 new KernelVariableGet(builder.target, fact, scope) | 1126 new KernelVariableGet(builder.target, fact, scope) |
1117 ..fileOffset = offsetForToken(token), | 1127 ..fileOffset = offsetForToken(token), |
1118 name, | 1128 name, |
1119 token); | 1129 token); |
1120 } else { | 1130 } else { |
1121 return new VariableAccessor(this, token, builder.target); | 1131 return new VariableAccessor(this, token, builder.target); |
1122 } | 1132 } |
1123 } else if (builder.isInstanceMember) { | 1133 } else if (builder.isInstanceMember) { |
1124 if (constantExpressionRequired && | 1134 if (constantExpressionRequired && |
1125 !inInitializer && | 1135 !inInitializer && |
1126 // TODO(ahe): This is a hack because Fasta sets up the scope | 1136 // TODO(ahe): This is a hack because Fasta sets up the scope |
1127 // "this.field" parameters according to old semantics. Under the new | 1137 // "this.field" parameters according to old semantics. Under the new |
1128 // semantics, such parameters introduces a new parameter with that | 1138 // semantics, such parameters introduces a new parameter with that |
1129 // name that should be resolved here. | 1139 // name that should be resolved here. |
1130 !member.isConstructor) { | 1140 !member.isConstructor) { |
1131 addCompileTimeError( | 1141 deprecated_addCompileTimeError( |
1132 offsetForToken(token), "Not a constant expression."); | 1142 offsetForToken(token), "Not a constant expression."); |
1133 } | 1143 } |
1134 return new ThisPropertyAccessor( | 1144 return new ThisPropertyAccessor( |
1135 this, token, new Name(name, library.library), null, null); | 1145 this, token, new Name(name, library.library), null, null); |
1136 } else if (builder.isRegularMethod) { | 1146 } else if (builder.isRegularMethod) { |
1137 assert(builder.isStatic || builder.isTopLevel); | 1147 assert(builder.isStatic || builder.isTopLevel); |
1138 return new StaticAccessor(this, token, builder.target, null); | 1148 return new StaticAccessor(this, token, builder.target, null); |
1139 } else if (builder is PrefixBuilder) { | 1149 } else if (builder is PrefixBuilder) { |
1140 if (constantExpressionRequired && builder.deferred) { | 1150 if (constantExpressionRequired && builder.deferred) { |
1141 addCompileTimeError( | 1151 deprecated_addCompileTimeError( |
1142 offsetForToken(token), | 1152 offsetForToken(token), |
1143 "'$name' can't be used in a constant expression because it's " | 1153 "'$name' can't be used in a constant expression because it's " |
1144 "marked as 'deferred' which means it isn't available until " | 1154 "marked as 'deferred' which means it isn't available until " |
1145 "loaded.\n" | 1155 "loaded.\n" |
1146 "You might try moving the constant to the deferred library, " | 1156 "You might try moving the constant to the deferred library, " |
1147 "or removing 'deferred' from the import."); | 1157 "or removing 'deferred' from the import."); |
1148 } | 1158 } |
1149 return builder; | 1159 return builder; |
1150 } else { | 1160 } else { |
1151 if (builder.hasProblem && builder is! AccessErrorBuilder) return builder; | 1161 if (builder.hasProblem && builder is! deprecated_AccessErrorBuilder) |
| 1162 return builder; |
1152 Builder setter; | 1163 Builder setter; |
1153 if (builder.isSetter) { | 1164 if (builder.isSetter) { |
1154 setter = builder; | 1165 setter = builder; |
1155 } else if (builder.isGetter) { | 1166 } else if (builder.isGetter) { |
1156 setter = scope.lookupSetter(name, offsetForToken(token), uri); | 1167 setter = scope.lookupSetter(name, offsetForToken(token), uri); |
1157 } else if (builder.isField && !builder.isFinal) { | 1168 } else if (builder.isField && !builder.isFinal) { |
1158 setter = builder; | 1169 setter = builder; |
1159 } | 1170 } |
1160 StaticAccessor accessor = | 1171 StaticAccessor accessor = |
1161 new StaticAccessor.fromBuilder(this, builder, token, setter); | 1172 new StaticAccessor.fromBuilder(this, builder, token, setter); |
1162 if (constantExpressionRequired) { | 1173 if (constantExpressionRequired) { |
1163 Member readTarget = accessor.readTarget; | 1174 Member readTarget = accessor.readTarget; |
1164 if (!(readTarget is Field && readTarget.isConst || | 1175 if (!(readTarget is Field && readTarget.isConst || |
1165 // Static tear-offs are also compile time constants. | 1176 // Static tear-offs are also compile time constants. |
1166 readTarget is Procedure)) { | 1177 readTarget is Procedure)) { |
1167 addCompileTimeError( | 1178 deprecated_addCompileTimeError( |
1168 offsetForToken(token), "Not a constant expression."); | 1179 offsetForToken(token), "Not a constant expression."); |
1169 } | 1180 } |
1170 } | 1181 } |
1171 return accessor; | 1182 return accessor; |
1172 } | 1183 } |
1173 } | 1184 } |
1174 | 1185 |
1175 @override | 1186 @override |
1176 void handleQualified(Token period) { | 1187 void handleQualified(Token period) { |
1177 debugEvent("Qualified"); | 1188 debugEvent("Qualified"); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1279 debugEvent("ExpressionFunctionBody"); | 1290 debugEvent("ExpressionFunctionBody"); |
1280 endReturnStatement(true, arrowToken.next, endToken); | 1291 endReturnStatement(true, arrowToken.next, endToken); |
1281 } | 1292 } |
1282 | 1293 |
1283 @override | 1294 @override |
1284 void endReturnStatement( | 1295 void endReturnStatement( |
1285 bool hasExpression, Token beginToken, Token endToken) { | 1296 bool hasExpression, Token beginToken, Token endToken) { |
1286 debugEvent("ReturnStatement"); | 1297 debugEvent("ReturnStatement"); |
1287 Expression expression = hasExpression ? popForValue() : null; | 1298 Expression expression = hasExpression ? popForValue() : null; |
1288 if (expression != null && inConstructor) { | 1299 if (expression != null && inConstructor) { |
1289 push(buildCompileTimeErrorStatement( | 1300 push(deprecated_buildCompileTimeErrorStatement( |
1290 "Can't return from a constructor.", beginToken.charOffset)); | 1301 "Can't return from a constructor.", beginToken.charOffset)); |
1291 } else { | 1302 } else { |
1292 push(new KernelReturnStatement(expression) | 1303 push(new KernelReturnStatement(expression) |
1293 ..fileOffset = beginToken.charOffset); | 1304 ..fileOffset = beginToken.charOffset); |
1294 } | 1305 } |
1295 } | 1306 } |
1296 | 1307 |
1297 @override | 1308 @override |
1298 void beginThenStatement(Token token) { | 1309 void beginThenStatement(Token token) { |
1299 Expression condition = popForValue(); | 1310 Expression condition = popForValue(); |
(...skipping 28 matching lines...) Expand all Loading... |
1328 void handleNoVariableInitializer(Token token) { | 1339 void handleNoVariableInitializer(Token token) { |
1329 debugEvent("NoVariableInitializer"); | 1340 debugEvent("NoVariableInitializer"); |
1330 bool isConst = (currentLocalVariableModifiers & constMask) != 0; | 1341 bool isConst = (currentLocalVariableModifiers & constMask) != 0; |
1331 bool isFinal = (currentLocalVariableModifiers & finalMask) != 0; | 1342 bool isFinal = (currentLocalVariableModifiers & finalMask) != 0; |
1332 Expression initializer; | 1343 Expression initializer; |
1333 if (!optional("in", token)) { | 1344 if (!optional("in", token)) { |
1334 // A for-in loop-variable can't have an initializer. So let's remain | 1345 // A for-in loop-variable can't have an initializer. So let's remain |
1335 // silent if the next token is `in`. Since a for-in loop can only have | 1346 // silent if the next token is `in`. Since a for-in loop can only have |
1336 // one variable it must be followed by `in`. | 1347 // one variable it must be followed by `in`. |
1337 if (isConst) { | 1348 if (isConst) { |
1338 initializer = buildCompileTimeError( | 1349 initializer = deprecated_buildCompileTimeError( |
1339 "A 'const' variable must be initialized.", token.charOffset); | 1350 "A 'const' variable must be initialized.", token.charOffset); |
1340 } else if (isFinal) { | 1351 } else if (isFinal) { |
1341 initializer = buildCompileTimeError( | 1352 initializer = deprecated_buildCompileTimeError( |
1342 "A 'final' variable must be initialized.", token.charOffset); | 1353 "A 'final' variable must be initialized.", token.charOffset); |
1343 } | 1354 } |
1344 } | 1355 } |
1345 pushNewLocalVariable(initializer); | 1356 pushNewLocalVariable(initializer); |
1346 } | 1357 } |
1347 | 1358 |
1348 void pushNewLocalVariable(Expression initializer, {Token equalsToken}) { | 1359 void pushNewLocalVariable(Expression initializer, {Token equalsToken}) { |
1349 Identifier identifier = pop(); | 1360 Identifier identifier = pop(); |
1350 assert(currentLocalVariableModifiers != -1); | 1361 assert(currentLocalVariableModifiers != -1); |
1351 bool isConst = (currentLocalVariableModifiers & constMask) != 0; | 1362 bool isConst = (currentLocalVariableModifiers & constMask) != 0; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1423 exitLocalScope(); | 1434 exitLocalScope(); |
1424 push(block); | 1435 push(block); |
1425 } | 1436 } |
1426 | 1437 |
1427 @override | 1438 @override |
1428 void handleAssignmentExpression(Token token) { | 1439 void handleAssignmentExpression(Token token) { |
1429 debugEvent("AssignmentExpression"); | 1440 debugEvent("AssignmentExpression"); |
1430 Expression value = popForValue(); | 1441 Expression value = popForValue(); |
1431 var accessor = pop(); | 1442 var accessor = pop(); |
1432 if (accessor is! FastaAccessor) { | 1443 if (accessor is! FastaAccessor) { |
1433 push(buildCompileTimeError("Can't assign to this.", token.charOffset)); | 1444 push(deprecated_buildCompileTimeError( |
| 1445 "Can't assign to this.", token.charOffset)); |
1434 } else { | 1446 } else { |
1435 push(new DelayedAssignment( | 1447 push(new DelayedAssignment( |
1436 this, token, accessor, value, token.stringValue)); | 1448 this, token, accessor, value, token.stringValue)); |
1437 } | 1449 } |
1438 } | 1450 } |
1439 | 1451 |
1440 @override | 1452 @override |
1441 void enterLoop(int charOffset) { | 1453 void enterLoop(int charOffset) { |
1442 if (peek() is LabelTarget) { | 1454 if (peek() is LabelTarget) { |
1443 LabelTarget target = peek(); | 1455 LabelTarget target = peek(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1481 variables.add(variableOrExpression); | 1493 variables.add(variableOrExpression); |
1482 } else if (variableOrExpression is List) { | 1494 } else if (variableOrExpression is List) { |
1483 // TODO(sigmund): remove this assignment (see issue #28651) | 1495 // TODO(sigmund): remove this assignment (see issue #28651) |
1484 Iterable vars = variableOrExpression; | 1496 Iterable vars = variableOrExpression; |
1485 variables.addAll(vars); | 1497 variables.addAll(vars); |
1486 } else if (variableOrExpression == null) { | 1498 } else if (variableOrExpression == null) { |
1487 // Do nothing. | 1499 // Do nothing. |
1488 } else if (variableOrExpression is Expression) { | 1500 } else if (variableOrExpression is Expression) { |
1489 begin = new KernelExpressionStatement(variableOrExpression); | 1501 begin = new KernelExpressionStatement(variableOrExpression); |
1490 } else { | 1502 } else { |
1491 return internalError("Unhandled: ${variableOrExpression.runtimeType}"); | 1503 return deprecated_internalProblem( |
| 1504 "Unhandled: ${variableOrExpression.runtimeType}"); |
1492 } | 1505 } |
1493 exitLocalScope(); | 1506 exitLocalScope(); |
1494 JumpTarget continueTarget = exitContinueTarget(); | 1507 JumpTarget continueTarget = exitContinueTarget(); |
1495 JumpTarget breakTarget = exitBreakTarget(); | 1508 JumpTarget breakTarget = exitBreakTarget(); |
1496 if (continueTarget.hasUsers) { | 1509 if (continueTarget.hasUsers) { |
1497 body = new KernelLabeledStatement(body); | 1510 body = new KernelLabeledStatement(body); |
1498 continueTarget.resolveContinues(body); | 1511 continueTarget.resolveContinues(body); |
1499 } | 1512 } |
1500 Statement result = | 1513 Statement result = |
1501 new KernelForStatement(variables, condition, updates, body); | 1514 new KernelForStatement(variables, condition, updates, body); |
(...skipping 24 matching lines...) Expand all Loading... |
1526 void handleLiteralList( | 1539 void handleLiteralList( |
1527 int count, Token beginToken, Token constKeyword, Token endToken) { | 1540 int count, Token beginToken, Token constKeyword, Token endToken) { |
1528 debugEvent("LiteralList"); | 1541 debugEvent("LiteralList"); |
1529 List<Expression> expressions = popListForValue(count); | 1542 List<Expression> expressions = popListForValue(count); |
1530 List<DartType> typeArguments = pop(); | 1543 List<DartType> typeArguments = pop(); |
1531 DartType typeArgument; | 1544 DartType typeArgument; |
1532 if (typeArguments != null) { | 1545 if (typeArguments != null) { |
1533 typeArgument = typeArguments.first; | 1546 typeArgument = typeArguments.first; |
1534 if (typeArguments.length > 1) { | 1547 if (typeArguments.length > 1) { |
1535 typeArgument = null; | 1548 typeArgument = null; |
1536 warningNotError( | 1549 deprecated_warningNotError( |
1537 "Too many type arguments on List literal.", beginToken.charOffset); | 1550 "Too many type arguments on List literal.", beginToken.charOffset); |
1538 } | 1551 } |
1539 } | 1552 } |
1540 push(new KernelListLiteral(expressions, | 1553 push(new KernelListLiteral(expressions, |
1541 typeArgument: typeArgument, isConst: constKeyword != null) | 1554 typeArgument: typeArgument, isConst: constKeyword != null) |
1542 ..fileOffset = offsetForToken(constKeyword ?? beginToken)); | 1555 ..fileOffset = offsetForToken(constKeyword ?? beginToken)); |
1543 } | 1556 } |
1544 | 1557 |
1545 @override | 1558 @override |
1546 void handleLiteralBool(Token token) { | 1559 void handleLiteralBool(Token token) { |
(...skipping 21 matching lines...) Expand all Loading... |
1568 int count, Token beginToken, Token constKeyword, Token endToken) { | 1581 int count, Token beginToken, Token constKeyword, Token endToken) { |
1569 debugEvent("LiteralMap"); | 1582 debugEvent("LiteralMap"); |
1570 List<MapEntry> entries = popList(count) ?? <MapEntry>[]; | 1583 List<MapEntry> entries = popList(count) ?? <MapEntry>[]; |
1571 List<DartType> typeArguments = pop(); | 1584 List<DartType> typeArguments = pop(); |
1572 DartType keyType; | 1585 DartType keyType; |
1573 DartType valueType; | 1586 DartType valueType; |
1574 if (typeArguments != null) { | 1587 if (typeArguments != null) { |
1575 if (typeArguments.length != 2) { | 1588 if (typeArguments.length != 2) { |
1576 keyType = null; | 1589 keyType = null; |
1577 valueType = null; | 1590 valueType = null; |
1578 warningNotError( | 1591 deprecated_warningNotError( |
1579 "Map literal requires two type arguments.", beginToken.charOffset); | 1592 "Map literal requires two type arguments.", beginToken.charOffset); |
1580 } else { | 1593 } else { |
1581 keyType = typeArguments[0]; | 1594 keyType = typeArguments[0]; |
1582 valueType = typeArguments[1]; | 1595 valueType = typeArguments[1]; |
1583 } | 1596 } |
1584 } | 1597 } |
1585 push(new KernelMapLiteral(entries, | 1598 push(new KernelMapLiteral(entries, |
1586 keyType: keyType, valueType: valueType, isConst: constKeyword != null) | 1599 keyType: keyType, valueType: valueType, isConst: constKeyword != null) |
1587 ..fileOffset = constKeyword?.charOffset ?? offsetForToken(beginToken)); | 1600 ..fileOffset = constKeyword?.charOffset ?? offsetForToken(beginToken)); |
1588 } | 1601 } |
1589 | 1602 |
1590 @override | 1603 @override |
1591 void endLiteralMapEntry(Token colon, Token endToken) { | 1604 void endLiteralMapEntry(Token colon, Token endToken) { |
1592 debugEvent("LiteralMapEntry"); | 1605 debugEvent("LiteralMapEntry"); |
1593 Expression value = popForValue(); | 1606 Expression value = popForValue(); |
1594 Expression key = popForValue(); | 1607 Expression key = popForValue(); |
1595 push(new MapEntry(key, value)); | 1608 push(new MapEntry(key, value)); |
1596 } | 1609 } |
1597 | 1610 |
1598 String symbolPartToString(name) { | 1611 String symbolPartToString(name) { |
1599 if (name is Identifier) { | 1612 if (name is Identifier) { |
1600 return name.name; | 1613 return name.name; |
1601 } else if (name is Operator) { | 1614 } else if (name is Operator) { |
1602 return name.name; | 1615 return name.name; |
1603 } else { | 1616 } else { |
1604 return internalError("Unhandled: ${name.runtimeType}"); | 1617 return deprecated_internalProblem("Unhandled: ${name.runtimeType}"); |
1605 } | 1618 } |
1606 } | 1619 } |
1607 | 1620 |
1608 @override | 1621 @override |
1609 void endLiteralSymbol(Token hashToken, int identifierCount) { | 1622 void endLiteralSymbol(Token hashToken, int identifierCount) { |
1610 debugEvent("LiteralSymbol"); | 1623 debugEvent("LiteralSymbol"); |
1611 String value; | 1624 String value; |
1612 if (identifierCount == 1) { | 1625 if (identifierCount == 1) { |
1613 value = symbolPartToString(pop()); | 1626 value = symbolPartToString(pop()); |
1614 } else { | 1627 } else { |
1615 List parts = popList(identifierCount); | 1628 List parts = popList(identifierCount); |
1616 value = symbolPartToString(parts.first); | 1629 value = symbolPartToString(parts.first); |
1617 for (int i = 1; i < parts.length; i++) { | 1630 for (int i = 1; i < parts.length; i++) { |
1618 value += ".${symbolPartToString(parts[i])}"; | 1631 value += ".${symbolPartToString(parts[i])}"; |
1619 } | 1632 } |
1620 } | 1633 } |
1621 push( | 1634 push( |
1622 new KernelSymbolLiteral(value)..fileOffset = offsetForToken(hashToken)); | 1635 new KernelSymbolLiteral(value)..fileOffset = offsetForToken(hashToken)); |
1623 } | 1636 } |
1624 | 1637 |
1625 DartType kernelTypeFromString( | 1638 DartType kernelTypeFromString( |
1626 String name, List<DartType> arguments, int charOffset) { | 1639 String name, List<DartType> arguments, int charOffset) { |
1627 Builder builder = scope.lookup(name, charOffset, uri); | 1640 Builder builder = scope.lookup(name, charOffset, uri); |
1628 if (builder == null) { | 1641 if (builder == null) { |
1629 warning("Type not found: '$name'.", charOffset); | 1642 deprecated_warning("Type not found: '$name'.", charOffset); |
1630 return const InvalidType(); | 1643 return const InvalidType(); |
1631 } else { | 1644 } else { |
1632 return kernelTypeFromBuilder(builder, arguments, charOffset); | 1645 return kernelTypeFromBuilder(builder, arguments, charOffset); |
1633 } | 1646 } |
1634 } | 1647 } |
1635 | 1648 |
1636 DartType kernelTypeFromBuilder( | 1649 DartType kernelTypeFromBuilder( |
1637 Builder builder, List<DartType> arguments, int charOffset) { | 1650 Builder builder, List<DartType> arguments, int charOffset) { |
1638 if (constantExpressionRequired && builder is TypeVariableBuilder) { | 1651 if (constantExpressionRequired && builder is TypeVariableBuilder) { |
1639 addCompileTimeError(charOffset, "Not a constant expression."); | 1652 deprecated_addCompileTimeError(charOffset, "Not a constant expression."); |
1640 } | 1653 } |
1641 if (builder.hasProblem) { | 1654 if (builder.hasProblem) { |
1642 ProblemBuilder problem = builder; | 1655 ProblemBuilder problem = builder; |
1643 addCompileTimeError(charOffset, problem.message); | 1656 deprecated_addCompileTimeError(charOffset, problem.deprecated_message); |
1644 } else { | 1657 } else { |
1645 warningNotError( | 1658 deprecated_warningNotError( |
1646 "Not a type: '${builder.fullNameForErrors}'.", charOffset); | 1659 "Not a type: '${builder.fullNameForErrors}'.", charOffset); |
1647 } | 1660 } |
1648 // TODO(ahe): Create an error somehow. | 1661 // TODO(ahe): Create an error somehow. |
1649 return const InvalidType(); | 1662 return const InvalidType(); |
1650 } | 1663 } |
1651 | 1664 |
1652 @override | 1665 @override |
1653 void handleType(Token beginToken, Token endToken) { | 1666 void handleType(Token beginToken, Token endToken) { |
1654 // TODO(ahe): The scope is wrong for return types of generic functions. | 1667 // TODO(ahe): The scope is wrong for return types of generic functions. |
1655 debugEvent("Type"); | 1668 debugEvent("Type"); |
1656 List<DartType> arguments = pop(); | 1669 List<DartType> arguments = pop(); |
1657 dynamic name = pop(); | 1670 dynamic name = pop(); |
1658 if (name is List) { | 1671 if (name is List) { |
1659 if (name.length != 2) { | 1672 if (name.length != 2) { |
1660 internalError("Unexpected: $name.length"); | 1673 deprecated_internalProblem("Unexpected: $name.length"); |
1661 } | 1674 } |
1662 var prefix = name[0]; | 1675 var prefix = name[0]; |
1663 if (prefix is Identifier) { | 1676 if (prefix is Identifier) { |
1664 prefix = prefix.name; | 1677 prefix = prefix.name; |
1665 } | 1678 } |
1666 var suffix = name[1]; | 1679 var suffix = name[1]; |
1667 if (suffix is Identifier) { | 1680 if (suffix is Identifier) { |
1668 suffix = suffix.name; | 1681 suffix = suffix.name; |
1669 } | 1682 } |
1670 Builder builder; | 1683 Builder builder; |
1671 if (prefix is Builder) { | 1684 if (prefix is Builder) { |
1672 builder = prefix; | 1685 builder = prefix; |
1673 } else { | 1686 } else { |
1674 builder = scope.lookup(prefix, beginToken.charOffset, uri); | 1687 builder = scope.lookup(prefix, beginToken.charOffset, uri); |
1675 } | 1688 } |
1676 if (builder is PrefixBuilder) { | 1689 if (builder is PrefixBuilder) { |
1677 name = scopeLookup(builder.exports, suffix, beginToken, | 1690 name = scopeLookup(builder.exports, suffix, beginToken, |
1678 isQualified: true, prefix: builder); | 1691 isQualified: true, prefix: builder); |
1679 } else { | 1692 } else { |
1680 push(const InvalidType()); | 1693 push(const InvalidType()); |
1681 addCompileTimeError(beginToken.charOffset, | 1694 deprecated_addCompileTimeError(beginToken.charOffset, |
1682 "Can't be used as a type: '${debugName(prefix, suffix)}'."); | 1695 "Can't be used as a type: '${debugName(prefix, suffix)}'."); |
1683 return; | 1696 return; |
1684 } | 1697 } |
1685 } | 1698 } |
1686 if (name is Identifier) { | 1699 if (name is Identifier) { |
1687 name = name.name; | 1700 name = name.name; |
1688 } | 1701 } |
1689 if (name is TypeDeclarationAccessor) { | 1702 if (name is TypeDeclarationAccessor) { |
1690 push(name.buildType(arguments)); | 1703 push(name.buildType(arguments)); |
1691 } else if (name is FastaAccessor) { | 1704 } else if (name is FastaAccessor) { |
1692 warningNotError( | 1705 deprecated_warningNotError( |
1693 "'${beginToken.lexeme}' isn't a type.", beginToken.charOffset); | 1706 "'${beginToken.lexeme}' isn't a type.", beginToken.charOffset); |
1694 push(const InvalidType()); | 1707 push(const InvalidType()); |
1695 } else if (name is TypeBuilder) { | 1708 } else if (name is TypeBuilder) { |
1696 push(name.build(library)); | 1709 push(name.build(library)); |
1697 } else if (name is Builder) { | 1710 } else if (name is Builder) { |
1698 push(kernelTypeFromBuilder(name, arguments, beginToken.charOffset)); | 1711 push(kernelTypeFromBuilder(name, arguments, beginToken.charOffset)); |
1699 } else if (name is String) { | 1712 } else if (name is String) { |
1700 push(kernelTypeFromString(name, arguments, beginToken.charOffset)); | 1713 push(kernelTypeFromString(name, arguments, beginToken.charOffset)); |
1701 } else { | 1714 } else { |
1702 internalError("Unhandled: '${name.runtimeType}'."); | 1715 deprecated_internalProblem("Unhandled: '${name.runtimeType}'."); |
1703 } | 1716 } |
1704 } | 1717 } |
1705 | 1718 |
1706 @override | 1719 @override |
1707 void beginFunctionType(Token beginToken) { | 1720 void beginFunctionType(Token beginToken) { |
1708 debugEvent("beginFunctionType"); | 1721 debugEvent("beginFunctionType"); |
1709 enterFunctionTypeScope(); | 1722 enterFunctionTypeScope(); |
1710 } | 1723 } |
1711 | 1724 |
1712 void enterFunctionTypeScope() { | 1725 void enterFunctionTypeScope() { |
1713 List typeVariables = pop(); | 1726 List typeVariables = pop(); |
1714 enterLocalScope(scope.createNestedScope(isModifiable: false)); | 1727 enterLocalScope(scope.createNestedScope(isModifiable: false)); |
1715 push(typeVariables ?? NullValue.TypeVariables); | 1728 push(typeVariables ?? NullValue.TypeVariables); |
1716 if (typeVariables != null) { | 1729 if (typeVariables != null) { |
1717 ScopeBuilder scopeBuilder = new ScopeBuilder(scope); | 1730 ScopeBuilder scopeBuilder = new ScopeBuilder(scope); |
1718 for (KernelTypeVariableBuilder builder in typeVariables) { | 1731 for (KernelTypeVariableBuilder builder in typeVariables) { |
1719 String name = builder.name; | 1732 String name = builder.name; |
1720 KernelTypeVariableBuilder existing = scopeBuilder[name]; | 1733 KernelTypeVariableBuilder existing = scopeBuilder[name]; |
1721 if (existing == null) { | 1734 if (existing == null) { |
1722 scopeBuilder.addMember(name, builder); | 1735 scopeBuilder.addMember(name, builder); |
1723 } else { | 1736 } else { |
1724 addCompileTimeError( | 1737 deprecated_addCompileTimeError( |
1725 builder.charOffset, "'$name' already declared in this scope."); | 1738 builder.charOffset, "'$name' already declared in this scope."); |
1726 addCompileTimeError( | 1739 deprecated_addCompileTimeError( |
1727 existing.charOffset, "Previous definition of '$name'."); | 1740 existing.charOffset, "Previous definition of '$name'."); |
1728 } | 1741 } |
1729 } | 1742 } |
1730 } | 1743 } |
1731 } | 1744 } |
1732 | 1745 |
1733 @override | 1746 @override |
1734 void endFunctionType(Token functionToken, Token endToken) { | 1747 void endFunctionType(Token functionToken, Token endToken) { |
1735 debugEvent("FunctionType"); | 1748 debugEvent("FunctionType"); |
1736 FormalParameters formals = pop(); | 1749 FormalParameters formals = pop(); |
1737 DartType returnType = pop(); | 1750 DartType returnType = pop(); |
1738 List<TypeParameter> typeVariables = typeVariableBuildersToKernel(pop()); | 1751 List<TypeParameter> typeVariables = typeVariableBuildersToKernel(pop()); |
1739 FunctionType type = formals.toFunctionType(returnType, typeVariables); | 1752 FunctionType type = formals.toFunctionType(returnType, typeVariables); |
1740 exitLocalScope(); | 1753 exitLocalScope(); |
1741 push(type); | 1754 push(type); |
1742 } | 1755 } |
1743 | 1756 |
1744 @override | 1757 @override |
1745 void handleVoidKeyword(Token token) { | 1758 void handleVoidKeyword(Token token) { |
1746 debugEvent("VoidKeyword"); | 1759 debugEvent("VoidKeyword"); |
1747 push(const VoidType()); | 1760 push(const VoidType()); |
1748 } | 1761 } |
1749 | 1762 |
1750 @override | 1763 @override |
1751 void handleAsOperator(Token operator, Token endToken) { | 1764 void handleAsOperator(Token operator, Token endToken) { |
1752 debugEvent("AsOperator"); | 1765 debugEvent("AsOperator"); |
1753 DartType type = pop(); | 1766 DartType type = pop(); |
1754 Expression expression = popForValue(); | 1767 Expression expression = popForValue(); |
1755 if (constantExpressionRequired) { | 1768 if (constantExpressionRequired) { |
1756 push(buildCompileTimeError( | 1769 push(deprecated_buildCompileTimeError( |
1757 "Not a constant expression.", operator.charOffset)); | 1770 "Not a constant expression.", operator.charOffset)); |
1758 } else { | 1771 } else { |
1759 push(new KernelAsExpression(expression, type) | 1772 push(new KernelAsExpression(expression, type) |
1760 ..fileOffset = offsetForToken(operator)); | 1773 ..fileOffset = offsetForToken(operator)); |
1761 } | 1774 } |
1762 } | 1775 } |
1763 | 1776 |
1764 @override | 1777 @override |
1765 void handleIsOperator(Token operator, Token not, Token endToken) { | 1778 void handleIsOperator(Token operator, Token not, Token endToken) { |
1766 debugEvent("IsOperator"); | 1779 debugEvent("IsOperator"); |
1767 DartType type = pop(); | 1780 DartType type = pop(); |
1768 Expression operand = popForValue(); | 1781 Expression operand = popForValue(); |
1769 bool isInverted = not != null; | 1782 bool isInverted = not != null; |
1770 var offset = offsetForToken(operator); | 1783 var offset = offsetForToken(operator); |
1771 Expression isExpression = isInverted | 1784 Expression isExpression = isInverted |
1772 ? new KernelIsNotExpression(operand, type, offset) | 1785 ? new KernelIsNotExpression(operand, type, offset) |
1773 : new KernelIsExpression(operand, type) | 1786 : new KernelIsExpression(operand, type) |
1774 ..fileOffset = offset; | 1787 ..fileOffset = offset; |
1775 if (operand is VariableGet) { | 1788 if (operand is VariableGet) { |
1776 typePromoter.handleIsCheck(isExpression, isInverted, operand.variable, | 1789 typePromoter.handleIsCheck(isExpression, isInverted, operand.variable, |
1777 type, functionNestingLevel); | 1790 type, functionNestingLevel); |
1778 } | 1791 } |
1779 if (constantExpressionRequired) { | 1792 if (constantExpressionRequired) { |
1780 push(buildCompileTimeError( | 1793 push(deprecated_buildCompileTimeError( |
1781 "Not a constant expression.", operator.charOffset)); | 1794 "Not a constant expression.", operator.charOffset)); |
1782 } else { | 1795 } else { |
1783 push(isExpression); | 1796 push(isExpression); |
1784 } | 1797 } |
1785 } | 1798 } |
1786 | 1799 |
1787 @override | 1800 @override |
1788 void handleConditionalExpression(Token question, Token colon) { | 1801 void handleConditionalExpression(Token question, Token colon) { |
1789 debugEvent("ConditionalExpression"); | 1802 debugEvent("ConditionalExpression"); |
1790 Expression elseExpression = popForValue(); | 1803 Expression elseExpression = popForValue(); |
1791 Expression thenExpression = popForValue(); | 1804 Expression thenExpression = popForValue(); |
1792 Expression condition = popForValue(); | 1805 Expression condition = popForValue(); |
1793 push(new KernelConditionalExpression( | 1806 push(new KernelConditionalExpression( |
1794 condition, thenExpression, elseExpression)); | 1807 condition, thenExpression, elseExpression)); |
1795 } | 1808 } |
1796 | 1809 |
1797 @override | 1810 @override |
1798 void endThrowExpression(Token throwToken, Token endToken) { | 1811 void endThrowExpression(Token throwToken, Token endToken) { |
1799 debugEvent("ThrowExpression"); | 1812 debugEvent("ThrowExpression"); |
1800 Expression expression = popForValue(); | 1813 Expression expression = popForValue(); |
1801 if (constantExpressionRequired) { | 1814 if (constantExpressionRequired) { |
1802 push(buildCompileTimeError( | 1815 push(deprecated_buildCompileTimeError( |
1803 "Not a constant expression.", throwToken.charOffset)); | 1816 "Not a constant expression.", throwToken.charOffset)); |
1804 } else { | 1817 } else { |
1805 push( | 1818 push( |
1806 new KernelThrow(expression)..fileOffset = offsetForToken(throwToken)); | 1819 new KernelThrow(expression)..fileOffset = offsetForToken(throwToken)); |
1807 } | 1820 } |
1808 } | 1821 } |
1809 | 1822 |
1810 @override | 1823 @override |
1811 void endFormalParameter(Token thisKeyword, Token nameToken, | 1824 void endFormalParameter(Token thisKeyword, Token nameToken, |
1812 FormalParameterType kind, MemberKind memberKind) { | 1825 FormalParameterType kind, MemberKind memberKind) { |
1813 debugEvent("FormalParameter"); | 1826 debugEvent("FormalParameter"); |
1814 if (thisKeyword != null) { | 1827 if (thisKeyword != null) { |
1815 if (!inConstructor) { | 1828 if (!inConstructor) { |
1816 addCompileTimeError(thisKeyword.charOffset, | 1829 deprecated_addCompileTimeError(thisKeyword.charOffset, |
1817 "'this' parameters can only be used on constructors."); | 1830 "'this' parameters can only be used on constructors."); |
1818 thisKeyword = null; | 1831 thisKeyword = null; |
1819 } | 1832 } |
1820 } | 1833 } |
1821 Identifier name = pop(); | 1834 Identifier name = pop(); |
1822 DartType type = pop(); | 1835 DartType type = pop(); |
1823 int modifiers = Modifier.validate(pop()); | 1836 int modifiers = Modifier.validate(pop()); |
1824 if (inCatchClause) { | 1837 if (inCatchClause) { |
1825 modifiers |= finalMask; | 1838 modifiers |= finalMask; |
1826 } | 1839 } |
1827 bool isConst = (modifiers & constMask) != 0; | 1840 bool isConst = (modifiers & constMask) != 0; |
1828 bool isFinal = (modifiers & finalMask) != 0; | 1841 bool isFinal = (modifiers & finalMask) != 0; |
1829 ignore(Unhandled.Metadata); | 1842 ignore(Unhandled.Metadata); |
1830 VariableDeclaration variable; | 1843 VariableDeclaration variable; |
1831 if (!inCatchClause && | 1844 if (!inCatchClause && |
1832 functionNestingLevel == 0 && | 1845 functionNestingLevel == 0 && |
1833 memberKind != MemberKind.GeneralizedFunctionType) { | 1846 memberKind != MemberKind.GeneralizedFunctionType) { |
1834 ProcedureBuilder member = this.member; | 1847 ProcedureBuilder member = this.member; |
1835 KernelFormalParameterBuilder formal = member.getFormal(name.name); | 1848 KernelFormalParameterBuilder formal = member.getFormal(name.name); |
1836 if (formal == null) { | 1849 if (formal == null) { |
1837 internalError("Internal error: formal missing for '${name.name}'"); | 1850 deprecated_internalProblem( |
| 1851 "Internal error: formal missing for '${name.name}'"); |
1838 } else { | 1852 } else { |
1839 variable = formal.build(library); | 1853 variable = formal.build(library); |
1840 variable.initializer = name.initializer; | 1854 variable.initializer = name.initializer; |
1841 } | 1855 } |
1842 } else { | 1856 } else { |
1843 variable = new KernelVariableDeclaration(name?.name, functionNestingLevel, | 1857 variable = new KernelVariableDeclaration(name?.name, functionNestingLevel, |
1844 type: type, | 1858 type: type, |
1845 initializer: name?.initializer, | 1859 initializer: name?.initializer, |
1846 isFinal: isFinal, | 1860 isFinal: isFinal, |
1847 isConst: isConst); | 1861 isConst: isConst); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1957 exception = catchParameters.required[0]; | 1971 exception = catchParameters.required[0]; |
1958 exception.type = type; | 1972 exception.type = type; |
1959 } | 1973 } |
1960 if (catchParameters.required.length > 1) { | 1974 if (catchParameters.required.length > 1) { |
1961 stackTrace = catchParameters.required[1]; | 1975 stackTrace = catchParameters.required[1]; |
1962 stackTrace.type = coreTypes.stackTraceClass.rawType; | 1976 stackTrace.type = coreTypes.stackTraceClass.rawType; |
1963 } | 1977 } |
1964 if (catchParameters.required.length > 2 || | 1978 if (catchParameters.required.length > 2 || |
1965 catchParameters.optional != null) { | 1979 catchParameters.optional != null) { |
1966 body = new Block(<Statement>[ | 1980 body = new Block(<Statement>[ |
1967 compileTimeErrorInTry ??= buildCompileTimeErrorStatement( | 1981 compileTimeErrorInTry ??= deprecated_buildCompileTimeErrorStatement( |
1968 "Invalid catch arguments.", catchKeyword.next.charOffset) | 1982 "Invalid catch arguments.", catchKeyword.next.charOffset) |
1969 ]); | 1983 ]); |
1970 } | 1984 } |
1971 } | 1985 } |
1972 push(new Catch(exception, body, guard: type, stackTrace: stackTrace)); | 1986 push(new Catch(exception, body, guard: type, stackTrace: stackTrace)); |
1973 } | 1987 } |
1974 | 1988 |
1975 @override | 1989 @override |
1976 void endTryStatement(int catchCount, Token tryKeyword, Token finallyKeyword) { | 1990 void endTryStatement(int catchCount, Token tryKeyword, Token finallyKeyword) { |
1977 Statement finallyBlock = popStatementIfNotNull(finallyKeyword); | 1991 Statement finallyBlock = popStatementIfNotNull(finallyKeyword); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2037 // This *could* be a constant expression, we can't know without | 2051 // This *could* be a constant expression, we can't know without |
2038 // evaluating [receiver]. | 2052 // evaluating [receiver]. |
2039 isConstantExpression: true)); | 2053 isConstantExpression: true)); |
2040 } | 2054 } |
2041 } | 2055 } |
2042 } | 2056 } |
2043 | 2057 |
2044 Name incrementOperator(Token token) { | 2058 Name incrementOperator(Token token) { |
2045 if (optional("++", token)) return plusName; | 2059 if (optional("++", token)) return plusName; |
2046 if (optional("--", token)) return minusName; | 2060 if (optional("--", token)) return minusName; |
2047 return internalError("Unknown increment operator: ${token.lexeme}"); | 2061 return deprecated_internalProblem( |
| 2062 "Unknown increment operator: ${token.lexeme}"); |
2048 } | 2063 } |
2049 | 2064 |
2050 @override | 2065 @override |
2051 void handleUnaryPrefixAssignmentExpression(Token token) { | 2066 void handleUnaryPrefixAssignmentExpression(Token token) { |
2052 debugEvent("UnaryPrefixAssignmentExpression"); | 2067 debugEvent("UnaryPrefixAssignmentExpression"); |
2053 var accessor = pop(); | 2068 var accessor = pop(); |
2054 if (accessor is FastaAccessor) { | 2069 if (accessor is FastaAccessor) { |
2055 push(accessor.buildPrefixIncrement(incrementOperator(token), | 2070 push(accessor.buildPrefixIncrement(incrementOperator(token), |
2056 offset: token.charOffset)); | 2071 offset: token.charOffset)); |
2057 } else { | 2072 } else { |
2058 push(wrapInCompileTimeError(toValue(accessor), "Can't assign to this.")); | 2073 push(deprecated_wrapInCompileTimeError( |
| 2074 toValue(accessor), "Can't assign to this.")); |
2059 } | 2075 } |
2060 } | 2076 } |
2061 | 2077 |
2062 @override | 2078 @override |
2063 void handleUnaryPostfixAssignmentExpression(Token token) { | 2079 void handleUnaryPostfixAssignmentExpression(Token token) { |
2064 debugEvent("UnaryPostfixAssignmentExpression"); | 2080 debugEvent("UnaryPostfixAssignmentExpression"); |
2065 var accessor = pop(); | 2081 var accessor = pop(); |
2066 if (accessor is FastaAccessor) { | 2082 if (accessor is FastaAccessor) { |
2067 push(new DelayedPostfixIncrement( | 2083 push(new DelayedPostfixIncrement( |
2068 this, token, accessor, incrementOperator(token), null)); | 2084 this, token, accessor, incrementOperator(token), null)); |
2069 } else { | 2085 } else { |
2070 push(wrapInCompileTimeError(toValue(accessor), "Can't assign to this.")); | 2086 push(deprecated_wrapInCompileTimeError( |
| 2087 toValue(accessor), "Can't assign to this.")); |
2071 } | 2088 } |
2072 } | 2089 } |
2073 | 2090 |
2074 @override | 2091 @override |
2075 void endConstructorReference( | 2092 void endConstructorReference( |
2076 Token start, Token periodBeforeName, Token endToken) { | 2093 Token start, Token periodBeforeName, Token endToken) { |
2077 debugEvent("ConstructorReference"); | 2094 debugEvent("ConstructorReference"); |
2078 pushQualifiedReference(start, periodBeforeName); | 2095 pushQualifiedReference(start, periodBeforeName); |
2079 } | 2096 } |
2080 | 2097 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2152 if (target is Constructor) { | 2169 if (target is Constructor) { |
2153 assert(!target.enclosingClass.isAbstract); | 2170 assert(!target.enclosingClass.isAbstract); |
2154 typeParameters = target.enclosingClass.typeParameters; | 2171 typeParameters = target.enclosingClass.typeParameters; |
2155 } | 2172 } |
2156 if (!checkArguments(target.function, arguments, typeParameters)) { | 2173 if (!checkArguments(target.function, arguments, typeParameters)) { |
2157 return throwNoSuchMethodError(new NullLiteral()..fileOffset = charOffset, | 2174 return throwNoSuchMethodError(new NullLiteral()..fileOffset = charOffset, |
2158 target.name.name, arguments, charOffset); | 2175 target.name.name, arguments, charOffset); |
2159 } | 2176 } |
2160 if (target is Constructor) { | 2177 if (target is Constructor) { |
2161 if (isConst && !target.isConst) { | 2178 if (isConst && !target.isConst) { |
2162 return buildCompileTimeError("Not a const constructor.", charOffset); | 2179 return deprecated_buildCompileTimeError( |
| 2180 "Not a const constructor.", charOffset); |
2163 } | 2181 } |
2164 return new KernelConstructorInvocation(target, initialTarget, arguments, | 2182 return new KernelConstructorInvocation(target, initialTarget, arguments, |
2165 isConst: isConst) | 2183 isConst: isConst) |
2166 ..fileOffset = charOffset; | 2184 ..fileOffset = charOffset; |
2167 } else { | 2185 } else { |
2168 Procedure procedure = target; | 2186 Procedure procedure = target; |
2169 if (isConst && !procedure.isConst) { | 2187 if (isConst && !procedure.isConst) { |
2170 return buildCompileTimeError("Not a const factory.", charOffset); | 2188 return deprecated_buildCompileTimeError( |
| 2189 "Not a const factory.", charOffset); |
2171 } else if (procedure.isFactory) { | 2190 } else if (procedure.isFactory) { |
2172 return new KernelFactoryConstructorInvocation( | 2191 return new KernelFactoryConstructorInvocation( |
2173 target, initialTarget, arguments, | 2192 target, initialTarget, arguments, |
2174 isConst: isConst) | 2193 isConst: isConst) |
2175 ..fileOffset = charOffset; | 2194 ..fileOffset = charOffset; |
2176 } else { | 2195 } else { |
2177 return new KernelStaticInvocation(target, arguments, isConst: isConst) | 2196 return new KernelStaticInvocation(target, arguments, isConst: isConst) |
2178 ..fileOffset = charOffset; | 2197 ..fileOffset = charOffset; |
2179 } | 2198 } |
2180 } | 2199 } |
(...skipping 30 matching lines...) Expand all Loading... |
2211 } | 2230 } |
2212 | 2231 |
2213 return true; | 2232 return true; |
2214 } | 2233 } |
2215 | 2234 |
2216 @override | 2235 @override |
2217 void beginNewExpression(Token token) { | 2236 void beginNewExpression(Token token) { |
2218 debugEvent("beginNewExpression"); | 2237 debugEvent("beginNewExpression"); |
2219 super.push(constantExpressionRequired); | 2238 super.push(constantExpressionRequired); |
2220 if (constantExpressionRequired) { | 2239 if (constantExpressionRequired) { |
2221 addCompileTimeError(token.charOffset, "Not a constant expression."); | 2240 deprecated_addCompileTimeError( |
| 2241 token.charOffset, "Not a constant expression."); |
2222 } | 2242 } |
2223 constantExpressionRequired = false; | 2243 constantExpressionRequired = false; |
2224 } | 2244 } |
2225 | 2245 |
2226 @override | 2246 @override |
2227 void beginConstExpression(Token token) { | 2247 void beginConstExpression(Token token) { |
2228 debugEvent("beginConstExpression"); | 2248 debugEvent("beginConstExpression"); |
2229 super.push(constantExpressionRequired); | 2249 super.push(constantExpressionRequired); |
2230 constantExpressionRequired = true; | 2250 constantExpressionRequired = true; |
2231 } | 2251 } |
(...skipping 21 matching lines...) Expand all Loading... |
2253 String name = pop(); | 2273 String name = pop(); |
2254 List<DartType> typeArguments = pop(); | 2274 List<DartType> typeArguments = pop(); |
2255 var type = pop(); | 2275 var type = pop(); |
2256 if (type is TypeDeclarationAccessor) { | 2276 if (type is TypeDeclarationAccessor) { |
2257 TypeDeclarationAccessor accessor = type; | 2277 TypeDeclarationAccessor accessor = type; |
2258 type = accessor.declaration; | 2278 type = accessor.declaration; |
2259 } | 2279 } |
2260 bool savedConstantExpressionRequired = pop(); | 2280 bool savedConstantExpressionRequired = pop(); |
2261 () { | 2281 () { |
2262 if (arguments == null) { | 2282 if (arguments == null) { |
2263 push(buildCompileTimeError("No arguments.", nameToken.charOffset)); | 2283 push(deprecated_buildCompileTimeError( |
| 2284 "No arguments.", nameToken.charOffset)); |
2264 return; | 2285 return; |
2265 } | 2286 } |
2266 | 2287 |
2267 if (typeArguments != null) { | 2288 if (typeArguments != null) { |
2268 assert(arguments.types.isEmpty); | 2289 assert(arguments.types.isEmpty); |
2269 KernelArguments.setExplicitArgumentTypes(arguments, typeArguments); | 2290 KernelArguments.setExplicitArgumentTypes(arguments, typeArguments); |
2270 } | 2291 } |
2271 | 2292 |
2272 String errorName; | 2293 String errorName; |
2273 if (type is ClassBuilder) { | 2294 if (type is ClassBuilder) { |
2274 if (type is EnumBuilder) { | 2295 if (type is EnumBuilder) { |
2275 push(buildCompileTimeError( | 2296 push(deprecated_buildCompileTimeError( |
2276 "An enum class can't be instantiated.", nameToken.charOffset)); | 2297 "An enum class can't be instantiated.", nameToken.charOffset)); |
2277 return; | 2298 return; |
2278 } | 2299 } |
2279 Builder b = | 2300 Builder b = |
2280 type.findConstructorOrFactory(name, token.charOffset, uri, library); | 2301 type.findConstructorOrFactory(name, token.charOffset, uri, library); |
2281 Member target; | 2302 Member target; |
2282 Member initialTarget; | 2303 Member initialTarget; |
2283 if (b == null) { | 2304 if (b == null) { |
2284 // Not found. Reported below. | 2305 // Not found. Reported below. |
2285 } else if (b.isConstructor) { | 2306 } else if (b.isConstructor) { |
2286 initialTarget = b.target; | 2307 initialTarget = b.target; |
2287 if (type.isAbstract) { | 2308 if (type.isAbstract) { |
2288 push(new KernelSyntheticExpression(evaluateArgumentsBefore( | 2309 push(new KernelSyntheticExpression(evaluateArgumentsBefore( |
2289 arguments, | 2310 arguments, |
2290 buildAbstractClassInstantiationError( | 2311 buildAbstractClassInstantiationError( |
2291 type.name, nameToken.charOffset)))); | 2312 type.name, nameToken.charOffset)))); |
2292 return; | 2313 return; |
2293 } else { | 2314 } else { |
2294 target = initialTarget; | 2315 target = initialTarget; |
2295 } | 2316 } |
2296 } else if (b.isFactory) { | 2317 } else if (b.isFactory) { |
2297 initialTarget = b.target; | 2318 initialTarget = b.target; |
2298 target = getRedirectionTarget(initialTarget); | 2319 target = getRedirectionTarget(initialTarget); |
2299 if (target == null) { | 2320 if (target == null) { |
2300 push(buildCompileTimeError( | 2321 push(deprecated_buildCompileTimeError( |
2301 "Cyclic definition of factory '${name}'.", | 2322 "Cyclic definition of factory '${name}'.", |
2302 nameToken.charOffset)); | 2323 nameToken.charOffset)); |
2303 return; | 2324 return; |
2304 } | 2325 } |
2305 RedirectingFactoryBody body = getRedirectingFactoryBody(target); | 2326 RedirectingFactoryBody body = getRedirectingFactoryBody(target); |
2306 if (body != null) { | 2327 if (body != null) { |
2307 // If the redirection target is itself a redirecting factory, it | 2328 // If the redirection target is itself a redirecting factory, it |
2308 // means that it is unresolved. So we set target to null so we | 2329 // means that it is unresolved. So we set target to null so we |
2309 // can generate a no-such-method error below. | 2330 // can generate a no-such-method error below. |
2310 assert(body.isUnresolved); | 2331 assert(body.isUnresolved); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2346 debugEvent("TypeArguments"); | 2367 debugEvent("TypeArguments"); |
2347 push(popList(count)); | 2368 push(popList(count)); |
2348 } | 2369 } |
2349 | 2370 |
2350 @override | 2371 @override |
2351 void handleThisExpression(Token token, IdentifierContext context) { | 2372 void handleThisExpression(Token token, IdentifierContext context) { |
2352 debugEvent("ThisExpression"); | 2373 debugEvent("ThisExpression"); |
2353 if (context.isScopeReference && isInstanceContext) { | 2374 if (context.isScopeReference && isInstanceContext) { |
2354 push(new ThisAccessor(this, token, inInitializer)); | 2375 push(new ThisAccessor(this, token, inInitializer)); |
2355 } else { | 2376 } else { |
2356 push(new IncompleteError( | 2377 push(new deprecated_IncompleteError( |
2357 this, token, "Expected identifier, but got 'this'.")); | 2378 this, token, "Expected identifier, but got 'this'.")); |
2358 } | 2379 } |
2359 } | 2380 } |
2360 | 2381 |
2361 @override | 2382 @override |
2362 void handleSuperExpression(Token token, IdentifierContext context) { | 2383 void handleSuperExpression(Token token, IdentifierContext context) { |
2363 debugEvent("SuperExpression"); | 2384 debugEvent("SuperExpression"); |
2364 if (context.isScopeReference && isInstanceContext) { | 2385 if (context.isScopeReference && isInstanceContext) { |
2365 Member member = this.member.target; | 2386 Member member = this.member.target; |
2366 member.transformerFlags |= TransformerFlag.superCalls; | 2387 member.transformerFlags |= TransformerFlag.superCalls; |
2367 push(new ThisAccessor(this, token, inInitializer, isSuper: true)); | 2388 push(new ThisAccessor(this, token, inInitializer, isSuper: true)); |
2368 } else { | 2389 } else { |
2369 push(new IncompleteError( | 2390 push(new deprecated_IncompleteError( |
2370 this, token, "Expected identifier, but got 'super'.")); | 2391 this, token, "Expected identifier, but got 'super'.")); |
2371 } | 2392 } |
2372 } | 2393 } |
2373 | 2394 |
2374 @override | 2395 @override |
2375 void handleNamedArgument(Token colon) { | 2396 void handleNamedArgument(Token colon) { |
2376 debugEvent("NamedArgument"); | 2397 debugEvent("NamedArgument"); |
2377 Expression value = popForValue(); | 2398 Expression value = popForValue(); |
2378 Identifier identifier = pop(); | 2399 Identifier identifier = pop(); |
2379 push(new NamedExpression(identifier.name, value) | 2400 push(new NamedExpression(identifier.name, value) |
2380 ..fileOffset = offsetForToken(identifier.token)); | 2401 ..fileOffset = offsetForToken(identifier.token)); |
2381 } | 2402 } |
2382 | 2403 |
2383 @override | 2404 @override |
2384 void endFunctionName(Token beginToken, Token token) { | 2405 void endFunctionName(Token beginToken, Token token) { |
2385 debugEvent("FunctionName"); | 2406 debugEvent("FunctionName"); |
2386 Identifier name = pop(); | 2407 Identifier name = pop(); |
2387 VariableDeclaration variable = new KernelVariableDeclaration( | 2408 VariableDeclaration variable = new KernelVariableDeclaration( |
2388 name.name, functionNestingLevel, | 2409 name.name, functionNestingLevel, |
2389 isFinal: true, isLocalFunction: true) | 2410 isFinal: true, isLocalFunction: true) |
2390 ..fileOffset = offsetForToken(name.token); | 2411 ..fileOffset = offsetForToken(name.token); |
2391 if (scope.local[variable.name] != null) { | 2412 if (scope.local[variable.name] != null) { |
2392 addCompileTimeError(offsetForToken(name.token), | 2413 deprecated_addCompileTimeError(offsetForToken(name.token), |
2393 "'${variable.name}' already declared in this scope."); | 2414 "'${variable.name}' already declared in this scope."); |
2394 } | 2415 } |
2395 push(new KernelFunctionDeclaration( | 2416 push(new KernelFunctionDeclaration( |
2396 variable, | 2417 variable, |
2397 // The function node is created later. | 2418 // The function node is created later. |
2398 null) | 2419 null) |
2399 ..fileOffset = beginToken.charOffset); | 2420 ..fileOffset = beginToken.charOffset); |
2400 declareVariable(variable); | 2421 declareVariable(variable); |
2401 enterLocalScope(); | 2422 enterLocalScope(); |
2402 } | 2423 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2481 AsyncMarker asyncModifier = pop(); | 2502 AsyncMarker asyncModifier = pop(); |
2482 exitLocalScope(); | 2503 exitLocalScope(); |
2483 FormalParameters formals = pop(); | 2504 FormalParameters formals = pop(); |
2484 exitFunction(); | 2505 exitFunction(); |
2485 List<TypeParameter> typeParameters = typeVariableBuildersToKernel(pop()); | 2506 List<TypeParameter> typeParameters = typeVariableBuildersToKernel(pop()); |
2486 FunctionNode function = formals.addToFunction(new FunctionNode(body, | 2507 FunctionNode function = formals.addToFunction(new FunctionNode(body, |
2487 typeParameters: typeParameters, asyncMarker: asyncModifier) | 2508 typeParameters: typeParameters, asyncMarker: asyncModifier) |
2488 ..fileOffset = beginToken.charOffset | 2509 ..fileOffset = beginToken.charOffset |
2489 ..fileEndOffset = token.charOffset); | 2510 ..fileEndOffset = token.charOffset); |
2490 if (constantExpressionRequired) { | 2511 if (constantExpressionRequired) { |
2491 push(buildCompileTimeError( | 2512 push(deprecated_buildCompileTimeError( |
2492 "Not a constant expression.", formals.charOffset)); | 2513 "Not a constant expression.", formals.charOffset)); |
2493 } else { | 2514 } else { |
2494 push(new KernelFunctionExpression(function) | 2515 push(new KernelFunctionExpression(function) |
2495 ..fileOffset = offsetForToken(beginToken)); | 2516 ..fileOffset = offsetForToken(beginToken)); |
2496 } | 2517 } |
2497 } | 2518 } |
2498 | 2519 |
2499 @override | 2520 @override |
2500 void endDoWhileStatement( | 2521 void endDoWhileStatement( |
2501 Token doKeyword, Token whileKeyword, Token endToken) { | 2522 Token doKeyword, Token whileKeyword, Token endToken) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2542 if (continueTarget.hasUsers) { | 2563 if (continueTarget.hasUsers) { |
2543 body = new KernelLabeledStatement(body); | 2564 body = new KernelLabeledStatement(body); |
2544 continueTarget.resolveContinues(body); | 2565 continueTarget.resolveContinues(body); |
2545 } | 2566 } |
2546 VariableDeclaration variable; | 2567 VariableDeclaration variable; |
2547 bool declaresVariable = false; | 2568 bool declaresVariable = false; |
2548 if (lvalue is VariableDeclaration) { | 2569 if (lvalue is VariableDeclaration) { |
2549 declaresVariable = true; | 2570 declaresVariable = true; |
2550 variable = lvalue; | 2571 variable = lvalue; |
2551 if (variable.isConst) { | 2572 if (variable.isConst) { |
2552 addCompileTimeError( | 2573 deprecated_addCompileTimeError( |
2553 variable.fileOffset, "A for-in loop-variable can't be 'const'."); | 2574 variable.fileOffset, "A for-in loop-variable can't be 'const'."); |
2554 } | 2575 } |
2555 } else if (lvalue is FastaAccessor) { | 2576 } else if (lvalue is FastaAccessor) { |
2556 /// We are in this case, where `lvalue` isn't a [VariableDeclaration]: | 2577 /// We are in this case, where `lvalue` isn't a [VariableDeclaration]: |
2557 /// | 2578 /// |
2558 /// for (lvalue in expression) body | 2579 /// for (lvalue in expression) body |
2559 /// | 2580 /// |
2560 /// This is normalized to: | 2581 /// This is normalized to: |
2561 /// | 2582 /// |
2562 /// for (final #t in expression) { | 2583 /// for (final #t in expression) { |
2563 /// lvalue = #t; | 2584 /// lvalue = #t; |
2564 /// body; | 2585 /// body; |
2565 /// } | 2586 /// } |
2566 variable = new VariableDeclaration.forValue(null); | 2587 variable = new VariableDeclaration.forValue(null); |
2567 body = combineStatements( | 2588 body = combineStatements( |
2568 new KernelSyntheticStatement(new ExpressionStatement(lvalue | 2589 new KernelSyntheticStatement(new ExpressionStatement(lvalue |
2569 .buildAssignment(new VariableGet(variable), voidContext: true))), | 2590 .buildAssignment(new VariableGet(variable), voidContext: true))), |
2570 body); | 2591 body); |
2571 } else { | 2592 } else { |
2572 variable = new VariableDeclaration.forValue(buildCompileTimeError( | 2593 variable = new VariableDeclaration.forValue( |
2573 "Expected lvalue, but got ${lvalue}", forToken.next.next.charOffset)); | 2594 deprecated_buildCompileTimeError("Expected lvalue, but got ${lvalue}", |
| 2595 forToken.next.next.charOffset)); |
2574 } | 2596 } |
2575 Statement result = new KernelForInStatement( | 2597 Statement result = new KernelForInStatement( |
2576 variable, expression, body, declaresVariable, | 2598 variable, expression, body, declaresVariable, |
2577 isAsync: awaitToken != null) | 2599 isAsync: awaitToken != null) |
2578 ..fileOffset = body.fileOffset; | 2600 ..fileOffset = body.fileOffset; |
2579 if (breakTarget.hasUsers) { | 2601 if (breakTarget.hasUsers) { |
2580 result = new KernelLabeledStatement(result); | 2602 result = new KernelLabeledStatement(result); |
2581 breakTarget.resolveBreaks(result); | 2603 breakTarget.resolveBreaks(result); |
2582 } | 2604 } |
2583 exitLoopOrSwitch(result); | 2605 exitLoopOrSwitch(result); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2624 push(statement); | 2646 push(statement); |
2625 } | 2647 } |
2626 | 2648 |
2627 @override | 2649 @override |
2628 void endRethrowStatement(Token rethrowToken, Token endToken) { | 2650 void endRethrowStatement(Token rethrowToken, Token endToken) { |
2629 debugEvent("RethrowStatement"); | 2651 debugEvent("RethrowStatement"); |
2630 if (inCatchBlock) { | 2652 if (inCatchBlock) { |
2631 push(new KernelExpressionStatement( | 2653 push(new KernelExpressionStatement( |
2632 new KernelRethrow()..fileOffset = offsetForToken(rethrowToken))); | 2654 new KernelRethrow()..fileOffset = offsetForToken(rethrowToken))); |
2633 } else { | 2655 } else { |
2634 push(buildCompileTimeErrorStatement( | 2656 push(deprecated_buildCompileTimeErrorStatement( |
2635 "'rethrow' can only be used in catch clauses.", | 2657 "'rethrow' can only be used in catch clauses.", |
2636 rethrowToken.charOffset)); | 2658 rethrowToken.charOffset)); |
2637 } | 2659 } |
2638 } | 2660 } |
2639 | 2661 |
2640 @override | 2662 @override |
2641 void handleFinallyBlock(Token finallyKeyword) { | 2663 void handleFinallyBlock(Token finallyKeyword) { |
2642 debugEvent("FinallyBlock"); | 2664 debugEvent("FinallyBlock"); |
2643 // Do nothing, handled by [endTryStatement]. | 2665 // Do nothing, handled by [endTryStatement]. |
2644 } | 2666 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2686 AssertStatement statement = new KernelAssertStatement(condition, | 2708 AssertStatement statement = new KernelAssertStatement(condition, |
2687 conditionStartOffset: leftParenthesis.offset + 1, | 2709 conditionStartOffset: leftParenthesis.offset + 1, |
2688 conditionEndOffset: rightParenthesis.offset, | 2710 conditionEndOffset: rightParenthesis.offset, |
2689 message: message); | 2711 message: message); |
2690 switch (kind) { | 2712 switch (kind) { |
2691 case Assert.Statement: | 2713 case Assert.Statement: |
2692 push(statement); | 2714 push(statement); |
2693 break; | 2715 break; |
2694 | 2716 |
2695 case Assert.Expression: | 2717 case Assert.Expression: |
2696 push(buildCompileTimeError("`assert` can't be used as an expression.")); | 2718 push(deprecated_buildCompileTimeError( |
| 2719 "`assert` can't be used as an expression.")); |
2697 break; | 2720 break; |
2698 | 2721 |
2699 case Assert.Initializer: | 2722 case Assert.Initializer: |
2700 push(buildAssertInitializer(statement)); | 2723 push(buildAssertInitializer(statement)); |
2701 break; | 2724 break; |
2702 } | 2725 } |
2703 } | 2726 } |
2704 | 2727 |
2705 Initializer buildAssertInitializer(AssertStatement statement) { | 2728 Initializer buildAssertInitializer(AssertStatement statement) { |
2706 // Since kernel only has asserts in statment form, we convert it to an | 2729 // Since kernel only has asserts in statment form, we convert it to an |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2813 target.resolveGotos(current); | 2836 target.resolveGotos(current); |
2814 } | 2837 } |
2815 } | 2838 } |
2816 } | 2839 } |
2817 // Check all but the last case for the following: | 2840 // Check all but the last case for the following: |
2818 // 1. That it isn't a default case (which should be last). | 2841 // 1. That it isn't a default case (which should be last). |
2819 // 2. That it doesn't fall through to the next case. | 2842 // 2. That it doesn't fall through to the next case. |
2820 for (int i = 0; i < caseCount - 1; i++) { | 2843 for (int i = 0; i < caseCount - 1; i++) { |
2821 SwitchCase current = cases[i]; | 2844 SwitchCase current = cases[i]; |
2822 if (current.isDefault) { | 2845 if (current.isDefault) { |
2823 addCompileTimeError(current.fileOffset, | 2846 deprecated_addCompileTimeError(current.fileOffset, |
2824 "'default' switch case should be the last case."); | 2847 "'default' switch case should be the last case."); |
2825 continue; | 2848 continue; |
2826 } | 2849 } |
2827 Block block = current.body; | 2850 Block block = current.body; |
2828 // [block] is a synthetic block that is added to handle variable | 2851 // [block] is a synthetic block that is added to handle variable |
2829 // declarations in the switch case. | 2852 // declarations in the switch case. |
2830 TreeNode lastNode = | 2853 TreeNode lastNode = |
2831 block.statements.isEmpty ? null : block.statements.last; | 2854 block.statements.isEmpty ? null : block.statements.last; |
2832 if (lastNode is Block) { | 2855 if (lastNode is Block) { |
2833 // This is a non-synthetic block. | 2856 // This is a non-synthetic block. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2870 bool hasTarget, Token breakKeyword, Token endToken) { | 2893 bool hasTarget, Token breakKeyword, Token endToken) { |
2871 debugEvent("BreakStatement"); | 2894 debugEvent("BreakStatement"); |
2872 var target = breakTarget; | 2895 var target = breakTarget; |
2873 String name; | 2896 String name; |
2874 if (hasTarget) { | 2897 if (hasTarget) { |
2875 Identifier identifier = pop(); | 2898 Identifier identifier = pop(); |
2876 name = identifier.name; | 2899 name = identifier.name; |
2877 target = scope.lookupLabel(identifier.name); | 2900 target = scope.lookupLabel(identifier.name); |
2878 } | 2901 } |
2879 if (target == null && name == null) { | 2902 if (target == null && name == null) { |
2880 push(compileTimeErrorInLoopOrSwitch = buildCompileTimeErrorStatement( | 2903 push(compileTimeErrorInLoopOrSwitch = |
2881 "No target of break.", breakKeyword.charOffset)); | 2904 deprecated_buildCompileTimeErrorStatement( |
| 2905 "No target of break.", breakKeyword.charOffset)); |
2882 } else if (target == null || | 2906 } else if (target == null || |
2883 target is! JumpTarget || | 2907 target is! JumpTarget || |
2884 !target.isBreakTarget) { | 2908 !target.isBreakTarget) { |
2885 push(compileTimeErrorInLoopOrSwitch = buildCompileTimeErrorStatement( | 2909 push(compileTimeErrorInLoopOrSwitch = |
2886 "Can't break to '$name'.", breakKeyword.next.charOffset)); | 2910 deprecated_buildCompileTimeErrorStatement( |
| 2911 "Can't break to '$name'.", breakKeyword.next.charOffset)); |
2887 } else if (target.functionNestingLevel != functionNestingLevel) { | 2912 } else if (target.functionNestingLevel != functionNestingLevel) { |
2888 push(compileTimeErrorInLoopOrSwitch = buildCompileTimeErrorStatement( | 2913 push(compileTimeErrorInLoopOrSwitch = |
2889 "Can't break to '$name' in a different function.", | 2914 deprecated_buildCompileTimeErrorStatement( |
2890 breakKeyword.next.charOffset)); | 2915 "Can't break to '$name' in a different function.", |
| 2916 breakKeyword.next.charOffset)); |
2891 } else { | 2917 } else { |
2892 BreakStatement statement = new KernelBreakStatement(null) | 2918 BreakStatement statement = new KernelBreakStatement(null) |
2893 ..fileOffset = breakKeyword.charOffset; | 2919 ..fileOffset = breakKeyword.charOffset; |
2894 target.addBreak(statement); | 2920 target.addBreak(statement); |
2895 push(statement); | 2921 push(statement); |
2896 } | 2922 } |
2897 } | 2923 } |
2898 | 2924 |
2899 @override | 2925 @override |
2900 void handleContinueStatement( | 2926 void handleContinueStatement( |
2901 bool hasTarget, Token continueKeyword, Token endToken) { | 2927 bool hasTarget, Token continueKeyword, Token endToken) { |
2902 debugEvent("ContinueStatement"); | 2928 debugEvent("ContinueStatement"); |
2903 var target = continueTarget; | 2929 var target = continueTarget; |
2904 String name; | 2930 String name; |
2905 if (hasTarget) { | 2931 if (hasTarget) { |
2906 Identifier identifier = pop(); | 2932 Identifier identifier = pop(); |
2907 name = identifier.name; | 2933 name = identifier.name; |
2908 target = scope.lookupLabel(identifier.name); | 2934 target = scope.lookupLabel(identifier.name); |
2909 if (target != null && target is! JumpTarget) { | 2935 if (target != null && target is! JumpTarget) { |
2910 push(compileTimeErrorInLoopOrSwitch = buildCompileTimeErrorStatement( | 2936 push(compileTimeErrorInLoopOrSwitch = |
2911 "Target of continue must be a label.", continueKeyword.charOffset)); | 2937 deprecated_buildCompileTimeErrorStatement( |
| 2938 "Target of continue must be a label.", |
| 2939 continueKeyword.charOffset)); |
2912 return; | 2940 return; |
2913 } | 2941 } |
2914 if (target == null) { | 2942 if (target == null) { |
2915 if (switchScope == null) { | 2943 if (switchScope == null) { |
2916 push(buildCompileTimeErrorStatement( | 2944 push(deprecated_buildCompileTimeErrorStatement( |
2917 "Can't find label '$name'.", continueKeyword.next.charOffset)); | 2945 "Can't find label '$name'.", continueKeyword.next.charOffset)); |
2918 return; | 2946 return; |
2919 } | 2947 } |
2920 switchScope.forwardDeclareLabel(identifier.name, | 2948 switchScope.forwardDeclareLabel(identifier.name, |
2921 target = createGotoTarget(offsetForToken(identifier.token))); | 2949 target = createGotoTarget(offsetForToken(identifier.token))); |
2922 } | 2950 } |
2923 if (target.isGotoTarget && | 2951 if (target.isGotoTarget && |
2924 target.functionNestingLevel == functionNestingLevel) { | 2952 target.functionNestingLevel == functionNestingLevel) { |
2925 ContinueSwitchStatement statement = | 2953 ContinueSwitchStatement statement = |
2926 new KernelContinueSwitchStatement(null); | 2954 new KernelContinueSwitchStatement(null); |
2927 target.addGoto(statement); | 2955 target.addGoto(statement); |
2928 push(statement); | 2956 push(statement); |
2929 return; | 2957 return; |
2930 } | 2958 } |
2931 } | 2959 } |
2932 if (target == null) { | 2960 if (target == null) { |
2933 push(compileTimeErrorInLoopOrSwitch = buildCompileTimeErrorStatement( | 2961 push(compileTimeErrorInLoopOrSwitch = |
2934 "No target of continue.", continueKeyword.charOffset)); | 2962 deprecated_buildCompileTimeErrorStatement( |
| 2963 "No target of continue.", continueKeyword.charOffset)); |
2935 } else if (!target.isContinueTarget) { | 2964 } else if (!target.isContinueTarget) { |
2936 push(compileTimeErrorInLoopOrSwitch = buildCompileTimeErrorStatement( | 2965 push(compileTimeErrorInLoopOrSwitch = |
2937 "Can't continue at '$name'.", continueKeyword.next.charOffset)); | 2966 deprecated_buildCompileTimeErrorStatement( |
| 2967 "Can't continue at '$name'.", continueKeyword.next.charOffset)); |
2938 } else if (target.functionNestingLevel != functionNestingLevel) { | 2968 } else if (target.functionNestingLevel != functionNestingLevel) { |
2939 push(compileTimeErrorInLoopOrSwitch = buildCompileTimeErrorStatement( | 2969 push(compileTimeErrorInLoopOrSwitch = |
2940 "Can't continue at '$name' in a different function.", | 2970 deprecated_buildCompileTimeErrorStatement( |
2941 continueKeyword.next.charOffset)); | 2971 "Can't continue at '$name' in a different function.", |
| 2972 continueKeyword.next.charOffset)); |
2942 } else { | 2973 } else { |
2943 BreakStatement statement = new KernelBreakStatement(null) | 2974 BreakStatement statement = new KernelBreakStatement(null) |
2944 ..fileOffset = continueKeyword.charOffset; | 2975 ..fileOffset = continueKeyword.charOffset; |
2945 target.addContinue(statement); | 2976 target.addContinue(statement); |
2946 push(statement); | 2977 push(statement); |
2947 } | 2978 } |
2948 } | 2979 } |
2949 | 2980 |
2950 @override | 2981 @override |
2951 void endTypeVariable(Token token, Token extendsOrSuper) { | 2982 void endTypeVariable(Token token, Token extendsOrSuper) { |
2952 debugEvent("TypeVariable"); | 2983 debugEvent("TypeVariable"); |
2953 DartType bound = pop(); | 2984 DartType bound = pop(); |
2954 if (bound != null) { | 2985 if (bound != null) { |
2955 // TODO(ahe): To handle F-bounded types, this needs to be a TypeBuilder. | 2986 // TODO(ahe): To handle F-bounded types, this needs to be a TypeBuilder. |
2956 warningNotError("Type variable bounds not implemented yet.", | 2987 deprecated_warningNotError("Type variable bounds not implemented yet.", |
2957 offsetForToken(extendsOrSuper.next)); | 2988 offsetForToken(extendsOrSuper.next)); |
2958 } | 2989 } |
2959 Identifier name = pop(); | 2990 Identifier name = pop(); |
2960 // TODO(ahe): Do not discard metadata. | 2991 // TODO(ahe): Do not discard metadata. |
2961 pop(); // Metadata. | 2992 pop(); // Metadata. |
2962 push(new KernelTypeVariableBuilder( | 2993 push(new KernelTypeVariableBuilder( |
2963 name.name, library, offsetForToken(name.token), null) | 2994 name.name, library, offsetForToken(name.token), null) |
2964 ..finish(library, library.loader.coreLibrary["Object"])); | 2995 ..finish(library, library.loader.coreLibrary["Object"])); |
2965 } | 2996 } |
2966 | 2997 |
(...skipping 27 matching lines...) Expand all Loading... |
2994 debugEvent("Modifiers"); | 3025 debugEvent("Modifiers"); |
2995 // TODO(ahe): Copied from outline_builder.dart. | 3026 // TODO(ahe): Copied from outline_builder.dart. |
2996 push(popList(count) ?? NullValue.Modifiers); | 3027 push(popList(count) ?? NullValue.Modifiers); |
2997 } | 3028 } |
2998 | 3029 |
2999 @override | 3030 @override |
3000 void handleRecoverableError(Token token, FastaMessage message) { | 3031 void handleRecoverableError(Token token, FastaMessage message) { |
3001 bool silent = hasParserError || | 3032 bool silent = hasParserError || |
3002 message.code == codeFinalFieldWithoutInitializer || | 3033 message.code == codeFinalFieldWithoutInitializer || |
3003 message.code == codeConstFieldWithoutInitializer; | 3034 message.code == codeConstFieldWithoutInitializer; |
3004 addCompileTimeError(message.charOffset, message.message, silent: silent); | 3035 deprecated_addCompileTimeError(message.charOffset, message.message, |
| 3036 silent: silent); |
3005 } | 3037 } |
3006 | 3038 |
3007 @override | 3039 @override |
3008 Token handleUnrecoverableError(Token token, FastaMessage message) { | 3040 Token handleUnrecoverableError(Token token, FastaMessage message) { |
3009 if (enableNative && message.code == codeExpectedFunctionBody) { | 3041 if (enableNative && message.code == codeExpectedFunctionBody) { |
3010 Token recover = skipNativeClause(token, stringExpectedAfterNative); | 3042 Token recover = skipNativeClause(token, stringExpectedAfterNative); |
3011 if (recover != null) return recover; | 3043 if (recover != null) return recover; |
3012 } else if (message.code == codeExpectedButGot) { | 3044 } else if (message.code == codeExpectedButGot) { |
3013 String expected = message.arguments["string"]; | 3045 String expected = message.arguments["string"]; |
3014 const List<String> trailing = const <String>[")", "}", ";", ","]; | 3046 const List<String> trailing = const <String>[")", "}", ";", ","]; |
3015 if (trailing.contains(token.stringValue) && trailing.contains(expected)) { | 3047 if (trailing.contains(token.stringValue) && trailing.contains(expected)) { |
3016 handleRecoverableError(token, message); | 3048 handleRecoverableError(token, message); |
3017 return newSyntheticToken(token); | 3049 return newSyntheticToken(token); |
3018 } | 3050 } |
3019 } | 3051 } |
3020 return super.handleUnrecoverableError(token, message); | 3052 return super.handleUnrecoverableError(token, message); |
3021 } | 3053 } |
3022 | 3054 |
3023 @override | 3055 @override |
3024 Expression buildCompileTimeError(error, [int charOffset = -1]) { | 3056 Expression deprecated_buildCompileTimeError(error, [int charOffset = -1]) { |
3025 // TODO(ahe): This method should be passed the erroneous expression, wrap | 3057 // TODO(ahe): This method should be passed the erroneous expression, wrap |
3026 // it in a class (TBD) from which the erroneous expression can be easily | 3058 // it in a class (TBD) from which the erroneous expression can be easily |
3027 // extracted. Similar for statements and initializers. See also [issue | 3059 // extracted. Similar for statements and initializers. See also [issue |
3028 // 29717](https://github.com/dart-lang/sdk/issues/29717) | 3060 // 29717](https://github.com/dart-lang/sdk/issues/29717) |
3029 addCompileTimeError(charOffset, error, wasHandled: true); | 3061 deprecated_addCompileTimeError(charOffset, error, wasHandled: true); |
3030 return new KernelSyntheticExpression(library.loader | 3062 return new KernelSyntheticExpression(library.loader |
3031 .throwCompileConstantError(library.loader.buildCompileTimeError( | 3063 .throwCompileConstantError(library.loader |
3032 formatUnexpected(uri, charOffset, error), charOffset))); | 3064 .deprecated_buildCompileTimeError( |
| 3065 deprecated_formatUnexpected(uri, charOffset, error), |
| 3066 charOffset))); |
3033 } | 3067 } |
3034 | 3068 |
3035 Expression wrapInCompileTimeError(Expression expression, String message) { | 3069 Expression deprecated_wrapInCompileTimeError( |
| 3070 Expression expression, String message) { |
3036 return new Let( | 3071 return new Let( |
3037 new VariableDeclaration.forValue(expression) | 3072 new VariableDeclaration.forValue(expression) |
3038 ..fileOffset = expression.fileOffset, | 3073 ..fileOffset = expression.fileOffset, |
3039 buildCompileTimeError(message, expression.fileOffset)) | 3074 deprecated_buildCompileTimeError(message, expression.fileOffset)) |
3040 ..fileOffset = expression.fileOffset; | 3075 ..fileOffset = expression.fileOffset; |
3041 } | 3076 } |
3042 | 3077 |
3043 Expression buildFallThroughError(int charOffset) { | 3078 Expression buildFallThroughError(int charOffset) { |
3044 warningNotError("Switch case may fall through to next case.", charOffset); | 3079 deprecated_warningNotError( |
| 3080 "Switch case may fall through to next case.", charOffset); |
3045 | 3081 |
3046 Location location = messages.getLocationFromUri(uri, charOffset); | 3082 Location location = messages.getLocationFromUri(uri, charOffset); |
3047 | 3083 |
3048 return new Throw(buildStaticInvocation( | 3084 return new Throw(buildStaticInvocation( |
3049 library.loader.coreTypes.fallThroughErrorUrlAndLineConstructor, | 3085 library.loader.coreTypes.fallThroughErrorUrlAndLineConstructor, |
3050 new Arguments(<Expression>[ | 3086 new Arguments(<Expression>[ |
3051 new StringLiteral(location?.file ?? uri.toString()), | 3087 new StringLiteral(location?.file ?? uri.toString()), |
3052 new IntLiteral(location?.line ?? 0) | 3088 new IntLiteral(location?.line ?? 0) |
3053 ]), | 3089 ]), |
3054 charOffset: charOffset)); | 3090 charOffset: charOffset)); |
3055 } | 3091 } |
3056 | 3092 |
3057 Expression buildAbstractClassInstantiationError(String className, | 3093 Expression buildAbstractClassInstantiationError(String className, |
3058 [int charOffset = -1]) { | 3094 [int charOffset = -1]) { |
3059 warning("The class '$className' is abstract and can't be instantiated.", | 3095 deprecated_warning( |
| 3096 "The class '$className' is abstract and can't be instantiated.", |
3060 charOffset); | 3097 charOffset); |
3061 Builder constructor = library.loader.getAbstractClassInstantiationError(); | 3098 Builder constructor = library.loader.getAbstractClassInstantiationError(); |
3062 return new Throw(buildStaticInvocation(constructor.target, | 3099 return new Throw(buildStaticInvocation(constructor.target, |
3063 new KernelArguments(<Expression>[new StringLiteral(className)]))); | 3100 new KernelArguments(<Expression>[new StringLiteral(className)]))); |
3064 } | 3101 } |
3065 | 3102 |
3066 Statement buildCompileTimeErrorStatement(error, [int charOffset = -1]) { | 3103 Statement deprecated_buildCompileTimeErrorStatement(error, |
| 3104 [int charOffset = -1]) { |
3067 return new KernelExpressionStatement( | 3105 return new KernelExpressionStatement( |
3068 buildCompileTimeError(error, charOffset)); | 3106 deprecated_buildCompileTimeError(error, charOffset)); |
3069 } | 3107 } |
3070 | 3108 |
3071 @override | 3109 @override |
3072 Initializer buildInvalidInitializer(Expression expression, | 3110 Initializer buildInvalidInitializer(Expression expression, |
3073 [int charOffset = -1]) { | 3111 [int charOffset = -1]) { |
3074 needsImplicitSuperInitializer = false; | 3112 needsImplicitSuperInitializer = false; |
3075 return new LocalInitializer(new VariableDeclaration.forValue(expression)) | 3113 return new LocalInitializer(new VariableDeclaration.forValue(expression)) |
3076 ..fileOffset = charOffset; | 3114 ..fileOffset = charOffset; |
3077 } | 3115 } |
3078 | 3116 |
3079 Initializer buildDuplicatedInitializer( | 3117 Initializer buildDuplicatedInitializer( |
3080 String name, int offset, int previousInitializerOffset) { | 3118 String name, int offset, int previousInitializerOffset) { |
3081 Initializer initializer = buildInvalidInitializer( | 3119 Initializer initializer = buildInvalidInitializer( |
3082 buildCompileTimeError("'$name' has already been initialized.", offset), | 3120 deprecated_buildCompileTimeError( |
| 3121 "'$name' has already been initialized.", offset), |
3083 offset); | 3122 offset); |
3084 addCompileTimeError( | 3123 deprecated_addCompileTimeError( |
3085 initializedFields[name], "'$name' was initialized here."); | 3124 initializedFields[name], "'$name' was initialized here."); |
3086 return initializer; | 3125 return initializer; |
3087 } | 3126 } |
3088 | 3127 |
3089 @override | 3128 @override |
3090 Initializer buildFieldInitializer( | 3129 Initializer buildFieldInitializer( |
3091 String name, int offset, Expression expression) { | 3130 String name, int offset, Expression expression) { |
3092 Builder builder = classBuilder.scope.local[name]; | 3131 Builder builder = classBuilder.scope.local[name]; |
3093 if (builder is KernelFieldBuilder && builder.isInstanceMember) { | 3132 if (builder is KernelFieldBuilder && builder.isInstanceMember) { |
3094 initializedFields ??= <String, int>{}; | 3133 initializedFields ??= <String, int>{}; |
3095 if (initializedFields.containsKey(name)) { | 3134 if (initializedFields.containsKey(name)) { |
3096 return buildDuplicatedInitializer( | 3135 return buildDuplicatedInitializer( |
3097 name, offset, initializedFields[name]); | 3136 name, offset, initializedFields[name]); |
3098 } | 3137 } |
3099 initializedFields[name] = offset; | 3138 initializedFields[name] = offset; |
3100 if (builder.isFinal && builder.hasInitializer) { | 3139 if (builder.isFinal && builder.hasInitializer) { |
3101 // TODO(ahe): If CL 2843733002 is landed, this becomes a compile-time | 3140 // TODO(ahe): If CL 2843733002 is landed, this becomes a compile-time |
3102 // error. Also, this is a compile-time error in strong mode. | 3141 // error. Also, this is a compile-time error in strong mode. |
3103 warningNotError( | 3142 deprecated_warningNotError( |
3104 "'$name' is final instance variable that has already been " | 3143 "'$name' is final instance variable that has already been " |
3105 "initialized.", | 3144 "initialized.", |
3106 offset); | 3145 offset); |
3107 warningNotError("'$name' was initialized here.", builder.charOffset); | 3146 deprecated_warningNotError( |
| 3147 "'$name' was initialized here.", builder.charOffset); |
3108 Builder constructor = | 3148 Builder constructor = |
3109 library.loader.getDuplicatedFieldInitializerError(); | 3149 library.loader.getDuplicatedFieldInitializerError(); |
3110 return buildInvalidInitializer( | 3150 return buildInvalidInitializer( |
3111 new Throw(buildStaticInvocation(constructor.target, | 3151 new Throw(buildStaticInvocation(constructor.target, |
3112 new Arguments(<Expression>[new StringLiteral(name)]), | 3152 new Arguments(<Expression>[new StringLiteral(name)]), |
3113 charOffset: offset)), | 3153 charOffset: offset)), |
3114 offset); | 3154 offset); |
3115 } else { | 3155 } else { |
3116 return new FieldInitializer(builder.field, expression) | 3156 return new FieldInitializer(builder.field, expression) |
3117 ..fileOffset = offset; | 3157 ..fileOffset = offset; |
3118 } | 3158 } |
3119 } else { | 3159 } else { |
3120 return buildInvalidInitializer( | 3160 return buildInvalidInitializer( |
3121 buildCompileTimeError( | 3161 deprecated_buildCompileTimeError( |
3122 "'$name' isn't an instance field of this class.", offset), | 3162 "'$name' isn't an instance field of this class.", offset), |
3123 offset); | 3163 offset); |
3124 } | 3164 } |
3125 } | 3165 } |
3126 | 3166 |
3127 @override | 3167 @override |
3128 Initializer buildSuperInitializer( | 3168 Initializer buildSuperInitializer( |
3129 Constructor constructor, Arguments arguments, | 3169 Constructor constructor, Arguments arguments, |
3130 [int charOffset = -1]) { | 3170 [int charOffset = -1]) { |
3131 if (member.isConst && !constructor.isConst) { | 3171 if (member.isConst && !constructor.isConst) { |
3132 return buildInvalidInitializer( | 3172 return buildInvalidInitializer( |
3133 buildCompileTimeError("Super constructor isn't const.", charOffset), | 3173 deprecated_buildCompileTimeError( |
| 3174 "Super constructor isn't const.", charOffset), |
3134 charOffset); | 3175 charOffset); |
3135 } | 3176 } |
3136 needsImplicitSuperInitializer = false; | 3177 needsImplicitSuperInitializer = false; |
3137 return new SuperInitializer(constructor, arguments) | 3178 return new SuperInitializer(constructor, arguments) |
3138 ..fileOffset = charOffset; | 3179 ..fileOffset = charOffset; |
3139 } | 3180 } |
3140 | 3181 |
3141 @override | 3182 @override |
3142 Initializer buildRedirectingInitializer( | 3183 Initializer buildRedirectingInitializer( |
3143 Constructor constructor, Arguments arguments, | 3184 Constructor constructor, Arguments arguments, |
3144 [int charOffset = -1]) { | 3185 [int charOffset = -1]) { |
3145 needsImplicitSuperInitializer = false; | 3186 needsImplicitSuperInitializer = false; |
3146 return new KernelRedirectingInitializer(constructor, arguments) | 3187 return new KernelRedirectingInitializer(constructor, arguments) |
3147 ..fileOffset = charOffset; | 3188 ..fileOffset = charOffset; |
3148 } | 3189 } |
3149 | 3190 |
3150 @override | 3191 @override |
3151 Expression buildProblemExpression(ProblemBuilder builder, int charOffset) { | 3192 Expression buildProblemExpression(ProblemBuilder builder, int charOffset) { |
3152 return buildCompileTimeError(builder.message, charOffset); | 3193 return deprecated_buildCompileTimeError( |
| 3194 builder.deprecated_message, charOffset); |
3153 } | 3195 } |
3154 | 3196 |
3155 @override | 3197 @override |
3156 void handleOperator(Token token) { | 3198 void handleOperator(Token token) { |
3157 debugEvent("Operator"); | 3199 debugEvent("Operator"); |
3158 push(new Operator(token.stringValue, token.charOffset)); | 3200 push(new Operator(token.stringValue, token.charOffset)); |
3159 } | 3201 } |
3160 | 3202 |
3161 @override | 3203 @override |
3162 void handleSymbolVoid(Token token) { | 3204 void handleSymbolVoid(Token token) { |
3163 debugEvent("SymbolVoid"); | 3205 debugEvent("SymbolVoid"); |
3164 push(new Identifier(token)); | 3206 push(new Identifier(token)); |
3165 } | 3207 } |
3166 | 3208 |
3167 @override | 3209 @override |
3168 dynamic addCompileTimeError(int charOffset, String message, | 3210 dynamic deprecated_addCompileTimeError(int charOffset, String message, |
3169 {bool silent: false, bool wasHandled: false}) { | 3211 {bool silent: false, bool wasHandled: false}) { |
3170 // TODO(ahe): If constantExpressionRequired is set, set it to false to | 3212 // TODO(ahe): If constantExpressionRequired is set, set it to false to |
3171 // avoid a long list of errors. | 3213 // avoid a long list of errors. |
3172 return library.addCompileTimeError(charOffset, message, | 3214 return library.deprecated_addCompileTimeError(charOffset, message, |
3173 fileUri: uri, silent: silent, wasHandled: wasHandled); | 3215 fileUri: uri, silent: silent, wasHandled: wasHandled); |
3174 } | 3216 } |
3175 | 3217 |
3176 @override | 3218 @override |
3177 void handleInvalidFunctionBody(Token token) { | 3219 void handleInvalidFunctionBody(Token token) { |
3178 if (member.isNative) { | 3220 if (member.isNative) { |
3179 push(NullValue.FunctionBody); | 3221 push(NullValue.FunctionBody); |
3180 } else { | 3222 } else { |
3181 push(new Block(<Statement>[ | 3223 push(new Block(<Statement>[ |
3182 buildCompileTimeErrorStatement("Expected '{'.", token.charOffset) | 3224 deprecated_buildCompileTimeErrorStatement( |
| 3225 "Expected '{'.", token.charOffset) |
3183 ])); | 3226 ])); |
3184 } | 3227 } |
3185 } | 3228 } |
3186 | 3229 |
3187 @override | 3230 @override |
3188 void warning(String message, [int charOffset = -1]) { | 3231 void deprecated_warning(String message, [int charOffset = -1]) { |
3189 if (constantExpressionRequired) { | 3232 if (constantExpressionRequired) { |
3190 addCompileTimeError(charOffset, message); | 3233 deprecated_addCompileTimeError(charOffset, message); |
3191 } else { | 3234 } else { |
3192 super.warning(message, charOffset); | 3235 super.deprecated_warning(message, charOffset); |
3193 } | 3236 } |
3194 } | 3237 } |
3195 | 3238 |
3196 void warningNotError(String message, [int charOffset = -1]) { | 3239 void deprecated_warningNotError(String message, [int charOffset = -1]) { |
3197 super.warning(message, charOffset); | 3240 super.deprecated_warning(message, charOffset); |
3198 } | 3241 } |
3199 | 3242 |
3200 @override | 3243 @override |
3201 DartType validatedTypeVariableUse( | 3244 DartType validatedTypeVariableUse( |
3202 TypeParameterType type, int offset, bool nonInstanceAccessIsError) { | 3245 TypeParameterType type, int offset, bool nonInstanceAccessIsError) { |
3203 if (!isInstanceContext && type.parameter.parent is Class) { | 3246 if (!isInstanceContext && type.parameter.parent is Class) { |
3204 String message = "Type variables can't be used in static members."; | 3247 String message = "Type variables can't be used in static members."; |
3205 if (nonInstanceAccessIsError) { | 3248 if (nonInstanceAccessIsError) { |
3206 addCompileTimeError(offset, message); | 3249 deprecated_addCompileTimeError(offset, message); |
3207 } else { | 3250 } else { |
3208 warning(message, offset); | 3251 deprecated_warning(message, offset); |
3209 } | 3252 } |
3210 return const InvalidType(); | 3253 return const InvalidType(); |
3211 } else if (constantExpressionRequired) { | 3254 } else if (constantExpressionRequired) { |
3212 addCompileTimeError( | 3255 deprecated_addCompileTimeError( |
3213 offset, | 3256 offset, |
3214 "Type variable '${type.parameter.name}' can't be used as a constant " | 3257 "Type variable '${type.parameter.name}' can't be used as a constant " |
3215 "expression $type."); | 3258 "expression $type."); |
3216 } | 3259 } |
3217 return type; | 3260 return type; |
3218 } | 3261 } |
3219 | 3262 |
3220 Expression evaluateArgumentsBefore( | 3263 Expression evaluateArgumentsBefore( |
3221 Arguments arguments, Expression expression) { | 3264 Arguments arguments, Expression expression) { |
3222 if (arguments == null) return expression; | 3265 if (arguments == null) return expression; |
(...skipping 13 matching lines...) Expand all Loading... |
3236 @override | 3279 @override |
3237 bool isIdentical(Member member) => member == coreTypes.identicalProcedure; | 3280 bool isIdentical(Member member) => member == coreTypes.identicalProcedure; |
3238 | 3281 |
3239 @override | 3282 @override |
3240 Expression buildMethodInvocation( | 3283 Expression buildMethodInvocation( |
3241 Expression receiver, Name name, Arguments arguments, int offset, | 3284 Expression receiver, Name name, Arguments arguments, int offset, |
3242 {bool isConstantExpression: false, | 3285 {bool isConstantExpression: false, |
3243 bool isNullAware: false, | 3286 bool isNullAware: false, |
3244 bool isImplicitCall: false}) { | 3287 bool isImplicitCall: false}) { |
3245 if (constantExpressionRequired && !isConstantExpression) { | 3288 if (constantExpressionRequired && !isConstantExpression) { |
3246 return buildCompileTimeError("Not a constant expression.", offset); | 3289 return deprecated_buildCompileTimeError( |
| 3290 "Not a constant expression.", offset); |
3247 } | 3291 } |
3248 if (isNullAware) { | 3292 if (isNullAware) { |
3249 VariableDeclaration variable = new VariableDeclaration.forValue(receiver); | 3293 VariableDeclaration variable = new VariableDeclaration.forValue(receiver); |
3250 return new KernelNullAwareMethodInvocation( | 3294 return new KernelNullAwareMethodInvocation( |
3251 variable, | 3295 variable, |
3252 new ConditionalExpression( | 3296 new ConditionalExpression( |
3253 buildIsNull(new VariableGet(variable), offset), | 3297 buildIsNull(new VariableGet(variable), offset), |
3254 new NullLiteral(), | 3298 new NullLiteral(), |
3255 new MethodInvocation(new VariableGet(variable), name, arguments) | 3299 new MethodInvocation(new VariableGet(variable), name, arguments) |
3256 ..fileOffset = offset, | 3300 ..fileOffset = offset, |
3257 null) | 3301 null) |
3258 ..fileOffset = offset) | 3302 ..fileOffset = offset) |
3259 ..fileOffset = offset; | 3303 ..fileOffset = offset; |
3260 } else { | 3304 } else { |
3261 return new KernelMethodInvocation(receiver, name, arguments, | 3305 return new KernelMethodInvocation(receiver, name, arguments, |
3262 isImplicitCall: isImplicitCall) | 3306 isImplicitCall: isImplicitCall) |
3263 ..fileOffset = offset; | 3307 ..fileOffset = offset; |
3264 } | 3308 } |
3265 } | 3309 } |
3266 | 3310 |
3267 @override | 3311 @override |
3268 void addCompileTimeErrorFromMessage(FastaMessage message) { | 3312 void addCompileTimeErrorFromMessage(FastaMessage message) { |
3269 library.addCompileTimeError(message.charOffset, message.message, | 3313 library.deprecated_addCompileTimeError(message.charOffset, message.message, |
3270 fileUri: message.uri); | 3314 fileUri: message.uri); |
3271 } | 3315 } |
3272 | 3316 |
3273 @override | 3317 @override |
3274 void debugEvent(String name) { | 3318 void debugEvent(String name) { |
3275 // printEvent(name); | 3319 // printEvent(name); |
3276 } | 3320 } |
3277 | 3321 |
3278 @override | 3322 @override |
3279 StaticGet makeStaticGet(Member readTarget, Token token) { | 3323 StaticGet makeStaticGet(Member readTarget, Token token) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3320 | 3364 |
3321 abstract class ContextAccessor extends FastaAccessor { | 3365 abstract class ContextAccessor extends FastaAccessor { |
3322 final BuilderHelper helper; | 3366 final BuilderHelper helper; |
3323 | 3367 |
3324 final FastaAccessor accessor; | 3368 final FastaAccessor accessor; |
3325 | 3369 |
3326 final Token token; | 3370 final Token token; |
3327 | 3371 |
3328 ContextAccessor(this.helper, this.token, this.accessor); | 3372 ContextAccessor(this.helper, this.token, this.accessor); |
3329 | 3373 |
3330 String get plainNameForRead => internalError("Unsupported operation."); | 3374 String get plainNameForRead => |
| 3375 deprecated_internalProblem("Unsupported operation."); |
3331 | 3376 |
3332 Expression doInvocation(int charOffset, Arguments arguments) { | 3377 Expression doInvocation(int charOffset, Arguments arguments) { |
3333 return internalError("Unhandled: ${runtimeType}", uri, charOffset); | 3378 return deprecated_internalProblem( |
| 3379 "Unhandled: ${runtimeType}", uri, charOffset); |
3334 } | 3380 } |
3335 | 3381 |
3336 Expression buildSimpleRead(); | 3382 Expression buildSimpleRead(); |
3337 | 3383 |
3338 Expression buildForEffect(); | 3384 Expression buildForEffect(); |
3339 | 3385 |
3340 Expression buildAssignment(Expression value, {bool voidContext: false}) { | 3386 Expression buildAssignment(Expression value, {bool voidContext: false}) { |
3341 return makeInvalidWrite(value); | 3387 return makeInvalidWrite(value); |
3342 } | 3388 } |
3343 | 3389 |
(...skipping 18 matching lines...) Expand all Loading... |
3362 return makeInvalidWrite(null); | 3408 return makeInvalidWrite(null); |
3363 } | 3409 } |
3364 | 3410 |
3365 Expression buildPostfixIncrement(Name binaryOperator, | 3411 Expression buildPostfixIncrement(Name binaryOperator, |
3366 {int offset: TreeNode.noOffset, | 3412 {int offset: TreeNode.noOffset, |
3367 bool voidContext: false, | 3413 bool voidContext: false, |
3368 Procedure interfaceTarget}) { | 3414 Procedure interfaceTarget}) { |
3369 return makeInvalidWrite(null); | 3415 return makeInvalidWrite(null); |
3370 } | 3416 } |
3371 | 3417 |
3372 makeInvalidRead() => internalError("not supported"); | 3418 makeInvalidRead() => deprecated_internalProblem("not supported"); |
3373 | 3419 |
3374 Expression makeInvalidWrite(Expression value) { | 3420 Expression makeInvalidWrite(Expression value) { |
3375 return helper.buildCompileTimeError( | 3421 return helper.deprecated_buildCompileTimeError( |
3376 "Can't be used as left-hand side of assignment.", | 3422 "Can't be used as left-hand side of assignment.", |
3377 offsetForToken(token)); | 3423 offsetForToken(token)); |
3378 } | 3424 } |
3379 } | 3425 } |
3380 | 3426 |
3381 class DelayedAssignment extends ContextAccessor { | 3427 class DelayedAssignment extends ContextAccessor { |
3382 final Expression value; | 3428 final Expression value; |
3383 | 3429 |
3384 final String assignmentOperator; | 3430 final String assignmentOperator; |
3385 | 3431 |
3386 DelayedAssignment(BuilderHelper helper, Token token, FastaAccessor accessor, | 3432 DelayedAssignment(BuilderHelper helper, Token token, FastaAccessor accessor, |
3387 this.value, this.assignmentOperator) | 3433 this.value, this.assignmentOperator) |
3388 : super(helper, token, accessor); | 3434 : super(helper, token, accessor); |
3389 | 3435 |
3390 Expression buildSimpleRead() { | 3436 Expression buildSimpleRead() { |
3391 return handleAssignment(false); | 3437 return handleAssignment(false); |
3392 } | 3438 } |
3393 | 3439 |
3394 Expression buildForEffect() { | 3440 Expression buildForEffect() { |
3395 return handleAssignment(true); | 3441 return handleAssignment(true); |
3396 } | 3442 } |
3397 | 3443 |
3398 Expression handleAssignment(bool voidContext) { | 3444 Expression handleAssignment(bool voidContext) { |
3399 if (helper.constantExpressionRequired) { | 3445 if (helper.constantExpressionRequired) { |
3400 return helper.buildCompileTimeError( | 3446 return helper.deprecated_buildCompileTimeError( |
3401 "Not a constant expression.", offsetForToken(token)); | 3447 "Not a constant expression.", offsetForToken(token)); |
3402 } | 3448 } |
3403 if (identical("=", assignmentOperator)) { | 3449 if (identical("=", assignmentOperator)) { |
3404 return accessor.buildAssignment(value, voidContext: voidContext); | 3450 return accessor.buildAssignment(value, voidContext: voidContext); |
3405 } else if (identical("+=", assignmentOperator)) { | 3451 } else if (identical("+=", assignmentOperator)) { |
3406 return accessor.buildCompoundAssignment(plusName, value, | 3452 return accessor.buildCompoundAssignment(plusName, value, |
3407 offset: offsetForToken(token), voidContext: voidContext); | 3453 offset: offsetForToken(token), voidContext: voidContext); |
3408 } else if (identical("-=", assignmentOperator)) { | 3454 } else if (identical("-=", assignmentOperator)) { |
3409 return accessor.buildCompoundAssignment(minusName, value, | 3455 return accessor.buildCompoundAssignment(minusName, value, |
3410 offset: offsetForToken(token), voidContext: voidContext); | 3456 offset: offsetForToken(token), voidContext: voidContext); |
(...skipping 22 matching lines...) Expand all Loading... |
3433 } else if (identical("^=", assignmentOperator)) { | 3479 } else if (identical("^=", assignmentOperator)) { |
3434 return accessor.buildCompoundAssignment(caretName, value, | 3480 return accessor.buildCompoundAssignment(caretName, value, |
3435 offset: offsetForToken(token), voidContext: voidContext); | 3481 offset: offsetForToken(token), voidContext: voidContext); |
3436 } else if (identical("|=", assignmentOperator)) { | 3482 } else if (identical("|=", assignmentOperator)) { |
3437 return accessor.buildCompoundAssignment(barName, value, | 3483 return accessor.buildCompoundAssignment(barName, value, |
3438 offset: offsetForToken(token), voidContext: voidContext); | 3484 offset: offsetForToken(token), voidContext: voidContext); |
3439 } else if (identical("~/=", assignmentOperator)) { | 3485 } else if (identical("~/=", assignmentOperator)) { |
3440 return accessor.buildCompoundAssignment(mustacheName, value, | 3486 return accessor.buildCompoundAssignment(mustacheName, value, |
3441 offset: offsetForToken(token), voidContext: voidContext); | 3487 offset: offsetForToken(token), voidContext: voidContext); |
3442 } else { | 3488 } else { |
3443 return internalError("Unhandled: $assignmentOperator"); | 3489 return deprecated_internalProblem("Unhandled: $assignmentOperator"); |
3444 } | 3490 } |
3445 } | 3491 } |
3446 | 3492 |
3447 @override | 3493 @override |
3448 Initializer buildFieldInitializer(Map<String, int> initializedFields) { | 3494 Initializer buildFieldInitializer(Map<String, int> initializedFields) { |
3449 if (!identical("=", assignmentOperator) || | 3495 if (!identical("=", assignmentOperator) || |
3450 !accessor.isThisPropertyAccessor) { | 3496 !accessor.isThisPropertyAccessor) { |
3451 return accessor.buildFieldInitializer(initializedFields); | 3497 return accessor.buildFieldInitializer(initializedFields); |
3452 } | 3498 } |
3453 return helper.buildFieldInitializer( | 3499 return helper.buildFieldInitializer( |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3550 | 3596 |
3551 LabelTarget(MemberBuilder member, this.functionNestingLevel, int charOffset) | 3597 LabelTarget(MemberBuilder member, this.functionNestingLevel, int charOffset) |
3552 : breakTarget = new JumpTarget( | 3598 : breakTarget = new JumpTarget( |
3553 JumpTargetKind.Break, functionNestingLevel, member, charOffset), | 3599 JumpTargetKind.Break, functionNestingLevel, member, charOffset), |
3554 continueTarget = new JumpTarget( | 3600 continueTarget = new JumpTarget( |
3555 JumpTargetKind.Continue, functionNestingLevel, member, charOffset), | 3601 JumpTargetKind.Continue, functionNestingLevel, member, charOffset), |
3556 super(member, charOffset, member.fileUri); | 3602 super(member, charOffset, member.fileUri); |
3557 | 3603 |
3558 bool get hasUsers => breakTarget.hasUsers || continueTarget.hasUsers; | 3604 bool get hasUsers => breakTarget.hasUsers || continueTarget.hasUsers; |
3559 | 3605 |
3560 List<Statement> get users => internalError("Unsupported operation."); | 3606 List<Statement> get users => |
| 3607 deprecated_internalProblem("Unsupported operation."); |
3561 | 3608 |
3562 JumpTargetKind get kind => internalError("Unsupported operation."); | 3609 JumpTargetKind get kind => |
| 3610 deprecated_internalProblem("Unsupported operation."); |
3563 | 3611 |
3564 bool get isBreakTarget => true; | 3612 bool get isBreakTarget => true; |
3565 | 3613 |
3566 bool get isContinueTarget => true; | 3614 bool get isContinueTarget => true; |
3567 | 3615 |
3568 bool get isGotoTarget => false; | 3616 bool get isGotoTarget => false; |
3569 | 3617 |
3570 void addBreak(BreakStatement statement) { | 3618 void addBreak(BreakStatement statement) { |
3571 breakTarget.addBreak(statement); | 3619 breakTarget.addBreak(statement); |
3572 } | 3620 } |
3573 | 3621 |
3574 void addContinue(BreakStatement statement) { | 3622 void addContinue(BreakStatement statement) { |
3575 continueTarget.addContinue(statement); | 3623 continueTarget.addContinue(statement); |
3576 } | 3624 } |
3577 | 3625 |
3578 void addGoto(ContinueSwitchStatement statement) { | 3626 void addGoto(ContinueSwitchStatement statement) { |
3579 internalError("Unsupported operation."); | 3627 deprecated_internalProblem("Unsupported operation."); |
3580 } | 3628 } |
3581 | 3629 |
3582 void resolveBreaks(LabeledStatement target) { | 3630 void resolveBreaks(LabeledStatement target) { |
3583 breakTarget.resolveBreaks(target); | 3631 breakTarget.resolveBreaks(target); |
3584 } | 3632 } |
3585 | 3633 |
3586 void resolveContinues(LabeledStatement target) { | 3634 void resolveContinues(LabeledStatement target) { |
3587 continueTarget.resolveContinues(target); | 3635 continueTarget.resolveContinues(target); |
3588 } | 3636 } |
3589 | 3637 |
3590 void resolveGotos(SwitchCase target) { | 3638 void resolveGotos(SwitchCase target) { |
3591 internalError("Unsupported operation."); | 3639 deprecated_internalProblem("Unsupported operation."); |
3592 } | 3640 } |
3593 | 3641 |
3594 @override | 3642 @override |
3595 String get fullNameForErrors => "<label-target>"; | 3643 String get fullNameForErrors => "<label-target>"; |
3596 } | 3644 } |
3597 | 3645 |
3598 class OptionalFormals { | 3646 class OptionalFormals { |
3599 final FormalParameterType kind; | 3647 final FormalParameterType kind; |
3600 | 3648 |
3601 final List<VariableDeclaration> formals; | 3649 final List<VariableDeclaration> formals; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3654 typeParameters: typeParameters); | 3702 typeParameters: typeParameters); |
3655 } | 3703 } |
3656 | 3704 |
3657 Scope computeFormalParameterScope( | 3705 Scope computeFormalParameterScope( |
3658 Scope parent, Builder builder, BuilderHelper helper) { | 3706 Scope parent, Builder builder, BuilderHelper helper) { |
3659 if (required.length == 0 && optional == null) return parent; | 3707 if (required.length == 0 && optional == null) return parent; |
3660 Map<String, Builder> local = <String, Builder>{}; | 3708 Map<String, Builder> local = <String, Builder>{}; |
3661 | 3709 |
3662 for (VariableDeclaration parameter in required) { | 3710 for (VariableDeclaration parameter in required) { |
3663 if (local[parameter.name] != null) { | 3711 if (local[parameter.name] != null) { |
3664 helper.addCompileTimeError(parameter.fileOffset, "Duplicated name."); | 3712 helper.deprecated_addCompileTimeError( |
| 3713 parameter.fileOffset, "Duplicated name."); |
3665 } | 3714 } |
3666 local[parameter.name] = | 3715 local[parameter.name] = |
3667 new KernelVariableBuilder(parameter, builder, builder.fileUri); | 3716 new KernelVariableBuilder(parameter, builder, builder.fileUri); |
3668 } | 3717 } |
3669 if (optional != null) { | 3718 if (optional != null) { |
3670 for (VariableDeclaration parameter in optional.formals) { | 3719 for (VariableDeclaration parameter in optional.formals) { |
3671 if (local[parameter.name] != null) { | 3720 if (local[parameter.name] != null) { |
3672 helper.addCompileTimeError(parameter.fileOffset, "Duplicated name."); | 3721 helper.deprecated_addCompileTimeError( |
| 3722 parameter.fileOffset, "Duplicated name."); |
3673 } | 3723 } |
3674 local[parameter.name] = | 3724 local[parameter.name] = |
3675 new KernelVariableBuilder(parameter, builder, builder.fileUri); | 3725 new KernelVariableBuilder(parameter, builder, builder.fileUri); |
3676 } | 3726 } |
3677 } | 3727 } |
3678 return new Scope(local, null, parent, isModifiable: false); | 3728 return new Scope(local, null, parent, isModifiable: false); |
3679 } | 3729 } |
3680 } | 3730 } |
3681 | 3731 |
3682 /// Returns a block like this: | 3732 /// Returns a block like this: |
(...skipping 22 matching lines...) Expand all Loading... |
3705 String getNodeName(Object node) { | 3755 String getNodeName(Object node) { |
3706 if (node is Identifier) { | 3756 if (node is Identifier) { |
3707 return node.name; | 3757 return node.name; |
3708 } else if (node is Builder) { | 3758 } else if (node is Builder) { |
3709 return node.fullNameForErrors; | 3759 return node.fullNameForErrors; |
3710 } else if (node is ThisAccessor) { | 3760 } else if (node is ThisAccessor) { |
3711 return node.isSuper ? "super" : "this"; | 3761 return node.isSuper ? "super" : "this"; |
3712 } else if (node is FastaAccessor) { | 3762 } else if (node is FastaAccessor) { |
3713 return node.plainNameForRead; | 3763 return node.plainNameForRead; |
3714 } else { | 3764 } else { |
3715 return internalError("Unhandled: ${node.runtimeType}"); | 3765 return deprecated_internalProblem("Unhandled: ${node.runtimeType}"); |
3716 } | 3766 } |
3717 } | 3767 } |
3718 | 3768 |
3719 AsyncMarker asyncMarkerFromTokens(Token asyncToken, Token starToken) { | 3769 AsyncMarker asyncMarkerFromTokens(Token asyncToken, Token starToken) { |
3720 if (asyncToken == null || identical(asyncToken.stringValue, "sync")) { | 3770 if (asyncToken == null || identical(asyncToken.stringValue, "sync")) { |
3721 if (starToken == null) { | 3771 if (starToken == null) { |
3722 return AsyncMarker.Sync; | 3772 return AsyncMarker.Sync; |
3723 } else { | 3773 } else { |
3724 assert(identical(starToken.stringValue, "*")); | 3774 assert(identical(starToken.stringValue, "*")); |
3725 return AsyncMarker.SyncStar; | 3775 return AsyncMarker.SyncStar; |
3726 } | 3776 } |
3727 } else if (identical(asyncToken.stringValue, "async")) { | 3777 } else if (identical(asyncToken.stringValue, "async")) { |
3728 if (starToken == null) { | 3778 if (starToken == null) { |
3729 return AsyncMarker.Async; | 3779 return AsyncMarker.Async; |
3730 } else { | 3780 } else { |
3731 assert(identical(starToken.stringValue, "*")); | 3781 assert(identical(starToken.stringValue, "*")); |
3732 return AsyncMarker.AsyncStar; | 3782 return AsyncMarker.AsyncStar; |
3733 } | 3783 } |
3734 } else { | 3784 } else { |
3735 return internalError("Unknown async modifier: $asyncToken"); | 3785 return deprecated_internalProblem("Unknown async modifier: $asyncToken"); |
3736 } | 3786 } |
3737 } | 3787 } |
OLD | NEW |