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

pidgeot at users.sourceforge.net pidgeot at users.sourceforge.net
Mon May 31 15:09:24 CEST 2010


Revision: 49354
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49354&view=rev
Author:   pidgeot
Date:     2010-05-31 13:09:24 +0000 (Mon, 31 May 2010)

Log Message:
-----------
Move individual parameter reading to separate method

Modified Paths:
--------------
    tools/branches/gsoc2010-decompiler/decompiler/simple_disassembler.cpp
    tools/branches/gsoc2010-decompiler/decompiler/simple_disassembler.h

Modified: tools/branches/gsoc2010-decompiler/decompiler/simple_disassembler.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/simple_disassembler.cpp	2010-05-31 12:43:28 UTC (rev 49353)
+++ tools/branches/gsoc2010-decompiler/decompiler/simple_disassembler.cpp	2010-05-31 13:09:24 UTC (rev 49354)
@@ -25,70 +25,74 @@
 void SimpleDisassembler::readParams(Instruction *inst, char *typeString) {
 	while (*typeString) {
 		Parameter p;
-		switch (*typeString) {
-		case 'b': //signed byte
-			p._type = kSByte;
-			p._sbyte = _f.readChar();
-			_address++;
-			break;
-		case 'B': //unsigned byte
-			p._type = kByte;
-			p._byte = _f.readByte();
-			_address++;
-			break;
-		case 's': //16-bit signed integer (short), little-endian
-			p._type = kShort;
-			p._short = _f.readSint16LE();
-			_address += 2;
-			break;
-		case 'S': //16-bit signed integer (short), big-endian
-			p._type = kShort;
-			p._short = _f.readSint16BE();
-			_address += 2;
-			break;
-		case 'w': //16-bit unsigned integer (word), little-endian
-			p._type = kUShort;
-			p._ushort = _f.readUint16LE();
-			_address += 2;
-			break;
-		case 'W': //16-bit unsigned integer (word), big-endian
-			p._type = kUShort;
-			p._ushort = _f.readUint16BE();
-			_address += 2;
-			break;
-		case 'i': //32-bit signed integer (int), little-endian
-			p._type = kInt;
-			p._int = _f.readSint32LE();
-			_address += 4;
-			break;
-		case 'I': //32-bit signed integer (int), big-endian
-			p._type = kInt;
-			p._int = _f.readSint32BE();
-			_address += 4;
-			break;
-		case 'd': //32-bit unsigned integer (dword), little-endian
-			p._type = kUInt;
-			p._uint = _f.readUint32LE();
-			_address += 4;
-			break;
-		case 'D': //32-bit unsigned integer (dword), big-endian
-			p._type = kUInt;
-			p._uint = _f.readUint32BE();
-			_address += 4;
-			break;
-		// Common::File doesn't have readFloat methods, but since the value is stored in a union, we just need to read the right bytes into memory.
-		case 'f': //Single-precision float, little-endian
-			p._type = kFloat;
-			p._uint = _f.readUint32LE();
-			_address += 4;
-			break;
-		case 'F': //Single-precision float, big-endian
-			p._type = kFloat;
-			p._uint = _f.readUint32BE();
-			_address += 4;
-			break;
-		}
+		readParameter(&p, *typeString);
 		inst->_params.push_back(p);
 		typeString++;
 	}
 }
+
+void SimpleDisassembler::readParameter(Parameter *p, char type) {
+	switch (type) {
+	case 'b': //signed byte
+		p->_type = kSByte;
+		p->_sbyte = _f.readChar();
+		_address++;
+		break;
+	case 'B': //unsigned byte
+		p->_type = kByte;
+		p->_byte = _f.readByte();
+		_address++;
+		break;
+	case 's': //16-bit signed integer (short), little-endian
+		p->_type = kShort;
+		p->_short = _f.readSint16LE();
+		_address += 2;
+		break;
+	case 'S': //16-bit signed integer (short), big-endian
+		p->_type = kShort;
+		p->_short = _f.readSint16BE();
+		_address += 2;
+		break;
+	case 'w': //16-bit unsigned integer (word), little-endian
+		p->_type = kUShort;
+		p->_ushort = _f.readUint16LE();
+		_address += 2;
+		break;
+	case 'W': //16-bit unsigned integer (word), big-endian
+		p->_type = kUShort;
+		p->_ushort = _f.readUint16BE();
+		_address += 2;
+		break;
+	case 'i': //32-bit signed integer (int), little-endian
+		p->_type = kInt;
+		p->_int = _f.readSint32LE();
+		_address += 4;
+		break;
+	case 'I': //32-bit signed integer (int), big-endian
+		p->_type = kInt;
+		p->_int = _f.readSint32BE();
+		_address += 4;
+		break;
+	case 'd': //32-bit unsigned integer (dword), little-endian
+		p->_type = kUInt;
+		p->_uint = _f.readUint32LE();
+		_address += 4;
+		break;
+	case 'D': //32-bit unsigned integer (dword), big-endian
+		p->_type = kUInt;
+		p->_uint = _f.readUint32BE();
+		_address += 4;
+		break;
+	// Common::File doesn't have readFloat methods, but since the value is stored in a union, we just need to read the right bytes into memory.
+	case 'f': //Single-precision float, little-endian
+		p->_type = kFloat;
+		p->_uint = _f.readUint32LE();
+		_address += 4;
+		break;
+	case 'F': //Single-precision float, big-endian
+		p->_type = kFloat;
+		p->_uint = _f.readUint32BE();
+		_address += 4;
+		break;
+	}
+}

Modified: tools/branches/gsoc2010-decompiler/decompiler/simple_disassembler.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/simple_disassembler.h	2010-05-31 12:43:28 UTC (rev 49353)
+++ tools/branches/gsoc2010-decompiler/decompiler/simple_disassembler.h	2010-05-31 13:09:24 UTC (rev 49354)
@@ -37,7 +37,14 @@
 	 * @param inst Pointer to the instruction to associate the parameters with.
 	 * @param typeString NUL-terminated string describing the type of each parameter.
 	 */
-	virtual void readParams(Instruction *inst, char *typeString);
+	void readParams(Instruction *inst, char *typeString);
+
+	/**
+	 * Reads data for a single parameter.
+	 * @param p Pointer to the destination Parameter structure.
+	 * @param type Character describing the type of the parameter.
+	 */
+	virtual void readParameter(Parameter *p, char type);
 };
 
 #define INC_ADDR _address++;


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