Implement some of the methods in DccImpl

This commit is contained in:
nemerle 2016-04-26 09:23:34 +02:00
parent d1738ea630
commit a944ea5da8
2 changed files with 48 additions and 41 deletions

View File

@ -29,26 +29,26 @@ class Project : public IProject
QString m_output_path; QString m_output_path;
public: public:
typedef llvm::iplist<Function> FunctionListType; typedef llvm::iplist<Function> FunctionListType;
typedef FunctionListType lFunction; typedef FunctionListType lFunction;
typedef FunctionListType::iterator ilFunction; typedef FunctionListType::iterator ilFunction;
SYMTAB symtab; /* Global symbol table */
SYMTAB symtab; /* Global symbol table */
FunctionListType pProcList; FunctionListType pProcList;
CALL_GRAPH * callGraph; /* Pointer to the head of the call graph */ CALL_GRAPH * callGraph; /* Pointer to the head of the call graph */
PROG prog; /* Loaded program image parameters */ PROG prog; /* Loaded program image parameters */
// no copies // no copies
Project(const Project&) = delete; Project(const Project&) = delete;
const Project &operator=(const Project & l) =delete; const Project & operator=(const Project & l) =delete;
// only moves // only moves
Project(); // default constructor, Project(); // default constructor,
public: public:
void create(const QString &a); void create(const QString &a);
bool load(); bool load();
const QString &output_path() const {return m_output_path;} const QString & output_path() const {return m_output_path;}
const QString &project_name() const {return m_project_name;} const QString & project_name() const {return m_project_name;}
const QString &binary_path() const {return m_fname;} const QString & binary_path() const {return m_fname;}
QString output_name(const char *ext); QString output_name(const char *ext);
ilFunction funcIter(Function *to_find); ilFunction funcIter(Function *to_find);
ilFunction findByEntry(uint32_t entry); ilFunction findByEntry(uint32_t entry);
@ -60,13 +60,14 @@ public:
size_t symbolSize(size_t idx); size_t symbolSize(size_t idx);
hlType symbolType(size_t idx); hlType symbolType(size_t idx);
const QString & symbolName(size_t idx); const QString & symbolName(size_t idx);
const SYM &getSymByIdx(size_t idx) const; const SYM & getSymByIdx(size_t idx) const;
static Project *get(); static Project * get();
PROG * binary() {return &prog;} PROG * binary() {return &prog;}
SourceMachine *machine(); SourceMachine *machine();
const FunctionListType &functions() const { return pProcList; } const FunctionListType &functions() const { return pProcList; }
FunctionListType &functions() { return pProcList; }
protected: protected:
void initialize(); void initialize();
void writeGlobSymTable(); void writeGlobSymTable();

View File

@ -1,22 +1,24 @@
#include "dcc_interface.h" #include "dcc_interface.h"
#include "dcc.h" #include "dcc.h"
#include "project.h" #include "project.h"
struct DccImpl : public IDcc{ struct DccImpl : public IDcc {
ilFunction m_current_func;
// IDcc interface // IDcc interface
public: public:
void BaseInit() void BaseInit()
{ {
m_current_func = Project::get()->functions().end();
} }
void Init(QObject *tgt) void Init(QObject *tgt)
{ {
} }
ilFunction GetFirstFuncHandle() ilFunction GetFirstFuncHandle()
{ {
return Project::get()->functions().begin();
} }
ilFunction GetCurFuncHandle() ilFunction GetCurFuncHandle()
{ {
return m_current_func;
} }
void analysis_Once() void analysis_Once()
{ {
@ -34,13 +36,17 @@ public:
} }
size_t getFuncCount() size_t getFuncCount()
{ {
return Project::get()->functions().size();
} }
const lFunction &validFunctions() const const lFunction &validFunctions() const
{ {
return Project::get()->functions(); return Project::get()->functions();
} }
void SetCurFunc_by_Name(QString) void SetCurFunc_by_Name(QString v)
{ {
if(m_current_func!=Project::get()->functions().end()) {
m_current_func->name = v;
}
} }
QDir installDir() { QDir installDir() {
return QDir("."); return QDir(".");