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

Side by Side Diff: runtime/vm/exceptions.h

Issue 260713008: Add support for javascript incompatibility warnings. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 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
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 #ifndef VM_EXCEPTIONS_H_ 5 #ifndef VM_EXCEPTIONS_H_
6 #define VM_EXCEPTIONS_H_ 6 #define VM_EXCEPTIONS_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/growable_array.h" 9 #include "vm/growable_array.h"
10 10
11 namespace dart { 11 namespace dart {
12 12
13 // Forward declarations. 13 // Forward declarations.
14 class Class; 14 class Class;
15 class DartFrameIterator; 15 class DartFrameIterator;
16 class Error; 16 class Error;
17 class ICData;
17 class Instance; 18 class Instance;
18 class Object; 19 class Object;
19 class RawInstance; 20 class RawInstance;
20 class RawScript; 21 class RawScript;
21 class RawStacktrace; 22 class RawStacktrace;
22 class RawObject; 23 class RawObject;
23 class Script; 24 class Script;
24 class String; 25 class String;
25 26
26 class Exceptions : AllStatic { 27 class Exceptions : AllStatic {
27 public: 28 public:
28 static const char* kCastErrorDstName; 29 static const char* kCastErrorDstName;
29 30
30 static void Throw(const Instance& exception); 31 static void Throw(const Instance& exception);
31 static void ReThrow(const Instance& exception, const Instance& stacktrace); 32 static void ReThrow(const Instance& exception, const Instance& stacktrace);
32 static void PropagateError(const Error& error); 33 static void PropagateError(const Error& error);
34
35 static bool MayIssueJSWarning(const ICData& ic_data, bool check_issued);
srdjan 2014/05/08 18:11:05 Please add comment about the arguments.
regis 2014/05/09 21:03:42 Done. I also removed the check_issue argument, whi
36
37 // Argument ic_data is passed when it is known, e.g. when issuing the warning
38 // from an inline cache miss handler. Otherwise, null is passed when ic_data
39 // is not looked up yet, e.g. when the warning is issued from native code.
srdjan 2014/05/08 18:11:05 Add comment that it can produce errors if appropri
regis 2014/05/09 21:03:42 Done.
40 static void JSWarning(const ICData& ic_data, const char* format, ...)
41 PRINTF_ATTRIBUTE(2, 3);
42
33 static RawStacktrace* CurrentStacktrace(); 43 static RawStacktrace* CurrentStacktrace();
34 44
35 // Helpers to create and throw errors. 45 // Helpers to create and throw errors.
36 static RawScript* GetCallerScript(DartFrameIterator* iterator); 46 static RawScript* GetCallerScript(DartFrameIterator* iterator);
37 static RawInstance* NewInstance(const char* class_name); 47 static RawInstance* NewInstance(const char* class_name);
38 static void CreateAndThrowTypeError(intptr_t location, 48 static void CreateAndThrowTypeError(intptr_t location,
39 const String& src_type_name, 49 const String& src_type_name,
40 const String& dst_type_name, 50 const String& dst_type_name,
41 const String& dst_name, 51 const String& dst_name,
42 const String& error_msg); 52 const String& error_msg);
43 53
44 enum ExceptionType { 54 enum ExceptionType {
45 kNone, 55 kNone,
46 kRange, 56 kRange,
47 kArgument, 57 kArgument,
48 kNoSuchMethod, 58 kNoSuchMethod,
49 kFormat, 59 kFormat,
50 kUnsupported, 60 kUnsupported,
51 kStackOverflow, 61 kStackOverflow,
52 kOutOfMemory, 62 kOutOfMemory,
53 kInternalError, 63 kInternalError,
54 kNullThrown, 64 kNullThrown,
55 kIsolateSpawn, 65 kIsolateSpawn,
56 kIsolateUnhandledException, 66 kIsolateUnhandledException,
57 kJavascriptIntegerOverflowError, 67 kJavascriptIntegerOverflowError,
68 kJavascriptCompatibilityError,
58 kAssertion, 69 kAssertion,
59 kCast, 70 kCast,
60 kType, 71 kType,
61 kFallThrough, 72 kFallThrough,
62 kAbstractClassInstantiation, 73 kAbstractClassInstantiation,
63 kMirroredCompilationError, 74 kMirroredCompilationError,
64 }; 75 };
65 76
66 static void ThrowByType(ExceptionType type, const Array& arguments); 77 static void ThrowByType(ExceptionType type, const Array& arguments);
67 static void ThrowOOM(); 78 static void ThrowOOM();
68 static void ThrowStackOverflow(); 79 static void ThrowStackOverflow();
69 static void ThrowArgumentError(const Instance& arg); 80 static void ThrowArgumentError(const Instance& arg);
70 81
71 // Returns a RawInstance if the exception is successfully created, 82 // Returns a RawInstance if the exception is successfully created,
72 // otherwise returns a RawError. 83 // otherwise returns a RawError.
73 static RawObject* Create(ExceptionType type, const Array& arguments); 84 static RawObject* Create(ExceptionType type, const Array& arguments);
74 85
75 private: 86 private:
76 DISALLOW_COPY_AND_ASSIGN(Exceptions); 87 DISALLOW_COPY_AND_ASSIGN(Exceptions);
77 }; 88 };
78 89
79 } // namespace dart 90 } // namespace dart
80 91
81 #endif // VM_EXCEPTIONS_H_ 92 #endif // VM_EXCEPTIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698