Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/wabt/binary-reader-stats.h
1 /* 2 * Copyright 2016 WebAssembly Community Group participants 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef WABT_BINARY_READER_OPCNT_H_ 18 #define WABT_BINARY_READER_OPCNT_H_ 19 20 #include <map> 21 #include <vector> 22 23 #include "wabt/common.h" 24 #include "wabt/opcode.h" 25 26 namespace wabt { 27 28 struct Module; 29 struct ReadBinaryOptions; 30 class Stream; 31 32 class OpcodeInfo { 33 public: 34 enum class Kind { 35 Bare, 36 Uint32, 37 Uint64, 38 Index, 39 Float32, 40 Float64, 41 Uint32Uint32, 42 Uint32Uint32Uint32, 43 Uint32Uint32Uint32Uint32, 44 BlockSig, 45 BrTable, 46 V128, 47 }; 48 49 explicit OpcodeInfo(Opcode, Kind); 50 template <typename T> 51 OpcodeInfo(Opcode, Kind, T* data, size_t count = 1); 52 template <typename T> 53 OpcodeInfo(Opcode, Kind, T* data, size_t count, T extra); 54 55 Opcode opcode() const { return opcode_; } 56 57 void Write(Stream&); 58 59 private: 60 template <typename T> 61 std::pair<const T*, size_t> GetDataArray() const; 62 template <typename T> 63 const T* GetData(size_t expected_size = 1) const; 64 65 template <typename T, typename F> 66 void WriteArray(Stream& stream, F&& write_func); 67 68 Opcode opcode_; 69 Kind kind_; 70 std::vector<uint8_t> data_; 71 72 friend bool operator==(const OpcodeInfo&, const OpcodeInfo&); 73 friend bool operator!=(const OpcodeInfo&, const OpcodeInfo&); 74 friend bool operator<(const OpcodeInfo&, const OpcodeInfo&); 75 friend bool operator<=(const OpcodeInfo&, const OpcodeInfo&); 76 friend bool operator>(const OpcodeInfo&, const OpcodeInfo&); 77 friend bool operator>=(const OpcodeInfo&, const OpcodeInfo&); 78 }; 79 80 bool operator==(const OpcodeInfo&, const OpcodeInfo&); 81 bool operator!=(const OpcodeInfo&, const OpcodeInfo&); 82 bool operator<(const OpcodeInfo&, const OpcodeInfo&); 83 bool operator<=(const OpcodeInfo&, const OpcodeInfo&); 84 bool operator>(const OpcodeInfo&, const OpcodeInfo&); 85 bool operator>=(const OpcodeInfo&, const OpcodeInfo&); 86 87 using OpcodeInfoCounts = std::map<OpcodeInfo, size_t>; 88 89 Result ReadBinaryOpcnt(const void* data, 90 size_t size, 91 const ReadBinaryOptions& options, 92 OpcodeInfoCounts* opcode_counts); 93 94 } // namespace wabt 95 96 #endif /* WABT_BINARY_READER_OPCNT_H_ */