libsrc/context.cxx File Reference

??? More...

#include <memory.h>
#include "udanax.h"

Include dependency graph for context.cxx:

Include dependency graph

Go to the source code of this file.

Functions

Contextcreatecontext (unsigned char type)
 ???

void contextfree (Context *context)
 ???

CrumContextcreatecrumcontext (typecorecrum *crumptr, typedsp *offsetptr)
 ???

void crumcontextfree (CrumContext *context)
 ???

int whereoncontext (Context *ptr, Tumbler *address, int index)
 ???

void prologuecontextnd (Context *ptr, typedsp *grasp, typedsp *reach)
 ???

void incontextlistnd (Context **clistptr, Context *c, int index)
 ???

void oncontextlistseq (Context **clistptr, Context *c)
 ???

Contextmakecontextfromcbc (typecbc *crumptr, typewid *offsetptr)
 ???

typeitemid index2itemid (int index, Context *context)
 ???

void context2span (Context *context, typespan *restrictionspanptr, int idx1, typespan *foundspanptr, int idx2)
 ???

void context2vtext (Context *context, typeispan *ispanptr, typevstuffset vstuffset)
 ???

bool context2vstuff (Session *sess, Context *context, typeispan *ispanptr, typevstuffset *vstuffsetptr)
 ???


Variables

int contextnum = 0
int c2dontextnum = 0
int crumcontextnum = 0


Detailed Description

???

(to be defined)

Definition in file context.cxx.


Function Documentation

void context2span Context context,
typespan restrictionspanptr,
int  idx1,
typespan foundspanptr,
int  idx2
 

???

(to be defined)

Definition at line 393 of file context.cxx.

References typewid::dsas, GREATER, index2itemid(), typespan::itemid, LESS, movetumbler, typespan::next, NULL, prologuecontextnd(), typespan::stream, tumbleradd, tumblercmp(), tumblerincrement(), tumblerintdiff(), tumblersub(), typedsp, and typespan::width.

Referenced by span2spanset().

00399 {
00400     Tumbler upperbound, lowerbound;
00401     typedsp grasp, reach;
00402 
00403 /* int i; */
00404 
00405 /* foo("entering context2span\n"); */
00406 /* foocontext("context = \n",context); */
00407 /* foospanset("restrictionspan = \n",restrictionspanptr); */
00408 
00409     movetumbler(&restrictionspanptr->stream, &lowerbound);
00410     tumbleradd(&lowerbound, &restrictionspanptr->width, &upperbound);
00411     prologuecontextnd(context, &grasp, &reach);
00412 /* footumbler("lowerbound = \n",&lowerbound); */
00413 /* footumbler("upperbound = \n",&upperbound); */
00414     if (tumblercmp(&grasp.dsas[idx1], &lowerbound) == LESS) {
00415 /* foo("LESSER\n"); */
00416 /* foodsp("grasp = \n",&grasp,POOM); */
00417         tumblerincrement(&grasp.dsas[idx2], 0, (int) tumblerintdiff(&lowerbound, &grasp.dsas[idx1]), &grasp.dsas[idx2]);
00418 /* foodsp("grasp = \n",&grasp,POOM); */
00419     }
00420     if (tumblercmp(&reach.dsas[idx1], &upperbound) == GREATER) {
00421 /* foo("GREATER\n"); */
00422 /* foodsp("reach = \n",&reach,POOM); */
00423         tumblerincrement(&reach.dsas[idx2], 0,  /* i= */
00424                          -tumblerintdiff(&reach.dsas[idx1], &upperbound), &reach.dsas[idx2]);
00425 /* foodec("tumblerintdiff = ",i); */
00426 /* foodsp("reach = \n",&reach,POOM); */
00427     }
00428 /* foodsp("grasp = \n",&grasp,POOM); */
00429 /* foodsp("reach = \n",&reach,POOM); */
00430     movetumbler(&grasp.dsas[idx2], &foundspanptr->stream);
00431     tumblersub(&reach.dsas[idx2], &grasp.dsas[idx2], &foundspanptr->width);
00432 /* footumbler("foundspanwidth = \n",&foundspanptr->width); */
00433     foundspanptr->itemid = index2itemid(idx2, context);
00434     foundspanptr->next = NULL;
00435 /* foospanset("leaving context2span with foundspan = \n",foundspanptr); */
00436 }

