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

Side by Side Diff: src/api.cc

Issue 342078: Added TryCatch::ReThrow method. (Closed)
Patch Set: Created 11 years, 1 month 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
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-api.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 // --- E x c e p t i o n s --- 1190 // --- E x c e p t i o n s ---
1191 1191
1192 1192
1193 v8::TryCatch::TryCatch() 1193 v8::TryCatch::TryCatch()
1194 : next_(i::Top::try_catch_handler()), 1194 : next_(i::Top::try_catch_handler()),
1195 exception_(i::Heap::the_hole_value()), 1195 exception_(i::Heap::the_hole_value()),
1196 message_(i::Smi::FromInt(0)), 1196 message_(i::Smi::FromInt(0)),
1197 is_verbose_(false), 1197 is_verbose_(false),
1198 can_continue_(true), 1198 can_continue_(true),
1199 capture_message_(true), 1199 capture_message_(true),
1200 rethrow_(false),
1200 js_handler_(NULL) { 1201 js_handler_(NULL) {
1201 i::Top::RegisterTryCatchHandler(this); 1202 i::Top::RegisterTryCatchHandler(this);
1202 } 1203 }
1203 1204
1204 1205
1205 v8::TryCatch::~TryCatch() { 1206 v8::TryCatch::~TryCatch() {
1206 i::Top::UnregisterTryCatchHandler(this); 1207 if (rethrow_) {
1208 v8::HandleScope scope;
1209 v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(Exception());
1210 i::Top::UnregisterTryCatchHandler(this);
1211 v8::ThrowException(exc);
1212 } else {
1213 i::Top::UnregisterTryCatchHandler(this);
1214 }
1207 } 1215 }
1208 1216
1209 1217
1210 bool v8::TryCatch::HasCaught() const { 1218 bool v8::TryCatch::HasCaught() const {
1211 return !reinterpret_cast<i::Object*>(exception_)->IsTheHole(); 1219 return !reinterpret_cast<i::Object*>(exception_)->IsTheHole();
1212 } 1220 }
1213 1221
1214 1222
1215 bool v8::TryCatch::CanContinue() const { 1223 bool v8::TryCatch::CanContinue() const {
1216 return can_continue_; 1224 return can_continue_;
1217 } 1225 }
1218 1226
1219 1227
1228 v8::Handle<v8::Value> v8::TryCatch::ReThrow() {
1229 if (!HasCaught()) return v8::Local<v8::Value>();
1230 rethrow_ = true;
1231 return v8::Undefined();
1232 }
1233
1234
1220 v8::Local<Value> v8::TryCatch::Exception() const { 1235 v8::Local<Value> v8::TryCatch::Exception() const {
1221 if (HasCaught()) { 1236 if (HasCaught()) {
1222 // Check for out of memory exception. 1237 // Check for out of memory exception.
1223 i::Object* exception = reinterpret_cast<i::Object*>(exception_); 1238 i::Object* exception = reinterpret_cast<i::Object*>(exception_);
1224 return v8::Utils::ToLocal(i::Handle<i::Object>(exception)); 1239 return v8::Utils::ToLocal(i::Handle<i::Object>(exception));
1225 } else { 1240 } else {
1226 return v8::Local<Value>(); 1241 return v8::Local<Value>();
1227 } 1242 }
1228 } 1243 }
1229 1244
(...skipping 2613 matching lines...) Expand 10 before | Expand all | Expand 10 after
3843 3858
3844 3859
3845 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 3860 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
3846 HandleScopeImplementer* thread_local = 3861 HandleScopeImplementer* thread_local =
3847 reinterpret_cast<HandleScopeImplementer*>(storage); 3862 reinterpret_cast<HandleScopeImplementer*>(storage);
3848 thread_local->IterateThis(v); 3863 thread_local->IterateThis(v);
3849 return storage + ArchiveSpacePerThread(); 3864 return storage + ArchiveSpacePerThread();
3850 } 3865 }
3851 3866
3852 } } // namespace v8::internal 3867 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698