#include <InstructionFactory.h>
Public Member Functions | |
InstructionFactory () | |
Static Public Member Functions | |
static Instruction * | createInstruction (string const &name, vector< RegisterReference * > const &operands) |
static Instruction * | createInstruction (string const &name, TProgramCounter pc, RegisterReference *operand) |
static Instruction * | createInstruction (string const &name, string const &function, vector< RegisterReference * > const &operands) |
static string | signatures () |
static string | extendedSignatures () |
static void | registerInstructions () |
static StringToCreateFn * | getInstructionTable () |
static ExtendedInstructionTable * | getExtendedInstructionTable () |
Static Private Member Functions | |
static Instruction * | createInstructionHelper (InstructionSignature const &sig) |
Static Private Attributes | |
static StringToCreateFn | instructionTable |
A map to hold regular instructions. | |
static ExtendedInstructionTable | extendedTable |
A map to hold extended instructions. |
Definition at line 40 of file InstructionFactory.h.
InstructionFactory::InstructionFactory | ( | ) | [inline, explicit] |
Instruction * InstructionFactory::createInstruction | ( | string const & | name, | |
vector< RegisterReference * > const & | operands | |||
) | [static] |
Definition at line 33 of file InstructionFactory.cpp.
References createInstructionHelper().
Referenced by CalcAssembler::createInstruction().
00036 { 00037 InstructionSignature signature(name, operands); 00038 return createInstructionHelper(signature); 00039 }
Instruction * InstructionFactory::createInstruction | ( | string const & | name, | |
TProgramCounter | pc, | |||
RegisterReference * | operand | |||
) | [static] |
Definition at line 43 of file InstructionFactory.cpp.
References createInstructionHelper().
00047 { 00048 vector<RegisterReference*> v; 00049 if (operand) { 00050 v.push_back(operand); 00051 } 00052 00053 InstructionSignature signature(name, pc, v); 00054 return createInstructionHelper(signature); 00055 }
Instruction * InstructionFactory::createInstruction | ( | string const & | name, | |
string const & | function, | |||
vector< RegisterReference * > const & | operands | |||
) | [static] |
Definition at line 71 of file InstructionFactory.cpp.
References InstructionSignature::compute(), ExtendedInstructionDef::createInstruction(), and extendedTable.
00075 { 00076 InstructionSignature signature(function, operands); 00077 ExtendedInstructionDef* instDef = extendedTable[signature.compute()]; 00078 if (instDef == NULL) { 00079 return NULL; 00080 } 00081 return instDef->createInstruction(operands); 00082 }
string InstructionFactory::signatures | ( | ) | [static] |
Definition at line 85 of file InstructionFactory.cpp.
References instructionTable.
Referenced by Calculator::assemble().
00086 { 00087 ostringstream s(""); 00088 00089 StringToCreateFnIter i = instructionTable.begin(); 00090 StringToCreateFnIter end = instructionTable.end(); 00091 00092 while (i != end) { 00093 s << (*i).first << endl; 00094 i++; 00095 } 00096 return s.str(); 00097 }
string InstructionFactory::extendedSignatures | ( | ) | [static] |
Definition at line 100 of file InstructionFactory.cpp.
References extendedTable, and ExtendedInstructionTable::signatures().
Referenced by Calculator::assemble().
00101 { 00102 return extendedTable.signatures(); 00103 }
void InstructionFactory::registerInstructions | ( | ) | [static] |
Definition at line 106 of file InstructionFactory.cpp.
References ReturnInstructionRegister::registerInstructions(), PointerPointerInstructionRegister::registerInstructions(), PointerIntegralInstructionRegister::registerInstructions(), NativeNativeInstructionRegister::registerInstructions(), JumpInstructionRegister::registerInstructions(), IntegralPointerInstructionRegister::registerInstructions(), IntegralNativeInstructionRegister::registerInstructions(), CastInstructionRegister::registerInstructions(), BoolPointerInstructionRegister::registerInstructions(), BoolNativeInstructionRegister::registerInstructions(), and BoolInstructionRegister::registerInstructions().
Referenced by CalcInit::instance(), and main().
00107 { 00108 BoolInstructionRegister::registerInstructions(); 00109 BoolNativeInstructionRegister::registerInstructions(); 00110 BoolPointerInstructionRegister::registerInstructions(); 00111 CastInstructionRegister::registerInstructions(); 00112 IntegralNativeInstructionRegister::registerInstructions(); 00113 IntegralPointerInstructionRegister::registerInstructions(); 00114 JumpInstructionRegister::registerInstructions(); 00115 NativeNativeInstructionRegister::registerInstructions(); 00116 PointerIntegralInstructionRegister::registerInstructions(); 00117 PointerPointerInstructionRegister::registerInstructions(); 00118 ReturnInstructionRegister::registerInstructions(); 00119 }
static StringToCreateFn* InstructionFactory::getInstructionTable | ( | ) | [inline, static] |
Definition at line 78 of file InstructionFactory.h.
Referenced by InstructionRegister::registerInstance(), InstructionRegister::registerInstance2(), and ReturnInstructionRegister::registerInstructions().
00079 { 00080 return &instructionTable; 00081 }
static ExtendedInstructionTable* InstructionFactory::getExtendedInstructionTable | ( | ) | [inline, static] |
Definition at line 85 of file InstructionFactory.h.
Referenced by CalcInit::instance(), CalcExtContextTest::setupExtendedTestInstructions(), and CalcAssemblerTest::testExtended().
00086 { 00087 return &extendedTable; 00088 }
Instruction * InstructionFactory::createInstructionHelper | ( | InstructionSignature const & | sig | ) | [static, private] |
Definition at line 58 of file InstructionFactory.cpp.
References InstructionSignature::compute(), and instructionTable.
Referenced by createInstruction().
00059 { 00060 InstructionCreateFunction createFn = instructionTable[sig.compute()]; 00061 00062 if (createFn) { 00063 return createFn(sig); 00064 } else { 00065 throw FennelExcn(sig.compute() + " is not a registered instruction"); 00066 } 00067 }
StringToCreateFn InstructionFactory::instructionTable [static, private] |
A map to hold regular instructions.
Definition at line 95 of file InstructionFactory.h.
Referenced by createInstructionHelper(), and signatures().
ExtendedInstructionTable InstructionFactory::extendedTable [static, private] |
A map to hold extended instructions.
Definition at line 97 of file InstructionFactory.h.
Referenced by createInstruction(), and extendedSignatures().