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

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

Issue 2882893002: Store Typedef(s) in kernel when parsing with Fasta, deserilize in DillLibraryBuilder. (Closed)
Patch Set: Add the new file. 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 side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/lib/src/fasta/kernel/kernel_function_type_alias_builder.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_function_type_alias_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_function_type_alias_builder.dart
index 4b083dcdaebffee0f62d1d375e97a859976e2be6..6e59e546f8846ee413eaea93a4a5ce57f6b67804 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_function_type_alias_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_function_type_alias_builder.dart
@@ -4,6 +4,7 @@
library fasta.kernel_function_type_alias_builder;
+import 'package:front_end/src/fasta/util/relativize.dart';
import 'package:kernel/ast.dart'
show
DartType,
@@ -11,17 +12,17 @@ import 'package:kernel/ast.dart'
FunctionType,
InvalidType,
NamedType,
- TypeParameter;
-
+ TypeParameter,
+ Typedef;
import 'package:kernel/type_algebra.dart' show substitute;
import '../messages.dart' show warning;
-
import 'kernel_builder.dart'
show
FormalParameterBuilder,
FunctionTypeAliasBuilder,
KernelFormalParameterBuilder,
+ KernelLibraryBuilder,
KernelTypeBuilder,
KernelTypeVariableBuilder,
LibraryBuilder,
@@ -46,6 +47,14 @@ class KernelFunctionTypeAliasBuilder
: super(metadata, returnType, name, typeVariables, formals, parent,
charOffset);
+ Typedef build(KernelLibraryBuilder libraryBuilder) {
+ DartType type = buildThisType(libraryBuilder);
+ var typedef = new Typedef(name, type);
+ typedef.fileUri = relativizeUri(parent.fileUri);
+ typedef.fileOffset = charOffset;
+ return typedef;
+ }
+
DartType buildThisType(LibraryBuilder library) {
if (thisType != null) {
if (thisType == const InvalidType()) {
@@ -90,22 +99,6 @@ class KernelFunctionTypeAliasBuilder
requiredParameterCount: requiredParameterCount);
}
- /// [arguments] have already been built.
- DartType buildTypesWithBuiltArguments(
- LibraryBuilder library, List<DartType> arguments) {
- var thisType = buildThisType(library);
- if (thisType is DynamicType) return thisType;
- FunctionType result = thisType;
- if (result.typeParameters.isEmpty && arguments == null) return result;
- arguments =
- computeDefaultTypeArguments(library, result.typeParameters, arguments);
- Map<TypeParameter, DartType> substitution = <TypeParameter, DartType>{};
- for (int i = 0; i < result.typeParameters.length; i++) {
- substitution[result.typeParameters[i]] = arguments[i];
- }
- return substitute(result.withoutTypeParameters, substitution);
- }
-
DartType buildType(
LibraryBuilder library, List<KernelTypeBuilder> arguments) {
var thisType = buildThisType(library);
@@ -121,4 +114,20 @@ class KernelFunctionTypeAliasBuilder
}
return buildTypesWithBuiltArguments(library, builtArguments);
}
+
+ /// [arguments] have already been built.
+ DartType buildTypesWithBuiltArguments(
+ LibraryBuilder library, List<DartType> arguments) {
+ var thisType = buildThisType(library);
+ if (thisType is DynamicType) return thisType;
+ FunctionType result = thisType;
+ if (result.typeParameters.isEmpty && arguments == null) return result;
+ arguments =
+ computeDefaultTypeArguments(library, result.typeParameters, arguments);
+ Map<TypeParameter, DartType> substitution = <TypeParameter, DartType>{};
+ for (int i = 0; i < result.typeParameters.length; i++) {
+ substitution[result.typeParameters[i]] = arguments[i];
+ }
+ return substitute(result.withoutTypeParameters, substitution);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698