cloud9_root/src/cloud9/lib/Module/Dyck/AAAnalyzer.cpp
/// if one of add and val is null, create and return it
/// otherwise return the ptr;
if one of add and val is null, create and return it
otherwise return the ptr.
if one of add and val is null create and return it otherwise return the ptr .
DyckVertex* AAAnalyzer::addPtrTo(DyckVertex* address, DyckVertex* val) {
	if (address == NULL && val == NULL) {
		errs() << "ERROR in addPtrTo\n";
		exit(1);
	} else if (address == NULL) {
		address = dgraph->retrieveDyckVertex(NULL).first;
		address->addTarget(val->getRepresentative(), (void*) DEREF_LABEL);
		return address;
	} else if (val == NULL) {
		DyckVertex* addrep = address->getRepresentative();
		set<DyckVertex*>* derefset = addrep->getOutVertices((void*) DEREF_LABEL);
		if (derefset != NULL && !derefset->empty()) {
			val = *(derefset->begin());
		} else {
			val = dgraph->retrieveDyckVertex(NULL).first;
			addrep->addTarget(val, (void*) DEREF_LABEL);
		}
		return val;
	} else {
		DyckVertex* addrep = address->getRepresentative();
		addrep->addTarget(val->getRepresentative(), (void*) DEREF_LABEL);
		return addrep;
	}
}
DyckVertex * AAAnalyzer :: addPtrTo ( DyckVertex * address , DyckVertex * val ) { if ( address == NULL && val == NULL ) { errs ( ) << " \n " ; exit ( 1 ) ; } else if ( address == NULL ) { address = dgraph -> retrieveDyckVertex ( NULL ) . first ; address -> addTarget ( val -> getRepresentative ( ) , ( void * ) DEREF_LABEL ) ; return address ; } else if ( val == NULL ) { DyckVertex * addrep = address -> getRepresentative ( ) ; set < DyckVertex * > * derefset = addrep -> getOutVertices ( ( void * ) DEREF_LABEL ) ; if ( derefset != NULL && ! derefset -> empty ( ) ) { val = * ( derefset -> begin ( ) ) ; } else { val = dgraph -> retrieveDyckVertex ( NULL ) . first ; addrep -> addTarget ( val , ( void * ) DEREF_LABEL ) ; } return val ; } else { DyckVertex * addrep = address -> getRepresentative ( ) ; addrep -> addTarget ( val -> getRepresentative ( ) , ( void * ) DEREF_LABEL ) ; return addrep ; } }
if one of add and val is null, create and return it
otherwise return the ptr;
if one of add and val is null create and return it otherwise return the ptr ;