WIP: module
This commit is contained in:
parent
0fffcd0f91
commit
8d06a90396
86
src/module.c
86
src/module.c
|
@ -39,44 +39,44 @@ initial_module ()
|
||||||
return M0;
|
return M0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct scm *
|
// struct scm *
|
||||||
module_define_x (struct scm *module, struct scm *name, struct scm *value)
|
// module_define_x (struct scm *module, struct scm *name, struct scm *value)
|
||||||
{
|
// {
|
||||||
return hashq_set_x (M0, name, value);
|
// return hashq_set_x (M0, name, value);
|
||||||
}
|
// }
|
||||||
|
|
||||||
struct scm *
|
// struct scm *
|
||||||
scm_module_lookup_closure (struct scm *module)
|
// scm_module_lookup_closure (struct scm *module)
|
||||||
{
|
// {
|
||||||
if (module == cell_f)
|
// if (module == cell_f)
|
||||||
return cell_f;
|
// return cell_f;
|
||||||
else
|
// else
|
||||||
return struct_ref (module, MODULE_EVAL_CLOSURE);
|
// return struct_ref (module, MODULE_EVAL_CLOSURE);
|
||||||
}
|
// }
|
||||||
|
|
||||||
struct scm *
|
// struct scm *
|
||||||
scm_current_module_lookup_closure ()
|
// scm_current_module_lookup_closure ()
|
||||||
{
|
// {
|
||||||
if (scm_module_system_booted_p)
|
// if (scm_module_system_booted_p)
|
||||||
return scm_module_lookup_closure (scm_current_module ());
|
// return scm_module_lookup_closure (scm_current_module ());
|
||||||
return cell_f;
|
// return cell_f;
|
||||||
}
|
// }
|
||||||
|
|
||||||
struct scm *
|
// struct scm *
|
||||||
scm_eval_closure_lookup (struct scm *eclo, struct scm *name, struct scm *define_p)
|
// scm_eval_closure_lookup (struct scm *eclo, struct scm *name, struct scm *define_p)
|
||||||
{
|
// {
|
||||||
struct scm *module = eclo;
|
// struct scm *module = eclo;
|
||||||
if (define_p == cell_f)
|
// if (define_p == cell_f)
|
||||||
return module_variable (module, name);
|
// return module_variable (module, name);
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
#if 0
|
// #if 0
|
||||||
if (struct scm *_EVAL_CLOSURE_INTERFACE_P (eclo))
|
// if (struct scm *_EVAL_CLOSURE_INTERFACE_P (eclo))
|
||||||
return struct cell_f;
|
// return struct cell_f;
|
||||||
#endif
|
// #endif
|
||||||
return apply (module_make_local_var_x_var, cons (module, cons (name, cell_nil)));
|
// return apply (module_make_local_var_x_var, cons (module, cons (name, cell_nil)));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
struct scm *
|
struct scm *
|
||||||
module_variable (struct scm *module, struct scm *name)
|
module_variable (struct scm *module, struct scm *name)
|
||||||
|
@ -87,14 +87,14 @@ module_variable (struct scm *module, struct scm *name)
|
||||||
if (b != cell_f)
|
if (b != cell_f)
|
||||||
return b;
|
return b;
|
||||||
|
|
||||||
/* 2. Custom binder */
|
// /* 2. Custom binder */
|
||||||
struct scm *binder = struct_ref (module, MODULE_BINDER);
|
// struct scm *binder = struct_ref (module, MODULE_BINDER);
|
||||||
if (binder != cell_f)
|
// if (binder != cell_f)
|
||||||
{
|
// {
|
||||||
b = apply (binder->cdr, (cons (module, cons (name, cons (cell_f, cell_nil)))), cell_f);
|
// b = apply (binder->cdr, (cons (module, cons (name, cons (cell_f, cell_nil)))), cell_f);
|
||||||
if (b != cell_f)
|
// if (b != cell_f)
|
||||||
return b;
|
// return b;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* 3. Search the use list */
|
/* 3. Search the use list */
|
||||||
struct scm *uses = struct_ref (module, MODULE_USES);
|
struct scm *uses = struct_ref (module, MODULE_USES);
|
||||||
|
|
Loading…
Reference in New Issue