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 "src/base/compiler-specific.h" | |
9 #include "src/base/smart-pointers.h" | 8 #include "src/base/smart-pointers.h" |
10 | 9 |
11 #include "src/globals.h" | 10 #include "src/globals.h" |
12 | 11 |
13 namespace v8 { | 12 namespace v8 { |
14 namespace internal { | 13 namespace internal { |
15 | 14 |
16 class Isolate; | 15 class Isolate; |
17 | 16 |
18 namespace wasm { | 17 namespace wasm { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 } | 86 } |
88 | 87 |
89 std::ostream& operator<<(std::ostream& os, const ErrorCode& error_code); | 88 std::ostream& operator<<(std::ostream& os, const ErrorCode& error_code); |
90 | 89 |
91 // A helper for generating error messages that bubble up to JS exceptions. | 90 // A helper for generating error messages that bubble up to JS exceptions. |
92 class ErrorThrower { | 91 class ErrorThrower { |
93 public: | 92 public: |
94 ErrorThrower(Isolate* isolate, const char* context) | 93 ErrorThrower(Isolate* isolate, const char* context) |
95 : isolate_(isolate), context_(context), error_(false) {} | 94 : isolate_(isolate), context_(context), error_(false) {} |
96 | 95 |
97 PRINTF_FORMAT(2, 3) void Error(const char* fmt, ...); | 96 void Error(const char* fmt, ...); |
98 | 97 |
99 template <typename T> | 98 template <typename T> |
100 void Failed(const char* error, Result<T>& result) { | 99 void Failed(const char* error, Result<T>& result) { |
101 std::ostringstream str; | 100 std::ostringstream str; |
102 str << error << result; | 101 str << error << result; |
103 return Error("%s", str.str().c_str()); | 102 return Error(str.str().c_str()); |
104 } | 103 } |
105 | 104 |
106 bool error() const { return error_; } | 105 bool error() const { return error_; } |
107 | 106 |
108 private: | 107 private: |
109 Isolate* isolate_; | 108 Isolate* isolate_; |
110 const char* context_; | 109 const char* context_; |
111 bool error_; | 110 bool error_; |
112 }; | 111 }; |
113 } // namespace wasm | 112 } // namespace wasm |
114 } // namespace internal | 113 } // namespace internal |
115 } // namespace v8 | 114 } // namespace v8 |
116 | 115 |
117 #endif | 116 #endif |
OLD | NEW |