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

Unified Diff: pkg/front_end/lib/src/fasta/type_inference/local_type_inferrer.dart

Issue 2768533002: Fasta type inference prototype #2
Patch Set: Rework atop 415c868589d02e98eb839f48150f4203d5cecdb0 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/type_inference/local_type_inferrer.dart
diff --git a/pkg/front_end/lib/src/fasta/type_inference/local_type_inferrer.dart b/pkg/front_end/lib/src/fasta/type_inference/local_type_inferrer.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b35a41cb8b2f23816e9371748f94d65cc24452c4
--- /dev/null
+++ b/pkg/front_end/lib/src/fasta/type_inference/local_type_inferrer.dart
@@ -0,0 +1,52 @@
+import 'package:kernel/ast.dart' show DartType;
+import 'package:kernel/core_types.dart';
+
+import '../builder/shadow_ast.dart';
+
+class FunctionContext {
+ final LocalTypeInferrer inferrer;
+
+ final bool returnTypeNeeded;
+
+ final bool isAsync;
+
+ final bool isGenerator;
+
+ DartType _inferredReturnType;
+
+ FunctionContext(
+ this.inferrer, this.returnTypeNeeded, this.isAsync, this.isGenerator);
+
+ get inferredReturnType {
+ if (_inferredReturnType == null) {
+ // No return statement found.
+ throw new UnimplementedError();
+ }
+ return _inferredReturnType;
+ }
+
+ void recordReturnType(DartType type) {
+ _inferredReturnType = inferrer.union(_inferredReturnType, type);
+ }
+}
+
+class LocalTypeInferrer {
+ final CoreTypes coreTypes;
+
+ LocalTypeInferrer(this.coreTypes);
+
+ void finishVariableDeclaration(DartType type, ShadowExpression initializer,
+ ShadowVariableDeclaration variable) {
+ // TODO(paulberry): is this needed at all?
+ // throw new UnimplementedError();
+ }
+
+ void inferBody(ShadowStatement statement) {
+ statement.shadowInfer(this, null);
+ }
+
+ DartType union(DartType a, DartType b) {
+ if (a == null) return b;
+ throw new UnimplementedError();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698