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

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

Issue 2849293002: Infer types of bool/null/string literals. (Closed)
Patch Set: Created 3 years, 7 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'package:front_end/src/fasta/kernel/utils.dart'; 5 import 'package:front_end/src/fasta/kernel/utils.dart';
6 import 'package:front_end/src/fasta/scanner/token.dart' show Token; 6 import 'package:front_end/src/fasta/scanner/token.dart' show Token;
7 import 'package:front_end/src/fasta/type_inference/type_promotion.dart'; 7 import 'package:front_end/src/fasta/type_inference/type_promotion.dart';
8 import 'package:kernel/ast.dart'; 8 import 'package:kernel/ast.dart';
9 9
10 import '../builder/ast_factory.dart'; 10 import '../builder/ast_factory.dart';
11 import 'kernel_shadow_ast.dart'; 11 import 'kernel_shadow_ast.dart';
12 12
13 /// Concrete implementation of [builder.AstFactory] for building a kernel AST. 13 /// Concrete implementation of [builder.AstFactory] for building a kernel AST.
14 class KernelAstFactory implements AstFactory<VariableDeclaration> { 14 class KernelAstFactory implements AstFactory<VariableDeclaration> {
15 @override 15 @override
16 KernelBlock block(List<Statement> statements, Token beginToken) { 16 KernelBlock block(List<Statement> statements, Token beginToken) {
17 return new KernelBlock(statements)..fileOffset = offsetForToken(beginToken); 17 return new KernelBlock(statements)..fileOffset = offsetForToken(beginToken);
18 } 18 }
19 19
20 @override 20 @override
21 KernelBoolLiteral boolLiteral(bool value, Token token) {
22 return new KernelBoolLiteral(value)..fileOffset = offsetForToken(token);
23 }
24
25 @override
21 KernelDoubleLiteral doubleLiteral(double value, Token token) { 26 KernelDoubleLiteral doubleLiteral(double value, Token token) {
22 return new KernelDoubleLiteral(value)..fileOffset = offsetForToken(token); 27 return new KernelDoubleLiteral(value)..fileOffset = offsetForToken(token);
23 } 28 }
24 29
25 @override 30 @override
26 ExpressionStatement expressionStatement(Expression expression) { 31 ExpressionStatement expressionStatement(Expression expression) {
27 return new KernelExpressionStatement(expression); 32 return new KernelExpressionStatement(expression);
28 } 33 }
29 34
30 @override 35 @override
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 return new KernelReturnStatement(expression) 78 return new KernelReturnStatement(expression)
74 ..fileOffset = offsetForToken(token); 79 ..fileOffset = offsetForToken(token);
75 } 80 }
76 81
77 @override 82 @override
78 StaticGet staticGet(Member readTarget, Token token) { 83 StaticGet staticGet(Member readTarget, Token token) {
79 return new KernelStaticGet(readTarget)..fileOffset = offsetForToken(token); 84 return new KernelStaticGet(readTarget)..fileOffset = offsetForToken(token);
80 } 85 }
81 86
82 @override 87 @override
88 StringConcatenation stringConcatenation(
89 List<Expression> expressions, Token token) {
90 return new KernelStringConcatenation(expressions)
91 ..fileOffset = offsetForToken(token);
92 }
93
94 @override
95 StringLiteral stringLiteral(String value, Token token) {
96 return new KernelStringLiteral(value)..fileOffset = offsetForToken(token);
97 }
98
99 @override
83 VariableDeclaration variableDeclaration( 100 VariableDeclaration variableDeclaration(
84 String name, Token token, int functionNestingLevel, 101 String name, Token token, int functionNestingLevel,
85 {DartType type, 102 {DartType type,
86 Expression initializer, 103 Expression initializer,
87 Token equalsToken, 104 Token equalsToken,
88 bool isFinal: false, 105 bool isFinal: false,
89 bool isConst: false}) { 106 bool isConst: false}) {
90 return new KernelVariableDeclaration(name, functionNestingLevel, 107 return new KernelVariableDeclaration(name, functionNestingLevel,
91 type: type, 108 type: type,
92 initializer: initializer, 109 initializer: initializer,
93 isFinal: isFinal, 110 isFinal: isFinal,
94 isConst: isConst) 111 isConst: isConst)
95 ..fileOffset = offsetForToken(token) 112 ..fileOffset = offsetForToken(token)
96 ..fileEqualsOffset = offsetForToken(equalsToken); 113 ..fileEqualsOffset = offsetForToken(equalsToken);
97 } 114 }
98 115
99 @override 116 @override
100 VariableGet variableGet( 117 VariableGet variableGet(
101 VariableDeclaration variable, 118 VariableDeclaration variable,
102 TypePromotionFact<VariableDeclaration> fact, 119 TypePromotionFact<VariableDeclaration> fact,
103 TypePromotionScope scope, 120 TypePromotionScope scope,
104 Token token) { 121 Token token) {
105 return new KernelVariableGet(variable, fact, scope) 122 return new KernelVariableGet(variable, fact, scope)
106 ..fileOffset = offsetForToken(token); 123 ..fileOffset = offsetForToken(token);
107 } 124 }
108 } 125 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698