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

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

Issue 812523002: Change signature of lookupConstructor to only require a name. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: return null for unresolved default constructors Created 5 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer2dart/lib/src/modely.dart ('k') | 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 part of dart2js; 5 part of dart2js;
6 6
7 /// A [ConstantEnvironment] provides access for constants compiled for variable 7 /// A [ConstantEnvironment] provides access for constants compiled for variable
8 /// initializers. 8 /// initializers.
9 abstract class ConstantEnvironment { 9 abstract class ConstantEnvironment {
10 /// Returns the constant for the initializer of [element]. 10 /// Returns the constant for the initializer of [element].
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 1036
1037 if (!foundSuperOrRedirect) { 1037 if (!foundSuperOrRedirect) {
1038 // No super initializer found. Try to find the default constructor if 1038 // No super initializer found. Try to find the default constructor if
1039 // the class is not Object. 1039 // the class is not Object.
1040 ClassElement enclosingClass = constructor.enclosingClass; 1040 ClassElement enclosingClass = constructor.enclosingClass;
1041 ClassElement superClass = enclosingClass.superclass; 1041 ClassElement superClass = enclosingClass.superclass;
1042 if (enclosingClass != compiler.objectClass) { 1042 if (enclosingClass != compiler.objectClass) {
1043 assert(superClass != null); 1043 assert(superClass != null);
1044 assert(superClass.resolutionState == STATE_DONE); 1044 assert(superClass.resolutionState == STATE_DONE);
1045 1045
1046 Selector selector =
1047 new Selector.callDefaultConstructor(enclosingClass.library);
1048
1049 FunctionElement targetConstructor = 1046 FunctionElement targetConstructor =
1050 superClass.lookupConstructor(selector); 1047 superClass.lookupDefaultConstructor();
1051 if (targetConstructor == null) { 1048 // If we do not find a default constructor, an error was reported
1052 compiler.internalError(functionNode, 1049 // already and compilation will fail anyway. So just ignore that case.
1053 "No default constructor available."); 1050 if (targetConstructor != null) {
1051 Selector selector =
1052 new Selector.callDefaultConstructor(enclosingClass.library);
1053 List<AstConstant> compiledArguments = evaluateArgumentsToConstructor(
1054 functionNode, selector, const Link<Node>(), targetConstructor);
1055 evaluateSuperOrRedirectSend(compiledArguments, targetConstructor);
1054 } 1056 }
1055 List<AstConstant> compiledArguments =
1056 evaluateArgumentsToConstructor(
1057 functionNode, selector, const Link<Node>(), targetConstructor);
1058 evaluateSuperOrRedirectSend(compiledArguments, targetConstructor);
1059 } 1057 }
1060 } 1058 }
1061 } 1059 }
1062 1060
1063 /** 1061 /**
1064 * Simulates the execution of the [constructor] with the given 1062 * Simulates the execution of the [constructor] with the given
1065 * [arguments] to obtain the field values that need to be passed to the 1063 * [arguments] to obtain the field values that need to be passed to the
1066 * native JavaScript constructor. 1064 * native JavaScript constructor.
1067 */ 1065 */
1068 void evaluateConstructorFieldValues(List<AstConstant> arguments) { 1066 void evaluateConstructorFieldValues(List<AstConstant> arguments) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 ConstantValue get value => expression.value; 1118 ConstantValue get value => expression.value;
1121 1119
1122 String toString() => expression.toString(); 1120 String toString() => expression.toString();
1123 } 1121 }
1124 1122
1125 /// A synthetic constant used to recover from errors. 1123 /// A synthetic constant used to recover from errors.
1126 class ErroneousAstConstant extends AstConstant { 1124 class ErroneousAstConstant extends AstConstant {
1127 ErroneousAstConstant(Element element, Node node) 1125 ErroneousAstConstant(Element element, Node node)
1128 : super(element, node, new ErroneousConstantExpression()); 1126 : super(element, node, new ErroneousConstantExpression());
1129 } 1127 }
OLDNEW
« no previous file with comments | « pkg/analyzer2dart/lib/src/modely.dart ('k') | pkg/compiler/lib/src/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698