00001 /* 00002 // $Id: //open/dev/fennel/calculator/InstructionFactory.h#2 $ 00003 // Fennel is a library of data storage and processing components. 00004 // Copyright (C) 2005-2009 The Eigenbase Project 00005 // Copyright (C) 2004-2009 SQLstream, Inc. 00006 // Copyright (C) 2009-2009 LucidEra, Inc. 00007 // 00008 // This program is free software; you can redistribute it and/or modify it 00009 // under the terms of the GNU General Public License as published by the Free 00010 // Software Foundation; either version 2 of the License, or (at your option) 00011 // any later version approved by The Eigenbase Project. 00012 // 00013 // This program is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 // GNU General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU General Public License 00019 // along with this program; if not, write to the Free Software 00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 // 00022 // InstructionFactory 00023 // 00024 */ 00025 00026 #ifndef Fennel_InstructionFactory_Included 00027 #define Fennel_InstructionFactory_Included 00028 00029 #include "fennel/calculator/InstructionSignature.h" 00030 #include "fennel/calculator/CalcAssemblerException.h" 00031 #include "fennel/calculator/RegisterReference.h" 00032 #include "fennel/tuple/StandardTypeDescriptor.h" 00033 00034 FENNEL_BEGIN_NAMESPACE 00035 00036 class ExtendedInstructionTable; 00037 00040 class FENNEL_CALCULATOR_EXPORT InstructionFactory 00041 { 00042 public: 00043 explicit 00044 InstructionFactory() {} 00045 00046 // Creates a typical instruction 00047 static Instruction* 00048 createInstruction( 00049 string const &name, 00050 vector<RegisterReference*> const &operands); 00051 00052 // Creates a Jump instruction 00053 static Instruction* 00054 createInstruction( 00055 string const &name, 00056 TProgramCounter pc, 00057 RegisterReference* operand); // add const? 00058 00059 // Creates an Extended instruction 00060 static Instruction* 00061 createInstruction( 00062 string const &name, 00063 string const &function, 00064 vector<RegisterReference*> const &operands); 00065 00066 // debugging & tracing 00067 static string 00068 signatures(); 00069 00070 static string 00071 extendedSignatures(); 00072 00073 // Start-of-world setup 00074 static void 00075 registerInstructions(); 00076 00077 static StringToCreateFn* 00078 getInstructionTable() 00079 { 00080 return &instructionTable; 00081 } 00082 00083 // Extended Instruction hooks 00084 static ExtendedInstructionTable* 00085 getExtendedInstructionTable() 00086 { 00087 return &extendedTable; 00088 } 00089 00090 private: 00091 static Instruction* 00092 createInstructionHelper(InstructionSignature const & sig); 00093 00095 static StringToCreateFn instructionTable; 00097 static ExtendedInstructionTable extendedTable; 00098 }; 00099 00100 FENNEL_END_NAMESPACE 00101 00102 #endif 00103 00104 // End InstructionFactory.h