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

Side by Side Diff: pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/errors.dart

Issue 3003613002: improve DDC's type checks (Closed)
Patch Set: format Created 3 years, 3 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 part of dart._runtime; 4 part of dart._runtime;
5 5
6 // We need to set these properties while the sdk is only partially initialized 6 // We need to set these properties while the sdk is only partially initialized
7 // so we cannot use regular Dart fields. 7 // so we cannot use regular Dart fields.
8 // The default values for these properties are set when the global_ final field 8 // The default values for these properties are set when the global_ final field
9 // in runtime.dart is initialized. 9 // in runtime.dart is initialized.
10 10
11 // Override, e.g., for testing 11 // Override, e.g., for testing
12 void trapRuntimeErrors(bool flag) { 12 void trapRuntimeErrors(bool flag) {
13 JS('', 'dart.__trapRuntimeErrors = #', flag); 13 JS('', 'dart.__trapRuntimeErrors = #', flag);
14 } 14 }
15 15
16 void ignoreWhitelistedErrors(bool flag) { 16 void ignoreWhitelistedErrors(bool flag) {
17 JS('', 'dart.__ignoreWhitelistedErrors = #', flag); 17 JS('', 'dart.__ignoreWhitelistedErrors = #', flag);
18 } 18 }
19 19
20 void ignoreAllErrors(bool flag) { 20 void ignoreAllErrors(bool flag) {
21 JS('', 'dart.__ignoreAllErrors = #', flag); 21 JS('', 'dart.__ignoreAllErrors = #', flag);
22 } 22 }
23 23
24 throwCastError(object, actual, type) {
25 var found = typeName(actual);
26 var expected = typeName(type);
27 if (JS('bool', 'dart.__trapRuntimeErrors')) JS('', 'debugger');
28 throw new CastErrorImplementation(object, found, expected);
29 }
30
31 throwTypeError(object, actual, type) {
32 var found = typeName(actual);
33 var expected = typeName(type);
34 if (JS('bool', 'dart.__trapRuntimeErrors')) JS('', 'debugger');
35 throw new TypeErrorImplementation(object, found, expected);
36 }
37
38 throwStrongModeCastError(object, actual, type) {
39 var found = typeName(actual);
40 var expected = typeName(type);
41 if (JS('bool', 'dart.__trapRuntimeErrors')) JS('', 'debugger');
42 throw new StrongModeCastError(object, found, expected);
43 }
44
45 throwStrongModeTypeError(object, actual, type) {
46 var found = typeName(actual);
47 var expected = typeName(type);
48 if (JS('bool', 'dart.__trapRuntimeErrors')) JS('', 'debugger');
49 throw new StrongModeTypeError(object, found, expected);
50 }
51
52 throwUnimplementedError(String message) { 24 throwUnimplementedError(String message) {
53 if (JS('bool', 'dart.__trapRuntimeErrors')) JS('', 'debugger'); 25 if (JS('bool', 'dart.__trapRuntimeErrors')) JS('', 'debugger');
54 throw new UnimplementedError(message); 26 throw new UnimplementedError(message);
55 } 27 }
56 28
57 assertFailed(message) { 29 assertFailed(message) {
58 if (JS('bool', 'dart.__trapRuntimeErrors')) JS('', 'debugger'); 30 if (JS('bool', 'dart.__trapRuntimeErrors')) JS('', 'debugger');
59 throw new AssertionErrorImpl(message); 31 throw new AssertionErrorImpl(message);
60 } 32 }
61 33
(...skipping 10 matching lines...) Expand all
72 throw new NoSuchMethodError( 44 throw new NoSuchMethodError(
73 null, new Symbol('<Unexpected Null Value>'), null, null, null); 45 null, new Symbol('<Unexpected Null Value>'), null, null, null);
74 } 46 }
75 47
76 throwNoSuchMethodError(Object receiver, Symbol memberName, 48 throwNoSuchMethodError(Object receiver, Symbol memberName,
77 List positionalArguments, Map<Symbol, dynamic> namedArguments) { 49 List positionalArguments, Map<Symbol, dynamic> namedArguments) {
78 if (JS('bool', 'dart.__trapRuntimeErrors')) JS('', 'debugger'); 50 if (JS('bool', 'dart.__trapRuntimeErrors')) JS('', 'debugger');
79 throw new NoSuchMethodError( 51 throw new NoSuchMethodError(
80 receiver, memberName, positionalArguments, namedArguments); 52 receiver, memberName, positionalArguments, namedArguments);
81 } 53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698