30 }
catch (
const std::runtime_error &e) {
46 if (filepath != L
"builtin") {
48 std::filesystem::path
final = prep / std::filesystem::path(filepath);
49 rFilepath =
realpath(
final.wstring());
50 if (std::filesystem::exists(rFilepath) && std::filesystem::is_regular_file(rFilepath)) {
52 }
else if (std::filesystem::exists(rFilepath + L
".hoshi") && std::filesystem::is_regular_file(rFilepath + L
".hoshi")) {
53 rFilepath += L
".hoshi";
55 }
else if (std::filesystem::exists(rFilepath) && std::filesystem::is_directory(rFilepath) && std::filesystem::exists(std::filesystem::path(rFilepath) /
"index.hoshi")) {
56 rFilepath = (std::filesystem::path(rFilepath) /
"index.hoshi").wstring();
67 if (rFilepath.empty()) {
68 throw std::runtime_error(
"file not resolved in all search paths: " +
wstring2string(filepath));
73 }
catch (
const std::out_of_range &e) {
76 throw std::runtime_error(
"invalid filename: " +
wstring2string(rFilepath));
79 buildConfig->searchPaths.push_back(std::filesystem::path(rFilepath).parent_path().wstring());
80 buildConfig->searchPaths.push_back(std::filesystem::path(rFilepath).parent_path().append(
".pardo_modules").wstring());
82 fseek(fp, 0, SEEK_END);
83 auto size = ftell(fp);
84 fseek(fp, 0, SEEK_SET);
85 auto *a =
new std::string(size, 0);
86 fread(a->data(), size, 1, fp);
98 std::shared_ptr<moduleContext> modCtx = std::make_shared<moduleContext>(shared_from_this(), rFilepath, mod);
99 std::shared_ptr<IRModule> irMod = std::make_shared<IRModule>();
100 irMod->modulePath = rFilepath;
102 irMod->identifier = idx;
104 std::shared_ptr<visitor> vis = std::make_shared<visitor>(modCtx, irMod, idx);
123 auto builtinModule = std::make_shared<IRModule>();
166 const std::shared_ptr<IRObjectFile> &irObjectFile) {
175 const std::shared_ptr<IRBuildConfig> &buildConfig) {
215 if (type->isForeignBasicType()) {
216 switch (type->type) {
224 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
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)
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)
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
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)
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_current_file_path(const std::wstring &path)
void finalizeAST(funcTypeSpec *ptr)
void parse(yoi::basicLiterals *&o, yoi::lexer &lex)