29 if (isnum(argv[0]))
return(
NIL);
30 return(classof(argv[0]));}
38 return(isclass(argv[0])?
T:
NIL);}
50 if (k>=s && k<=
classtab[s].subcix)
return(
T);
else return(
NIL); }
57 register int objcix,klasscix;
59 obj=argv[0]; klass=argv[1];
67 if (objcix>=klasscix && objcix<=
classtab[klasscix].subcix)
return(
T);
92 register pointer meth,
class,doc;
94 register pointer selector,methods,classes,medoc,medoc2;
100 if (classes!=
NIL) classes=ccdr(classes);
101 putprop(ctx,selector,
cons(ctx,
class,classes),K_CLASS);
107 K_METHOD_DOCUMENTATION);
109 medoc2=
assq(
class,ccdr(medoc));
111 {pointer_update(medoc->
c.
cons.
cdr,
cons(ctx,
cons(ctx,
class,doc),ccdr(medoc)));}
112 else pointer_update(medoc2->
c.
cons.
cdr,doc); } }
115 else if (ccar(ccar(methods))==selector) {pointer_update(ccar(methods),meth);}
117 while(ccdr(methods)!=
NIL) {
118 methods=ccdr(methods);
119 if (ccar(ccar(methods))==selector) {
122 pointer_update(ccdr(methods),
cons(ctx,meth,
NIL)); }
126 for (j=0; j<MAXTHREAD; j++) {
128 for (i=0; i<MAXMETHCACHE; i++)
129 if (ctx->methcache[i].selector==selector)
130 pointer_update(ctx->methcache[i].selector,
NIL); }
147 {
register pointer class,selector,classsym,
body,doc;
150 class=speval(classsym);
153 while (islist(arg)) {
156 doc=ccdr(ccdr(body));
157 if (isstring(ccar(doc))) doc=ccar(doc);
else doc=
NIL;
158 addmethod(ctx,body,
class,doc); arg=ccdr(arg);}
171 if (s<0) {
ckarg(2); s=ckintval(argv[1]);}
183 else if (isclass(a)) {
205 register pointer sel,search, *curclass;
206 {
register pointer meths,klass=search;
212 mt= &ctx->methcache[h];
218 while (isclass(klass) || isvecclass(klass)) {
221 while (islist(meths))
222 if (ccar(ccar(meths))==sel) {
225 pointer_update(mt->
class,search);
227 pointer_update(mt->
method,ccar(meths));
229 *curclass = klass;
return(ccar(meths));}
230 else meths=ccdr(meths);
238 register int i=0,vcount=vecsize(forwards);
240 flist=forwards->
c.
vec.
v[i];
241 if (flist==
T ||
memq(selector,flist)!=
NIL) {
242 *component = obj->
c.
obj.
iv[i];
243 if (!isnum(*component)) {
244 meth=
findmethod(ctx,selector,classof(*component),classfound);
245 if (meth!=
NIL)
return(meth);}
255 register pointer *spsave=ctx->vsp, *altargv;
257 struct bindframe *bf,*bfsave=ctx->bindfp;
259 int sbcount=ctx->special_bind_count;
261 #if defined(DEBUG_COUNT) || defined(SEND_DEBUG) 262 static int count = 0;
268 printf(
"SEND:%d\n", count );
275 klass=classof(receiver);
276 meth=
findmethod(ctx,selector,klass, &curclass);
279 meth=
findforward(ctx,selector,klass,receiver, &component, &curclass);
280 if (meth!=
NIL) { argv[0]=component; receiver=component; argoffset=2;}
284 if (iscode(ccar(ccdr(meth)))) {
286 vpush(receiver); vpush(selector);
288 while (i<
n) ckpush(argv[i++]);
294 if (iscode(ccar(ccdr(meth)))) {
299 bf=
fastbind(ctx,classof(receiver)->c.cls.vars,receiver,
NULL);
306 result=
funlambda(ctx,ccar(meth),ccar(ccdr(meth)),ccdr(ccdr(meth)),
307 &argv[argoffset],bf,
n-argoffset);
319 {
register pointer receiver,klass,selector,meth,result;
320 register pointer *spsave=ctx->vsp,*altargv;
322 struct bindframe *bf,*bfsave=ctx->bindfp;
329 if (isnum(receiver))
return(argv[0]);
330 klass=classof(receiver);
331 meth=
findmethod(ctx,selector,klass, &curclass);
335 if (meth!=
NIL) { argv[1]=component; receiver=component; argoffset=3;}
336 else return(argv[0]); }
339 if (iscode(ccar(ccdr(meth)))) {
344 bf=
fastbind(ctx,classof(receiver)->c.cls.vars,receiver,
NULL);
351 result=
funlambda(ctx,ccar(meth),ccar(ccdr(meth)),ccdr(ccdr(meth)),
352 &argv[argoffset],bf,
n-argoffset);
368 {
pointer receiver,search,selector,meth,form,result,*spsave, curclass;
369 struct bindframe *bf,*bfsave=ctx->bindfp;
373 receiver=argv[0]; search=argv[1]; selector=argv[2];
374 if (issymbol(search)) search=speval(search);
375 if (search==UNBOUND || (!isclass(search) && !isvecclass(search)))
378 meth=
findmethod(ctx,selector,search, &curclass);
380 form=ctx->callfp->form;
381 if (iscode(ccar(ccdr(meth)))) {
382 argv[1]=receiver; argv[2]=curclass;
386 bf=
fastbind(ctx,classof(receiver)->c.cls.vars,receiver,
NULL);
413 if (isvecclass(klass)) {
414 etype=
intval(klass->c.vcls.elmtype);
417 case ELM_BIT:
n=(s+WORD_SIZE-1)/WORD_SIZE;
break;
419 default:
n=
s;
break;}
424 n=vecsize(klass->c.cls.vars);
426 for (i=0; i<
n; i++) x->c.obj.iv[i]=a->
c.
obj.
iv[i];
441 for (i=0; i<MAXMETHCACHE; i++) {
442 pointer_update(ctx->methcache[i].class,
NIL);
443 pointer_update(ctx->methcache[i].selector,
NIL);
466 a=
findmethod(ctx,argv[1],classof(a), &curclass);
474 register pointer obj,klass,varid;
476 register int objcix,klasscix,
index;
483 if (objcix>=klasscix && objcix<=
classtab[klasscix].subcix) {
485 if (isint(varid)) index=
intval(varid);
486 else if (issymbol(varid)) {
488 while (index<vecsize(vvec))
489 if (vvec->
c.
vec.
v[index]==varid)
break;
else index++;}
490 else if (isstring(varid)) {
492 while (index<vecsize(vvec))
517 pointer_update(argv[0]->c.obj.iv[
n],argv[3]);
526 if (
n>=3) pointer_update(self->c.cons.car,argv[2]);
527 return(self->c.cons.car);}
534 if (
n>=3) pointer_update(self->c.cons.cdr,argv[2]);
535 return(self->c.cons.cdr);}
541 #define p_marked(p) (bpointerof(p)->h.pmark) 542 #define p_mark_on(p) (bpointerof(p)->h.pmark=1) 543 #define p_mark_off(p) (bpointerof(p)->h.pmark=0) 557 if (isnum(org) || issymbol(org) || isclass(org))
return(org);
560 if (p_marked(org))
return(cpvec[
intval(x)]);
563 if (isvecclass(klass)) {
564 etype=elmtypeof(org);
567 elmtypeof(clone)=etype;
569 case ELM_BIT: s=(s+WORD_SIZE-1)/WORD_SIZE;
break;
571 case ELM_FOREIGN: s=1;
break; }}
577 if (ctx->vsp>ctx->stacklimit)
579 fprintf(stderr,
"cannot copy\n"); euslongjmp(
cpyjmp,ERR);}
581 if (etype == ELM_FIXED || etype == ELM_POINTER) {
616 if (isnum(obj) || pissymbol(obj) || pisclass(obj))
return;
621 if (pisvector(obj)) {
622 if (elmtypeof(obj)<ELM_POINTER)
return;
658 {
int e1,e2, newsize;
661 if (isvecclass(argv[1])) {
663 if (e1==ELM_FIXED)
error(
E_USER,(
pointer)
"a record type object cannot become a vector");
668 case ELM_BIT:
switch(e2) {
669 case ELM_CHAR:
case ELM_BYTE:
n=(
n+7)/8;
break;
671 default:
n=(
n+WORD_SIZE-1)/WORD_SIZE;
break;}
break;
672 case ELM_CHAR:
case ELM_BYTE:
674 case ELM_CHAR:
case ELM_BYTE:
break;
675 case ELM_BIT:
n*=8;
break;
677 default:
switch(e2) {
678 case ELM_CHAR:
case ELM_BYTE:
n*=
sizeof(
pointer);
break;
679 case ELM_BIT:
n*=WORD_SIZE;
break;
680 default:
break;}
break; }
684 elmtypeof(argv[0])=e2;
686 else if (isint(argv[1])) {
687 newsize=ckintval(argv[1]);
689 switch(elmtypeof(argv[0])) {
690 case ELM_BIT:
n=(newsize+WORD_SIZE-1)/WORD_SIZE;
break;
691 case ELM_BYTE:
case ELM_CHAR:
692 n=(newsize+(WORD_SIZE/8)-1)/(WORD_SIZE/8);
break;
693 default:
n=newsize; }
705 {
register pointer dest=argv[0],src=argv[1];
708 if (isnum(src) || isnum(dest))
return(src);
709 nsrc=objsize(src); ndest=objsize(dest);
context * euscontexts[MAXTHREAD]
pointer INSTANTIATE(context *ctx, int n, argv)
pointer FINDMETHOD(context *ctx, int n, argv)
pointer putprop(context *, pointer, pointer, pointer)
pointer equal(pointer, pointer)
pointer SENDMESSAGE(context *ctx, int n, argv)
pointer CONSCDR(context *ctx, int n, argv)
pointer cons(context *, pointer, pointer)
pointer makecode(pointer, pointer(*)(), pointer)
void leo(context *ctx, pointer mod)
pointer DEFMETHOD(context *ctx, pointer arg)
pointer K_METHOD_DOCUMENTATION
pointer REPLACEOBJECT(context *ctx, int n, argv)
pointer SUBCLASSP(context *ctx, int n, argv)
pointer defunpkg(context *, char *, pointer, pointer(*)(), pointer)
pointer defkeyword(context *, char *)
pointer ENTERCLASS(context *ctx, int n, argv)
defun("ADR_TO_STRING", mod, ADR_TO_STRING)
pointer ufuncall(context *, pointer, pointer, pointer, struct bindframe *, int)
pointer copyobj(context *ctx, pointer org)
pointer makevector(pointer, int)
struct bindframe * fastbind(context *, pointer, pointer, struct bindframe *)
pointer METHCACHE(context *ctx, int n, argv)
void unbindspecial(context *, struct specialbindframe *)
pointer findmethod(context *ctx, pointer sel, pointer search, pointer *curclass)
pointer CLASSP(context *ctx, int n, argv)
void addcmethod(context *ctx, pointer mod, pointer(*cfunc)(), pointer sel, pointer class, pointer doc)
pointer SLOT(context *ctx, int n, argv)
pointer assq(pointer, pointer)
long buddysize[MAXBUDDY+1]
pointer findforward(context *ctx, pointer selector, pointer klass, pointer obj, pointer *component, pointer *classfound)
pointer GETCLASS(context *ctx, int n, argv)
pointer BECOME(context *ctx, int n, argv)
pointer error(enum errorcode ec,...) pointer error(va_alist) va_dcl
int getslotindex(pointer obj, pointer klass, pointer varid)
pointer funcode(context *, pointer, pointer, int)
pointer funlambda(context *, pointer, pointer, pointer, pointer *, struct bindframe *, int)
pointer makeobject(pointer)
pointer DERIVEDP(context *ctx, int n, argv)
struct class_desc classtab[MAXCLASS]
void copyunmark(pointer obj)
pointer COPYOBJ(context *ctx, int n, argv)
pointer CONSCAR(context *ctx, int n, argv)
pointer CLONE(context *ctx, int n, argv)
pointer SETSLOT(context *ctx, int n, argv)
pointer SEND(context *ctx, int n, argv)
void addmethod(context *ctx, pointer meth, pointer class, pointer doc)
pointer SEND_IF_FOUND(context *ctx, int n, argv)
pointer defspecial(context *, char *, pointer, pointer(*)())