29 if (isnum(argv[0]))
return(
NIL);
30 return(classof(argv[0]));}
38 return(isclass(argv[0])?
T:
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);
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;
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];
242 *component = obj->
c.
obj.
iv[i];
243 if (!isnum(*component)) {
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);
474 register pointer obj,klass,varid;
476 register int objcix,klasscix,
index;
483 if (objcix>=klasscix && objcix<=
classtab[klasscix].subcix) {
486 else if (issymbol(varid)) {
488 while (
index<vecsize(vvec))
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);
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);