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

Unified Diff: frog/leg/compile_time_constants.dart

Issue 9703105: Re-land r5529. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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
« no previous file with comments | « client/tests/client/client-leg.status ('k') | frog/leg/resolver.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/compile_time_constants.dart
diff --git a/frog/leg/compile_time_constants.dart b/frog/leg/compile_time_constants.dart
index ddd80a2143a623c249c4d79ba9ec02307518b61c..f6994b40f7c8ff916c28a4b320ade3b8555d9008 100644
--- a/frog/leg/compile_time_constants.dart
+++ b/frog/leg/compile_time_constants.dart
@@ -901,37 +901,21 @@ class CompileTimeConstantEvaluator extends AbstractVisitor {
}
Constant visitNewExpression(NewExpression node) {
- List<Constant> compileArguments() {
- if (!node.isConst()) error(node);
- Send send = node.send;
- List<Constant> arguments;
- if (send.arguments.isEmpty()) {
- arguments = const <Constant>[];
- } else {
- arguments = <Constant>[];
- for (Link<Node> link = send.arguments;
- !link.isEmpty();
- link = link.tail) {
- arguments.add(evaluate(link.head));
- }
- }
- return arguments;
- }
-
void assignArgumentsToParameters(
- List<Constant> arguments,
FunctionParameters parameters,
Map<Element, Constant> constructorDefinitions,
Map<Element, Constant> fieldValues) {
- if (arguments.length != parameters.parameterCount) {
- if (arguments.length < parameters.parameterCount &&
- arguments.length >= parameters.requiredParameterCount) {
- compiler.unimplemented("ConstantHandler with optional arguments",
- node: node);
- } else {
- error(node);
- }
- }
+ Send send = node.send;
+ if (send.arguments.isEmpty() && parameters.parameterCount == 0) return;
+ List<Constant> arguments = <Constant>[];
+ Selector selector = elements.getSelector(send);
+
+ Function compileArgument = evaluate;
+ Function compileConstant = constantHandler.compileVariable;
+ bool succeeded = selector.addSendArgumentsToList(
+ send, arguments, parameters, compileArgument, compileConstant);
+ if (!succeeded) error(node);
+
int index = 0;
parameters.forEachParameter((Element parameter) {
Constant argument = arguments[index++];
@@ -987,6 +971,8 @@ class CompileTimeConstantEvaluator extends AbstractVisitor {
return jsNewArguments;
}
+ if (!node.isConst()) error(node);
+
// TODO(floitsch): get the type from somewhere.
FunctionElement constructor = elements[node.send];
ClassElement classElement = constructor.enclosingElement;
@@ -1000,9 +986,8 @@ class CompileTimeConstantEvaluator extends AbstractVisitor {
Map<Element, Constant> constructorDefinitions =
new Map<Element, Constant>();
- List<Constant> arguments = compileArguments();
- assignArgumentsToParameters(arguments, parameters,
- constructorDefinitions, fieldValues);
+ assignArgumentsToParameters(parameters, constructorDefinitions,
+ fieldValues);
CompileTimeConstantEvaluator initializerEvaluator =
new CompileTimeConstantEvaluator.insideConstructor(
constantHandler, constructorElements, compiler,
« no previous file with comments | « client/tests/client/client-leg.status ('k') | frog/leg/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698