bool context2vstuff Session sess,
Context context,
typeispan ispanptr,
typevstuffset vstuffsetptr
 

???

(to be defined)

Parameters:
sess  Input: User's session context

Definition at line 493 of file context.cxx.

References ADDRESSID, context2vtext(), Context::contextinfo, typewid::dsas, foo(), foocontext(), typebottomcruminfo::granbottomcruminfo, GRANORGL, GRANTEXT, typegranbottomcruminfo::infotype, movetumbler, NULL, TEXTID, ContextBase::totaloffset, typeispan, typelink, typevstuffset, and WIDTH.

Referenced by ispan2vstuffset().

00494                                            : User's session context
00495     Context       *context,
00496     typeispan     *ispanptr,
00497     typevstuffset *vstuffsetptr)
00498 {
00499     typevstuffset vstuffset = NULL;
00500 
00501 #ifndef DISTRIBUTION
00502     foo("context2stuff\n");
00503 #endif
00504 
00505     int contextinfotype = context->contextinfo.granbottomcruminfo.infotype;
00506 
00507     if (contextinfotype != GRANTEXT && contextinfotype != GRANORGL)
00508         return false;
00509 
00510     switch (contextinfotype) {
00511     case GRANTEXT:
00512         vstuffset = (typevstuffset) new(sess) typetext;
00513 //        vstuffset = (typevstuffset) sess->alloc(sizeof(typetext));
00514 
00515         ((typeitemheader *) vstuffset)->next = NULL;
00516 #ifndef DISTRIBUTION
00517         foocontext("context after item= ", context);
00518 #endif
00519         ((typeitemheader *) vstuffset)->itemid = TEXTID;
00520         context2vtext(context, ispanptr, vstuffset);
00521         if (((typetext *) vstuffset)->length == 0)
00522             return false;
00523         break;
00524 
00525     case GRANORGL:
00526         vstuffset = (typevstuffset) new(sess) typeaddress;
00527 //        vstuffset = (typevstuffset) sess->alloc(sizeof(typeaddress));
00528 
00529         ((typeitemheader *) vstuffset)->next = NULL;
00530 #ifndef DISTRIBUTION
00531         foocontext("context after item= ", context);
00532 #endif
00533         ((typeitemheader *) vstuffset)->itemid = ADDRESSID;
00534         movetumbler(&context->totaloffset.dsas[WIDTH], &((typelink *) vstuffset)->address);
00535     }
00536 
00537     *vstuffsetptr = vstuffset;
00538     return true;
00539 }

void context2vtext Context context,
typeispan ispanptr,
typevstuffset  vstuffset
[static]
 

???

(to be defined)

Definition at line 446 of file context.cxx.

References Context::contextinfo, typewid::dsas, foo(), footumbler(), typebottomcruminfo::granbottomcruminfo, typegranbottomcruminfo::granstuff, GREATER, LESS, movetumbler, movmem, typespan::stream, typegrantext::textlength, typegrantext::textstring, typegranstuff::textstuff, ContextBase::totaloffset, tumbleradd, tumblercmp(), tumblerincrement(), tumblerintdiff(), typeispan, typevstuffset, typespan::width, and WIDTH.

Referenced by context2vstuff().

