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

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

Issue 9421025: Improve double implementation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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 | dart/frog/leg/lib/js_helper.dart » ('j') | dart/frog/leg/lib/js_helper.dart » ('J')
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 // TODO(floitsch): finish implementation. 5 // TODO(floitsch): finish implementation.
6 class CompileTimeConstant implements Hashable { 6 class CompileTimeConstant implements Hashable {
7 static int idCounter = 0; 7 static int idCounter = 0;
8 8
9 // TODO(floitsch): don't just expose the name. 9 // TODO(floitsch): don't just expose the name.
10 final String name; 10 final String name;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 154 }
155 155
156 List<CompileTimeConstant> getCompileTimeConstantsForEmission() { 156 List<CompileTimeConstant> getCompileTimeConstantsForEmission() {
157 return new List<CompileTimeConstant>.from(compiledConstants); 157 return new List<CompileTimeConstant>.from(compiledConstants);
158 } 158 }
159 159
160 StringBuffer writeJsCode(StringBuffer buffer, var value) { 160 StringBuffer writeJsCode(StringBuffer buffer, var value) {
161 if (value === null) { 161 if (value === null) {
162 buffer.add("(void 0)"); 162 buffer.add("(void 0)");
163 } else if (value is num) { 163 } else if (value is num) {
164 if (value.isNaN()) buffer.add("(0/0)"); 164 if (value.isNaN()) {
165 if (value == double.INFINITY) buffer.add("(1/0)"); 165 buffer.add("(0/0)");
166 if (value == -double.INFINITY) buffer.add("(-1/0)"); 166 } else if (value == double.INFINITY) {
167 buffer.add("($value)"); 167 buffer.add("(1/0)");
168 } else if (value == -double.INFINITY) {
169 buffer.add("(-1/0)");
170 } else {
171 buffer.add("($value)");
172 }
168 } else if (value === true) { 173 } else if (value === true) {
169 buffer.add("true"); 174 buffer.add("true");
170 } else if (value === false) { 175 } else if (value === false) {
171 buffer.add("false"); 176 buffer.add("false");
172 } else if (value is DartString) { 177 } else if (value is DartString) {
173 buffer.add("'"); 178 buffer.add("'");
174 writeEscapedString(value, buffer, (reason) { 179 writeEscapedString(value, buffer, (reason) {
175 compiler.cancel("failed to write escaped string: $value"); 180 compiler.cancel("failed to write escaped string: $value");
176 }); 181 });
177 buffer.add("'"); 182 buffer.add("'");
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 return constantHandler.compileListLiteral(node, arguments); 402 return constantHandler.compileListLiteral(node, arguments);
398 } 403 }
399 404
400 error(Node node) { 405 error(Node node) {
401 // TODO(floitsch): get the list of constants that are currently compiled 406 // TODO(floitsch): get the list of constants that are currently compiled
402 // and present some kind of stack-trace. 407 // and present some kind of stack-trace.
403 MessageKind kind = MessageKind.NOT_A_COMPILE_TIME_CONSTANT; 408 MessageKind kind = MessageKind.NOT_A_COMPILE_TIME_CONSTANT;
404 compiler.reportError(node, new CompileTimeConstantError(kind, const [])); 409 compiler.reportError(node, new CompileTimeConstantError(kind, const []));
405 } 410 }
406 } 411 }
OLDNEW
« no previous file with comments | « no previous file | dart/frog/leg/lib/js_helper.dart » ('j') | dart/frog/leg/lib/js_helper.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698