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

Side by Side Diff: pkg/compiler/lib/src/ssa/graph_builder.dart

Issue 2603263002: Prefix resolution_types with Resolution. (Closed)
Patch Set: Rebased Created 3 years, 11 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 import '../closure.dart'; 5 import '../closure.dart';
6 import '../common.dart'; 6 import '../common.dart';
7 import '../common/codegen.dart' show CodegenRegistry; 7 import '../common/codegen.dart' show CodegenRegistry;
8 import '../compiler.dart'; 8 import '../compiler.dart';
9 import '../constants/constant_system.dart'; 9 import '../constants/constant_system.dart';
10 import '../elements/resolution_types.dart'; 10 import '../elements/resolution_types.dart';
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 HSubGraphBlockInformation wrapStatementGraph(SubGraph statements) { 194 HSubGraphBlockInformation wrapStatementGraph(SubGraph statements) {
195 if (statements == null) return null; 195 if (statements == null) return null;
196 return new HSubGraphBlockInformation(statements); 196 return new HSubGraphBlockInformation(statements);
197 } 197 }
198 198
199 HSubExpressionBlockInformation wrapExpressionGraph(SubExpression expression) { 199 HSubExpressionBlockInformation wrapExpressionGraph(SubExpression expression) {
200 if (expression == null) return null; 200 if (expression == null) return null;
201 return new HSubExpressionBlockInformation(expression); 201 return new HSubExpressionBlockInformation(expression);
202 } 202 }
203 203
204 HInstruction buildFunctionType(FunctionType type) { 204 HInstruction buildFunctionType(ResolutionFunctionType type) {
205 type.accept(new ReifiedTypeRepresentationBuilder(closedWorld), this); 205 type.accept(new ReifiedTypeRepresentationBuilder(closedWorld), this);
206 return pop(); 206 return pop();
207 } 207 }
208 208
209 HInstruction buildFunctionTypeConversion( 209 HInstruction buildFunctionTypeConversion(
210 HInstruction original, DartType type, int kind); 210 HInstruction original, ResolutionDartType type, int kind);
211 211
212 /// Returns the current source element. 212 /// Returns the current source element.
213 /// 213 ///
214 /// The returned element is a declaration element. 214 /// The returned element is a declaration element.
215 Element get sourceElement; 215 Element get sourceElement;
216 216
217 // TODO(karlklose): this is needed to avoid a bug where the resolved type is 217 // TODO(karlklose): this is needed to avoid a bug where the resolved type is
218 // not stored on a type annotation in the closure translator. Remove when 218 // not stored on a type annotation in the closure translator. Remove when
219 // fixed. 219 // fixed.
220 bool hasDirectLocal(Local local) { 220 bool hasDirectLocal(Local local) {
221 return !localsHandler.isAccessedDirectly(local) || 221 return !localsHandler.isAccessedDirectly(local) ||
222 localsHandler.directLocals[local] != null; 222 localsHandler.directLocals[local] != null;
223 } 223 }
224 224
225 HInstruction callSetRuntimeTypeInfoWithTypeArguments( 225 HInstruction callSetRuntimeTypeInfoWithTypeArguments(ResolutionDartType type,
226 DartType type, List<HInstruction> rtiInputs, HInstruction newObject) { 226 List<HInstruction> rtiInputs, HInstruction newObject) {
227 if (!backend.classNeedsRti(type.element)) { 227 if (!backend.classNeedsRti(type.element)) {
228 return newObject; 228 return newObject;
229 } 229 }
230 230
231 HInstruction typeInfo = new HTypeInfoExpression( 231 HInstruction typeInfo = new HTypeInfoExpression(
232 TypeInfoExpressionKind.INSTANCE, 232 TypeInfoExpressionKind.INSTANCE,
233 (type.element as ClassElement).thisType, 233 (type.element as ClassElement).thisType,
234 rtiInputs, 234 rtiInputs,
235 closedWorld.commonMasks.dynamicType); 235 closedWorld.commonMasks.dynamicType);
236 add(typeInfo); 236 add(typeInfo);
237 return callSetRuntimeTypeInfo(typeInfo, newObject); 237 return callSetRuntimeTypeInfo(typeInfo, newObject);
238 } 238 }
239 239
240 HInstruction callSetRuntimeTypeInfo( 240 HInstruction callSetRuntimeTypeInfo(
241 HInstruction typeInfo, HInstruction newObject); 241 HInstruction typeInfo, HInstruction newObject);
242 242
243 /// The element for which this SSA builder is being used. 243 /// The element for which this SSA builder is being used.
244 Element get targetElement; 244 Element get targetElement;
245 TypeBuilder get typeBuilder; 245 TypeBuilder get typeBuilder;
246 } 246 }
247 247
248 class ReifiedTypeRepresentationBuilder 248 class ReifiedTypeRepresentationBuilder
249 implements DartTypeVisitor<dynamic, GraphBuilder> { 249 implements DartTypeVisitor<dynamic, GraphBuilder> {
250 final ClosedWorld closedWorld; 250 final ClosedWorld closedWorld;
251 251
252 ReifiedTypeRepresentationBuilder(this.closedWorld); 252 ReifiedTypeRepresentationBuilder(this.closedWorld);
253 253
254 void visit(DartType type, GraphBuilder builder) => type.accept(this, builder); 254 void visit(ResolutionDartType type, GraphBuilder builder) =>
255 type.accept(this, builder);
255 256
256 void visitVoidType(VoidType type, GraphBuilder builder) { 257 void visitVoidType(ResolutionVoidType type, GraphBuilder builder) {
257 ClassElement cls = builder.backend.helpers.VoidRuntimeType; 258 ClassElement cls = builder.backend.helpers.VoidRuntimeType;
258 builder.push(new HVoidType(type, new TypeMask.exact(cls, closedWorld))); 259 builder.push(new HVoidType(type, new TypeMask.exact(cls, closedWorld)));
259 } 260 }
260 261
261 void visitTypeVariableType(TypeVariableType type, GraphBuilder builder) { 262 void visitTypeVariableType(
263 ResolutionTypeVariableType type, GraphBuilder builder) {
262 ClassElement cls = builder.backend.helpers.RuntimeType; 264 ClassElement cls = builder.backend.helpers.RuntimeType;
263 TypeMask instructionType = new TypeMask.subclass(cls, closedWorld); 265 TypeMask instructionType = new TypeMask.subclass(cls, closedWorld);
264 if (!builder.sourceElement.enclosingElement.isClosure && 266 if (!builder.sourceElement.enclosingElement.isClosure &&
265 builder.sourceElement.isInstanceMember) { 267 builder.sourceElement.isInstanceMember) {
266 HInstruction receiver = builder.localsHandler.readThis(); 268 HInstruction receiver = builder.localsHandler.readThis();
267 builder.push(new HReadTypeVariable(type, receiver, instructionType)); 269 builder.push(new HReadTypeVariable(type, receiver, instructionType));
268 } else { 270 } else {
269 builder.push(new HReadTypeVariable.noReceiver( 271 builder.push(new HReadTypeVariable.noReceiver(
270 type, 272 type,
271 builder.typeBuilder 273 builder.typeBuilder
272 .addTypeVariableReference(type, builder.sourceElement), 274 .addTypeVariableReference(type, builder.sourceElement),
273 instructionType)); 275 instructionType));
274 } 276 }
275 } 277 }
276 278
277 void visitFunctionType(FunctionType type, GraphBuilder builder) { 279 void visitFunctionType(ResolutionFunctionType type, GraphBuilder builder) {
278 type.returnType.accept(this, builder); 280 type.returnType.accept(this, builder);
279 HInstruction returnType = builder.pop(); 281 HInstruction returnType = builder.pop();
280 List<HInstruction> inputs = <HInstruction>[returnType]; 282 List<HInstruction> inputs = <HInstruction>[returnType];
281 283
282 for (DartType parameter in type.parameterTypes) { 284 for (ResolutionDartType parameter in type.parameterTypes) {
283 parameter.accept(this, builder); 285 parameter.accept(this, builder);
284 inputs.add(builder.pop()); 286 inputs.add(builder.pop());
285 } 287 }
286 288
287 for (DartType parameter in type.optionalParameterTypes) { 289 for (ResolutionDartType parameter in type.optionalParameterTypes) {
288 parameter.accept(this, builder); 290 parameter.accept(this, builder);
289 inputs.add(builder.pop()); 291 inputs.add(builder.pop());
290 } 292 }
291 293
292 List<DartType> namedParameterTypes = type.namedParameterTypes; 294 List<ResolutionDartType> namedParameterTypes = type.namedParameterTypes;
293 List<String> names = type.namedParameters; 295 List<String> names = type.namedParameters;
294 for (int index = 0; index < names.length; index++) { 296 for (int index = 0; index < names.length; index++) {
295 ast.DartString dartString = new ast.DartString.literal(names[index]); 297 ast.DartString dartString = new ast.DartString.literal(names[index]);
296 inputs.add( 298 inputs.add(
297 builder.graph.addConstantString(dartString, builder.closedWorld)); 299 builder.graph.addConstantString(dartString, builder.closedWorld));
298 namedParameterTypes[index].accept(this, builder); 300 namedParameterTypes[index].accept(this, builder);
299 inputs.add(builder.pop()); 301 inputs.add(builder.pop());
300 } 302 }
301 303
302 ClassElement cls = builder.backend.helpers.RuntimeFunctionType; 304 ClassElement cls = builder.backend.helpers.RuntimeFunctionType;
303 builder.push( 305 builder.push(
304 new HFunctionType(inputs, type, new TypeMask.exact(cls, closedWorld))); 306 new HFunctionType(inputs, type, new TypeMask.exact(cls, closedWorld)));
305 } 307 }
306 308
307 void visitMalformedType(MalformedType type, GraphBuilder builder) { 309 void visitMalformedType(MalformedType type, GraphBuilder builder) {
308 visitDynamicType(const DynamicType(), builder); 310 visitDynamicType(const ResolutionDynamicType(), builder);
309 } 311 }
310 312
311 void visitInterfaceType(InterfaceType type, GraphBuilder builder) { 313 void visitInterfaceType(ResolutionInterfaceType type, GraphBuilder builder) {
312 List<HInstruction> inputs = <HInstruction>[]; 314 List<HInstruction> inputs = <HInstruction>[];
313 for (DartType typeArgument in type.typeArguments) { 315 for (ResolutionDartType typeArgument in type.typeArguments) {
314 typeArgument.accept(this, builder); 316 typeArgument.accept(this, builder);
315 inputs.add(builder.pop()); 317 inputs.add(builder.pop());
316 } 318 }
317 ClassElement cls; 319 ClassElement cls;
318 if (type.typeArguments.isEmpty) { 320 if (type.typeArguments.isEmpty) {
319 cls = builder.backend.helpers.RuntimeTypePlain; 321 cls = builder.backend.helpers.RuntimeTypePlain;
320 } else { 322 } else {
321 cls = builder.backend.helpers.RuntimeTypeGeneric; 323 cls = builder.backend.helpers.RuntimeTypeGeneric;
322 } 324 }
323 builder.push( 325 builder.push(
324 new HInterfaceType(inputs, type, new TypeMask.exact(cls, closedWorld))); 326 new HInterfaceType(inputs, type, new TypeMask.exact(cls, closedWorld)));
325 } 327 }
326 328
327 void visitTypedefType(TypedefType type, GraphBuilder builder) { 329 void visitTypedefType(ResolutionTypedefType type, GraphBuilder builder) {
328 DartType unaliased = type.unaliased; 330 ResolutionDartType unaliased = type.unaliased;
329 if (unaliased is TypedefType) throw 'unable to unalias $type'; 331 if (unaliased is ResolutionTypedefType) throw 'unable to unalias $type';
330 unaliased.accept(this, builder); 332 unaliased.accept(this, builder);
331 } 333 }
332 334
333 void visitDynamicType(DynamicType type, GraphBuilder builder) { 335 void visitDynamicType(ResolutionDynamicType type, GraphBuilder builder) {
334 JavaScriptBackend backend = builder.compiler.backend; 336 JavaScriptBackend backend = builder.compiler.backend;
335 ClassElement cls = backend.helpers.DynamicRuntimeType; 337 ClassElement cls = backend.helpers.DynamicRuntimeType;
336 builder.push(new HDynamicType(type, new TypeMask.exact(cls, closedWorld))); 338 builder.push(new HDynamicType(type, new TypeMask.exact(cls, closedWorld)));
337 } 339 }
338 } 340 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/codegen_helpers.dart ('k') | pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698