[Scummvm-cvs-logs] SF.net SVN: scummvm:[54966] tools/trunk/decompiler

pidgeot at users.sourceforge.net pidgeot at users.sourceforge.net
Sun Dec 19 21:35:58 CET 2010


Revision: 54966
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54966&view=rev
Author:   pidgeot
Date:     2010-12-19 20:35:57 +0000 (Sun, 19 Dec 2010)

Log Message:
-----------
DECOMPILER: Renaming Instruction classes

To reflect that Instructions with default implementations are aimed at
stack-based engines, I've renamed the affected types and added new ones
to keep a "base" type that other engines can use.

Modified Paths:
--------------
    tools/trunk/decompiler/disassembler.cpp
    tools/trunk/decompiler/instruction.cpp
    tools/trunk/decompiler/instruction.h
    tools/trunk/decompiler/scummv6/engine.h

Modified: tools/trunk/decompiler/disassembler.cpp
===================================================================
--- tools/trunk/decompiler/disassembler.cpp	2010-12-19 17:36:36 UTC (rev 54965)
+++ tools/trunk/decompiler/disassembler.cpp	2010-12-19 20:35:57 UTC (rev 54966)
@@ -24,13 +24,13 @@
 
 Disassembler::Disassembler(InstVec &insts) : _insts(insts) {
 	_addressBase = 0;
-	_instFactory.addEntry<BinaryOpInstruction>(kBinaryOpInst);
-	_instFactory.addEntry<BoolNegateInstruction>(kBoolNegateInst);
-	_instFactory.addEntry<DupInstruction>(kDupInst);
-	_instFactory.addEntry<KernelCallInstruction>(kKernelCallInst);
+	_instFactory.addEntry<BinaryOpStackInstruction>(kBinaryOpInst);
+	_instFactory.addEntry<BoolNegateStackInstruction>(kBoolNegateInst);
+	_instFactory.addEntry<DupStackInstruction>(kDupInst);
+	_instFactory.addEntry<KernelCallStackInstruction>(kKernelCallInst);
 	_instFactory.addEntry<ReturnInstruction>(kReturnInst);
-	_instFactory.addEntry<UnaryOpPrefixInstruction>(kUnaryOpPreInst);
-	_instFactory.addEntry<UnaryOpPostfixInstruction>(kUnaryOpPostInst);
+	_instFactory.addEntry<UnaryOpPrefixStackInstruction>(kUnaryOpPreInst);
+	_instFactory.addEntry<UnaryOpPostfixStackInstruction>(kUnaryOpPostInst);
 }
 
 void Disassembler::open(const char *filename) {

Modified: tools/trunk/decompiler/instruction.cpp
===================================================================
--- tools/trunk/decompiler/instruction.cpp	2010-12-19 17:36:36 UTC (rev 54965)
+++ tools/trunk/decompiler/instruction.cpp	2010-12-19 20:35:57 UTC (rev 54966)
@@ -110,7 +110,7 @@
 	return true;
 }
 
