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

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

Issue 11412245: MalformedType used for all invalid type annotations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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 3041 matching lines...) Expand 10 before | Expand all | Expand 10 after
3052 } 3052 }
3053 } else { 3053 } else {
3054 target = new HInvokeSuper(inputs); 3054 target = new HInvokeSuper(inputs);
3055 add(target); 3055 add(target);
3056 inputs = <HInstruction>[target]; 3056 inputs = <HInstruction>[target];
3057 addDynamicSendArgumentsToList(node, inputs); 3057 addDynamicSendArgumentsToList(node, inputs);
3058 push(new HInvokeClosure(selector, inputs)); 3058 push(new HInvokeClosure(selector, inputs));
3059 } 3059 }
3060 } 3060 }
3061 3061
3062 /**
3063 * Documentation wanted -- johnniwinther
3064 *
3065 * Invariant: [argument] must not be malformed in checked mode.
3066 */
3062 HInstruction analyzeTypeArgument(DartType argument, Node currentNode) { 3067 HInstruction analyzeTypeArgument(DartType argument, Node currentNode) {
3063 if (argument == compiler.types.dynamicType) { 3068 assert(invariant(currentNode,
3069 !compiler.enableTypeAssertions || !argument.isMalformed,
3070 message: '$argument is malformed in checked mode'));
3071 if (argument == compiler.types.dynamicType || argument.isMalformed) {
3064 // Represent [dynamic] as [null]. 3072 // Represent [dynamic] as [null].
3065 return graph.addConstantNull(constantSystem); 3073 return graph.addConstantNull(constantSystem);
3066 } 3074 }
3067 3075
3068 // These variables are shared between invocations of the helper methods. 3076 // These variables are shared between invocations of the helper methods.
3069 HInstruction typeInfo; 3077 HInstruction typeInfo;
3070 StringBuffer template = new StringBuffer(); 3078 StringBuffer template = new StringBuffer();
3071 List<HInstruction> inputs = <HInstruction>[]; 3079 List<HInstruction> inputs = <HInstruction>[];
3072 3080
3073 /** 3081 /**
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
3181 add(typeInfo); 3189 add(typeInfo);
3182 3190
3183 // Set the runtime type information on the object. 3191 // Set the runtime type information on the object.
3184 Element typeInfoSetterElement = interceptors.getSetRuntimeTypeInfo(); 3192 Element typeInfoSetterElement = interceptors.getSetRuntimeTypeInfo();
3185 HInstruction typeInfoSetter = new HStatic(typeInfoSetterElement); 3193 HInstruction typeInfoSetter = new HStatic(typeInfoSetterElement);
3186 add(typeInfoSetter); 3194 add(typeInfoSetter);
3187 add(new HInvokeStatic( 3195 add(new HInvokeStatic(
3188 <HInstruction>[typeInfoSetter, newObject, typeInfo])); 3196 <HInstruction>[typeInfoSetter, newObject, typeInfo]));
3189 } 3197 }
3190 3198
3199 /**
3200 * Documentation wanted -- johnniwinther
3201 *
3202 * Invariant: [type] must not be malformed in checked mode.
3203 */
3191 visitNewSend(Send node, InterfaceType type) { 3204 visitNewSend(Send node, InterfaceType type) {
3205 assert(invariant(node,
3206 !compiler.enableTypeAssertions || !type.isMalformed,
3207 message: '$type is malformed in checked mode'));
3192 bool isListConstructor = false; 3208 bool isListConstructor = false;
3193 computeType(element) { 3209 computeType(element) {
3194 Element originalElement = elements[node]; 3210 Element originalElement = elements[node];
3195 if (identical(originalElement.getEnclosingClass(), compiler.listClass)) { 3211 if (identical(originalElement.getEnclosingClass(), compiler.listClass)) {
3196 isListConstructor = true; 3212 isListConstructor = true;
3197 if (node.arguments.isEmpty) { 3213 if (node.arguments.isEmpty) {
3198 return HType.EXTENDABLE_ARRAY; 3214 return HType.EXTENDABLE_ARRAY;
3199 } else { 3215 } else {
3200 return HType.MUTABLE_ARRAY; 3216 return HType.MUTABLE_ARRAY;
3201 } 3217 }
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
3423 existingArguments.add(parameter.name.slowToString()); 3439 existingArguments.add(parameter.name.slowToString());
3424 }); 3440 });
3425 generateThrowNoSuchMethod(diagnosticNode, 3441 generateThrowNoSuchMethod(diagnosticNode,
3426 function.name.slowToString(), 3442 function.name.slowToString(),
3427 argumentNodes: argumentNodes, 3443 argumentNodes: argumentNodes,
3428 existingArguments: existingArguments); 3444 existingArguments: existingArguments);
3429 } 3445 }
3430 3446
3431 visitNewExpression(NewExpression node) { 3447 visitNewExpression(NewExpression node) {
3432 Element element = elements[node.send]; 3448 Element element = elements[node.send];
3433 if (!Elements.isErroneousElement(element) && 3449 if (!Elements.isErroneousElement(element)) {
3434 !Elements.isMalformedElement(element)) {
3435 FunctionElement function = element; 3450 FunctionElement function = element;
3436 element = function.redirectionTarget; 3451 element = function.redirectionTarget;
3437 } 3452 }
3438 if (Elements.isErroneousElement(element)) { 3453 if (Elements.isErroneousElement(element)) {
3439 ErroneousElement error = element; 3454 ErroneousElement error = element;
3440 if (error.messageKind == MessageKind.CANNOT_FIND_CONSTRUCTOR) { 3455 if (error.messageKind == MessageKind.CANNOT_FIND_CONSTRUCTOR) {
3441 generateThrowNoSuchMethod(node.send, 3456 generateThrowNoSuchMethod(node.send,
3442 getTargetName(error, 'constructor'), 3457 getTargetName(error, 'constructor'),
3443 argumentNodes: node.send.arguments); 3458 argumentNodes: node.send.arguments);
3444 } else if (error.messageKind == MessageKind.CANNOT_RESOLVE) { 3459 } else {
3445 Message message = error.messageKind.message(error.messageArguments); 3460 Message message = error.messageKind.message(error.messageArguments);
3446 generateRuntimeError(node.send, message.toString()); 3461 generateRuntimeError(node.send, message.toString());
3447 } else {
3448 compiler.internalError('unexpected unresolved constructor call',
3449 node: node);
3450 } 3462 }
3451 } else if (node.isConst()) { 3463 } else if (node.isConst()) {
3452 // TODO(karlklose): add type representation 3464 // TODO(karlklose): add type representation
3453 ConstantHandler handler = compiler.constantHandler; 3465 ConstantHandler handler = compiler.constantHandler;
3454 Constant constant = handler.compileNodeWithDefinitions(node, elements); 3466 Constant constant = handler.compileNodeWithDefinitions(node, elements);
3455 stack.add(graph.addConstant(constant)); 3467 stack.add(graph.addConstant(constant));
3456 } else if (Elements.isMalformedElement(element)) {
3457 Message message =
3458 MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER.message([element]);
3459 generateRuntimeError(node.send, message.toString());
3460 } else { 3468 } else {
3461 visitNewSend(node.send, elements.getType(node)); 3469 DartType type = elements.getType(node);
3470 if (compiler.enableTypeAssertions && type.isMalformed) {
3471 ErroneousElement error;
3472 type.forEachMalformedType((MalformedType malformedType) {
3473 error = malformedType.element;
3474 return false; // Visit the for malformed type only.
ngeoffray 2012/11/30 12:00:40 for -> first Why the first only? for a type annot
Johnni Winther 2012/12/04 10:07:17 Changed to use the newly added fetchReasonsFromMal
3475 });
3476 Message message = error.messageKind.message(error.messageArguments);
3477 generateRuntimeError(node, message.toString());
3478 } else {
3479 visitNewSend(node.send, type);
3480 }
3462 } 3481 }
3463 } 3482 }
3464 3483
3465 visitSendSet(SendSet node) { 3484 visitSendSet(SendSet node) {
3466 Element element = elements[node]; 3485 Element element = elements[node];
3467 if (!Elements.isUnresolved(element) && element.impliesType()) { 3486 if (!Elements.isUnresolved(element) && element.impliesType()) {
3468 Identifier selector = node.selector; 3487 Identifier selector = node.selector;
3469 generateThrowNoSuchMethod(node, selector.source.slowToString(), 3488 generateThrowNoSuchMethod(node, selector.source.slowToString(),
3470 argumentNodes: node.arguments); 3489 argumentNodes: node.arguments);
3471 return; 3490 return;
(...skipping 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after
4902 new HSubGraphBlockInformation(elseBranch.graph)); 4921 new HSubGraphBlockInformation(elseBranch.graph));
4903 4922
4904 HBasicBlock conditionStartBlock = conditionBranch.block; 4923 HBasicBlock conditionStartBlock = conditionBranch.block;
4905 conditionStartBlock.setBlockFlow(info, joinBlock); 4924 conditionStartBlock.setBlockFlow(info, joinBlock);
4906 SubGraph conditionGraph = conditionBranch.graph; 4925 SubGraph conditionGraph = conditionBranch.graph;
4907 HIf branch = conditionGraph.end.last; 4926 HIf branch = conditionGraph.end.last;
4908 assert(branch is HIf); 4927 assert(branch is HIf);
4909 branch.blockInformation = conditionStartBlock.blockFlow; 4928 branch.blockInformation = conditionStartBlock.blockFlow;
4910 } 4929 }
4911 } 4930 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698