OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Native Client Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef DWARF_READER_PARSE_STATE_H_ | |
6 #define DWARF_READER_PARSE_STATE_H_ | |
7 | |
8 #include <stack> | |
9 | |
10 namespace dwarf_reader { | |
11 | |
12 /// This class is used to store some basic information about the data currenty | |
13 /// being parsed out of the binary. It uses stacks because they are useful | |
14 /// for doing the breadth-first traversal which the DWARF information is laid | |
15 /// out to facilitate (by being a flattened representation of a tree of | |
16 /// information entries). | |
17 class ParseState { | |
18 public: | |
19 ParseState() | |
20 : current_compilation_unit_(NULL) {} | |
21 | |
22 void set_current_compilation_unit(void *compilation_unit) { | |
23 current_compilation_unit_ = compilation_unit; | |
24 }; | |
25 void *current_compilation_unit(); | |
26 | |
27 void PushStackFrame(void * context, uint64 address) { | |
28 context_stack_.push(context); | |
29 address_stack_.push(address); | |
30 }; | |
31 | |
32 void * GetTopStackContext() const { | |
33 return context_stack_.top(); | |
34 } | |
35 | |
36 uint64 GetTopStackAddress() const { | |
37 return address_stack_.top(); | |
38 } | |
39 | |
40 void PopStackFrame() { | |
41 context_stack_.pop(); | |
42 address_stack_.pop(); | |
43 }; | |
44 | |
45 private: | |
46 stack<void*> context_stack_; | |
47 stack<uint64> address_stack_; | |
48 void *current_compilation_unit_; | |
49 }; | |
50 | |
51 } // namespace dwarf_reader | |
52 | |
53 #endif // DWARF_READER_PARSE_STATE_H_ | |
OLD | NEW |