| 43 | } |
| 44 | |
| 45 | namespace_t instance_type::source_import(const std::string &path) |
| 46 | { |
| 47 | if (context->compiler->modules.count(path) > 0) |
| 48 | return context->compiler->modules[path]; |
| 49 | if (cs_impl::file_system::is_exe(path)) { |
| 50 | // is extension file |
| 51 | namespace_t module = std::make_shared<extension>(path); |
| 52 | context->compiler->modules.emplace(path, module); |
| 53 | return module; |
| 54 | } |
| 55 | else { |
| 56 | // is package file |
| 57 | context_t rt = create_subcontext(context); |
| 58 | rt->compiler->swap_context(rt); |
| 59 | try { |
| 60 | rt->instance->compile(path); |
| 61 | } |
| 62 | catch (...) { |
| 63 | context->compiler->swap_context(context); |
| 64 | throw; |
| 65 | } |
| 66 | context->compiler->swap_context(context); |
| 67 | rt->instance->interpret(); |
| 68 | namespace_t module = std::make_shared<name_space>(*rt->instance->storage.get_namespace()); |
| 69 | context->compiler->modules.emplace(path, module); |
| 70 | return module; |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | namespace_t instance_type::import(const std::string &path, const std::string &name) |
| 75 | { |
no test coverage detected