1/*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef CFA_CONTEXT_H
6#define CFA_CONTEXT_H
7
8
9#include <ObjectList.h>
10
11#include "CfaRuleSet.h"
12#include "Types.h"
13
14
15class CfaContext {
16public:
17								CfaContext();
18								~CfaContext();
19
20			void				SetLocation(target_addr_t targetLocation,
21									target_addr_t initialLocation);
22
23			status_t			Init(uint32 registerCount);
24			status_t			SaveInitialRuleSet();
25
26			status_t			PushRuleSet();
27			status_t			PopRuleSet();
28
29			target_addr_t		TargetLocation() const
30									{ return fTargetLocation; }
31
32			target_addr_t		Location() const
33									{ return fLocation; }
34			void				SetLocation(target_addr_t location);
35
36			uint32				CodeAlignment() const
37									{ return fCodeAlignment; }
38			void				SetCodeAlignment(uint32 alignment);
39
40			int32				DataAlignment() const
41									{ return fDataAlignment; }
42			void				SetDataAlignment(int32 alignment);
43
44			uint32				ReturnAddressRegister() const
45									{ return fReturnAddressRegister; }
46			void				SetReturnAddressRegister(uint32 reg);
47
48			CfaCfaRule*			GetCfaCfaRule() const
49									{ return fRuleSet->GetCfaCfaRule(); }
50			CfaRule*			RegisterRule(uint32 index) const
51									{ return fRuleSet->RegisterRule(index); }
52
53			void				RestoreRegisterRule(uint32 reg);
54
55private:
56			typedef BObjectList<CfaRuleSet> RuleSetList;
57
58private:
59			target_addr_t		fTargetLocation;
60			target_addr_t		fLocation;
61			uint32				fCodeAlignment;
62			int32				fDataAlignment;
63			uint32				fReturnAddressRegister;
64			CfaRuleSet*			fRuleSet;
65			CfaRuleSet*			fInitialRuleSet;
66			RuleSetList			fRuleSetStack;
67};
68
69
70
71#endif	// CFA_CONTEXT_H
72