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

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

Issue 1115183002: Add ConstantConstructor to ConstantExpression system. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add test. 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.semantics_visitor; 5 part of dart2js.semantics_visitor;
6 6
7 enum SendStructureKind { 7 enum SendStructureKind {
8 GET, 8 GET,
9 SET, 9 SET,
10 INVOKE, 10 INVOKE,
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 Node node = definitions.definitions.nodes.single; 741 Node node = definitions.definitions.nodes.single;
742 ParameterElement element = elements[node]; 742 ParameterElement element = elements[node];
743 if (element == null) { 743 if (element == null) {
744 throw new SpannableAssertionFailure( 744 throw new SpannableAssertionFailure(
745 node, "No parameter structure for $node."); 745 node, "No parameter structure for $node.");
746 } 746 }
747 if (isRequired) { 747 if (isRequired) {
748 return new RequiredParameterStructure( 748 return new RequiredParameterStructure(
749 definitions, node, element, index); 749 definitions, node, element, index);
750 } else { 750 } else {
751 ConstantExpression defaultValue; 751 // TODO(johnniwinther): Should we differentiate between implicit (null)
752 if (element.initializer != null) { 752 // and explicit values? What about optional parameters on redirecting
753 defaultValue = elements.getConstant(element.initializer); 753 // factories?
754 }
755 if (isNamed) { 754 if (isNamed) {
756 return new NamedParameterStructure( 755 return new NamedParameterStructure(
757 definitions, node, element, defaultValue); 756 definitions, node, element, element.constant);
758 } else { 757 } else {
759 return new OptionalParameterStructure( 758 return new OptionalParameterStructure(
760 definitions, node, element, defaultValue, index); 759 definitions, node, element, element.constant, index);
761 } 760 }
762 } 761 }
763 } 762 }
764 763
765 void computeVariableStructures( 764 void computeVariableStructures(
766 VariableDefinitions definitions, 765 VariableDefinitions definitions,
767 void callback(Node node, VariableStructure structure)) { 766 void callback(Node node, VariableStructure structure)) {
768 for (Node node in definitions.definitions) { 767 for (Node node in definitions.definitions) {
769 callback(definitions, computeVariableStructure(node)); 768 callback(definitions, computeVariableStructure(node));
770 } 769 }
(...skipping 14 matching lines...) Expand all
785 return internalError(node, "Unexpected variable $element."); 784 return internalError(node, "Unexpected variable $element.");
786 } 785 }
787 if (element.isConst) { 786 if (element.isConst) {
788 ConstantExpression constant = elements.getConstant(element.initializer); 787 ConstantExpression constant = elements.getConstant(element.initializer);
789 return new ConstantVariableStructure(kind, node, element, constant); 788 return new ConstantVariableStructure(kind, node, element, constant);
790 } else { 789 } else {
791 return new NonConstantVariableStructure(kind, node, element); 790 return new NonConstantVariableStructure(kind, node, element);
792 } 791 }
793 } 792 }
794 } 793 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698