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

Side by Side Diff: frog/leg/compile_time_constants.dart

Issue 9360039: Create values for literal Strings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add removed line again. Created 8 years, 10 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
« no previous file with comments | « no previous file | tests/co19/co19-leg.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /** 5 /**
6 * The [CompileTimeConstantHandler] keeps track of compile-time constants, 6 * The [CompileTimeConstantHandler] keeps track of compile-time constants,
7 * initializations of global and static fields, and default values of 7 * initializations of global and static fields, and default values of
8 * optional parameters. 8 * optional parameters.
9 */ 9 */
10 class CompileTimeConstantHandler extends CompilerTask { 10 class CompileTimeConstantHandler extends CompilerTask {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 && element.modifiers.isFinal(); 89 && element.modifiers.isFinal();
90 }); 90 });
91 } 91 }
92 92
93 String getJsCodeForVariable(VariableElement element) { 93 String getJsCodeForVariable(VariableElement element) {
94 var value = initialVariableValues[element]; 94 var value = initialVariableValues[element];
95 if (value === null) return "(void 0)"; 95 if (value === null) return "(void 0)";
96 if (value is num) return "$value"; 96 if (value is num) return "$value";
97 if (value === true) return "true"; 97 if (value === true) return "true";
98 if (value === false) return "false"; 98 if (value === false) return "false";
99 if (value is SourceString) return value.stringValue;
floitsch 2012/02/14 10:40:57 The string must be escaped. Please also add a smal
99 100
100 // TODO(floitsch): support more values. 101 // TODO(floitsch): support more values.
101 compiler.unimplemented("CompileTimeConstantHandler.getJsCodeForVariable", 102 compiler.unimplemented("CompileTimeConstantHandler.getJsCodeForVariable",
102 node: element.parseNode(compiler)); 103 node: element.parseNode(compiler));
103 } 104 }
104 } 105 }
105 106
106 class CompileTimeConstantEvaluator extends AbstractVisitor { 107 class CompileTimeConstantEvaluator extends AbstractVisitor {
107 final CompileTimeConstantHandler constantHandler; 108 final CompileTimeConstantHandler constantHandler;
108 final TreeElements definitions; 109 final TreeElements definitions;
(...skipping 30 matching lines...) Expand all
139 140
140 error(Element element) { 141 error(Element element) {
141 // TODO(floitsch): get the list of constants that are currently compiled 142 // TODO(floitsch): get the list of constants that are currently compiled
142 // and present some kind of stack-trace. 143 // and present some kind of stack-trace.
143 MessageKind kind = MessageKind.NOT_A_COMPILE_TIME_CONSTANT; 144 MessageKind kind = MessageKind.NOT_A_COMPILE_TIME_CONSTANT;
144 List arguments = [element.name]; 145 List arguments = [element.name];
145 Node node = element.parseNode(compiler); 146 Node node = element.parseNode(compiler);
146 compiler.reportError(node, new CompileTimeConstantError(kind, arguments)); 147 compiler.reportError(node, new CompileTimeConstantError(kind, arguments));
147 } 148 }
148 } 149 }
OLDNEW
« no previous file with comments | « no previous file | tests/co19/co19-leg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698