Exemple #1
0
int	evalNodeSet_ce (cachedExpr *ce,VTDNav *vn){
			int i=-1;
		if (ce->cached){
			if (ce->count<ce->ens->size){
				i=intAt(ce->ens,ce->count);
				recoverNode(vn,i);
				ce->count++;
				return i;
			}else
				return -1;

		}else{
			ce->cached = TRUE;
			
			if (ce->ens==NULL){
				ce->ens = createFastIntBuffer2(8);//page size 64
			}
			//record node set
			while((i=ce->e->evalNodeSet(ce->e,vn))!=-1){
				appendInt(ce->ens,i);
			}
			ce->e->reset(ce->e,vn);
			if(ce->ens->size>0){
				i=intAt(ce->ens,ce->count);//count should be zero
				recoverNode(vn,i);
				vn->count++;
				return i;
			}else
				return -1;
		}
	
}
Exemple #2
0
static Boolean compNodeSetNodeSet(binaryExpr *be, expr* left, expr* right, VTDNav *vn, opType op){
	exception e;
	int i,i1,k,s1,stackSize;
	Try {
		if (be->fib1 == NULL)
			be->fib1 = createFastIntBuffer2(BUF_SZ_EXP);

	          push2(vn);
	          stackSize = vn->contextBuf2->size;
	          while ((i = be->left->evalNodeSet(be->left,vn)) != -1) {
	              i1 = getStringVal(vn,i);
	              if (i1 != -1)
	              appendInt(be->fib1,i1);
	          }
			  be->left->reset(be->left,vn);
	          vn->contextBuf2->size = stackSize;
	          pop2(vn);
	          push2(vn);
	          stackSize = vn->contextBuf2->size;
	          while ((i = be->right->evalNodeSet(be->right,vn)) != -1) {
	              i1 = getStringVal(vn,i);
	              if (i1 != -1){
	                  s1 = be->fib1->size;
	                  for (k = 0; k < s1; k++) {
		                  Boolean b = compareVV(be,intAt(be->fib1,k),vn,i1,op);
		                  if (b){
		                      clearFastIntBuffer(be->fib1);
		                      vn->contextBuf2->size = stackSize;
		        	          pop2(vn);
		        	          be->right->reset(be->right,vn);
		                      return TRUE;
		                  }
		              }
	              }
	          }
	          vn->contextBuf2->size = stackSize;
	          pop2(vn);
	          be->right->reset(be->right,vn);
	          clearFastIntBuffer(be->fib1);
	          return FALSE;

	} Catch (e) {
		if (e.et == out_of_mem){
			Throw e;
		}
		if(be->fib1!=NULL)
			clearFastIntBuffer(be->fib1);

		e.et = other_exception;
		e.msg = "undefined run time behavior in computerEQNE";
		Throw e;
	}
	return FALSE;
}
Exemple #3
0
 static bool intAt(char* name, int* value)		{ return intAt(name, strlen(name), value); }
Exemple #4
0
int iterateNodeRecorder(NodeRecorder *nr){
	int j, i;
	Boolean b;
	if (nr->count < nr->fib->size)
	{
		i = intAt(nr->fib,nr->count);
		b = (i >= 0);
		if (b == FALSE)
		{
			i = i & 0x7fffffff;
		}
		switch (i)
		{
		case 0xff:
			nr->vn->context[0] = -1;
			nr->vn->atTerminal = FALSE;
			nr->count++;
			break;

		case 0:
			nr->vn->context[0] = 0;
			if (b == FALSE)
			{
				nr->vn->atTerminal = TRUE;
				nr->vn->LN = intAt(nr->fib,nr->count + 1);
				nr->count += 2;
			}
			else
			{
				nr->vn->atTerminal = FALSE;
				nr->count++;
			}

			break;

		case 1:
			nr->vn->context[0] = 1;
			nr->vn->context[1] = intAt(nr->fib,nr->count + 1);
			nr->vn->l1index = intAt(nr->fib,nr->count + 2);
			if (b == FALSE)
			{
				nr->vn->atTerminal = TRUE;
				nr->vn->LN = intAt(nr->fib,nr->count + 3);
				nr->count += 4;
			}
			else
			{
				nr->vn->atTerminal = FALSE;
				nr->count += 3;
			}

			break;

		case 2:
			nr->vn->context[0] = 2;
			nr->vn->context[1] = intAt(nr->fib,nr->count + 1);
			nr->vn->context[2] = intAt(nr->fib,nr->count + 2);
			nr->vn->l1index = intAt(nr->fib,nr->count + 3);
			nr->vn->l2lower = intAt(nr->fib,nr->count + 4);
			nr->vn->l2upper = intAt(nr->fib,nr->count + 5);
			nr->vn->l2index = intAt(nr->fib,nr->count + 6);
			if (b == FALSE)
			{
				nr->vn->atTerminal = TRUE;
				nr->vn->LN = intAt(nr->fib,nr->count + 7);
				nr->count += 8;
			}
			else
			{
				nr->vn->atTerminal = FALSE;
				nr->count += 7;
			}

			break;

		case 3:
			nr->vn->context[0] = 3;
			nr->vn->context[1] = intAt(nr->fib,nr->count + 1);
			nr->vn->context[2] = intAt(nr->fib,nr->count + 2);
			nr->vn->context[3] = intAt(nr->fib,nr->count + 3);
			nr->vn->l1index = intAt(nr->fib,nr->count + 4);
			nr->vn->l2lower = intAt(nr->fib,nr->count + 5);
			nr->vn->l2upper = intAt(nr->fib,nr->count + 6);
			nr->vn->l2index = intAt(nr->fib,nr->count + 7);
			nr->vn->l3lower = intAt(nr->fib,nr->count + 8);
			nr->vn->l3upper = intAt(nr->fib,nr->count + 9);
			nr->vn->l3index = intAt(nr->fib,nr->count + 10);
			if (b == FALSE)
			{
				nr->vn->atTerminal = TRUE;
				nr->vn->LN = intAt(nr->fib,nr->count + 11);
				nr->count += 12;
			}
			else
			{
				nr->vn->atTerminal = FALSE;
				nr->count += 11;
			}

			break;

		default:
			nr->vn->context[0] = i;
			for (j = 1; j < i; j++)
			{
				nr->vn->context[j] = intAt(nr->fib,nr->count + j);
			}
			nr->vn->l1index = intAt(nr->fib,nr->count + i);
			nr->vn->l2lower = intAt(nr->fib,nr->count + i + 1);
			nr->vn->l2upper = intAt(nr->fib,nr->count + i + 2);
			nr->vn->l2index = intAt(nr->fib,nr->count + i + 3);
			nr->vn->l3lower = intAt(nr->fib,nr->count + i + 4);
			nr->vn->l3upper = intAt(nr->fib,nr->count + i + 5);
			nr->vn->l3index = intAt(nr->fib,nr->count + i + 6);
			if (b == FALSE)
			{
				nr->vn->atTerminal = TRUE;
				nr->vn->LN = intAt(nr->fib,nr->count + 11);
				nr->count += i + 8;
			}
			else
			{
				nr->vn->atTerminal = FALSE;
				nr->count += i + 7;
			}
			break;
		}
		nr->position++;
		return getCurrentIndex(nr->vn);
	}
	return -1;
}