| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/wasm/wasm-result.h" | 5 #include "src/wasm/wasm-result.h" |
| 6 | 6 |
| 7 #include "src/factory.h" | 7 #include "src/factory.h" |
| 8 #include "src/heap/heap.h" | 8 #include "src/heap/heap.h" |
| 9 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
| 10 #include "src/objects.h" | 10 #include "src/objects.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 if (context_ != nullptr) { | 39 if (context_ != nullptr) { |
| 40 str << context_ << ": "; | 40 str << context_ << ": "; |
| 41 } | 41 } |
| 42 str << buffer; | 42 str << buffer; |
| 43 | 43 |
| 44 i::Handle<i::String> message = | 44 i::Handle<i::String> message = |
| 45 isolate_->factory()->NewStringFromAsciiChecked(str.str().c_str()); | 45 isolate_->factory()->NewStringFromAsciiChecked(str.str().c_str()); |
| 46 exception_ = isolate_->factory()->NewError(constructor, message); | 46 exception_ = isolate_->factory()->NewError(constructor, message); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void ErrorThrower::Error(const char* format, ...) { | |
| 50 if (error()) return; | |
| 51 va_list arguments; | |
| 52 va_start(arguments, format); | |
| 53 Format(isolate_->error_function(), format, arguments); | |
| 54 va_end(arguments); | |
| 55 } | |
| 56 | |
| 57 void ErrorThrower::TypeError(const char* format, ...) { | 49 void ErrorThrower::TypeError(const char* format, ...) { |
| 58 if (error()) return; | 50 if (error()) return; |
| 59 va_list arguments; | 51 va_list arguments; |
| 60 va_start(arguments, format); | 52 va_start(arguments, format); |
| 61 Format(isolate_->type_error_function(), format, arguments); | 53 Format(isolate_->type_error_function(), format, arguments); |
| 62 va_end(arguments); | 54 va_end(arguments); |
| 63 } | 55 } |
| 64 | 56 |
| 65 void ErrorThrower::RangeError(const char* format, ...) { | 57 void ErrorThrower::RangeError(const char* format, ...) { |
| 66 if (error()) return; | 58 if (error()) return; |
| 67 va_list arguments; | 59 va_list arguments; |
| 68 va_start(arguments, format); | 60 va_start(arguments, format); |
| 69 CHECK(*isolate_->range_error_function() != *isolate_->type_error_function()); | |
| 70 Format(isolate_->range_error_function(), format, arguments); | 61 Format(isolate_->range_error_function(), format, arguments); |
| 71 va_end(arguments); | 62 va_end(arguments); |
| 72 } | 63 } |
| 73 | 64 |
| 65 void ErrorThrower::CompileError(const char* format, ...) { |
| 66 if (error()) return; |
| 67 va_list arguments; |
| 68 va_start(arguments, format); |
| 69 Format(isolate_->wasm_compile_error_function(), format, arguments); |
| 70 va_end(arguments); |
| 71 } |
| 72 |
| 73 void ErrorThrower::RuntimeError(const char* format, ...) { |
| 74 if (error()) return; |
| 75 va_list arguments; |
| 76 va_start(arguments, format); |
| 77 Format(isolate_->wasm_runtime_error_function(), format, arguments); |
| 78 va_end(arguments); |
| 79 } |
| 80 |
| 74 ErrorThrower::~ErrorThrower() { | 81 ErrorThrower::~ErrorThrower() { |
| 75 if (error() && !isolate_->has_pending_exception()) { | 82 if (error() && !isolate_->has_pending_exception()) { |
| 76 isolate_->ScheduleThrow(*exception_); | 83 isolate_->ScheduleThrow(*exception_); |
| 77 } | 84 } |
| 78 } | 85 } |
| 79 } // namespace wasm | 86 } // namespace wasm |
| 80 } // namespace internal | 87 } // namespace internal |
| 81 } // namespace v8 | 88 } // namespace v8 |
| OLD | NEW |