[Scummvm-cvs-logs] SF.net SVN: scummvm:[54873] tools/branches/gsoc2010-decompiler/decompiler

pidgeot at users.sourceforge.net pidgeot at users.sourceforge.net
Sun Dec 12 01:15:52 CET 2010


Revision: 54873
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54873&view=rev
Author:   pidgeot
Date:     2010-12-12 00:15:52 +0000 (Sun, 12 Dec 2010)

Log Message:
-----------
DECOMPILER: Use pointers to Instructions

Modified Paths:
--------------
    tools/branches/gsoc2010-decompiler/decompiler/codegen.cpp
    tools/branches/gsoc2010-decompiler/decompiler/codegen.h
    tools/branches/gsoc2010-decompiler/decompiler/control_flow.cpp
    tools/branches/gsoc2010-decompiler/decompiler/control_flow.h
    tools/branches/gsoc2010-decompiler/decompiler/engine.h
    tools/branches/gsoc2010-decompiler/decompiler/graph.h
    tools/branches/gsoc2010-decompiler/decompiler/instruction.h
    tools/branches/gsoc2010-decompiler/decompiler/kyra/codegen.cpp
    tools/branches/gsoc2010-decompiler/decompiler/kyra/codegen.h
    tools/branches/gsoc2010-decompiler/decompiler/kyra/disassembler.cpp
    tools/branches/gsoc2010-decompiler/decompiler/kyra/engine.cpp
    tools/branches/gsoc2010-decompiler/decompiler/kyra/engine.h
    tools/branches/gsoc2010-decompiler/decompiler/scummv6/codegen.cpp
    tools/branches/gsoc2010-decompiler/decompiler/scummv6/codegen.h
    tools/branches/gsoc2010-decompiler/decompiler/scummv6/disassembler.cpp
    tools/branches/gsoc2010-decompiler/decompiler/scummv6/engine.cpp
    tools/branches/gsoc2010-decompiler/decompiler/scummv6/engine.h
    tools/branches/gsoc2010-decompiler/decompiler/simple_disassembler.cpp
    tools/branches/gsoc2010-decompiler/decompiler/simple_disassembler.h
    tools/branches/gsoc2010-decompiler/decompiler/test/cfg_test.h
    tools/branches/gsoc2010-decompiler/decompiler/test/codegen.h
    tools/branches/gsoc2010-decompiler/decompiler/test/disassembler_test.h

Modified: tools/branches/gsoc2010-decompiler/decompiler/codegen.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/codegen.cpp	2010-12-11 23:51:50 UTC (rev 54872)
+++ tools/branches/gsoc2010-decompiler/decompiler/codegen.cpp	2010-12-12 00:15:52 UTC (rev 54873)
@@ -158,7 +158,7 @@
 		while (!dfsStack.empty()) {
 			DFSEntry e = dfsStack.pop();
 			GroupPtr tmp = GET(e.first);
-			if (tmp->_start->_address > lastGroup->_start->_address)
+			if ((*tmp->_start)->_address > (*lastGroup->_start)->_address)
 				lastGroup = tmp;
 			_stack = e.second;
 			GraphVertex v = e.first;
@@ -186,7 +186,7 @@
 					assert(_indentLevel > 0);
 					_indentLevel--;
 				}
-				_output << boost::format("%08X: %s") % p->_start->_address % indentString(it->_line) << std::endl;
+				_output << boost::format("%08X: %s") % (*p->_start)->_address % indentString(it->_line) << std::endl;
 				if (it->_indentAfter)
 					_indentLevel++;
 			}
@@ -253,8 +253,8 @@
 	}
 }
 
