Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

/ray/src/vm/input/asmfile.h

Go to the documentation of this file.
00001 /*
00002  * vm/input/asmfile.h
00003  * 
00004  * VM assembler input file. 
00005  * 
00006  * Copyright (c) 2004 by Wolfgang Wieser ] wwieser (a) gmx <*> de [ 
00007  * 
00008  * This file may be distributed and/or modified under the terms of the 
00009  * GNU General Public License version 2 as published by the Free Software 
00010  * Foundation. (See COPYING.GPL for details.)
00011  * 
00012  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00013  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00014  * 
00015  */
00016 
00017 #ifndef _VM_INPUT_ASSEMBLERFILE_H_
00018 #define _VM_INPUT_ASSEMBLERFILE_H_ 1
00019 
00027 #include <vm/vmconfig.h>    /* MUST be first */
00028 
00029 #include <vm/maptable.h>
00030 #include <vm/imaptable.h>
00031 #include <vm/input/classinfo.h>
00032 #include <lib/lex/location.h>
00033 #include <vm/nrarray.h>
00034 #include <vm/program.h>
00035 #include <lib/tl/tllinearqueue.h>
00036 
00037 
00038 namespace VM
00039 {
00040 
00041 // See <vm/input/linker.h>. 
00042 class VMLinker;
00043 
00044 
00054 class AssemblerFile
00055 {
00056     friend class VMLinker;
00057     public:
00059         struct Config
00060         {
00061             bool read_non_pointer_members;
00062             bool read_member_var_names;
00065             bool emit_all_namespaces;
00067             bool emit_all_classinfo;
00068             
00070             Config();
00071             inline ~Config() {}
00072         };
00073         
00075         struct GlobalVarEntry
00076         {
00077             VarType vtype;  
00078             Offset off;     
00079             union {
00081                 SymRef symref;
00083                 NamespaceInfo::SymbolEntryE *se;
00084             };
00085             
00086             inline GlobalVarEntry() {}
00087             inline ~GlobalVarEntry() {}
00088         };
00089         
00092         struct ORD_SymRef_SE
00093         {
00094             static inline SymRef ord(const NamespaceInfo::SymbolEntryB *se)
00095                 {  return(se->symref);  }
00096         };
00098         struct ORD_TypeID
00099         {
00100             static inline TypeID ord(const ClassInfo *ci)
00101                 {  return(ci->ClassTID());  }
00102         };
00104         struct ORD_TypeID2
00105         {
00106             static inline TypeID ord(const ClassInfoIE *ci)
00107                 {  return(ci->class_tid);  }
00108         };
00109         
00114         class InternalSymbolList
00115         {
00116             private:
00119                 TLLinearQueue<NamespaceInfo::SymbolEntryB,
00120                     TLDefaultOperators_CDT<NamespaceInfo::SymbolEntryB> > 
00121                         sym_stor;
00122                 
00125                 ImplicitMapTable< NamespaceInfo::SymbolEntryB,SymRef,
00126                     ImplicitMapOperators<NamespaceInfo::SymbolEntryB,SymRef,
00127                         ORD_SymRef_SE> > sym_map;
00128                 
00130                 InternalSymbolList(const InternalSymbolList &);
00132                 void operator=(const InternalSymbolList &);
00133             public:
00135                 InternalSymbolList();
00137                 inline ~InternalSymbolList()  {}
00138                 
00140                 NamespaceInfo::SymbolEntryB *LookupStore(SymRef symref);
00141         };
00142         
00144         class InternalClassList
00145         {
00146             private:
00149                 TLLinearQueue<ClassInfoIE,TLDefaultOperators_CDT<ClassInfoIE> > 
00150                         class_stor;
00151                 
00154                 ImplicitMapTable< ClassInfoIE,SymRef,
00155                     ImplicitMapOperators<ClassInfoIE,SymRef,
00156                         ORD_TypeID2> > class_map;
00157                 
00159                 InternalClassList(const InternalClassList &);
00161                 void operator=(const InternalClassList &);
00162             public:
00164                 InternalClassList();
00166                 inline ~InternalClassList()  {}
00167                 
00169                 ClassInfoIE *LookupStore(TypeID tid);
00170         };
00171         
00172     protected:
00174         Config cfg;
00175         
00177         SCLocation filename;
00178         
00181         uint32 file_num;
00182         
00184         TLString abi_version;
00185         
00188         NamespaceInfo *nspc_root;
00189         
00190         typedef TLLinearQueue<GlobalVarEntry,
00191                 TLDefaultOperators_CDT<GlobalVarEntry> > GlobalVarList;
00192         struct _GlobVars {
00194             Offset size;
00196             GlobalVarList globvarq;
00197             
00198             inline _GlobVars() : size(0),globvarq(/*chunk_size=*/32) {}
00199             inline ~_GlobVars() {}
00200         } gvar_v,gvar_p;
00201         
00203         ProgramStorage program;
00204         
00207         ImplicitMapTable< ClassInfo,TypeID,
00208             ImplicitMapOperators<ClassInfo,TypeID,ORD_TypeID> > tid2classinfo;
00209         
00212         ImplicitMapTable< NamespaceInfo::SymbolEntryE,SymRef,
00213             ImplicitMapOperators<NamespaceInfo::SymbolEntryE,SymRef,
00214                 ORD_SymRef_SE> > symref2symbol;
00215         
00217         InternalSymbolList internal_symbols;
00220         InternalClassList internal_classes;
00221         
00227         // NOTE: canNOT be replaced by an ImplicitMapTable<>. 
00228         IDMapTable<SymRef,ProgramStorage::Function*> symref2function;
00230         // NOTE: canNOT be replaced by an ImplicitMapTable<>. 
00231         IDMapTable<SymRef,GlobalVarEntry*> symref2globvar;
00232         
00234         struct SLabelInfo
00235         {
00237             ProgramStorage::Function *pfunc;
00239             NamespaceInfo::SymbolEntryE se;
00240         } slabel_init,slabel_start;
00241         
00242     private:
00244         int _ResolveIDsNamespaceLocal_Recursive(NamespaceInfo *root);
00246         int _ResolveSymrefsInGlobal(_GlobVars *gvar);
00247     
00248     private:
00250         AssemblerFile(const AssemblerFile &);
00251         void operator=(const AssemblerFile &);
00252     protected:
00255         AssemblerFile();
00256     public:
00259         virtual ~AssemblerFile();
00260         
00275         virtual int ParseFile(const TLString &fname,SError &error,
00276             uint32 file_num);
00277         
00294         int ResolveIDsNamespaceLocal();
00295         
00305         virtual int WriteFile(const TLString &fname,SError &error);
00306 };
00307 
00308 }  // end of namespace VM
00309 
00310 #endif  /* _VM_INPUT_ASSEMBLERFILE_H_ */

Generated on Sat Feb 19 22:33:46 2005 for Ray by doxygen 1.3.5