00450 {
00451     IStreamAddr crumistart, crumiend, ispanstart, ispanend;
00452     int i, vtlength;
00453 
00454     movetumbler(&context->totaloffset.dsas[WIDTH], &crumistart);
00455 #ifndef DISTRIBUTION
00456     footumbler("crumistart = ", &crumistart);
00457 #endif
00458     tumblerincrement(&crumistart, 0, (int) context->contextinfo.granbottomcruminfo.granstuff.textstuff.textlength,
00459                      &crumiend);
00460 #ifndef DISTRIBUTION
00461     footumbler("crumiend = ", &crumiend);
00462 #endif
00463     movetumbler(&ispanptr->stream, &ispanstart);
00464     tumbleradd(&ispanstart, &ispanptr->width, &ispanend);
00465     i = 0;
00466     vtlength = context->contextinfo.granbottomcruminfo.granstuff.textstuff.textlength;
00467     if (tumblercmp(&crumistart, &ispanstart) == LESS) {
00468 #ifndef DISTRIBUTION
00469         foo("first if\n\ti = tumblerintdiff (&ispanstart, &crumistart)\n");
00470 #endif
00471         i = tumblerintdiff(&ispanstart, &crumistart);
00472         vtlength -= i;
00473     }
00474     if (tumblercmp(&crumiend, &ispanend) == GREATER) {
00475 #ifndef DISTRIBUTION
00476         foo("second if\n\tvtlength -= tumblerintdiff (&crumiend, &ispanend)\n");
00477 #endif
00478         vtlength -= tumblerintdiff(&crumiend, &ispanend);
00479     }
00480     ((typetext *) vstuffset)->length = vtlength > 0 ? vtlength : -vtlength;
00481     movmem(&context->contextinfo.granbottomcruminfo.granstuff.textstuff.textstring[i], ((typetext *) vstuffset)->string,
00482            ((typetext *) vstuffset)->length);
00483 }

void contextfree Context context  ) 
 

???

(to be defined)

Definition at line 136 of file context.cxx.

References c2dontextnum, contextnum, ContextBase::contexttype, efree(), GRAN, and ContextBase::nextcontext.

Referenced by finddocscontainingsp(), isaexistsgr(), ispan2vstuffset(), link2sporglset(), retrievesporglsetinrange(), span2spanset(), and sporglset2linksetinrange().

00138 {
00139     Context *c;
00140 
00141     for (; (c = context) != 0;) {
00142         if (c->contexttype == GRAN) {
00143             --contextnum;
00144         } else {
00145             --c2dontextnum;
00146         }
00147 
00148         context = (Context *) context->nextcontext;;
00149         efree((char *)c);
00150     }
00151 }

Context* createcontext unsigned char  type  )  [static]
 

???

(to be defined)

Definition at line 110 of file context.cxx.

References c2dontextnum, clear, CONTEXT2DTAG, contextnum, CONTEXTTAG, ContextBase::contexttype, eallocwithtag(), and GRAN.

Referenced by makecontextfromcbc().

00112 {
00113     Context *ret;
00114 
00115     if (type == GRAN) {
00116         ret = (Context *) eallocwithtag(sizeof(Context), CONTEXTTAG);
00117         clear(ret, sizeof(Context));
00118         ++contextnum;
00119     } else {
00120         ret = (Context *) eallocwithtag(sizeof(type2dcontext), CONTEXT2DTAG);
00121         clear(ret, sizeof(type2dcontext));
00122         ++c2dontextnum;
00123     }
00124     ret->contexttype = type;
00125     return (ret);
00126 }

CrumContext* createcrumcontext typecorecrum crumptr,
typedsp offsetptr
 

???

(to be defined)

Definition at line 161 of file context.cxx.

References CrumContext::corecrum, crumcontextnum, CRUMCONTEXTTAG, eallocwithtag(), movewisp, CrumContext::nextcrumcontext, NULL, reserve(), CrumContext::totaloffset, typecorecrum, and typedsp.

Referenced by findcbcseqcrum().

00164 {
00165     reserve(crumptr);
00166     CrumContext *ret = (CrumContext *) eallocwithtag(sizeof(CrumContext), CRUMCONTEXTTAG);
00167     ret->nextcrumcontext = NULL;
00168     ret->corecrum = (typecbc *) crumptr;
00169     movewisp(offsetptr, &ret->totaloffset);
00170     ++crumcontextnum;
00171     return ret;
00172 }

