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

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: Updated cf. comments. Created 7 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/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 89e783b293d5aabc13a1593cf1b6d50cea63db3c..4d43a2a5adee683a69b91f23109732edd379db99 100644
--- a/sdk/lib/_internal/compiler/implementation/compile_time_constants.dart
+++ b/sdk/lib/_internal/compiler/implementation/compile_time_constants.dart
@@ -475,6 +475,16 @@ class CompileTimeConstantEvaluator extends Visitor {
return constantSystem.createString(accumulator, node);
}
+ Constant visitLiteralSymbol(LiteralSymbol node) {
+ InterfaceType type = compiler.symbolClass.computeType(compiler);
+ List<Constant> createArguments(_) {
+ return [constantSystem.createString(
ngeoffray 2013/09/04 07:14:17 add <Constant> (since you went into the trouble of
Johnni Winther 2013/09/10 09:09:07 Done.
+ new DartString.literal(node.slowNameString), node)];
+ }
+ return makeConstructedConstant(
+ node, type, compiler.symbolConstructor, createArguments);
+ }
+
Constant makeTypeConstant(Element element) {
DartType elementType = element.computeType(compiler).asRaw();
compiler.backend.registerTypeLiteral(element, elements);
@@ -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);

Powered by Google App Engine
This is Rietveld 408576698