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

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

Issue 868643002: Revert "Change signature of lookupConstructor to only require a name." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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
1046 FunctionElement targetConstructor = 1049 FunctionElement targetConstructor =
1047 superClass.lookupDefaultConstructor(); 1050 superClass.lookupConstructor(selector);
1048 // If we do not find a default constructor, an error was reported 1051 if (targetConstructor == null) {
1049 // already and compilation will fail anyway. So just ignore that case. 1052 compiler.internalError(functionNode,
1050 if (targetConstructor != null) { 1053 "No default constructor available.");
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);
1056 } 1054 }
1055 List<AstConstant> compiledArguments =
1056 evaluateArgumentsToConstructor(
1057 functionNode, selector, const Link<Node>(), targetConstructor);
1058 evaluateSuperOrRedirectSend(compiledArguments, targetConstructor);
1057 } 1059 }
1058 } 1060 }
1059 } 1061 }
1060 1062
1061 /** 1063 /**
1062 * Simulates the execution of the [constructor] with the given 1064 * Simulates the execution of the [constructor] with the given
1063 * [arguments] to obtain the field values that need to be passed to the 1065 * [arguments] to obtain the field values that need to be passed to the
1064 * native JavaScript constructor. 1066 * native JavaScript constructor.
1065 */ 1067 */
1066 void evaluateConstructorFieldValues(List<AstConstant> arguments) { 1068 void evaluateConstructorFieldValues(List<AstConstant> arguments) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 ConstantValue get value => expression.value; 1120 ConstantValue get value => expression.value;
1119 1121
1120 String toString() => expression.toString(); 1122 String toString() => expression.toString();
1121 } 1123 }
1122 1124
1123 /// A synthetic constant used to recover from errors. 1125 /// A synthetic constant used to recover from errors.
1124 class ErroneousAstConstant extends AstConstant { 1126 class ErroneousAstConstant extends AstConstant {
1125 ErroneousAstConstant(Element element, Node node) 1127 ErroneousAstConstant(Element element, Node node)
1126 : super(element, node, new ErroneousConstantExpression()); 1128 : super(element, node, new ErroneousConstantExpression());
1127 } 1129 }
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