-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41623bd
commit 838c9d6
Showing
6 changed files
with
31 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,17 @@ | ||
// | ||
// Created by wangz on 24-7-29. | ||
// | ||
module; | ||
#include <stdexcept> | ||
module Manager.ClassManager; | ||
|
||
#include "ClassManager.h" | ||
|
||
namespace Riddle{ | ||
namespace Riddle { | ||
/// @brief 查找相关的类 | ||
ClassNode ClassManager::getClass(const std::string &name){ | ||
if (const auto it = Classes.find(name);it == Classes.end()) { | ||
ClassNode ClassManager::getClass(const std::string &name) { | ||
if(const auto it = Classes.find(name); it == Classes.end()) { | ||
throw std::logic_error("没有这个类或者使用了不支持的路径"); | ||
} | ||
return Classes.find(name)->second; | ||
} | ||
|
||
void ClassManager::createClass(const ClassNode &theClass){ | ||
Classes.emplace(theClass.get().types->getName().str(),theClass); | ||
void ClassManager::createClass(const ClassNode &theClass) { | ||
Classes.emplace(theClass.get().types->getName().str(), theClass); | ||
} | ||
} // namespace Riddle |
19 changes: 6 additions & 13 deletions
19
src/Tools/Managers/ClassManager.h → src/Tools/Managers/ClassManger.ixx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,19 @@ | ||
// | ||
// Created by wangz on 24-7-29. | ||
// | ||
|
||
#ifndef RIDDLE_LANGUAGE_CLASSMANAGER_H | ||
#define RIDDLE_LANGUAGE_CLASSMANAGER_H | ||
module; | ||
#include <llvm/IR/IRBuilder.h> | ||
|
||
export module Manager.ClassManager; | ||
import Types.Class; | ||
import Types.ClassNode; | ||
|
||
namespace Riddle{ | ||
export namespace Riddle { | ||
/// @brief 管理类 | ||
class ClassManager{ | ||
class ClassManager { | ||
/// @brief 存储数据字段 | ||
std::unordered_map<std::string,const ClassNode> Classes; | ||
std::unordered_map<std::string, const ClassNode> Classes; | ||
|
||
public: | ||
ClassNode getClass(const std::string &name); | ||
|
||
// class 在进入该函数后则不可修改 | ||
void createClass(const ClassNode &theClass); | ||
}; | ||
} // namespace Riddle | ||
|
||
#endif//RIDDLE_LANGUAGE_CLASSMANAGER_H | ||
} // namespace Riddle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters