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

Unified Diff: src/wasm/wasm-result.cc

Issue 2350643003: [wasm] Set up Table and Memory constructors (Closed)
Patch Set: Address comments Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/wasm-result.h ('k') | test/cctest/interpreter/bytecode_expectations/CallRuntime.golden » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-result.cc
diff --git a/src/wasm/wasm-result.cc b/src/wasm/wasm-result.cc
index 30268ac8ad52d4ee03ee3b80e99393283e77d2f7..7d251f03dfc884f19df22ca731bf800b15718a22 100644
--- a/src/wasm/wasm-result.cc
+++ b/src/wasm/wasm-result.cc
@@ -27,15 +27,13 @@ std::ostream& operator<<(std::ostream& os, const ErrorCode& error_code) {
return os;
}
-void ErrorThrower::Error(const char* format, ...) {
+void ErrorThrower::Format(i::Handle<i::JSFunction> constructor,
+ const char* format, va_list args) {
// Only report the first error.
if (error()) return;
char buffer[256];
- va_list arguments;
- va_start(arguments, format);
- base::OS::VSNPrintF(buffer, 255, format, arguments);
- va_end(arguments);
+ base::OS::VSNPrintF(buffer, 255, format, args);
std::ostringstream str;
if (context_ != nullptr) {
@@ -43,12 +41,39 @@ void ErrorThrower::Error(const char* format, ...) {
}
str << buffer;
- message_ = isolate_->factory()->NewStringFromAsciiChecked(str.str().c_str());
+ i::Handle<i::String> message =
+ isolate_->factory()->NewStringFromAsciiChecked(str.str().c_str());
+ exception_ = isolate_->factory()->NewError(constructor, message);
+}
+
+void ErrorThrower::Error(const char* format, ...) {
+ if (error()) return;
+ va_list arguments;
+ va_start(arguments, format);
+ Format(isolate_->error_function(), format, arguments);
+ va_end(arguments);
+}
+
+void ErrorThrower::TypeError(const char* format, ...) {
+ if (error()) return;
+ va_list arguments;
+ va_start(arguments, format);
+ Format(isolate_->type_error_function(), format, arguments);
+ va_end(arguments);
+}
+
+void ErrorThrower::RangeError(const char* format, ...) {
+ if (error()) return;
+ va_list arguments;
+ va_start(arguments, format);
+ CHECK(*isolate_->range_error_function() != *isolate_->type_error_function());
+ Format(isolate_->range_error_function(), format, arguments);
+ va_end(arguments);
}
ErrorThrower::~ErrorThrower() {
if (error() && !isolate_->has_pending_exception()) {
- isolate_->ScheduleThrow(*message_);
+ isolate_->ScheduleThrow(*exception_);
}
}
} // namespace wasm
« no previous file with comments | « src/wasm/wasm-result.h ('k') | test/cctest/interpreter/bytecode_expectations/CallRuntime.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698