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

Side by Side Diff: pkg/compiler/lib/src/js_backend/constant_handler_javascript.dart

Issue 1182663008: Typecheck const classes in the context of the constructor call. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address comments Created 5 years, 4 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 js_backend; 5 part of js_backend;
6 6
7 /// [ConstantCompilerTask] for compilation of constants for the JavaScript 7 /// [ConstantCompilerTask] for compilation of constants for the JavaScript
8 /// backend. 8 /// backend.
9 /// 9 ///
10 /// Since this task needs to distinguish between frontend and backend constants 10 /// Since this task needs to distinguish between frontend and backend constants
(...skipping 26 matching lines...) Expand all
37 } 37 }
38 38
39 @override 39 @override
40 ConstantExpression getConstantForVariable(VariableElement element) { 40 ConstantExpression getConstantForVariable(VariableElement element) {
41 return dartConstantCompiler.getConstantForVariable(element); 41 return dartConstantCompiler.getConstantForVariable(element);
42 } 42 }
43 43
44 @override 44 @override
45 ConstantExpression compileConstant(VariableElement element) { 45 ConstantExpression compileConstant(VariableElement element) {
46 return measure(() { 46 return measure(() {
47 // TODO(het): Only report errors from one of the constant compilers
47 ConstantExpression result = dartConstantCompiler.compileConstant(element); 48 ConstantExpression result = dartConstantCompiler.compileConstant(element);
48 jsConstantCompiler.compileConstant(element); 49 jsConstantCompiler.compileConstant(element);
49 return result; 50 return result;
50 }); 51 });
51 } 52 }
52 53
53 @override 54 @override
54 void evaluate(ConstantExpression constant) { 55 void evaluate(ConstantExpression constant) {
55 return measure(() { 56 return measure(() {
56 dartConstantCompiler.evaluate(constant); 57 dartConstantCompiler.evaluate(constant);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 120
120 // Constants computed for metadata. 121 // Constants computed for metadata.
121 final Map<MetadataAnnotation, ConstantExpression> metadataConstantMap = 122 final Map<MetadataAnnotation, ConstantExpression> metadataConstantMap =
122 new Map<MetadataAnnotation, ConstantExpression>(); 123 new Map<MetadataAnnotation, ConstantExpression>();
123 124
124 JavaScriptConstantCompiler(Compiler compiler) 125 JavaScriptConstantCompiler(Compiler compiler)
125 : super(compiler, JAVA_SCRIPT_CONSTANT_SYSTEM); 126 : super(compiler, JAVA_SCRIPT_CONSTANT_SYSTEM);
126 127
127 ConstantExpression compileVariableWithDefinitions(VariableElement element, 128 ConstantExpression compileVariableWithDefinitions(VariableElement element,
128 TreeElements definitions, 129 TreeElements definitions,
129 {bool isConst: false}) { 130 {bool isConst: false,
131 bool checkType: true}) {
130 if (!isConst && lazyStatics.contains(element)) { 132 if (!isConst && lazyStatics.contains(element)) {
131 return null; 133 return null;
132 } 134 }
133 ConstantExpression value = super.compileVariableWithDefinitions( 135 ConstantExpression value = super.compileVariableWithDefinitions(
134 element, definitions, isConst: isConst); 136 element, definitions, isConst: isConst, checkType: checkType);
135 if (!isConst && value == null) { 137 if (!isConst && value == null) {
136 lazyStatics.add(element); 138 lazyStatics.add(element);
137 } 139 }
138 return value; 140 return value;
139 } 141 }
140 142
141 void addCompileTimeConstantForEmission(ConstantValue constant) { 143 void addCompileTimeConstantForEmission(ConstantValue constant) {
142 compiledConstants.add(constant); 144 compiledConstants.add(constant);
143 } 145 }
144 146
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 // TODO(ahe): This doesn't belong here. Rename this class and generalize. 290 // TODO(ahe): This doesn't belong here. Rename this class and generalize.
289 var closureClassMap = 291 var closureClassMap =
290 constants.compiler.closureToClassMapper.closureMappingCache 292 constants.compiler.closureToClassMapper.closureMappingCache
291 .remove(node); 293 .remove(node);
292 if (closureClassMap != null) { 294 if (closureClassMap != null) {
293 closureClassMap.removeMyselfFrom( 295 closureClassMap.removeMyselfFrom(
294 constants.compiler.enqueuer.codegen.universe); 296 constants.compiler.enqueuer.codegen.universe);
295 } 297 }
296 } 298 }
297 } 299 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/compile_time_constants.dart ('k') | tests/compiler/dart2js/compiler_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698