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

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

Issue 9148048: Standardize error printing a bit by moving it to the Error object and (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 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/object.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_OBJECT_H_ 5 #ifndef VM_OBJECT_H_
6 #define VM_OBJECT_H_ 6 #define VM_OBJECT_H_
7 7
8 #include "vm/assert.h" 8 #include "vm/assert.h"
9 #include "vm/dart.h" 9 #include "vm/dart.h"
10 #include "vm/globals.h" 10 #include "vm/globals.h"
(...skipping 2171 matching lines...) Expand 10 before | Expand all | Expand 10 after
2182 (index * sizeof(RawContextScope::VariableDesc)); 2182 (index * sizeof(RawContextScope::VariableDesc));
2183 return reinterpret_cast<RawContextScope::VariableDesc*>(raw_addr); 2183 return reinterpret_cast<RawContextScope::VariableDesc*>(raw_addr);
2184 } 2184 }
2185 2185
2186 HEAP_OBJECT_IMPLEMENTATION(ContextScope, Object); 2186 HEAP_OBJECT_IMPLEMENTATION(ContextScope, Object);
2187 friend class Class; 2187 friend class Class;
2188 }; 2188 };
2189 2189
2190 2190
2191 class Error : public Object { 2191 class Error : public Object {
2192 public:
2193 virtual const char* ToErrorCString() const;
2194
2192 private: 2195 private:
2193 HEAP_OBJECT_IMPLEMENTATION(Error, Object); 2196 HEAP_OBJECT_IMPLEMENTATION(Error, Object);
2194 }; 2197 };
2195 2198
2196 2199
2197 class ApiError : public Error { 2200 class ApiError : public Error {
2198 public: 2201 public:
2199 RawString* message() const { return raw_ptr()->message_; } 2202 RawString* message() const { return raw_ptr()->message_; }
2200 static intptr_t message_offset() { 2203 static intptr_t message_offset() {
2201 return OFFSET_OF(RawApiError, message_); 2204 return OFFSET_OF(RawApiError, message_);
2202 } 2205 }
2203 2206
2204 static intptr_t InstanceSize() { 2207 static intptr_t InstanceSize() {
2205 return RoundedAllocationSize(sizeof(RawApiError)); 2208 return RoundedAllocationSize(sizeof(RawApiError));
2206 } 2209 }
2207 2210
2208 static RawApiError* New(const String& message, 2211 static RawApiError* New(const String& message,
2209 Heap::Space space = Heap::kNew); 2212 Heap::Space space = Heap::kNew);
2210 2213
2214 virtual const char* ToErrorCString() const;
2215
2211 private: 2216 private:
2212 void set_message(const String& message) const; 2217 void set_message(const String& message) const;
2213 2218
2214 HEAP_OBJECT_IMPLEMENTATION(ApiError, Error); 2219 HEAP_OBJECT_IMPLEMENTATION(ApiError, Error);
2215 friend class Class; 2220 friend class Class;
2216 }; 2221 };
2217 2222
2218 2223
2219 class LanguageError : public Error { 2224 class LanguageError : public Error {
2220 public: 2225 public:
2221 RawString* message() const { return raw_ptr()->message_; } 2226 RawString* message() const { return raw_ptr()->message_; }
2222 static intptr_t message_offset() { 2227 static intptr_t message_offset() {
2223 return OFFSET_OF(RawLanguageError, message_); 2228 return OFFSET_OF(RawLanguageError, message_);
2224 } 2229 }
2225 2230
2226 static intptr_t InstanceSize() { 2231 static intptr_t InstanceSize() {
2227 return RoundedAllocationSize(sizeof(RawLanguageError)); 2232 return RoundedAllocationSize(sizeof(RawLanguageError));
2228 } 2233 }
2229 2234
2230 static RawLanguageError* New(const String& message, 2235 static RawLanguageError* New(const String& message,
2231 Heap::Space space = Heap::kNew); 2236 Heap::Space space = Heap::kNew);
2232 2237
2238 virtual const char* ToErrorCString() const;
2239
2233 private: 2240 private:
2234 void set_message(const String& message) const; 2241 void set_message(const String& message) const;
2235 2242
2236 HEAP_OBJECT_IMPLEMENTATION(LanguageError, Error); 2243 HEAP_OBJECT_IMPLEMENTATION(LanguageError, Error);
2237 friend class Class; 2244 friend class Class;
2238 }; 2245 };
2239 2246
2240 2247
2241 class UnhandledException : public Error { 2248 class UnhandledException : public Error {
2242 public: 2249 public:
2243 RawInstance* exception() const { return raw_ptr()->exception_; } 2250 RawInstance* exception() const { return raw_ptr()->exception_; }
2244 static intptr_t exception_offset() { 2251 static intptr_t exception_offset() {
2245 return OFFSET_OF(RawUnhandledException, exception_); 2252 return OFFSET_OF(RawUnhandledException, exception_);
2246 } 2253 }
2247 2254
2248 RawInstance* stacktrace() const { return raw_ptr()->stacktrace_; } 2255 RawInstance* stacktrace() const { return raw_ptr()->stacktrace_; }
2249 static intptr_t stacktrace_offset() { 2256 static intptr_t stacktrace_offset() {
2250 return OFFSET_OF(RawUnhandledException, stacktrace_); 2257 return OFFSET_OF(RawUnhandledException, stacktrace_);
2251 } 2258 }
2252 2259
2253 static intptr_t InstanceSize() { 2260 static intptr_t InstanceSize() {
2254 return RoundedAllocationSize(sizeof(RawUnhandledException)); 2261 return RoundedAllocationSize(sizeof(RawUnhandledException));
2255 } 2262 }
2256 2263
2257 static RawUnhandledException* New(const Instance& exception, 2264 static RawUnhandledException* New(const Instance& exception,
2258 const Instance& stacktrace, 2265 const Instance& stacktrace,
2259 Heap::Space space = Heap::kNew); 2266 Heap::Space space = Heap::kNew);
2260 2267
2268 virtual const char* ToErrorCString() const;
2269
2261 private: 2270 private:
2262 void set_exception(const Instance& exception) const; 2271 void set_exception(const Instance& exception) const;
2263 void set_stacktrace(const Instance& stacktrace) const; 2272 void set_stacktrace(const Instance& stacktrace) const;
2264 2273
2265 HEAP_OBJECT_IMPLEMENTATION(UnhandledException, Error); 2274 HEAP_OBJECT_IMPLEMENTATION(UnhandledException, Error);
2266 friend class Class; 2275 friend class Class;
2267 }; 2276 };
2268 2277
2269 2278
2270 class UnwindError : public Error { 2279 class UnwindError : public Error {
2271 public: 2280 public:
2272 RawString* message() const { return raw_ptr()->message_; } 2281 RawString* message() const { return raw_ptr()->message_; }
2273 static intptr_t message_offset() { 2282 static intptr_t message_offset() {
2274 return OFFSET_OF(RawUnwindError, message_); 2283 return OFFSET_OF(RawUnwindError, message_);
2275 } 2284 }
2276 2285
2277 static intptr_t InstanceSize() { 2286 static intptr_t InstanceSize() {
2278 return RoundedAllocationSize(sizeof(RawUnwindError)); 2287 return RoundedAllocationSize(sizeof(RawUnwindError));
2279 } 2288 }
2280 2289
2281 static RawUnwindError* New(const String& message, 2290 static RawUnwindError* New(const String& message,
2282 Heap::Space space = Heap::kNew); 2291 Heap::Space space = Heap::kNew);
2283 2292
2293 virtual const char* ToErrorCString() const;
2294
2284 private: 2295 private:
2285 void set_message(const String& message) const; 2296 void set_message(const String& message) const;
2286 2297
2287 HEAP_OBJECT_IMPLEMENTATION(UnwindError, Error); 2298 HEAP_OBJECT_IMPLEMENTATION(UnwindError, Error);
2288 friend class Class; 2299 friend class Class;
2289 }; 2300 };
2290 2301
2291 2302
2292 // Instance is the base class for all instance objects (aka the Object class 2303 // Instance is the base class for all instance objects (aka the Object class
2293 // in Dart source code. 2304 // in Dart source code.
(...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after
3434 } 3445 }
3435 3446
3436 3447
3437 void Context::SetAt(intptr_t index, const Instance& value) const { 3448 void Context::SetAt(intptr_t index, const Instance& value) const {
3438 StorePointer(InstanceAddr(index), value.raw()); 3449 StorePointer(InstanceAddr(index), value.raw());
3439 } 3450 }
3440 3451
3441 } // namespace dart 3452 } // namespace dart
3442 3453
3443 #endif // VM_OBJECT_H_ 3454 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698