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

kjdf at users.sourceforge.net kjdf at users.sourceforge.net
Thu Jul 9 21:24:39 CEST 2009


Revision: 42313
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42313&view=rev
Author:   kjdf
Date:     2009-07-09 19:24:39 +0000 (Thu, 09 Jul 2009)

Log Message:
-----------
decompiler: renamed Block to Node

Modified Paths:
--------------
    tools/branches/gsoc2009-decompiler/decompiler/Makefile
    tools/branches/gsoc2009-decompiler/decompiler/decompiler.cpp
    tools/branches/gsoc2009-decompiler/decompiler/graph.cpp
    tools/branches/gsoc2009-decompiler/decompiler/graph.h
    tools/branches/gsoc2009-decompiler/decompiler/test/data_graph.h
    tools/branches/gsoc2009-decompiler/decompiler/test/test_graph_internal.h

Added Paths:
-----------
    tools/branches/gsoc2009-decompiler/decompiler/node.cpp
    tools/branches/gsoc2009-decompiler/decompiler/node.h

Removed Paths:
-------------
    tools/branches/gsoc2009-decompiler/decompiler/block.cpp
    tools/branches/gsoc2009-decompiler/decompiler/block.h

Modified: tools/branches/gsoc2009-decompiler/decompiler/Makefile
===================================================================
--- tools/branches/gsoc2009-decompiler/decompiler/Makefile	2009-07-09 18:03:09 UTC (rev 42312)
+++ tools/branches/gsoc2009-decompiler/decompiler/Makefile	2009-07-09 19:24:39 UTC (rev 42313)
@@ -68,7 +68,7 @@
 
 test:
 	cxxtest/cxxtestgen.pl --error-printer --abort-on-fail --have-eh -o test_runner.cpp test/test_*.h
-	g++ -g $(DEFINES) $(INCLUDES)  -Icxxtest -o test_runner test_runner.cpp graph.cpp misc.cpp block.cpp
+	g++ -g $(DEFINES) $(INCLUDES)  -Icxxtest -o test_runner test_runner.cpp graph.cpp misc.cpp node.cpp
 	rm test_runner.cpp
 	./test_runner
 
@@ -76,7 +76,7 @@
 .PHONY: all clean test
 
 
-decompiler$(EXEEXT): decompiler.o graph.o misc.o block.o
+decompiler$(EXEEXT): decompiler.o graph.o misc.o node.o
 	$(CXX) $(LDFLAGS) -o $@ $+ -lboost_program_options
 
 decompiler.o: instruction.h misc.h parser.h reader.h

Deleted: tools/branches/gsoc2009-decompiler/decompiler/block.cpp
===================================================================
--- tools/branches/gsoc2009-decompiler/decompiler/block.cpp	2009-07-09 18:03:09 UTC (rev 42312)
+++ tools/branches/gsoc2009-decompiler/decompiler/block.cpp	2009-07-09 19:24:39 UTC (rev 42313)
@@ -1,25 +0,0 @@
-#include "block.h"
-
-#include <boost/foreach.hpp>
-
-using namespace boost;
-using namespace std;
-
-#ifndef foreach
-#define foreach BOOST_FOREACH
-#endif
-
-
-Block::Block() : _interval(), _number(), _dominator(), _component() {
-}
-
-
-Block::~Block() {
-}
-
-string Block::toString() {
-	ostringstream ret;
-	foreach (Instruction *instruction, _instructions)
-		ret << instruction->toString();
-	return ret.str();
-}

Deleted: tools/branches/gsoc2009-decompiler/decompiler/block.h
===================================================================
--- tools/branches/gsoc2009-decompiler/decompiler/block.h	2009-07-09 18:03:09 UTC (rev 42312)
+++ tools/branches/gsoc2009-decompiler/decompiler/block.h	2009-07-09 19:24:39 UTC (rev 42313)
@@ -1,28 +0,0 @@
-#ifndef BLOCK_H
-#define BLOCK_H
-
-#include "instruction.h"
-
-#include <list>
-
-#include <boost/utility.hpp>
-
-
-struct Block : boost::noncopyable {
-
-	bool _visited;
-	Block *_dominator;       // immediate dominator
-	Block *_interval;        // header node of the interval this block belongs to
-	Block *_primitive;       // interval header of the graph from which this graph has been derived
-	Block *_component;
-	int _number;             // number in post-order
-	std::list<Block*> _in;
-	std::list<Block*> _out;
-	std::list<Instruction*> _instructions;
-
-	Block();
-	~Block();
-	std::string toString();
-};
-
-#endif

