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

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

Issue 2849293002: Infer types of bool/null/string literals. (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/lib/src/fasta/kernel/body_builder.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index 7e58b33e2eee99ea0e513bdf7a5704a94fa40b76..1a056a98968e9a2f422a99d64243ebb7e10a75e8 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -964,8 +964,8 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
debugEvent("endLiteralString");
if (interpolationCount == 0) {
Token token = pop();
- push(new StringLiteral(unescapeString(token.lexeme))
- ..fileOffset = token.charOffset);
+ String value = unescapeString(token.lexeme);
+ push(astFactory.stringLiteral(value, token));
} else {
List parts = popList(1 + interpolationCount * 2);
Token first = parts.first;
@@ -974,14 +974,15 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
List<Expression> expressions = <Expression>[];
// Contains more than just \' or \".
if (first.lexeme.length > 1) {
- expressions.add(
- new StringLiteral(unescapeFirstStringPart(first.lexeme, quote)));
+ String value = unescapeFirstStringPart(first.lexeme, quote);
+ expressions.add(astFactory.stringLiteral(value, first));
}
for (int i = 1; i < parts.length - 1; i++) {
var part = parts[i];
if (part is Token) {
if (part.lexeme.length != 0) {
- expressions.add(new StringLiteral(unescape(part.lexeme, quote)));
+ String value = unescape(part.lexeme, quote);
+ expressions.add(astFactory.stringLiteral(value, part));
}
} else {
expressions.add(toValue(part));
@@ -989,11 +990,10 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
}
// Contains more than just \' or \".
if (last.lexeme.length > 1) {
- expressions
- .add(new StringLiteral(unescapeLastStringPart(last.lexeme, quote)));
+ String value = unescapeLastStringPart(last.lexeme, quote);
+ expressions.add(astFactory.stringLiteral(value, last));
}
- push(new StringConcatenation(expressions)
- ..fileOffset = endToken.charOffset);
+ push(astFactory.stringConcatenation(expressions, endToken));
}
}
@@ -1298,7 +1298,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
debugEvent("LiteralBool");
bool value = optional("true", token);
assert(value || optional("false", token));
- push(new BoolLiteral(value)..fileOffset = token.charOffset);
+ push(astFactory.boolLiteral(value, token));
}
@override

Powered by Google App Engine
This is Rietveld 408576698