mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-30 23:10:21 +02:00
refactor to resolve_variable
* libguile/vm.c (resolve_variable): Slight refactor.
This commit is contained in:
parent
a0ec1ca116
commit
b782ed0137
1 changed files with 13 additions and 16 deletions
|
@ -600,30 +600,27 @@ static SCM boot_continuation;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static SCM
|
static SCM
|
||||||
resolve_variable (SCM what, SCM program_module)
|
resolve_variable (SCM what, SCM module)
|
||||||
{
|
{
|
||||||
if (SCM_LIKELY (scm_is_symbol (what)))
|
if (SCM_LIKELY (scm_is_symbol (what)))
|
||||||
{
|
{
|
||||||
if (scm_is_true (program_module))
|
if (scm_is_true (module))
|
||||||
return scm_module_lookup (program_module, what);
|
return scm_module_lookup (module, what);
|
||||||
else
|
else
|
||||||
return scm_module_lookup (scm_the_root_module (), what);
|
return scm_module_lookup (scm_the_root_module (), what);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SCM mod;
|
SCM modname, sym, public;
|
||||||
/* compilation of @ or @@
|
|
||||||
`what' is a three-element list: (MODNAME SYM INTERFACE?)
|
modname = SCM_CAR (what);
|
||||||
INTERFACE? is #t if we compiled @ or #f if we compiled @@
|
sym = SCM_CADR (what);
|
||||||
*/
|
public = SCM_CADDR (what);
|
||||||
mod = scm_resolve_module (SCM_CAR (what));
|
|
||||||
if (scm_is_true (SCM_CADDR (what)))
|
if (scm_is_true (public))
|
||||||
mod = scm_module_public_interface (mod);
|
return scm_public_lookup (modname, sym);
|
||||||
if (scm_is_false (mod))
|
else
|
||||||
scm_misc_error (NULL, "no such module: ~S",
|
return scm_private_lookup (modname, sym);
|
||||||
scm_list_1 (SCM_CAR (what)));
|
|
||||||
/* might longjmp */
|
|
||||||
return scm_module_lookup (mod, SCM_CADR (what));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue