38 printf(
"quote:" ); hoge_print(arg);
49 if (n==2) env=argv[1];
else env=
NULL;
52 hoge_print_sub(argv[0]);
54 hoge_print_sub( env );
57 return(
eval2(ctx,argv[0],env));}
64 printf(
"PROGN:" ); hoge_print( arg );
66 return(
progn(ctx,arg));}
75 if( n >= 0 ) hoge_print_sub( argv[0] );
78 return((n>=1)?argv[0]:
NIL);}
84 {
register pointer a,*spsave=ctx->vsp,fun=argv[0];
85 register int i=1,
argc=n-2;
91 for( i = 0; i <
n; i++ )
92 hoge_print_sub( argv[i] );
97 if (fun->c.sym.spefunc==UNBOUND)
error(
E_UNDEF,argv[0]);}
98 while (i<n-1) ckpush(argv[i++]);
116 {
register pointer fun=argv[0];
119 printf(
"FUNCALL:" );
122 for( i = 0; i <
n; i++ )
123 hoge_print_sub( argv[i] );
139 printf(
"FUNCTION_CLOSURE:" );
143 if (issymbol(arg)) { funcname=arg; arg=
getfunc(ctx,arg);}
145 if (iscode(arg))
return(arg);
146 else if (ccar(arg)==LAMCLOSURE)
return(arg);
147 else if (ccar(arg)==LAMBDA) {
150 arg=
cons(ctx,funcname,arg);
151 return(
cons(ctx,LAMCLOSURE,arg));}
158 {
pointer mac,args,expander,*argp,result;
162 printf(
"MACEXPAND2:" ); hoge_print( argv[0] );
164 if (!islist(argv[0]))
return(argv[0]);
165 mac=ccar(argv[0]); args=ccdr(argv[0]);
166 if (issymbol(mac)) mac=
getfunc(ctx,mac);
170 #if (WORD_SIZE == 64) 175 #if (WORD_SIZE == 64) 188 pointer_update(expander->c.code.entry,mac->
c.
code.
entry);}
189 else if (carof(mac,
E_NOLIST)==MACRO) expander=
cons(ctx,LAMBDA,ccdr(mac));
190 else return(argv[0]);
193 while (islist(args)) { vpush(ccar(args)); args=ccdr(args); noarg++;}
213 for( i = 0; i <
n; i++ )
214 hoge_print_sub( argv[i] );
218 while (islist(argv[1])) {
237 register int rcount=0,i;
244 for( i = 0; i <
n; i++ )
245 hoge_print_sub( argv[i] );
249 while (islist(argv[1])) {
272 register int i,rcount=0;
278 for( i = 0; i <
n; i++ )
279 hoge_print_sub( argv[i] );
283 while (islist(argv[1])) {
310 printf(
"SETQ:" ); hoge_print( arg );
312 while (iscons(arg)) {
313 var=ccar(arg); arg=ccdr(arg);
316 val=
eval(ctx,ccar(arg)); arg=ccdr(arg);
317 if (issymbol(var))
setval(ctx,var,val);
318 else if (islist(var) && issymbol(ccdr(var)) && ccdr(var)!=
NIL) {
334 if (!iscons(rest))
return(
NIL);
336 printf(
"IF:" ); hoge_print( arg );
339 if (
eval(ctx,ccar(arg))!=
NIL)
return(
eval(ctx,ccar(rest)));
342 if (iscons(rest))
return(
eval(ctx,ccar(rest)));
343 else return(
NIL); } }
355 for( i = 0; i <
n; i++ )
356 hoge_print_sub( argv[i] );
360 while (n>1) form=
cons(ctx,argv[--n],form);
361 form=
cons(ctx,QPROGN,form);
363 return(
cons(ctx,QIF,form));}
375 printf(
"WHILE:" ); hoge_print(arg);
377 if (!islist(arg))
return(
NIL);
378 cond=ccar(arg); body=ccdr(arg);
381 if ((result=(
pointer)eussetjmp(whilejmp))==0) {
393 {
register pointer clause,cond;
396 printf(
"COND:" ); hoge_print(arg);
398 while (islist(arg)) {
402 cond=
eval(ctx,ccar(clause));
403 if (cond!=
NIL)
if (islist(ccdr(clause)))
return(
progn(ctx,ccdr(clause)));
411 {
pointer vlist,vlistsave,var,
init,
body,result,decl,*spsave=ctx->vsp,*vinits;
412 register struct bindframe *env, *bfsave=ctx->bindfp, *declenv;
415 #if defined(PARLET_DEBUG) || defined(DEBUG_COUNT) 416 static int count = 0;
421 #if defined(SPEC_DEBUG) || defined(PARLET_DEBUG) 422 printf(
"PARLET:%d",count ); hoge_print(args);
430 while (islist(body)) {
432 if (!islist(decl) || (ccar(decl)!=
QDECLARE))
break;
433 env=
declare(ctx,ccdr(decl),env);
440 while (islist(vlist)) {
441 var=ccar(vlist); vlist=ccdr(vlist);
443 init=ccdr(var); var=ccar(var);
444 if (islist(init)) init=
eval(ctx,ccar(init));
447 vpush(init); vcount++;}
452 var=ccar(vlist); vlist=ccdr(vlist);
453 if (islist(var)) var=ccar(var);
454 env=
vbind(ctx,var,vinits[i++],env,bfsave);}
456 result=
progn(ctx,body);
467 register struct bindframe *bf=ctx->bindfp, *env;
471 printf(
"SEQLET:" ); hoge_print(args);
480 while (islist(body)) {
482 if (!islist(decl) || (ccar(decl)!=
QDECLARE))
break;
483 env=
declare(ctx,ccdr(decl),env);
487 while (islist(vlist)) {
489 var=ccar(vlist); vlist=ccdr(vlist);
491 init=ccdr(var); var=ccar(var);
492 if (islist(init)) init=
eval(ctx,ccar(init));
495 env=
vbind(ctx,var,init,env,bf);
499 result=
progn(ctx,body);
515 printf(
"CATCH:" ); hoge_print(arg);
521 if ((val=(
pointer)eussetjmp(catchbuf))==0) val=
progn(ctx,body);
523 ctx->callfp=ctx->catchfp->cf;
524 ctx->bindfp=ctx->catchfp->bf;
525 ctx->fletfp=ctx->catchfp->ff;
526 ctx->vsp=(
pointer *)ctx->catchfp;
528 #ifdef __RETURN_BARRIER 529 check_return_barrier(ctx);
533 void throw(ctx,tag,result)
538 if (cfp->
label==tag) {
550 printf(
"THROW:" ); hoge_print(arg);
558 result=
eval(ctx,result);
559 throw(ctx,tag,result);
566 register struct fletframe *ffp=ctx->fletfp;
569 printf(
"FLET:" ); hoge_print(arg);
573 while (iscons(fns)) {
574 fn=ccar(fns); fns=ccdr(fns);
575 makeflet(ctx,ccar(fn),ccdr(fn),ffp,ctx->fletfp);}
576 result=
progn(ctx,ccdr(arg));
584 register struct fletframe *ffp=ctx->fletfp, *ffpp;
587 printf(
"LABELS:" ); hoge_print(arg);
591 while (iscons(fns)) {
592 fn=ccar(fns); fns=ccdr(fns);
593 makeflet(ctx,ccar(fn),ccdr(fn),ctx->fletfp,ctx->fletfp);}
594 fns=ccar(arg); ffpp=ctx->fletfp;
595 while (iscons(fns)) {
598 fns=ccdr(fns); ffpp=ffpp->lexlink;}
599 result=
progn(ctx,ccdr(arg));
611 for( i = 0; i <
n; i++ )
612 hoge_print_sub(argv[i] );
623 {
pointer form,val,env, *vspsave=ctx->vsp;
628 printf(
"EVALHOOK:" );
630 for( i = 0; i <
n; i++ )
631 hoge_print_sub(argv[i] );
635 if (n==3) env=argv[2];
else env=
NULL;
641 val=
eval2(ctx,form,env);
645 else return(
eval2(ctx,form,env));}
650 {
pointer name,result,*spsave=ctx->vsp;
655 printf(
"BLOCK:" ); hoge_print(arg);
662 if ((result=(
pointer)eussetjmp(blkjmp))==0) result=
progn(ctx,arg);
676 printf(
"RETFROM:" ); hoge_print(arg);
680 blkfp_old = ctx->blkfp;
681 while (ctx->blkfp!=
NULL)
682 if (ctx->blkfp->kind==BLOCKFRAME && ctx->blkfp->name==name) {
683 blkfp_new = ctx->blkfp;
684 ctx->blkfp = blkfp_old;
685 if (islist(arg)) result=
eval(ctx,ccar(arg));
else result=
NIL;
687 ctx->blkfp = blkfp_new;
689 euslongjmp(*ctx->blkfp->jbp,result);}
690 else ctx->blkfp=ctx->blkfp->lexklink;
698 if (n==1) result=argv[0];
701 printf(
"RETURN:" ); hoge_print(result);
714 printf(
"UNWINDPROTECT:" ); hoge_print(arg);
718 if (islist(arg)) cleanupform=ccdr(arg);
else cleanupform=
NIL;
719 cleaner=
cons(ctx,
NIL,cleanupform);
723 cleaner=
cons(ctx,LAMCLOSURE,cleaner);
726 vpush(ctx->protfp); vpush(cleaner);
729 result=
eval(ctx,protform);
731 ctx->protfp=oldprotfp;
732 progn(ctx,cleanupform);
742 pointer *spsave=ctx->vsp, *tagspsave;
745 printf(
"TAGBODY:" ); hoge_print(arg);
750 if (!iscons(ccar(p))) golist=
cons(ctx,p,golist);
753 makeblock(ctx,TAGBODYFRAME,golist,&tagjmp,ctx->blkfp);
756 if ((p=(
pointer)eussetjmp(tagjmp))==0)
760 while (iscons(forms)) {
763 if (iscons(p))
eval(ctx,p);
764 forms=ccdr(forms);} }
765 else { forms=ccdr(p);
goto repeat;}
775 printf(
"GO:" ); hoge_print( arg );
777 tag=carof(arg,
"GO TAG?");
778 while (ctx->blkfp!=
NULL) {
779 if (ctx->blkfp->kind==TAGBODYFRAME &&
782 euslongjmp(*(ctx->blkfp->jbp),body);}
784 ctx->blkfp=ctx->blkfp->lexklink;}
792 printf(
"EVALWHEN:" ); hoge_print( arg );
795 while (islist(situation))
796 if (ccar(situation)==QEVAL)
return(
progn(ctx,forms));
797 else situation=ccdr(situation);
805 printf(
"THE:" ); hoge_print( arg );
811 result=
eval(ctx,form);
824 else return(result);} }
831 printf(
"AND:" ); hoge_print( arg );
833 while (islist(arg)) {
835 if ((r=
eval(ctx,ccar(arg)))==
NIL)
return(r);
844 printf(
"OR:" ); hoge_print( arg );
846 while (islist(arg)) {
848 if ((r=
eval(ctx,ccar(arg)))!=
NIL)
return(r);
859 printf(
"PROCLAIM:" );
861 for( i = 0; i <
n; i++ )
862 hoge_print_sub( argv[i] );}
871 while (islist(decl)) {
872 var=ccar(decl); decl=ccdr(decl);
877 fprintf(stderr,
"%s has already been declared as special\n",
884 ctx->specials->c.vec.v[vt]=curval;}
902 printf(
"ALLPACKAGES:\n" );
913 printf(
"FINDPACKAGE:" ); hoge_print( argv[0] );
916 if (pkg)
return(pkg);
else return(
NIL);}
926 printf(
"MAKEPACKAGE:" );
928 for( i = 0; i <
n; i++ )
929 hoge_print_sub( argv[i] );
933 if (n>1) nick=argv[1];
else nick=
NIL;
934 if (n>2) use=argv[2];
else use=
NIL;
935 pkg=
makepkg(ctx,name,nick,use);
945 if (isstring(x))
return(
rehash(x));
946 else if (issymbol(x))
return(
rehash(x->c.sym.pname));
947 else if (isint(x))
return(
intval(x));
950 else if (islist(x)) {
951 while (islist(x)) { h +=
sxhash(ccar(x)); x=ccdr(x);}}
952 else if (isvector(x)) {
954 switch( elmtypeof(x)) {
955 case ELM_BIT: s /= 8*
sizeof(
pointer);
break;
957 case ELM_BYTE: s /=
sizeof(
pointer);
break;
959 for (i=0; i<
s; i++) h +=
sxhash(x->c.vec.v[i]);
961 for (i=0; i<
s; i++) h += x->c.ivec.iv[i]; }
973 else if (n==2) m=ckintval(argv[1]);
978 for( i = 0; i <
n; i++ )
979 hoge_print_sub( argv[i] );
983 m=(
sxhash(argv[0]) & MAXPOSFIXNUM) % m;
993 {
register pointer sy=argv[0],val;
999 printf(
"SYMVALUE:" );
1001 for( i =0; i <
n; i++ )
1002 hoge_print_sub(argv[i] );
1012 {
register pointer sy=argv[0],val;
1026 printf(
"SETFUNC:" ); hoge_print_sub(argv[0]); hoge_print(argv[1]);
1038 printf(
"SYMFUNC:" ); hoge_print( argv[0] );
1040 return(
getfunc(ctx,argv[0]));}
1049 printf(
"MAKEUNBOUND:" ); hoge_print( argv[0] );
1051 pointer_update(argv[0]->c.sym.speval,UNBOUND);
1061 else if (vt==V_VARIABLE || vt==V_GLOBAL) {pointer_update(speval(var),val);}
1064 pointer_update(ctx->specials->c.vec.v[x],val);} }
1072 var=argv[0]; val=argv[1];
1075 printf(
"SETSPECIAL:" ); hoge_print_sub(var); hoge_print(val);
1086 printf(
"DEFUN:" ); hoge_print( arg );
1090 if (issymbol(funcname)) {pointer_update(funcname->
c.
sym.
spefunc,
cons(ctx,LAMBDA,arg));}
1093 (isstring(ccar(ccdr(arg))))?(ccar(ccdr(arg))):(ccar(arg)),
1094 K_FUNCTION_DOCUMENTATION);
1102 printf(
"DEFMACRO:" ); hoge_print(arg);
1106 if (issymbol(macname)) {pointer_update(macname->
c.
sym.
spefunc,
cons(ctx,MACRO,arg));}
1124 printf(
"FINDSYMBOL:" );
1126 for( i = 0; i <
n; i++ )
1127 hoge_print_sub( argv[i] );
1133 if (sym)
return(sym);
1140 {
register pointer str,sym,pkg;
1144 if (n>=2) pkg=
findpkg(argv[1]);
1148 printf(
"INTERN:" );
1150 for( i = 0; i <
n; i++ )
1151 hoge_print_sub( argv[i] );
1169 printf(
"GENSYM:" );
1171 for( i =0 ; i<
n; i++ )
1172 hoge_print_sub(argv[i] );
1179 if (isstring(argv[0])) {
1192 {
register pointer p,attr=argv[1];
1196 printf(
"GETPROP:" );
1198 for( i = 0; i <
n; i++ )
1199 hoge_print_sub(argv[i] );
1205 if (ccar(ccar(p))==attr)
return(ccdr(ccar(p)));
1207 if (n==3)
return(argv[2]);
else return(
NIL);}
1217 printf(
"EXPORT:" );
1219 for( i =0; i<
n; i++ )
1220 hoge_print_sub(argv[i]);
1225 if (n==2) pkg =
findpkg(argv[1]);
1228 if (issymbol(sym))
export(sym,pkg);
1229 else if (iscons(sym))
1230 while (iscons(sym)) {
1231 export(ccar(sym),pkg); sym=ccdr(sym);}
1237 register
pointer sym,val,attr;
1241 if (ccar(ccar(p))==attr) { pointer_update(ccdr(ccar(p)),val);
return(val);}
1244 p=
cons(ctx,attr,val);
1245 pointer_update(sym->c.sym.plist,
cons(ctx,p,sym->
c.
sym.
plist));
1256 printf(
"PUTPROP:" );
1258 for( i =0 ; i <
n; i++ )
1259 hoge_print_sub(argv[i]);
1263 return(
putprop(ctx,argv[0],argv[1],argv[2]));}
1273 evaldebug = ( argv[0] !=
NIL );
1275 return evaldebug ?
T :
NIL;
static char buf[CHAR_SIZE]
pointer K_FUNCTION_DOCUMENTATION
pointer makesymbol(context *, char *, int, pointer)
pointer DEFMACRO(context *ctx, pointer arg)
pointer intern(context *, char *, int, pointer)
pointer RETFROM(context *ctx, pointer arg)
pointer SETSPECIAL(context *ctx, int n, pointer *argv)
struct blockframe * makeblock(context *, pointer, pointer, jmp_buf *, struct blockframe *)
pointer EVAL(context *ctx, int n, argv)
pointer GENSYM(context *ctx, int n, argv)
pointer PROGN(context *ctx, pointer arg)
pointer cons(context *, pointer, pointer)
pointer makecode(pointer, pointer(*)(), pointer)
pointer DEFUN(context *ctx, pointer arg)
pointer FLET(context *ctx, pointer arg)
pointer SYMBNDVALUE(context *ctx, int n, argv)
pointer IF(context *ctx, pointer arg)
pointer putprop(context *ctx, pointer sym, pointer val, pointer attr)
void bindspecial(context *, pointer, pointer)
pointer makepkg(context *, pointer, pointer, pointer)
pointer defunpkg(context *, char *, pointer, pointer(*)(), pointer)
eusinteger_t hide_ptr(pointer p)
pointer SYMFUNC(context *ctx, int n, pointer *argv)
defun("ADR_TO_STRING", mod, ADR_TO_STRING)
pointer NCONC(context *, int, pointer *)
pointer ufuncall(context *, pointer, pointer, pointer, struct bindframe *, int)
pointer progn(context *, pointer)
pointer BLOCK(context *ctx, pointer arg)
pointer PARLET(context *ctx, pointer args)
pointer PUTPROP(context *ctx, int n, argv)
pointer SXHASH(context *ctx, int n, argv)
struct blockframe * dynklink
pointer MACEXPAND2(context *ctx, int n, argv)
pointer FUNCTION_CLOSURE(context *ctx, pointer arg)
pointer TAGBODY(context *ctx, pointer arg)
pointer INTERN(context *ctx, int n, argv)
void unbindspecial(context *, struct specialbindframe *)
pointer * ovafptr(pointer, pointer)
void specials(context *ctx, pointer mod)
pointer export(pointer, pointer)
pointer setval(context *, pointer, pointer)
pointer SETQ(context *ctx, pointer arg)
struct fletframe * makeflet(context *, pointer, pointer, struct fletframe *, struct fletframe *)
pointer THROW(context *ctx, pointer arg)
pointer SYMVALUE(context *ctx, int n, argv)
pointer LABELS(context *ctx, pointer arg)
pointer EXPORT(context *ctx, int n, argv)
pointer assq(pointer, pointer)
pointer EVALHOOK(context *ctx, int n, pointer *argv)
pointer getfunc(context *, pointer)
pointer PROCLAIM(context *ctx, int n, argv)
pointer THE(context *ctx, pointer arg)
struct bindframe * vbind(context *, pointer, pointer, struct bindframe *, struct bindframe *)
pointer GO(context *ctx, pointer arg)
void set_special(context *ctx, pointer var, pointer val)
pointer error(enum errorcode ec,...) pointer error(va_alist) va_dcl
struct catchframe * nextcatch
pointer MAKUNBOUND(context *ctx, int n, pointer *argv)
pointer WHILE(context *ctx, pointer arg)
pointer gensym(context *ctx)
pointer PROG1(context *ctx, int n, pointer *argv)
pointer OR(context *ctx, pointer arg)
pointer stacknlist(context *, int)
struct bindframe * declare()
struct catchframe * catchfp
void unwind(context *ctx, pointer *p)
pointer FINDPACKAGE(context *ctx, int n, pointer *argv)
eusinteger_t sxhash(pointer x)
pointer APPLY(context *ctx, int n, argv)
pointer FINDSYMBOL(context *ctx, int n, argv)
pointer COND(context *ctx, pointer arg)
pointer EVALDEBUG(context *ctx, int n, argv)
pointer EVALWHEN(context *ctx, pointer arg)
pointer makestring(char *, int)
pointer quote(context *ctx, pointer arg)
pointer RETURN(context *ctx, int n, argv)
void setfunc(pointer, pointer)
pointer MAPCAR(context *ctx, int n, pointer *argv)
pointer SEQLET(context *ctx, pointer args)
pointer MAKEPACKAGE(context *ctx, int n, pointer *argv)
pointer AND(context *ctx, pointer arg)
pointer MAPC(context *ctx, int n, pointer *argv)
pointer ALLPACKAGES(context *ctx, int n, argv)
pointer CATCH(context *ctx, pointer arg)
pointer MAPCAN(context *ctx, int n, pointer *argv)
void mkcatchframe(context *, pointer, jmp_buf *)
pointer SETFUNC(context *ctx, int n, pointer *argv)
pointer eval(context *, pointer)
pointer RESET(context *ctx, int n, pointer *argv)
pointer UNWINDPROTECT(context *ctx, pointer arg)
pointer defmacro(context *, char *, pointer, pointer(*)())
pointer eval2(context *, pointer, pointer)
pointer FUNCALL(context *ctx, int n, argv)
pointer DECLARE(pointer arg)
pointer WHEN(context *ctx, int n, pointer *argv)
pointer GETPROP(context *ctx, int n, argv)
pointer defspecial(context *, char *, pointer, pointer(*)())