Esempio n. 1
0
Tr_accessList Tr_formals(Tr_level level){
	F_accessList faccList = F_formals(level->frame);
	Tr_accessList accList = NULL;
	Tr_accessList accList_head = NULL;

	for(;faccList!=NULL;faccList=faccList->tail){
		if(accList_head==NULL){
			accList = (Tr_accessList)checked_malloc(sizeof(struct Tr_accessList_));
			accList_head = accList;
		} else {
			accList->tail = (Tr_accessList)checked_malloc(sizeof(struct Tr_accessList_));
			accList = accList->tail;
		}
		accList->head = (Tr_access)checked_malloc(sizeof(struct Tr_access_));
		accList->head->level = level;
		accList->head->access = faccList->head;
	}
	if(accList!=NULL){
		accList->tail = NULL;
	}

/* Problematic on 64-bit machine
	//1) Calculate the number of formals
	int i = 0;
	F_accessList faccList = F_formals(level->frame);
	F_accessList cursor;
	for(cursor=faccList; cursor!=NULL; cursor=cursor->tail){
		i++;
	}

	//2) Allocate mem for the accesse list
	int acc_size = sizeof(struct Tr_access_);
	int acc_list_size = sizeof(struct Tr_accessList_);
	int total_list_size = (i+1) * acc_list_size;
	Tr_accessList accList = (Tr_accessList)checked_malloc(total_list_size);
	Tr_accessList accList_head = accList;

	//Construct a list in the allocated mem
	for(;faccList!=NULL;faccList=faccList->tail){
		if(faccList->head!=NULL){
			accList->head = (Tr_access)checked_malloc(acc_size);
			accList->head->level = level;
			accList->head->access = faccList->head;

			// Make the tail point to the head of next node	
			//  |---- node  1 ----||---- node  2 ----|
			//	|--head--|--tail--||--head--|--tail--|
			//                 |____+
			accList->tail = accList + acc_list_size/8;

			// Move to next node
			accList = accList->tail;
		}
	}
	accList->tail = NULL;
*/
	return accList_head;
}
Esempio n. 2
0
/*
 * get the access-list from frame (ingnore the first one)
 */
static Tr_accessList makeFormalAccessList(Tr_level l) {
	Tr_accessList head = NULL, tail = NULL;
	F_accessList  acsl = F_formals(l->frame)->tail; /*ignore the first one for static-link*/
	for (; acsl; acsl = acsl->tail) {
		Tr_access ac = Tr_Access(l, acsl->head);
		if (head) {
			tail->tail = Tr_AccessList(ac, NULL);
			tail = tail->tail;
		} else {
			head = Tr_AccessList(ac, NULL);
			tail = head;
		}
	}
	return head;
}