MCPcopy Create free account
hub / github.com/covscript/covscript / source_import

Method source_import

sources/instance/instance.cpp:45–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers 1

source_importFunction · 0.80

Calls 6

create_subcontextFunction · 0.85
compileMethod · 0.80
interpretMethod · 0.80
is_exeFunction · 0.50
swap_contextMethod · 0.45
get_namespaceMethod · 0.45

Tested by

no test coverage detected