Modified: tools/branches/gsoc2009-decompiler/decompiler/decompiler.cpp
===================================================================
--- tools/branches/gsoc2009-decompiler/decompiler/decompiler.cpp	2009-07-09 18:03:09 UTC (rev 42312)
+++ tools/branches/gsoc2009-decompiler/decompiler/decompiler.cpp	2009-07-09 19:24:39 UTC (rev 42313)
@@ -54,23 +54,23 @@
 		exit(0);
 	}
 	ControlFlowGraph cfg;
-	cfg.addBlocksFromScript(script._instructions.begin(), script._instructions.end());
+	cfg.addNodesFromScript(script._instructions.begin(), script._instructions.end());
 	// TODO won't work with empty script
 	cfg.setEntry(script._instructions.front()->_addr);
 	if (vars.count("blocks")) {
-		foreach (Block *block, cfg._blocks)
-			cout << block->toString() << endl;
+		foreach (Node *node, cfg._nodes)
+			cout << node->toString() << endl;
 		exit(0);
 	}
 	if (!vars.count("no-remove-jumps"))
 		cfg.removeJumpsToJumps();
-	cfg.orderBlocks();
-	cfg.removeUnreachableBlocks();
+	cfg.orderNodes();
+	cfg.removeUnreachableNodes();
 	cfg.assignDominators();
 	if (vars.count("check-reducibility")) {
 		if (cfg.isReducible())
 			exit(0);
-		foreach (Block *interval, cfg.intervals())
+		foreach (Node *interval, cfg.intervals())
 			cout << phex(interval->_instructions.front()->_addr) << endl;
 		exit(1);
 	}

Modified: tools/branches/gsoc2009-decompiler/decompiler/graph.cpp
===================================================================
--- tools/branches/gsoc2009-decompiler/decompiler/graph.cpp	2009-07-09 18:03:09 UTC (rev 42312)
+++ tools/branches/gsoc2009-decompiler/decompiler/graph.cpp	2009-07-09 19:24:39 UTC (rev 42313)
@@ -13,16 +13,16 @@
 #endif
 
 
