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

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

Powered by Google App Engine
This is Rietveld 408576698