COMMENT This file sets up necessary entry points for autoloading modules
      in Reduce. It uses a modified version of the Defautoload function
      of Eric Benson;

SYMBOLIC MACRO PROCEDURE DEFAUTOLOAD U;
% (DEFAUTOLOAD name), (DEFAUTOLOAD name loadname),
% (DEFAUTOLOAD name loadname fntype), or
% (DEFAUTOLOAD name loadname fntype numargs)
% Default is 1 Arg EXPR in module of same name;
  BEGIN SCALAR NAME, NUMARGS, LOADNAME, FNTYPE;
    U := CDR U;
    NAME := CAR U;
    U := CDR U;
    IF U THEN <<LOADNAME := CAR U; U :=CDR U>> ELSE LOADNAME := NAME;
    IF EQCAR(NAME, 'QUOTE) THEN NAME := CADR NAME;
    IF ATOM LOADNAME THEN LOADNAME := LIST LOADNAME
     ELSE IF CAR LOADNAME EQ 'QUOTE THEN LOADNAME := CADR LOADNAME;
    FOR EACH J IN LOADNAME
                   COLLECT IF IDP J THEN LIST('RED3!:,(J . 'FAP)) ELSE J;
    IF U THEN <<FNTYPE := CAR U; U := CDR U>> ELSE FNTYPE := 'EXPR;
    IF U THEN NUMARGS := CAR U ELSE NUMARGS := 1;
    NUMARGS := IF NUMARGS=0 THEN NIL
		ELSE IF NUMARGS=1 THEN '(X1)
		ELSE IF NUMARGS=2 THEN '(X1 X2)
		ELSE IF NUMARGS=3 THEN '(X1 X2 X3)
		ELSE IF NUMARGS=4 THEN '(X1 X2 X3 X4)
		ELSE ERROR(99,LIST(NUMARGS,"too large in DEFAUTOLOAD"));
    RETURN
       LIST('PUTD,
	    MKQUOTE NAME,
	    MKQUOTE FNTYPE,
	    MKQUOTE LIST('LAMBDA, NUMARGS,
			 'PROGN .
			   ACONC(FOR EACH J IN LOADNAME
				  COLLECT LIST('LOAD!-MODULE,MKQUOTE J),
				 LIST('APPLY,
				      MKQUOTE NAME,
				      'LIST . NUMARGS))))
  END;


COMMENT Actual Entry Point Definitions;

%input editor entry points;

DEFAUTOLOAD CEDIT;

DEFAUTOLOAD(DISPLAY,CEDIT);

PUT('DISPLAY,'STAT,'RLIS);

DEFAUTOLOAD(EDITDEF,CEDIT);

PUT('EDITDEF,'STAT,'RLIS);

DEFAUTOLOAD(EDITDEF1,CEDIT);


%Compiler and LAP entry points;

%DEFAUTOLOAD(COMPD,'(LAP COMPLR CMACRO),EXPR,3);

%DEFAUTOLOAD(COMPILE,'(LAP COMPLR CMACRO));

DEFAUTOLOAD(LAP,'(LAP COMPILER CMACRO));


%Cross-reference module entry points;

PUT('CREF ,'SIMPFG ,'((T (CREFON)) (NIL (CREFOFF))));

DEFAUTOLOAD(CREFON,'(RCREF REDIO),EXPR,0);


%Factorizer module entry points;

REMPROP('FACTOR,'STAT);

DEFAUTOLOAD(EZGCDF,FACTOR,EXPR,2);

DEFAUTOLOAD(FACTORF,FACTOR);

DEFAUTOLOAD(SIMPFACTORIZE,FACTOR);

PUT('FACTORIZE,'SIMPFN,'SIMPFACTORIZE);

DEFAUTOLOAD(SIMPNPRIMITIVE,FACTOR);

PUT('NPRIMITIVE,'SIMPFN,'SIMPNPRIMITIVE);

DEFAUTOLOAD(SIMPRESULTANT,FACTOR);

PUT('RESULTANT,'SIMPFN,'SIMPRESULTANT);

PUT('FACTOR,'STAT,'RLIS);


%FASL module entry points;

REMPROP('FASLOUT,'STAT);

DEFAUTOLOAD(FASLOUT,'(LAP COMPLR CMACRO FAP));

PUT('FASLOUT,'STAT,'RLIS);


%Help module entry points (not yet available);

%REMFLAG('(HELP),'GO);

%REMPROP('HELP,'STAT);

%DEFAUTOLOAD HELP;

%FLAG('(HELP),'GO);

%PUT('HELP,'STAT,'RLIS);


%Part module entry points;

DEFAUTOLOAD(ARGLENGTH,PART);

FLAG('(ARGLENGTH),'OPFN);

DEFAUTOLOAD(SIMPPART,PART);

PUT('PART,'SIMPFN,'SIMPPART);

DEFAUTOLOAD(SIMPSETPART,PART);

PUT('SETPART!*,'SIMPFN,'SIMPSETPART);

PUT('PART,'SETQFN,'SETPART!*);


%Prettyprint module entry point;

DEFAUTOLOAD(PRETTYPRINT,PRETTY);


%Matrix module entry points;

DEFAUTOLOAD(DETQ,MATR);

DEFAUTOLOAD(LETMTR,MATR,EXPR,3);

DEFAUTOLOAD(MAPC2,MATR,EXPR,2);    %used by SOLVE;

DEFAUTOLOAD(MATSM!*,MATR);

DEFAUTOLOAD(SIMPDET,MATR);

PUT('DET,'SIMPFN,'SIMPDET);

DEFAUTOLOAD(SIMPTRACE,MATR);

PUT('TRACE,'SIMPFN,'SIMPTRACE);


%META module entry point (not yet available);

%DEFAUTOLOAD META;


%Rprint module entry point;

DEFAUTOLOAD RPRINT;


%SOLVE module entry point;

DEFAUTOLOAD(SIMPSOLVE,'(MATR SOLVE));

PUT('SOLVE,'SIMPFN,'SIMPSOLVE);


%High energy physics module entry points;

REMPROP('INDEX,'STAT); REMPROP('MASS,'STAT);

REMPROP('MSHELL,'STAT); REMPROP('VECDIM,'STAT);

REMPROP('VECTOR,'STAT);

DEFAUTOLOAD(INDEX,HEPHYS);

DEFAUTOLOAD(MASS,HEPHYS);

DEFAUTOLOAD(MSHELL,HEPHYS);

DEFAUTOLOAD(VECDIM,HEPHYS);

DEFAUTOLOAD(VECTOR,HEPHYS);

PUT('INDEX,'STAT,'RLIS);

PUT('MSHELL,'STAT,'RLIS);

PUT('MASS,'STAT,'RLIS);

PUT('VECDIM,'STAT,'RLIS);

PUT('VECTOR,'STAT,'RLIS);

FLAGOP NONCOM,NOSPUR;


%Integrator module entry point;

DEFAUTOLOAD(SIMPINT,INT);

PUT('INT,'SIMPFN,'SIMPINT);

PUT('BIGFLOAT,'MODULE!-NAME,'BFLOAT);


%Debug module entry points;

DEFAUTOLOAD(EMBFN,DEBUG,EXPR,3);

%DEFAUTOLOAD(SU2SL,TRANS);


% exec and system editor entry points;

REMFLAG('(EXEC PUSH),'GO);

IF SYSTEM!* NEQ 0 THEN

 <<REMPROP('CMD,'STAT);

   REMPROP('EDIT,'STAT);

   REMPROP('CREATE,'STAT);

   REMPROP('EXEC,'STAT);

   REMPROP('PUSH,'STAT);

   DEFAUTOLOAD(EXEC,EXEC,EXPR,0);

   DEFAUTOLOAD(PUSH,EXEC,EXPR,0);

   DEFAUTOLOAD(CREATE,'(EXEC EDIT),EXPR,0);

   DEFAUTOLOAD(EDIT1,'(EXEC EDIT),EXPR,2);

   DEFAUTOLOAD(CMD,'(EXEC EDIT),EXPR,0);

   DEFAUTOLOAD(EDITSTAT,'(EXEC EDIT),EXPR,0);

   DEFAUTOLOAD(PINSTAT,EXEC,EXPR,0);

   PUT('CMD,'STAT,'EDITSTAT);

   PUT('EXEC,'STAT,'PINSTAT);

   PUT('PUSH,'STAT,'PINSTAT);

   PUT('CREATE,'STAT,'PINSTAT);

   PUT('EDIT,'STAT,'EDITSTAT);

   FLAG('(EXEC PUSH CREATE),'IGNORE);

   FLAG('(CMD EDIT),'EVAL);

   %FLAG('(EXEC PUSH),'GO);
  >>;


END;
