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

Side by Side Diff: pkg/compiler/lib/src/resolution/members.dart

Issue 1109393012: Allow use of deferred type-literals in non-constant contexts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review Created 5 years, 7 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
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 resolution; 5 part of resolution;
6 6
7 abstract class TreeElements { 7 abstract class TreeElements {
8 AnalyzableElement get analyzedElement; 8 AnalyzableElement get analyzedElement;
9 Iterable<Node> get superUses; 9 Iterable<Node> get superUses;
10 10
(...skipping 2850 matching lines...) Expand 10 before | Expand all | Expand 10 after
2861 // Potentially a 'dynamic' type literal. 2861 // Potentially a 'dynamic' type literal.
2862 type = registry.getType(node.selector); 2862 type = registry.getType(node.selector);
2863 } 2863 }
2864 if (type == null) { 2864 if (type == null) {
2865 type = target.computeType(compiler); 2865 type = target.computeType(compiler);
2866 } 2866 }
2867 registry.registerTypeLiteral(node, type); 2867 registry.registerTypeLiteral(node, type);
2868 2868
2869 // Don't try to make constants of calls to type literals. 2869 // Don't try to make constants of calls to type literals.
2870 if (!node.isCall) { 2870 if (!node.isCall) {
2871 analyzeConstantDeferred(node); 2871 analyzeConstantDeferred(node, enforceConst: false);
2872 } else { 2872 } else {
2873 // The node itself is not a constant but we register the selector (the 2873 // The node itself is not a constant but we register the selector (the
2874 // identifier that refers to the class/typedef) as a constant. 2874 // identifier that refers to the class/typedef) as a constant.
2875 if (node.receiver != null) { 2875 if (node.receiver != null) {
2876 // This is a hack for the case of prefix.Type, we need to store 2876 // This is a hack for the case of prefix.Type, we need to store
2877 // the element on the selector, so [analyzeConstant] can build 2877 // the element on the selector, so [analyzeConstant] can build
2878 // the type literal from the selector. 2878 // the type literal from the selector.
2879 registry.useElement(node.selector, target); 2879 registry.useElement(node.selector, target);
2880 } 2880 }
2881 analyzeConstantDeferred(node.selector); 2881 analyzeConstantDeferred(node.selector, enforceConst: false);
2882 } 2882 }
2883 } 2883 }
2884 if (isPotentiallyMutableTarget(target)) { 2884 if (isPotentiallyMutableTarget(target)) {
2885 if (enclosingElement != target.enclosingElement) { 2885 if (enclosingElement != target.enclosingElement) {
2886 for (Node scope in promotionScope) { 2886 for (Node scope in promotionScope) {
2887 registry.setAccessedByClosureIn(scope, target, node); 2887 registry.setAccessedByClosureIn(scope, target, node);
2888 } 2888 }
2889 } 2889 }
2890 } 2890 }
2891 } 2891 }
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
3434 if (cls == compiler.stringClass) continue; 3434 if (cls == compiler.stringClass) continue;
3435 Element equals = cls.lookupMember('=='); 3435 Element equals = cls.lookupMember('==');
3436 if (equals.enclosingClass != compiler.objectClass) { 3436 if (equals.enclosingClass != compiler.objectClass) {
3437 compiler.reportError(spannable, 3437 compiler.reportError(spannable,
3438 MessageKind.CONST_MAP_KEY_OVERRIDES_EQUALS, 3438 MessageKind.CONST_MAP_KEY_OVERRIDES_EQUALS,
3439 {'type': keyType}); 3439 {'type': keyType});
3440 } 3440 }
3441 } 3441 }
3442 } 3442 }
3443 3443
3444 void analyzeConstant(Node node) { 3444 void analyzeConstant(Node node, {enforceConst: true}) {
3445 ConstantExpression constant = 3445 ConstantExpression constant =
3446 compiler.resolver.constantCompiler.compileNode( 3446 compiler.resolver.constantCompiler.compileNode(
3447 node, registry.mapping); 3447 node, registry.mapping, enforceConst: enforceConst);
3448 3448
3449 if (constant == null) { 3449 if (constant == null) {
3450 assert(invariant(node, compiler.compilationFailed)); 3450 assert(invariant(node, compiler.compilationFailed));
3451 return; 3451 return;
3452 } 3452 }
3453 3453
3454 ConstantValue value = constant.value; 3454 ConstantValue value = constant.value;
3455 if (value.isMap) { 3455 if (value.isMap) {
3456 checkConstMapKeysDontOverrideEquals(node, value); 3456 checkConstMapKeysDontOverrideEquals(node, value);
3457 } 3457 }
(...skipping 11 matching lines...) Expand all
3469 compiler.reportError(node, 3469 compiler.reportError(node,
3470 MessageKind.WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT); 3470 MessageKind.WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT);
3471 } 3471 }
3472 } else { 3472 } else {
3473 compiler.reportError(node, 3473 compiler.reportError(node,
3474 MessageKind.WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT); 3474 MessageKind.WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT);
3475 } 3475 }
3476 } 3476 }
3477 } 3477 }
3478 3478
3479 void analyzeConstantDeferred(Node node) { 3479 void analyzeConstantDeferred(Node node, {bool enforceConst: true}) {
3480 addDeferredAction(enclosingElement, () { 3480 addDeferredAction(enclosingElement, () {
3481 analyzeConstant(node); 3481 analyzeConstant(node, enforceConst: enforceConst);
3482 }); 3482 });
3483 } 3483 }
3484 3484
3485 bool validateSymbol(Node node, String name, {bool reportError: true}) { 3485 bool validateSymbol(Node node, String name, {bool reportError: true}) {
3486 if (name.isEmpty) return true; 3486 if (name.isEmpty) return true;
3487 if (name.startsWith('_')) { 3487 if (name.startsWith('_')) {
3488 if (reportError) { 3488 if (reportError) {
3489 compiler.reportError(node, MessageKind.PRIVATE_IDENTIFIER, 3489 compiler.reportError(node, MessageKind.PRIVATE_IDENTIFIER,
3490 {'value': name}); 3490 {'value': name});
3491 } 3491 }
(...skipping 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after
5148 } 5148 }
5149 5149
5150 /// The result for the resolution of the `assert` method. 5150 /// The result for the resolution of the `assert` method.
5151 class AssertResult implements ResolutionResult { 5151 class AssertResult implements ResolutionResult {
5152 const AssertResult(); 5152 const AssertResult();
5153 5153
5154 Element get element => null; 5154 Element get element => null;
5155 5155
5156 String toString() => 'AssertResult()'; 5156 String toString() => 'AssertResult()';
5157 } 5157 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/type_variable_handler.dart ('k') | pkg/compiler/lib/src/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698