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

Side by Side Diff: frog/corejs.dart

Issue 8534001: Adds typechecking of return values (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: better runtime checks Created 9 years, 1 month 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 | frog/frogsh » ('j') | frog/lib/corelib_impl.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 * Generates JS helpers for dart:core. This used to be in a file "core.js". 6 * Generates JS helpers for dart:core. This used to be in a file "core.js".
7 * Having them in Dart code means we can easily control which are generated. 7 * Having them in Dart code means we can easily control which are generated.
8 */ 8 */
9 // TODO(jmesserly): one idea to make this cleaner: put these as private "native" 9 // TODO(jmesserly): one idea to make this cleaner: put these as private "native"
10 // methods somewhere in a library that we import. This would be rather elegant 10 // methods somewhere in a library that we import. This would be rather elegant
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 // TODO(jmesserly): setting the stack property is not a long term solution. 280 // TODO(jmesserly): setting the stack property is not a long term solution.
281 // Also it causes the exception to print as if it were a TypeError or 281 // Also it causes the exception to print as if it were a TypeError or
282 // RangeError, instead of using the proper toString. 282 // RangeError, instead of using the proper toString.
283 res.stack = e.stack; 283 res.stack = e.stack;
284 return res; 284 return res;
285 }"""); 285 }""");
286 } 286 }
287 287
288 if (useNotNullBool) { 288 if (useNotNullBool) {
289 useThrow = true; 289 useThrow = true;
290 // Some testing showed that this patterned fared well across browsers.
290 w.writeln(@""" 291 w.writeln(@"""
291 function $notnull_bool(test) { 292 function $notnull_bool(test) {
292 if (test == null || typeof(test) != 'boolean') { 293 return typeof(test) == 'boolean' ? test : test.is$bool();
293 $throw(new TypeError('must be "true" or "false"'));
294 }
295 return test === true;
296 }"""); 294 }""");
297 } 295 }
298 296
299 if (useAssert) { 297 if (useAssert) {
300 useThrow = true; 298 useThrow = true;
301 w.writeln(@""" 299 w.writeln(@"""
302 function $assert(test, text, url, line, column) { 300 function $assert(test, text, url, line, column) {
303 if (typeof test == 'function') test = test(); 301 if (typeof test == 'function') test = test();
304 if (!test) $throw(new AssertError(text, url, line, column)); 302 if (!test) $throw(new AssertError(text, url, line, column));
305 }"""); 303 }""");
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 Object.prototype.$setindex = function(i, value) { return this[i] = value; } 382 Object.prototype.$setindex = function(i, value) { return this[i] = value; }
385 Array.prototype.$setindex = function(i, value) { return this[i] = value; }"""); 383 Array.prototype.$setindex = function(i, value) { return this[i] = value; }""");
386 } 384 }
387 385
388 // Write operator helpers 386 // Write operator helpers
389 for (var opImpl in orderValuesByKeys(_usedOperators)) { 387 for (var opImpl in orderValuesByKeys(_usedOperators)) {
390 w.writeln(opImpl); 388 w.writeln(opImpl);
391 } 389 }
392 } 390 }
393 } 391 }
OLDNEW
« no previous file with comments | « no previous file | frog/frogsh » ('j') | frog/lib/corelib_impl.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698