/* Compiler: ECL 26.3.27                                                      */
/* Source: /build/ecl/src/ecl-26.3.27/src/lsp/module.lsp                      */
#include <ecl/ecl-cmp.h>
#include "lsp/module.eclh"
/* function definition for PROVIDE                                            */
/* optimize speed 1, debug 1, space 1, safety 2                               */
cl_object cl_provide(cl_object v1module_name)
{
 cl_object T0, T1, T2, T3;
 cl_object env0 = ECL_NIL;
 const cl_env_ptr cl_env_copy = ecl_process_env();
 cl_object value0;
 ecl_cs_check(cl_env_copy,value0);
L1:;
 T0 = cl_string(v1module_name);
 T1 = ecl_cmp_symbol_value(cl_env_copy,ECL_SYM("*MODULES*",43));
 T2 = (ECL_SYM("STRING=",825)->symbol.gfdef);
 T3 = cl_adjoin(4, T0, T1, ECL_SYM("TEST",1353), T2);
 ecl_cmp_setq(cl_env_copy,ECL_SYM("*MODULES*",43),T3);
 value0 = ECL_T;
 cl_env_copy->nvalues = 1;
 return value0;
}
/* function definition for REQUIRE-ERROR                                      */
/* optimize speed 1, debug 1, space 1, safety 2                               */
static cl_object L755require_error(cl_narg narg, cl_object v1control, ...)
{
 cl_object env0 = ECL_NIL;
 const cl_env_ptr cl_env_copy = ecl_process_env();
 cl_object value0;
 ecl_cs_check(cl_env_copy,value0);
 if (ecl_unlikely(narg<1)) FEwrong_num_arguments(VV[1]);
 {
  cl_object v2arguments;
  ecl_va_list args; ecl_va_start(args,v1control,narg,1);
  v2arguments = cl_grab_rest_args(args);
  ecl_va_end(args);
  value0 = cl_error(3, VV[2], v1control, v2arguments);
  return value0;
 }
}
/* function definition for REQUIRE                                            */
/* optimize speed 1, debug 1, space 1, safety 2                               */
cl_object cl_require(cl_narg narg, cl_object v1module_name, ...)
{
 cl_object T0;
 cl_object env0 = ECL_NIL;
 cl_object CLV0;
 const cl_env_ptr cl_env_copy = ecl_process_env();
 cl_object value0;
 ecl_cs_check(cl_env_copy,value0);
 if (ecl_unlikely(narg<1)) FEwrong_num_arguments(ECL_SYM("REQUIRE",721));
 if (ecl_unlikely(narg>2)) FEwrong_num_arguments(ECL_SYM("REQUIRE",721));
 {
  cl_object v2pathnames;
  va_list args; va_start(args,v1module_name);
  env0 = ECL_NIL;
  CLV0 = env0 = CONS(v1module_name,env0);         /*  MODULE-NAME             */
  {
   int i = 1;
   if (i >= narg) {
    v2pathnames = ECL_NIL;
   } else {
    i++;
    v2pathnames = va_arg(args,cl_object);
   }
  }
  va_end(args);
  {
   cl_object v3name;
   v3name = cl_string(ECL_CONS_CAR(CLV0));
   {
    cl_object v4;
    cl_object v5;
    v4 = ecl_cmp_symbol_value(cl_env_copy,VV[0]);
    v5 = (ECL_SYM("STRING=",825)->symbol.gfdef);
    {
     cl_object v6;
     v6 = v4;
     goto L10;
L9:;
     {
      cl_object v7;
      cl_object v8;
      {
       cl_object v9;
       v9 = v6;
       if (ecl_unlikely(ECL_ATOM(v9))) FEtype_error_cons(v9);
       value0 = ECL_NIL;
       cl_env_copy->nvalues = 0;
       v7 = v9;
      }
      v8 = ECL_CONS_CAR(v7);
      if (Null(cl_stringE(2, v3name, v8))){
       goto L12;
      }
      if (Null(v7)){
       goto L3;
      }
      goto L4;
     }
L12:;
     v6 = ECL_CONS_CDR(v6);
L10:;
     if (v6==ECL_NIL) {
      goto L20;
     }
     goto L9;
L20:;
     goto L3;
    }
   }
L4:;
   L755require_error(3, VV[7], ECL_SYM("REQUIRE",721), ECL_CONS_CAR(CLV0));
L3:;
   {
    cl_object v4;
    cl_object v5;
    v4 = cl_copy_list(ecl_cmp_symbol_value(cl_env_copy,ECL_SYM("*MODULES*",43)));
    v5 = CONS(v3name,ecl_cmp_symbol_value(cl_env_copy,VV[0]));
    ecl_bds_bind(cl_env_copy,VV[0],v5);           /*  *REQUIRING*             */
    {
     cl_object v6;
     cl_object v7;
     v6 = ecl_cmp_symbol_value(cl_env_copy,ECL_SYM("*MODULES*",43));
     v7 = (ECL_SYM("STRING=",825)->symbol.gfdef);
     {
      cl_object v8;
      v8 = v6;
      goto L31;
L30:;
      {
       cl_object v9;
       cl_object v10;
       {
        cl_object v11;
        v11 = v8;
        if (ecl_unlikely(ECL_ATOM(v11))) FEtype_error_cons(v11);
        value0 = ECL_NIL;
        cl_env_copy->nvalues = 0;
        v9 = v11;
       }
       v10 = ECL_CONS_CAR(v9);
       if (Null(cl_stringE(2, v3name, v10))){
        goto L33;
       }
       if (v9!=ECL_NIL) {
        goto L24;
       }
       goto L25;
      }
L33:;
      v8 = ECL_CONS_CDR(v8);
L31:;
      if (v8==ECL_NIL) {
       goto L41;
      }
      goto L30;
L41:;
     }
    }
L25:;
    if (Null(v2pathnames)){
     goto L43;
    }
    if (ECL_LISTP(v2pathnames)) {
     goto L45;
    }
    v2pathnames = ecl_list1(v2pathnames);
L45:;
    {
     cl_object v6;
     v6 = v2pathnames;
     goto L51;
L50:;
     {
      cl_object v7ele;
      v7ele = ecl_car(v6);
      cl_load(1, v7ele);
     }
     v6 = ecl_cdr(v6);
L51:;
     if (Null(v6)){
      goto L58;
     }
     goto L50;
L58:;
     goto L24;
    }
L43:;
    {
     cl_object v7;
     v7 = ecl_make_cclosure_va((cl_objectfn)LC756__lambda38,env0,Cblock,1);
     T0 = v7;
    }
    if (cl_some(2, T0, ecl_cmp_symbol_value(cl_env_copy,ECL_SYM("*MODULE-PROVIDER-FUNCTIONS*",44)))!=ECL_NIL) {
     goto L24;
    }
    L755require_error(3, VV[9], ECL_SYM("REQUIRE",721), ECL_CONS_CAR(CLV0));
L24:;
    value0 = cl_set_difference(2, ecl_cmp_symbol_value(cl_env_copy,ECL_SYM("*MODULES*",43)), v4);
    ecl_bds_unwind1(cl_env_copy);
    return value0;
   }
  }
 }
}
/* local function LAMBDA41                                                    */
/* optimize speed 1, debug 1, space 1, safety 2                               */
static cl_object LC757__lambda41(cl_object v1module)
{
 cl_object T0;
 cl_object env0 = ECL_NIL;
 const cl_env_ptr cl_env_copy = ecl_process_env();
 cl_object value0;
 ecl_cs_check(cl_env_copy,value0);
L1:;
 {
  cl_object v2module;
  v2module = cl_string(v1module);
  {
   cl_object v3path;
   v3path = cl_make_pathname(4, ECL_SYM("NAME",1309), v2module, ECL_SYM("DEFAULTS",1247), VV[11]);
   value0 = cl_load(3, v3path, ECL_SYM("IF-DOES-NOT-EXIST",1277), ECL_NIL);
  }
  if (value0!=ECL_NIL) {
   goto L4;
  }
  {
   cl_object v3path;
   T0 = cl_string_downcase(1, v2module);
   v3path = cl_make_pathname(4, ECL_SYM("NAME",1309), T0, ECL_SYM("DEFAULTS",1247), VV[11]);
   value0 = cl_load(3, v3path, ECL_SYM("IF-DOES-NOT-EXIST",1277), ECL_NIL);
   return value0;
  }
L4:;
  cl_env_copy->nvalues = 1;
  return value0;
 }
}
static cl_object LC757__lambda41_va(cl_narg narg, cl_object v4module, ...)
{
 if (ecl_unlikely(narg!=1)) FEwrong_num_arguments(VV[10]);
 {
  return LC757__lambda41(v4module);
 }
}
/* closure LAMBDA38                                                           */
/* optimize speed 1, debug 1, space 1, safety 2                               */
static cl_object LC756__lambda38(cl_narg narg, cl_object v1p, ...)
{
 cl_object CLV0;
 const cl_env_ptr cl_env_copy = ecl_process_env();
 cl_object env0 = cl_env_copy->function->cclosure.env;
 cl_object value0;
 ecl_cs_check(cl_env_copy,value0);
 /* Scanning closure data ... */
 CLV0 = env0;                                     /*  MODULE-NAME             */
 { /* ... closure scanning finished */
 if (ecl_unlikely(narg!=1)) FEwrong_num_arguments(VV[8]);
 {
L1:;
  value0 = ecl_function_dispatch(cl_env_copy,v1p)(1, ECL_CONS_CAR(CLV0));
  return value0;
 }
 }
}
#include "lsp/module.data"
#ifdef __cplusplus
extern "C"
#endif

