⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 data.cc

📁 功能较全面的反汇编器:反汇编器ht-2.0.15.tar.gz
💻 CC
📖 第 1 页 / 共 4 页
字号:
		leastRU = _node;	}}void MRUCache::store(ObjectStream &s) const{	throw NotImplementedException(HERE);}void MRUCache::propagate(ObjHandle h){	if (h != invObjHandle) {		MRUCacheNode *n = handleToNative(h);		// remove from MRU list		if (n == mostRU) {			if (n == leastRU) {				mostRU = NULL;				leastRU = NULL;			} else {				mostRU = n->lessRU;				mostRU->moreRU = NULL;			}		} else if (n == leastRU) {			leastRU = n->moreRU;			leastRU->lessRU = NULL;		} else {			n->moreRU->lessRU = n->lessRU;			n->lessRU->moreRU = n->moreRU;		}//		checkList();		// make mostRU in MRU list		n->moreRU = NULL;		n->lessRU = mostRU;		if (mostRU == NULL) {			mostRU = leastRU = n;		} else {			mostRU->moreRU = n;			mostRU = n;		}//		checkList();	}}ObjHandle MRUCache::getLRU(){	return nativeToHandle(leastRU);}void MRUCache::checkList() const{	assert(expensiveCheck());	DPRINTF("======================================================\n");	if (!mostRU || !leastRU) {		DPRINTF("empty\n");		assert(!mostRU);		assert(!leastRU);		return;	}	DPRINTF("list: \n");	MRUCacheNode *i = mostRU;	while (i) {		DPRINTF(" moreRU   | this   | lessRU   ");		if (i->lessRU) DPRINTF("||");		i = i->lessRU;	}	DPRINTF("\n");	i = mostRU;	while (i) {#if 0		DPRINTF("%08x|%08x|%08x", i->moreRU, i, i->lessRU);		if (i->lessRU) DPRINTF("||");#else		DPRINTF("%08x\n", i->moreRU);		DPRINTF("%08x\n", i);		DPRINTF("%08x\n", i->lessRU);		if (i->lessRU) DPRINTF("       ||\n");#endif		i = i->lessRU;	}	DPRINTF("\n");	uint c1 = 1;	i = mostRU;	while (i->lessRU) {		if (i->lessRU->moreRU != i) {			DPRINTF("ecount =%08x\n", ecount);			DPRINTF("mostRU: %08x, leastRU: %08x\n", mostRU, leastRU);			DPRINTF("i: %08x, i->lessRU: %08x, i->np: %08x\n", i, i->lessRU, i->lessRU->moreRU);		}		assert(i->lessRU->moreRU == i);		assert(((i == mostRU) && (i->moreRU == NULL)) || ((i != mostRU) && (i->moreRU != NULL)));		i = i->lessRU;		c1++;		assert(c1<=ecount);	}	assert(i == leastRU);	uint c2 = 1;	i = leastRU;	while (i->moreRU) {		assert(i->moreRU->lessRU == i);		assert(((i == leastRU) && (i->lessRU == NULL)) || ((i != leastRU) && (i->lessRU != NULL)));		i = i->moreRU;		c2++;		assert(c2<=ecount);	}	assert(i == mostRU);//	assert(c1 == ecount);//	assert(c2 == ecount);}/* *	Set */Set::Set(bool oo): AVLTree(oo){}ObjectID Set::getObjectID() const{	return OBJID_SET;}void Set::intersectWith(Set *b){	foreach(Object, elem, *this,		if (!b->contains(elem)) delObj(elem);	);}void Set::unionWith(Set *b){	foreach(Object, elem, *b,		if (!contains(elem)) insert(own_objects ? elem->clone() : elem);	);}/* * */KeyValue::~KeyValue(){	if (mKey) mKey->done();	delete mKey;	if (mValue) mValue->done();	delete mValue;}KeyValue *KeyValue::clone() const{	return new KeyValue(mKey->clone(), mValue->clone());}int KeyValue::compareTo(const Object *obj) const{	return mKey->compareTo(((KeyValue*)obj)->mKey);}int KeyValue::toString(char *buf, int buflen) const{	return ht_snprintf(buf, buflen, "[Key: %y; Value: %y]", mKey, mValue);}void KeyValue::load(ObjectStream &s){	GET_OBJECT(s, mKey);	GET_OBJECT(s, mValue);}ObjectID KeyValue::getObjectID() const{	return OBJID_KEYVALUE;}void KeyValue::store(ObjectStream &s) const{	PUT_OBJECT(s, mKey);	PUT_OBJECT(s, mValue);}/* *	SInt */SInt *SInt::clone() const{	return new SInt(value);}int SInt::compareTo(const Object *obj) const{	SInt *s = (SInt*)obj;	return value - s->value;}int SInt::toString(char *buf, int buflen) const{	return ht_snprintf(buf, buflen, "%d", value);}void SInt::load(ObjectStream &s){	GET_INT32D(s, value);}ObjectID SInt::getObjectID() const{	return OBJID_SINT;}void SInt::store(ObjectStream &s) const{	PUT_INT32D(s, value);}/* *	A signed Integer (64-bit) */SInt64 *SInt64::clone() const{	return new SInt64(value);}int SInt64::compareTo(const Object *obj) const{	SInt64 *u = (SInt64*)obj;	if (value < u->value) {		return -1;	} else if (value > u->value) {		return 1;	} else {		return 0;	}}int SInt64::toString(char *buf, int buflen) const{	return ht_snprintf(buf, buflen, "%qd", value);}void SInt64::load(ObjectStream &s){	GET_INT64D(s, value);}ObjectID SInt64::getObjectID() const{	return OBJID_SINT64;}void SInt64::store(ObjectStream &s) const{	PUT_INT64D(s, value);}/* *	UInt */UInt *UInt::clone() const{	return new UInt(value);}int UInt::compareTo(const Object *obj) const{	UInt *u = (UInt*)obj;	if (value < u->value) {		return -1;	} else if (value > u->value) {		return 1;	} else {		return 0;	}}int UInt::toString(char *buf, int buflen) const{	return ht_snprintf(buf, buflen, "%u", value);}void UInt::load(ObjectStream &s){	GET_INT32D(s, value);}ObjectID UInt::getObjectID() const{	return OBJID_UINT;}void UInt::store(ObjectStream &s) const{	PUT_INT32D(s, value);}/* *	A unsigned Integer (64-bit) */UInt64 *UInt64::clone() const{	return new UInt64(value);}int UInt64::compareTo(const Object *obj) const{	UInt64 *u = (UInt64*)obj;	if (value < u->value) {		return -1;	} else if (value > u->value) {		return 1;	} else {		return 0;	}}int UInt64::toString(char *buf, int buflen) const{	return ht_snprintf(buf, buflen, "%qu", value);}void UInt64::load(ObjectStream &s){	GET_INT64D(s, value);}ObjectID UInt64::getObjectID() const{	return OBJID_UINT64;}void UInt64::store(ObjectStream &s) const{	PUT_INT64D(s, value);}/* *	A floating-point number	(FIXME: no portable storage yet) */Float *Float::clone() const{	return new Float(value);}int Float::compareTo(const Object *obj) const{// FIXME: do we want to compare for equality using some error term epsilon ?	Float *f = (Float*)obj;	if (value < f->value) {		return -1;	} else if (value > f->value) {		return 1;	} else {		return 0;	}}int Float::toString(char *buf, int buflen) const{	return ht_snprintf(buf, buflen, "%f", value);}ObjectID Float::getObjectID() const{	return OBJID_FLOAT;}/** *	A memory area. */MemArea::MemArea(const void *p, uint s, bool d){	duplicate = d;	size = s;	if (duplicate) {		ptr = malloc(size);		if (!ptr) throw std::bad_alloc();		memcpy(ptr, p, size);	} else {		// FIXME: un-const'ing p		ptr = const_cast<void*>(p);	}}MemArea::~MemArea(){	if (duplicate) free(ptr);}MemArea *MemArea::clone() const{	return new MemArea(ptr, size, true);}int MemArea::compareTo(const Object *obj) const{	const MemArea *a = this;	const MemArea *b = (const MemArea*)obj;	if (a->size != b->size) return a->size - b->size;	return memcmp(a->ptr, b->ptr, a->size);}int MemArea::toString(char *buf, int buflen) const{	throw NotImplementedException(HERE);}void MemArea::load(ObjectStream &s){	GET_INT32D(s, size);	ptr = malloc(size);	if (!ptr) throw std::bad_alloc();	GET_BINARY(s, ptr, size);}ObjectID MemArea::getObjectID() const{	return OBJID_MEMAREA;}void MemArea::store(ObjectStream &s) const{	PUT_INT32D(s, size),	PUT_BINARY(s, ptr, size);}/* *	IntSet */IntSet::IntSet(uint aMaxSetSize){	mMaxSetSize = aMaxSetSize;	mSetSize = 0;	mSet = NULL;}IntSet::~IntSet(){	free(mSet);}void IntSet::assign(const IntSet &from){	delAll();	if (from.mSetSize) makeAccessible(from.mSetSize-1);	uint s = from.mSetSize ? idx2ByteOfs(from.mSetSize-1)+1 : 0;	if (s) memcpy(mSet, from.mSet, s);}IntSet *IntSet::clone() const{	IntSet *s = new IntSet(mMaxSetSize);	s->assign(*this);	return s;}int IntSet::compareTo(const Object *obj) const{	const IntSet *a = (const IntSet*)this;	const IntSet *b = (const IntSet*)obj;	if (a->mSetSize == b->mSetSize) {		uint s = a->mSetSize ? idx2ByteOfs(a->mSetSize-1)+1 : 0;		return memcmp(a->mSet, b->mSet, s);	}	return a->mSetSize - b->mSetSize;}inline uint IntSet::idx2ByteOfs(uint i) const{	return i >> 3;}inline uint IntSet::idx2BitMask(uint i) const{	return 1 << (i & 7);}void IntSet::makeAccessible(uint i){	if (!isAccessible(i)) {		if (i+1 > mMaxSetSize) throw IndexOutOfBoundsException(HERE);		uint oldByteSize = mSetSize ? idx2ByteOfs(mSetSize-1)+1 : 0;		uint newByteSize = idx2ByteOfs(i)+1;		// grow exponentially		if (newByteSize < 3*oldByteSize/2) newByteSize = 3*oldByteSize/2;		mSet = (byte*)realloc(mSet, newByteSize);		if (!mSet) throw std::bad_alloc();		memset(mSet+oldByteSize, 0, newByteSize-oldByteSize);		mSetSize = i+1;	}}inline bool IntSet::isAccessible(uint i) const{	return i < mSetSize;}bool IntSet::contains(uint i) const{	if (!isAccessible(i)) return false;	return mSet[idx2ByteOfs(i)] & idx2BitMask(i);}void IntSet::del(uint i){	makeAccessible(i);	mSet[idx2ByteOfs(i)] &= ~idx2BitMask(i);}void IntSet::delAll(){	free(mSet);	mSet = NULL;	mSetSize = 0;}bool IntSet::findFirst(uint &i, bool set) const{	i = (uint)-1;	return findNext(i, set);}bool IntSet::findNext(uint &i, bool set) const{	// FIXME: naive impl	for (uint j=i+1; j < mSetSize; j++) {		if (contains(j) == set) {			i = j;			return true;		}	}	if (i+1 >= mSetSize && i+1 < mMaxSetSize && !set) {		i++;		return true;	}	return false;}bool IntSet::findPrev(uint &i, bool set) const{	// FIXME: naive impl	if (i == 0) return false;	if (i-1 >= mSetSize && i-1 < mMaxSetSize && !set) {		i--;		return true;	}	for (uint j=i-1; j >= 0; j--) {		if (contains(j) == set) {			i = j;			return true;		}	}	return false;}void IntSet::insert(uint i){	makeAccessible(i);	mSet[idx2ByteOfs(i)] |= idx2BitMask(i);}int IntSet::toString(char *buf, int buflen) const{	int w = 0;	uint s;	if (!findFirst(s, true)) return 0;	w += ht_snprintf(buf+w, buflen-w, "(");	while (buflen-w > 0) {		w += ht_snprintf(buf+w, buflen-w, "%d", s);		if (!findNext(s, true)) break;		w += ht_snprintf(buf+w, buflen-w, ",");	}	w += ht_snprintf(buf+w, buflen-w, ")");	return w;}/* *	sorter */static void quickSortR(List &list, int l, int r){	int m = (l+r)/2;	int L = l;	int R = r;	Object *c = list[m];	do {		while ((l<=r) && (list.compareObjects(list[l], c)<0)) l++;		while ((l<=r) && (list.compareObjects(list[r], c)>0)) r--;		if (l<=r) {			list.swap(list.findByIdx(l), list.findByIdx(r));			l++;			r--;		}	} while (l<r);	if (L<r) quickSortR(list, L, r);	if (l<R) quickSortR(list, l, R);}bool quickSort(List &l){	int c = l.count();	if (c) quickSortR(l, 0, c-1);	return true;}/* *   matchhash */const char *matchhash(int value, int_hash *hash_table){	if (hash_table) {		while (hash_table->desc) {			if (hash_table->value==value) return hash_table->desc;			hash_table++;		}	}	return NULL;}/* *	Module Init/Done */BUILDER2(OBJID_OBJECT, Object);BUILDER(OBJID_ARRAY, Array, List);BUILDER(OBJID_STACK, Stack, Array);BUILDER(OBJID_BINARY_TREE, BinaryTree, Container);BUILDER(OBJID_AVL_TREE, AVLTree, BinaryTree);BUILDER(OBJID_SET, Set, AVLTree);BUILDER(OBJID_SLINKED_LIST, SLinkedList, List);BUILDER(OBJID_QUEUE, Queue, SLinkedList);BUILDER(OBJID_DLINKED_LIST, DLinkedList, List);BUILDER(OBJID_KEYVALUE, KeyValue, Object);BUILDER(OBJID_SINT, SInt, Object);BUILDER(OBJID_UINT, UInt, Object);BUILDER(OBJID_MEMAREA, MemArea, Object);BUILDER(OBJID_STRING, String, Object);BUILDER(OBJID_ISTRING, IString, String);bool init_data(){	registerAtom(OBJID_AUTO_COMPARE, (void*)&autoCompare);	REGISTER(OBJID_OBJECT, Object);	REGISTER(OBJID_ARRAY, Array);	REGISTER(OBJID_STACK, Stack);	REGISTER(OBJID_BINARY_TREE, BinaryTree);	REGISTER(OBJID_AVL_TREE, AVLTree);	REGISTER(OBJID_SET, Set);	REGISTER(OBJID_SLINKED_LIST, SLinkedList);	REGISTER(OBJID_QUEUE, Queue);	REGISTER(OBJID_DLINKED_LIST, DLinkedList);	REGISTER(OBJID_KEYVALUE, KeyValue);	REGISTER(OBJID_SINT, SInt);	REGISTER(OBJID_UINT, UInt);	REGISTER(OBJID_MEMAREA, MemArea);	REGISTER(OBJID_STRING, String);	REGISTER(OBJID_ISTRING, IString);	return true;}  void done_data(){	unregisterAtom(OBJID_AUTO_COMPARE);	UNREGISTER(OBJID_OBJECT, Object);	UNREGISTER(OBJID_ARRAY, Array);	UNREGISTER(OBJID_STACK, Stack);	UNREGISTER(OBJID_BINARY_TREE, BinaryTree);	UNREGISTER(OBJID_AVL_TREE, AVLTree);	UNREGISTER(OBJID_SET, Set);	UNREGISTER(OBJID_SLINKED_LIST, SLinkedList);	UNREGISTER(OBJID_QUEUE, Queue);	UNREGISTER(OBJID_DLINKED_LIST, DLinkedList);	UNREGISTER(OBJID_KEYVALUE, KeyValue);	UNREGISTER(OBJID_SINT, SInt);	UNREGISTER(OBJID_UINT, UInt);	UNREGISTER(OBJID_MEMAREA, MemArea);	UNREGISTER(OBJID_STRING, String);	UNREGISTER(OBJID_ISTRING, IString);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -