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

Side by Side Diff: frog/lib/natives.dart

Issue 10548047: Remove frog from the repository. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Move test and update apidoc.gyp. Created 8 years, 6 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 | « frog/lib/math.dart ('k') | frog/lib/num.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // Native helpers generated by the compiler
6 // TODO(jmesserly): more natives should use this pattern
7
8 // Translate a JavaScript exception to a Dart exception
9 // TODO(jmesserly): cross browser support. This is Chrome specific.
10 _toDartException(e) native @"""
11 function attachStack(dartEx) {
12 // TODO(jmesserly): setting the stack property is not a long term solution.
13 var stack = e.stack;
14 // The stack contains the error message, and the stack is all that is
15 // printed (the exception's toString() is never called). Make the Dart
16 // exception's toString() be the dominant message.
17 if (typeof stack == 'string') {
18 var message = dartEx.toString();
19 if (/^(Type|Range)Error:/.test(stack)) {
20 // Indent JS message (it can be helpful) so new message stands out.
21 stack = ' (' + stack.substring(0, stack.indexOf('\n')) + ')\n' +
22 stack.substring(stack.indexOf('\n') + 1);
23 }
24 stack = message + '\n' + stack;
25 }
26 dartEx.stack = stack;
27 return dartEx;
28 }
29
30 if (e instanceof TypeError) {
31 switch(e.type) {
32 case 'property_not_function':
33 case 'called_non_callable':
34 if (e.arguments[0] == null) {
35 return attachStack(new NullPointerException(null, []));
36 } else {
37 return attachStack(new ObjectNotClosureException());
38 }
39 break;
40 case 'non_object_property_call':
41 case 'non_object_property_load':
42 return attachStack(new NullPointerException(null, []));
43 break;
44 case 'undefined_method':
45 var mname = e.arguments[0];
46 if (typeof(mname) == 'string' && (mname.indexOf('call$') == 0
47 || mname == 'call' || mname == 'apply')) {
48 return attachStack(new ObjectNotClosureException());
49 } else {
50 // TODO(jmesserly): fix noSuchMethod on operators so we don't hit this
51 return attachStack(new NoSuchMethodException('', e.arguments[0], []));
52 }
53 break;
54 }
55 } else if (e instanceof RangeError) {
56 if (e.message.indexOf('call stack') >= 0) {
57 return attachStack(new StackOverflowException());
58 }
59 }
60 return e;""" {
61 // Ensure constructors are generated
62 new ObjectNotClosureException();
63 new NullPointerException(null, null);
64 new NoSuchMethodException(null, null, null);
65 new StackOverflowException();
66 }
67
68 // TODO(jmesserly): we shouldn't be relying on the e.stack property.
69 // Need to mangle it.
70 _stackTraceOf(e) native @"return (e && e.stack) ? e.stack : null;";
OLDNEW
« no previous file with comments | « frog/lib/math.dart ('k') | frog/lib/num.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698