-void DupInstruction::processInst(ValueStack &stack, Engine *engine, CodeGenerator *codeGen) {
+void DupStackInstruction::processInst(ValueStack &stack, Engine *engine, CodeGenerator *codeGen) {
 	std::stringstream s;
 	ValuePtr p = stack.pop()->dup(s);
 	if (s.str().length() > 0)
@@ -119,11 +119,11 @@
 	stack.push(p);
 }
 
-void BoolNegateInstruction::processInst(ValueStack &stack, Engine *engine, CodeGenerator *codeGen) {
+void BoolNegateStackInstruction::processInst(ValueStack &stack, Engine *engine, CodeGenerator *codeGen) {
 	stack.push(stack.pop()->negate());
 }
 
-void BinaryOpInstruction::processInst(ValueStack &stack, Engine *engine, CodeGenerator *codeGen) {
+void BinaryOpStackInstruction::processInst(ValueStack &stack, Engine *engine, CodeGenerator *codeGen) {
 	ValuePtr op1 = stack.pop();
 	ValuePtr op2 = stack.pop();
 	if (codeGen->_binOrder == kFIFOArgOrder)
@@ -140,15 +140,15 @@
 	codeGen->addOutputLine("return;");
 }
 
-void UnaryOpPrefixInstruction::processInst(ValueStack &stack, Engine *engine, CodeGenerator *codeGen) {
+void UnaryOpPrefixStackInstruction::processInst(ValueStack &stack, Engine *engine, CodeGenerator *codeGen) {
 	stack.push(new UnaryOpValue(stack.pop(), _codeGenData, false));
 }
 
-void UnaryOpPostfixInstruction::processInst(ValueStack &stack, Engine *engine, CodeGenerator *codeGen) {
+void UnaryOpPostfixStackInstruction::processInst(ValueStack &stack, Engine *engine, CodeGenerator *codeGen) {
 	stack.push(new UnaryOpValue(stack.pop(), _codeGenData, true));
 }
 
-void KernelCallInstruction::processInst(ValueStack &stack, Engine *engine, CodeGenerator *codeGen) {
+void KernelCallStackInstruction::processInst(ValueStack &stack, Engine *engine, CodeGenerator *codeGen) {
 	codeGen->_argList.clear();
 	bool returnsValue = (_codeGenData.find("r") == 0);
 	std::string metadata = (!returnsValue ? _codeGenData : _codeGenData.substr(1));

Modified: tools/trunk/decompiler/instruction.h
===================================================================
--- tools/trunk/decompiler/instruction.h	2010-12-19 17:36:36 UTC (rev 54965)
+++ tools/trunk/decompiler/instruction.h	2010-12-19 20:35:57 UTC (rev 54966)
@@ -238,27 +238,59 @@
  * Instruction duplicating the topmost stack value.
  */
 struct DupInstruction : public Instruction {
-public:
-	virtual void processInst(ValueStack &stack, Engine *engine, CodeGenerator *codeGen);
 };
 
 /**
  * Instruction performing boolean negation.
  */
 struct BoolNegateInstruction : public Instruction {
-public:
-	virtual void processInst(ValueStack &stack, Engine *engine, CodeGenerator *codeGen);
 };
 
 /**
  * Instruction performing a binary operation.
  */
 struct BinaryOpInstruction : public Instruction {
+};
+
+/**
+ * Instruction performing a unary operation.
+ */
+struct UnaryOpInstruction : public Instruction {
+};
+
+/**
+ * Instruction performing a kernel function call.
+ */
+struct KernelCallInstruction : public Instruction {
 public:
+	virtual bool isKernelCall() const;
+};
+
+/**
+ * Default implementation for stack-based instruction duplicating the topmost stack value.
+ */
+struct DupStackInstruction : public DupInstruction {
+public:
 	virtual void processInst(ValueStack &stack, Engine *engine, CodeGenerator *codeGen);
 };
 
 /**
+ * Default implementation for stack-based instruction performing boolean negation.
+ */
+struct BoolNegateStackInstruction : public BoolNegateInstruction {
+public:
+	virtual void processInst(ValueStack &stack, Engine *engine, CodeGenerator *codeGen);
+};
+
+/**
+ * Default implementation for stack-based instruction performing a binary operation.
+ */
+struct BinaryOpStackInstruction : public BinaryOpInstruction {
+public:
+	virtual void processInst(ValueStack &stack, Engine *engine, CodeGenerator *codeGen);
+};
+
+/**
  * Instruction which returns from a function.
  */
 struct ReturnInstruction : public Instruction {
@@ -268,28 +300,27 @@
 };
 
 /**
- * Instruction performing a unary operation, with a prefixed operator.
+ * Default implementation for stack-based instruction performing a unary operation, with a prefixed operator.
  */
-struct UnaryOpPrefixInstruction : public Instruction {
+struct UnaryOpPrefixStackInstruction : public UnaryOpInstruction {
 public:
 	virtual void processInst(ValueStack &stack, Engine *engine, CodeGenerator *codeGen);
 };
 
 /**
- * Instruction performing a unary operation, with a postfixed operator.
+ * Default implementation for stack-based instruction performing a unary operation, with a postfixed operator.
  */
-struct UnaryOpPostfixInstruction : public Instruction {
+struct UnaryOpPostfixStackInstruction : public UnaryOpInstruction {
 public:
 	virtual void processInst(ValueStack &stack, Engine *engine, CodeGenerator *codeGen);
 };
 
 /**
- * Instruction performing a kernel function call.
+ * Default implementation for stack-based instruction performing a kernel function call.
  */
-struct KernelCallInstruction : public Instruction {
+struct KernelCallStackInstruction : public Instruction {
 public:
 	virtual void processInst(ValueStack &stack, Engine *engine, CodeGenerator *codeGen);
-	virtual bool isKernelCall() const;
 };
 
 /**

Modified: tools/trunk/decompiler/scummv6/engine.h
===================================================================
--- tools/trunk/decompiler/scummv6/engine.h	2010-12-19 17:36:36 UTC (rev 54965)
+++ tools/trunk/decompiler/scummv6/engine.h	2010-12-19 20:35:57 UTC (rev 54966)
@@ -102,7 +102,7 @@
 /**
  * SCUMM v6 variable increment/decrement.
  */
-class Scummv6IncDecInstruction : public UnaryOpPostfixInstruction {
+class Scummv6IncDecInstruction : public UnaryOpPostfixStackInstruction {
 public:
 	virtual void processInst(ValueStack &stack, Engine *engine, CodeGenerator *codeGen);
 };


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