Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/body_builder.dart

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

Powered by Google App Engine
This is Rietveld 408576698