Index: sdk/lib/_internal/lib/collection_dev_patch.dart |
diff --git a/sdk/lib/_internal/lib/collection_dev_patch.dart b/sdk/lib/_internal/lib/collection_dev_patch.dart |
index f224f24aab6db81fdd02fe889ed215cbb223c6e5..f7467fd72562765f3afdeafc9f0669ef60bc54d1 100644 |
--- a/sdk/lib/_internal/lib/collection_dev_patch.dart |
+++ b/sdk/lib/_internal/lib/collection_dev_patch.dart |
@@ -2,7 +2,45 @@ |
// for details. All rights reserved. Use of this source code is governed by a |
// BSD-style license that can be found in the LICENSE file. |
+import 'dart:_foreign_helper' show JS; |
ahe
2013/11/04 09:01:19
In the future, please do not add dart2js secret im
|
+ |
patch class Symbol implements core.Symbol { |
patch const Symbol(String name) |
: this._name = name; |
} |
+ |
+/** |
+ * This is the low-level method that is used to implement |
+ * [print]. It is possible to override this function from JavaScript |
+ * by defining a function in JavaScript called "dartPrint". |
+ */ |
+patch void printToConsole(String line) { |
+ if (JS('bool', r'typeof dartPrint == "function"')) { |
+ // Support overriding print from JavaScript. |
+ JS('void', r'dartPrint(#)', line); |
+ return; |
+ } |
+ |
+ // Inside browser or nodejs. |
+ if (JS('bool', r'typeof console == "object"') && |
+ JS('bool', r'typeof console.log == "function"')) { |
+ JS('void', r'console.log(#)', line); |
+ return; |
+ } |
+ |
+ // Don't throw inside IE, the console is only defined if dev tools is open. |
+ if (JS('bool', r'typeof window == "object"')) { |
+ return; |
+ } |
+ |
+ // Running in d8, the V8 developer shell, or in Firefox' js-shell. |
+ if (JS('bool', r'typeof print == "function"')) { |
+ JS('void', r'print(#)', line); |
+ return; |
+ } |
+ |
+ // This is somewhat nasty, but we don't want to drag in a bunch of |
+ // dependencies to handle a situation that cannot happen. So we |
+ // avoid using Dart [:throw:] and Dart [toString]. |
+ JS('void', 'throw "Unable to print message: " + String(#)', line); |
+} |