ECL_DLLEXPORT void _ecltwS0ObbvOHvl9_wC00M881(cl_object flag)
{
 const cl_env_ptr cl_env_copy = ecl_process_env();
 cl_object value0;
 cl_object *VVtemp;
 if (flag != OBJNULL){
 Cblock = flag;
 #ifndef ECL_DYNAMIC_VV
 flag->cblock.data = VV;
 #endif
 flag->cblock.data_size = VM;
 flag->cblock.temp_data_size = VMtemp;
 flag->cblock.data_text = compiler_data_text;
 flag->cblock.cfuns_size = compiler_cfuns_size;
 flag->cblock.cfuns = compiler_cfuns;
 flag->cblock.source = ecl_make_constant_base_string("SRC:LSP;MODULE.LSP.NEWEST",-1);
 return;}
 #ifdef ECL_DYNAMIC_VV
 VV = Cblock->cblock.data;
 #endif
 Cblock->cblock.data_text = (const cl_object *)"@EcLtAg:_ecltwS0ObbvOHvl9_wC00M881@";
 VVtemp = Cblock->cblock.temp_data;
 ECL_DEFINE_SETF_FUNCTIONS
 {
  cl_object T0, T1;
  cl_object volatile env0 = ECL_NIL;
/* MAKE-LOAD-FORMs                                                            */
/* TOP-LEVEL-FORMs                                                            */
  si_select_package(VVtemp[0]);
  si_Xmake_special(ECL_SYM("*MODULES*",43));
  T0 = ECL_NIL;
  ecl_cmp_setq(cl_env_copy,ECL_SYM("*MODULES*",43),T0);
  si_Xmake_special(ECL_SYM("*MODULE-PROVIDER-FUNCTIONS*",44));
  T0 = ECL_NIL;
  ecl_cmp_setq(cl_env_copy,ECL_SYM("*MODULE-PROVIDER-FUNCTIONS*",44),T0);
  (void)0; /* No entry created for PROVIDE */
  si_Xmake_special(VV[0]);
  T0 = ECL_NIL;
  ecl_cmp_setq(cl_env_copy,VV[0],T0);
  ecl_cmp_defun(VV[12]);                          /*  REQUIRE-ERROR           */
  (void)0; /* No entry created for REQUIRE */
  {
   cl_object volatile v1;
   v1 = ecl_make_cfun_va((cl_objectfn)LC757__lambda41_va,ECL_NIL,Cblock,1);
   T0 = v1;
  }
  T1 = cl_adjoin(2, T0, ecl_cmp_symbol_value(cl_env_copy,ECL_SYM("*MODULE-PROVIDER-FUNCTIONS*",44)));
  ecl_cmp_setq(cl_env_copy,ECL_SYM("*MODULE-PROVIDER-FUNCTIONS*",44),T1);
 }
}
