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

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

Issue 2682993002: Pay some naming debt. (Closed)
Patch Set: Created 3 years, 10 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 library fasta.kernel_library_builder; 5 library fasta.kernel_library_builder;
6 6
7 import 'package:kernel/ast.dart'; 7 import 'package:kernel/ast.dart';
8 8
9 import 'package:kernel/clone.dart' show 9 import 'package:kernel/clone.dart' show
10 CloneVisitor; 10 CloneVisitor;
(...skipping 19 matching lines...) Expand all
30 ConstructorReferenceBuilder, 30 ConstructorReferenceBuilder,
31 DynamicTypeBuilder, 31 DynamicTypeBuilder,
32 EnumBuilder, 32 EnumBuilder,
33 FieldBuilder, 33 FieldBuilder,
34 FormalParameterBuilder, 34 FormalParameterBuilder,
35 FunctionTypeAliasBuilder, 35 FunctionTypeAliasBuilder,
36 KernelEnumBuilder, 36 KernelEnumBuilder,
37 KernelFieldBuilder, 37 KernelFieldBuilder,
38 KernelFormalParameterBuilder, 38 KernelFormalParameterBuilder,
39 KernelFunctionTypeAliasBuilder, 39 KernelFunctionTypeAliasBuilder,
40 KernelInterfaceTypeBuilder,
41 KernelInvalidTypeBuilder, 40 KernelInvalidTypeBuilder,
42 KernelMixinApplicationBuilder, 41 KernelMixinApplicationBuilder,
43 KernelNamedMixinApplicationBuilder, 42 KernelNamedMixinApplicationBuilder,
43 KernelNamedTypeBuilder,
44 KernelProcedureBuilder, 44 KernelProcedureBuilder,
45 KernelTypeBuilder, 45 KernelTypeBuilder,
46 KernelTypeVariableBuilder, 46 KernelTypeVariableBuilder,
47 MemberBuilder, 47 MemberBuilder,
48 MetadataBuilder, 48 MetadataBuilder,
49 MixedAccessor, 49 MixedAccessor,
50 NamedMixinApplicationBuilder, 50 NamedMixinApplicationBuilder,
51 PrefixBuilder, 51 PrefixBuilder,
52 ProcedureBuilder, 52 ProcedureBuilder,
53 TypeVariableBuilder; 53 TypeVariableBuilder;
54 54
55 class KernelLibraryBuilder 55 class KernelLibraryBuilder
56 extends SourceLibraryBuilder<KernelTypeBuilder, Library> { 56 extends SourceLibraryBuilder<KernelTypeBuilder, Library> {
57 final Library library; 57 final Library library;
58 58
59 final List<Class> mixinApplicationClasses = <Class>[]; 59 final List<Class> mixinApplicationClasses = <Class>[];
60 60
61 final List<List> argumentsWithMissingDefaultValues = <List>[]; 61 final List<List> argumentsWithMissingDefaultValues = <List>[];
62 62
63 KernelLibraryBuilder(Uri uri, Uri fileUri, Loader loader) 63 KernelLibraryBuilder(Uri uri, Uri fileUri, Loader loader)
64 : library = new Library(uri), 64 : library = new Library(uri),
65 super(loader, fileUri); 65 super(loader, fileUri);
66 66
67 Uri get uri => library.importUri; 67 Uri get uri => library.importUri;
68 68
69 KernelTypeBuilder addInterfaceType(String name, 69 KernelTypeBuilder addNamedType(String name,
70 List<KernelTypeBuilder> arguments) { 70 List<KernelTypeBuilder> arguments) {
71 KernelInterfaceTypeBuilder type = 71 KernelNamedTypeBuilder type =
72 new KernelInterfaceTypeBuilder(name, arguments); 72 new KernelNamedTypeBuilder(name, arguments);
73 if (identical(name, "dynamic")) { 73 if (identical(name, "dynamic")) {
74 // TODO(ahe): Make const. 74 // TODO(ahe): Make const.
75 type.builder = new DynamicTypeBuilder(const DynamicType()); 75 type.builder = new DynamicTypeBuilder(const DynamicType());
76 } else { 76 } else {
77 addType(type); 77 addType(type);
78 } 78 }
79 return type; 79 return type;
80 } 80 }
81 81
82 KernelTypeBuilder addMixinApplication(KernelTypeBuilder supertype, 82 KernelTypeBuilder addMixinApplication(KernelTypeBuilder supertype,
83 List<KernelTypeBuilder> mixins) { 83 List<KernelTypeBuilder> mixins) {
84 KernelTypeBuilder type = 84 KernelTypeBuilder type =
85 new KernelMixinApplicationBuilder(supertype, mixins); 85 new KernelMixinApplicationBuilder(supertype, mixins);
86 return addType(type); 86 return addType(type);
87 } 87 }
88 88
89 KernelTypeBuilder addVoidType() { 89 KernelTypeBuilder addVoidType() {
90 return new KernelInterfaceTypeBuilder("void", null); 90 return new KernelNamedTypeBuilder("void", null);
91 } 91 }
92 92
93 ClassBuilder addClass(List<MetadataBuilder> metadata, 93 ClassBuilder addClass(List<MetadataBuilder> metadata,
94 int modifiers, String className, 94 int modifiers, String className,
95 List<TypeVariableBuilder> typeVariables, KernelTypeBuilder supertype, 95 List<TypeVariableBuilder> typeVariables, KernelTypeBuilder supertype,
96 List<KernelTypeBuilder> interfaces) { 96 List<KernelTypeBuilder> interfaces) {
97 ClassBuilder cls = new SourceClassBuilder(metadata, modifiers, className, 97 ClassBuilder cls = new SourceClassBuilder(metadata, modifiers, className,
98 typeVariables, supertype, interfaces, classMembers, declarationTypes, 98 typeVariables, supertype, interfaces, classMembers, declarationTypes,
99 this, 99 this,
100 new List<ConstructorReferenceBuilder>.from(constructorReferences)); 100 new List<ConstructorReferenceBuilder>.from(constructorReferences));
101 constructorReferences.clear(); 101 constructorReferences.clear();
102 classMembers.forEach((String name, MemberBuilder builder) { 102 classMembers.forEach((String name, MemberBuilder builder) {
103 while (builder != null) { 103 while (builder != null) {
104 builder.parent = cls; 104 builder.parent = cls;
105 builder = builder.next; 105 builder = builder.next;
106 } 106 }
107 }); 107 });
108 // Nested scope began in `OutlineBuilder.beginClassDeclaration`. 108 // Nested declaration began in `OutlineBuilder.beginClassDeclaration`.
109 endNestedScope(); 109 endNestedDeclaration();
110 return addBuilder(className, cls); 110 return addBuilder(className, cls);
111 } 111 }
112 112
113 NamedMixinApplicationBuilder addNamedMixinApplication( 113 NamedMixinApplicationBuilder addNamedMixinApplication(
114 List<MetadataBuilder> metadata, String name, 114 List<MetadataBuilder> metadata, String name,
115 List<TypeVariableBuilder> typeVariables, int modifiers, 115 List<TypeVariableBuilder> typeVariables, int modifiers,
116 KernelTypeBuilder mixinApplication, List<KernelTypeBuilder> interfaces) { 116 KernelTypeBuilder mixinApplication, List<KernelTypeBuilder> interfaces) {
117 NamedMixinApplicationBuilder builder = 117 NamedMixinApplicationBuilder builder =
118 new KernelNamedMixinApplicationBuilder(metadata, name, typeVariables, 118 new KernelNamedMixinApplicationBuilder(metadata, name, typeVariables,
119 modifiers, mixinApplication, interfaces, declarationTypes, this); 119 modifiers, mixinApplication, interfaces, declarationTypes, this);
120 // Nested scope began in `OutlineBuilder.beginNamedMixinApplication`. 120 // Nested declaration began in `OutlineBuilder.beginNamedMixinApplication`.
121 endNestedScope(); 121 endNestedDeclaration();
122 return addBuilder(name, builder); 122 return addBuilder(name, builder);
123 } 123 }
124 124
125 FieldBuilder addField(List<MetadataBuilder> metadata, 125 FieldBuilder addField(List<MetadataBuilder> metadata,
126 int modifiers, KernelTypeBuilder type, String name) { 126 int modifiers, KernelTypeBuilder type, String name) {
127 return addBuilder(name, 127 return addBuilder(name,
128 new KernelFieldBuilder(metadata, type, name, modifiers)); 128 new KernelFieldBuilder(metadata, type, name, modifiers));
129 } 129 }
130 130
131 ProcedureBuilder addProcedure(List<MetadataBuilder> metadata, 131 ProcedureBuilder addProcedure(List<MetadataBuilder> metadata,
132 int modifiers, KernelTypeBuilder returnType, String name, 132 int modifiers, KernelTypeBuilder returnType, String name,
133 List<TypeVariableBuilder> typeVariables, 133 List<TypeVariableBuilder> typeVariables,
134 List<FormalParameterBuilder> formals, AsyncMarker asyncModifier, 134 List<FormalParameterBuilder> formals, AsyncMarker asyncModifier,
135 ProcedureKind kind) { 135 ProcedureKind kind) {
136 // Nested scope began in `OutlineBuilder.beginMethod` or 136 // Nested declaration began in `OutlineBuilder.beginMethod` or
137 // `OutlineBuilder.beginTopLevelMethod`. 137 // `OutlineBuilder.beginTopLevelMethod`.
138 endNestedScope().resolveTypes(typeVariables); 138 endNestedDeclaration().resolveTypes(typeVariables);
139 return addBuilder(name, 139 return addBuilder(name,
140 new KernelProcedureBuilder(metadata, modifiers, returnType, name, 140 new KernelProcedureBuilder(metadata, modifiers, returnType, name,
141 typeVariables, formals, asyncModifier, kind)); 141 typeVariables, formals, asyncModifier, kind));
142 } 142 }
143 143
144 void addFactoryMethod(List<MetadataBuilder> metadata, 144 void addFactoryMethod(List<MetadataBuilder> metadata,
145 ConstructorReferenceBuilder constructorName, 145 ConstructorReferenceBuilder constructorName,
146 List<FormalParameterBuilder> formals, AsyncMarker asyncModifier, 146 List<FormalParameterBuilder> formals, AsyncMarker asyncModifier,
147 ConstructorReferenceBuilder redirectionTarget) { 147 ConstructorReferenceBuilder redirectionTarget) {
148 String name = constructorName.name; 148 String name = constructorName.name;
149 assert(constructorName.suffix == null); 149 assert(constructorName.suffix == null);
150 addBuilder(name, 150 addBuilder(name,
151 new KernelProcedureBuilder(metadata, staticMask, null, name, null, 151 new KernelProcedureBuilder(metadata, staticMask, null, name, null,
152 formals, asyncModifier, ProcedureKind.Factory, redirectionTarget)); 152 formals, asyncModifier, ProcedureKind.Factory, redirectionTarget));
153 } 153 }
154 154
155 EnumBuilder addEnum(List<MetadataBuilder> metadata, String name, 155 EnumBuilder addEnum(List<MetadataBuilder> metadata, String name,
156 List<String> constants) { 156 List<String> constants) {
157 return addBuilder(name, 157 return addBuilder(name,
158 new KernelEnumBuilder(metadata, name, constants, this)); 158 new KernelEnumBuilder(metadata, name, constants, this));
159 } 159 }
160 160
161 FunctionTypeAliasBuilder addFunctionTypeAlias(List<MetadataBuilder> metadata, 161 FunctionTypeAliasBuilder addFunctionTypeAlias(List<MetadataBuilder> metadata,
162 KernelTypeBuilder returnType, String name, 162 KernelTypeBuilder returnType, String name,
163 List<TypeVariableBuilder> typeVariables, 163 List<TypeVariableBuilder> typeVariables,
164 List<FormalParameterBuilder> formals) { 164 List<FormalParameterBuilder> formals) {
165 FunctionTypeAliasBuilder typedef = new KernelFunctionTypeAliasBuilder( 165 FunctionTypeAliasBuilder typedef = new KernelFunctionTypeAliasBuilder(
166 metadata, returnType, name, typeVariables, formals, declarationTypes, 166 metadata, returnType, name, typeVariables, formals, declarationTypes,
167 this); 167 this);
168 // Nested scope began in `OutlineBuilder.beginFunctionTypeAlias`. 168 // Nested declaration began in `OutlineBuilder.beginFunctionTypeAlias`.
169 endNestedScope(); 169 endNestedDeclaration();
170 return addBuilder(name, typedef); 170 return addBuilder(name, typedef);
171 } 171 }
172 172
173 KernelFormalParameterBuilder addFormalParameter( 173 KernelFormalParameterBuilder addFormalParameter(
174 List<MetadataBuilder> metadata, int modifiers, 174 List<MetadataBuilder> metadata, int modifiers,
175 KernelTypeBuilder type, String name, bool hasThis) { 175 KernelTypeBuilder type, String name, bool hasThis) {
176 return new KernelFormalParameterBuilder( 176 return new KernelFormalParameterBuilder(
177 metadata, modifiers, type, name, hasThis); 177 metadata, modifiers, type, name, hasThis);
178 } 178 }
179 179
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 } 275 }
276 expression.value = 276 expression.value =
277 defaultArgumentFrom(names[expression.name].initializer) 277 defaultArgumentFrom(names[expression.name].initializer)
278 ..parent = expression; 278 ..parent = expression;
279 } 279 }
280 } 280 }
281 } 281 }
282 return argumentsWithMissingDefaultValues.length; 282 return argumentsWithMissingDefaultValues.length;
283 } 283 }
284 } 284 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698