Example #1
0
void _insert(int k,int kk)
{
    //printf("_%d\n",k);
	if(_RTree[k].num==-2)//表头没用过
	{
		RTreeNode* t1;
        _RTree[k].num=-1;//开始用表头
		_RTree[k].next[0]=(RTreeNode*)malloc(sizeof(RTreeNode));
        t1=_RTree[k].next[0];
		t1->num=0;
		t1->id=kk;
		t1->x1=exMin[kk]-request_dist;
		t1->x2=exMax[kk]+request_dist;
		t1->y1=eyMin[kk]-request_dist;
		t1->y2=eyMax[kk]+request_dist;
	}else
	{
		FreeNode.id=kk;
		FreeNode.num=0;
		FreeNode.x1=exMin[kk]-request_dist;
		FreeNode.x2=exMax[kk]+request_dist;
		FreeNode.y1=eyMin[kk]-request_dist;
		FreeNode.y2=eyMax[kk]+request_dist;
		if(!insertRT(&_RTree[k],_RTree[k].next[0]))
		{
			RTreeNode* root=(RTreeNode*)malloc(sizeof(RTreeNode));
			root->num=2;
			root->next[0]=_RTree[k].next[0];
			root->next[1]=NodeCopy();
			re(root);
			_RTree[k].next[0]=root;
		}
	}
}
Example #2
0
GLOBAL Node *DemoteProcArgs(Node *fdcl)
{
     Node *arg;
     ListMarker marker;

     assert(fdcl != NULL);

     IterateList(&marker, fdcl->u.fdcl.args);
     while (NextOnList(&marker, (GenericREF) & arg)) {
	  if (arg->typ == Decl) {
	       Node *decltype = NodeDataType(arg);

	       /* convert Adcl to pointer */
	       if (decltype->typ == Adcl) {
		    /* 
		     * ``If the specification of an array type
		     * includes any type qualifiers, the element type
		     * is so-qualified, not the array type. If the
		     * specification of a function type includes any
		     * type qualifiers, the behavior is
		     * undefined.'' 
		     * 
		     * (WG14/N843 6.7.3.8)
		     */

		    Node *t = decltype->u.adcl.type;

		    /* the type qualifiers of the specification */
		    TypeQual tq = NodeTq(NodeDataTypeSuperior(arg));
		    
		    if (tq_has_anything(tq)) {
			 t = NodeCopy(t, NodeOnly);
			 /* add qualifiers to the element type */
			 NodeUpdateTq2(t, tq_union, tq);
		    }
		    /* the pointer type is never qualified, hence EMPTY_TQ */
		    arg->u.decl.type = 
			 MakePtrCoord(EMPTY_TQ, t, decltype->coord);
	       }
	  }
     }
Example #3
0
void insert(int k,int kk)
{
     //printf(",%d\n",k);
	if(RTree[k].num==-2)//表头没用过
	{
        //system("pause");
		RTreeNode* t1;
		RTree[k].num=-1;//开始用表头
		RTree[k].next[0]=(RTreeNode*)malloc(sizeof(RTreeNode));
        t1=RTree[k].next[0];
		t1->num=0;
		t1->id=kk;
		t1->x1=exMin[kk];
		t1->x2=exMax[kk];
		t1->y1=eyMin[kk];
		t1->y2=eyMax[kk];
		//printf(",%d\n",t1->num);
	}else
	{
         //system("pause");
		FreeNode.id=kk;
		FreeNode.num=0;
		FreeNode.x1=exMin[kk];
		FreeNode.x2=exMax[kk];
		FreeNode.y1=eyMin[kk];
		FreeNode.y2=eyMax[kk];
		if(!insertRT(&RTree[k],RTree[k].next[0]))
		{
			RTreeNode* root=(RTreeNode*)malloc(sizeof(RTreeNode));
			root->num=2;
			root->next[0]=RTree[k].next[0];
			root->next[1]=NodeCopy();
			re(root);
			RTree[k].next[0]=root;
		}
	}
}
Example #4
0
/* Make a type that is merged from <type1> and quals of <qual2> */
GLOBAL Node *MakeMergedType(Node *type1, Node *qual2)
{
  return TypeQualifyNode(NodeCopy(type1, NodeOnly), NodeTypeQuals(qual2));
}
Example #5
0
int insertRT(RTreeNode* father,RTreeNode* me)
{
    //system("pause");
	if(me->num==0)
	{
		return 0;
	}else
	{
        //printf("1me%d\n",me->num);
		double temp=1e100,tmp;
		int best,i;
		for(i=0;i<me->num;i++)
		{
			tmp=change_rec(me->next[i],&FreeNode);
			if(tmp<temp){temp=tmp;best=i;}
		}
		//printf("2me%d %x\n",me->num,me->next[best]);
		if(!insertRT(me,me->next[best]))
		{
		    //printf("8me%d %x\n",me->num,me->next[best]);
			if(me->num<MAXCH)
			{
			    //printf("10me%d %x\n",me->num,me->next[best]);
				me->num++;
				me->next[(me->num)-1]=NodeCopy();
				re(me);
				return 1;
			}else
			{
			    //printf("3me%d\n",me->num);
				RTreeNode* t=(RTreeNode*)malloc(sizeof(RTreeNode));
				int i;
				t->num=0;
                for(i=MAXCH/2;i<MAXCH;i++)
				{
					t->next[t->num]=me->next[i];
					t->num++;
				}
				me->num=MAXCH/2;
				re(me);
				t->next[t->num]=NodeCopy();
				t->num++;
				re(t);
				FreeNode.id=t->id;
				FreeNode.num=t->num;
				FreeNode.x1=t->x1;
				FreeNode.y1=t->y1;
				FreeNode.x2=t->x2;
				FreeNode.y2=t->y2;
				for(i=0;i<t->num;i++) FreeNode.next[i]=t->next[i];
				free(t);
				return 0;
			}
		}else
		{
		    //printf("9me%d %x\n",me->num,me->next[best]);
			re(me);
			//printf("9me%d %x\n",me->num,me->next[best]);
			return 1;
		}
	}
}