-void CodeGenerator::processInst(const Instruction inst) {
-	switch (inst._type) {
+void CodeGenerator::processInst(const InstPtr inst) {
+	switch (inst->_type) {
 	// We handle plain dups here because their behavior should be identical across instruction sets and this prevents implementation error.
 	case kDupInstType:
 		{
@@ -268,16 +268,16 @@
 		}
 	case kUnaryOpPreInstType:
 	case kUnaryOpPostInstType:
-		_stack.push(new UnaryOpEntry(_stack.pop(), inst._codeGenData, inst._type == kUnaryOpPostInstType));
+		_stack.push(new UnaryOpEntry(_stack.pop(), inst->_codeGenData, inst->_type == kUnaryOpPostInstType));
 		break;
 	case kBinaryOpInstType:
 		{
 			EntryPtr op1 = _stack.pop();
 			EntryPtr op2 = _stack.pop();
 			if (_binOrder == kFIFOArgOrder)
-				_stack.push(new BinaryOpEntry(op2, op1, inst._codeGenData));
+				_stack.push(new BinaryOpEntry(op2, op1, inst->_codeGenData));
 			else if (_binOrder == kLIFOArgOrder)
-				_stack.push(new BinaryOpEntry(op1, op2, inst._codeGenData));
+				_stack.push(new BinaryOpEntry(op1, op2, inst->_codeGenData));
 			break;
 		}
 	case kCondJumpInstType:
@@ -366,11 +366,11 @@
 	case kSpecialCallInstType:
 		{
 			_argList.clear();
-			bool returnsValue = (inst._codeGenData.find("r") == 0);
-			std::string metadata = (!returnsValue ? inst._codeGenData : inst._codeGenData.substr(1));
+			bool returnsValue = (inst->_codeGenData.find("r") == 0);
+			std::string metadata = (!returnsValue ? inst->_codeGenData : inst->_codeGenData.substr(1));
 			for (size_t i = 0; i < metadata.length(); i++)
 				processSpecialMetadata(inst, metadata[i], i);
-			_stack.push(new CallEntry(inst._name, _argList));
+			_stack.push(new CallEntry(inst->_name, _argList));
 			if (!returnsValue) {
 				std::stringstream stream;
 				stream << _stack.pop() << ";";
@@ -381,7 +381,7 @@
 	default:
 		{
 			std::stringstream s;
-			s << boost::format("WARNING: Unknown opcode %X at address %08X") % inst._opcode % inst._address;
+			s << boost::format("WARNING: Unknown opcode %X at address %08X") % inst->_opcode % inst->_address;
 			addOutputLine(s.str());
 		}
 		break;
@@ -395,7 +395,7 @@
 		_argList.push_back(p);
 }
 
-void CodeGenerator::processSpecialMetadata(const Instruction &inst, char c, int pos) {
+void CodeGenerator::processSpecialMetadata(const InstPtr inst, char c, int pos) {
 	switch (c) {
 	case 'p':
 		addArg(_stack.pop());

Modified: tools/branches/gsoc2010-decompiler/decompiler/codegen.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/codegen.h	2010-12-11 23:51:50 UTC (rev 54872)
+++ tools/branches/gsoc2010-decompiler/decompiler/codegen.h	2010-12-12 00:15:52 UTC (rev 54873)
@@ -356,7 +356,7 @@
 	 *
 	 * @param inst The instruction to process.
 	 */
-	virtual void processInst(const Instruction inst);
+	virtual void processInst(const InstPtr inst);
 
 	/**
 	 * Indents a string according to the current indentation level.
@@ -390,7 +390,7 @@
 	 * @param c The character signifying the action to be taken.
 	 * @param pos The position at which c occurred in the metadata.
 	 */
-	virtual void processSpecialMetadata(const Instruction &inst, char c, int pos);
+	virtual void processSpecialMetadata(const InstPtr inst, char c, int pos);
 
 	/**
 	 * Add an argument to the argument list.

Modified: tools/branches/gsoc2010-decompiler/decompiler/control_flow.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/control_flow.cpp	2010-12-11 23:51:50 UTC (rev 54872)
+++ tools/branches/gsoc2010-decompiler/decompiler/control_flow.cpp	2010-12-12 00:15:52 UTC (rev 54873)
@@ -41,21 +41,21 @@
 	// Automatically add a function if we're not supposed to look for more functions and no functions are defined
 	// This avoids a special case for when no real functions exist in the script
 	if (engine->_functions.empty() && !_engine->detectMoreFuncs())
-		engine->_functions[insts.begin()->_address] = Function(insts.begin(), insts.end());
+		engine->_functions[(*insts.begin())->_address] = Function(insts.begin(), insts.end());
 
 	GroupPtr prev = NULL;
 	int id = 0;
 	// Create vertices
 	for (ConstInstIterator it = insts.begin(); it != insts.end(); ++it) {
 		GraphVertex cur = boost::add_vertex(_g);
-		_addrMap[it->_address] = cur;
+		_addrMap[(*it)->_address] = cur;
 		PUT(cur, new Group(cur, it, it, prev));
 		PUT_ID(cur, id);
 		id++;
 
 		// Add reference to vertex if function starts here
-		if (_engine->_functions.find(it->_address) != _engine->_functions.end())
-			_engine->_functions[it->_address]._v = cur;
+		if (_engine->_functions.find((*it)->_address) != _engine->_functions.end())
+			_engine->_functions[(*it)->_address]._v = cur;
 
 		prev = GET(cur);
 	}
@@ -66,7 +66,7 @@
 	bool addEdge = false;
 	prev = NULL;
 	for (ConstInstIterator it = insts.begin(); it != insts.end(); ++it) {
-		if (_engine->_functions.find(it->_address) != _engine->_functions.end()) {
+		if (_engine->_functions.find((*it)->_address) != _engine->_functions.end()) {
 			addEdge = false;
 		}
 
@@ -77,14 +77,14 @@
 		}
 
 		last = cur;
-		addEdge = (it->_type != kJumpInstType && it->_type != kJumpRelInstType && it->_type != kReturnInstType);
+		addEdge = ((*it)->_type != kJumpInstType && (*it)->_type != kJumpRelInstType && (*it)->_type != kReturnInstType);
 		prev = GET(cur);
 
 	}
 
 	// Add jump edges
 	for (ConstInstIterator it = insts.begin(); it != insts.end(); ++it) {
-		switch(it->_type) {
+		switch((*it)->_type) {
 		case kJumpInstType:
 		case kCondJumpInstType:
 		case kJumpRelInstType:
@@ -99,12 +99,12 @@
 	}
 }
 
-GraphVertex ControlFlow::find(const Instruction &inst) {
-	return _addrMap[inst._address];
+GraphVertex ControlFlow::find(const InstPtr inst) {
+	return _addrMap[inst->_address];
 }
 
 GraphVertex ControlFlow::find(ConstInstIterator it) {
-	return _addrMap[it->_address];
+	return _addrMap[(*it)->_address];
 }
 
 GraphVertex ControlFlow::find(uint32 address) {
@@ -124,7 +124,7 @@
 	// Update address map
 	ConstInstIterator it = gr2->_start;
 	do {
-		_addrMap[it->_address] = g1;
+		_addrMap[(*it)->_address] = g1;
 		++it;
 	} while (gr2->_start != gr2->_end && it != gr2->_end);
 
@@ -158,7 +158,7 @@
 		GroupPtr gr = GET(e.first);
 		if (gr->_stackLevel != -1) {
 			if (gr->_stackLevel != e.second)
-				std::cerr << boost::format("WARNING: Inconsistency in expected stack level for instruction at address 0x%08x (current: %d, requested: %d)\n") % gr->_start->_address % gr->_stackLevel % e.second;
+				std::cerr << boost::format("WARNING: Inconsistency in expected stack level for instruction at address 0x%08x (current: %d, requested: %d)\n") % (*gr->_start)->_address % gr->_stackLevel % e.second;
 			continue;
 		}
 		gr->_stackLevel = e.second;
@@ -167,7 +167,7 @@
 		for (OutEdgeIterator oe = r.first; oe != r.second; ++oe) {
 			GraphVertex target = boost::target(*oe, _g);
 			if (seen.find(target) == seen.end()) {
-				levelStack.push(LevelEntry(target, e.second + gr->_start->_stackChange));
+				levelStack.push(LevelEntry(target, e.second + (*gr->_start)->_stackChange));
 				seen.insert(target);
 			}
 		}
@@ -180,13 +180,13 @@
 		GraphVertex v = find(it);
 		GroupPtr gr = GET(v);
 
-		if (it->_address < nextFunc)
+		if ((*it)->_address < nextFunc)
 			continue;
 
 		bool functionExists = false;
 		bool detectEndPoint = false;
 		for (FuncMap::iterator fn = _engine->_functions.begin(); fn != _engine->_functions.end(); ++fn) {
-			if (fn->first == it->_address) {
+			if (fn->first == (*it)->_address) {
 				if (fn->second._endIt == _insts.end()) {
 					return;
 				}
@@ -195,7 +195,7 @@
 					detectEndPoint = true;
 					break;
 				}
-				nextFunc = fn->second._endIt->_address;
+				nextFunc = (*fn->second._endIt)->_address;
 				functionExists = true;
 			}
 		}
@@ -208,7 +208,7 @@
 			InEdgeRange ier = boost::in_edges(v, _g);
 			for (InEdgeIterator e = ier.first; e != ier.second; ++e) {
 				// If an ingoing edge exists from earlier in the code, this is not a function entry point
-				if (GET(boost::source(*e, _g))->_start->_address < gr->_start->_address)
+				if ((*GET(boost::source(*e, _g))->_start)->_address < (*gr->_start)->_address)
 					isEntryPoint = false;
 			}
 		}
@@ -222,7 +222,7 @@
 			while (!stack.empty()) {
 				v = stack.pop();
 				GroupPtr tmp = GET(v);
-				if (tmp->_start->_address > endPoint->_start->_address)
+				if ((*tmp->_start)->_address > (*endPoint->_start)->_address)
 					endPoint = tmp;
 				OutEdgeRange r = boost::out_edges(v, _g);
 				for (OutEdgeIterator i = r.first; i != r.second; ++i) {
@@ -237,20 +237,20 @@
 			ConstInstIterator endInst;
 			if (endPoint->_next) {
 				endInst = endPoint->_next->_start;
-				nextFunc = endInst->_address;
+				nextFunc = (*endInst)->_address;
 			} else {
 				endInst = _insts.end();
 			}
 			Function f;
 			if (detectEndPoint) {
-				f = _engine->_functions[gr->_start->_address];
+				f = _engine->_functions[(*gr->_start)->_address];
 				f._endIt = endInst;
 			} else {
 				f = Function(gr->_start, endInst);
 				f._name = "auto_";
 			}
 			f._v = find(it);
-			_engine->_functions[gr->_start->_address] = f;
+			_engine->_functions[(*gr->_start)->_address] = f;
 			if (!endPoint->_next)
 				return;
 		}
@@ -293,22 +293,22 @@
 			grCur->_stackLevel = expectedStackLevel;
 		}
 
-		stackLevel += curInst->_stackChange;
+		stackLevel += (*curInst)->_stackChange;
 
 		// For stack operations, the new stack level becomes the expected stack level starting from the next group
-		if (curInst->_type == kStackInstType) {
+		if ((*curInst)->_type == kStackInstType) {
 			expectedStackLevel = stackLevel;
 			grNext->_stackLevel = stackLevel;
 		}
 
 		// Group ends after a jump
-		if (curInst->_type == kJumpInstType || curInst->_type == kJumpRelInstType || curInst->_type == kCondJumpInstType || curInst->_type == kCondJumpRelInstType) {
+		if ((*curInst)->_type == kJumpInstType || (*curInst)->_type == kJumpRelInstType || (*curInst)->_type == kCondJumpInstType || (*curInst)->_type == kCondJumpRelInstType) {
 			stackLevel = grNext->_stackLevel;
 			continue;
 		}
 
 		// Group ends with a return
-		if (curInst->_type == kReturnInstType) {
+		if ((*curInst)->_type == kReturnInstType) {
 			stackLevel = grNext->_stackLevel;
 			continue;
 		}
@@ -323,13 +323,13 @@
 		bool forceMerge = true;
 		ConstInstIterator it = grCur->_start;
 		do {
-			if (it->_stackChange >= 0)
+			if ((*it)->_stackChange >= 0)
 				forceMerge = false;
 			++it;
 		} while (grCur->_start != grCur->_end && it != grCur->_end);
 
 		// Group ends when stack is balanced, unless just before conditional jump
-		if (stackLevel == expectedStackLevel && !forceMerge && nextInst->_type != kCondJumpInstType && nextInst->_type != kCondJumpRelInstType) {
+		if (stackLevel == expectedStackLevel && !forceMerge && (*nextInst)->_type != kCondJumpInstType && (*nextInst)->_type != kCondJumpRelInstType) {
 			continue;
 		}
 
@@ -402,7 +402,7 @@
 			for (InEdgeIterator e = ier.first; e != ier.second; ++e) {
 				GroupPtr sourceGr = GET(boost::source(*e, _g));
 				// Block has ingoing edge from block later in the code that isn't a do-while condition
-				if (sourceGr->_start->_address > gr->_start->_address && sourceGr->_type != kDoWhileCondGroupType)
+				if ((*sourceGr->_start)->_address > (*gr->_start)->_address && sourceGr->_type != kDoWhileCondGroupType)
 					isWhile = true;
 			}
 			if (isWhile)
@@ -421,7 +421,7 @@
 			for (OutEdgeIterator e = oer.first; e != oer.second; ++e) {
 				GroupPtr targetGr = GET(boost::target(*e, _g));
 				// ...to earlier in code
-				if (targetGr->_start->_address < gr->_start->_address)
+				if ((*targetGr->_start)->_address < (*gr->_start)->_address)
 					gr->_type = kDoWhileCondGroupType;
 			}
 		}
@@ -433,12 +433,12 @@
 	for (VertexIterator v = vr.first; v != vr.second; ++v) {
 		GroupPtr gr = GET(*v);
 		// Undetermined block with unconditional jump...
-		if (gr->_type == kNormalGroupType && (gr->_end->_type == kJumpInstType || gr->_end->_type == kJumpRelInstType) && out_degree(*v, _g) == 1) {
+		if (gr->_type == kNormalGroupType && ((*gr->_end)->_type == kJumpInstType || (*gr->_end)->_type == kJumpRelInstType) && out_degree(*v, _g) == 1) {
 			OutEdgeIterator oe = boost::out_edges(*v, _g).first;
 			GraphVertex target = boost::target(*oe, _g);
 			GroupPtr targetGr = GET(target);
 			// ...to somewhere later in the code...
-			if (gr->_start->_address >= targetGr->_start->_address)
+			if ((*gr->_start)->_address >= (*targetGr->_start)->_address)
 				continue;
 			InEdgeRange ier = boost::in_edges(target, _g);
 			for (InEdgeIterator ie = ier.first; ie != ier.second; ++ie) {
@@ -458,7 +458,7 @@
 	for (VertexIterator v = vr.first; v != vr.second; ++v) {
 		GroupPtr gr = GET(*v);
 		// Undetermined block with unconditional jump...
-		if (gr->_type == kNormalGroupType && (gr->_end->_type == kJumpInstType || gr->_end->_type == kJumpRelInstType) && out_degree(*v, _g) == 1) {
+		if (gr->_type == kNormalGroupType && ((*gr->_end)->_type == kJumpInstType || (*gr->_end)->_type == kJumpRelInstType) && out_degree(*v, _g) == 1) {
 			OutEdgeIterator oe = boost::out_edges(*v, _g).first;
 			GraphVertex target = boost::target(*oe, _g);
 			GroupPtr targetGr = GET(target);
@@ -473,7 +473,7 @@
 					if (targetGr->_type == kWhileCondGroupType && GET(boost::target(*toe, _g)) == gr->_next)
 						isContinue = false;
 					// ...or the instruction is placed after all jump targets from condition
-					if (GET(boost::target(*toe, _g))->_start->_address > gr->_start->_address)
+					if ((*GET(boost::target(*toe, _g))->_start)->_address > (*gr->_start)->_address)
 						afterJumpTargets = false;
 				}
 				if (afterJumpTargets)
@@ -506,14 +506,14 @@
 				GraphVertex vValidate = boost::target(*oeValidate, _g);
 				GroupPtr gValidate = GET(vValidate);
 				// For all other loops of same type found in range, all targets must fall within that range
-				if (gValidate->_start->_address < from->_start->_address || gValidate->_start->_address > to->_start->_address )
+				if ((*gValidate->_start)->_address < (*from->_start)->_address || (*gValidate->_start)->_address > (*to->_start)->_address )
 					return false;
 
 				InEdgeRange ierValidate = boost::in_edges(vValidate, _g);
 				for (InEdgeIterator ieValidate = ierValidate.first; ieValidate != ierValidate.second; ++ieValidate) {
 					GroupPtr igValidate = GET(boost::source(*ieValidate, _g));
 					// All loops of other type going into range must be placed within range
-					if (igValidate->_type == ogt && (igValidate->_start->_address < from->_start->_address || igValidate->_start->_address > to->_start->_address ))
+					if (igValidate->_type == ogt && ((*igValidate->_start)->_address < (*from->_start)->_address || (*igValidate->_start)->_address > (*to->_start)->_address ))
 					return false;
 				}
 			}
@@ -527,7 +527,7 @@
 	for (VertexIterator v = vr.first; v != vr.second; ++v) {
 		GroupPtr gr = GET(*v);
 		// if: Undetermined block with conditional jump
-		if (gr->_type == kNormalGroupType && (gr->_end->_type == kCondJumpInstType || gr->_end->_type == kCondJumpRelInstType)) {
+		if (gr->_type == kNormalGroupType && ((*gr->_end)->_type == kCondJumpInstType || (*gr->_end)->_type == kCondJumpRelInstType)) {
 			gr->_type = kIfCondGroupType;
 		}
 	}
@@ -545,22 +545,22 @@
 			// Find jump target
 			for (OutEdgeIterator oe = oer.first; oe != oer.second; ++oe) {
 				targetGr = GET(boost::target(*oe, _g));
-				if (targetGr->_start->_address > maxAddress) {
+				if ((*targetGr->_start)->_address > maxAddress) {
 					target = boost::target(*oe, _g);
-					maxAddress = targetGr->_start->_address;
+					maxAddress = (*targetGr->_start)->_address;
 				}
 			}
 			targetGr = GET(target);
 			// else: Jump target of if immediately preceded by an unconditional jump...
-			if (targetGr->_prev->_end->_type != kJumpInstType && targetGr->_prev->_end->_type != kJumpRelInstType)
+			if ((*targetGr->_prev->_end)->_type != kJumpInstType && (*targetGr->_prev->_end)->_type != kJumpRelInstType)
 				continue;
 			// ...which is not a break or a continue...
 			if (targetGr->_prev->_type == kContinueGroupType || targetGr->_prev->_type == kBreakGroupType)
 				continue;
 			// ...to later in the code
-			OutEdgeIterator toe = boost::out_edges(find(targetGr->_prev->_start->_address), _g).first;
+			OutEdgeIterator toe = boost::out_edges(find((*targetGr->_prev->_start)->_address), _g).first;
 			GroupPtr targetTargetGr = GET(boost::target(*toe, _g));
-			if (targetTargetGr->_start->_address > targetGr->_end->_address) {
+			if ((*targetTargetGr->_start)->_address > (*targetGr->_end)->_address) {
 				if (validateElseBlock(gr, targetGr, targetTargetGr)) {
 					targetGr->_startElse = true;
 					targetTargetGr->_prev->_endElse.push_back(targetGr.get());
@@ -579,7 +579,7 @@
 				GraphVertex target = boost::target(*oe, _g);
 				GroupPtr targetGr = GET(target);
 				// Each edge from condition must not leave the range [start, end]
-				if (start->_start->_address > targetGr->_start->_address || targetGr->_start->_address > end->_start->_address)
+				if ((*start->_start)->_address > (*targetGr->_start)->_address || (*targetGr->_start)->_address > (*end->_start)->_address)
 					return false;
 			}
 		}
@@ -587,12 +587,12 @@
 		// If previous group ends an else, that else must start inside the range
 		for (ElseEndIterator it = cursor->_prev->_endElse.begin(); it != cursor->_prev->_endElse.end(); ++it)
 		{
-			if ((*it)->_start->_address < start->_start->_address)
+			if ((*(*it)->_start)->_address < (*start->_start)->_address)
 				return false;
 		}
 
 		// Unless group is a simple unconditional jump...
-		if (cursor->_start->_type == kJumpInstType || cursor->_start->_type == kJumpRelInstType)
+		if ((*cursor->_start)->_type == kJumpInstType || (*cursor->_start)->_type == kJumpRelInstType)
 			continue;
 
 		// ...validate ingoing edges
@@ -604,9 +604,9 @@
 			// Edges going to conditions...
 			if (sourceGr->_type == kIfCondGroupType || sourceGr->_type == kWhileCondGroupType || sourceGr->_type == kDoWhileCondGroupType) {
 				// ...must not come from outside the range [start, end]...
-				if (start->_start->_address > sourceGr->_start->_address || sourceGr->_start->_address > end->_start->_address) {
+				if ((*start->_start)->_address > (*sourceGr->_start)->_address || (*sourceGr->_start)->_address > (*end->_start)->_address) {
 					// ...unless source is simple unconditional jump...
-					if (sourceGr->_start->_type == kJumpInstType || sourceGr->_start->_type == kJumpRelInstType)
+					if ((*sourceGr->_start)->_type == kJumpInstType || (*sourceGr->_start)->_type == kJumpRelInstType)
 						continue;
 					// ...or the edge is from the if condition associated with this else
 					if (ifGroup == sourceGr)

Modified: tools/branches/gsoc2010-decompiler/decompiler/control_flow.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/control_flow.h	2010-12-11 23:51:50 UTC (rev 54872)
+++ tools/branches/gsoc2010-decompiler/decompiler/control_flow.h	2010-12-12 00:15:52 UTC (rev 54873)
@@ -41,7 +41,7 @@
 	 *
 	 * @param inst The instruction to find the vertex for.
 	 */
-	GraphVertex find(const Instruction &inst);
+	GraphVertex find(const InstPtr inst);
 
 	/**
 	 * Finds a graph vertex through an instruction iterator.

Modified: tools/branches/gsoc2010-decompiler/decompiler/engine.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/engine.h	2010-12-11 23:51:50 UTC (rev 54872)
+++ tools/branches/gsoc2010-decompiler/decompiler/engine.h	2010-12-12 00:15:52 UTC (rev 54873)
@@ -84,7 +84,7 @@
 	 * @param inst Instruction to decode.
 	 * @return The destination address of the jump instruction.
 	 */
-	virtual uint32 getDestAddress(const Instruction &inst) const = 0;
+	virtual uint32 getDestAddress(const InstPtr inst) const = 0;
 
 	/**
 	 * Decode a jump instruction to get the destination address.

Modified: tools/branches/gsoc2010-decompiler/decompiler/graph.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/graph.h	2010-12-11 23:51:50 UTC (rev 54872)
+++ tools/branches/gsoc2010-decompiler/decompiler/graph.h	2010-12-12 00:15:52 UTC (rev 54873)
@@ -301,19 +301,19 @@
 		if (group->_startElse)
 			output << "Start of else\\n";
 		for (ElseEndIterator it = group->_endElse.begin(); it != group->_endElse.end(); ++it) {
-			output << boost::format("End of else at %08x\\n") % (*it)->_start->_address;
+			output << boost::format("End of else at %08x\\n") % (*(*it)->_start)->_address;
 		}
 		output << "|";
 		ConstInstIterator inst = group->_start;
 		do {
-			output << boost::format("%08x: %s") % inst->_address % inst->_name;
+			output << boost::format("%08x: %s") % (*inst)->_address % (*inst)->_name;
 			std::vector<Parameter>::const_iterator param;
-			for (param = inst->_params.begin(); param != inst->_params.end(); ++param) {
-				if (param != inst->_params.begin())
+			for (param = (*inst)->_params.begin(); param != (*inst)->_params.end(); ++param) {
+				if (param != (*inst)->_params.begin())
 					output << ",";
 				output << " ";
 				if (param->_type != kStringParamType) {
-					if (inst->_type == kCondJumpInstType || inst->_type == kCondJumpRelInstType || inst->_type == kJumpInstType || inst->_type == kJumpRelInstType || inst->_type == kCallInstType) {
+					if ((*inst)->_type == kCondJumpInstType || (*inst)->_type == kCondJumpRelInstType || (*inst)->_type == kJumpInstType || (*inst)->_type == kJumpRelInstType || (*inst)->_type == kCallInstType) {
 						// Output numerical arguments to jumps in hexadecimal
 						switch (param->_type) {
 						case kSByteParamType:
@@ -347,7 +347,7 @@
 							output << *it;
 				}
 			}
-			output << boost::format(" (%d)") % inst->_stackChange << "\\n";
+			output << boost::format(" (%d)") % (*inst)->_stackChange << "\\n";
 		} while (inst++ != group->_end);
 		output << "}";
 		return output;

Modified: tools/branches/gsoc2010-decompiler/decompiler/instruction.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/instruction.h	2010-12-11 23:51:50 UTC (rev 54872)
+++ tools/branches/gsoc2010-decompiler/decompiler/instruction.h	2010-12-12 00:15:52 UTC (rev 54873)
@@ -26,9 +26,11 @@
 #include <string>
 #include <vector>
 #include <boost/format.hpp>
+#include <boost/intrusive_ptr.hpp>
 #include <boost/variant.hpp>
 
 #include "common/scummsys.h"
+#include "refcounted.h"
 
 /**
  * Enumeration for categorizing the different kinds of instructions.
@@ -102,7 +104,7 @@
 /**
  * Structure for representing an instruction.
  */
-struct Instruction {
+struct Instruction : public RefCounted {
 	uint32 _opcode;                 ///< The instruction opcode.
 	uint32 _address;                ///< The instruction address.
 	std::string _name;              ///< The instruction name (opcode name).
@@ -116,12 +118,23 @@
 		_opcode(opcode), _address(address), _name(name), _type(type), _stackChange(stackChange) {}
 
 	/**
-	 * Operator overload to output a vector to a std::ostream.
+	 * Operator overload to output an Instruction to a std::ostream.
 	 *
 	 * @param output The std::ostream to output to.
 	 * @param inst   The Instruction to output.
 	 * @return The std::ostream used for output.
 	 */
+	friend std::ostream &operator<<(std::ostream &output, const Instruction *inst) {
+		return output << *inst;
+	}
+
+	/**
+	 * Operator overload to output an Instruction to a std::ostream.
+	 *
+	 * @param output The std::ostream to output to.
+	 * @param inst   The Instruction to output.
+	 * @return The std::ostream used for output.
+	 */
 	friend std::ostream &operator<<(std::ostream &output, const Instruction &inst) {
 		output << boost::format("%08x: %s") % inst._address % inst._name;
 		std::vector<Parameter>::const_iterator param;
@@ -154,17 +167,22 @@
 };
 
 /**
- * Type representing a vector of Instructions.
+ * Pointer to an Instruction.
  */
-typedef std::vector<Instruction> InstVec;
+typedef boost::intrusive_ptr<Instruction> InstPtr;
 
 /**
- * Type representing an iterator over Instructions.
+ * Type representing a vector of InstPtrs.
  */
+typedef std::vector<InstPtr> InstVec;
+
+/**
+ * Type representing an iterator over InstPtrs.
+ */
 typedef InstVec::iterator InstIterator;
 
 /**
- * Type representing a const_iterator over Instructions.
+ * Type representing a const_iterator over InstPtrs.
  */
 typedef InstVec::const_iterator ConstInstIterator;
 

Modified: tools/branches/gsoc2010-decompiler/decompiler/kyra/codegen.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/kyra/codegen.cpp	2010-12-11 23:51:50 UTC (rev 54872)
+++ tools/branches/gsoc2010-decompiler/decompiler/kyra/codegen.cpp	2010-12-12 00:15:52 UTC (rev 54873)
@@ -35,44 +35,44 @@
 	return s.str();
 }
 
-void Kyra::Kyra2CodeGenerator::processInst(const Instruction inst) {
-	switch (inst._type) {
+void Kyra::Kyra2CodeGenerator::processInst(const InstPtr inst) {
+	switch (inst->_type) {
 	case kLoadInstType:
-		switch (inst._opcode) {
+		switch (inst->_opcode) {
 		case 2:
 			// If something has been called previously in this group, don't output retval variable
-			if (inst._address <= findFirstCall()._address)
+			if (inst->_address <= findFirstCall()->_address)
 				_stack.push(new VarEntry("retval"));
 			break;
 		case 3:
 		case 4:
-			_stack.push(new IntEntry(inst._params[0].getSigned(), true));
+			_stack.push(new IntEntry(inst->_params[0].getSigned(), true));
 			break;
 		case 5:
 			{
 				std::stringstream s;
-				s << boost::format("var%d") % inst._params[0].getSigned();
+				s << boost::format("var%d") % inst->_params[0].getSigned();
 				_stack.push(new VarEntry(s.str()));
 			}
 			break;
 		case 6:
 			{
 				std::stringstream s;
-				s << boost::format("localvar%d") % inst._params[0].getSigned();
+				s << boost::format("localvar%d") % inst->_params[0].getSigned();
 				_stack.push(new VarEntry(s.str()));
 			}
 			break;
 		case 7:
 			{
 				std::stringstream s;
-				s << boost::format("param%d") % inst._params[0].getSigned();
+				s << boost::format("param%d") % inst->_params[0].getSigned();
 				_stack.push(new VarEntry(s.str()));
 			}
 			break;
 		}
 		break;
 	case kStoreInstType:
-		switch (inst._opcode) {
+		switch (inst->_opcode) {
 		case 8:
 			{
 				EntryPtr p = new VarEntry("retval");
@@ -82,7 +82,7 @@
 		case 9:
 			{
 				std::stringstream s;
-				s << boost::format("var%d") % inst._params[0].getSigned();
+				s << boost::format("var%d") % inst->_params[0].getSigned();
 				EntryPtr p = new VarEntry(s.str());
 				writeAssignment(p, _stack.pop());
 			}
@@ -90,7 +90,7 @@
 		case 10:
 			{
 				std::stringstream s;
-				s << boost::format("localvar%d") % inst._params[0].getSigned();
+				s << boost::format("localvar%d") % inst->_params[0].getSigned();
 				EntryPtr p = new VarEntry(s.str());
 				writeAssignment(p, _stack.pop());
 			}
@@ -98,7 +98,7 @@
 		case 11:
 			{
 				std::stringstream s;
-				s << boost::format("param%d") % inst._params[0].getSigned();
+				s << boost::format("param%d") % inst->_params[0].getSigned();
 				EntryPtr p = new VarEntry(s.str());
 				writeAssignment(p, _stack.pop());
 			}
@@ -106,13 +106,13 @@
 		}
 		break;
 	case kStackInstType:
-		if (inst._opcode == 12) {
-			for (int i = inst._params[0].getSigned(); i != 0; --i) {
+		if (inst->_opcode == 12) {
+			for (int i = inst->_params[0].getSigned(); i != 0; --i) {
 				if (!_stack.empty())
 					_stack.pop();
 			}
-		} else if (inst._opcode == 13) {
-			for (int i = 0; i != inst._params[0].getSigned(); ++i) {
+		} else if (inst->_opcode == 13) {
+			for (int i = 0; i != inst->_params[0].getSigned(); ++i) {
 				std::stringstream s;
 				s << boost::format("localvar%d") % i;
 				_stack.push(new VarEntry(s.str()));
@@ -130,7 +130,7 @@
 		default:
 			{
 				std::stringstream s;
-				s << boost::format("WARNING: Couldn't handle conditional jump at address %08X") % inst._address;
+				s << boost::format("WARNING: Couldn't handle conditional jump at address %08X") % inst->_address;
 				addOutputLine(s.str());
 			}
 			return;
@@ -140,12 +140,12 @@
 	case kCallInstType:
 		{
 			_argList.clear();
-			Function f = _engine->_functions.find(inst._params[0].getUnsigned())->second;
+			Function f = _engine->_functions.find(inst->_params[0].getUnsigned())->second;
 			for (size_t i = 0; i < f._metadata.length(); i++)
 				processSpecialMetadata(inst, f._metadata[i], i);
 			_stack.push(new CallEntry(f._name, _argList));
 			// Leave call on stack if this is a condition, or other calls follow in same group
-			if (_curGroup->_type == kIfCondGroupType || _curGroup->_type == kWhileCondGroupType || _curGroup->_type == kDoWhileCondGroupType || inst._address != findLastCall()._address) {
+			if (_curGroup->_type == kIfCondGroupType || _curGroup->_type == kWhileCondGroupType || _curGroup->_type == kDoWhileCondGroupType || inst->_address != findLastCall()->_address) {
 				break;
 			}	else if (!f._retVal) {
 				std::stringstream stream;
@@ -159,16 +159,16 @@
 		}
 	case kSpecialCallInstType:
 		{
-			if (inst._opcode != 14)
+			if (inst->_opcode != 14)
 				return;
 			_argList.clear();
-			bool returnsValue = (inst._codeGenData.find("r") == 0);
-			std::string metadata = (!returnsValue ? inst._codeGenData : inst._codeGenData.substr(1));
+			bool returnsValue = (inst->_codeGenData.find("r") == 0);
+			std::string metadata = (!returnsValue ? inst->_codeGenData : inst->_codeGenData.substr(1));
 			for (size_t i = 0; i < metadata.length(); i++)
 				processSpecialMetadata(inst, metadata[i], i);
-			_stack.push(new CallEntry(inst._name, _argList));
+			_stack.push(new CallEntry(inst->_name, _argList));
 			// Leave call on stack if this is a condition, or other calls follow in same group
-			if (_curGroup->_type == kIfCondGroupType || _curGroup->_type == kWhileCondGroupType || _curGroup->_type == kDoWhileCondGroupType || inst._address != findLastCall()._address) {
+			if (_curGroup->_type == kIfCondGroupType || _curGroup->_type == kWhileCondGroupType || _curGroup->_type == kDoWhileCondGroupType || inst->_address != findLastCall()->_address) {
 				break;
 			}	else if (!returnsValue) {
 				std::stringstream stream;
@@ -181,32 +181,32 @@
 			break;
 		}
 	default:
-		CodeGenerator::processInst(inst);	
+		CodeGenerator::processInst(inst);
 		break;
 	}
 }
 
-const Instruction &Kyra::Kyra2CodeGenerator::findFirstCall() {
+const InstPtr Kyra::Kyra2CodeGenerator::findFirstCall() {
 	ConstInstIterator it = _curGroup->_start;
 	do {
-		if (it->_type == kCallInstType || (it->_type == kSpecialCallInstType && it->_opcode == 14))
+		if ((*it)->_type == kCallInstType || ((*it)->_type == kSpecialCallInstType && (*it)->_opcode == 14))
 			return *it;
 	} while (it++ != _curGroup->_end);
 
 	return *_curGroup->_start;
 }
 
-const Instruction &Kyra::Kyra2CodeGenerator::findLastCall() {
+const InstPtr Kyra::Kyra2CodeGenerator::findLastCall() {
 	ConstInstIterator it = _curGroup->_end;
 	do {
-		if (it->_type == kCallInstType || (it->_type == kSpecialCallInstType && it->_opcode == 14))
+		if ((*it)->_type == kCallInstType || ((*it)->_type == kSpecialCallInstType && (*it)->_opcode == 14))
 			return *it;
 	} while (it-- != _curGroup->_start);
 
 	return *_curGroup->_end;
 }
 
-void Kyra::Kyra2CodeGenerator::processSpecialMetadata(const Instruction &inst, char c, int pos) {
+void Kyra::Kyra2CodeGenerator::processSpecialMetadata(const InstPtr inst, char c, int pos) {
 	switch (c) {
 	case 'p':
 		addArg(_stack.peekPos(pos));

Modified: tools/branches/gsoc2010-decompiler/decompiler/kyra/codegen.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/kyra/codegen.h	2010-12-11 23:51:50 UTC (rev 54872)
+++ tools/branches/gsoc2010-decompiler/decompiler/kyra/codegen.h	2010-12-12 00:15:52 UTC (rev 54873)
@@ -39,7 +39,7 @@
 	 *
 	 * @return The first call instruction in the current group. If no calls are found, returns the first instruction.
 	 */
-	const Instruction &findFirstCall();
+	const InstPtr findFirstCall();
 
 	/**
 	 * Finds the last call instruction in the current group and returns it.
@@ -48,7 +48,7 @@
 	 *
 	 * @return The last call instruction in the current group. If no calls are found, returns the last instruction.
 	 */
-	const Instruction &findLastCall();
+	const InstPtr findLastCall();
 public:
 	/**
 	 * Constructor for Kyra2CodeGenerator.
@@ -58,8 +58,8 @@
 	 */
 	Kyra2CodeGenerator(Engine *engine, std::ostream &output) : CodeGenerator(engine, output, kFIFOArgOrder, kLIFOArgOrder) {}
 protected:
-	void processInst(const Instruction inst);
-	virtual void processSpecialMetadata(const Instruction &inst, char c, int pos);
+	void processInst(const InstPtr inst);
+	virtual void processSpecialMetadata(const InstPtr inst, char c, int pos);
 	std::string constructFuncSignature(const Function &func);
 };
 

Modified: tools/branches/gsoc2010-decompiler/decompiler/kyra/disassembler.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/kyra/disassembler.cpp	2010-12-11 23:51:50 UTC (rev 54872)
+++ tools/branches/gsoc2010-decompiler/decompiler/kyra/disassembler.cpp	2010-12-12 00:15:52 UTC (rev 54873)
@@ -388,16 +388,16 @@
 			parameter = 0;
 		}
 
-#define ADD_INST _insts.insert(_insts.end(), Instruction());
+#define ADD_INST _insts.insert(_insts.end(), new Instruction());
 #define LAST_INST (_insts.back())
 #define OPCODE_MD(name, category, stackChange, hasParam, isSigned, codeGenData) \
 		ADD_INST; \
-		LAST_INST._opcode = opcode; \
-		LAST_INST._address = address; \
-		LAST_INST._stackChange = stackChange; \
-		LAST_INST._name = name; \
-		LAST_INST._type = category; \
-		LAST_INST._codeGenData = codeGenData; \
+		LAST_INST->_opcode = opcode; \
+		LAST_INST->_address = address; \
+		LAST_INST->_stackChange = stackChange; \
+		LAST_INST->_name = name; \
+		LAST_INST->_type = category; \
+		LAST_INST->_codeGenData = codeGenData; \
 		if (hasParam) { \
 			Parameter p; \
 			if (isSigned) { \
@@ -407,7 +407,7 @@
 				p._type = kUShortParamType; \
 				p._value = (uint32)parameter; \
 			} \
-			LAST_INST._params.push_back(p);\
+			LAST_INST->_params.push_back(p);\
 		}
 #define OPCODE(name, category, stackChange, hasParam, isSigned) OPCODE_MD(name, category, stackChange, hasParam, isSigned, "");
 
@@ -573,7 +573,7 @@
 	std::map<uint16, InstIterator> addrMap;
 
 	for (InstIterator it = _insts.begin(); it != _insts.end(); ++it)
-		addrMap[it->_address] = it;
+		addrMap[(*it)->_address] = it;
 
 	std::sort(funcAddrs.begin(), funcAddrs.end());
 	// We only have the entry points, but the end points are not known, so create placeholder function entries
@@ -585,12 +585,12 @@
 	// Correct jumps to functions so they're treated as calls
 	bool lastWasPushPos = false;
 	for (InstIterator it = _insts.begin(); it != _insts.end(); ++it) {
-		if (it->_type == kJumpInstType || it->_type == kCondJumpInstType) {
-			if (lastWasPushPos || _engine->_functions.find(it->_params[0].getUnsigned()) != _engine->_functions.end()) {
-				it->_type = kCallInstType;
+		if ((*it)->_type == kJumpInstType || (*it)->_type == kCondJumpInstType) {
+			if (lastWasPushPos || _engine->_functions.find((*it)->_params[0].getUnsigned()) != _engine->_functions.end()) {
+				(*it)->_type = kCallInstType;
 			}
 		}
-		lastWasPushPos = (it->_name.compare("pushPos") == 0);
+		lastWasPushPos = ((*it)->_name.compare("pushPos") == 0);
 	}
 }
 

Modified: tools/branches/gsoc2010-decompiler/decompiler/kyra/engine.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/kyra/engine.cpp	2010-12-11 23:51:50 UTC (rev 54872)
+++ tools/branches/gsoc2010-decompiler/decompiler/kyra/engine.cpp	2010-12-12 00:15:52 UTC (rev 54873)
@@ -32,8 +32,8 @@
 	return new Kyra2Disassembler(this, insts);
 }
 
-uint32 Kyra::Kyra2Engine::getDestAddress(const Instruction &inst) const {
-	return inst._params[0].getUnsigned();
+uint32 Kyra::Kyra2Engine::getDestAddress(const InstPtr inst) const {
+	return inst->_params[0].getUnsigned();
 }
 
 CodeGenerator *Kyra::Kyra2Engine::getCodeGenerator(std::ostream &output) {
@@ -44,13 +44,13 @@
 	// Add metadata to functions
 	for (FuncMap::iterator it = _functions.begin(); it != _functions.end(); ++it) {
 		std::stringstream s;
-		s << it->second._name << boost::format("sub0x%X") % it->second._startIt->_address;
+		s << it->second._name << boost::format("sub0x%X") % (*it->second._startIt)->_address;
 		it->second._name = s.str();
 		int maxArg = 0;
 		for (ConstInstIterator instIt = it->second._startIt; instIt != it->second._endIt; ++instIt) {
-			if (instIt->_name.compare("pushBPAdd") == 0) {
-				if (maxArg < instIt->_params[0].getSigned()) {
-					maxArg = instIt->_params[0].getSigned();
+			if ((*instIt)->_name.compare("pushBPAdd") == 0) {
+				if (maxArg < (*instIt)->_params[0].getSigned()) {
+					maxArg = (*instIt)->_params[0].getSigned();
 				}
 			}
 		}

Modified: tools/branches/gsoc2010-decompiler/decompiler/kyra/engine.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/kyra/engine.h	2010-12-11 23:51:50 UTC (rev 54872)
+++ tools/branches/gsoc2010-decompiler/decompiler/kyra/engine.h	2010-12-12 00:15:52 UTC (rev 54873)
@@ -36,7 +36,7 @@
 class Kyra2Engine : public Engine {
 public:
 	Disassembler *getDisassembler(InstVec &insts);
-	uint32 getDestAddress(const Instruction &inst) const;
+	uint32 getDestAddress(const InstPtr inst) const;
 	CodeGenerator *getCodeGenerator(std::ostream &output);
 	void postCFG(InstVec &insts, Graph g);
 	bool detectMoreFuncs() const;

Modified: tools/branches/gsoc2010-decompiler/decompiler/scummv6/codegen.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/scummv6/codegen.cpp	2010-12-11 23:51:50 UTC (rev 54872)
+++ tools/branches/gsoc2010-decompiler/decompiler/scummv6/codegen.cpp	2010-12-12 00:15:52 UTC (rev 54873)
@@ -34,30 +34,30 @@
 	return new ListEntry(list);
 }
 
-void Scumm::v6::Scummv6CodeGenerator::processInst(const Instruction inst) {
+void Scumm::v6::Scummv6CodeGenerator::processInst(const InstPtr inst) {
 	// This is just to keep some order in this code and have related
 	// opcodes near each other. It's not strictly necessary, because we
 	// can just look directly at the opcode, but this should be easier
 	// to read.
-	switch (inst._type) {
+	switch (inst->_type) {
 	case kLoadInstType:
-		switch (inst._opcode) {
+		switch (inst->_opcode) {
 		case 0x00: // pushByte
-			_stack.push(new IntEntry(inst._params[0].getUnsigned(), false));
+			_stack.push(new IntEntry(inst->_params[0].getUnsigned(), false));
 			break;
 		case 0x01: // pushWord
-			_stack.push(new IntEntry(inst._params[0].getSigned(), true));
+			_stack.push(new IntEntry(inst->_params[0].getSigned(), true));
 			break;
 		case 0x02: // pushByteVar
 		case 0x03: // pushWordVar
-			_stack.push(new VarEntry(decodeVarName(inst._params[0].getUnsigned())));
+			_stack.push(new VarEntry(decodeVarName(inst->_params[0].getUnsigned())));
 			break;
 		case 0x06: // byteArrayRead
 		case 0x07: // wordArrayRead
 			{
 				EntryList idxs;
 				idxs.push_front(_stack.pop());
-				_stack.push(new ArrayEntry(decodeArrayName(inst._params[0].getUnsigned()), idxs));
+				_stack.push(new ArrayEntry(decodeArrayName(inst->_params[0].getUnsigned()), idxs));
 				break;
 			}
 		case 0x0A: // byteArrayIndexedRead
@@ -66,17 +66,17 @@
 				EntryList idxs;
 				idxs.push_front(_stack.pop());
 				idxs.push_front(_stack.pop());
-				_stack.push(new ArrayEntry(decodeArrayName(inst._params[0].getUnsigned()), idxs));
+				_stack.push(new ArrayEntry(decodeArrayName(inst->_params[0].getUnsigned()), idxs));
 				break;
 			}
 		}
 		break;
 	case kStoreInstType:
-		switch (inst._opcode) {
+		switch (inst->_opcode) {
 			case 0x42: // writeByteVar
 			case 0x43: // writeWordVar
 				{
-					EntryPtr p = new VarEntry(decodeVarName(inst._params[0].getUnsigned()));
+					EntryPtr p = new VarEntry(decodeVarName(inst->_params[0].getUnsigned()));
 					writeAssignment(p, _stack.pop());
 				}
 				break;
@@ -86,7 +86,7 @@
 					EntryPtr value = _stack.pop();
 					EntryList idxs;
 					idxs.push_back(_stack.pop());
-					EntryPtr p = new ArrayEntry(decodeArrayName(inst._params[0].getUnsigned()), idxs);
+					EntryPtr p = new ArrayEntry(decodeArrayName(inst->_params[0].getUnsigned()), idxs);
 					writeAssignment(p, value);
 				}
 				break;
@@ -97,14 +97,14 @@
 					EntryList idxs;
 					idxs.push_front(_stack.pop());
 					idxs.push_front(_stack.pop());
-					EntryPtr p = new ArrayEntry(decodeArrayName(inst._params[0].getUnsigned()), idxs);
+					EntryPtr p = new ArrayEntry(decodeArrayName(inst->_params[0].getUnsigned()), idxs);
 					writeAssignment(p, value);
 				}
 				break;
 			default:
 				{
 					std::stringstream s;
-					s << boost::format("WARNING: Unknown opcode %X at address %08X") % inst._opcode % inst._address;
+					s << boost::format("WARNING: Unknown opcode %X at address %08X") % inst->_opcode % inst->_address;
 					addOutputLine(s.str());
 				}
 				break;
@@ -119,17 +119,17 @@
 		switch (_curGroup->_type) {
 		case kIfCondGroupType:
 		case kWhileCondGroupType:
-			if (inst._opcode == 0x5C) // jumpTrue
+			if (inst->_opcode == 0x5C) // jumpTrue
 				_stack.push(new UnaryOpEntry(_stack.pop(), "!", false));
 			break;
 		case kDoWhileCondGroupType:
-			if (inst._opcode == 0x5D) // jumpFalse
+			if (inst->_opcode == 0x5D) // jumpFalse
 				_stack.push(new UnaryOpEntry(_stack.pop(), "!", false));
 			break;
 		default:
 			{
 				std::stringstream s;
-				s << boost::format("WARNING: Couldn't handle conditional jump at address %08X") % inst._address;
+				s << boost::format("WARNING: Couldn't handle conditional jump at address %08X") % inst->_address;
 				addOutputLine(s.str());
 			}
 			return;
@@ -137,14 +137,14 @@
 		CodeGenerator::processInst(inst);
 		break;
 	case kUnaryOpPostInstType:
-		switch (inst._opcode) {
+		switch (inst->_opcode) {
 		case 0x4E: // byteVarInc
 		case 0x4F: // wordVarInc
 		case 0x56: // byteVarDec
 		case 0x57: // wordVarDec
 			{
 				std::stringstream s;
-				EntryPtr p = new UnaryOpEntry(new VarEntry(decodeVarName(inst._params[0].getUnsigned())), inst._codeGenData, true);
+				EntryPtr p = new UnaryOpEntry(new VarEntry(decodeVarName(inst->_params[0].getUnsigned())), inst->_codeGenData, true);
 				s << p << ";";
 				addOutputLine(s.str());
 			}
@@ -157,7 +157,7 @@
 				std::stringstream s;
 				EntryList idxs;
 				idxs.push_front(_stack.pop());
-				EntryPtr p = new UnaryOpEntry(new ArrayEntry(decodeVarName(inst._params[0].getUnsigned()), idxs), inst._codeGenData, true);
+				EntryPtr p = new UnaryOpEntry(new ArrayEntry(decodeVarName(inst->_params[0].getUnsigned()), idxs), inst->_codeGenData, true);
 				s << p << ";";
 				addOutputLine(s.str());
 			}
@@ -168,13 +168,13 @@
 		}
 		break;
 	case kSpecialCallInstType:
-		switch (inst._opcode) {
+		switch (inst->_opcode) {
 		case 0xA4CD: // arrayOp_assignString
 			{
-				EntryPtr value = new StringEntry(inst._params[1].getString());
+				EntryPtr value = new StringEntry(inst->_params[1].getString());
 				EntryList idxs;
 				idxs.push_front(_stack.pop());
-				EntryPtr p = new ArrayEntry(decodeArrayName(inst._params[0].getUnsigned()), idxs);
+				EntryPtr p = new ArrayEntry(decodeArrayName(inst->_params[0].getUnsigned()), idxs);
 				writeAssignment(p, value);
 			}
 			break;
@@ -183,7 +183,7 @@
 				EntryList idxs;
 				idxs.push_front(_stack.pop());
 				EntryPtr value = createListEntry();
-				EntryPtr p = new ArrayEntry(decodeArrayName(inst._params[0].getUnsigned()), idxs);
+				EntryPtr p = new ArrayEntry(decodeArrayName(inst->_params[0].getUnsigned()), idxs);
 				writeAssignment(p, value);
 			}
 
@@ -194,7 +194,7 @@
 				idxs.push_front(_stack.pop());
 				EntryPtr value = createListEntry();
 				idxs.push_front(_stack.pop());
-				EntryPtr p = new ArrayEntry(decodeArrayName(inst._params[0].getUnsigned()), idxs);
+				EntryPtr p = new ArrayEntry(decodeArrayName(inst->_params[0].getUnsigned()), idxs);
 				writeAssignment(p, value);
 			}
 
@@ -412,7 +412,7 @@
 	return s.str();
 }
 
-void Scumm::v6::Scummv6CodeGenerator::processSpecialMetadata(const Instruction &inst, char c, int pos) {
+void Scumm::v6::Scummv6CodeGenerator::processSpecialMetadata(const InstPtr inst, char c, int pos) {
 	switch (c) {
 	// All of these meanings are taken from descumm.
 	case 'l':
@@ -422,25 +422,25 @@
 	case 'w':
 	case 'j':
 	case 'i':
-		switch (inst._params[0]._type) {
+		switch (inst->_params[0]._type) {
 		case kSByteParamType:
 		case kShortParamType:
-			addArg(new IntEntry(inst._params[0].getSigned(), true));
+			addArg(new IntEntry(inst->_params[0].getSigned(), true));
 			break;
 		case kByteParamType:
 		case kUShortParamType:
-			addArg(new IntEntry(inst._params[0].getUnsigned(), false));
+			addArg(new IntEntry(inst->_params[0].getUnsigned(), false));
 			break;
 		default:
-			std::cerr << boost::format("WARNING: Unexpected type for parameter 0 @ %08X while processing metadata character %c") % inst._address % c;
+			std::cerr << boost::format("WARNING: Unexpected type for parameter 0 @ %08X while processing metadata character %c") % inst->_address % c;
 			break;
 		}
 		break;
 	case 'v':
-		addArg(new VarEntry(decodeVarName(inst._params[0].getUnsigned())));
+		addArg(new VarEntry(decodeVarName(inst->_params[0].getUnsigned())));
 		break;
 	case 's':
-		addArg(new StringEntry(inst._params[0].getString()));
+		addArg(new StringEntry(inst->_params[0].getString()));
 		break;
 	case 'z':
 		addArg(_stack.pop());

Modified: tools/branches/gsoc2010-decompiler/decompiler/scummv6/codegen.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/scummv6/codegen.h	2010-12-11 23:51:50 UTC (rev 54872)
+++ tools/branches/gsoc2010-decompiler/decompiler/scummv6/codegen.h	2010-12-12 00:15:52 UTC (rev 54873)
@@ -73,8 +73,8 @@
 	 */
 	Scummv6CodeGenerator(Engine *engine, std::ostream &output) : CodeGenerator(engine, output, kFIFOArgOrder, kFIFOArgOrder) {}
 protected:
-	void processInst(const Instruction inst);
-	virtual void processSpecialMetadata(const Instruction &inst, char c, int pos);
+	void processInst(const InstPtr inst);
+	virtual void processSpecialMetadata(const InstPtr inst, char c, int pos);
 };
 
 } // End of namespace v6

Modified: tools/branches/gsoc2010-decompiler/decompiler/scummv6/disassembler.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/scummv6/disassembler.cpp	2010-12-11 23:51:50 UTC (rev 54872)
+++ tools/branches/gsoc2010-decompiler/decompiler/scummv6/disassembler.cpp	2010-12-12 00:15:52 UTC (rev 54873)
@@ -439,17 +439,17 @@
 
 	InstIterator it;
 	for (it = _insts.begin(); it != _insts.end(); ++it)
-		if (it->_stackChange >= 0x1000)
-			fixStackEffect(it, (it->_stackChange >> 8) & 0xF, (it->_stackChange >> 4) & 0xF, it->_stackChange & 0xF);
+		if ((*it)->_stackChange >= 0x1000)
+			fixStackEffect(it, ((*it)->_stackChange >> 8) & 0xF, ((*it)->_stackChange >> 4) & 0xF, (*it)->_stackChange & 0xF);
 }
 
 void Scumm::v6::Scummv6Disassembler::fixStackEffect(InstIterator &it, int popBefore, int popAfter, int pushTotal) {
-	it->_stackChange = -popBefore - popAfter + pushTotal;
+	(*it)->_stackChange = -popBefore - popAfter + pushTotal;
 	InstIterator it2 = it;
 	for (--it2; popBefore != 0; --it2)
-		if (it2->_type == kLoadInstType)
+		if ((*it2)->_type == kLoadInstType)
 			--popBefore;
-	it->_stackChange -= it2->_params[0].getSigned() + 1;
+	(*it)->_stackChange -= (*it2)->_params[0].getSigned() + 1;
 }
 
 void Scumm::v6::Scummv6Disassembler::readParameter(Parameter *p, char type) {

Modified: tools/branches/gsoc2010-decompiler/decompiler/scummv6/engine.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/scummv6/engine.cpp	2010-12-11 23:51:50 UTC (rev 54872)
+++ tools/branches/gsoc2010-decompiler/decompiler/scummv6/engine.cpp	2010-12-12 00:15:52 UTC (rev 54873)
@@ -28,11 +28,11 @@
 	return new Scummv6Disassembler(insts);
 }
 
-uint32 Scumm::v6::Scummv6Engine::getDestAddress(const Instruction &inst) const {
-	switch(inst._type) {
+uint32 Scumm::v6::Scummv6Engine::getDestAddress(const InstPtr inst) const {
+	switch(inst->_type) {
 	case kJumpRelInstType:
 	case kCondJumpRelInstType:
-		return inst._params[0].getSigned() + inst._address + 3;
+		return inst->_params[0].getSigned() + inst->_address + 3;
 	default:
 		return 0;
 	}

Modified: tools/branches/gsoc2010-decompiler/decompiler/scummv6/engine.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/scummv6/engine.h	2010-12-11 23:51:50 UTC (rev 54872)
+++ tools/branches/gsoc2010-decompiler/decompiler/scummv6/engine.h	2010-12-12 00:15:52 UTC (rev 54873)
@@ -35,7 +35,7 @@
 class Scummv6Engine : public Engine {
 public:
 	Disassembler *getDisassembler(InstVec &insts);
-	uint32 getDestAddress(const Instruction &inst) const;
+	uint32 getDestAddress(const InstPtr inst) const;
 	CodeGenerator *getCodeGenerator(std::ostream &output);
 };
 

Modified: tools/branches/gsoc2010-decompiler/decompiler/simple_disassembler.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/simple_disassembler.cpp	2010-12-11 23:51:50 UTC (rev 54872)
+++ tools/branches/gsoc2010-decompiler/decompiler/simple_disassembler.cpp	2010-12-12 00:15:52 UTC (rev 54873)
@@ -25,11 +25,11 @@
 SimpleDisassembler::SimpleDisassembler(InstVec &insts) : Disassembler(insts) {
 }
 
-void SimpleDisassembler::readParams(Instruction &inst, const char *typeString) {
+void SimpleDisassembler::readParams(InstPtr inst, const char *typeString) {
 	while (*typeString) {
 		Parameter p;
 		readParameter(&p, *typeString);
-		inst._params.push_back(p);
+		inst->_params.push_back(p);
 		typeString++;
 	}
 }

Modified: tools/branches/gsoc2010-decompiler/decompiler/simple_disassembler.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/simple_disassembler.h	2010-12-11 23:51:50 UTC (rev 54872)
+++ tools/branches/gsoc2010-decompiler/decompiler/simple_disassembler.h	2010-12-12 00:15:52 UTC (rev 54873)
@@ -38,7 +38,7 @@
 	 * @param inst       The instruction to associate the parameters with.
 	 * @param typeString NUL-terminated string describing the type of each parameter.
 	 */
-	void readParams(Instruction &inst, const char *typeString);
+	void readParams(InstPtr inst, const char *typeString);
 
 	/**
 	 * Reads data for a single parameter.
@@ -58,7 +58,7 @@
 };
 
 #define INC_ADDR _address++;
-#define ADD_INST _insts.push_back(Instruction());
+#define ADD_INST _insts.push_back(new Instruction());
 #define LAST_INST (_insts.back())
 
 #define START_OPCODES \
@@ -83,12 +83,12 @@
 
 #define OPCODE_BODY(name, category, stackChange, params, codeGenData) \
 		ADD_INST; \
-		LAST_INST._opcode = full_opcode; \
-		LAST_INST._address = _address; \
-		LAST_INST._stackChange = stackChange; \
-		LAST_INST._name = opcodePrefix + std::string(name); \
-		LAST_INST._type = category; \
-		LAST_INST._codeGenData = codeGenData; \
+		LAST_INST->_opcode = full_opcode; \
+		LAST_INST->_address = _address; \
+		LAST_INST->_stackChange = stackChange; \
+		LAST_INST->_name = opcodePrefix + std::string(name); \
+		LAST_INST->_type = category; \
+		LAST_INST->_codeGenData = codeGenData; \
 		readParams(LAST_INST, params); \
 
 #define OPCODE_MD(val, name, category, stackChange, params, codeGenData) \

Modified: tools/branches/gsoc2010-decompiler/decompiler/test/cfg_test.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/test/cfg_test.h	2010-12-11 23:51:50 UTC (rev 54872)
+++ tools/branches/gsoc2010-decompiler/decompiler/test/cfg_test.h	2010-12-12 00:15:52 UTC (rev 54873)
@@ -46,7 +46,7 @@
 		VertexRange range = boost::vertices(g);
 		for (VertexIterator it = range.first; it != range.second; ++it) {
 			GroupPtr gr = GET(*it);
-			switch (gr->_start->_address) {
+			switch ((*gr->_start)->_address) {
 			case 0:
 				TS_ASSERT(boost::in_degree(*it, g) == 0 && boost::out_degree(*it, g) == 1);
 				break;
@@ -80,7 +80,7 @@
 		VertexRange range = boost::vertices(g);
 		for (VertexIterator it = range.first; it != range.second; ++it) {
 			GroupPtr gr = GET(*it);
-			switch (gr->_start->_address) {
+			switch ((*gr->_start)->_address) {
 			case 0:
 				TS_ASSERT(boost::in_degree(*it, g) == 0 && boost::out_degree(*it, g) == 1);
 				break;
@@ -115,9 +115,9 @@
 		VertexRange range = boost::vertices(g);
 		for (VertexIterator it = range.first; it != range.second; ++it) {
 			GroupPtr gr = GET(*it);
-			switch (gr->_start->_address) {
+			switch ((*gr->_start)->_address) {
 			case 0:
-				TS_ASSERT(gr->_end->_address == 2);
+				TS_ASSERT((*gr->_end)->_address == 2);
 				TS_ASSERT(boost::in_degree(*it, g) == 0 && boost::out_degree(*it, g) == 2);
 				break;
 			case 5:
@@ -163,7 +163,7 @@
 		VertexRange range = boost::vertices(g);
 		for (VertexIterator it = range.first; it != range.second; ++it) {
 			GroupPtr gr = GET(*it);
-			if (gr->_start->_address == 0)
+			if ((*gr->_start)->_address == 0)
 				TS_ASSERT(gr->_type == kWhileCondGroupType);
 		}
 		delete c;
@@ -183,7 +183,7 @@
 		VertexRange range = boost::vertices(g);
 		for (VertexIterator it = range.first; it != range.second; ++it) {
 			GroupPtr gr = GET(*it);
-			if (gr->_start->_address == 3)
+			if ((*gr->_start)->_address == 3)
 				TS_ASSERT(gr->_type == kDoWhileCondGroupType);
 		}
 		delete c;
@@ -203,7 +203,7 @@
 		VertexRange range = boost::vertices(g);
 		for (VertexIterator it = range.first; it != range.second; ++it) {
 			GroupPtr gr = GET(*it);
-			if (gr->_start->_address == 0x14)
+			if ((*gr->_start)->_address == 0x14)
 				TS_ASSERT(gr->_type == kBreakGroupType);
 		}
 		delete c;
@@ -221,7 +221,7 @@
 		range = boost::vertices(g);
 		for (VertexIterator it = range.first; it != range.second; ++it) {
 			GroupPtr gr = GET(*it);
-			if (gr->_start->_address == 0xA)
+			if ((*gr->_start)->_address == 0xA)
 				TS_ASSERT(gr->_type == kBreakGroupType);
 		}
 		delete c;
@@ -239,7 +239,7 @@
 		range = boost::vertices(g);
 		for (VertexIterator it = range.first; it != range.second; ++it) {
 			GroupPtr gr = GET(*it);
-			if (gr->_start->_address == 0xD)
+			if ((*gr->_start)->_address == 0xD)
 				TS_ASSERT(gr->_type == kBreakGroupType);
 		}
 		delete c;
@@ -259,9 +259,9 @@
 		VertexRange range = boost::vertices(g);
 		for (VertexIterator it = range.first; it != range.second; ++it) {
 			GroupPtr gr = GET(*it);
-			if (gr->_start->_address == 0x14)
+			if ((*gr->_start)->_address == 0x14)
 				TS_ASSERT(gr->_type == kContinueGroupType);
-			if (gr->_start->_address == 0x1a)
+			if ((*gr->_start)->_address == 0x1a)
 				TS_ASSERT(gr->_type == kNormalGroupType);
 		}
 		delete c;
@@ -279,7 +279,7 @@
 		range = boost::vertices(g);
 		for (VertexIterator it = range.first; it != range.second; ++it) {
 			GroupPtr gr = GET(*it);
-			if (gr->_start->_address == 0xA)
+			if ((*gr->_start)->_address == 0xA)
 				TS_ASSERT(gr->_type == kContinueGroupType);
 		}
 		delete c;
@@ -297,7 +297,7 @@
 		range = boost::vertices(g);
 		for (VertexIterator it = range.first; it != range.second; ++it) {
 			GroupPtr gr = GET(*it);
-			if (gr->_start->_address == 0xD)
+			if ((*gr->_start)->_address == 0xD)
 				TS_ASSERT(gr->_type == kContinueGroupType);
 		}
 		delete c;
@@ -317,7 +317,7 @@
 		VertexRange range = boost::vertices(g);
 		for (VertexIterator it = range.first; it != range.second; ++it) {
 			GroupPtr gr = GET(*it);
-			if (gr->_start->_address == 0x0)
+			if ((*gr->_start)->_address == 0x0)
 				TS_ASSERT(gr->_type == kIfCondGroupType);
 		}
 		delete c;
@@ -335,7 +335,7 @@
 		range = boost::vertices(g);
 		for (VertexIterator it = range.first; it != range.second; ++it) {
 			GroupPtr gr = GET(*it);
-			if (gr->_start->_address == 0x0)
+			if ((*gr->_start)->_address == 0x0)
 				TS_ASSERT(gr->_type == kIfCondGroupType);
 		}
 		delete c;
@@ -353,7 +353,7 @@
 		range = boost::vertices(g);
 		for (VertexIterator it = range.first; it != range.second; ++it) {
 			GroupPtr gr = GET(*it);
-			if (gr->_start->_address == 0x3)
+			if ((*gr->_start)->_address == 0x3)
 				TS_ASSERT(gr->_type == kIfCondGroupType);
 		}
 		delete c;
@@ -371,7 +371,7 @@
 		range = boost::vertices(g);
 		for (VertexIterator it = range.first; it != range.second; ++it) {
 			GroupPtr gr = GET(*it);
-			if (gr->_start->_address == 0x0)
+			if ((*gr->_start)->_address == 0x0)
 				TS_ASSERT(gr->_type == kIfCondGroupType);
 		}
 		delete c;
@@ -389,7 +389,7 @@
 		range = boost::vertices(g);
 		for (VertexIterator it = range.first; it != range.second; ++it) {
 			GroupPtr gr = GET(*it);
-			if (gr->_start->_address == 0x3)
+			if ((*gr->_start)->_address == 0x3)
 				TS_ASSERT(gr->_type == kIfCondGroupType);
 		}
 		delete c;
@@ -409,7 +409,7 @@
 		VertexRange range = boost::vertices(g);
 		for (VertexIterator it = range.first; it != range.second; ++it) {
 			GroupPtr gr = GET(*it);
-			if (gr->_start->_address == 0x10) {
+			if ((*gr->_start)->_address == 0x10) {
 				TS_ASSERT(gr->_startElse);
 				TS_ASSERT(gr->_endElse.size() == 1 && gr->_endElse[0] == gr);
 			}
@@ -429,7 +429,7 @@
 		range = boost::vertices(g);
 		for (VertexIterator it = range.first; it != range.second; ++it) {
 			GroupPtr gr = GET(*it);
-			if (gr->_start->_address == 0x0)
+			if ((*gr->_start)->_address == 0x0)
 				TS_ASSERT(gr->_type == kIfCondGroupType);
 			TS_ASSERT(!gr->_startElse);
 		}
@@ -451,9 +451,9 @@
 		VertexRange range = boost::vertices(g);
 		for (VertexIterator it = range.first; it != range.second; ++it) {
 			GroupPtr gr = GET(*it);
-			if (gr->_start->_address == 0x0)
+			if ((*gr->_start)->_address == 0x0)
 				TS_ASSERT(gr->_type == kWhileCondGroupType);
-			if (gr->_start->_address == 0xd)
+			if ((*gr->_start)->_address == 0xd)
 				TS_ASSERT(gr->_type == kDoWhileCondGroupType);
 		}
 		delete c;
@@ -471,9 +471,9 @@
 		range = boost::vertices(g);
 		for (VertexIterator it = range.first; it != range.second; ++it) {
 			GroupPtr gr = GET(*it);
-			if (gr->_start->_address == 0x6)
+			if ((*gr->_start)->_address == 0x6)
 				TS_ASSERT(gr->_type == kDoWhileCondGroupType);
-			if (gr->_start->_address == 0x10)
+			if ((*gr->_start)->_address == 0x10)
 				TS_ASSERT(gr->_type == kDoWhileCondGroupType);
 		}
 		delete c;
@@ -491,9 +491,9 @@
 		range = boost::vertices(g);
 		for (VertexIterator it = range.first; it != range.second; ++it) {
 			GroupPtr gr = GET(*it);
-			if (gr->_start->_address == 0x0)
+			if ((*gr->_start)->_address == 0x0)
 				TS_ASSERT(gr->_type == kWhileCondGroupType);
-			if (gr->_start->_address == 0xa)
+			if ((*gr->_start)->_address == 0xa)
 				TS_ASSERT(gr->_type == kWhileCondGroupType);
 		}
 		delete c;
@@ -511,9 +511,9 @@
 		range = boost::vertices(g);
 		for (VertexIterator it = range.first; it != range.second; ++it) {
 			GroupPtr gr = GET(*it);
-			if (gr->_start->_address == 0x0)
+			if ((*gr->_start)->_address == 0x0)
 				TS_ASSERT(gr->_type == kWhileCondGroupType);
-			if (gr->_start->_address == 0xd)
+			if ((*gr->_start)->_address == 0xd)
 				TS_ASSERT(gr->_type == kWhileCondGroupType);
 		}
 		delete c;
@@ -531,9 +531,9 @@
 		range = boost::vertices(g);
 		for (VertexIterator it = range.first; it != range.second; ++it) {
 			GroupPtr gr = GET(*it);
-			if (gr->_start->_address == 0x0)
+			if ((*gr->_start)->_address == 0x0)
 				TS_ASSERT(gr->_type == kWhileCondGroupType);
-			if (gr->_start->_address == 0x10)
+			if ((*gr->_start)->_address == 0x10)
 				TS_ASSERT(gr->_type == kDoWhileCondGroupType);
 		}
 		delete c;
@@ -551,9 +551,9 @@
 		range = boost::vertices(g);
 		for (VertexIterator it = range.first; it != range.second; ++it) {
 			GroupPtr gr = GET(*it);
-			if (gr->_start->_address == 0x3)
+			if ((*gr->_start)->_address == 0x3)
 				TS_ASSERT(gr->_type == kWhileCondGroupType);
-			if (gr->_start->_address == 0x13)
+			if ((*gr->_start)->_address == 0x13)
 				TS_ASSERT(gr->_type == kDoWhileCondGroupType);
 		}
 		delete c;
@@ -575,7 +575,7 @@
 		VertexRange range = boost::vertices(g);
 		for (VertexIterator it = range.first; it != range.second; ++it) {
 			GroupPtr gr = GET(*it);
-			switch (gr->_start->_address) {
+			switch ((*gr->_start)->_address) {
 			case 0x6:
 				TS_ASSERT(gr->_type == kWhileCondGroupType);
 				TS_ASSERT(!gr->_startElse);
@@ -595,7 +595,7 @@
 			case 0x8B:
 				TS_ASSERT(gr->_type == kNormalGroupType);
 				TS_ASSERT(gr->_startElse);
-				TS_ASSERT(gr->_endElse.size() == 1 && gr->_endElse[0]->_start->_address == 0x8B);
+				TS_ASSERT(gr->_endElse.size() == 1 && (*gr->_endElse[0]->_start)->_address == 0x8B);
 				break;
 			case 0x91:
 				TS_ASSERT(gr->_type == kNormalGroupType || gr->_type == kIfCondGroupType); // Allow inclusion of the pop instruction immediately before
@@ -605,7 +605,7 @@
 			case 0xA6:
 				TS_ASSERT(gr->_type == kNormalGroupType);
 				TS_ASSERT(!gr->_startElse);
-				TS_ASSERT(gr->_endElse.size() == 1 && gr->_endElse[0]->_start->_address == 0x91);
+				TS_ASSERT(gr->_endElse.size() == 1 && (*gr->_endElse[0]->_start)->_address == 0x91);
 				break;
 			default:
 				TS_ASSERT(gr->_type == kNormalGroupType);

Modified: tools/branches/gsoc2010-decompiler/decompiler/test/codegen.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/test/codegen.h	2010-12-11 23:51:50 UTC (rev 54872)
+++ tools/branches/gsoc2010-decompiler/decompiler/test/codegen.h	2010-12-12 00:15:52 UTC (rev 54873)
@@ -226,7 +226,7 @@
 		while (gr->_prev != NULL)
 			gr = gr->_prev;
 		// Find vertex to test
-		while (gr->_start->_address != 0x91)
+		while ((*gr->_start)->_address != 0x91)
 			gr = gr->_next;
 
 		TS_ASSERT(gr->_code.size() == 2);
@@ -255,7 +255,7 @@
 		while (gr->_prev != NULL)
 			gr = gr->_prev;
 		// Find vertex to test
-		while (gr->_start->_address != 0x191)
+		while ((*gr->_start)->_address != 0x191)
 			gr = gr->_next;
 
 		TS_ASSERT(gr->_code.size() == 1);
@@ -310,11 +310,11 @@
 			gr = gr->_prev;
 
 		// Find right starting node
-		while (gr->_start->_address != 0x278)
+		while ((*gr->_start)->_address != 0x278)
 			gr = gr->_next;
 
 		// Copy out all lines of code from function
-		while (gr->_start->_address <= 0x2DC) {
+		while ((*gr->_start)->_address <= 0x2DC) {
 			for (std::vector<CodeLine>::iterator it = gr->_code.begin(); it != gr->_code.end(); ++it) {
 				if (it->_line.compare("") != 0)
 					output.push_back(it->_line);

Modified: tools/branches/gsoc2010-decompiler/decompiler/test/disassembler_test.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/test/disassembler_test.h	2010-12-11 23:51:50 UTC (rev 54872)
+++ tools/branches/gsoc2010-decompiler/decompiler/test/disassembler_test.h	2010-12-12 00:15:52 UTC (rev 54873)
@@ -35,12 +35,12 @@
 			PasCDisassembler p(insts);
 			p.open("decompiler/test/hanoi20.pasb");
 			p.disassemble();
-			TS_ASSERT(insts[0]._address == 0);
-			TS_ASSERT(insts[0]._opcode == 0x00);
-			TS_ASSERT(insts[0]._name == "PUSH");
-			TS_ASSERT(insts[0]._stackChange == 0);
-			TS_ASSERT(insts[0]._params[0]._type == kIntParamType);
-			TS_ASSERT(insts[0]._params[0].getSigned() == 0x60);
+			TS_ASSERT(insts[0]->_address == 0);
+			TS_ASSERT(insts[0]->_opcode == 0x00);
+			TS_ASSERT(insts[0]->_name == "PUSH");
+			TS_ASSERT(insts[0]->_stackChange == 0);
+			TS_ASSERT(insts[0]->_params[0]._type == kIntParamType);
+			TS_ASSERT(insts[0]->_params[0].getSigned() == 0x60);
 		} catch (UnknownOpcodeException &uoe) {
 			printf("Exception message: %s\n", uoe.what());
 			TS_ASSERT(false);
@@ -56,8 +56,8 @@
 			SubOpcodeDisassembler s(insts);
 			s.open("decompiler/test/subopcode_test.bin");
 			s.disassemble();
-			TS_ASSERT(insts[0]._name == "FOO");
-			TS_ASSERT(insts[0]._opcode == 0xFFFF);
+			TS_ASSERT(insts[0]->_name == "FOO");
+			TS_ASSERT(insts[0]->_opcode == 0xFFFF);
 		} catch (...) {
 			TS_ASSERT(false);
 		}
@@ -86,47 +86,47 @@
 			s.open("decompiler/test/script-15.dmp");
 			s.disassemble();
 			TS_ASSERT(insts.size() == 11);
-			TS_ASSERT(insts[0]._address == 0);
-			TS_ASSERT(insts[0]._opcode == 0x03);
-			TS_ASSERT(insts[0]._name == "pushWordVar");
-			TS_ASSERT(insts[0]._params[0].getUnsigned() == 16384);
-			TS_ASSERT(insts[1]._address == 3);
-			TS_ASSERT(insts[1]._opcode == 0x43);
-			TS_ASSERT(insts[1]._name == "writeWordVar");
-			TS_ASSERT(insts[1]._params[0].getUnsigned() == 197);
-			TS_ASSERT(insts[2]._address == 6);
-			TS_ASSERT(insts[2]._opcode == 0x01);
-			TS_ASSERT(insts[2]._name == "pushWord");
-			TS_ASSERT(insts[2]._params[0].getSigned() == 0);
-			TS_ASSERT(insts[3]._address == 9);
-			TS_ASSERT(insts[3]._opcode == 0x01);
-			TS_ASSERT(insts[3]._name == "pushWord");
-			TS_ASSERT(insts[3]._params[0].getSigned() == 11);
-			TS_ASSERT(insts[4]._address == 12);
-			TS_ASSERT(insts[4]._opcode == 0x01);
-			TS_ASSERT(insts[4]._name == "pushWord");
-			TS_ASSERT(insts[4]._params[0].getSigned() == 0);
-			TS_ASSERT(insts[5]._address == 15);
-			TS_ASSERT(insts[5]._opcode == 0x5E);
-			TS_ASSERT(insts[5]._name == "startScript");
-			TS_ASSERT(insts[6]._address == 16);
-			TS_ASSERT(insts[6]._opcode == 0x01);
-			TS_ASSERT(insts[6]._name == "pushWord");
-			TS_ASSERT(insts[6]._params[0].getSigned() == 0);
-			TS_ASSERT(insts[7]._address == 19);
-			TS_ASSERT(insts[7]._opcode == 0x01);
-			TS_ASSERT(insts[7]._name == "pushWord");
-			TS_ASSERT(insts[7]._params[0].getSigned() == 14);
-			TS_ASSERT(insts[8]._address == 22);
-			TS_ASSERT(insts[8]._opcode == 0x01);
-			TS_ASSERT(insts[8]._name == "pushWord");
-			TS_ASSERT(insts[8]._params[0].getSigned() == 0);
-			TS_ASSERT(insts[9]._address == 25);
-			TS_ASSERT(insts[9]._opcode == 0x5E);
-			TS_ASSERT(insts[9]._name == "startScript");
-			TS_ASSERT(insts[10]._address == 26);
-			TS_ASSERT(insts[10]._opcode == 0x66);
-			TS_ASSERT(insts[10]._name == "stopObjectCodeB");
+			TS_ASSERT(insts[0]->_address == 0);
+			TS_ASSERT(insts[0]->_opcode == 0x03);
+			TS_ASSERT(insts[0]->_name == "pushWordVar");
+			TS_ASSERT(insts[0]->_params[0].getUnsigned() == 16384);
+			TS_ASSERT(insts[1]->_address == 3);
+			TS_ASSERT(insts[1]->_opcode == 0x43);
+			TS_ASSERT(insts[1]->_name == "writeWordVar");
+			TS_ASSERT(insts[1]->_params[0].getUnsigned() == 197);
+			TS_ASSERT(insts[2]->_address == 6);
+			TS_ASSERT(insts[2]->_opcode == 0x01);
+			TS_ASSERT(insts[2]->_name == "pushWord");
+			TS_ASSERT(insts[2]->_params[0].getSigned() == 0);
+			TS_ASSERT(insts[3]->_address == 9);
+			TS_ASSERT(insts[3]->_opcode == 0x01);
+			TS_ASSERT(insts[3]->_name == "pushWord");
+			TS_ASSERT(insts[3]->_params[0].getSigned() == 11);
+			TS_ASSERT(insts[4]->_address == 12);
+			TS_ASSERT(insts[4]->_opcode == 0x01);
+			TS_ASSERT(insts[4]->_name == "pushWord");
+			TS_ASSERT(insts[4]->_params[0].getSigned() == 0);
+			TS_ASSERT(insts[5]->_address == 15);
+			TS_ASSERT(insts[5]->_opcode == 0x5E);
+			TS_ASSERT(insts[5]->_name == "startScript");
+			TS_ASSERT(insts[6]->_address == 16);
+			TS_ASSERT(insts[6]->_opcode == 0x01);
+			TS_ASSERT(insts[6]->_name == "pushWord");
+			TS_ASSERT(insts[6]->_params[0].getSigned() == 0);
+			TS_ASSERT(insts[7]->_address == 19);
+			TS_ASSERT(insts[7]->_opcode == 0x01);
+			TS_ASSERT(insts[7]->_name == "pushWord");
+			TS_ASSERT(insts[7]->_params[0].getSigned() == 14);
+			TS_ASSERT(insts[8]->_address == 22);
+			TS_ASSERT(insts[8]->_opcode == 0x01);
+			TS_ASSERT(insts[8]->_name == "pushWord");
+			TS_ASSERT(insts[8]->_params[0].getSigned() == 0);
+			TS_ASSERT(insts[9]->_address == 25);
+			TS_ASSERT(insts[9]->_opcode == 0x5E);
+			TS_ASSERT(insts[9]->_name == "startScript");
+			TS_ASSERT(insts[10]->_address == 26);
+			TS_ASSERT(insts[10]->_opcode == 0x66);
+			TS_ASSERT(insts[10]->_name == "stopObjectCodeB");
 		} catch (...) {
 			TS_ASSERT(false);
 		}
@@ -141,25 +141,25 @@
 			s.open("decompiler/test/script-31.dmp");
 			s.disassemble();
 			TS_ASSERT(insts.size() == 5);
-			TS_ASSERT(insts[0]._address == 0);
-			TS_ASSERT(insts[0]._opcode == 0x01);
-			TS_ASSERT(insts[0]._name == "pushWord");
-			TS_ASSERT(insts[0]._params[0].getSigned() == 0);
-			TS_ASSERT(insts[1]._address == 3);
-			TS_ASSERT(insts[1]._opcode == 0x43);
-			TS_ASSERT(insts[1]._name == "writeWordVar");
-			TS_ASSERT(insts[1]._params[0].getUnsigned() == 180);
-			TS_ASSERT(insts[2]._address == 6);
-			TS_ASSERT(insts[2]._opcode == 0x01);
-			TS_ASSERT(insts[2]._name == "pushWord");
-			TS_ASSERT(insts[2]._params[0].getSigned() == 0);
-			TS_ASSERT(insts[3]._address == 9);
-			TS_ASSERT(insts[3]._opcode == 0x43);
-			TS_ASSERT(insts[3]._name == "writeWordVar");
-			TS_ASSERT(insts[3]._params[0].getUnsigned() == 181);
-			TS_ASSERT(insts[4]._address == 12);
-			TS_ASSERT(insts[4]._opcode == 0x66);
-			TS_ASSERT(insts[4]._name == "stopObjectCodeB");
+			TS_ASSERT(insts[0]->_address == 0);
+			TS_ASSERT(insts[0]->_opcode == 0x01);
+			TS_ASSERT(insts[0]->_name == "pushWord");
+			TS_ASSERT(insts[0]->_params[0].getSigned() == 0);
+			TS_ASSERT(insts[1]->_address == 3);
+			TS_ASSERT(insts[1]->_opcode == 0x43);
+			TS_ASSERT(insts[1]->_name == "writeWordVar");
+			TS_ASSERT(insts[1]->_params[0].getUnsigned() == 180);
+			TS_ASSERT(insts[2]->_address == 6);
+			TS_ASSERT(insts[2]->_opcode == 0x01);
+			TS_ASSERT(insts[2]->_name == "pushWord");
+			TS_ASSERT(insts[2]->_params[0].getSigned() == 0);
+			TS_ASSERT(insts[3]->_address == 9);
+			TS_ASSERT(insts[3]->_opcode == 0x43);
+			TS_ASSERT(insts[3]->_name == "writeWordVar");
+			TS_ASSERT(insts[3]->_params[0].getUnsigned() == 181);
+			TS_ASSERT(insts[4]->_address == 12);
+			TS_ASSERT(insts[4]->_opcode == 0x66);
+			TS_ASSERT(insts[4]->_name == "stopObjectCodeB");
 		} catch (...) {
 			TS_ASSERT(false);
 		}
@@ -174,44 +174,44 @@
 			s.open("decompiler/test/script-33.dmp");
 			s.disassemble();
 			TS_ASSERT(insts.size() == 10);
-			TS_ASSERT(insts[0]._address == 0);
-			TS_ASSERT(insts[0]._opcode == 0x01);
-			TS_ASSERT(insts[0]._name == "pushWord");
-			TS_ASSERT(insts[0]._params[0].getSigned() == 0);
-			TS_ASSERT(insts[1]._address == 3);
-			TS_ASSERT(insts[1]._opcode == 0x43);
-			TS_ASSERT(insts[1]._name == "writeWordVar");
-			TS_ASSERT(insts[1]._params[0].getUnsigned() == 71);
-			TS_ASSERT(insts[2]._address == 6);
-			TS_ASSERT(insts[2]._opcode == 0x03);
-			TS_ASSERT(insts[2]._name == "pushWordVar");
-			TS_ASSERT(insts[2]._params[0].getUnsigned() == 177);
-			TS_ASSERT(insts[3]._address == 9);
-			TS_ASSERT(insts[3]._opcode == 0x43);
-			TS_ASSERT(insts[3]._name == "writeWordVar");
-			TS_ASSERT(insts[3]._params[0].getUnsigned() == 173);
-			TS_ASSERT(insts[4]._address == 12);
-			TS_ASSERT(insts[4]._opcode == 0x01);
-			TS_ASSERT(insts[4]._name == "pushWord");
-			TS_ASSERT(insts[4]._params[0].getSigned() == 874);
-			TS_ASSERT(insts[5]._address == 15);
-			TS_ASSERT(insts[5]._opcode == 0x43);
-			TS_ASSERT(insts[5]._name == "writeWordVar");
-			TS_ASSERT(insts[5]._params[0].getUnsigned() == 177);
-			TS_ASSERT(insts[6]._address == 18);
-			TS_ASSERT(insts[6]._opcode == 0x03);
-			TS_ASSERT(insts[6]._name == "pushWordVar");
-			TS_ASSERT(insts[6]._params[0].getUnsigned() == 177);
-			TS_ASSERT(insts[7]._address == 21);
-			TS_ASSERT(insts[7]._opcode == 0x01);
-			TS_ASSERT(insts[7]._name == "pushWord");
-			TS_ASSERT(insts[7]._params[0].getSigned() == 93);
-			TS_ASSERT(insts[8]._address == 24);
-			TS_ASSERT(insts[8]._opcode == 0x6B99);
-			TS_ASSERT(insts[8]._name == "cursorCommand.setCursorImg");
-			TS_ASSERT(insts[9]._address == 26);
-			TS_ASSERT(insts[9]._opcode == 0x66);
-			TS_ASSERT(insts[9]._name == "stopObjectCodeB");
+			TS_ASSERT(insts[0]->_address == 0);
+			TS_ASSERT(insts[0]->_opcode == 0x01);
+			TS_ASSERT(insts[0]->_name == "pushWord");
+			TS_ASSERT(insts[0]->_params[0].getSigned() == 0);
+			TS_ASSERT(insts[1]->_address == 3);
+			TS_ASSERT(insts[1]->_opcode == 0x43);
+			TS_ASSERT(insts[1]->_name == "writeWordVar");
+			TS_ASSERT(insts[1]->_params[0].getUnsigned() == 71);
+			TS_ASSERT(insts[2]->_address == 6);
+			TS_ASSERT(insts[2]->_opcode == 0x03);
+			TS_ASSERT(insts[2]->_name == "pushWordVar");
+			TS_ASSERT(insts[2]->_params[0].getUnsigned() == 177);
+			TS_ASSERT(insts[3]->_address == 9);
+			TS_ASSERT(insts[3]->_opcode == 0x43);
+			TS_ASSERT(insts[3]->_name == "writeWordVar");
+			TS_ASSERT(insts[3]->_params[0].getUnsigned() == 173);
+			TS_ASSERT(insts[4]->_address == 12);
+			TS_ASSERT(insts[4]->_opcode == 0x01);
+			TS_ASSERT(insts[4]->_name == "pushWord");
+			TS_ASSERT(insts[4]->_params[0].getSigned() == 874);
+			TS_ASSERT(insts[5]->_address == 15);
+			TS_ASSERT(insts[5]->_opcode == 0x43);
+			TS_ASSERT(insts[5]->_name == "writeWordVar");
+			TS_ASSERT(insts[5]->_params[0].getUnsigned() == 177);
+			TS_ASSERT(insts[6]->_address == 18);
+			TS_ASSERT(insts[6]->_opcode == 0x03);
+			TS_ASSERT(insts[6]->_name == "pushWordVar");
+			TS_ASSERT(insts[6]->_params[0].getUnsigned() == 177);
+			TS_ASSERT(insts[7]->_address == 21);
+			TS_ASSERT(insts[7]->_opcode == 0x01);
+			TS_ASSERT(insts[7]->_name == "pushWord");
+			TS_ASSERT(insts[7]->_params[0].getSigned() == 93);
+			TS_ASSERT(insts[8]->_address == 24);
+			TS_ASSERT(insts[8]->_opcode == 0x6B99);
+			TS_ASSERT(insts[8]->_name == "cursorCommand.setCursorImg");
+			TS_ASSERT(insts[9]->_address == 26);
+			TS_ASSERT(insts[9]->_opcode == 0x66);
+			TS_ASSERT(insts[9]->_name == "stopObjectCodeB");
 		} catch (...) {
 			TS_ASSERT(false);
 		}
@@ -227,7 +227,7 @@
 			s.disassemble();
 			InstIterator it = insts.end();
 			it -= 8;
-			TS_ASSERT(it->_stackChange == -3);
+			TS_ASSERT((*it)->_stackChange == -3);
 		} catch (...) {
 			TS_ASSERT(false);
 		}
@@ -243,7 +243,7 @@
 			s.disassemble();
 			InstIterator it = insts.end();
 			it -= 3;
-			TS_ASSERT(it->_stackChange == -6);
+			TS_ASSERT((*it)->_stackChange == -6);
 		} catch (...) {
 			TS_ASSERT(false);
 		}
@@ -264,14 +264,14 @@
 			TS_ASSERT(insts.size() == 481);
 
 			//These scripts are far too big to check all instructions, so we just check a few different ones
-			TS_ASSERT(insts[16]._address == 0x20);
-			TS_ASSERT(insts[16]._opcode == 15);
-			TS_ASSERT(insts[16]._name == "ifNotJmp");
-			TS_ASSERT(insts[16]._stackChange == -1);
-			TS_ASSERT(insts[38]._address == 0x54);
-			TS_ASSERT(insts[38]._opcode == 14);
-			TS_ASSERT(insts[38]._name == "o1_setHandItem");
-			TS_ASSERT(insts[38]._stackChange == 0);
+			TS_ASSERT(insts[16]->_address == 0x20);
+			TS_ASSERT(insts[16]->_opcode == 15);
+			TS_ASSERT(insts[16]->_name == "ifNotJmp");
+			TS_ASSERT(insts[16]->_stackChange == -1);
+			TS_ASSERT(insts[38]->_address == 0x54);
+			TS_ASSERT(insts[38]->_opcode == 14);
+			TS_ASSERT(insts[38]->_name == "o1_setHandItem");
+			TS_ASSERT(insts[38]->_stackChange == 0);
 
 			delete s;
 		} catch (...) {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list