EvalContext.h
/*
* File: EvalContext.h
*
* Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
* See included license file for license details.
*/
#if !defined(_EvalContext_h_)
#define _EvalContext_h_
#include <map>
#include <string>
#include "Value.h"
#include "int_size.h"
#include "SourceFile.h"
namespace elftosb
{
class EvalContext
{
public:
class SourceFileManager
{
public:
virtual bool hasSourceFile(const std::string &name) = 0;
virtual SourceFile *getSourceFile(const std::string &name) = 0;
virtual SourceFile *getDefaultSourceFile() = 0;
};
public:
EvalContext();
virtual ~EvalContext();
void setSourceFileManager(SourceFileManager *manager) { m_sourcesManager = manager; }
SourceFileManager *getSourceFileManager() { return m_sourcesManager; }
bool isVariableDefined(const std::string &name);
uint32_t getVariableValue(const std::string &name);
int_size_t getVariableSize(const std::string &name);
void setVariable(const std::string &name, uint32_t value, int_size_t size = kWordSize);
bool isVariableLocked(const std::string &name);
void lockVariable(const std::string &name);
void unlockVariable(const std::string &name);
void dump();
protected:
struct variable_info_t
{
uint32_t m_value;
int_size_t m_size;
bool m_isLocked;
};
typedef std::map<std::string, variable_info_t> variable_map_t;
SourceFileManager *m_sourcesManager;
variable_map_t m_variables;
};
}; // namespace elftosb
#endif // _EvalContext_h_
elftosb::EvalContext::variable_info_t::m_value
uint32_t m_value
Variable value.
Definition: EvalContext.h:83
elftosb::EvalContext::variable_map_t
std::map< std::string, variable_info_t > variable_map_t
Type to maps between the variable name and its info.
Definition: EvalContext.h:89
elftosb::EvalContext::m_variables
variable_map_t m_variables
Map of variables to their final values.
Definition: EvalContext.h:92
elftosb::EvalContext::m_sourcesManager
SourceFileManager * m_sourcesManager
Interface to source file manager.
Definition: EvalContext.h:91
elftosb::EvalContext
Context for evaluating AST tree and expressions.
Definition: EvalContext.h:28
elftosb
Definition: BootImage.h:13
elftosb::SourceFile
Abstract base class for a source file containing executable code.
Definition: apps/elftosb/common/SourceFile.h:33
elftosb::EvalContext::SourceFileManager
Abstract interface for a manager of source files.
Definition: EvalContext.h:34
elftosb::EvalContext::EvalContext
EvalContext()
Constructor.
Definition: EvalContext.cpp:14
elftosb::EvalContext::variable_info_t::m_isLocked
bool m_isLocked
Can this variable&#39;s value be changed?
Definition: EvalContext.h:85
elftosb::EvalContext::SourceFileManager::getDefaultSourceFile
virtual SourceFile * getDefaultSourceFile()=0
Returns the default source file, or NULL if none is set.
elftosb::EvalContext::~EvalContext
virtual ~EvalContext()
Destructor.
Definition: EvalContext.cpp:19
elftosb::EvalContext::SourceFileManager::hasSourceFile
virtual bool hasSourceFile(const std::string &name)=0
Returns true if a source file with the name name exists.
elftosb::EvalContext::variable_info_t::m_size
int_size_t m_size
Number of bytes.
Definition: EvalContext.h:84
elftosb::EvalContext::SourceFileManager::getSourceFile
virtual SourceFile * getSourceFile(const std::string &name)=0
Gets the requested source file.
elftosb::EvalContext::variable_info_t
Information about a variable&#39;s value.
Definition: EvalContext.h:81