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

Side by Side Diff: src/wasm/wasm-result.h

Issue 2084573002: Upgrade Wasm JS API, step 1 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Separate test refactorings Created 4 years, 6 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 unified diff | Download patch
OLDNEW
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" 8 #include "src/base/compiler-specific.h"
9 #include "src/base/smart-pointers.h" 9 #include "src/base/smart-pointers.h"
10 10
11 #include "src/handles.h"
11 #include "src/globals.h" 12 #include "src/globals.h"
12 13
13 namespace v8 { 14 namespace v8 {
14 namespace internal { 15 namespace internal {
15 16
16 class Isolate; 17 class Isolate;
17 18
18 namespace wasm { 19 namespace wasm {
19 20
20 // Error codes for programmatic checking of the decoder's verification. 21 // Error codes for programmatic checking of the decoder's verification.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 os << std::endl; 85 os << std::endl;
85 return os; 86 return os;
86 } 87 }
87 88
88 std::ostream& operator<<(std::ostream& os, const ErrorCode& error_code); 89 std::ostream& operator<<(std::ostream& os, const ErrorCode& error_code);
89 90
90 // A helper for generating error messages that bubble up to JS exceptions. 91 // A helper for generating error messages that bubble up to JS exceptions.
91 class ErrorThrower { 92 class ErrorThrower {
92 public: 93 public:
93 ErrorThrower(Isolate* isolate, const char* context) 94 ErrorThrower(Isolate* isolate, const char* context)
94 : isolate_(isolate), context_(context), error_(false) {} 95 : isolate_(isolate), context_(context) {}
96 ~ErrorThrower();
95 97
96 PRINTF_FORMAT(2, 3) void Error(const char* fmt, ...); 98 PRINTF_FORMAT(2, 3) void Error(const char* fmt, ...);
97 99
98 template <typename T> 100 template <typename T>
99 void Failed(const char* error, Result<T>& result) { 101 void Failed(const char* error, Result<T>& result) {
100 std::ostringstream str; 102 std::ostringstream str;
101 str << error << result; 103 str << error << result;
102 return Error("%s", str.str().c_str()); 104 return Error("%s", str.str().c_str());
103 } 105 }
104 106
105 bool error() const { return error_; } 107 i::Handle<i::String> Reify() {
108 auto result = message_;
109 message_ = i::Handle<i::String>();
110 return result;
111 }
112
113 bool error() const { return !message_.is_null(); }
106 114
107 private: 115 private:
108 Isolate* isolate_; 116 Isolate* isolate_;
109 const char* context_; 117 const char* context_;
110 bool error_; 118 i::Handle<i::String> message_;
111 }; 119 };
112 } // namespace wasm 120 } // namespace wasm
113 } // namespace internal 121 } // namespace internal
114 } // namespace v8 122 } // namespace v8
115 123
116 #endif 124 #endif
OLDNEW
« src/wasm/wasm-js.cc ('K') | « src/wasm/wasm-js.cc ('k') | src/wasm/wasm-result.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698