Kinetis Bootloader Host  2.0.0
Host Tools for Kinetis devices
EvalContext.h
1 /*
2  * File: EvalContext.h
3  *
4  * Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
5  * See included license file for license details.
6  */
7 #if !defined(_EvalContext_h_)
8 #define _EvalContext_h_
9 
10 #include <map>
11 #include <string>
12 #include "Value.h"
13 #include "int_size.h"
14 #include "SourceFile.h"
15 
16 namespace elftosb
17 {
29 {
30 public:
35  {
36  public:
38  virtual bool hasSourceFile(const std::string &name) = 0;
39 
41  virtual SourceFile *getSourceFile(const std::string &name) = 0;
42 
44  virtual SourceFile *getDefaultSourceFile() = 0;
45  };
46 
47 public:
49  EvalContext();
50 
52  virtual ~EvalContext();
53 
55 
56  void setSourceFileManager(SourceFileManager *manager) { m_sourcesManager = manager; }
59  SourceFileManager *getSourceFileManager() { return m_sourcesManager; }
61 
63 
64  bool isVariableDefined(const std::string &name);
65  uint32_t getVariableValue(const std::string &name);
66  int_size_t getVariableSize(const std::string &name);
67  void setVariable(const std::string &name, uint32_t value, int_size_t size = kWordSize);
69 
71 
72  bool isVariableLocked(const std::string &name);
73  void lockVariable(const std::string &name);
74  void unlockVariable(const std::string &name);
76 
77  void dump();
78 
79 protected:
82  {
83  uint32_t m_value;
84  int_size_t m_size;
85  bool m_isLocked;
86  };
87 
89  typedef std::map<std::string, variable_info_t> variable_map_t;
90 
92  variable_map_t m_variables;
93 };
94 
95 }; // namespace elftosb
96 
97 #endif // _EvalContext_h_
uint32_t m_value
Variable value.
Definition: EvalContext.h:83
std::map< std::string, variable_info_t > variable_map_t
Type to maps between the variable name and its info.
Definition: EvalContext.h:89
variable_map_t m_variables
Map of variables to their final values.
Definition: EvalContext.h:92
SourceFileManager * m_sourcesManager
Interface to source file manager.
Definition: EvalContext.h:91
Context for evaluating AST tree and expressions.
Definition: EvalContext.h:28
Definition: BootImage.h:13
Abstract base class for a source file containing executable code.
Definition: apps/elftosb/common/SourceFile.h:33
Abstract interface for a manager of source files.
Definition: EvalContext.h:34
EvalContext()
Constructor.
Definition: EvalContext.cpp:14
bool m_isLocked
Can this variable&#39;s value be changed?
Definition: EvalContext.h:85
virtual SourceFile * getDefaultSourceFile()=0
Returns the default source file, or NULL if none is set.
virtual ~EvalContext()
Destructor.
Definition: EvalContext.cpp:19
virtual bool hasSourceFile(const std::string &name)=0
Returns true if a source file with the name name exists.
int_size_t m_size
Number of bytes.
Definition: EvalContext.h:84
virtual SourceFile * getSourceFile(const std::string &name)=0
Gets the requested source file.
Information about a variable&#39;s value.
Definition: EvalContext.h:81