void crumcontextfree CrumContext context  ) 
 

???

(to be defined)

Definition at line 182 of file context.cxx.

References CrumContext::corecrum, crumcontextnum, efree(), CrumContext::nextcrumcontext, rejuvinate, and typecorecrum.

Referenced by fetchorglgr(), and insertseq().

00184 {
00185     CrumContext *c;
00186 
00187     for (; (c = context) != 0; context = context->nextcrumcontext, efree((char *)c)) {
00188         rejuvinate((typecorecrum *) c->corecrum);
00189         --crumcontextnum;
00190     }
00191 }

void incontextlistnd Context **  clistptr,
Context c,
int  index
 

???

(to be defined)

Definition at line 259 of file context.cxx.

References typewid::dsas, ContextBase::nextcontext, NULL, ONMYLEFTBORDER, prologuecontextnd(), THRUME, typedsp, and whereoncontext().

Referenced by findcbcinarea2d().

00263 {
00264     Context *clist, *nextc;
00265     typedsp grasp;
00266 
00267     prologuecontextnd(c, &grasp, (typedsp *) NULL);
00268     c->nextcontext = NULL;
00269     clist = *clistptr;
00270 /* 1st insertion */
00271     if (!clist) {
00272 /* if (debug) L("first insertion\n"); */
00273         *clistptr = c;
00274         return;
00275     }
00276 /* on beginning */
00277     if (whereoncontext(clist, &grasp.dsas[index], index) < THRUME) {
00278 /* if (debug) L("beginning\n"); */
00279         c->nextcontext = clist;
00280         *clistptr = c;
00281         return;
00282     } else {
00283         for (; (nextc = (Context *) clist->nextcontext) != 0; clist = nextc) {
00284 /* in middle */
00285             if ((whereoncontext(clist, &grasp.dsas[index], index) > ONMYLEFTBORDER)
00286                 && (whereoncontext(nextc, &grasp.dsas[index], index) < ONMYLEFTBORDER)) {
00287 /* if (debug) L("middle\n"); */
00288                 c->nextcontext = nextc;
00289                 clist->nextcontext = c;
00290                 return;
00291             }
00292         }
00293     }
00294 /* on end */
00295 /* if (debug) L("end\n"); */
00296     c->nextcontext = NULL;
00297     clist->nextcontext = c;
00298 }

typeitemid index2itemid int  index,
Context context
[static]
 

???

(to be defined)

Definition at line 372 of file context.cxx.

References assert, ContextBase::contexttype, I, ISPANID, POOM, SPAN, UNKNOWNID, and VSPANID.

Referenced by context2span().

00375 {
00376     switch (context->contexttype) {
00377     case POOM:  return (index == I) ? ISPANID : VSPANID;
00378     case SPAN:  return ISPANID;
00379     default:
00380         assert(0); // index2itemid bad enftype
00381         return UNKNOWNID;
00382     }
00383 }

Context* makecontextfromcbc typecbc crumptr,
typewid offsetptr
 

???

(to be defined)

Definition at line 330 of file context.cxx.

References typecbc::cdsp, typecbc::cenftype, typecbc::cinfo, Context::contextinfo, ContextBase::contextwid, createcontext(), typecbc::cwid, debug, dspadd(), dump(), dumpcontext(), foo(), GRAN, is2dcrum(), move2dinfo(), moveinfo(), movewisp, ContextBase::nextcontext, NULL, rejuvinate, reserve(), ContextBase::totaloffset, and typecorecrum.

Referenced by findcbcinarea2d(), findcbcinspanseq(), findcbcnd(), findcbcseq(), and findlastcbcseq().

