30 }
catch (
const std::runtime_error &e) {
54 if (filepath != L
"builtin") {
56 std::filesystem::path
final = prep / std::filesystem::path(filepath);
58 rFilepath =
realpath(
final.wstring());
59 if (std::filesystem::exists(rFilepath) && std::filesystem::is_regular_file(rFilepath)) {
61 }
else if (std::filesystem::exists(rFilepath + L
".hoshi") && std::filesystem::is_regular_file(rFilepath + L
".hoshi")) {
62 rFilepath += L
".hoshi";
64 }
else if (std::filesystem::exists(rFilepath) && std::filesystem::is_directory(rFilepath) && std::filesystem::exists(std::filesystem::path(rFilepath) /
"index.hoshi")) {
65 rFilepath = (std::filesystem::path(rFilepath) /
"index.hoshi").wstring();
76 if (rFilepath.empty()) {
77 throw std::runtime_error(
"file not resolved in all search paths: " +
wstring2string(filepath));
82 }
catch (
const std::out_of_range &e) {
85 throw std::runtime_error(
"invalid filename: " +
wstring2string(rFilepath));
88 buildConfig->searchPaths.push_back(std::filesystem::path(rFilepath).parent_path().wstring());
89 buildConfig->searchPaths.push_back(std::filesystem::path(rFilepath).parent_path().append(
".tsuki_modules").wstring());
91 fseek(fp, 0, SEEK_END);
92 auto size = ftell(fp);
93 fseek(fp, 0, SEEK_SET);
94 auto *a =
new std::string(size, 0);
95 fread(a->data(), size, 1, fp);
114 std::shared_ptr<moduleContext> modCtx = std::make_shared<moduleContext>(shared_from_this(), rFilepath, mod);
115 std::shared_ptr<IRModule> irMod = std::make_shared<IRModule>();
116 irMod->modulePath = rFilepath;
118 irMod->identifier = idx;
120 std::shared_ptr<visitor> vis = std::make_shared<visitor>(modCtx, irMod, idx);
142 auto builtinModule = std::make_shared<IRModule>();
194 const std::shared_ptr<IRObjectFile> &irObjectFile) {
203 const std::shared_ptr<IRBuildConfig> &buildConfig) {
243 if (type->isForeignBasicType()) {
244 switch (type->type) {
252 throw std::runtime_error(
"unknown foreign basic type");
#define HOSHI_COMPILER_CTX_GLOB_ID_CONST
std::shared_ptr< IRBuildConfig > buildConfig
std::shared_ptr< yoi::IRValueType > getForeignFloatObjectType()
std::map< yoi::indexT, std::shared_ptr< IRModule > > moduleImported
const std::map< yoi::indexT, std::shared_ptr< IRModule > > & getCompiledModules() const
std::shared_ptr< moduleContext > builtinModuleContext
bool isInitialized() const
void setIRObjectFile(const std::shared_ptr< IRObjectFile > &irObjectFile)
yoi::indexTable< yoi::wstr, std::shared_ptr< yoi::moduleContext > > modules
std::shared_ptr< yoi::moduleContext > getModuleContext(yoi::indexT index)
get module context by index
std::shared_ptr< yoi::IRValueType > getCharObjectType(bool forceRawAttr=false)
void registerModule(yoi::indexT idx, std::shared_ptr< IRModule > mod)
std::shared_ptr< yoi::IRValueType > getNullInterfaceType()
void setBuildConfig(const std::shared_ptr< IRBuildConfig > &buildConfig)
std::set< hoshiModule * > astToFinalize
std::shared_ptr< yoi::IRValueType > getPointerType()
const std::shared_ptr< IRObjectFile > & getIRObjectFile() const
std::shared_ptr< yoi::IRValueType > getBoolObjectType(bool forceRawAttr=false)
std::shared_ptr< DiagnosticEngine > getDiagnosticEngine() const
yoi::indexT getModuleIndexByRealPath(const yoi::wstr &modRealPath)
std::shared_ptr< yoi::IRValueType > getUnsignedObjectType(bool forceRawAttr=false)
std::shared_ptr< IRFFITable > getIRFFITable()
std::shared_ptr< yoi::IRValueType > getForeignInt32ObjectType()
std::shared_ptr< yoi::IRValueType > getShortObjectType(bool forceRawAttr=false)
std::shared_ptr< yoi::IRValueType > getNoneObjectType()
yoi::indexT compileModule(const yoi::wstr &filepath)
void initializeSharedObjects()
std::shared_ptr< yoi::IRValueType > getIntObjectType(bool forceRawAttr=false)
std::shared_ptr< IRObjectFile > irObjectFile
std::shared_ptr< IRFFITable > irFFITable
std::shared_ptr< IRModule > getImportedModule(yoi::indexT index)
std::shared_ptr< BuiltinModuleBuilder > builtinModuleBuilder
void setDiagnosticEngine(const std::shared_ptr< DiagnosticEngine > &engine)
std::shared_ptr< IRBuildConfig > getBuildConfig() const
std::shared_ptr< yoi::IRValueType > getDeciObjectType(bool forceRawAttr=false)
yoi::IRValueType normalizeForeignBasicType(const std::shared_ptr< yoi::IRValueType > &type, bool handlePointer=true)
std::shared_ptr< yoi::IRValueType > getStrObjectType(bool forceRawAttr=false)
std::shared_ptr< DiagnosticEngine > diagnosticEngine
yoi::indexT getIndex(const A &k)
yoi::indexT put(const A &a, const B &b)
static const char * __yoi_builtin_module_hoshi
std::string wstring2string(const std::wstring &v)
std::shared_ptr< T > managedPtr(const T &v)
std::wstring string2wstring(const std::string &v)
yoi::wstr realpath(const std::wstring &path)
thread_local yoi::wstr __current_file_path
void set_diagnostic_engine(DiagnosticEngine *engine)
void set_current_file_path(const std::wstring &path)
void finalizeAST(funcTypeSpec *ptr)
void parse(yoi::basicLiterals *&o, yoi::lexer &lex)