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

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

Issue 2769723004: Introduce a shadow hierarchy and factory class for use by fasta's BodyBuilder. (Closed)
Patch Set: Created 3 years, 9 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/ast_factory.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/ast_factory.dart b/pkg/front_end/lib/src/fasta/kernel/ast_factory.dart
new file mode 100644
index 0000000000000000000000000000000000000000..676466958fb65c82b70cad833d2245812fa157ad
--- /dev/null
+++ b/pkg/front_end/lib/src/fasta/kernel/ast_factory.dart
@@ -0,0 +1,50 @@
+import 'package:kernel/ast.dart' show DartType;
ahe 2017/03/24 12:00:40 Missing copyright.
Paul Berry 2017/03/24 14:55:23 Done.
+
+import '../builder/ast_factory.dart' as builder;
ahe 2017/03/24 12:00:40 Could you rename this file to kernel_ast_factory.d
Paul Berry 2017/03/24 14:55:24 Done.
+import '../builder/shadow_ast.dart' as builder;
+import 'shadow_ast.dart';
+
+/// Concrete implementation of [builder.AstFactory] for building a kernel AST.
+class AstFactory implements builder.AstFactory {
ahe 2017/03/24 12:00:40 KernelAstFactory?
Paul Berry 2017/03/24 14:55:24 Done.
+ @override
+ Block block(List<builder.Statement> statements, int charOffset) {
+ return new Block(statements)..fileOffset = charOffset;
+ }
+
+ @override
+ IntLiteral intLiteral(value, int charOffset) {
+ return new IntLiteral(value)..fileOffset = charOffset;
+ }
+
+ @override
+ ListLiteral listLiteral(List<builder.Expression> expressions,
+ DartType typeArgument, bool isConst, int charOffset) {
+ return new ListLiteral(expressions,
+ typeArgument: typeArgument, isConst: isConst)..fileOffset = charOffset;
+ }
+
+ @override
+ NullLiteral nullLiteral(int charOffset) {
+ return new NullLiteral()..fileOffset = charOffset;
+ }
+
+ @override
+ ReturnStatement returnStatement(
+ builder.Expression expression, int charOffset) {
+ return new ReturnStatement(expression)..fileOffset = charOffset;
+ }
+
+ @override
+ VariableDeclaration variableDeclaration(String name,
+ {DartType type,
+ builder.Expression initializer,
+ int charOffset,
+ bool isFinal: false,
+ bool isConst: false}) {
+ return new VariableDeclaration(name,
+ type: type,
+ initializer: initializer,
+ isFinal: isFinal,
+ isConst: isConst)..fileEqualsOffset = charOffset;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698