00333 {
00334     Context *context;
00335 
00336 #ifndef DISTRIBUTION
00337     if (debug) {
00338         foo("make contextfromcbc crum is ");
00339         dump((typecorecrum *) crumptr);
00340     }
00341 #endif
00342     reserve((typecorecrum *) crumptr);
00343     context = createcontext(crumptr->cenftype);
00344     movewisp(offsetptr, &context->totaloffset);
00345     movewisp(&crumptr->cwid, &context->contextwid);
00346 
00347     if (is2dcrum((typecorecrum *) crumptr))
00348         move2dinfo(&((type2dcbc *) crumptr)->c2dinfo, &((type2dcontext *) context)->context2dinfo);
00349     else
00350         moveinfo((typebottomcruminfo *) &crumptr->cinfo, &context->contextinfo);
00351 
00352     if (crumptr->cenftype != GRAN)
00353         dspadd(&context->totaloffset, &crumptr->cdsp, &context->totaloffset, (int) crumptr->cenftype);
00354     context->nextcontext = NULL;
00355     rejuvinate((typecorecrum *) crumptr);
00356 #ifndef DISTRIBUTION
00357     if (debug) {
00358         dumpcontext(context);
00359     }
00360 #endif
00361     return context;
00362 }

void oncontextlistseq Context **  clistptr,
Context c
 

???

(to be defined)

Definition at line 308 of file context.cxx.

References Context::lastcontext, ContextBase::nextcontext, and NULL.

Referenced by findcbcinspanseq(), and retrieveinspan().

00311 {                                      /* add to list of context */
00312     c->nextcontext = NULL;
00313     if (!*clistptr) {                  /* 1st insertion */
00314         *clistptr = c;
00315         c->lastcontext = c;
00316     } else {                           /* on end */
00317         (*clistptr)->lastcontext->nextcontext = c;
00318         (*clistptr)->lastcontext = c;
00319     }
00320 }

void prologuecontextnd Context ptr,
typedsp grasp,
typedsp reach
[static]
 

???

(to be defined)

Definition at line 240 of file context.cxx.

References ContextBase::contexttype, ContextBase::contextwid, dspadd(), movewisp, ContextBase::totaloffset, and typedsp.

Referenced by context2span(), and incontextlistnd().

00244 {
00245     movewisp(&ptr->totaloffset, grasp);
00246     if (reach)
00247         dspadd(grasp, &ptr->contextwid, reach, ptr->contexttype);
00248 }

int whereoncontext Context ptr,
Tumbler address,
int  index
[static]
 

???

(to be defined)

Definition at line 201 of file context.cxx.

References assert, ContextBase::contexttype, ContextBase::contextwid, typewid::dsas, GRAN, intervalcmp(), movetumbler, POOM, SPAN, ContextBase::totaloffset, tumbleradd, and WIDTH.

Referenced by incontextlistnd().

00205 {
00206     Tumbler left, right;
00207 
00208     switch (ptr->contexttype) {
00209     case GRAN:
00210         movetumbler(&ptr->totaloffset.dsas[WIDTH], &left);
00211         tumbleradd(&left, &ptr->contextwid.dsas[WIDTH], &right);
00212         break;
00213     case SPAN:
00214         /* zzz
00215          * if (iszerotumbler(&ptr->contextwid.dsas[SPANRANGE])) {
00216          *     assert(0) // zero spanrange in whereoncontext
00217          * }
00218          */
00219     case POOM:
00220         movetumbler(&ptr->totaloffset.dsas[index], &left);
00221         tumbleradd(&left, &ptr->contextwid.dsas[index], &right);
00222         break;
00223     default:
00224         assert(0); // whereoncontext: bad enftype
00225     }
00226 
00227     return intervalcmp(&left, &right, address);
00228 }


Variable Documentation

int c2dontextnum = 0 [static]
 

Definition at line 99 of file context.cxx.

Referenced by contextfree(), and createcontext().

int contextnum = 0 [static]
 

Definition at line 98 of file context.cxx.

Referenced by contextfree(), and createcontext().

int crumcontextnum = 0 [static]
 

Definition at line 100 of file context.cxx.

Referenced by createcrumcontext(), and crumcontextfree().


Generated on Sun Aug 21 04:18:25 2005 for Udanax-Green by doxygen1.3.4