InstructionDescription.h

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/calculator/InstructionDescription.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 // InstructionDescription
00023 //
00024 */
00025 
00026 #ifndef Fennel_InstructionDescription_Included
00027 #define Fennel_InstructionDescription_Included
00028 
00029 #include "fennel/calculator/Calculator.h"
00030 #include "fennel/calculator/RegisterReference.h"
00031 #include "fennel/tuple/StandardTypeDescriptor.h"
00032 #include <map>
00033 
00034 FENNEL_BEGIN_NAMESPACE
00035 
00036 class Instruction;
00037 
00040 class FENNEL_CALCULATOR_EXPORT RegDesc
00041 {
00042 public:
00043     enum Groups {
00044         REGDESC_NONE = 0,
00045         REGDESC_ANY,
00046         REGDESC_NATIVE,
00047         REGDESC_INTEGRAL,
00048         REGDESC_POINTER,
00049         REGDESC_ARRAY
00050     };
00051 
00052     // C'tor for exactly one type
00053     explicit
00054     RegDesc(StandardTypeDescriptorOrdinal typeArg) :
00055         type(typeArg),
00056         group(REGDESC_NONE)
00057     {
00058     }
00059 
00060     // C'tor for a group of types
00061     explicit
00062     RegDesc(Groups groupArg) :
00063         type(STANDARD_TYPE_END_NO_UNICODE),
00064         group(groupArg)
00065     {
00066     }
00067 
00068     bool
00069     match(StandardTypeDescriptorOrdinal m);
00070 
00071 private:
00072     StandardTypeDescriptorOrdinal type;
00073     Groups group;
00074 };
00075 
00078 class FENNEL_CALCULATOR_EXPORT InstructionDescription
00079 {
00080 private:
00081     // TODO: Move to instruction.h?
00084     typedef Instruction *(*InstructionCreateFunction)(
00085         vector<RegisterReference*> const &);
00086 public:
00087     explicit
00088     InstructionDescription(
00089         string const &nameArg,
00090         vector<RegDesc> const &registerdescArg,
00091         InstructionCreateFunction createFnArg) :
00092         name(nameArg),
00093         registerdesc(registerdescArg),
00094         createFn(createFnArg)
00095     {
00096     }
00097 
00098     void setName(string const &s)
00099     {
00100         name = s;
00101     }
00102 
00103     string getName() const
00104     {
00105         return name;
00106     }
00107 
00108 private:
00109     string name;
00110     vector<RegDesc> registerdesc;
00111     InstructionCreateFunction createFn;
00112     Instruction* inst;
00113     TProgramCounter pc;
00114 };
00115 
00116 
00117 typedef std::map< string, InstructionDescription* > StringToInstDesc;
00118 
00119 FENNEL_END_NAMESPACE
00120 
00121 #endif
00122 
00123 // End InstructionDescription.h

Generated on Mon Jun 22 04:00:17 2009 for Fennel by  doxygen 1.5.1