| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium 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 COURGETTE_INSTRUCTION_UTILS_H_ | 5 #ifndef COURGETTE_INSTRUCTION_UTILS_H_ |
| 6 #define COURGETTE_INSTRUCTION_UTILS_H_ | 6 #define COURGETTE_INSTRUCTION_UTILS_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 virtual CheckBool EmitAbs64(Label* label) = 0; | 54 virtual CheckBool EmitAbs64(Label* label) = 0; |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 DISALLOW_COPY_AND_ASSIGN(InstructionReceptor); | 57 DISALLOW_COPY_AND_ASSIGN(InstructionReceptor); |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 // A rerunable callback that emit instructions to a provided receptor. Returns | 60 // A rerunable callback that emit instructions to a provided receptor. Returns |
| 61 // true on success, and false otherwise. | 61 // true on success, and false otherwise. |
| 62 using InstructionGenerator = base::Callback<CheckBool(InstructionReceptor*)>; | 62 using InstructionGenerator = base::Callback<CheckBool(InstructionReceptor*)>; |
| 63 | 63 |
| 64 // A counter that increments via .push_back(), so it can be passed via template |
| 65 // to substitute std::vector<T>, to count elements instead of storing them. |
| 66 template <typename T> |
| 67 class CountingVector { |
| 68 public: |
| 69 CountingVector() {} |
| 70 |
| 71 void push_back(const T& /* unused */) { ++size_; } |
| 72 size_t size() const { return size_; } |
| 73 |
| 74 private: |
| 75 size_t size_ = 0; |
| 76 }; |
| 77 |
| 64 } // namespace courgette | 78 } // namespace courgette |
| 65 | 79 |
| 66 #endif // COURGETTE_INSTRUCTION_UTILS_H_ | 80 #endif // COURGETTE_INSTRUCTION_UTILS_H_ |
| OLD | NEW |