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

Side by Side Diff: pkg/compiler/lib/src/ssa/builder.dart

Issue 1414913002: Introduce .isMalformed (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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
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 SsaFunctionCompiler implements FunctionCompiler { 7 class SsaFunctionCompiler implements FunctionCompiler {
8 final SsaCodeGeneratorTask generator; 8 final SsaCodeGeneratorTask generator;
9 final SsaBuilderTask builder; 9 final SsaBuilderTask builder;
10 final SsaOptimizerTask optimizer; 10 final SsaOptimizerTask optimizer;
(...skipping 2004 matching lines...) Expand 10 before | Expand all | Expand 10 after
2015 List<FunctionElement> constructors, 2015 List<FunctionElement> constructors,
2016 Map<Element, HInstruction> fieldValues) { 2016 Map<Element, HInstruction> fieldValues) {
2017 assert(invariant(constructor, constructor.isImplementation)); 2017 assert(invariant(constructor, constructor.isImplementation));
2018 if (constructor.isSynthesized) { 2018 if (constructor.isSynthesized) {
2019 List<HInstruction> arguments = <HInstruction>[]; 2019 List<HInstruction> arguments = <HInstruction>[];
2020 HInstruction compileArgument(ParameterElement parameter) { 2020 HInstruction compileArgument(ParameterElement parameter) {
2021 return localsHandler.readLocal(parameter); 2021 return localsHandler.readLocal(parameter);
2022 } 2022 }
2023 2023
2024 Element target = constructor.definingConstructor.implementation; 2024 Element target = constructor.definingConstructor.implementation;
2025 bool match = !target.isErroneous && 2025 bool match = !target.isMalformed &&
2026 CallStructure.addForwardingElementArgumentsToList( 2026 CallStructure.addForwardingElementArgumentsToList(
2027 constructor, 2027 constructor,
2028 arguments, 2028 arguments,
2029 target, 2029 target,
2030 compileArgument, 2030 compileArgument,
2031 handleConstantForOptionalParameter); 2031 handleConstantForOptionalParameter);
2032 if (!match) { 2032 if (!match) {
2033 if (compiler.elementHasCompileTimeError(constructor)) { 2033 if (compiler.elementHasCompileTimeError(constructor)) {
2034 return; 2034 return;
2035 } 2035 }
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after
3468 3468
3469 /// Generate read access of an unresolved static or top level entity. 3469 /// Generate read access of an unresolved static or top level entity.
3470 void generateStaticUnresolvedGet(ast.Send node, Element element) { 3470 void generateStaticUnresolvedGet(ast.Send node, Element element) {
3471 if (element is ErroneousElement) { 3471 if (element is ErroneousElement) {
3472 SourceInformation sourceInformation = 3472 SourceInformation sourceInformation =
3473 sourceInformationBuilder.buildGet(node); 3473 sourceInformationBuilder.buildGet(node);
3474 // An erroneous element indicates an unresolved static getter. 3474 // An erroneous element indicates an unresolved static getter.
3475 handleInvalidStaticGet(node, element); 3475 handleInvalidStaticGet(node, element);
3476 } else { 3476 } else {
3477 // This happens when [element] has parse errors. 3477 // This happens when [element] has parse errors.
3478 assert(invariant(node, element == null || element.isErroneous)); 3478 assert(invariant(node, element == null || element.isMalformed));
3479 // TODO(ahe): Do something like the above, that is, emit a runtime 3479 // TODO(ahe): Do something like the above, that is, emit a runtime
3480 // error. 3480 // error.
3481 stack.add(graph.addConstantNull(compiler)); 3481 stack.add(graph.addConstantNull(compiler));
3482 } 3482 }
3483 } 3483 }
3484 3484
3485 /// Read a static or top level [field] of constant value. 3485 /// Read a static or top level [field] of constant value.
3486 void generateStaticConstGet( 3486 void generateStaticConstGet(
3487 ast.Send node, 3487 ast.Send node,
3488 FieldElement field, 3488 FieldElement field,
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
3757 if (Elements.isStaticOrTopLevelField(element)) { 3757 if (Elements.isStaticOrTopLevelField(element)) {
3758 if (element.isSetter) { 3758 if (element.isSetter) {
3759 pushInvokeStatic(location, element, <HInstruction>[value]); 3759 pushInvokeStatic(location, element, <HInstruction>[value]);
3760 pop(); 3760 pop();
3761 } else { 3761 } else {
3762 VariableElement field = element; 3762 VariableElement field = element;
3763 value = potentiallyCheckOrTrustType(value, field.type); 3763 value = potentiallyCheckOrTrustType(value, field.type);
3764 addWithPosition(new HStaticStore(element, value), location); 3764 addWithPosition(new HStaticStore(element, value), location);
3765 } 3765 }
3766 stack.add(value); 3766 stack.add(value);
3767 } else if (Elements.isErroneous(element)) { 3767 } else if (Elements.isMalformed(element)) {
Johnni Winther 2015/10/21 07:51:56 Change to } else if (Elements.isError(element)) {
sigurdm 2015/10/22 07:33:14 Done.
3768 if (element is ErroneousElement) { 3768 if (element is ErroneousElement) {
3769 generateNoSuchSetter(location, element, send == null ? null : value); 3769 generateNoSuchSetter(location, element, send == null ? null : value);
3770 } else { 3770 } else {
3771 // TODO(ahe): Do something like [generateWrongArgumentCountError]. 3771 // TODO(ahe): Do something like [generateWrongArgumentCountError].
3772 stack.add(graph.addConstantNull(compiler)); 3772 stack.add(graph.addConstantNull(compiler));
3773 } 3773 }
3774 } else { 3774 } else {
3775 stack.add(value); 3775 stack.add(value);
3776 LocalElement local = element; 3776 LocalElement local = element;
3777 // If the value does not already have a name, give it here. 3777 // If the value does not already have a name, give it here.
(...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after
5129 var inputs = <HInstruction>[]; 5129 var inputs = <HInstruction>[];
5130 if (constructor.isGenerativeConstructor && 5130 if (constructor.isGenerativeConstructor &&
5131 Elements.isNativeOrExtendsNative(constructor.enclosingClass) && 5131 Elements.isNativeOrExtendsNative(constructor.enclosingClass) &&
5132 !constructor.isJsInterop) { 5132 !constructor.isJsInterop) {
5133 // Native class generative constructors take a pre-constructed object. 5133 // Native class generative constructors take a pre-constructed object.
5134 inputs.add(graph.addConstantNull(compiler)); 5134 inputs.add(graph.addConstantNull(compiler));
5135 } 5135 }
5136 // TODO(5347): Try to avoid the need for calling [implementation] before 5136 // TODO(5347): Try to avoid the need for calling [implementation] before
5137 // calling [makeStaticArgumentList]. 5137 // calling [makeStaticArgumentList].
5138 constructorImplementation = constructor.implementation; 5138 constructorImplementation = constructor.implementation;
5139 if (constructorImplementation.isErroneous || 5139 if (constructorImplementation.isMalformed ||
5140 !callStructure.signatureApplies( 5140 !callStructure.signatureApplies(
5141 constructorImplementation.functionSignature)) { 5141 constructorImplementation.functionSignature)) {
5142 generateWrongArgumentCountError(send, constructor, send.arguments); 5142 generateWrongArgumentCountError(send, constructor, send.arguments);
5143 return; 5143 return;
5144 } 5144 }
5145 inputs.addAll(makeStaticArgumentList(callStructure, 5145 inputs.addAll(makeStaticArgumentList(callStructure,
5146 send.arguments, 5146 send.arguments,
5147 constructorImplementation)); 5147 constructorImplementation));
5148 5148
5149 TypeMask elementType = computeType(constructor); 5149 TypeMask elementType = computeType(constructor);
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
5717 5717
5718 @override 5718 @override
5719 void bulkHandleNode(ast.Node node, String message, _) { 5719 void bulkHandleNode(ast.Node node, String message, _) {
5720 internalError(node, "Unexpected bulk handled node: $node"); 5720 internalError(node, "Unexpected bulk handled node: $node");
5721 } 5721 }
5722 5722
5723 @override 5723 @override
5724 void bulkHandleNew(ast.NewExpression node, [_]) { 5724 void bulkHandleNew(ast.NewExpression node, [_]) {
5725 Element element = elements[node.send]; 5725 Element element = elements[node.send];
5726 final bool isSymbolConstructor = element == compiler.symbolConstructor; 5726 final bool isSymbolConstructor = element == compiler.symbolConstructor;
5727 if (!Elements.isErroneous(element)) { 5727 if (!Elements.isMalformed(element)) {
5728 ConstructorElement function = element; 5728 ConstructorElement function = element;
5729 element = function.effectiveTarget; 5729 element = function.effectiveTarget;
5730 } 5730 }
5731 if (Elements.isErroneous(element)) { 5731 if (Elements.isMalformed(element)) {
Johnni Winther 2015/10/21 07:51:56 Change to if (Elements.isError(element)) { Erro
sigurdm 2015/10/22 07:33:14 Done.
5732 if (element is !ErroneousElement) { 5732 if (element is !ErroneousElement) {
5733 // TODO(ahe): Do something like [generateWrongArgumentCountError]. 5733 // TODO(ahe): Do something like [generateWrongArgumentCountError].
5734 stack.add(graph.addConstantNull(compiler)); 5734 stack.add(graph.addConstantNull(compiler));
5735 return; 5735 return;
5736 } 5736 }
5737 ErroneousElement error = element; 5737 ErroneousElement error = element;
5738 if (error.messageKind == MessageKind.CANNOT_FIND_CONSTRUCTOR) { 5738 if (error.messageKind == MessageKind.CANNOT_FIND_CONSTRUCTOR) {
5739 generateThrowNoSuchMethod( 5739 generateThrowNoSuchMethod(
5740 node.send, 5740 node.send,
5741 noSuchMethodTargetSymbolString(error, 'constructor'), 5741 noSuchMethodTargetSymbolString(error, 'constructor'),
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after
6874 pushCheckNull(receiver); 6874 pushCheckNull(receiver);
6875 }, 6875 },
6876 () => stack.add(receiver), 6876 () => stack.add(receiver),
6877 () => generateAssignment(receiver)); 6877 () => generateAssignment(receiver));
6878 } else { 6878 } else {
6879 generateAssignment(generateInstanceSendReceiver(node)); 6879 generateAssignment(generateInstanceSendReceiver(node));
6880 } 6880 }
6881 return; 6881 return;
6882 } 6882 }
6883 6883
6884 if (getter.isErroneous) { 6884 if (getter.isMalformed) {
6885 generateStaticUnresolvedGet(node, getter); 6885 generateStaticUnresolvedGet(node, getter);
6886 } else if (getter.isField) { 6886 } else if (getter.isField) {
6887 generateStaticFieldGet(node, getter); 6887 generateStaticFieldGet(node, getter);
6888 } else if (getter.isGetter) { 6888 } else if (getter.isGetter) {
6889 generateStaticGetterGet(node, getter); 6889 generateStaticGetterGet(node, getter);
6890 } else if (getter.isFunction) { 6890 } else if (getter.isFunction) {
6891 generateStaticFunctionGet(node, getter); 6891 generateStaticFunctionGet(node, getter);
6892 } else if (getter.isLocal) { 6892 } else if (getter.isLocal) {
6893 handleLocalGet(node, getter); 6893 handleLocalGet(node, getter);
6894 } else { 6894 } else {
(...skipping 2250 matching lines...) Expand 10 before | Expand all | Expand 10 after
9145 if (unaliased is TypedefType) throw 'unable to unalias $type'; 9145 if (unaliased is TypedefType) throw 'unable to unalias $type';
9146 unaliased.accept(this, builder); 9146 unaliased.accept(this, builder);
9147 } 9147 }
9148 9148
9149 void visitDynamicType(DynamicType type, SsaBuilder builder) { 9149 void visitDynamicType(DynamicType type, SsaBuilder builder) {
9150 JavaScriptBackend backend = builder.compiler.backend; 9150 JavaScriptBackend backend = builder.compiler.backend;
9151 ClassElement cls = backend.findHelper('DynamicRuntimeType'); 9151 ClassElement cls = backend.findHelper('DynamicRuntimeType');
9152 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); 9152 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld)));
9153 } 9153 }
9154 } 9154 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698