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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 359413006: Fix handling of type literals. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Split visitTypeReferenceSend Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of ssa; 5 part of ssa;
6 6
7 /** 7 /**
8 * A special element for the extra parameter taken by intercepted 8 * A special element for the extra parameter taken by intercepted
9 * methods. We need to implement [TypedElement.type] because our 9 * methods. We need to implement [TypedElement.type] because our
10 * optimizers may look at its declared type. 10 * optimizers may look at its declared type.
(...skipping 4298 matching lines...) Expand 10 before | Expand all | Expand 10 after
4309 node); 4309 node);
4310 } 4310 }
4311 } 4311 }
4312 4312
4313 HConstant addConstantString(String string) { 4313 HConstant addConstantString(String string) {
4314 ast.DartString dartString = new ast.DartString.literal(string); 4314 ast.DartString dartString = new ast.DartString.literal(string);
4315 Constant constant = constantSystem.createString(dartString); 4315 Constant constant = constantSystem.createString(dartString);
4316 return graph.addConstant(constant, compiler); 4316 return graph.addConstant(constant, compiler);
4317 } 4317 }
4318 4318
4319 visitTypeReferenceSend(ast.Send node) { 4319 visitTypePrefixSend(ast.Send node) {
4320 Element element = elements[node]; 4320 compiler.internalError(node, "visitTypePrefixSend should not be called.");
4321 if (element.isClass || element.isTypedef) { 4321 }
4322
4323 visitTypeLiteralSend(ast.Send node) {
4324 DartType type = elements.getTypeLiteralType(node);
4325 if (type.isInterfaceType || type.isTypedef || type.isDynamic) {
4322 // TODO(karlklose): add type representation 4326 // TODO(karlklose): add type representation
4323 if (node.isCall) { 4327 if (node.isCall) {
4324 // The node itself is not a constant but we register the selector (the 4328 // The node itself is not a constant but we register the selector (the
4325 // identifier that refers to the class/typedef) as a constant. 4329 // identifier that refers to the class/typedef) as a constant.
4326 stack.add(addConstant(node.selector)); 4330 stack.add(addConstant(node.selector));
4327 } else { 4331 } else {
4328 stack.add(addConstant(node)); 4332 stack.add(addConstant(node));
4329 } 4333 }
4330 } else if (element.isTypeVariable) { 4334 } else if (type.isTypeVariable) {
4331 TypeVariableElement typeVariable = element; 4335 type = localsHandler.substInContext(type);
4332 DartType type = localsHandler.substInContext(typeVariable.type);
4333 HInstruction value = analyzeTypeArgument(type); 4336 HInstruction value = analyzeTypeArgument(type);
4334 pushInvokeStatic(node, 4337 pushInvokeStatic(node,
4335 backend.getRuntimeTypeToString(), 4338 backend.getRuntimeTypeToString(),
4336 [value], 4339 [value],
4337 backend.stringType); 4340 backend.stringType);
4338 pushInvokeStatic(node, 4341 pushInvokeStatic(node,
4339 backend.getCreateRuntimeType(), 4342 backend.getCreateRuntimeType(),
4340 [pop()]); 4343 [pop()]);
4341 } else { 4344 } else {
4342 internalError('unexpected element kind $element', node: node); 4345 internalError('unexpected type kind ${type.kind}', node: node);
4343 } 4346 }
4344 if (node.isCall) { 4347 if (node.isCall) {
4345 // This send is of the form 'e(...)', where e is resolved to a type 4348 // This send is of the form 'e(...)', where e is resolved to a type
4346 // reference. We create a regular closure call on the result of the type 4349 // reference. We create a regular closure call on the result of the type
4347 // reference instead of creating a NoSuchMethodError to avoid pulling it 4350 // reference instead of creating a NoSuchMethodError to avoid pulling it
4348 // in if it is not used (e.g., in a try/catch). 4351 // in if it is not used (e.g., in a try/catch).
4349 HInstruction target = pop(); 4352 HInstruction target = pop();
4350 Selector selector = elements.getSelector(node); 4353 Selector selector = elements.getSelector(node);
4351 List<HInstruction> inputs = <HInstruction>[target]; 4354 List<HInstruction> inputs = <HInstruction>[target];
4352 addDynamicSendArgumentsToList(node, inputs); 4355 addDynamicSendArgumentsToList(node, inputs);
(...skipping 2033 matching lines...) Expand 10 before | Expand all | Expand 10 after
6386 if (unaliased is TypedefType) throw 'unable to unalias $type'; 6389 if (unaliased is TypedefType) throw 'unable to unalias $type';
6387 unaliased.accept(this, builder); 6390 unaliased.accept(this, builder);
6388 } 6391 }
6389 6392
6390 void visitDynamicType(DynamicType type, SsaBuilder builder) { 6393 void visitDynamicType(DynamicType type, SsaBuilder builder) {
6391 JavaScriptBackend backend = builder.compiler.backend; 6394 JavaScriptBackend backend = builder.compiler.backend;
6392 ClassElement cls = backend.findHelper('DynamicRuntimeType'); 6395 ClassElement cls = backend.findHelper('DynamicRuntimeType');
6393 builder.push(new HDynamicType(type, new TypeMask.exact(cls))); 6396 builder.push(new HDynamicType(type, new TypeMask.exact(cls)));
6394 } 6397 }
6395 } 6398 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698