Chromium Code Reviews| OLD | NEW |
|---|---|
| 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.resolution; | 5 library dart2js.resolution; |
| 6 | 6 |
| 7 import 'dart:collection' show Queue; | 7 import 'dart:collection' show Queue; |
| 8 | 8 |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../common/names.dart' show | 10 import '../common/names.dart' show |
| 11 Identifiers; | 11 Identifiers; |
| 12 import '../common/resolution.dart' show | 12 import '../common/resolution.dart' show |
| 13 Feature, | 13 Feature, |
| 14 Parsing, | 14 Parsing, |
| 15 Resolution, | 15 Resolution, |
| 16 ResolutionImpact; | 16 ResolutionImpact; |
| 17 import '../common/tasks.dart' show | 17 import '../common/tasks.dart' show |
| 18 CompilerTask, | 18 CompilerTask, |
| 19 DeferredAction; | 19 DeferredAction; |
| 20 import '../compiler.dart' show | 20 import '../compiler.dart' show |
| 21 Compiler; | 21 Compiler; |
| 22 import '../compile_time_constants.dart' show | 22 import '../compile_time_constants.dart' show |
| 23 ConstantCompiler; | 23 ConstantCompiler; |
| 24 import '../constants/expressions.dart' show | |
| 25 ConstantExpression, | |
| 26 ConstantExpressionKind, | |
| 27 ConstructedConstantExpression, | |
| 28 ErroneousConstantExpression; | |
| 24 import '../constants/values.dart' show | 29 import '../constants/values.dart' show |
| 25 ConstantValue; | 30 ConstantValue; |
| 26 import '../core_types.dart' show | 31 import '../core_types.dart' show |
| 27 CoreClasses, | 32 CoreClasses, |
| 28 CoreTypes; | 33 CoreTypes; |
| 29 import '../dart_types.dart'; | 34 import '../dart_types.dart'; |
| 30 import '../elements/elements.dart'; | 35 import '../elements/elements.dart'; |
| 31 import '../elements/modelx.dart' show | 36 import '../elements/modelx.dart' show |
| 32 BaseClassElementX, | 37 BaseClassElementX, |
| 33 BaseFunctionElementX, | 38 BaseFunctionElementX, |
| (...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1054 classElement.ensureResolved(resolution); | 1059 classElement.ensureResolved(resolution); |
| 1055 } | 1060 } |
| 1056 assert(invariant(node, context != null, | 1061 assert(invariant(node, context != null, |
| 1057 message: "No context found for metadata annotation " | 1062 message: "No context found for metadata annotation " |
| 1058 "on $annotatedElement.")); | 1063 "on $annotatedElement.")); |
| 1059 ResolverVisitor visitor = visitorFor(context, useEnclosingScope: true); | 1064 ResolverVisitor visitor = visitorFor(context, useEnclosingScope: true); |
| 1060 ResolutionRegistry registry = visitor.registry; | 1065 ResolutionRegistry registry = visitor.registry; |
| 1061 node.accept(visitor); | 1066 node.accept(visitor); |
| 1062 // TODO(johnniwinther): Avoid passing the [TreeElements] to | 1067 // TODO(johnniwinther): Avoid passing the [TreeElements] to |
| 1063 // [compileMetadata]. | 1068 // [compileMetadata]. |
| 1064 annotation.constant = | 1069 ConstantExpression constant = constantCompiler.compileMetadata( |
| 1065 constantCompiler.compileMetadata(annotation, node, registry.mapping); | 1070 annotation, node, registry.mapping); |
| 1071 switch (constant.kind) { | |
| 1072 case ConstantExpressionKind.CONSTRUCTED: | |
| 1073 ConstructedConstantExpression constructedConstant = constant; | |
| 1074 if (constructedConstant.type.isGeneric) { | |
| 1075 // Enforce the unnecessary syntactic restriction that disallows type | |
|
karlklose
2015/12/09 14:07:29
Maybe file a bug against the specification instead
Johnni Winther
2015/12/09 14:43:43
Done.
| |
| 1076 // arguments in the immediate const constructor call. | |
| 1077 reporter.reportErrorMessage( | |
| 1078 node, MessageKind.INVALID_METADATA_GENERIC); | |
| 1079 constant = new ErroneousConstantExpression(); | |
| 1080 } | |
| 1081 break; | |
| 1082 case ConstantExpressionKind.VARIABLE: | |
| 1083 case ConstantExpressionKind.ERRONEOUS: | |
| 1084 break; | |
| 1085 default: | |
|
karlklose
2015/12/09 14:07:29
Consider asserting what can reach here.
Johnni Winther
2015/12/09 14:43:43
Everything else (the kind is an enum).
| |
| 1086 reporter.reportErrorMessage(node, MessageKind.INVALID_METADATA); | |
| 1087 constant = new ErroneousConstantExpression(); | |
| 1088 break; | |
| 1089 } | |
| 1090 annotation.constant = constant; | |
| 1091 | |
| 1066 constantCompiler.evaluate(annotation.constant); | 1092 constantCompiler.evaluate(annotation.constant); |
| 1067 // TODO(johnniwinther): Register the relation between the annotation | 1093 // TODO(johnniwinther): Register the relation between the annotation |
| 1068 // and the annotated element instead. This will allow the backend to | 1094 // and the annotated element instead. This will allow the backend to |
| 1069 // retrieve the backend constant and only register metadata on the | 1095 // retrieve the backend constant and only register metadata on the |
| 1070 // elements for which it is needed. (Issue 17732). | 1096 // elements for which it is needed. (Issue 17732). |
| 1071 registry.registerMetadataConstant(annotation); | 1097 registry.registerMetadataConstant(annotation); |
| 1072 annotation.resolutionState = STATE_DONE; | 1098 annotation.resolutionState = STATE_DONE; |
| 1073 })); | 1099 })); |
| 1074 } | 1100 } |
| 1075 | 1101 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1101 TreeElements get treeElements { | 1127 TreeElements get treeElements { |
| 1102 assert(invariant(this, _treeElements !=null, | 1128 assert(invariant(this, _treeElements !=null, |
| 1103 message: "TreeElements have not been computed for $this.")); | 1129 message: "TreeElements have not been computed for $this.")); |
| 1104 return _treeElements; | 1130 return _treeElements; |
| 1105 } | 1131 } |
| 1106 | 1132 |
| 1107 void reuseElement() { | 1133 void reuseElement() { |
| 1108 _treeElements = null; | 1134 _treeElements = null; |
| 1109 } | 1135 } |
| 1110 } | 1136 } |
| OLD | NEW |