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

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

Issue 2173403002: Replace SmartArrayPointer<T> with unique_ptr<T[]> (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 5 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
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | test/cctest/compiler/test-operator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <memory>
9
8 #include "src/base/compiler-specific.h" 10 #include "src/base/compiler-specific.h"
9 #include "src/base/smart-pointers.h" 11 #include "src/base/smart-pointers.h"
10 12
11 #include "src/handles.h" 13 #include "src/handles.h"
12 #include "src/globals.h" 14 #include "src/globals.h"
13 15
14 namespace v8 { 16 namespace v8 {
15 namespace internal { 17 namespace internal {
16 18
17 class Isolate; 19 class Isolate;
(...skipping 14 matching lines...) Expand all
32 kTypeError, // type mismatch 34 kTypeError, // type mismatch
33 kInvalidLocalIndex, // invalid local 35 kInvalidLocalIndex, // invalid local
34 kInvalidGlobalIndex, // invalid global 36 kInvalidGlobalIndex, // invalid global
35 kInvalidFunctionIndex, // invalid function 37 kInvalidFunctionIndex, // invalid function
36 kInvalidMemType // invalid memory type 38 kInvalidMemType // invalid memory type
37 }; 39 };
38 40
39 // The overall result of decoding a function or a module. 41 // The overall result of decoding a function or a module.
40 template <typename T> 42 template <typename T>
41 struct Result { 43 struct Result {
42 Result() : val(), error_code(kSuccess), start(nullptr), error_pc(nullptr) { 44 Result() : val(), error_code(kSuccess), start(nullptr), error_pc(nullptr) {}
43 error_msg.Reset(nullptr); 45 Result(Result&& other) { *this = std::move(other); }
46 Result& operator=(Result&& other) {
47 MoveFrom(other);
48 val = other.val;
49 return *this;
44 } 50 }
45 51
46 T val; 52 T val;
47 ErrorCode error_code; 53 ErrorCode error_code;
48 const byte* start; 54 const byte* start;
49 const byte* error_pc; 55 const byte* error_pc;
50 const byte* error_pt; 56 const byte* error_pt;
51 base::SmartArrayPointer<char> error_msg; 57 std::unique_ptr<char[]> error_msg;
52 58
53 bool ok() const { return error_code == kSuccess; } 59 bool ok() const { return error_code == kSuccess; }
54 bool failed() const { return error_code != kSuccess; } 60 bool failed() const { return error_code != kSuccess; }
55 61
56 template <typename V> 62 template <typename V>
57 void CopyFrom(Result<V>& that) { 63 void MoveFrom(Result<V>& that) {
58 error_code = that.error_code; 64 error_code = that.error_code;
59 start = that.start; 65 start = that.start;
60 error_pc = that.error_pc; 66 error_pc = that.error_pc;
61 error_pt = that.error_pt; 67 error_pt = that.error_pt;
62 error_msg = that.error_msg; 68 error_msg = std::move(that.error_msg);
63 } 69 }
70
71 private:
72 DISALLOW_COPY_AND_ASSIGN(Result);
64 }; 73 };
65 74
66 template <typename T> 75 template <typename T>
67 std::ostream& operator<<(std::ostream& os, const Result<T>& result) { 76 std::ostream& operator<<(std::ostream& os, const Result<T>& result) {
68 os << "Result = "; 77 os << "Result = ";
69 if (result.ok()) { 78 if (result.ok()) {
70 if (result.val != nullptr) { 79 if (result.val != nullptr) {
71 os << *result.val; 80 os << *result.val;
72 } else { 81 } else {
73 os << "success (no value)"; 82 os << "success (no value)";
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 private: 124 private:
116 Isolate* isolate_; 125 Isolate* isolate_;
117 const char* context_; 126 const char* context_;
118 i::Handle<i::String> message_; 127 i::Handle<i::String> message_;
119 }; 128 };
120 } // namespace wasm 129 } // namespace wasm
121 } // namespace internal 130 } // namespace internal
122 } // namespace v8 131 } // namespace v8
123 132
124 #endif 133 #endif
OLDNEW
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | test/cctest/compiler/test-operator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698