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

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

Issue 16549004: Add type arguments to constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 6 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 override [Element.computeType] because our 9 * methods. We need to override [Element.computeType] because our
10 * optimizers may look at its declared type. 10 * optimizers may look at its declared type.
(...skipping 3376 matching lines...) Expand 10 before | Expand all | Expand 10 after
3387 assert(invariant(send, constructor != null, 3387 assert(invariant(send, constructor != null,
3388 message: 'Constructor Symbol.validated is missing')); 3388 message: 'Constructor Symbol.validated is missing'));
3389 selector = compiler.symbolValidatedConstructorSelector; 3389 selector = compiler.symbolValidatedConstructorSelector;
3390 assert(invariant(send, selector != null, 3390 assert(invariant(send, selector != null,
3391 message: 'Constructor Symbol.validated is missing')); 3391 message: 'Constructor Symbol.validated is missing'));
3392 } 3392 }
3393 3393
3394 bool isRedirected = functionElement.isRedirectingFactory; 3394 bool isRedirected = functionElement.isRedirectingFactory;
3395 DartType expectedType = type; 3395 DartType expectedType = type;
3396 if (isRedirected) { 3396 if (isRedirected) {
3397 FunctionExpression functionNode = functionElement.parseNode(compiler); 3397 type = functionElement.computeTargetType(compiler, type);
3398 if (functionNode.isRedirectingFactory) {
3399 // Lookup the type used in the redirection.
3400 Return redirectionNode = functionNode.body;
3401 TreeElements treeElements =
3402 compiler.enqueuer.resolution.getCachedElements(
3403 functionElement.declaration);
3404 ClassElement targetClass = functionElement.getEnclosingClass();
3405 type = treeElements.getType(redirectionNode.expression)
3406 .subst(type.typeArguments, targetClass.typeVariables);
3407 }
3408 functionElement = functionElement.redirectionTarget;
3409 } 3398 }
3410 3399
3411 var inputs = <HInstruction>[]; 3400 var inputs = <HInstruction>[];
3412 // TODO(5347): Try to avoid the need for calling [implementation] before 3401 // TODO(5347): Try to avoid the need for calling [implementation] before
3413 // calling [addStaticSendArgumentsToList]. 3402 // calling [addStaticSendArgumentsToList].
3414 bool succeeded = addStaticSendArgumentsToList(selector, send.arguments, 3403 bool succeeded = addStaticSendArgumentsToList(selector, send.arguments,
3415 constructor.implementation, 3404 constructor.implementation,
3416 inputs); 3405 inputs);
3417 if (!succeeded) { 3406 if (!succeeded) {
3418 generateWrongArgumentCountError(send, constructor, send.arguments); 3407 generateWrongArgumentCountError(send, constructor, send.arguments);
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
3653 ErroneousElement error = element; 3642 ErroneousElement error = element;
3654 if (error.messageKind == MessageKind.CANNOT_FIND_CONSTRUCTOR) { 3643 if (error.messageKind == MessageKind.CANNOT_FIND_CONSTRUCTOR) {
3655 generateThrowNoSuchMethod(node.send, 3644 generateThrowNoSuchMethod(node.send,
3656 getTargetName(error, 'constructor'), 3645 getTargetName(error, 'constructor'),
3657 argumentNodes: node.send.arguments); 3646 argumentNodes: node.send.arguments);
3658 } else { 3647 } else {
3659 Message message = error.messageKind.message(error.messageArguments); 3648 Message message = error.messageKind.message(error.messageArguments);
3660 generateRuntimeError(node.send, message.toString()); 3649 generateRuntimeError(node.send, message.toString());
3661 } 3650 }
3662 } else if (node.isConst()) { 3651 } else if (node.isConst()) {
3663 // TODO(karlklose): add type representation
3664 ConstantHandler handler = compiler.constantHandler; 3652 ConstantHandler handler = compiler.constantHandler;
3665 Constant constant = handler.compileNodeWithDefinitions(node, elements); 3653 Constant constant = handler.compileNodeWithDefinitions(node, elements);
3666 stack.add(graph.addConstant(constant, compiler)); 3654 stack.add(graph.addConstant(constant, compiler));
3667 if (isSymbolConstructor) { 3655 if (isSymbolConstructor) {
3668 ConstructedConstant symbol = constant; 3656 ConstructedConstant symbol = constant;
3669 StringConstant stringConstant = symbol.fields.single; 3657 StringConstant stringConstant = symbol.fields.single;
3670 String nameString = stringConstant.toDartString().slowToString(); 3658 String nameString = stringConstant.toDartString().slowToString();
3671 compiler.enqueuer.codegen.registerConstSymbol(nameString, elements); 3659 compiler.enqueuer.codegen.registerConstSymbol(nameString, elements);
3672 } 3660 }
3673 } else { 3661 } else {
(...skipping 1723 matching lines...) Expand 10 before | Expand all | Expand 10 after
5397 new HSubGraphBlockInformation(elseBranch.graph)); 5385 new HSubGraphBlockInformation(elseBranch.graph));
5398 5386
5399 HBasicBlock conditionStartBlock = conditionBranch.block; 5387 HBasicBlock conditionStartBlock = conditionBranch.block;
5400 conditionStartBlock.setBlockFlow(info, joinBlock); 5388 conditionStartBlock.setBlockFlow(info, joinBlock);
5401 SubGraph conditionGraph = conditionBranch.graph; 5389 SubGraph conditionGraph = conditionBranch.graph;
5402 HIf branch = conditionGraph.end.last; 5390 HIf branch = conditionGraph.end.last;
5403 assert(branch is HIf); 5391 assert(branch is HIf);
5404 branch.blockInformation = conditionStartBlock.blockFlow; 5392 branch.blockInformation = conditionStartBlock.blockFlow;
5405 } 5393 }
5406 } 5394 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698