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

Side by Side Diff: pkg/analyzer/lib/src/fasta/ast_builder.dart

Issue 2930673002: Implement initializer asserts. (Closed)
Patch Set: Address comments and tweak error recovery. Created 3 years, 6 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/parser/node_listener.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.analyzer.ast_builder; 5 library fasta.analyzer.ast_builder;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory; 8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory;
9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard; 9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard;
10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token; 10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token;
11 import 'package:analyzer/dart/ast/token.dart' show Token, TokenType; 11 import 'package:analyzer/dart/ast/token.dart' show Token, TokenType;
12 import 'package:analyzer/dart/element/element.dart' show Element; 12 import 'package:analyzer/dart/element/element.dart' show Element;
13 import 'package:front_end/src/fasta/parser/parser.dart' 13 import 'package:front_end/src/fasta/parser/parser.dart'
14 show FormalParameterType, MemberKind, Parser; 14 show Assert, FormalParameterType, MemberKind, Parser;
15 import 'package:front_end/src/fasta/scanner/string_scanner.dart'; 15 import 'package:front_end/src/fasta/scanner/string_scanner.dart';
16 import 'package:front_end/src/fasta/scanner/token.dart' show CommentToken; 16 import 'package:front_end/src/fasta/scanner/token.dart' show CommentToken;
17 import 'package:front_end/src/scanner/token.dart' as analyzer; 17 import 'package:front_end/src/scanner/token.dart' as analyzer;
18 18
19 import 'package:front_end/src/fasta/errors.dart' show internalError; 19 import 'package:front_end/src/fasta/errors.dart' show internalError;
20 import 'package:front_end/src/fasta/fasta_codes.dart' 20 import 'package:front_end/src/fasta/fasta_codes.dart'
21 show FastaMessage, codeExpectedExpression, codeExpectedFunctionBody; 21 show FastaMessage, codeExpectedExpression, codeExpectedFunctionBody;
22 import 'package:front_end/src/fasta/kernel/kernel_builder.dart' 22 import 'package:front_end/src/fasta/kernel/kernel_builder.dart'
23 show Builder, KernelLibraryBuilder, ProcedureBuilder, Scope; 23 show Builder, KernelLibraryBuilder, ProcedureBuilder, Scope;
24 import 'package:front_end/src/fasta/parser/identifier_context.dart' 24 import 'package:front_end/src/fasta/parser/identifier_context.dart'
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 debugEvent("Type"); 675 debugEvent("Type");
676 TypeArgumentList arguments = pop(); 676 TypeArgumentList arguments = pop();
677 Identifier name = pop(); 677 Identifier name = pop();
678 // TODO(paulberry,ahe): what if the type doesn't resolve to a class 678 // TODO(paulberry,ahe): what if the type doesn't resolve to a class
679 // element? Try to share code with BodyBuilder.builderToFirstExpression. 679 // element? Try to share code with BodyBuilder.builderToFirstExpression.
680 KernelClassElement cls = name.staticElement; 680 KernelClassElement cls = name.staticElement;
681 push(ast.typeName(name, arguments)..type = cls?.rawType); 681 push(ast.typeName(name, arguments)..type = cls?.rawType);
682 } 682 }
683 683
684 @override 684 @override
685 void handleAssertStatement(Token assertKeyword, Token leftParenthesis, 685 void endAssert(Token assertKeyword, Assert kind, Token leftParenthesis,
686 Token comma, Token rightParenthesis, Token semicolon) { 686 Token comma, Token rightParenthesis, Token semicolon) {
687 debugEvent("AssertStatement"); 687 debugEvent("Assert");
688 Expression message = popIfNotNull(comma); 688 Expression message = popIfNotNull(comma);
689 Expression condition = pop(); 689 Expression condition = pop();
690 push(ast.assertStatement(assertKeyword, leftParenthesis, condition, comma, 690 push(ast.assertStatement(assertKeyword, leftParenthesis, condition, comma,
691 message, rightParenthesis, semicolon)); 691 message, rightParenthesis, semicolon));
692 } 692 }
693 693
694 void handleAsOperator(Token operator, Token endToken) { 694 void handleAsOperator(Token operator, Token endToken) {
695 debugEvent("AsOperator"); 695 debugEvent("AsOperator");
696 TypeAnnotation type = pop(); 696 TypeAnnotation type = pop();
697 Expression expression = pop(); 697 Expression expression = pop();
(...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after
2021 } else if (identical('var', s)) { 2021 } else if (identical('var', s)) {
2022 finalConstOrVarKeyword = token; 2022 finalConstOrVarKeyword = token;
2023 } else if (identical('covariant', s)) { 2023 } else if (identical('covariant', s)) {
2024 covariantKeyword = token; 2024 covariantKeyword = token;
2025 } else { 2025 } else {
2026 internalError('Unhandled modifier: $s'); 2026 internalError('Unhandled modifier: $s');
2027 } 2027 }
2028 } 2028 }
2029 } 2029 }
2030 } 2030 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/parser/node_listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698