00001 /* 00002 // $Id: //open/dev/fennel/calculator/InstructionSignature.h#3 $ 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 00023 #ifndef Fennel_InstructionSignature_Included 00024 #define Fennel_InstructionSignature_Included 00025 00026 #include "fennel/tuple/StandardTypeDescriptor.h" 00027 #include "fennel/calculator/RegisterReference.h" 00028 #include "fennel/calculator/CalcTypedefs.h" 00029 #include <string> 00030 #include <vector> 00031 #include <map> 00032 00033 FENNEL_BEGIN_NAMESPACE 00034 00035 using namespace std; 00036 00037 class FENNEL_CALCULATOR_EXPORT InstructionSignature 00038 { 00039 public: 00040 explicit 00041 InstructionSignature(string const & name); 00042 explicit 00043 InstructionSignature( 00044 string const & name, 00045 vector<StandardTypeDescriptorOrdinal> 00046 const &operands); 00047 00048 explicit 00049 InstructionSignature( 00050 string const & name, 00051 vector<RegisterReference*> const & operands); 00052 00053 explicit 00054 InstructionSignature( 00055 string const & name, 00056 TProgramCounter pc, 00057 vector<StandardTypeDescriptorOrdinal> 00058 const &operands); 00059 00060 explicit 00061 InstructionSignature( 00062 string const & name, 00063 TProgramCounter pc, 00064 vector<RegisterReference*> const & operands); 00065 00066 // TODO: convert this to an explicit conversion 00067 string compute() const; 00068 00069 string getName() const; 00070 RegisterReference* operator[] (uint index) const; 00071 uint size() const; 00072 TProgramCounter getPc() const; 00073 00076 static vector<StandardTypeDescriptorOrdinal> 00077 typeVector(bool(*typeFunction)(StandardTypeDescriptorOrdinal)); 00078 00079 private: 00080 string name; 00081 vector<StandardTypeDescriptorOrdinal> types; 00082 vector<RegisterReference*> registers; 00083 bool hasRegisters; 00084 TProgramCounter pc; 00085 bool hasPc; 00086 00087 void registersToTypes(); 00088 }; 00089 00090 00091 class Instruction; 00092 00095 typedef Instruction*(*InstructionCreateFunction) 00096 (InstructionSignature const &); 00097 00100 // TODO: Consider merging the regular & extended tables. 00101 typedef std::map< string, InstructionCreateFunction > StringToCreateFn; 00102 00104 typedef 00105 std::map< string, InstructionCreateFunction >::iterator StringToCreateFnIter; 00106 00107 00108 FENNEL_END_NAMESPACE 00109 00110 #endif 00111 00112 // End InstructionSignature.h 00113