-
Notifications
You must be signed in to change notification settings - Fork 207
/
operand.h
60 lines (48 loc) · 1.81 KB
/
operand.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2011-2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef OPERAND_H_
#define OPERAND_H_
#include <cstdint>
#include <string>
#include "third_party/absl/container/flat_hash_set.h"
#include "third_party/absl/container/node_hash_map.h"
#include "third_party/zynamics/binexport/expression.h"
#pragma pack(push, 1)
class Operand {
public:
using OperandCache = absl::node_hash_map<std::string, Operand>;
Expressions::iterator begin() const;
Expressions::iterator end() const;
Expressions::const_iterator cbegin() const;
Expressions::const_iterator cend() const;
uint8_t GetExpressionCount() const;
int GetId() const;
static Operand* CreateOperand(const Expressions& expressions);
static void EmptyCache();
static const OperandCache& GetOperands();
static void PurgeCache(const absl::flat_hash_set<int>& ids_to_keep);
const Expression& GetExpression(int index) const;
const Expression& GetLastExpression() const;
private:
static thread_local Expressions expressions_;
static thread_local OperandCache operand_cache_;
static thread_local uint32_t global_id_;
explicit Operand(const Expressions& expressions);
uint32_t id_ = 0;
uint32_t expression_index_;
uint8_t expression_count_;
};
#pragma pack(pop)
using Operands = std::vector<Operand*>;
#endif // OPERAND_H_