-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow modules to optionally import nothing at all #40110
Changes from 1 commit
dc5eb44
a9f6d7f
4f26a5e
d0ccdec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
extern "C" { | ||
#endif | ||
|
||
JL_DLLEXPORT jl_module_t *jl_new_module(jl_sym_t *name) | ||
JL_DLLEXPORT jl_module_t *jl_new_module_(jl_sym_t *name, uint8_t using_core) | ||
{ | ||
jl_ptls_t ptls = jl_get_ptls_states(); | ||
const jl_uuid_t uuid_zero = {0, 0}; | ||
|
@@ -36,7 +36,7 @@ JL_DLLEXPORT jl_module_t *jl_new_module(jl_sym_t *name) | |
htable_new(&m->bindings, 0); | ||
arraylist_new(&m->usings, 0); | ||
JL_GC_PUSH1(&m); | ||
if (jl_core_module) { | ||
if (jl_core_module && using_core) { | ||
jl_module_using(m, jl_core_module); | ||
} | ||
// export own name, so "using Foo" makes "Foo" itself visible | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might want to omit this as well, just so you can get a truly truly empty module. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Triage seconds this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And then I guess |
||
|
@@ -46,15 +46,20 @@ JL_DLLEXPORT jl_module_t *jl_new_module(jl_sym_t *name) | |
return m; | ||
} | ||
|
||
JL_DLLEXPORT jl_module_t *jl_new_module(jl_sym_t *name) | ||
{ | ||
return jl_new_module_(name, 1); | ||
} | ||
|
||
uint32_t jl_module_next_counter(jl_module_t *m) | ||
{ | ||
return jl_atomic_fetch_add(&m->counter, 1); | ||
} | ||
|
||
JL_DLLEXPORT jl_value_t *jl_f_new_module(jl_sym_t *name, uint8_t std_imports) | ||
JL_DLLEXPORT jl_value_t *jl_f_new_module(jl_sym_t *name, uint8_t std_imports, uint8_t using_core) | ||
{ | ||
// TODO: should we prohibit this during incremental compilation? | ||
jl_module_t *m = jl_new_module(name); | ||
jl_module_t *m = jl_new_module_(name, using_core); | ||
JL_GC_PUSH1(&m); | ||
m->parent = jl_main_module; // TODO: this is a lie | ||
jl_gc_wb(m, m->parent); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to put this into
julia.h
as well?