OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 * Helpers for lazy static initialization. | 6 * Helpers for lazy static initialization. |
7 */ | 7 */ |
8 var static$uninitialized = {}; | 8 var static$uninitialized = {}; |
9 var static$initializing = {}; | 9 var static$initializing = {}; |
10 | 10 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 /** | 174 /** |
175 * Dart null object that should be used by JS implementation to test for | 175 * Dart null object that should be used by JS implementation to test for |
176 * Dart null. | 176 * Dart null. |
177 * | 177 * |
178 * TODO(ngeoffray): update dartc to generate this variable instead of | 178 * TODO(ngeoffray): update dartc to generate this variable instead of |
179 * undefined. | 179 * undefined. |
180 * @const | 180 * @const |
181 */ | 181 */ |
182 var $Dart$Null = void 0; | 182 var $Dart$Null = void 0; |
183 | 183 |
184 function assert(expr, msg) { | 184 function assert(expr) { |
185 var val = typeof(expr) == 'function' ? expr() : expr; | 185 var val = typeof(expr) == 'function' ? $dartcall(expr, []) : expr; |
186 if (!val) { | 186 if (val !== true) { |
187 // TODO: throw a Dart AssertionError instead | 187 $Dart$ThrowException(native_ExceptionHelper_createAssertionError()); |
188 var err = new Error('Assertion failed. ' + (msg || '')); | |
189 Error.captureStackTrace && Error.captureStackTrace(err); | |
190 throw err; | |
191 } | 188 } |
192 } | 189 } |
193 | 190 |
194 // TODO(jimhug): Remove these functions after updating compiler backend. | 191 // TODO(jimhug): Remove these functions after updating compiler backend. |
195 function BIT_OR$operator(val1, val2) { | 192 function BIT_OR$operator(val1, val2) { |
196 return (typeof(val1) == 'number' && typeof(val2) == 'number') | 193 return (typeof(val1) == 'number' && typeof(val2) == 'number') |
197 ? val1 | val2 | 194 ? val1 | val2 |
198 : val1.BIT_OR$operator(val2); | 195 : val1.BIT_OR$operator(val2); |
199 } | 196 } |
200 | 197 |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 return match; | 463 return match; |
467 } | 464 } |
468 o.$dartConstId = id; | 465 o.$dartConstId = id; |
469 $consts[key] = o; | 466 $consts[key] = o; |
470 return o; | 467 return o; |
471 } | 468 } |
472 | 469 |
473 function $Dart$MapLiteralFactory() { | 470 function $Dart$MapLiteralFactory() { |
474 return native__CoreJsUtil__newMapLiteral(); | 471 return native__CoreJsUtil__newMapLiteral(); |
475 } | 472 } |
OLD | NEW |