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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/compile_time_constants.dart

Issue 11419037: Use the constant system to do a subtype type in the compile time constant handler. This is needed b… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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 | « no previous file | tests/language/compile_time_constant_q_test.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 /** 7 /**
8 * The [ConstantHandler] keeps track of compile-time constants, 8 * The [ConstantHandler] keeps track of compile-time constants,
9 * initializations of global and static fields, and default values of 9 * initializations of global and static fields, and default values of
10 * optional parameters. 10 * optional parameters.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 value = new NullConstant(); 127 value = new NullConstant();
128 } else { 128 } else {
129 Node right = assignment.arguments.head; 129 Node right = assignment.arguments.head;
130 value = 130 value =
131 compileNodeWithDefinitions(right, definitions, isConst: isConst); 131 compileNodeWithDefinitions(right, definitions, isConst: isConst);
132 if (compiler.enableTypeAssertions 132 if (compiler.enableTypeAssertions
133 && value != null 133 && value != null
134 && element.isField()) { 134 && element.isField()) {
135 DartType elementType = element.computeType(compiler); 135 DartType elementType = element.computeType(compiler);
136 DartType constantType = value.computeType(compiler); 136 DartType constantType = value.computeType(compiler);
137 if (!compiler.types.isSubtype(constantType, elementType)) { 137 if (!constantSystem.isSubtype(compiler, constantType, elementType)) {
138 if (isConst) { 138 if (isConst) {
139 MessageKind kind = MessageKind.NOT_ASSIGNABLE; 139 MessageKind kind = MessageKind.NOT_ASSIGNABLE;
140 compiler.reportError(node, new CompileTimeConstantError( 140 compiler.reportError(node, new CompileTimeConstantError(
141 kind, [elementType, constantType])); 141 kind, [elementType, constantType]));
142 } else { 142 } else {
143 // If the field can be lazily initialized, we will throw 143 // If the field can be lazily initialized, we will throw
144 // the exception at runtime. 144 // the exception at runtime.
145 value = null; 145 value = null;
146 } 146 }
147 } 147 }
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 // Use the default value. 823 // Use the default value.
824 fieldValue = compiler.compileConstant(field); 824 fieldValue = compiler.compileConstant(field);
825 } 825 }
826 jsNewArguments.add(fieldValue); 826 jsNewArguments.add(fieldValue);
827 }, 827 },
828 includeBackendMembers: true, 828 includeBackendMembers: true,
829 includeSuperMembers: true); 829 includeSuperMembers: true);
830 return jsNewArguments; 830 return jsNewArguments;
831 } 831 }
832 } 832 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/compile_time_constant_q_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698