-void componentVisit(Block *u, Block *head) {
+void componentVisit(Node *u, Node *head) {
 	if (u->_component)
 		return;
 	u->_component = head;
-	foreach (Block *v, u->_in)
+	foreach (Node *v, u->_in)
 		componentVisit(v, head);
 }
 
 
-Block *dominatorIntersect(Block *u, Block *v) {
+Node *dominatorIntersect(Node *u, Node *v) {
 	while (u != v) {
 		while (u->_number < v->_number)
 			u = u->_dominator;
@@ -33,20 +33,20 @@
 }
 
 
-bool postOrderCompare(Block *a, Block *b) {
+bool postOrderCompare(Node *a, Node *b) {
 	return a->_number < b->_number;
 }
 
-list<Block*> inPostOrder(list<Block*> &blocks) {
-	list<Block*> ret(blocks);
+list<Node*> inPostOrder(list<Node*> &nodes) {
+	list<Node*> ret(nodes);
 	ret.sort(postOrderCompare);
 	return ret;
 }
 
 
-int orderVisit(Block *u, int number) {
+int orderVisit(Node *u, int number) {
 	u->_number = -1;
-	foreach (Block *v, u->_out)
+	foreach (Node *v, u->_out)
 		if (!v->_number)
 			number = orderVisit(v, number);
 	u->_number = ++number;
@@ -60,20 +60,20 @@
 
 
 ControlFlowGraph::~ControlFlowGraph() {
-	foreach (Block *u, _blocks)
+	foreach (Node *u, _nodes)
 		delete u;
 }
 
 
-Block *ControlFlowGraph::addBlock(list<Instruction*>::iterator first, list<Instruction*>::iterator last) {
-	Block* block = new Block;
-	_blocks.push_back(block);
-	copy(first, last, back_inserter(block->_instructions));
-	return block;
+Node *ControlFlowGraph::addNode(list<Instruction*>::iterator first, list<Instruction*>::iterator last) {
+	Node* node = new Node;
+	_nodes.push_back(node);
+	copy(first, last, back_inserter(node->_instructions));
+	return node;
 }
 
 
-void ControlFlowGraph::addBlocksFromScript(list<Instruction*>::iterator scriptBegin, list<Instruction*>::iterator scriptEnd) {
+void ControlFlowGraph::addNodesFromScript(list<Instruction*>::iterator scriptBegin, list<Instruction*>::iterator scriptEnd) {
 	Jump *jump;
 	for (list<Instruction*>::iterator it = scriptBegin; it != scriptEnd; it++)
 		if ((jump = dynamic_cast<Jump*>(*it))) {
@@ -84,47 +84,47 @@
 	list<Instruction*>::iterator first = scriptBegin;
 	for (list<Instruction*>::iterator last = scriptBegin; last != scriptEnd; last++) {
 		if (next(last) == scriptEnd || contains(_targets, (*next(last))->_addr)) {
-			_targets[(*first)->_addr] = addBlock(first, next(last));
+			_targets[(*first)->_addr] = addNode(first, next(last));
 			first = next(last);
 		}
 	}
-	foreach (Block *block, _blocks) {
-		if ((jump = dynamic_cast<Jump*>(block->_instructions.back())))
-			addEdge(block, _targets[jump->target()]);
-		map<address_t, Block*>::iterator succ = next(_targets.find(block->_instructions.front()->_addr));
+	foreach (Node *node, _nodes) {
+		if ((jump = dynamic_cast<Jump*>(node->_instructions.back())))
+			addEdge(node, _targets[jump->target()]);
+		map<address_t, Node*>::iterator succ = next(_targets.find(node->_instructions.front()->_addr));
 		if (succ != _targets.end() && (!jump || dynamic_cast<CondJump*>(jump)))
-			addEdge(block, succ->second);
+			addEdge(node, succ->second);
 	}
 }
 
 
-void ControlFlowGraph::addEdge(Block *from, Block *to) {
+void ControlFlowGraph::addEdge(Node *from, Node *to) {
 	from->_out.push_back(to);
 	to->_in.push_back(from);
 }
 
 
 void ControlFlowGraph::assignComponents() {
-	orderBlocks();
-	list<Block*> blocks = inPostOrder(_blocks);
-	blocks.reverse();
-	foreach (Block *u, blocks)
+	orderNodes();
+	list<Node*> nodes = inPostOrder(_nodes);
+	nodes.reverse();
+	foreach (Node *u, nodes)
 		componentVisit(u, u);
 }
 
 
 void ControlFlowGraph::assignDominators() {
-	list<Block*> blocks = inPostOrder(_blocks);
-	blocks.reverse();
-	blocks.remove(_entry);
+	list<Node*> nodes = inPostOrder(_nodes);
+	nodes.reverse();
+	nodes.remove(_entry);
 	_entry->_dominator = _entry;
 	for (bool changed = true; changed; ) {
 		changed = false;
-		foreach (Block *u, blocks) {
-			list<Block*>::iterator it = u->_in.begin();
+		foreach (Node *u, nodes) {
+			list<Node*>::iterator it = u->_in.begin();
 			while (!(*it)->_dominator)
 				it++;
-			Block *dom = *it++; // first processed predecessor
+			Node *dom = *it++; // first processed predecessor
 			for (; it != u->_in.end(); it++)
 				if ((*it)->_dominator)
 					dom = dominatorIntersect(*it, dom);
@@ -142,15 +142,15 @@
 // a node belongs to an interval, if all its immediate predecessors belong the given interval
 // otherwise it is an interval header
 void ControlFlowGraph::assignIntervals() {
-	list<Block*> intervals;
+	list<Node*> intervals;
 	intervals.push_back(_entry);
-	foreach (Block *interval, intervals) {
+	foreach (Node *interval, intervals) {
 		interval->_interval = interval;
 		for (bool added = true; added; ) {
 			added = false;
-			foreach (Block *m, _blocks) {
+			foreach (Node *m, _nodes) {
 				bool allPredInInterval = true;
-				foreach (Block *p, m->_in)
+				foreach (Node *p, m->_in)
 					allPredInInterval &= p->_interval == interval;
 				if (!m->_interval && allPredInInterval) {
 					added = true;
@@ -158,9 +158,9 @@
 				}
 			}
 		}
-		foreach (Block *m, _blocks) {
+		foreach (Node *m, _nodes) {
 			bool anyPredInInterval = false;
-			foreach (Block *p, m->_in)
+			foreach (Node *p, m->_in)
 				anyPredInInterval |= p->_interval == interval;
 			if (!m->_interval && anyPredInInterval)
 				intervals.push_back(m);
@@ -175,19 +175,19 @@
 // intervals in the original graph
 void ControlFlowGraph::extendIntervals() {
 	ControlFlowGraph d;
-	map<Block*, Block*> trans;
-	foreach (Block *interval, intervals()) {
-		trans[interval] = d.addBlock(interval->_instructions.begin(), interval->_instructions.end());
+	map<Node*, Node*> trans;
+	foreach (Node *interval, intervals()) {
+		trans[interval] = d.addNode(interval->_instructions.begin(), interval->_instructions.end());
 		trans[interval]->_primitive = interval;
 	}
-	foreach (Block *interval, intervals())
-		foreach (Block *u, interval->_in)
+	foreach (Node *interval, intervals())
+		foreach (Node *u, interval->_in)
 		if (u->_interval != interval)
 			d.addEdge(trans[u->_interval], trans[interval]);
 	d.setEntry(_entry->_instructions.front()->_addr);
 	d.assignIntervals();
-	foreach (Block *du, d._blocks)
-		foreach (Block *v, _blocks)
+	foreach (Node *du, d._nodes)
+		foreach (Node *v, _nodes)
 		if (v->_interval == du->_primitive)
 			v->_interval = du->_interval->_primitive;
 }
@@ -203,10 +203,10 @@
 	return ret;
 }
 
-list<Block*> ControlFlowGraph::components() {
-	list<Block*> ret;
+list<Node*> ControlFlowGraph::components() {
+	list<Node*> ret;
 	assignComponents();
-	foreach (Block *u, _blocks)
+	foreach (Node *u, _nodes)
 		if (u->_component == u)
 			ret.push_back(u);
 	return ret;
@@ -215,10 +215,10 @@
 string ControlFlowGraph::graphvizToString(const string &fontname, int fontsize) {
 	stringstream ret;
 	ret << "digraph G {" << endl;
-	foreach (Block *interval, intervals()) {
+	foreach (Node *interval, intervals()) {
 		ret << "subgraph " << '"' << "cluster_" << interval << '"' << " {" << endl;
 		ret << "style=dotted;" << endl;
-		foreach (Block *u, _blocks)
+		foreach (Node *u, _nodes)
 			if (u->_interval == interval) {
 				ret << '"' << u << "\"[";
 				if (fontname != "")
@@ -232,18 +232,18 @@
 			}
 		ret << "}" << endl;
 	}
-	foreach (Block *u, _blocks)
-		foreach (Block *v, u->_out)
+	foreach (Node *u, _nodes)
+		foreach (Node *v, u->_out)
 		    ret << '"' << u << "\" -> \"" << v << '"' << ";" << endl;
 	ret << "}" << endl;
 	return ret.str();
 }
 
 
-list<Block*> ControlFlowGraph::intervals() {
-	list<Block*> ret;
+list<Node*> ControlFlowGraph::intervals() {
+	list<Node*> ret;
 	assignIntervals();
-	foreach (Block *u, _blocks)
+	foreach (Node *u, _nodes)
 		if (u->_interval == u)
 			ret.push_back(u);
 	return ret;
@@ -251,13 +251,13 @@
 
 
 bool ControlFlowGraph::isReducible() {
-	for (size_t size = _blocks.size()+1; size > intervals().size(); size = intervals().size(), extendIntervals())
+	for (size_t size = _nodes.size()+1; size > intervals().size(); size = intervals().size(), extendIntervals())
 		;
 	return intervals().size() == 1;
 }
 
 
-void ControlFlowGraph::orderBlocks() {
+void ControlFlowGraph::orderNodes() {
 	assert(_entry);
 	if (!_entry->_number)
 		orderVisit(_entry, 0);
@@ -267,8 +267,8 @@
 void ControlFlowGraph::removeJumpsToJumps() {
 	for (bool changed = true; changed; ) {
 		changed = false;
-		foreach (Block *u, _blocks) {
-			foreach (Block *v, u->_out) {
+		foreach (Node *u, _nodes) {
+			foreach (Node *v, u->_out) {
 				Jump *jump = dynamic_cast<Jump*>(v->_instructions.front());
 				if (jump && !dynamic_cast<CondJump*>(jump) && jump->target() != jump->_addr) {
 					changed = true;
@@ -280,36 +280,36 @@
 }
 
 
-void ControlFlowGraph::removeUnreachableBlocks() {
-	foreach (Block *u, _blocks)
+void ControlFlowGraph::removeUnreachableNodes() {
+	foreach (Node *u, _nodes)
 		if (!u->_number) {
-			foreach (Block *v, u->_out)
+			foreach (Node *v, u->_out)
 				v->_in.remove(u);
-			foreach (Block *v, u->_in)
+			foreach (Node *v, u->_in)
 				v->_out.remove(u);
 		}
-	for (list<Block*>::iterator it = _blocks.begin(); it != _blocks.end(); )
+	for (list<Node*>::iterator it = _nodes.begin(); it != _nodes.end(); )
 		if ((*it)->_number)
 			it++;
 		else {
 			delete *it;
-			it = _blocks.erase(it);
+			it = _nodes.erase(it);
 		}
 }
 
 
-void ControlFlowGraph::replaceEdges(Block *from, Block *oldTo, Block *newTo) {
+void ControlFlowGraph::replaceEdges(Node *from, Node *oldTo, Node *newTo) {
 	size_t n = count(oldTo->_in.begin(), oldTo->_in.end(), from);
 	oldTo->_in.remove(from);
 	fill_n(back_inserter(newTo->_in), n, from);
-	foreach (Block *&block, from->_out)
-		if (block == oldTo)
-			block = newTo;
+	foreach (Node *&node, from->_out)
+		if (node == oldTo)
+			node = newTo;
 }
 
 
 void ControlFlowGraph::setEntry(address_t entry) {
-	foreach (Block *block, _blocks)
-		if (block->_instructions.front()->_addr == entry)
-			_entry = block;
+	foreach (Node *node, _nodes)
+		if (node->_instructions.front()->_addr == entry)
+			_entry = node;
 }

Modified: tools/branches/gsoc2009-decompiler/decompiler/graph.h
===================================================================
--- tools/branches/gsoc2009-decompiler/decompiler/graph.h	2009-07-09 18:03:09 UTC (rev 42312)
+++ tools/branches/gsoc2009-decompiler/decompiler/graph.h	2009-07-09 19:24:39 UTC (rev 42313)
@@ -9,36 +9,36 @@
 #include <sstream>
 
 #include "instruction.h"
-#include "block.h"
+#include "node.h"
 #include "misc.h"
 
 
 struct ControlFlowGraph : boost::noncopyable {
 
-	Block *_entry;
-	std::list<Block*> _blocks;
-	std::map<address_t, Block*> _targets; // helps partitioning code into basic blocks
+	Node *_entry;
+	std::list<Node*> _nodes;
+	std::map<address_t, Node*> _targets; // helps partitioning code into basic nodes
 
 	ControlFlowGraph();
 	~ControlFlowGraph();
 
-	Block *addBlock(std::list<Instruction*>::iterator first, std::list<Instruction*>::iterator last);
-	void addBlocksFromScript(std::list<Instruction*>::iterator scriptBegin, std::list<Instruction*>::iterator scriptEnd);
-	void addEdge(Block *from, Block *to);
+	Node *addNode(std::list<Instruction*>::iterator first, std::list<Instruction*>::iterator last);
+	void addNodesFromScript(std::list<Instruction*>::iterator scriptBegin, std::list<Instruction*>::iterator scriptEnd);
+	void addEdge(Node *from, Node *to);
 	void assignComponents(); // after order
 	void assignDominators(); // after order
-	std::list<Block*> components();
+	std::list<Node*> components();
 	std::string graphvizToString(const std::string &fontname="", int fontsize=0);
-	void orderBlocks();
+	void orderNodes();
 	void removeJumpsToJumps();
-	void removeUnreachableBlocks(); // after order
-	void replaceEdges(Block *from, Block *oldTo, Block *newTo);
+	void removeUnreachableNodes(); // after order
+	void replaceEdges(Node *from, Node *oldTo, Node *newTo);
 	void setEntry(address_t entry);
 
 	// to be removed
 	void assignIntervals();
 	void extendIntervals();
-	std::list<Block*> intervals();
+	std::list<Node*> intervals();
 	bool isReducible();
 };
 

Copied: tools/branches/gsoc2009-decompiler/decompiler/node.cpp (from rev 42312, tools/branches/gsoc2009-decompiler/decompiler/block.cpp)
===================================================================
--- tools/branches/gsoc2009-decompiler/decompiler/node.cpp	                        (rev 0)
+++ tools/branches/gsoc2009-decompiler/decompiler/node.cpp	2009-07-09 19:24:39 UTC (rev 42313)
@@ -0,0 +1,25 @@
+#include "node.h"
+
+#include <boost/foreach.hpp>
+
+using namespace boost;
+using namespace std;
+
+#ifndef foreach
+#define foreach BOOST_FOREACH
+#endif
+
+
+Node::Node() : _interval(), _number(), _dominator(), _component() {
+}
+
+
+Node::~Node() {
+}
+
+string Node::toString() {
+	ostringstream ret;
+	foreach (Instruction *instruction, _instructions)
+		ret << instruction->toString();
+	return ret.str();
+}


Property changes on: tools/branches/gsoc2009-decompiler/decompiler/node.cpp
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

Added: tools/branches/gsoc2009-decompiler/decompiler/node.h
===================================================================
--- tools/branches/gsoc2009-decompiler/decompiler/node.h	                        (rev 0)
+++ tools/branches/gsoc2009-decompiler/decompiler/node.h	2009-07-09 19:24:39 UTC (rev 42313)
@@ -0,0 +1,28 @@
+#ifndef NODE_H
+#define NODE_H
+
+#include "instruction.h"
+
+#include <list>
+
+#include <boost/utility.hpp>
+
+
+struct Node : boost::noncopyable {
+
+	bool _visited;
+	Node *_dominator;       // immediate dominator
+	Node *_interval;        // header node of the interval this node belongs to
+	Node *_primitive;       // interval header of the graph from which this graph has been derived
+	Node *_component;
+	int _number;             // number in post-order
+	std::list<Node*> _in;
+	std::list<Node*> _out;
+	std::list<Instruction*> _instructions;
+
+	Node();
+	~Node();
+	std::string toString();
+};
+
+#endif


Property changes on: tools/branches/gsoc2009-decompiler/decompiler/node.h
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

Modified: tools/branches/gsoc2009-decompiler/decompiler/test/data_graph.h
===================================================================
--- tools/branches/gsoc2009-decompiler/decompiler/test/data_graph.h	2009-07-09 18:03:09 UTC (rev 42312)
+++ tools/branches/gsoc2009-decompiler/decompiler/test/data_graph.h	2009-07-09 19:24:39 UTC (rev 42313)
@@ -8,12 +8,12 @@
 #include <instruction.h>
 
 
-unsigned addr(Block *block) {
-	return block->_instructions.front()->_addr;
+unsigned addr(Node *node) {
+	return node->_instructions.front()->_addr;
 }
 
-Block *node(ControlFlowGraph *g, unsigned addr) {
-	BOOST_FOREACH (Block *u, g->_blocks)
+Node *node(ControlFlowGraph *g, unsigned addr) {
+	BOOST_FOREACH (Node *u, g->_nodes)
 		if (u->_instructions.front()->_addr == addr)
 			return u;
 	return 0;
@@ -28,7 +28,7 @@
 	instructions.push_back(new    CondJump("jumpif -4", 5, -4));
 	instructions.push_back(new Instruction("ret",       6    ));
 	ControlFlowGraph *g = new ControlFlowGraph;
-	g->addBlocksFromScript(instructions.begin(), instructions.end());
+	g->addNodesFromScript(instructions.begin(), instructions.end());
 	g->setEntry(1);
 	return g;
 }
@@ -51,7 +51,7 @@
 	instructions.push_back(new        Jump("nop",       14, +1));
 	instructions.push_back(new Instruction("ret",       15    ));
 	ControlFlowGraph *g = new ControlFlowGraph;
-	g->addBlocksFromScript(instructions.begin(), instructions.end());
+	g->addNodesFromScript(instructions.begin(), instructions.end());
 	g->setEntry(1);
 	return g;
 }
@@ -62,7 +62,7 @@
 	instructions.push_back(new        Jump("nop",       2, +1));
 	instructions.push_back(new        Jump("jump -1",   3, -1));
 	ControlFlowGraph *g = new ControlFlowGraph;
-	g->addBlocksFromScript(instructions.begin(), instructions.end());
+	g->addNodesFromScript(instructions.begin(), instructions.end());
 	g->setEntry(1);
 	return g;
 }
@@ -73,7 +73,7 @@
 	instructions.push_back(new    CondJump("jumpif +0", 2, +0));
 	instructions.push_back(new        Jump("jump -2",   3, -2));
 	ControlFlowGraph *g = new ControlFlowGraph;
-	g->addBlocksFromScript(instructions.begin(), instructions.end());
+	g->addNodesFromScript(instructions.begin(), instructions.end());
 	g->setEntry(1);
 	return g;
 }

Modified: tools/branches/gsoc2009-decompiler/decompiler/test/test_graph_internal.h
===================================================================
--- tools/branches/gsoc2009-decompiler/decompiler/test/test_graph_internal.h	2009-07-09 18:03:09 UTC (rev 42312)
+++ tools/branches/gsoc2009-decompiler/decompiler/test/test_graph_internal.h	2009-07-09 19:24:39 UTC (rev 42313)
@@ -83,7 +83,7 @@
 
 
 	void test_assignDominators() {
-		ga->orderBlocks();
+		ga->orderNodes();
 		ga->assignDominators();
 		TS_ASSERT(!node(ga,1)->_dominator);
 		TS_ASSERT_EQUALS(addr(node(ga,2)->_dominator), 1);
@@ -92,7 +92,7 @@
 		TS_ASSERT_EQUALS(addr(node(ga,5)->_dominator), 2);
 		TS_ASSERT_EQUALS(addr(node(ga,6)->_dominator), 5);
 
-		gb->orderBlocks();
+		gb->orderNodes();
 		gb->assignDominators();
 		TS_ASSERT(!node(gb,1)->_dominator);
 		TS_ASSERT_EQUALS(addr(node(gb,2)->_dominator), 1);
@@ -110,13 +110,13 @@
 		TS_ASSERT_EQUALS(addr(node(gb,14)->_dominator), 11);
 		TS_ASSERT_EQUALS(addr(node(gb,15)->_dominator), 14);
 
-		gc->orderBlocks();
+		gc->orderNodes();
 		gc->assignDominators();
 		TS_ASSERT(!node(gc,1)->_dominator);
 		TS_ASSERT_EQUALS(addr(node(gc,2)->_dominator), 1);
 		TS_ASSERT_EQUALS(addr(node(gc,3)->_dominator), 1);
 
-		gd->orderBlocks();
+		gd->orderNodes();
 		gd->assignDominators();
 		TS_ASSERT(!node(gd,1)->_dominator);
 		TS_ASSERT_EQUALS(addr(node(gd,2)->_dominator), 1);


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