Envision
A visual programming IDE for object-oriented languages
|
This class is to manage the whole translation process. More...
Public Member Functions | |
TranslateManager (ClangHelpers &clang, OOModel::Project *root, ExpressionVisitor *visitor) | |
~TranslateManager () | |
QList< OOModel::Class * > | classesInFile (QString fileName) |
bool | containsClass (clang::CXXRecordDecl *recordDecl) |
bool | insertClass (clang::CXXRecordDecl *rDecl, OOModel::Class *&createdClass) |
Inserts the class ooClass to the managed class if it is not yet managed. More... | |
bool | insertClassTemplate (clang::ClassTemplateDecl *classTemplate, OOModel::Class *&createdClass) |
Inserts the class ooClass to the managed class if it is not yet managed. More... | |
bool | insertClassTemplateSpec (clang::ClassTemplateSpecializationDecl *classTemplate, OOModel::Class *&createdClass) |
Inserts the class ooClass to the managed class if it is not yet managed. More... | |
bool | insertEnum (clang::EnumDecl *enumDecl, OOModel::Class *&createdEnum) |
Inserts the enum ooEnum to the managed class if it is not yet managed. More... | |
OOModel::ExplicitTemplateInstantiation * | insertExplicitTemplateInstantiation (clang::ClassTemplateSpecializationDecl *explicitTemplateInst) |
OOModel::Field * | insertField (clang::FieldDecl *fieldDecl) |
Inserts the field fieldDecl to the manager and into the correct class. More... | |
OOModel::Method * | insertFunctionDecl (clang::FunctionDecl *functionDecl) |
Inserts the method mDecl to the manager if not yet managed. More... | |
OOModel::Method * | insertMethodDecl (clang::CXXMethodDecl *mDecl, OOModel::Method::MethodKind kind) |
Inserts the method mDecl to the manager if not yet managed. More... | |
OOModel::Module * | insertNamespace (clang::NamespaceDecl *namespaceDecl) |
OOModel::TypeAlias * | insertNamespaceAlias (clang::NamespaceAliasDecl *namespaceAlias) |
This function is to make sure that an using directive is used only once. More... | |
OOModel::Field * | insertNamespaceField (clang::VarDecl *varDecl, bool &wasDeclared) |
OOModel::Field * | insertStaticField (clang::VarDecl *varDecl, bool &wasDeclared) |
Inserts the static field varDecl to the manager and into the correct class. More... | |
OOModel::TypeAlias * | insertTypeAlias (clang::TypedefNameDecl *typeAlias) |
This function is to make sure that a TypeAlias (either using or typedef) is used only once. More... | |
OOModel::TypeAlias * | insertTypeAliasTemplate (clang::TypeAliasTemplateDecl *typeAliasTemplate) |
This function is to make sure that a TypeAlias with template arguments is used only once. More... | |
OOModel::NameImport * | insertUnresolvedUsing (clang::UnresolvedUsingValueDecl *unresolvedUsing) |
This function is to make sure that an unresolved using directive is used only once. More... | |
OOModel::NameImport * | insertUsingDecl (clang::UsingDecl *usingDecl) |
This function is to make sure that an using declaration is used only once. More... | |
OOModel::NameImport * | insertUsingDirective (clang::UsingDirectiveDecl *usingDirective) |
This function is to make sure that an using directive is used only once. More... | |
OOModel::Class * | lookupClass (clang::CXXRecordDecl *rDecl) |
void | removeEmptyNamespaces () |
Called at the end of each translation unit in order to remove empty namespaces that were added because of forward declarations. More... | |
void | setUtils (CppImportUtilities *utils) |
Private Member Functions | |
void | addMethodArguments (clang::FunctionDecl *functionDecl, OOModel::Method *method) |
void | addMethodResult (clang::FunctionDecl *functionDecl, OOModel::Method *method) |
OOModel::Method * | addNewFunction (clang::FunctionDecl *functionDecl) |
OOModel::Method * | addNewMethod (clang::CXXMethodDecl *mDecl, OOModel::Method::MethodKind kind) |
OOModel::Class * | createClass (clang::CXXRecordDecl *recordDecl) |
Creates a class with the name as specified in recordDecl. More... | |
bool | isNameSpaceEmpty (OOModel::Module *nameSpace) |
Private Attributes | |
ClangHelpers & | clang_ |
QHash< QString, OOModel::Class * > | classMap_ |
QHash< QString, OOModel::Class * > | enumMap_ |
QHash< QString, OOModel::ExplicitTemplateInstantiation * > | explicitTemplateInstMap_ {} |
ExpressionVisitor * | exprVisitor_ {} |
QHash< QString, OOModel::Method * > | functionMap_ |
QHash< QString, OOModel::Method * > | methodMap_ |
QHash< QString, OOModel::TypeAlias * > | namespacAliasMap_ |
QHash< QString, OOModel::Field * > | namespaceFieldMap_ |
QHash< QString, OOModel::Module * > | nameSpaceMap_ |
NodeHasher * | nh_ {} |
OOModel::Project * | rootProject_ {} |
QHash< QString, OOModel::Field * > | staticFieldMap_ |
QHash< QString, OOModel::TypeAlias * > | typeAliasMap_ |
QHash< QString, OOModel::NameImport * > | usingDeclMap_ |
QHash< QString, OOModel::NameImport * > | usingDirectiveMap_ |
CppImportUtilities * | utils_ {} |
This class is to manage the whole translation process.
It keeps track of nodes already translated and completes them if needed.
CppImport::TranslateManager::TranslateManager | ( | ClangHelpers & | clang, |
OOModel::Project * | root, | ||
ExpressionVisitor * | visitor | ||
) |
CppImport::TranslateManager::~TranslateManager | ( | ) |
|
private |
|
private |
|
private |
|
private |
QList< OOModel::Class * > CppImport::TranslateManager::classesInFile | ( | QString | fileName | ) |
bool CppImport::TranslateManager::containsClass | ( | clang::CXXRecordDecl * | recordDecl | ) |
|
private |
Creates a class with the name as specified in recordDecl.
It also sets the correct Kind (class, struct or union) if the kind is none of this the method returns a nullptr
bool CppImport::TranslateManager::insertClass | ( | clang::CXXRecordDecl * | rDecl, |
OOModel::Class *& | createdClass | ||
) |
Inserts the class ooClass to the managed class if it is not yet managed.
Returns true if the class is not yet managed (insert success) else false
bool CppImport::TranslateManager::insertClassTemplate | ( | clang::ClassTemplateDecl * | classTemplate, |
OOModel::Class *& | createdClass | ||
) |
Inserts the class ooClass to the managed class if it is not yet managed.
Returns true if the class is not yet managed (insert success) else false
bool CppImport::TranslateManager::insertClassTemplateSpec | ( | clang::ClassTemplateSpecializationDecl * | classTemplate, |
OOModel::Class *& | createdClass | ||
) |
Inserts the class ooClass to the managed class if it is not yet managed.
Returns true if the class is not yet managed (insert success) else false
bool CppImport::TranslateManager::insertEnum | ( | clang::EnumDecl * | enumDecl, |
OOModel::Class *& | createdEnum | ||
) |
Inserts the enum ooEnum to the managed class if it is not yet managed.
Returns true if the enum is not yet managed (insert success) else false
OOModel::ExplicitTemplateInstantiation * CppImport::TranslateManager::insertExplicitTemplateInstantiation | ( | clang::ClassTemplateSpecializationDecl * | explicitTemplateInst | ) |
OOModel::Field * CppImport::TranslateManager::insertField | ( | clang::FieldDecl * | fieldDecl | ) |
Inserts the field fieldDecl to the manager and into the correct class.
If the parent is not yet visited this method returns a nullptr.
OOModel::Method * CppImport::TranslateManager::insertFunctionDecl | ( | clang::FunctionDecl * | functionDecl | ) |
Inserts the method mDecl to the manager if not yet managed.
If the method is already managed the arguments may be completed. Returns either the new method created or the existing one.
OOModel::Method * CppImport::TranslateManager::insertMethodDecl | ( | clang::CXXMethodDecl * | mDecl, |
OOModel::Method::MethodKind | kind | ||
) |
Inserts the method mDecl to the manager if not yet managed.
If the method is already managed the arguments may be completed. Returns either the new method created or the existing one.
OOModel::Module * CppImport::TranslateManager::insertNamespace | ( | clang::NamespaceDecl * | namespaceDecl | ) |
OOModel::TypeAlias * CppImport::TranslateManager::insertNamespaceAlias | ( | clang::NamespaceAliasDecl * | namespaceAlias | ) |
This function is to make sure that an using directive is used only once.
The function returns a new allocated NameImport object if this usingdecl is not yet there in this context. Else it returns a nullptr.
OOModel::Field * CppImport::TranslateManager::insertNamespaceField | ( | clang::VarDecl * | varDecl, |
bool & | wasDeclared | ||
) |
OOModel::Field * CppImport::TranslateManager::insertStaticField | ( | clang::VarDecl * | varDecl, |
bool & | wasDeclared | ||
) |
Inserts the static field varDecl to the manager and into the correct class.
The parameter wasDeclared will be set to true if the declaration of this field was visited (only need to visit initializer now). The caller has to make sure that this is a static field. If the parent is not yet visited this method returns a nullptr. Note that clang treats a static field as a VarDecl
OOModel::TypeAlias * CppImport::TranslateManager::insertTypeAlias | ( | clang::TypedefNameDecl * | typeAlias | ) |
This function is to make sure that a TypeAlias (either using or typedef) is used only once.
The function returns a new allocated TypeAlias object if this type alias is not yet there in this context. Else it returns a nullptr.
OOModel::TypeAlias * CppImport::TranslateManager::insertTypeAliasTemplate | ( | clang::TypeAliasTemplateDecl * | typeAliasTemplate | ) |
This function is to make sure that a TypeAlias with template arguments is used only once.
The function returns a new allocated TypeAlias object if this type alias is not yet there in this context. Else it returns a nullptr.
OOModel::NameImport * CppImport::TranslateManager::insertUnresolvedUsing | ( | clang::UnresolvedUsingValueDecl * | unresolvedUsing | ) |
This function is to make sure that an unresolved using directive is used only once.
The function returns a new allocated NameImport object if this usingdecl is not yet there in this context. Else it returns a nullptr.
OOModel::NameImport * CppImport::TranslateManager::insertUsingDecl | ( | clang::UsingDecl * | usingDecl | ) |
This function is to make sure that an using declaration is used only once.
The function returns a new allocated NameImport object if this usingdecl is not yet there in this context. Else it returns a nullptr.
OOModel::NameImport * CppImport::TranslateManager::insertUsingDirective | ( | clang::UsingDirectiveDecl * | usingDirective | ) |
This function is to make sure that an using directive is used only once.
The function returns a new allocated NameImport object if this usingdecl is not yet there in this context. Else it returns a nullptr.
|
private |
OOModel::Class * CppImport::TranslateManager::lookupClass | ( | clang::CXXRecordDecl * | rDecl | ) |
void CppImport::TranslateManager::removeEmptyNamespaces | ( | ) |
Called at the end of each translation unit in order to remove empty namespaces that were added because of forward declarations.
void CppImport::TranslateManager::setUtils | ( | CppImportUtilities * | utils | ) |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |