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

Unified Diff: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 574683002: Use ConstExp for storing constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes and further implementation. Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/resolution/members.dart
diff --git a/sdk/lib/_internal/compiler/implementation/resolution/members.dart b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
index 0b76aecfe728f0b8ebee2a667d5fbb9c20809272..ce0a51022b65cdce3e9416f607bd39715de4ee98 100644
--- a/sdk/lib/_internal/compiler/implementation/resolution/members.dart
+++ b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
@@ -11,7 +11,7 @@ abstract class TreeElements {
/// Iterables of the dependencies that this [TreeElement] records of
/// [analyzedElement].
Iterable<Element> get allElements;
- void forEachConstantNode(f(Node n, Constant c));
+ void forEachConstantNode(f(Node n, ConstExp c));
/// A set of additional dependencies. See [registerDependency] below.
Iterable<Element> get otherDependencies;
@@ -35,8 +35,8 @@ abstract class TreeElements {
void setIteratorSelector(ForIn node, Selector selector);
void setMoveNextSelector(ForIn node, Selector selector);
void setCurrentSelector(ForIn node, Selector selector);
- void setConstant(Node node, Constant constant);
- Constant getConstant(Node node);
+ void setConstant(Node node, ConstExp constant);
+ ConstExp getConstant(Node node);
bool isAssert(Send send);
/// Returns the [FunctionElement] defined by [node].
@@ -93,7 +93,7 @@ class TreeElementMapping implements TreeElements {
Map<Node, DartType> _types;
Setlet<Node> _superUses;
Setlet<Element> _otherDependencies;
- Map<Node, Constant> _constants;
+ Map<Node, ConstExp> _constants;
Map<VariableElement, List<Node>> _potentiallyMutated;
Map<Node, Map<VariableElement, List<Node>>> _potentiallyMutatedIn;
Map<VariableElement, List<Node>> _potentiallyMutatedInClosure;
@@ -236,14 +236,14 @@ class TreeElementMapping implements TreeElements {
return this[node];
}
- void setConstant(Node node, Constant constant) {
+ void setConstant(Node node, ConstExp constant) {
if (_constants == null) {
- _constants = new Maplet<Node, Constant>();
+ _constants = new Maplet<Node, ConstExp>();
}
_constants[node] = constant;
}
- Constant getConstant(Node node) {
+ ConstExp getConstant(Node node) {
return _constants != null ? _constants[node] : null;
}
@@ -344,7 +344,7 @@ class TreeElementMapping implements TreeElements {
return _elements != null ? _elements : const <Element>[];
}
- void forEachConstantNode(f(Node n, Constant c)) {
+ void forEachConstantNode(f(Node n, ConstExp c)) {
if (_constants != null) {
_constants.forEach(f);
}
@@ -1012,7 +1012,8 @@ class ResolverTask extends CompilerTask {
void _postProcessClassElement(BaseClassElementX element) {
for (MetadataAnnotation metadata in element.metadata) {
metadata.ensureResolved(compiler);
- if (!element.isProxy && metadata.value == compiler.proxyConstant) {
+ if (!element.isProxy &&
+ metadata.constant.value == compiler.proxyConstant) {
element.isProxy = true;
}
}
@@ -1401,7 +1402,7 @@ class ResolverTask extends CompilerTask {
node.accept(visitor);
// TODO(johnniwinther): Avoid passing the [TreeElements] to
// [compileMetadata].
- annotation.value =
+ annotation.constant =
constantCompiler.compileMetadata(annotation, node, registry.mapping);
// TODO(johnniwinther): Register the relation between the annotation
// and the annotated element instead. This will allow the backend to
@@ -3308,8 +3309,9 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
if (isSymbolConstructor) {
if (node.isConst) {
Node argumentNode = node.send.arguments.head;
- Constant name = compiler.resolver.constantCompiler.compileNode(
+ ConstExp constant = compiler.resolver.constantCompiler.compileNode(
argumentNode, registry.mapping);
+ Constant name = constant.value;
if (!name.isString) {
DartType type = name.computeType(compiler);
compiler.reportError(argumentNode, MessageKind.STRING_EXPECTED,
@@ -3359,11 +3361,12 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
void analyzeConstant(Node node) {
addDeferredAction(enclosingElement, () {
- Constant constant = compiler.resolver.constantCompiler.compileNode(
+ ConstExp constant = compiler.resolver.constantCompiler.compileNode(
node, registry.mapping);
- if (constant.isMap) {
- checkConstMapKeysDontOverrideEquals(node, constant);
+ Constant value = constant.value;
+ if (value.isMap) {
+ checkConstMapKeysDontOverrideEquals(node, value);
}
// The type constant that is an argument to JS_INTERCEPTOR_CONSTANT names
@@ -3371,8 +3374,8 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
// native class dispatch record referencing the interceptor.
if (argumentsToJsInterceptorConstant != null &&
argumentsToJsInterceptorConstant.contains(node)) {
- if (constant.isType) {
- TypeConstant typeConstant = constant;
+ if (value.isType) {
+ TypeConstant typeConstant = value;
if (typeConstant.representedType is InterfaceType) {
registry.registerInstantiatedType(typeConstant.representedType);
} else {
@@ -3745,11 +3748,11 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
if (caseMatch == null) continue;
// Analyze the constant.
- Constant constant = registry.getConstant(caseMatch.expression);
+ ConstExp constant = registry.getConstant(caseMatch.expression);
assert(invariant(node, constant != null,
message: 'No constant computed for $node'));
- DartType caseType = typeOfConstant(constant);
+ DartType caseType = typeOfConstant(constant.value);
if (firstCaseType == null) {
firstCase = caseMatch;
@@ -3764,7 +3767,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
} else if (caseType.element == compiler.functionClass) {
compiler.reportError(node, MessageKind.SWITCH_CASE_FORBIDDEN,
{'type': "Function"});
- } else if (constant.isObject && overridesEquals(caseType)) {
+ } else if (constant.value.isObject && overridesEquals(caseType)) {
compiler.reportError(firstCase.expression,
MessageKind.SWITCH_CASE_VALUE_OVERRIDES_EQUALS,
{'type': caseType});

Powered by Google App Engine
This is Rietveld 408576698