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

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

Issue 9615035: Generate dynamic type errors according to spec. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/exceptions.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
15 class DartFrameIterator;
14 class Error; 16 class Error;
15 class Instance; 17 class Instance;
16 class Object; 18 class Object;
19 class RawInstance;
20 class RawScript;
17 class RawObject; 21 class RawObject;
22 class Script;
23 class String;
18 24
19 class Exceptions : AllStatic { 25 class Exceptions : AllStatic {
20 public: 26 public:
21 static void Throw(const Instance& exception); 27 static void Throw(const Instance& exception);
22 static void ReThrow(const Instance& exception, const Instance& stacktrace); 28 static void ReThrow(const Instance& exception, const Instance& stacktrace);
23 static void PropagateError(const Object& obj); 29 static void PropagateError(const Object& obj);
24 30
31 // Helpers to create and throw errors.
32 static RawScript* GetCallerScript(DartFrameIterator* iterator);
33 static RawInstance* NewInstance(const char* class_name);
34 static void SetField(const Instance& instance,
35 const Class& cls,
36 const char* field_name,
37 const Object& value);
38 static void SetLocationFields(const Instance& instance,
39 const Class& cls,
40 const Script& script,
41 intptr_t location);
42 static void CreateAndThrowTypeError(intptr_t location,
43 const String& src_type_name,
44 const String& dst_type_name,
45 const String& dst_name,
46 const String& malformed_error);
47
25 enum ExceptionType { 48 enum ExceptionType {
26 kIndexOutOfRange, 49 kIndexOutOfRange,
27 kIllegalArgument, 50 kIllegalArgument,
28 kNoSuchMethod, 51 kNoSuchMethod,
29 kClosureArgumentMismatch, 52 kClosureArgumentMismatch,
30 kObjectNotClosure, 53 kObjectNotClosure,
31 kBadNumberFormat, 54 kBadNumberFormat,
32 kStackOverflow, 55 kStackOverflow,
33 kOutOfMemory, 56 kOutOfMemory,
34 kWrongArgumentCount, 57 kWrongArgumentCount,
35 kInternalError, 58 kInternalError,
36 kNullPointer, 59 kNullPointer,
37 kIllegalJSRegExp, 60 kIllegalJSRegExp,
38 }; 61 };
39 62
40 static void ThrowByType(ExceptionType type, 63 static void ThrowByType(ExceptionType type,
41 const GrowableArray<const Object*>& arguments); 64 const GrowableArray<const Object*>& arguments);
42 // Returns a RawInstance if the exception is successfully created, 65 // Returns a RawInstance if the exception is successfully created,
43 // otherwise returns a RawError. 66 // otherwise returns a RawError.
44 static RawObject* Create(ExceptionType type, 67 static RawObject* Create(ExceptionType type,
45 const GrowableArray<const Object*>& arguments); 68 const GrowableArray<const Object*>& arguments);
46 69
47 private: 70 private:
48 DISALLOW_COPY_AND_ASSIGN(Exceptions); 71 DISALLOW_COPY_AND_ASSIGN(Exceptions);
49 }; 72 };
50 73
51 } // namespace dart 74 } // namespace dart
52 75
53 #endif // VM_EXCEPTIONS_H_ 76 #endif // VM_EXCEPTIONS_H_
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/exceptions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698