Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/ssa/codegen.dart |
| diff --git a/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart b/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart |
| index b704a11fe016a38760a79c27d65f6cd8142db80f..8b6b0dcd553b71fbbb9af25752ded0bc7633d4d9 100644 |
| --- a/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart |
| +++ b/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart |
| @@ -1612,7 +1612,8 @@ abstract class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
| } |
| HType receiverHType = types[node.inputs[0]]; |
| DartType receiverType = receiverHType.computeType(compiler); |
| - if (receiverType != null) { |
| + if (receiverType != null && |
| + !identical(receiverType.kind, TypeKind.MALFORMED_TYPE)) { |
|
ngeoffray
2012/12/05 15:43:46
Is that important? If it's malformed, it will say
Johnni Winther
2012/12/05 18:33:51
It is to make a distinction between List<SomeMalfo
ngeoffray
2012/12/05 18:37:38
What I'm trying to understand is whether that will
Johnni Winther
2012/12/05 19:11:20
It's the latter.
|
| return new TypedSelector(receiverType, defaultSelector); |
| } else { |
| return defaultSelector; |
| @@ -1736,7 +1737,7 @@ abstract class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
| push(new js.PropertyAccess.field(pop(), name), node); |
| HType receiverHType = types[node.receiver]; |
| DartType type = receiverHType.computeType(compiler); |
| - if (type != null) { |
| + if (type != null && !identical(type.kind, TypeKind.MALFORMED_TYPE)) { |
|
ngeoffray
2012/12/05 15:43:46
ditto
|
| world.registerFieldGetter( |
| node.element.name, node.element.getLibrary(), type); |
| } |
| @@ -1746,7 +1747,7 @@ abstract class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
| visitFieldSet(HFieldSet node) { |
| String name = _fieldPropertyName(node.element); |
| DartType type = types[node.receiver].computeType(compiler); |
| - if (type != null) { |
| + if (type != null && !identical(type.kind, TypeKind.MALFORMED_TYPE)) { |
|
ngeoffray
2012/12/05 15:43:46
ditto
|
| // Field setters in the generative constructor body are handled in a |
| // step "SsaConstructionFieldTypes" in the ssa optimizer. |
| if (!work.element.isGenerativeConstructorBody()) { |
| @@ -2080,7 +2081,7 @@ abstract class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
| }); |
| Element element = node.element; |
| world.registerStaticUse(element); |
| - ClassElement cls = element.getEnclosingClass(); |
| + ClassElement cls = element.getEnclosingClass(); |
| if (element.isGenerativeConstructor() |
| || (element.isFactoryConstructor() && cls == compiler.listClass)) { |
| world.registerInstantiatedClass(cls); |
| @@ -2274,6 +2275,8 @@ abstract class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
| } |
| void checkType(HInstruction input, DartType type, {bool negative: false}) { |
| + assert(invariant(input, !type.isMalformed, |
| + message: 'Attempt to check malformed type $type')); |
| world.registerIsCheck(type); |
| Element element = type.element; |
| use(input); |
| @@ -2427,6 +2430,7 @@ abstract class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
| } |
| } |
| + // TODO(johnniwinther): Refactor this method. |
| void visitTypeConversion(HTypeConversion node) { |
| Map<String, SourceString> castNames = const <String, SourceString> { |
| "stringTypeCheck": |
| @@ -2458,7 +2462,11 @@ abstract class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
| "callTypeCheck": |
| const SourceString("callTypeCast"), |
| "propertyTypeCheck": |
| - const SourceString("propertyTypeCast") |
| + const SourceString("propertyTypeCast"), |
| + // TODO(johnniwinther): Add a malformedTypeCast which produces a TypeError |
| + // with another message. |
| + "malformedTypeCheck": |
| + const SourceString("malformedTypeCheck") |
| }; |
| if (node.isChecked) { |
| @@ -2499,9 +2507,23 @@ abstract class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
| List<js.Expression> arguments = <js.Expression>[]; |
| use(node.checkedInput); |
| arguments.add(pop()); |
| - if (helperElement.computeSignature(compiler).parameterCount != 1) { |
| + int parameterCount = |
| + helperElement.computeSignature(compiler).parameterCount; |
| + if (parameterCount == 2) { |
| + // 2 arguments implies that the method is either [propertyTypeCheck] |
| + // or [propertyTypeCast]. |
| + assert(!type.isMalformed); |
| String additionalArgument = backend.namer.operatorIs(element); |
| arguments.add(new js.LiteralString("'$additionalArgument'")); |
| + } else if (parameterCount == 3) { |
| + // 3 arguments implies that the method is [malformedTypeCheck]. |
| + assert(type.isMalformed); |
| + String reasons = fetchReasonsFromMalformedType(type); |
| + arguments.add(new js.LiteralString("'$type'")); |
| + // TODO(johnniwinther): Handle escaping correctly. |
| + arguments.add(new js.LiteralString("'$reasons'")); |
| + } else { |
| + assert(!type.isMalformed); |
| } |
| String helperName = backend.namer.isolateAccess(helperElement); |
| push(new js.Call(new js.VariableUse(helperName), arguments)); |