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

Unified Diff: lib/compiler/implementation/lib/js_helper.dart

Issue 10694089: Guard the use of write in the implementation of print. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/lib/js_helper.dart
diff --git a/lib/compiler/implementation/lib/js_helper.dart b/lib/compiler/implementation/lib/js_helper.dart
index 1027a46bae0699588e200b47cc0e574c0affbd01..d2a5c030948b79526dce820b62d65c504563828b 100644
--- a/lib/compiler/implementation/lib/js_helper.dart
+++ b/lib/compiler/implementation/lib/js_helper.dart
@@ -370,17 +370,22 @@ class Primitives {
* by defining a function in JavaScript called "dartPrint".
*/
static void printString(String string) {
- var hasDartPrint = JS('bool', @'typeof dartPrint == "function"');
+ bool hasDartPrint = JS('bool', @'typeof dartPrint == "function"');
Emily Fortuna 2012/07/05 11:46:42 nit: the style guide suggests having leaving varia
kasperl 2012/07/05 11:49:03 Done.
if (hasDartPrint) {
JS('void', @'dartPrint(#)', string);
- } else {
- var hasConsole = JS('bool', @'typeof console == "object"');
- if (hasConsole) {
- JS('void', @'console.log(#)', string);
- } else {
- JS('void', @'write(#)', string);
- JS('void', @'write("\n")');
- }
+ return;
+ }
+
+ bool hasConsole = JS('bool', @'typeof console == "object"');
Emily Fortuna 2012/07/05 11:46:42 nit: personally I'd write this as if (hasDartPrin
kasperl 2012/07/05 11:49:03 In this case, I think the JS expressions are a bit
+ if (hasConsole) {
+ JS('void', @'console.log(#)', string);
+ return;
+ }
+
+ bool hasWrite = JS('bool', @'typeof write == "function"');
+ if (hasWrite) {
+ JS('void', @'write(#)', string);
+ JS('void', @'write("\n")');
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698