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

Unified Diff: sdk/lib/_internal/compiler/implementation/compile_time_constants.dart

Issue 21511003: Support symbol literals. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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/compile_time_constants.dart
diff --git a/sdk/lib/_internal/compiler/implementation/compile_time_constants.dart b/sdk/lib/_internal/compiler/implementation/compile_time_constants.dart
index baaef0ba5bf4932824591a6cd7756eb6ef9cf25b..083f5f2039be7b4151f8968b11b0ec58474d611c 100644
--- a/sdk/lib/_internal/compiler/implementation/compile_time_constants.dart
+++ b/sdk/lib/_internal/compiler/implementation/compile_time_constants.dart
@@ -433,7 +433,7 @@ class CompileTimeConstantEvaluator extends Visitor {
Constant visitLiteralNull(LiteralNull node) {
return constantSystem.createNull();
}
-
+
Constant visitLiteralString(LiteralString node) {
handler.registerStringInstance(elements);
return constantSystem.createString(node.dartString, node);
@@ -474,6 +474,16 @@ class CompileTimeConstantEvaluator extends Visitor {
handler.registerStringInstance(elements);
return constantSystem.createString(accumulator, node);
}
+
+ Constant visitSymbolLiteral(SymbolLiteral node) {
+ InterfaceType type = compiler.symbolClass.computeType(compiler);
+ List<Constant> createArguments(_) {
+ return [constantSystem.createString(
+ new DartString.literal(node.nameString), node)];
+ }
+ return makeConstructedConstant(
+ node, type, compiler.symbolConstructor, createArguments);
+ }
Constant makeTypeConstant(Element element) {
DartType elementType = element.computeType(compiler).asRaw();
@@ -687,6 +697,17 @@ class CompileTimeConstantEvaluator extends Visitor {
compiler.analyzeElement(constructor.declaration);
InterfaceType type = elements.getType(node);
+ List<Constant> evaluateArguments(FunctionElement constructor) {
+ Selector selector = elements.getSelector(send);
+ return evaluateArgumentsToConstructor(
+ node, selector, send.arguments, constructor);
+ }
+ return makeConstructedConstant(node, type, constructor, evaluateArguments);
+ }
+
+ Constant makeConstructedConstant(
+ Node node, InterfaceType type, FunctionElement constructor,
+ List<Constant> getArguments(FunctionElement constructor)) {
if (constructor.isRedirectingFactory) {
type = constructor.computeTargetType(compiler, type);
}
@@ -698,9 +719,7 @@ class CompileTimeConstantEvaluator extends Visitor {
constructor = constructor.implementation;
assert(invariant(node, constructor.isImplementation));
- Selector selector = elements.getSelector(send);
- List<Constant> arguments = evaluateArgumentsToConstructor(
- node, selector, send.arguments, constructor);
+ List<Constant> arguments = getArguments(constructor);
ConstructorEvaluator evaluator =
new ConstructorEvaluator(constructor, handler, compiler);
evaluator.evaluateConstructorFieldValues(arguments);
@@ -711,7 +730,7 @@ class CompileTimeConstantEvaluator extends Visitor {
handler.registerCompileTimeConstant(constant, elements);
return constant;
}
-
+
Constant visitParenthesizedExpression(ParenthesizedExpression node) {
return node.expression.accept(this);
}

Powered by Google App Engine
This is Rietveld 408576698