2003-08-19 15:19:38 -04:00
|
|
|
#include "kernel.h"
|
|
|
|
|
|
|
|
Object V_Autoload_Notifyp;
|
|
|
|
|
2003-08-19 15:24:23 -04:00
|
|
|
void Init_Auto (void) {
|
2003-08-19 15:19:38 -04:00
|
|
|
Define_Variable (&V_Autoload_Notifyp, "autoload-notify?", True);
|
|
|
|
}
|
|
|
|
|
2003-08-19 15:24:23 -04:00
|
|
|
Object P_Autoload (Object sym, Object files) {
|
2003-08-19 15:19:38 -04:00
|
|
|
Object al, ret;
|
|
|
|
GC_Node3;
|
|
|
|
|
|
|
|
al = Null;
|
|
|
|
Check_Type (sym, T_Symbol);
|
|
|
|
Check_Loadarg (files);
|
|
|
|
GC_Link3 (al, sym, files);
|
|
|
|
al = Alloc_Object (sizeof (struct S_Autoload), T_Autoload, 0);
|
|
|
|
AUTOLOAD(al)->files = files;
|
|
|
|
AUTOLOAD(al)->env = The_Environment;
|
|
|
|
al = Cons (al, Null);
|
|
|
|
al = Cons (sym, al);
|
|
|
|
ret = P_Define (al);
|
|
|
|
GC_Unlink;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2003-08-19 15:24:23 -04:00
|
|
|
Object Do_Autoload (Object sym, Object al) {
|
2003-08-19 15:19:38 -04:00
|
|
|
Object val, a[1];
|
|
|
|
GC_Node;
|
|
|
|
|
|
|
|
if (Var_Is_True (V_Autoload_Notifyp)) {
|
|
|
|
a[0] = AUTOLOAD(al)->files;
|
|
|
|
Format (Standard_Output_Port, "[Autoloading ~a]~%", 18, 1, a);
|
|
|
|
}
|
|
|
|
GC_Link (sym);
|
|
|
|
(void)General_Load (AUTOLOAD(al)->files, AUTOLOAD(al)->env);
|
|
|
|
GC_Unlink;
|
|
|
|
val = SYMBOL(sym)->value;
|
|
|
|
if (TYPE(val) == T_Autoload)
|
|
|
|
Primitive_Error ("autoloading failed to define ~s", sym);
|
|
|
|
return val;
|
|
|
|
}
|