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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // A helper for generating error messages that bubble up to JS exceptions. | 88 // A helper for generating error messages that bubble up to JS exceptions. |
89 class V8_EXPORT_PRIVATE ErrorThrower { | 89 class V8_EXPORT_PRIVATE ErrorThrower { |
90 public: | 90 public: |
91 ErrorThrower(i::Isolate* isolate, const char* context) | 91 ErrorThrower(i::Isolate* isolate, const char* context) |
92 : isolate_(isolate), context_(context) {} | 92 : isolate_(isolate), context_(context) {} |
93 ~ErrorThrower(); | 93 ~ErrorThrower(); |
94 | 94 |
95 PRINTF_FORMAT(2, 3) void TypeError(const char* fmt, ...); | 95 PRINTF_FORMAT(2, 3) void TypeError(const char* fmt, ...); |
96 PRINTF_FORMAT(2, 3) void RangeError(const char* fmt, ...); | 96 PRINTF_FORMAT(2, 3) void RangeError(const char* fmt, ...); |
97 PRINTF_FORMAT(2, 3) void CompileError(const char* fmt, ...); | 97 PRINTF_FORMAT(2, 3) void CompileError(const char* fmt, ...); |
| 98 PRINTF_FORMAT(2, 3) void LinkError(const char* fmt, ...); |
98 PRINTF_FORMAT(2, 3) void RuntimeError(const char* fmt, ...); | 99 PRINTF_FORMAT(2, 3) void RuntimeError(const char* fmt, ...); |
99 | 100 |
100 template <typename T> | 101 template <typename T> |
101 void CompileFailed(const char* error, Result<T>& result) { | 102 void CompileFailed(const char* error, Result<T>& result) { |
102 std::ostringstream str; | 103 std::ostringstream str; |
103 str << error << result; | 104 str << error << result; |
104 CompileError("%s", str.str().c_str()); | 105 CompileError("%s", str.str().c_str()); |
105 } | 106 } |
106 | 107 |
107 i::Handle<i::Object> Reify() { | 108 i::Handle<i::Object> Reify() { |
108 i::Handle<i::Object> result = exception_; | 109 i::Handle<i::Object> result = exception_; |
109 exception_ = i::Handle<i::Object>::null(); | 110 exception_ = i::Handle<i::Object>::null(); |
110 return result; | 111 return result; |
111 } | 112 } |
112 | 113 |
113 bool error() const { return !exception_.is_null(); } | 114 bool error() const { return !exception_.is_null(); } |
114 | 115 |
115 private: | 116 private: |
116 void Format(i::Handle<i::JSFunction> constructor, const char* fmt, va_list); | 117 void Format(i::Handle<i::JSFunction> constructor, const char* fmt, va_list); |
117 | 118 |
118 i::Isolate* isolate_; | 119 i::Isolate* isolate_; |
119 const char* context_; | 120 const char* context_; |
120 i::Handle<i::Object> exception_; | 121 i::Handle<i::Object> exception_; |
121 }; | 122 }; |
122 } // namespace wasm | 123 } // namespace wasm |
123 } // namespace internal | 124 } // namespace internal |
124 } // namespace v8 | 125 } // namespace v8 |
125 | 126 |
126 #endif | 127 #endif |
OLD | NEW |