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

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

Issue 8746005: Fix a bunch of issues with 'hidden' DOM types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: removed dead code Created 9 years 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
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 // Native helpers generated by the compiler 5 // Native helpers generated by the compiler
6 // TODO(jmesserly): more natives should use this pattern 6 // TODO(jmesserly): more natives should use this pattern
7 7
8 // Translate a JavaScript exception to a Dart exception 8 // Translate a JavaScript exception to a Dart exception
9 // TODO(jmesserly): cross browser support. This is Chrome specific. 9 // TODO(jmesserly): cross browser support. This is Chrome specific.
10 _toDartException(e) native @"""{ 10 _toDartException(e) native @"""
11 function attachStack(dartEx) { 11 function attachStack(dartEx) {
12 // TODO(jmesserly): setting the stack property is not a long term solution. 12 // TODO(jmesserly): setting the stack property is not a long term solution.
13 var stack = e.stack; 13 var stack = e.stack;
14 // The stack contains the error message, and the stack is all that is 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 15 // printed (the exception's toString() is never called). Make the Dart
16 // exception's toString() be the dominant message. 16 // exception's toString() be the dominant message.
17 if (typeof stack == 'string') { 17 if (typeof stack == 'string') {
18 var message = dartEx.toString(); 18 var message = dartEx.toString();
19 if (/^(Type|Range)Error:/.test(stack)) { 19 if (/^(Type|Range)Error:/.test(stack)) {
20 // Indent JS message (it can be helpful) so new message stands out. 20 // Indent JS message (it can be helpful) so new message stands out.
21 stack = ' (' + stack.substring(0, stack.indexOf('\n')) + ')\n' + 21 stack = ' (' + stack.substring(0, stack.indexOf('\n')) + ')\n' +
22 stack.substring(stack.indexOf('\n') + 1); 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());
36 } else {
37 return attachStack(new ObjectNotClosureException());
23 } 38 }
24 stack = message + '\n' + stack; 39 break;
25 } 40 case 'non_object_property_call':
26 dartEx.stack = stack; 41 case 'non_object_property_load':
27 return dartEx; 42 return attachStack(new NullPointerException());
43 break;
44 case 'undefined_method':
45 if (e.arguments[0] == 'call' || e.arguments[0] == 'apply') {
46 return attachStack(new ObjectNotClosureException());
47 } else {
48 // TODO(jmesserly): can this ever happen?
49 // sra: Yes, seen on '$add'.
50 return attachStack(new NoSuchMethodException('', e.arguments[0], []));
51 }
52 break;
28 } 53 }
29 54 } else if (e instanceof RangeError) {
30 if (e instanceof TypeError) { 55 if (e.message.indexOf('call stack') >= 0) {
31 switch(e.type) { 56 return attachStack(new StackOverflowException());
32 case 'property_not_function':
33 case 'called_non_callable':
34 if (e.arguments[0] == null) {
35 return attachStack(new NullPointerException());
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());
43 break;
44 case 'undefined_method':
45 if (e.arguments[0] == 'call' || e.arguments[0] == 'apply') {
46 return attachStack(new ObjectNotClosureException());
47 } else {
48 // TODO(jmesserly): can this ever happen?
49 // sra: Yes, seen on '$add'.
50 return attachStack(new NoSuchMethodException('', e.arguments[0], []));
51 }
52 break;
53 }
54 } else if (e instanceof RangeError) {
55 if (e.message.indexOf('call stack') >= 0) {
56 return attachStack(new StackOverflowException());
57 }
58 } 57 }
59 return e; 58 }
60 }""" { 59 return e;""" {
61 // Ensure constructors are generated 60 // Ensure constructors are generated
62 new ObjectNotClosureException(); 61 new ObjectNotClosureException();
63 new NullPointerException(); 62 new NullPointerException();
64 new NoSuchMethodException(null, null, null); 63 new NoSuchMethodException(null, null, null);
65 new StackOverflowException(); 64 new StackOverflowException();
66 } 65 }
OLDNEW
« frog/lib/corelib.dart ('K') | « frog/lib/corelib.dart ('k') | frog/member.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698