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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/codegen.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 class SsaCodeGeneratorTask extends CompilerTask { 7 class SsaCodeGeneratorTask extends CompilerTask {
8 8
9 final JavaScriptBackend backend; 9 final JavaScriptBackend backend;
10 10
(...skipping 2062 matching lines...) Expand 10 before | Expand all | Expand 10 after
2073 backend.registerNonCallStaticUse(node); 2073 backend.registerNonCallStaticUse(node);
2074 if (node.element.isFunction()) { 2074 if (node.element.isFunction()) {
2075 world.registerInstantiatedClass(compiler.functionClass); 2075 world.registerInstantiatedClass(compiler.functionClass);
2076 } 2076 }
2077 } else if (instr.target != node) { 2077 } else if (instr.target != node) {
2078 backend.registerNonCallStaticUse(node); 2078 backend.registerNonCallStaticUse(node);
2079 } 2079 }
2080 }); 2080 });
2081 Element element = node.element; 2081 Element element = node.element;
2082 world.registerStaticUse(element); 2082 world.registerStaticUse(element);
2083 ClassElement cls = element.getEnclosingClass(); 2083 ClassElement cls = element.getEnclosingClass();
2084 if (element.isGenerativeConstructor() 2084 if (element.isGenerativeConstructor()
2085 || (element.isFactoryConstructor() && cls == compiler.listClass)) { 2085 || (element.isFactoryConstructor() && cls == compiler.listClass)) {
2086 world.registerInstantiatedClass(cls); 2086 world.registerInstantiatedClass(cls);
2087 } 2087 }
2088 push(new js.VariableUse(backend.namer.isolateAccess(node.element))); 2088 push(new js.VariableUse(backend.namer.isolateAccess(node.element)));
2089 } 2089 }
2090 2090
2091 void visitLazyStatic(HLazyStatic node) { 2091 void visitLazyStatic(HLazyStatic node) {
2092 Element element = node.element; 2092 Element element = node.element;
2093 world.registerStaticUse(element); 2093 world.registerStaticUse(element);
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
2451 const SourceString("stringSuperTypeCast"), 2451 const SourceString("stringSuperTypeCast"),
2452 "listTypeCheck": 2452 "listTypeCheck":
2453 const SourceString("listTypeCast"), 2453 const SourceString("listTypeCast"),
2454 "listSuperNativeTypeCheck": 2454 "listSuperNativeTypeCheck":
2455 const SourceString("listSuperNativeTypeCast"), 2455 const SourceString("listSuperNativeTypeCast"),
2456 "listSuperTypeCheck": 2456 "listSuperTypeCheck":
2457 const SourceString("listSuperTypeCast"), 2457 const SourceString("listSuperTypeCast"),
2458 "callTypeCheck": 2458 "callTypeCheck":
2459 const SourceString("callTypeCast"), 2459 const SourceString("callTypeCast"),
2460 "propertyTypeCheck": 2460 "propertyTypeCheck":
2461 const SourceString("propertyTypeCast") 2461 const SourceString("propertyTypeCast"),
2462 "malformedTypeCheck":
2463 const SourceString("malformedTypeCheck")
2462 }; 2464 };
2463 2465
2464 if (node.isChecked) { 2466 if (node.isChecked) {
2465 DartType type = node.type.computeType(compiler); 2467 DartType type = node.type.computeType(compiler);
2466 Element element = type.element; 2468 Element element = type.element;
2467 world.registerIsCheck(type); 2469 world.registerIsCheck(type);
2468 2470
2469 if (node.isArgumentTypeCheck) { 2471 if (node.isArgumentTypeCheck) {
2470 if (element == compiler.intClass) { 2472 if (element == compiler.intClass) {
2471 checkInt(node.checkedInput, '!=='); 2473 checkInt(node.checkedInput, '!==');
(...skipping 20 matching lines...) Expand all
2492 helper = backend.getCheckedModeHelper(type); 2494 helper = backend.getCheckedModeHelper(type);
2493 if (node.isCastTypeCheck) { 2495 if (node.isCastTypeCheck) {
2494 helper = castNames[helper.stringValue]; 2496 helper = castNames[helper.stringValue];
2495 } 2497 }
2496 } 2498 }
2497 FunctionElement helperElement = compiler.findHelper(helper); 2499 FunctionElement helperElement = compiler.findHelper(helper);
2498 world.registerStaticUse(helperElement); 2500 world.registerStaticUse(helperElement);
2499 List<js.Expression> arguments = <js.Expression>[]; 2501 List<js.Expression> arguments = <js.Expression>[];
2500 use(node.checkedInput); 2502 use(node.checkedInput);
2501 arguments.add(pop()); 2503 arguments.add(pop());
2502 if (helperElement.computeSignature(compiler).parameterCount != 1) { 2504 int parameterCount =
2505 helperElement.computeSignature(compiler).parameterCount;
2506 if (parameterCount == 2) {
2507 assert(!type.isMalformed);
2503 String additionalArgument = backend.namer.operatorIs(element); 2508 String additionalArgument = backend.namer.operatorIs(element);
2504 arguments.add(new js.LiteralString("'$additionalArgument'")); 2509 arguments.add(new js.LiteralString("'$additionalArgument'"));
2510 } else if (parameterCount == 3) {
2511 assert(type.isMalformed);
2512 var reasons = new List<String>();
2513 type.forEachMalformedType((MalformedType malformedType) {
2514 ErroneousElement error = malformedType.element;
2515 Message message = error.messageKind.message(error.messageArguments);
2516 reasons.add(message.toString());
2517 return true;
2518 });
2519 arguments.add(new js.LiteralString("'$type'"));
2520 arguments.add(new js.LiteralString("'${Strings.join(reasons, ', ')}'"));
2521 } else {
2522 assert(!type.isMalformed);
2505 } 2523 }
2506 String helperName = backend.namer.isolateAccess(helperElement); 2524 String helperName = backend.namer.isolateAccess(helperElement);
2507 push(new js.Call(new js.VariableUse(helperName), arguments)); 2525 push(new js.Call(new js.VariableUse(helperName), arguments));
2508 } else { 2526 } else {
2509 use(node.checkedInput); 2527 use(node.checkedInput);
2510 } 2528 }
2511 } 2529 }
2512 } 2530 }
2513 2531
2514 class SsaOptimizedCodeGenerator extends SsaCodeGenerator { 2532 class SsaOptimizedCodeGenerator extends SsaCodeGenerator {
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
3034 if (leftType.canBeNull() && rightType.canBeNull()) { 3052 if (leftType.canBeNull() && rightType.canBeNull()) {
3035 if (left.isConstantNull() || right.isConstantNull() || 3053 if (left.isConstantNull() || right.isConstantNull() ||
3036 (leftType.isPrimitive() && leftType == rightType)) { 3054 (leftType.isPrimitive() && leftType == rightType)) {
3037 return '=='; 3055 return '==';
3038 } 3056 }
3039 return null; 3057 return null;
3040 } else { 3058 } else {
3041 return '==='; 3059 return '===';
3042 } 3060 }
3043 } 3061 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698