| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library fasta.body_builder; | 5 library fasta.body_builder; |
| 6 | 6 |
| 7 import '../fasta_codes.dart' | 7 import '../fasta_codes.dart' |
| 8 show FastaMessage, codeExpectedButGot, codeExpectedFunctionBody; | 8 show FastaMessage, codeExpectedButGot, codeExpectedFunctionBody; |
| 9 | 9 |
| 10 import '../parser/parser.dart' show FormalParameterType, optional; | 10 import '../parser/parser.dart' show FormalParameterType, optional; |
| 11 | 11 |
| 12 import '../parser/identifier_context.dart' show IdentifierContext; | 12 import '../parser/identifier_context.dart' show IdentifierContext; |
| 13 | 13 |
| 14 import 'package:front_end/src/fasta/builder/ast_factory.dart' show AstFactory; | 14 import 'package:front_end/src/fasta/builder/ast_factory.dart' show AstFactory; |
| 15 | 15 |
| 16 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart' | 16 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart' |
| 17 show KernelField; | 17 show KernelField; |
| 18 | 18 |
| 19 import 'package:front_end/src/fasta/kernel/utils.dart' show offsetForToken; |
| 20 |
| 19 import 'package:front_end/src/fasta/type_inference/type_inference_engine.dart' | 21 import 'package:front_end/src/fasta/type_inference/type_inference_engine.dart' |
| 20 show FieldNode; | 22 show FieldNode; |
| 21 | 23 |
| 22 import 'package:front_end/src/fasta/type_inference/type_inferrer.dart' | 24 import 'package:front_end/src/fasta/type_inference/type_inferrer.dart' |
| 23 show TypeInferrer; | 25 show TypeInferrer; |
| 24 | 26 |
| 25 import 'package:front_end/src/fasta/type_inference/type_promotion.dart' | 27 import 'package:front_end/src/fasta/type_inference/type_promotion.dart' |
| 26 show TypePromoter; | 28 show TypePromoter; |
| 27 | 29 |
| 28 import 'package:kernel/ast.dart'; | 30 import 'package:kernel/ast.dart'; |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 | 239 |
| 238 List<Expression> popListForEffect(int n) { | 240 List<Expression> popListForEffect(int n) { |
| 239 List<Expression> list = | 241 List<Expression> list = |
| 240 new List<Expression>.filled(n, null, growable: true); | 242 new List<Expression>.filled(n, null, growable: true); |
| 241 for (int i = n - 1; i >= 0; i--) { | 243 for (int i = n - 1; i >= 0; i--) { |
| 242 list[i] = popForEffect(); | 244 list[i] = popForEffect(); |
| 243 } | 245 } |
| 244 return list; | 246 return list; |
| 245 } | 247 } |
| 246 | 248 |
| 247 Block popBlock(int count, int charOffset) { | 249 Block popBlock(int count, Token beginToken) { |
| 248 List<dynamic /*Statement | List<Statement>*/ > statements = | 250 List<dynamic /*Statement | List<Statement>*/ > statements = |
| 249 popList(count) ?? <Statement>[]; | 251 popList(count) ?? <Statement>[]; |
| 250 List<Statement> copy; | 252 List<Statement> copy; |
| 251 for (int i = 0; i < statements.length; i++) { | 253 for (int i = 0; i < statements.length; i++) { |
| 252 var statement = statements[i]; | 254 var statement = statements[i]; |
| 253 if (statement is List) { | 255 if (statement is List) { |
| 254 copy ??= new List<Statement>.from(statements.getRange(0, i)); | 256 copy ??= new List<Statement>.from(statements.getRange(0, i)); |
| 255 // TODO(sigmund): remove this assignment (issue #28651) | 257 // TODO(sigmund): remove this assignment (issue #28651) |
| 256 Iterable subStatements = statement; | 258 Iterable subStatements = statement; |
| 257 copy.addAll(subStatements); | 259 copy.addAll(subStatements); |
| 258 } else if (copy != null) { | 260 } else if (copy != null) { |
| 259 copy.add(statement); | 261 copy.add(statement); |
| 260 } | 262 } |
| 261 } | 263 } |
| 262 return astFactory.block(copy ?? statements, charOffset); | 264 return astFactory.block(copy ?? statements, beginToken); |
| 263 } | 265 } |
| 264 | 266 |
| 265 Statement popStatementIfNotNull(Object value) { | 267 Statement popStatementIfNotNull(Object value) { |
| 266 return value == null ? null : popStatement(); | 268 return value == null ? null : popStatement(); |
| 267 } | 269 } |
| 268 | 270 |
| 269 Statement popStatement() { | 271 Statement popStatement() { |
| 270 var statement = pop(); | 272 var statement = pop(); |
| 271 if (statement is List) { | 273 if (statement is List) { |
| 272 return new Block(new List<Statement>.from(statement)); | 274 return new Block(new List<Statement>.from(statement)); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 checkEmpty(-1); | 372 checkEmpty(-1); |
| 371 } | 373 } |
| 372 | 374 |
| 373 @override | 375 @override |
| 374 void endBlockFunctionBody(int count, Token beginToken, Token endToken) { | 376 void endBlockFunctionBody(int count, Token beginToken, Token endToken) { |
| 375 debugEvent("BlockFunctionBody"); | 377 debugEvent("BlockFunctionBody"); |
| 376 if (beginToken == null) { | 378 if (beginToken == null) { |
| 377 assert(count == 0); | 379 assert(count == 0); |
| 378 push(NullValue.Block); | 380 push(NullValue.Block); |
| 379 } else { | 381 } else { |
| 380 Block block = popBlock(count, beginToken.charOffset); | 382 Block block = popBlock(count, beginToken); |
| 381 exitLocalScope(); | 383 exitLocalScope(); |
| 382 push(block); | 384 push(block); |
| 383 } | 385 } |
| 384 } | 386 } |
| 385 | 387 |
| 386 @override | 388 @override |
| 387 void prepareInitializers() { | 389 void prepareInitializers() { |
| 388 scope = formalParameterScope; | 390 scope = formalParameterScope; |
| 389 assert(fieldInitializers.isEmpty); | 391 assert(fieldInitializers.isEmpty); |
| 390 final member = this.member; | 392 final member = this.member; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 arguments.getRange(firstNamedArgumentIndex, arguments.length)); | 570 arguments.getRange(firstNamedArgumentIndex, arguments.length)); |
| 569 push(new Arguments(positional, named: named)); | 571 push(new Arguments(positional, named: named)); |
| 570 } else { | 572 } else { |
| 571 push(new Arguments(arguments)); | 573 push(new Arguments(arguments)); |
| 572 } | 574 } |
| 573 } | 575 } |
| 574 | 576 |
| 575 @override | 577 @override |
| 576 void handleParenthesizedExpression(BeginGroupToken token) { | 578 void handleParenthesizedExpression(BeginGroupToken token) { |
| 577 debugEvent("ParenthesizedExpression"); | 579 debugEvent("ParenthesizedExpression"); |
| 578 push(new ParenthesizedExpression( | 580 push(new ParenthesizedExpression(this, popForValue(), token.endGroup)); |
| 579 this, popForValue(), token.endGroup.charOffset)); | |
| 580 } | 581 } |
| 581 | 582 |
| 582 @override | 583 @override |
| 583 void endSend(Token beginToken, Token endToken) { | 584 void endSend(Token beginToken, Token endToken) { |
| 584 debugEvent("Send"); | 585 debugEvent("Send"); |
| 585 Arguments arguments = pop(); | 586 Arguments arguments = pop(); |
| 586 List<DartType> typeArguments = pop(); | 587 List<DartType> typeArguments = pop(); |
| 587 Object receiver = pop(); | 588 Object receiver = pop(); |
| 588 if (arguments != null && typeArguments != null) { | 589 if (arguments != null && typeArguments != null) { |
| 589 arguments.types.addAll(typeArguments); | 590 arguments.types.addAll(typeArguments); |
| 590 } else { | 591 } else { |
| 591 assert(typeArguments == null); | 592 assert(typeArguments == null); |
| 592 } | 593 } |
| 593 if (receiver is Identifier) { | 594 if (receiver is Identifier) { |
| 594 Name name = new Name(receiver.name, library.library); | 595 Name name = new Name(receiver.name, library.library); |
| 595 if (arguments == null) { | 596 if (arguments == null) { |
| 596 push(new IncompletePropertyAccessor(this, beginToken.charOffset, name)); | 597 push(new IncompletePropertyAccessor(this, beginToken, name)); |
| 597 } else { | 598 } else { |
| 598 push(new SendAccessor(this, beginToken.charOffset, name, arguments)); | 599 push(new SendAccessor(this, beginToken, name, arguments)); |
| 599 } | 600 } |
| 600 } else if (arguments == null) { | 601 } else if (arguments == null) { |
| 601 push(receiver); | 602 push(receiver); |
| 602 } else { | 603 } else { |
| 603 push(finishSend(receiver, arguments, beginToken.charOffset)); | 604 push(finishSend(receiver, arguments, beginToken.charOffset)); |
| 604 } | 605 } |
| 605 } | 606 } |
| 606 | 607 |
| 607 @override | 608 @override |
| 608 finishSend(Object receiver, Arguments arguments, int charOffset) { | 609 finishSend(Object receiver, Arguments arguments, int charOffset) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 624 toValue(receiver), callName, arguments, charOffset); | 625 toValue(receiver), callName, arguments, charOffset); |
| 625 } | 626 } |
| 626 } | 627 } |
| 627 | 628 |
| 628 @override | 629 @override |
| 629 void beginCascade(Token token) { | 630 void beginCascade(Token token) { |
| 630 debugEvent("beginCascade"); | 631 debugEvent("beginCascade"); |
| 631 Expression expression = popForValue(); | 632 Expression expression = popForValue(); |
| 632 if (expression is CascadeReceiver) { | 633 if (expression is CascadeReceiver) { |
| 633 push(expression); | 634 push(expression); |
| 634 push(new VariableAccessor( | 635 push(new VariableAccessor(this, token, expression.variable)); |
| 635 this, expression.fileOffset, expression.variable)); | |
| 636 expression.extend(); | 636 expression.extend(); |
| 637 } else { | 637 } else { |
| 638 VariableDeclaration variable = | 638 VariableDeclaration variable = |
| 639 new VariableDeclaration.forValue(expression); | 639 new VariableDeclaration.forValue(expression); |
| 640 push(new CascadeReceiver(variable)); | 640 push(new CascadeReceiver(variable)); |
| 641 push(new VariableAccessor(this, expression.fileOffset, variable)); | 641 push(new VariableAccessor(this, token, variable)); |
| 642 } | 642 } |
| 643 } | 643 } |
| 644 | 644 |
| 645 @override | 645 @override |
| 646 void endCascade() { | 646 void endCascade() { |
| 647 debugEvent("endCascade"); | 647 debugEvent("endCascade"); |
| 648 Expression expression = popForEffect(); | 648 Expression expression = popForEffect(); |
| 649 CascadeReceiver cascadeReceiver = pop(); | 649 CascadeReceiver cascadeReceiver = pop(); |
| 650 cascadeReceiver.finalize(expression); | 650 cascadeReceiver.finalize(expression); |
| 651 push(cascadeReceiver); | 651 push(cascadeReceiver); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 @override | 817 @override |
| 818 void handleIdentifier(Token token, IdentifierContext context) { | 818 void handleIdentifier(Token token, IdentifierContext context) { |
| 819 debugEvent("handleIdentifier"); | 819 debugEvent("handleIdentifier"); |
| 820 String name = token.lexeme; | 820 String name = token.lexeme; |
| 821 if (context.isScopeReference) { | 821 if (context.isScopeReference) { |
| 822 assert(!inInitializer || | 822 assert(!inInitializer || |
| 823 this.scope == enclosingScope || | 823 this.scope == enclosingScope || |
| 824 this.scope.parent == enclosingScope); | 824 this.scope.parent == enclosingScope); |
| 825 // This deals with this kind of initializer: `C(a) : a = a;` | 825 // This deals with this kind of initializer: `C(a) : a = a;` |
| 826 Scope scope = inInitializer ? enclosingScope : this.scope; | 826 Scope scope = inInitializer ? enclosingScope : this.scope; |
| 827 push(scopeLookup(scope, name, token.charOffset)); | 827 push(scopeLookup(scope, name, token)); |
| 828 return; | 828 return; |
| 829 } else if (context.inDeclaration) { | 829 } else if (context.inDeclaration) { |
| 830 if (context == IdentifierContext.topLevelVariableDeclaration || | 830 if (context == IdentifierContext.topLevelVariableDeclaration || |
| 831 context == IdentifierContext.fieldDeclaration) { | 831 context == IdentifierContext.fieldDeclaration) { |
| 832 constantExpressionRequired = member.isConst; | 832 constantExpressionRequired = member.isConst; |
| 833 } | 833 } |
| 834 } else if (constantExpressionRequired && | 834 } else if (constantExpressionRequired && |
| 835 !context.allowedInConstantExpression) { | 835 !context.allowedInConstantExpression) { |
| 836 addCompileTimeError( | 836 addCompileTimeError( |
| 837 token.charOffset, "Not a constant expression: $context"); | 837 token.charOffset, "Not a constant expression: $context"); |
| 838 } | 838 } |
| 839 push(new Identifier(name, token.charOffset)); | 839 push(new Identifier(token)); |
| 840 } | 840 } |
| 841 | 841 |
| 842 /// Look up [name] in [scope] using [charOffset] to report any | 842 /// Look up [name] in [scope] using [token] as location information (both to |
| 843 /// problems. [isQualified] should be true if [name] is a qualified access | 843 /// report problems and as the file offset in the generated kernel code). |
| 844 /// [isQualified] should be true if [name] is a qualified access |
| 844 /// (which implies that it shouldn't be turned into a [ThisPropertyAccessor] | 845 /// (which implies that it shouldn't be turned into a [ThisPropertyAccessor] |
| 845 /// if the name doesn't resolve in the scope). | 846 /// if the name doesn't resolve in the scope). |
| 846 @override | 847 @override |
| 847 scopeLookup(Scope scope, String name, int charOffset, | 848 scopeLookup(Scope scope, String name, Token token, |
| 848 {bool isQualified: false, PrefixBuilder prefix}) { | 849 {bool isQualified: false, PrefixBuilder prefix}) { |
| 849 Builder builder = scope.lookup(name, charOffset, uri); | 850 Builder builder = scope.lookup(name, offsetForToken(token), uri); |
| 850 if (builder == null || (!isInstanceContext && builder.isInstanceMember)) { | 851 if (builder == null || (!isInstanceContext && builder.isInstanceMember)) { |
| 851 Name n = new Name(name, library.library); | 852 Name n = new Name(name, library.library); |
| 852 if (prefix != null && | 853 if (prefix != null && |
| 853 prefix.deferred && | 854 prefix.deferred && |
| 854 builder == null && | 855 builder == null && |
| 855 "loadLibrary" == name) { | 856 "loadLibrary" == name) { |
| 856 return buildCompileTimeError( | 857 return buildCompileTimeError( |
| 857 "Deferred loading isn't implemented yet.", charOffset); | 858 "Deferred loading isn't implemented yet.", offsetForToken(token)); |
| 858 } else if (!isQualified && isInstanceContext) { | 859 } else if (!isQualified && isInstanceContext) { |
| 859 assert(builder == null); | 860 assert(builder == null); |
| 860 if (constantExpressionRequired) { | 861 if (constantExpressionRequired) { |
| 861 return new UnresolvedAccessor(this, n, charOffset); | 862 return new UnresolvedAccessor(this, n, token); |
| 862 } | 863 } |
| 863 return new ThisPropertyAccessor(this, charOffset, n, null, null); | 864 return new ThisPropertyAccessor(this, token, n, null, null); |
| 864 } else if (isDartLibrary && | 865 } else if (isDartLibrary && |
| 865 name == "main" && | 866 name == "main" && |
| 866 library.uri.path == "_builtin" && | 867 library.uri.path == "_builtin" && |
| 867 member?.name == "_getMainClosure") { | 868 member?.name == "_getMainClosure") { |
| 868 // TODO(ahe): https://github.com/dart-lang/sdk/issues/28989 | 869 // TODO(ahe): https://github.com/dart-lang/sdk/issues/28989 |
| 869 return new NullLiteral()..fileOffset = charOffset; | 870 return new NullLiteral()..fileOffset = offsetForToken(token); |
| 870 } else { | 871 } else { |
| 871 return new UnresolvedAccessor(this, n, charOffset); | 872 return new UnresolvedAccessor(this, n, token); |
| 872 } | 873 } |
| 873 } else if (builder.isTypeDeclaration) { | 874 } else if (builder.isTypeDeclaration) { |
| 874 if (constantExpressionRequired && | 875 if (constantExpressionRequired && |
| 875 builder.isTypeVariable && | 876 builder.isTypeVariable && |
| 876 !member.isConstructor) { | 877 !member.isConstructor) { |
| 877 addCompileTimeError(charOffset, "Not a constant expression."); | 878 addCompileTimeError( |
| 879 offsetForToken(token), "Not a constant expression."); |
| 878 } | 880 } |
| 879 return builder; | 881 return builder; |
| 880 } else if (builder.isLocal) { | 882 } else if (builder.isLocal) { |
| 881 if (constantExpressionRequired && | 883 if (constantExpressionRequired && |
| 882 !builder.isConst && | 884 !builder.isConst && |
| 883 !member.isConstructor) { | 885 !member.isConstructor) { |
| 884 addCompileTimeError(charOffset, "Not a constant expression."); | 886 addCompileTimeError( |
| 887 offsetForToken(token), "Not a constant expression."); |
| 885 } | 888 } |
| 886 return new VariableAccessor(this, charOffset, builder.target); | 889 return new VariableAccessor(this, token, builder.target); |
| 887 } else if (builder.isInstanceMember) { | 890 } else if (builder.isInstanceMember) { |
| 888 if (constantExpressionRequired && | 891 if (constantExpressionRequired && |
| 889 !inInitializer && | 892 !inInitializer && |
| 890 // TODO(ahe): This is a hack because Fasta sets up the scope | 893 // TODO(ahe): This is a hack because Fasta sets up the scope |
| 891 // "this.field" parameters according to old semantics. Under the new | 894 // "this.field" parameters according to old semantics. Under the new |
| 892 // semantics, such parameters introduces a new parameter with that | 895 // semantics, such parameters introduces a new parameter with that |
| 893 // name that should be resolved here. | 896 // name that should be resolved here. |
| 894 !member.isConstructor) { | 897 !member.isConstructor) { |
| 895 addCompileTimeError(charOffset, "Not a constant expression."); | 898 addCompileTimeError( |
| 899 offsetForToken(token), "Not a constant expression."); |
| 896 } | 900 } |
| 897 return new ThisPropertyAccessor( | 901 return new ThisPropertyAccessor( |
| 898 this, charOffset, new Name(name, library.library), null, null); | 902 this, token, new Name(name, library.library), null, null); |
| 899 } else if (builder.isRegularMethod) { | 903 } else if (builder.isRegularMethod) { |
| 900 assert(builder.isStatic || builder.isTopLevel); | 904 assert(builder.isStatic || builder.isTopLevel); |
| 901 return new StaticAccessor(this, charOffset, builder.target, null); | 905 return new StaticAccessor(this, token, builder.target, null); |
| 902 } else if (builder is PrefixBuilder) { | 906 } else if (builder is PrefixBuilder) { |
| 903 if (constantExpressionRequired && builder.deferred) { | 907 if (constantExpressionRequired && builder.deferred) { |
| 904 addCompileTimeError( | 908 addCompileTimeError( |
| 905 charOffset, | 909 offsetForToken(token), |
| 906 "'$name' can't be used in a constant expression because it's " | 910 "'$name' can't be used in a constant expression because it's " |
| 907 "marked as 'deferred' which means it isn't available until " | 911 "marked as 'deferred' which means it isn't available until " |
| 908 "loaded.\n" | 912 "loaded.\n" |
| 909 "You might try moving the constant to the deferred library, " | 913 "You might try moving the constant to the deferred library, " |
| 910 "or removing 'deferred' from the import."); | 914 "or removing 'deferred' from the import."); |
| 911 } | 915 } |
| 912 return builder; | 916 return builder; |
| 913 } else { | 917 } else { |
| 914 if (builder.hasProblem && builder is! AccessErrorBuilder) return builder; | 918 if (builder.hasProblem && builder is! AccessErrorBuilder) return builder; |
| 915 Builder setter; | 919 Builder setter; |
| 916 if (builder.isSetter) { | 920 if (builder.isSetter) { |
| 917 setter = builder; | 921 setter = builder; |
| 918 } else if (builder.isGetter) { | 922 } else if (builder.isGetter) { |
| 919 setter = scope.lookupSetter(name, charOffset, uri); | 923 setter = scope.lookupSetter(name, offsetForToken(token), uri); |
| 920 } else if (builder.isField && !builder.isFinal) { | 924 } else if (builder.isField && !builder.isFinal) { |
| 921 setter = builder; | 925 setter = builder; |
| 922 } | 926 } |
| 923 StaticAccessor accessor = | 927 StaticAccessor accessor = |
| 924 new StaticAccessor.fromBuilder(this, builder, charOffset, setter); | 928 new StaticAccessor.fromBuilder(this, builder, token, setter); |
| 925 if (constantExpressionRequired) { | 929 if (constantExpressionRequired) { |
| 926 Member readTarget = accessor.readTarget; | 930 Member readTarget = accessor.readTarget; |
| 927 if (!(readTarget is Field && readTarget.isConst || | 931 if (!(readTarget is Field && readTarget.isConst || |
| 928 // Static tear-offs are also compile time constants. | 932 // Static tear-offs are also compile time constants. |
| 929 readTarget is Procedure)) { | 933 readTarget is Procedure)) { |
| 930 addCompileTimeError(charOffset, "Not a constant expression."); | 934 addCompileTimeError( |
| 935 offsetForToken(token), "Not a constant expression."); |
| 931 } | 936 } |
| 932 } | 937 } |
| 933 return accessor; | 938 return accessor; |
| 934 } | 939 } |
| 935 } | 940 } |
| 936 | 941 |
| 937 @override | 942 @override |
| 938 void handleQualified(Token period) { | 943 void handleQualified(Token period) { |
| 939 debugEvent("Qualified"); | 944 debugEvent("Qualified"); |
| 940 Identifier name = pop(); | 945 Identifier name = pop(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 expressions.add(part); | 1020 expressions.add(part); |
| 1016 } | 1021 } |
| 1017 } | 1022 } |
| 1018 } | 1023 } |
| 1019 push(new StringConcatenation(expressions ?? parts)); | 1024 push(new StringConcatenation(expressions ?? parts)); |
| 1020 } | 1025 } |
| 1021 | 1026 |
| 1022 @override | 1027 @override |
| 1023 void handleLiteralInt(Token token) { | 1028 void handleLiteralInt(Token token) { |
| 1024 debugEvent("LiteralInt"); | 1029 debugEvent("LiteralInt"); |
| 1025 push(astFactory.intLiteral(int.parse(token.lexeme), token.charOffset)); | 1030 push(astFactory.intLiteral(int.parse(token.lexeme), token)); |
| 1026 } | 1031 } |
| 1027 | 1032 |
| 1028 @override | 1033 @override |
| 1029 void handleEmptyFunctionBody(Token semicolon) { | 1034 void handleEmptyFunctionBody(Token semicolon) { |
| 1030 debugEvent("ExpressionFunctionBody"); | 1035 debugEvent("ExpressionFunctionBody"); |
| 1031 endBlockFunctionBody(0, null, semicolon); | 1036 endBlockFunctionBody(0, null, semicolon); |
| 1032 } | 1037 } |
| 1033 | 1038 |
| 1034 @override | 1039 @override |
| 1035 void handleExpressionFunctionBody(Token arrowToken, Token endToken) { | 1040 void handleExpressionFunctionBody(Token arrowToken, Token endToken) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 Statement thenPart = popStatement(); | 1075 Statement thenPart = popStatement(); |
| 1071 Expression condition = popForValue(); | 1076 Expression condition = popForValue(); |
| 1072 typePromoter.exitConditional(); | 1077 typePromoter.exitConditional(); |
| 1073 push(astFactory.ifStatement(condition, thenPart, elsePart)); | 1078 push(astFactory.ifStatement(condition, thenPart, elsePart)); |
| 1074 } | 1079 } |
| 1075 | 1080 |
| 1076 @override | 1081 @override |
| 1077 void endVariableInitializer(Token assignmentOperator) { | 1082 void endVariableInitializer(Token assignmentOperator) { |
| 1078 debugEvent("VariableInitializer"); | 1083 debugEvent("VariableInitializer"); |
| 1079 assert(assignmentOperator.stringValue == "="); | 1084 assert(assignmentOperator.stringValue == "="); |
| 1080 pushNewLocalVariable(popForValue(), | 1085 pushNewLocalVariable(popForValue(), equalsToken: assignmentOperator); |
| 1081 equalsCharOffset: assignmentOperator.charOffset); | |
| 1082 } | 1086 } |
| 1083 | 1087 |
| 1084 @override | 1088 @override |
| 1085 void handleNoVariableInitializer(Token token) { | 1089 void handleNoVariableInitializer(Token token) { |
| 1086 debugEvent("NoVariableInitializer"); | 1090 debugEvent("NoVariableInitializer"); |
| 1087 pushNewLocalVariable(null); | 1091 pushNewLocalVariable(null); |
| 1088 } | 1092 } |
| 1089 | 1093 |
| 1090 void pushNewLocalVariable(Expression initializer, | 1094 void pushNewLocalVariable(Expression initializer, {Token equalsToken}) { |
| 1091 {int equalsCharOffset: TreeNode.noOffset}) { | |
| 1092 Identifier identifier = pop(); | 1095 Identifier identifier = pop(); |
| 1093 assert(currentLocalVariableModifiers != -1); | 1096 assert(currentLocalVariableModifiers != -1); |
| 1094 bool isConst = (currentLocalVariableModifiers & constMask) != 0; | 1097 bool isConst = (currentLocalVariableModifiers & constMask) != 0; |
| 1095 bool isFinal = (currentLocalVariableModifiers & finalMask) != 0; | 1098 bool isFinal = (currentLocalVariableModifiers & finalMask) != 0; |
| 1096 assert(isConst == constantExpressionRequired); | 1099 assert(isConst == constantExpressionRequired); |
| 1097 push(astFactory.variableDeclaration( | 1100 push(astFactory.variableDeclaration( |
| 1098 identifier.name, identifier.fileOffset, functionNestingLevel, | 1101 identifier.name, identifier.token, functionNestingLevel, |
| 1099 initializer: initializer, | 1102 initializer: initializer, |
| 1100 type: currentLocalVariableType, | 1103 type: currentLocalVariableType, |
| 1101 isFinal: isFinal, | 1104 isFinal: isFinal, |
| 1102 isConst: isConst, | 1105 isConst: isConst, |
| 1103 equalsCharOffset: equalsCharOffset)); | 1106 equalsToken: equalsToken)); |
| 1104 } | 1107 } |
| 1105 | 1108 |
| 1106 @override | 1109 @override |
| 1107 void endFieldInitializer(Token assignmentOperator, Token token) { | 1110 void endFieldInitializer(Token assignmentOperator, Token token) { |
| 1108 debugEvent("FieldInitializer"); | 1111 debugEvent("FieldInitializer"); |
| 1109 assert(assignmentOperator.stringValue == "="); | 1112 assert(assignmentOperator.stringValue == "="); |
| 1110 push(popForValue()); | 1113 push(popForValue()); |
| 1111 } | 1114 } |
| 1112 | 1115 |
| 1113 @override | 1116 @override |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 if (variables.length != 1) { | 1161 if (variables.length != 1) { |
| 1159 push(variables); | 1162 push(variables); |
| 1160 } else { | 1163 } else { |
| 1161 push(variables.single); | 1164 push(variables.single); |
| 1162 } | 1165 } |
| 1163 } | 1166 } |
| 1164 | 1167 |
| 1165 @override | 1168 @override |
| 1166 void endBlock(int count, Token beginToken, Token endToken) { | 1169 void endBlock(int count, Token beginToken, Token endToken) { |
| 1167 debugEvent("Block"); | 1170 debugEvent("Block"); |
| 1168 Block block = popBlock(count, beginToken.charOffset); | 1171 Block block = popBlock(count, beginToken); |
| 1169 exitLocalScope(); | 1172 exitLocalScope(); |
| 1170 push(block); | 1173 push(block); |
| 1171 } | 1174 } |
| 1172 | 1175 |
| 1173 @override | 1176 @override |
| 1174 void handleAssignmentExpression(Token token) { | 1177 void handleAssignmentExpression(Token token) { |
| 1175 debugEvent("AssignmentExpression"); | 1178 debugEvent("AssignmentExpression"); |
| 1176 Expression value = popForValue(); | 1179 Expression value = popForValue(); |
| 1177 var accessor = pop(); | 1180 var accessor = pop(); |
| 1178 if (accessor is TypeDeclarationBuilder) { | 1181 if (accessor is TypeDeclarationBuilder) { |
| 1179 push(wrapInvalid(new TypeLiteral( | 1182 push(wrapInvalid(new TypeLiteral( |
| 1180 accessor.buildTypesWithBuiltArguments(library, null)))); | 1183 accessor.buildTypesWithBuiltArguments(library, null)))); |
| 1181 } else if (accessor is! FastaAccessor) { | 1184 } else if (accessor is! FastaAccessor) { |
| 1182 push(buildCompileTimeError("Can't assign to this.", token.charOffset)); | 1185 push(buildCompileTimeError("Can't assign to this.", token.charOffset)); |
| 1183 } else { | 1186 } else { |
| 1184 push(new DelayedAssignment( | 1187 push(new DelayedAssignment( |
| 1185 this, token.charOffset, accessor, value, token.stringValue)); | 1188 this, token, accessor, value, token.stringValue)); |
| 1186 } | 1189 } |
| 1187 } | 1190 } |
| 1188 | 1191 |
| 1189 @override | 1192 @override |
| 1190 void enterLoop(int charOffset) { | 1193 void enterLoop(int charOffset) { |
| 1191 if (peek() is LabelTarget) { | 1194 if (peek() is LabelTarget) { |
| 1192 LabelTarget target = peek(); | 1195 LabelTarget target = peek(); |
| 1193 enterBreakTarget(charOffset, target.breakTarget); | 1196 enterBreakTarget(charOffset, target.breakTarget); |
| 1194 enterContinueTarget(charOffset, target.continueTarget); | 1197 enterContinueTarget(charOffset, target.continueTarget); |
| 1195 } else { | 1198 } else { |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1416 if (suffix is Identifier) { | 1419 if (suffix is Identifier) { |
| 1417 suffix = suffix.name; | 1420 suffix = suffix.name; |
| 1418 } | 1421 } |
| 1419 Builder builder; | 1422 Builder builder; |
| 1420 if (prefix is Builder) { | 1423 if (prefix is Builder) { |
| 1421 builder = prefix; | 1424 builder = prefix; |
| 1422 } else { | 1425 } else { |
| 1423 builder = scope.lookup(prefix, beginToken.charOffset, uri); | 1426 builder = scope.lookup(prefix, beginToken.charOffset, uri); |
| 1424 } | 1427 } |
| 1425 if (builder is PrefixBuilder) { | 1428 if (builder is PrefixBuilder) { |
| 1426 name = scopeLookup(builder.exports, suffix, beginToken.charOffset, | 1429 name = scopeLookup(builder.exports, suffix, beginToken, |
| 1427 isQualified: true, prefix: builder); | 1430 isQualified: true, prefix: builder); |
| 1428 } else { | 1431 } else { |
| 1429 push(const DynamicType()); | 1432 push(const DynamicType()); |
| 1430 addCompileTimeError(beginToken.charOffset, | 1433 addCompileTimeError(beginToken.charOffset, |
| 1431 "Can't be used as a type: '${debugName(prefix, suffix)}'."); | 1434 "Can't be used as a type: '${debugName(prefix, suffix)}'."); |
| 1432 return; | 1435 return; |
| 1433 } | 1436 } |
| 1434 } | 1437 } |
| 1435 if (name is Identifier) { | 1438 if (name is Identifier) { |
| 1436 name = name.name; | 1439 name = name.name; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1481 push(new AsExpression(expression, type)..fileOffset = operator.charOffset); | 1484 push(new AsExpression(expression, type)..fileOffset = operator.charOffset); |
| 1482 } | 1485 } |
| 1483 | 1486 |
| 1484 @override | 1487 @override |
| 1485 void handleIsOperator(Token operator, Token not, Token endToken) { | 1488 void handleIsOperator(Token operator, Token not, Token endToken) { |
| 1486 debugEvent("IsOperator"); | 1489 debugEvent("IsOperator"); |
| 1487 DartType type = pop(); | 1490 DartType type = pop(); |
| 1488 Expression operand = popForValue(); | 1491 Expression operand = popForValue(); |
| 1489 bool isInverted = not != null; | 1492 bool isInverted = not != null; |
| 1490 Expression isExpression = | 1493 Expression isExpression = |
| 1491 astFactory.isExpression(operand, type, operator.charOffset, isInverted); | 1494 astFactory.isExpression(operand, type, operator, isInverted); |
| 1492 if (operand is VariableGet) { | 1495 if (operand is VariableGet) { |
| 1493 typePromoter.handleIsCheck(isExpression, isInverted, operand.variable, | 1496 typePromoter.handleIsCheck(isExpression, isInverted, operand.variable, |
| 1494 type, functionNestingLevel); | 1497 type, functionNestingLevel); |
| 1495 } | 1498 } |
| 1496 push(isExpression); | 1499 push(isExpression); |
| 1497 } | 1500 } |
| 1498 | 1501 |
| 1499 @override | 1502 @override |
| 1500 void handleConditionalExpression(Token question, Token colon) { | 1503 void handleConditionalExpression(Token question, Token colon) { |
| 1501 debugEvent("ConditionalExpression"); | 1504 debugEvent("ConditionalExpression"); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1555 variable = builder.build(library); | 1558 variable = builder.build(library); |
| 1556 variable.initializer = name.initializer; | 1559 variable.initializer = name.initializer; |
| 1557 } else if (builder.isField && builder.parent == classBuilder) { | 1560 } else if (builder.isField && builder.parent == classBuilder) { |
| 1558 FieldBuilder field = builder; | 1561 FieldBuilder field = builder; |
| 1559 if (type != null) { | 1562 if (type != null) { |
| 1560 nit("Ignoring type on 'this' parameter '${name.name}'.", | 1563 nit("Ignoring type on 'this' parameter '${name.name}'.", |
| 1561 thisKeyword.charOffset); | 1564 thisKeyword.charOffset); |
| 1562 } | 1565 } |
| 1563 type = field.target.type ?? const DynamicType(); | 1566 type = field.target.type ?? const DynamicType(); |
| 1564 variable = astFactory.variableDeclaration( | 1567 variable = astFactory.variableDeclaration( |
| 1565 name.name, name.fileOffset, functionNestingLevel, | 1568 name.name, name.token, functionNestingLevel, |
| 1566 type: type, | 1569 type: type, |
| 1567 initializer: name.initializer, | 1570 initializer: name.initializer, |
| 1568 isFinal: isFinal, | 1571 isFinal: isFinal, |
| 1569 isConst: isConst); | 1572 isConst: isConst); |
| 1570 } else { | 1573 } else { |
| 1571 addCompileTimeError( | 1574 addCompileTimeError(offsetForToken(name.token), |
| 1572 name.fileOffset, "'${name.name}' isn't a field in this class."); | 1575 "'${name.name}' isn't a field in this class."); |
| 1573 } | 1576 } |
| 1574 } | 1577 } |
| 1575 variable ??= astFactory.variableDeclaration( | 1578 variable ??= astFactory.variableDeclaration( |
| 1576 name.name, name.fileOffset, functionNestingLevel, | 1579 name.name, name.token, functionNestingLevel, |
| 1577 type: type ?? const DynamicType(), | 1580 type: type ?? const DynamicType(), |
| 1578 initializer: name.initializer, | 1581 initializer: name.initializer, |
| 1579 isFinal: isFinal, | 1582 isFinal: isFinal, |
| 1580 isConst: isConst); | 1583 isConst: isConst); |
| 1581 push(variable); | 1584 push(variable); |
| 1582 } | 1585 } |
| 1583 | 1586 |
| 1584 @override | 1587 @override |
| 1585 void endOptionalFormalParameters( | 1588 void endOptionalFormalParameters( |
| 1586 int count, Token beginToken, Token endToken) { | 1589 int count, Token beginToken, Token endToken) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1611 push(formals.toFunctionType(returnType)); | 1614 push(formals.toFunctionType(returnType)); |
| 1612 push(name); | 1615 push(name); |
| 1613 functionNestingLevel--; | 1616 functionNestingLevel--; |
| 1614 } | 1617 } |
| 1615 | 1618 |
| 1616 @override | 1619 @override |
| 1617 void handleValuedFormalParameter(Token equals, Token token) { | 1620 void handleValuedFormalParameter(Token equals, Token token) { |
| 1618 debugEvent("ValuedFormalParameter"); | 1621 debugEvent("ValuedFormalParameter"); |
| 1619 Expression initializer = popForValue(); | 1622 Expression initializer = popForValue(); |
| 1620 Identifier name = pop(); | 1623 Identifier name = pop(); |
| 1621 push(new InitializedIdentifier(name.name, initializer, name.fileOffset)); | 1624 push(new InitializedIdentifier(name.token, initializer)); |
| 1622 } | 1625 } |
| 1623 | 1626 |
| 1624 @override | 1627 @override |
| 1625 void handleFormalParameterWithoutValue(Token token) { | 1628 void handleFormalParameterWithoutValue(Token token) { |
| 1626 debugEvent("FormalParameterWithoutValue"); | 1629 debugEvent("FormalParameterWithoutValue"); |
| 1627 } | 1630 } |
| 1628 | 1631 |
| 1629 @override | 1632 @override |
| 1630 void endFormalParameters(int count, Token beginToken, Token endToken) { | 1633 void endFormalParameters(int count, Token beginToken, Token endToken) { |
| 1631 debugEvent("FormalParameters"); | 1634 debugEvent("FormalParameters"); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1713 push(NullValue.Expression); | 1716 push(NullValue.Expression); |
| 1714 } | 1717 } |
| 1715 | 1718 |
| 1716 @override | 1719 @override |
| 1717 void handleIndexedExpression( | 1720 void handleIndexedExpression( |
| 1718 Token openCurlyBracket, Token closeCurlyBracket) { | 1721 Token openCurlyBracket, Token closeCurlyBracket) { |
| 1719 debugEvent("IndexedExpression"); | 1722 debugEvent("IndexedExpression"); |
| 1720 Expression index = popForValue(); | 1723 Expression index = popForValue(); |
| 1721 var receiver = pop(); | 1724 var receiver = pop(); |
| 1722 if (receiver is ThisAccessor && receiver.isSuper) { | 1725 if (receiver is ThisAccessor && receiver.isSuper) { |
| 1723 push(new SuperIndexAccessor(this, receiver.offset, index, | 1726 push(new SuperIndexAccessor(this, receiver.token, index, |
| 1724 lookupSuperMember(indexGetName), lookupSuperMember(indexSetName))); | 1727 lookupSuperMember(indexGetName), lookupSuperMember(indexSetName))); |
| 1725 } else { | 1728 } else { |
| 1726 push(IndexAccessor.make(this, openCurlyBracket.charOffset, | 1729 push(IndexAccessor.make( |
| 1727 toValue(receiver), index, null, null)); | 1730 this, openCurlyBracket, toValue(receiver), index, null, null)); |
| 1728 } | 1731 } |
| 1729 } | 1732 } |
| 1730 | 1733 |
| 1731 @override | 1734 @override |
| 1732 void handleUnaryPrefixExpression(Token token) { | 1735 void handleUnaryPrefixExpression(Token token) { |
| 1733 debugEvent("UnaryPrefixExpression"); | 1736 debugEvent("UnaryPrefixExpression"); |
| 1734 var receiver = pop(); | 1737 var receiver = pop(); |
| 1735 if (optional("!", token)) { | 1738 if (optional("!", token)) { |
| 1736 push(new Not(toValue(receiver))); | 1739 push(new Not(toValue(receiver))); |
| 1737 } else { | 1740 } else { |
| 1738 String operator = token.stringValue; | 1741 String operator = token.stringValue; |
| 1739 if (optional("-", token)) { | 1742 if (optional("-", token)) { |
| 1740 operator = "unary-"; | 1743 operator = "unary-"; |
| 1741 } | 1744 } |
| 1742 if (receiver is ThisAccessor && receiver.isSuper) { | 1745 if (receiver is ThisAccessor && receiver.isSuper) { |
| 1743 push(toSuperMethodInvocation(buildMethodInvocation( | 1746 push(toSuperMethodInvocation(buildMethodInvocation( |
| 1744 new ThisExpression()..fileOffset = receiver.offset, | 1747 new ThisExpression()..fileOffset = offsetForToken(receiver.token), |
| 1745 new Name(operator), | 1748 new Name(operator), |
| 1746 new Arguments.empty(), | 1749 new Arguments.empty(), |
| 1747 token.charOffset))); | 1750 token.charOffset))); |
| 1748 } else { | 1751 } else { |
| 1749 push(buildMethodInvocation(toValue(receiver), new Name(operator), | 1752 push(buildMethodInvocation(toValue(receiver), new Name(operator), |
| 1750 new Arguments.empty(), token.charOffset)); | 1753 new Arguments.empty(), token.charOffset)); |
| 1751 } | 1754 } |
| 1752 } | 1755 } |
| 1753 } | 1756 } |
| 1754 | 1757 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1769 push(wrapInvalid(toValue(accessor))); | 1772 push(wrapInvalid(toValue(accessor))); |
| 1770 } | 1773 } |
| 1771 } | 1774 } |
| 1772 | 1775 |
| 1773 @override | 1776 @override |
| 1774 void handleUnaryPostfixAssignmentExpression(Token token) { | 1777 void handleUnaryPostfixAssignmentExpression(Token token) { |
| 1775 debugEvent("UnaryPostfixAssignmentExpression"); | 1778 debugEvent("UnaryPostfixAssignmentExpression"); |
| 1776 var accessor = pop(); | 1779 var accessor = pop(); |
| 1777 if (accessor is FastaAccessor) { | 1780 if (accessor is FastaAccessor) { |
| 1778 push(new DelayedPostfixIncrement( | 1781 push(new DelayedPostfixIncrement( |
| 1779 this, token.charOffset, accessor, incrementOperator(token), null)); | 1782 this, token, accessor, incrementOperator(token), null)); |
| 1780 } else { | 1783 } else { |
| 1781 push(wrapInvalid(toValue(accessor))); | 1784 push(wrapInvalid(toValue(accessor))); |
| 1782 } | 1785 } |
| 1783 } | 1786 } |
| 1784 | 1787 |
| 1785 @override | 1788 @override |
| 1786 void endConstructorReference( | 1789 void endConstructorReference( |
| 1787 Token start, Token periodBeforeName, Token endToken) { | 1790 Token start, Token periodBeforeName, Token endToken) { |
| 1788 debugEvent("ConstructorReference"); | 1791 debugEvent("ConstructorReference"); |
| 1789 // A constructor reference can contain up to three identifiers: | 1792 // A constructor reference can contain up to three identifiers: |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1806 // ClassBuilder, or a ThisPropertyAccessor. Otherwise, it's an error that | 1809 // ClassBuilder, or a ThisPropertyAccessor. Otherwise, it's an error that |
| 1807 // should be handled later. | 1810 // should be handled later. |
| 1808 Identifier suffix = popIfNotNull(periodBeforeName); | 1811 Identifier suffix = popIfNotNull(periodBeforeName); |
| 1809 Identifier identifier; | 1812 Identifier identifier; |
| 1810 List<DartType> typeArguments = pop(); | 1813 List<DartType> typeArguments = pop(); |
| 1811 dynamic type = pop(); | 1814 dynamic type = pop(); |
| 1812 if (type is List) { | 1815 if (type is List) { |
| 1813 var prefix = type[0]; | 1816 var prefix = type[0]; |
| 1814 identifier = type[1]; | 1817 identifier = type[1]; |
| 1815 if (prefix is PrefixBuilder) { | 1818 if (prefix is PrefixBuilder) { |
| 1816 type = scopeLookup(prefix.exports, identifier.name, start.charOffset, | 1819 type = scopeLookup(prefix.exports, identifier.name, start, |
| 1817 isQualified: true, prefix: prefix); | 1820 isQualified: true, prefix: prefix); |
| 1818 identifier = null; | 1821 identifier = null; |
| 1819 } else if (prefix is ClassBuilder) { | 1822 } else if (prefix is ClassBuilder) { |
| 1820 type = prefix; | 1823 type = prefix; |
| 1821 } else { | 1824 } else { |
| 1822 type = new Identifier(start.lexeme, start.charOffset); | 1825 type = new Identifier(start); |
| 1823 } | 1826 } |
| 1824 } | 1827 } |
| 1825 String name; | 1828 String name; |
| 1826 if (identifier != null && suffix != null) { | 1829 if (identifier != null && suffix != null) { |
| 1827 name = "${identifier.name}.${suffix.name}"; | 1830 name = "${identifier.name}.${suffix.name}"; |
| 1828 } else if (identifier != null) { | 1831 } else if (identifier != null) { |
| 1829 name = identifier.name; | 1832 name = identifier.name; |
| 1830 } else if (suffix != null) { | 1833 } else if (suffix != null) { |
| 1831 name = suffix.name; | 1834 name = suffix.name; |
| 1832 } else { | 1835 } else { |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1996 @override | 1999 @override |
| 1997 void endTypeArguments(int count, Token beginToken, Token endToken) { | 2000 void endTypeArguments(int count, Token beginToken, Token endToken) { |
| 1998 debugEvent("TypeArguments"); | 2001 debugEvent("TypeArguments"); |
| 1999 push(popList(count)); | 2002 push(popList(count)); |
| 2000 } | 2003 } |
| 2001 | 2004 |
| 2002 @override | 2005 @override |
| 2003 void handleThisExpression(Token token, IdentifierContext context) { | 2006 void handleThisExpression(Token token, IdentifierContext context) { |
| 2004 debugEvent("ThisExpression"); | 2007 debugEvent("ThisExpression"); |
| 2005 if (context.isScopeReference && isInstanceContext) { | 2008 if (context.isScopeReference && isInstanceContext) { |
| 2006 push(new ThisAccessor(this, token.charOffset, inInitializer)); | 2009 push(new ThisAccessor(this, token, inInitializer)); |
| 2007 } else { | 2010 } else { |
| 2008 push(new IncompleteError( | 2011 push(new IncompleteError( |
| 2009 this, token.charOffset, "Expected identifier, but got 'this'.")); | 2012 this, token, "Expected identifier, but got 'this'.")); |
| 2010 } | 2013 } |
| 2011 } | 2014 } |
| 2012 | 2015 |
| 2013 @override | 2016 @override |
| 2014 void handleSuperExpression(Token token, IdentifierContext context) { | 2017 void handleSuperExpression(Token token, IdentifierContext context) { |
| 2015 debugEvent("SuperExpression"); | 2018 debugEvent("SuperExpression"); |
| 2016 if (context.isScopeReference && isInstanceContext) { | 2019 if (context.isScopeReference && isInstanceContext) { |
| 2017 Member member = this.member.target; | 2020 Member member = this.member.target; |
| 2018 member.transformerFlags |= TransformerFlag.superCalls; | 2021 member.transformerFlags |= TransformerFlag.superCalls; |
| 2019 push(new ThisAccessor(this, token.charOffset, inInitializer, | 2022 push(new ThisAccessor(this, token, inInitializer, isSuper: true)); |
| 2020 isSuper: true)); | |
| 2021 } else { | 2023 } else { |
| 2022 push(new IncompleteError( | 2024 push(new IncompleteError( |
| 2023 this, token.charOffset, "Expected identifier, but got 'super'.")); | 2025 this, token, "Expected identifier, but got 'super'.")); |
| 2024 } | 2026 } |
| 2025 } | 2027 } |
| 2026 | 2028 |
| 2027 @override | 2029 @override |
| 2028 void handleNamedArgument(Token colon) { | 2030 void handleNamedArgument(Token colon) { |
| 2029 debugEvent("NamedArgument"); | 2031 debugEvent("NamedArgument"); |
| 2030 Expression value = popForValue(); | 2032 Expression value = popForValue(); |
| 2031 Identifier identifier = pop(); | 2033 Identifier identifier = pop(); |
| 2032 push(new NamedExpression(identifier.name, value)); | 2034 push(new NamedExpression(identifier.name, value)); |
| 2033 } | 2035 } |
| 2034 | 2036 |
| 2035 @override | 2037 @override |
| 2036 void endFunctionName(Token beginToken, Token token) { | 2038 void endFunctionName(Token beginToken, Token token) { |
| 2037 debugEvent("FunctionName"); | 2039 debugEvent("FunctionName"); |
| 2038 Identifier name = pop(); | 2040 Identifier name = pop(); |
| 2039 VariableDeclaration variable = astFactory.variableDeclaration( | 2041 VariableDeclaration variable = astFactory.variableDeclaration( |
| 2040 name.name, name.fileOffset, functionNestingLevel, | 2042 name.name, name.token, functionNestingLevel, |
| 2041 isFinal: true); | 2043 isFinal: true); |
| 2042 push(new FunctionDeclaration( | 2044 push(new FunctionDeclaration( |
| 2043 variable, new FunctionNode(new InvalidStatement())) | 2045 variable, new FunctionNode(new InvalidStatement())) |
| 2044 ..fileOffset = beginToken.charOffset); | 2046 ..fileOffset = beginToken.charOffset); |
| 2045 scope[variable.name] = new KernelVariableBuilder( | 2047 scope[variable.name] = new KernelVariableBuilder( |
| 2046 variable, member ?? classBuilder ?? library, uri); | 2048 variable, member ?? classBuilder ?? library, uri); |
| 2047 enterLocalScope(); | 2049 enterLocalScope(); |
| 2048 } | 2050 } |
| 2049 | 2051 |
| 2050 void enterFunction() { | 2052 void enterFunction() { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2111 Statement body = popStatement(); | 2113 Statement body = popStatement(); |
| 2112 AsyncMarker asyncModifier = pop(); | 2114 AsyncMarker asyncModifier = pop(); |
| 2113 exitLocalScope(); | 2115 exitLocalScope(); |
| 2114 FormalParameters formals = pop(); | 2116 FormalParameters formals = pop(); |
| 2115 exitFunction(); | 2117 exitFunction(); |
| 2116 List<TypeParameter> typeParameters = pop(); | 2118 List<TypeParameter> typeParameters = pop(); |
| 2117 FunctionNode function = formals.addToFunction(new FunctionNode(body, | 2119 FunctionNode function = formals.addToFunction(new FunctionNode(body, |
| 2118 typeParameters: typeParameters, asyncMarker: asyncModifier) | 2120 typeParameters: typeParameters, asyncMarker: asyncModifier) |
| 2119 ..fileOffset = beginToken.charOffset | 2121 ..fileOffset = beginToken.charOffset |
| 2120 ..fileEndOffset = token.charOffset); | 2122 ..fileEndOffset = token.charOffset); |
| 2121 push(astFactory.functionExpression(function, beginToken.charOffset)); | 2123 push(astFactory.functionExpression(function, beginToken)); |
| 2122 } | 2124 } |
| 2123 | 2125 |
| 2124 @override | 2126 @override |
| 2125 void endDoWhileStatement( | 2127 void endDoWhileStatement( |
| 2126 Token doKeyword, Token whileKeyword, Token endToken) { | 2128 Token doKeyword, Token whileKeyword, Token endToken) { |
| 2127 debugEvent("DoWhileStatement"); | 2129 debugEvent("DoWhileStatement"); |
| 2128 Expression condition = popForValue(); | 2130 Expression condition = popForValue(); |
| 2129 Statement body = popStatement(); | 2131 Statement body = popStatement(); |
| 2130 JumpTarget continueTarget = exitContinueTarget(); | 2132 JumpTarget continueTarget = exitContinueTarget(); |
| 2131 JumpTarget breakTarget = exitBreakTarget(); | 2133 JumpTarget breakTarget = exitBreakTarget(); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2341 | 2343 |
| 2342 @override | 2344 @override |
| 2343 void handleSwitchCase( | 2345 void handleSwitchCase( |
| 2344 int labelCount, | 2346 int labelCount, |
| 2345 int expressionCount, | 2347 int expressionCount, |
| 2346 Token defaultKeyword, | 2348 Token defaultKeyword, |
| 2347 int statementCount, | 2349 int statementCount, |
| 2348 Token firstToken, | 2350 Token firstToken, |
| 2349 Token endToken) { | 2351 Token endToken) { |
| 2350 debugEvent("SwitchCase"); | 2352 debugEvent("SwitchCase"); |
| 2351 Block block = popBlock(statementCount, firstToken.charOffset); | 2353 Block block = popBlock(statementCount, firstToken); |
| 2352 exitLocalScope(); | 2354 exitLocalScope(); |
| 2353 List<Label> labels = pop(); | 2355 List<Label> labels = pop(); |
| 2354 List<Expression> expressions = pop(); | 2356 List<Expression> expressions = pop(); |
| 2355 List<int> expressionOffsets = <int>[]; | 2357 List<int> expressionOffsets = <int>[]; |
| 2356 for (Expression expression in expressions) { | 2358 for (Expression expression in expressions) { |
| 2357 expressionOffsets.add(expression.fileOffset); | 2359 expressionOffsets.add(expression.fileOffset); |
| 2358 } | 2360 } |
| 2359 push(new SwitchCase(expressions, expressionOffsets, block, | 2361 push(new SwitchCase(expressions, expressionOffsets, block, |
| 2360 isDefault: defaultKeyword != null) | 2362 isDefault: defaultKeyword != null) |
| 2361 ..fileOffset = firstToken.charOffset); | 2363 ..fileOffset = firstToken.charOffset); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2447 push(compileTimeErrorInLoopOrSwitch = buildCompileTimeErrorStatement( | 2449 push(compileTimeErrorInLoopOrSwitch = buildCompileTimeErrorStatement( |
| 2448 "Target of continue must be a label.", continueKeyword.charOffset)); | 2450 "Target of continue must be a label.", continueKeyword.charOffset)); |
| 2449 return; | 2451 return; |
| 2450 } | 2452 } |
| 2451 if (target == null) { | 2453 if (target == null) { |
| 2452 if (switchScope == null) { | 2454 if (switchScope == null) { |
| 2453 push(buildCompileTimeErrorStatement( | 2455 push(buildCompileTimeErrorStatement( |
| 2454 "Can't find label '$name'.", continueKeyword.next.charOffset)); | 2456 "Can't find label '$name'.", continueKeyword.next.charOffset)); |
| 2455 return; | 2457 return; |
| 2456 } | 2458 } |
| 2457 switchScope.forwardDeclareLabel( | 2459 switchScope.forwardDeclareLabel(identifier.name, |
| 2458 identifier.name, target = createGotoTarget(identifier.fileOffset)); | 2460 target = createGotoTarget(offsetForToken(identifier.token))); |
| 2459 } | 2461 } |
| 2460 if (target.isGotoTarget && | 2462 if (target.isGotoTarget && |
| 2461 target.functionNestingLevel == functionNestingLevel) { | 2463 target.functionNestingLevel == functionNestingLevel) { |
| 2462 ContinueSwitchStatement statement = new ContinueSwitchStatement(null); | 2464 ContinueSwitchStatement statement = new ContinueSwitchStatement(null); |
| 2463 target.addGoto(statement); | 2465 target.addGoto(statement); |
| 2464 push(statement); | 2466 push(statement); |
| 2465 return; | 2467 return; |
| 2466 } | 2468 } |
| 2467 } | 2469 } |
| 2468 if (target == null) { | 2470 if (target == null) { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2592 | 2594 |
| 2593 @override | 2595 @override |
| 2594 void handleOperator(Token token) { | 2596 void handleOperator(Token token) { |
| 2595 debugEvent("Operator"); | 2597 debugEvent("Operator"); |
| 2596 push(new Operator(token.stringValue)..fileOffset = token.charOffset); | 2598 push(new Operator(token.stringValue)..fileOffset = token.charOffset); |
| 2597 } | 2599 } |
| 2598 | 2600 |
| 2599 @override | 2601 @override |
| 2600 void handleSymbolVoid(Token token) { | 2602 void handleSymbolVoid(Token token) { |
| 2601 debugEvent("SymbolVoid"); | 2603 debugEvent("SymbolVoid"); |
| 2602 push(new Identifier(token.stringValue, token.charOffset)); | 2604 push(new Identifier(token)); |
| 2603 } | 2605 } |
| 2604 | 2606 |
| 2605 dynamic addCompileTimeError(int charOffset, String message, | 2607 dynamic addCompileTimeError(int charOffset, String message, |
| 2606 {bool silent: false}) { | 2608 {bool silent: false}) { |
| 2607 // TODO(ahe): If constantExpressionRequired is set, set it to false to | 2609 // TODO(ahe): If constantExpressionRequired is set, set it to false to |
| 2608 // avoid a long list of errors. | 2610 // avoid a long list of errors. |
| 2609 return library.addCompileTimeError(charOffset, message, fileUri: uri); | 2611 return library.addCompileTimeError(charOffset, message, fileUri: uri); |
| 2610 } | 2612 } |
| 2611 | 2613 |
| 2612 @override | 2614 @override |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2646 } | 2648 } |
| 2647 return expression; | 2649 return expression; |
| 2648 } | 2650 } |
| 2649 | 2651 |
| 2650 @override | 2652 @override |
| 2651 void debugEvent(String name) { | 2653 void debugEvent(String name) { |
| 2652 // printEvent(name); | 2654 // printEvent(name); |
| 2653 } | 2655 } |
| 2654 | 2656 |
| 2655 @override | 2657 @override |
| 2656 StaticGet makeStaticGet(Member readTarget, int offset) { | 2658 StaticGet makeStaticGet(Member readTarget, Token token) { |
| 2657 // TODO(paulberry): only record the dependencies mandated by the top level | 2659 // TODO(paulberry): only record the dependencies mandated by the top level |
| 2658 // type inference spec. | 2660 // type inference spec. |
| 2659 if (fieldDependencies != null && readTarget is KernelField) { | 2661 if (fieldDependencies != null && readTarget is KernelField) { |
| 2660 var fieldNode = _typeInferrer.getFieldNodeForReadTarget(readTarget); | 2662 var fieldNode = _typeInferrer.getFieldNodeForReadTarget(readTarget); |
| 2661 if (fieldNode != null) { | 2663 if (fieldNode != null) { |
| 2662 fieldDependencies.add(fieldNode); | 2664 fieldDependencies.add(fieldNode); |
| 2663 } | 2665 } |
| 2664 } | 2666 } |
| 2665 return astFactory.staticGet(readTarget, offset); | 2667 return astFactory.staticGet(readTarget, token); |
| 2666 } | 2668 } |
| 2667 } | 2669 } |
| 2668 | 2670 |
| 2669 class Identifier { | 2671 class Identifier { |
| 2670 final String name; | 2672 final Token token; |
| 2671 final int fileOffset; | 2673 String get name => token.lexeme; |
| 2672 | 2674 |
| 2673 Identifier(this.name, int charOffset) : fileOffset = charOffset; | 2675 Identifier(this.token); |
| 2674 | 2676 |
| 2675 Expression get initializer => null; | 2677 Expression get initializer => null; |
| 2676 | 2678 |
| 2677 String toString() => "identifier($name)"; | 2679 String toString() => "identifier($name)"; |
| 2678 } | 2680 } |
| 2679 | 2681 |
| 2680 // TODO(ahe): Shouldn't need to be an expression. | 2682 // TODO(ahe): Shouldn't need to be an expression. |
| 2681 class Operator extends InvalidExpression { | 2683 class Operator extends InvalidExpression { |
| 2682 final String name; | 2684 final String name; |
| 2683 | 2685 |
| 2684 Operator(this.name); | 2686 Operator(this.name); |
| 2685 | 2687 |
| 2686 String toString() => "operator($name)"; | 2688 String toString() => "operator($name)"; |
| 2687 } | 2689 } |
| 2688 | 2690 |
| 2689 class InitializedIdentifier extends Identifier { | 2691 class InitializedIdentifier extends Identifier { |
| 2690 final Expression initializer; | 2692 final Expression initializer; |
| 2691 | 2693 |
| 2692 InitializedIdentifier(String name, this.initializer, int charOffset) | 2694 InitializedIdentifier(Token token, this.initializer) : super(token); |
| 2693 : super(name, charOffset); | |
| 2694 | 2695 |
| 2695 String toString() => "initialized-identifier($name, $initializer)"; | 2696 String toString() => "initialized-identifier($name, $initializer)"; |
| 2696 } | 2697 } |
| 2697 | 2698 |
| 2698 // TODO(ahe): Shouldn't need to be an expression. | 2699 // TODO(ahe): Shouldn't need to be an expression. |
| 2699 class Label extends InvalidExpression { | 2700 class Label extends InvalidExpression { |
| 2700 String name; | 2701 String name; |
| 2701 | 2702 |
| 2702 Label(this.name); | 2703 Label(this.name); |
| 2703 | 2704 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2730 nextCascade.variable.initializer = expression; | 2731 nextCascade.variable.initializer = expression; |
| 2731 expression.parent = nextCascade.variable; | 2732 expression.parent = nextCascade.variable; |
| 2732 } | 2733 } |
| 2733 } | 2734 } |
| 2734 | 2735 |
| 2735 abstract class ContextAccessor extends FastaAccessor { | 2736 abstract class ContextAccessor extends FastaAccessor { |
| 2736 final BuilderHelper helper; | 2737 final BuilderHelper helper; |
| 2737 | 2738 |
| 2738 final FastaAccessor accessor; | 2739 final FastaAccessor accessor; |
| 2739 | 2740 |
| 2740 final int offset; | 2741 final Token token; |
| 2741 | 2742 |
| 2742 ContextAccessor(this.helper, this.offset, this.accessor); | 2743 ContextAccessor(this.helper, this.token, this.accessor); |
| 2743 | 2744 |
| 2744 @override | 2745 @override |
| 2745 Expression get builtBinary => internalError("Unsupported operation."); | 2746 Expression get builtBinary => internalError("Unsupported operation."); |
| 2746 | 2747 |
| 2747 @override | 2748 @override |
| 2748 void set builtBinary(Expression expression) { | 2749 void set builtBinary(Expression expression) { |
| 2749 internalError("Unsupported operation."); | 2750 internalError("Unsupported operation."); |
| 2750 } | 2751 } |
| 2751 | 2752 |
| 2752 @override | 2753 @override |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2794 {int offset: TreeNode.noOffset, | 2795 {int offset: TreeNode.noOffset, |
| 2795 bool voidContext: false, | 2796 bool voidContext: false, |
| 2796 Procedure interfaceTarget}) { | 2797 Procedure interfaceTarget}) { |
| 2797 return makeInvalidWrite(null); | 2798 return makeInvalidWrite(null); |
| 2798 } | 2799 } |
| 2799 | 2800 |
| 2800 makeInvalidRead() => internalError("not supported"); | 2801 makeInvalidRead() => internalError("not supported"); |
| 2801 | 2802 |
| 2802 Expression makeInvalidWrite(Expression value) { | 2803 Expression makeInvalidWrite(Expression value) { |
| 2803 return helper.buildCompileTimeError( | 2804 return helper.buildCompileTimeError( |
| 2804 "Can't be used as left-hand side of assignment.", offset); | 2805 "Can't be used as left-hand side of assignment.", |
| 2806 offsetForToken(token)); |
| 2805 } | 2807 } |
| 2806 } | 2808 } |
| 2807 | 2809 |
| 2808 class DelayedAssignment extends ContextAccessor { | 2810 class DelayedAssignment extends ContextAccessor { |
| 2809 final Expression value; | 2811 final Expression value; |
| 2810 | 2812 |
| 2811 final String assignmentOperator; | 2813 final String assignmentOperator; |
| 2812 | 2814 |
| 2813 DelayedAssignment(BuilderHelper helper, int charOffset, | 2815 DelayedAssignment(BuilderHelper helper, Token token, FastaAccessor accessor, |
| 2814 FastaAccessor accessor, this.value, this.assignmentOperator) | 2816 this.value, this.assignmentOperator) |
| 2815 : super(helper, charOffset, accessor); | 2817 : super(helper, token, accessor); |
| 2816 | 2818 |
| 2817 Expression buildSimpleRead() { | 2819 Expression buildSimpleRead() { |
| 2818 return handleAssignment(false); | 2820 return handleAssignment(false); |
| 2819 } | 2821 } |
| 2820 | 2822 |
| 2821 Expression buildForEffect() { | 2823 Expression buildForEffect() { |
| 2822 return handleAssignment(true); | 2824 return handleAssignment(true); |
| 2823 } | 2825 } |
| 2824 | 2826 |
| 2825 Expression handleAssignment(bool voidContext) { | 2827 Expression handleAssignment(bool voidContext) { |
| 2826 if (identical("=", assignmentOperator)) { | 2828 if (identical("=", assignmentOperator)) { |
| 2827 return accessor.buildAssignment(value, voidContext: voidContext); | 2829 return accessor.buildAssignment(value, voidContext: voidContext); |
| 2828 } else if (identical("+=", assignmentOperator)) { | 2830 } else if (identical("+=", assignmentOperator)) { |
| 2829 return accessor.buildCompoundAssignment(plusName, value, | 2831 return accessor.buildCompoundAssignment(plusName, value, |
| 2830 offset: offset, voidContext: voidContext); | 2832 offset: offsetForToken(token), voidContext: voidContext); |
| 2831 } else if (identical("-=", assignmentOperator)) { | 2833 } else if (identical("-=", assignmentOperator)) { |
| 2832 return accessor.buildCompoundAssignment(minusName, value, | 2834 return accessor.buildCompoundAssignment(minusName, value, |
| 2833 offset: offset, voidContext: voidContext); | 2835 offset: offsetForToken(token), voidContext: voidContext); |
| 2834 } else if (identical("*=", assignmentOperator)) { | 2836 } else if (identical("*=", assignmentOperator)) { |
| 2835 return accessor.buildCompoundAssignment(multiplyName, value, | 2837 return accessor.buildCompoundAssignment(multiplyName, value, |
| 2836 offset: offset, voidContext: voidContext); | 2838 offset: offsetForToken(token), voidContext: voidContext); |
| 2837 } else if (identical("%=", assignmentOperator)) { | 2839 } else if (identical("%=", assignmentOperator)) { |
| 2838 return accessor.buildCompoundAssignment(percentName, value, | 2840 return accessor.buildCompoundAssignment(percentName, value, |
| 2839 offset: offset, voidContext: voidContext); | 2841 offset: offsetForToken(token), voidContext: voidContext); |
| 2840 } else if (identical("&=", assignmentOperator)) { | 2842 } else if (identical("&=", assignmentOperator)) { |
| 2841 return accessor.buildCompoundAssignment(ampersandName, value, | 2843 return accessor.buildCompoundAssignment(ampersandName, value, |
| 2842 offset: offset, voidContext: voidContext); | 2844 offset: offsetForToken(token), voidContext: voidContext); |
| 2843 } else if (identical("/=", assignmentOperator)) { | 2845 } else if (identical("/=", assignmentOperator)) { |
| 2844 return accessor.buildCompoundAssignment(divisionName, value, | 2846 return accessor.buildCompoundAssignment(divisionName, value, |
| 2845 offset: offset, voidContext: voidContext); | 2847 offset: offsetForToken(token), voidContext: voidContext); |
| 2846 } else if (identical("<<=", assignmentOperator)) { | 2848 } else if (identical("<<=", assignmentOperator)) { |
| 2847 return accessor.buildCompoundAssignment(leftShiftName, value, | 2849 return accessor.buildCompoundAssignment(leftShiftName, value, |
| 2848 offset: offset, voidContext: voidContext); | 2850 offset: offsetForToken(token), voidContext: voidContext); |
| 2849 } else if (identical(">>=", assignmentOperator)) { | 2851 } else if (identical(">>=", assignmentOperator)) { |
| 2850 return accessor.buildCompoundAssignment(rightShiftName, value, | 2852 return accessor.buildCompoundAssignment(rightShiftName, value, |
| 2851 offset: offset, voidContext: voidContext); | 2853 offset: offsetForToken(token), voidContext: voidContext); |
| 2852 } else if (identical("??=", assignmentOperator)) { | 2854 } else if (identical("??=", assignmentOperator)) { |
| 2853 return accessor.buildNullAwareAssignment(value, const DynamicType(), | 2855 return accessor.buildNullAwareAssignment(value, const DynamicType(), |
| 2854 voidContext: voidContext); | 2856 voidContext: voidContext); |
| 2855 } else if (identical("^=", assignmentOperator)) { | 2857 } else if (identical("^=", assignmentOperator)) { |
| 2856 return accessor.buildCompoundAssignment(caretName, value, | 2858 return accessor.buildCompoundAssignment(caretName, value, |
| 2857 offset: offset, voidContext: voidContext); | 2859 offset: offsetForToken(token), voidContext: voidContext); |
| 2858 } else if (identical("|=", assignmentOperator)) { | 2860 } else if (identical("|=", assignmentOperator)) { |
| 2859 return accessor.buildCompoundAssignment(barName, value, | 2861 return accessor.buildCompoundAssignment(barName, value, |
| 2860 offset: offset, voidContext: voidContext); | 2862 offset: offsetForToken(token), voidContext: voidContext); |
| 2861 } else if (identical("~/=", assignmentOperator)) { | 2863 } else if (identical("~/=", assignmentOperator)) { |
| 2862 return accessor.buildCompoundAssignment(mustacheName, value, | 2864 return accessor.buildCompoundAssignment(mustacheName, value, |
| 2863 offset: offset, voidContext: voidContext); | 2865 offset: offsetForToken(token), voidContext: voidContext); |
| 2864 } else { | 2866 } else { |
| 2865 return internalError("Unhandled: $assignmentOperator"); | 2867 return internalError("Unhandled: $assignmentOperator"); |
| 2866 } | 2868 } |
| 2867 } | 2869 } |
| 2868 | 2870 |
| 2869 Initializer buildFieldInitializer( | 2871 Initializer buildFieldInitializer( |
| 2870 Map<String, FieldInitializer> initializers) { | 2872 Map<String, FieldInitializer> initializers) { |
| 2871 if (!identical("=", assignmentOperator) || | 2873 if (!identical("=", assignmentOperator) || |
| 2872 !accessor.isThisPropertyAccessor) { | 2874 !accessor.isThisPropertyAccessor) { |
| 2873 return accessor.buildFieldInitializer(initializers); | 2875 return accessor.buildFieldInitializer(initializers); |
| 2874 } | 2876 } |
| 2875 String name = accessor.plainNameForRead; | 2877 String name = accessor.plainNameForRead; |
| 2876 FieldInitializer initializer = initializers[name]; | 2878 FieldInitializer initializer = initializers[name]; |
| 2877 if (initializer != null && initializer.value == null) { | 2879 if (initializer != null && initializer.value == null) { |
| 2878 initializers.remove(name); | 2880 initializers.remove(name); |
| 2879 initializer.value = value..parent = initializer; | 2881 initializer.value = value..parent = initializer; |
| 2880 return initializer; | 2882 return initializer; |
| 2881 } | 2883 } |
| 2882 return accessor.buildFieldInitializer(initializers); | 2884 return accessor.buildFieldInitializer(initializers); |
| 2883 } | 2885 } |
| 2884 } | 2886 } |
| 2885 | 2887 |
| 2886 class DelayedPostfixIncrement extends ContextAccessor { | 2888 class DelayedPostfixIncrement extends ContextAccessor { |
| 2887 final Name binaryOperator; | 2889 final Name binaryOperator; |
| 2888 | 2890 |
| 2889 final Procedure interfaceTarget; | 2891 final Procedure interfaceTarget; |
| 2890 | 2892 |
| 2891 DelayedPostfixIncrement(BuilderHelper helper, int offset, | 2893 DelayedPostfixIncrement(BuilderHelper helper, Token token, |
| 2892 FastaAccessor accessor, this.binaryOperator, this.interfaceTarget) | 2894 FastaAccessor accessor, this.binaryOperator, this.interfaceTarget) |
| 2893 : super(helper, offset, accessor); | 2895 : super(helper, token, accessor); |
| 2894 | 2896 |
| 2895 Expression buildSimpleRead() { | 2897 Expression buildSimpleRead() { |
| 2896 return accessor.buildPostfixIncrement(binaryOperator, | 2898 return accessor.buildPostfixIncrement(binaryOperator, |
| 2897 offset: offset, voidContext: false, interfaceTarget: interfaceTarget); | 2899 offset: offsetForToken(token), |
| 2900 voidContext: false, |
| 2901 interfaceTarget: interfaceTarget); |
| 2898 } | 2902 } |
| 2899 | 2903 |
| 2900 Expression buildForEffect() { | 2904 Expression buildForEffect() { |
| 2901 return accessor.buildPostfixIncrement(binaryOperator, | 2905 return accessor.buildPostfixIncrement(binaryOperator, |
| 2902 offset: offset, voidContext: true, interfaceTarget: interfaceTarget); | 2906 offset: offsetForToken(token), |
| 2907 voidContext: true, |
| 2908 interfaceTarget: interfaceTarget); |
| 2903 } | 2909 } |
| 2904 } | 2910 } |
| 2905 | 2911 |
| 2906 class JumpTarget extends Builder { | 2912 class JumpTarget extends Builder { |
| 2907 final List<Statement> users = <Statement>[]; | 2913 final List<Statement> users = <Statement>[]; |
| 2908 | 2914 |
| 2909 final JumpTargetKind kind; | 2915 final JumpTargetKind kind; |
| 2910 | 2916 |
| 2911 final int functionNestingLevel; | 2917 final int functionNestingLevel; |
| 2912 | 2918 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3123 } else if (node is PrefixBuilder) { | 3129 } else if (node is PrefixBuilder) { |
| 3124 return node.name; | 3130 return node.name; |
| 3125 } else if (node is ThisAccessor) { | 3131 } else if (node is ThisAccessor) { |
| 3126 return node.isSuper ? "super" : "this"; | 3132 return node.isSuper ? "super" : "this"; |
| 3127 } else if (node is FastaAccessor) { | 3133 } else if (node is FastaAccessor) { |
| 3128 return node.plainNameForRead; | 3134 return node.plainNameForRead; |
| 3129 } else { | 3135 } else { |
| 3130 return internalError("Unhandled: ${node.runtimeType}"); | 3136 return internalError("Unhandled: ${node.runtimeType}"); |
| 3131 } | 3137 } |
| 3132 } | 3138 } |
| OLD | NEW |