Chromium Code Reviews| 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 #ifndef V8_WASM_RESULT_H_ | 5 #ifndef V8_WASM_RESULT_H_ |
| 6 #define V8_WASM_RESULT_H_ | 6 #define V8_WASM_RESULT_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "src/base/compiler-specific.h" | 10 #include "src/base/compiler-specific.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 } | 92 } |
| 93 os << std::endl; | 93 os << std::endl; |
| 94 return os; | 94 return os; |
| 95 } | 95 } |
| 96 | 96 |
| 97 std::ostream& operator<<(std::ostream& os, const ErrorCode& error_code); | 97 std::ostream& operator<<(std::ostream& os, const ErrorCode& error_code); |
| 98 | 98 |
| 99 // A helper for generating error messages that bubble up to JS exceptions. | 99 // A helper for generating error messages that bubble up to JS exceptions. |
| 100 class ErrorThrower { | 100 class ErrorThrower { |
| 101 public: | 101 public: |
| 102 ErrorThrower(Isolate* isolate, const char* context) | 102 ErrorThrower(Isolate* isolate, const char* context) |
|
ahaas
2016/09/15 14:41:06
Why does the constructor not use i::Isolate* isola
ahaas
2016/09/19 14:02:37
I changed it to i::Isolate*
| |
| 103 : isolate_(isolate), context_(context) {} | 103 : isolate_(reinterpret_cast<i::Isolate*>(isolate)), context_(context) {} |
| 104 ~ErrorThrower(); | 104 ~ErrorThrower(); |
| 105 | 105 |
| 106 PRINTF_FORMAT(2, 3) void Error(const char* fmt, ...); | 106 PRINTF_FORMAT(2, 3) void Error(const char* fmt, ...); |
| 107 PRINTF_FORMAT(2, 3) void TypeError(const char* fmt, ...); | |
| 108 PRINTF_FORMAT(2, 3) void RangeError(const char* fmt, ...); | |
| 107 | 109 |
| 108 template <typename T> | 110 template <typename T> |
| 109 void Failed(const char* error, Result<T>& result) { | 111 void Failed(const char* error, Result<T>& result) { |
| 110 std::ostringstream str; | 112 std::ostringstream str; |
| 111 str << error << result; | 113 str << error << result; |
| 112 return Error("%s", str.str().c_str()); | 114 Error("%s", str.str().c_str()); |
| 113 } | 115 } |
| 114 | 116 |
| 115 i::Handle<i::String> Reify() { | 117 i::Handle<i::Object> Reify() { |
| 116 auto result = message_; | 118 auto result = exception_; |
|
ahaas
2016/09/15 14:41:06
Could you not use auto here please?
ahaas
2016/09/19 14:02:37
Done.
ahaas
2016/09/19 14:02:37
Done.
| |
| 117 message_ = i::Handle<i::String>(); | 119 exception_ = i::Handle<i::Object>::null(); |
| 118 return result; | 120 return result; |
| 119 } | 121 } |
| 120 | 122 |
| 121 bool error() const { return !message_.is_null(); } | 123 bool error() const { return !exception_.is_null(); } |
| 122 | 124 |
| 123 private: | 125 private: |
| 124 Isolate* isolate_; | 126 void Format(i::Handle<i::JSFunction> constructor, const char* fmt, va_list); |
| 127 | |
| 128 i::Isolate* isolate_; | |
| 125 const char* context_; | 129 const char* context_; |
| 126 i::Handle<i::String> message_; | 130 i::Handle<i::Object> exception_; |
| 127 }; | 131 }; |
| 128 } // namespace wasm | 132 } // namespace wasm |
| 129 } // namespace internal | 133 } // namespace internal |
| 130 } // namespace v8 | 134 } // namespace v8 |
| 131 | 135 |
| 132 #endif | 136 #endif |
| OLD | NEW |