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

Side by Side Diff: pkg/compiler/lib/src/compile_time_constants.dart

Issue 1414913002: Introduce .isMalformed (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Address review 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/compiler.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 library dart2js.compile_time_constant_evaluator; 5 library dart2js.compile_time_constant_evaluator;
6 6
7 import 'common.dart'; 7 import 'common.dart';
8 import 'common/resolution.dart' show 8 import 'common/resolution.dart' show
9 Resolution; 9 Resolution;
10 import 'common/tasks.dart' show 10 import 'common/tasks.dart' show
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 // The redirection chain of this element may not have been resolved through 823 // The redirection chain of this element may not have been resolved through
824 // a post-process action, so we have to make sure it is done here. 824 // a post-process action, so we have to make sure it is done here.
825 compiler.resolver.resolveRedirectionChain(constructor, node); 825 compiler.resolver.resolveRedirectionChain(constructor, node);
826 InterfaceType constructedType = 826 InterfaceType constructedType =
827 constructor.computeEffectiveTargetType(type); 827 constructor.computeEffectiveTargetType(type);
828 ConstructorElement target = constructor.effectiveTarget; 828 ConstructorElement target = constructor.effectiveTarget;
829 // The constructor must be an implementation to ensure that field 829 // The constructor must be an implementation to ensure that field
830 // initializers are handled correctly. 830 // initializers are handled correctly.
831 ConstructorElement implementation = target.implementation; 831 ConstructorElement implementation = target.implementation;
832 832
833 if (implementation.isErroneous) { 833 if (implementation.isMalformed) {
834 // TODO(johnniwinther): This should probably be an [ErroneousAstConstant]. 834 // TODO(johnniwinther): This should probably be an [ErroneousAstConstant].
835 return new AstConstant(context, node, new ConstructedConstantExpression( 835 return new AstConstant(context, node, new ConstructedConstantExpression(
836 type, constructor, callStructure, const <ConstantExpression>[]), 836 type, constructor, callStructure, const <ConstantExpression>[]),
837 new ConstructedConstantValue( 837 new ConstructedConstantValue(
838 constructedType, const <FieldElement, ConstantValue>{})); 838 constructedType, const <FieldElement, ConstantValue>{}));
839 } 839 }
840 840
841 List<AstConstant> concreteArguments; 841 List<AstConstant> concreteArguments;
842 if (arguments != null) { 842 if (arguments != null) {
843 Map<Node, AstConstant> concreteArgumentMap = <Node, AstConstant>{}; 843 Map<Node, AstConstant> concreteArgumentMap = <Node, AstConstant>{};
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 potentiallyCheckType(element, constant); 1082 potentiallyCheckType(element, constant);
1083 fieldValues[element] = constant; 1083 fieldValues[element] = constant;
1084 } 1084 }
1085 1085
1086 /** 1086 /**
1087 * Given the arguments (a list of constants) assigns them to the parameters, 1087 * Given the arguments (a list of constants) assigns them to the parameters,
1088 * updating the definitions map. If the constructor has field-initializer 1088 * updating the definitions map. If the constructor has field-initializer
1089 * parameters (like [:this.x:]), also updates the [fieldValues] map. 1089 * parameters (like [:this.x:]), also updates the [fieldValues] map.
1090 */ 1090 */
1091 void assignArgumentsToParameters(List<AstConstant> arguments) { 1091 void assignArgumentsToParameters(List<AstConstant> arguments) {
1092 if (constructor.isErroneous) return; 1092 if (constructor.isMalformed) return;
1093 // Assign arguments to parameters. 1093 // Assign arguments to parameters.
1094 FunctionSignature signature = constructor.functionSignature; 1094 FunctionSignature signature = constructor.functionSignature;
1095 int index = 0; 1095 int index = 0;
1096 signature.orderedForEachParameter((ParameterElement parameter) { 1096 signature.orderedForEachParameter((ParameterElement parameter) {
1097 AstConstant argument = arguments[index++]; 1097 AstConstant argument = arguments[index++];
1098 Node node = parameter.node; 1098 Node node = parameter.node;
1099 if (parameter.isInitializingFormal) { 1099 if (parameter.isInitializingFormal) {
1100 InitializingFormalElement initializingFormal = parameter; 1100 InitializingFormalElement initializingFormal = parameter;
1101 updateFieldValue(node, initializingFormal.fieldElement, argument); 1101 updateFieldValue(node, initializingFormal.fieldElement, argument);
1102 } else { 1102 } else {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 } 1186 }
1187 } 1187 }
1188 } 1188 }
1189 1189
1190 /** 1190 /**
1191 * Simulates the execution of the [constructor] with the given 1191 * Simulates the execution of the [constructor] with the given
1192 * [arguments] to obtain the field values that need to be passed to the 1192 * [arguments] to obtain the field values that need to be passed to the
1193 * native JavaScript constructor. 1193 * native JavaScript constructor.
1194 */ 1194 */
1195 void evaluateConstructorFieldValues(List<AstConstant> arguments) { 1195 void evaluateConstructorFieldValues(List<AstConstant> arguments) {
1196 if (constructor.isErroneous) return; 1196 if (constructor.isMalformed) return;
1197 reporter.withCurrentElement(constructor, () { 1197 reporter.withCurrentElement(constructor, () {
1198 assignArgumentsToParameters(arguments); 1198 assignArgumentsToParameters(arguments);
1199 evaluateConstructorInitializers(); 1199 evaluateConstructorInitializers();
1200 }); 1200 });
1201 } 1201 }
1202 1202
1203 /// Builds a normalized list of the constant values for each field in the 1203 /// Builds a normalized list of the constant values for each field in the
1204 /// inheritance chain of [classElement]. 1204 /// inheritance chain of [classElement].
1205 Map<FieldElement, AstConstant> buildFieldConstants( 1205 Map<FieldElement, AstConstant> buildFieldConstants(
1206 ClassElement classElement) { 1206 ClassElement classElement) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 class _CompilerEnvironment implements Environment { 1269 class _CompilerEnvironment implements Environment {
1270 final Compiler compiler; 1270 final Compiler compiler;
1271 1271
1272 _CompilerEnvironment(this.compiler); 1272 _CompilerEnvironment(this.compiler);
1273 1273
1274 @override 1274 @override
1275 String readFromEnvironment(String name) { 1275 String readFromEnvironment(String name) {
1276 return compiler.fromEnvironment(name); 1276 return compiler.fromEnvironment(name);
1277 } 1277 }
1278 } 1278 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698