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

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;
25 class StackFrame;
24 class String; 26 class String;
25 27
26 class Exceptions : AllStatic { 28 class Exceptions : AllStatic {
27 public: 29 public:
28 static const char* kCastErrorDstName; 30 static const char* kCastErrorDstName;
29 31
30 static void Throw(const Instance& exception); 32 static void Throw(const Instance& exception);
31 static void ReThrow(const Instance& exception, const Instance& stacktrace); 33 static void ReThrow(const Instance& exception, const Instance& stacktrace);
32 static void PropagateError(const Error& error); 34 static void PropagateError(const Error& error);
35
36 // Return true if the target function of the given ic_data may check for (and
37 // possibly issue) a Javascript compatibility warning.
38 static bool MayCheckForJSWarning(const ICData& ic_data);
39
40 // Report a Javascript compatibility warning at the call site given by
41 // caller_frame. Note that a JavascriptCompatibilityError is thrown
42 // if --warning_as_error is specified.
43 static void JSWarning(StackFrame* caller_frame, const char* format, ...)
44 PRINTF_ATTRIBUTE(2, 3);
45
33 static RawStacktrace* CurrentStacktrace(); 46 static RawStacktrace* CurrentStacktrace();
34 47
35 // Helpers to create and throw errors. 48 // Helpers to create and throw errors.
36 static RawScript* GetCallerScript(DartFrameIterator* iterator); 49 static RawScript* GetCallerScript(DartFrameIterator* iterator);
37 static RawInstance* NewInstance(const char* class_name); 50 static RawInstance* NewInstance(const char* class_name);
38 static void CreateAndThrowTypeError(intptr_t location, 51 static void CreateAndThrowTypeError(intptr_t location,
39 const String& src_type_name, 52 const String& src_type_name,
40 const String& dst_type_name, 53 const String& dst_type_name,
41 const String& dst_name, 54 const String& dst_name,
42 const String& error_msg); 55 const String& error_msg);
43 56
44 enum ExceptionType { 57 enum ExceptionType {
45 kNone, 58 kNone,
46 kRange, 59 kRange,
47 kArgument, 60 kArgument,
48 kNoSuchMethod, 61 kNoSuchMethod,
49 kFormat, 62 kFormat,
50 kUnsupported, 63 kUnsupported,
51 kStackOverflow, 64 kStackOverflow,
52 kOutOfMemory, 65 kOutOfMemory,
53 kInternalError, 66 kInternalError,
54 kNullThrown, 67 kNullThrown,
55 kIsolateSpawn, 68 kIsolateSpawn,
56 kIsolateUnhandledException, 69 kIsolateUnhandledException,
57 kJavascriptIntegerOverflowError, 70 kJavascriptIntegerOverflowError,
71 kJavascriptCompatibilityError,
58 kAssertion, 72 kAssertion,
59 kCast, 73 kCast,
60 kType, 74 kType,
61 kFallThrough, 75 kFallThrough,
62 kAbstractClassInstantiation, 76 kAbstractClassInstantiation,
63 kMirroredCompilationError, 77 kMirroredCompilationError,
64 }; 78 };
65 79
66 static void ThrowByType(ExceptionType type, const Array& arguments); 80 static void ThrowByType(ExceptionType type, const Array& arguments);
67 static void ThrowOOM(); 81 static void ThrowOOM();
68 static void ThrowStackOverflow(); 82 static void ThrowStackOverflow();
69 static void ThrowArgumentError(const Instance& arg); 83 static void ThrowArgumentError(const Instance& arg);
70 84
71 // Returns a RawInstance if the exception is successfully created, 85 // Returns a RawInstance if the exception is successfully created,
72 // otherwise returns a RawError. 86 // otherwise returns a RawError.
73 static RawObject* Create(ExceptionType type, const Array& arguments); 87 static RawObject* Create(ExceptionType type, const Array& arguments);
74 88
75 private: 89 private:
76 DISALLOW_COPY_AND_ASSIGN(Exceptions); 90 DISALLOW_COPY_AND_ASSIGN(Exceptions);
77 }; 91 };
78 92
79 } // namespace dart 93 } // namespace dart
80 94
81 #endif // VM_EXCEPTIONS_H_ 95 #endif // VM_EXCEPTIONS_H_
OLDNEW
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/exceptions.cc » ('j') | runtime/vm/exceptions.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698