00001 /* 00002 * vm/program.h 00003 * 00004 * VM program storage. 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_PROGRAM_H_ 00018 #define _VM_PROGRAM_H_ 1 00019 00027 #include <vm/vmconfig.h> /* MUST be first */ 00028 #include <vm/instruction/storage.h> 00029 #include <lib/tl/linkedlist.h> 00030 #include <lib/lex/location.h> 00031 00032 00033 namespace VM 00034 { 00035 00048 class ProgramStorage 00049 { 00050 public: 00069 class Function : 00070 public LinkedListBase<Function>, 00071 public InstructionStorage 00072 { 00073 public: 00074 union { 00076 SymRef symref; 00080 NamespaceInfo::SymbolEntryE *se; 00081 }; 00082 00084 SCLocation loc; 00085 00086 private: 00088 Function(const Function &); 00090 void operator=(const Function &); 00091 public: 00093 Function(SymRef _symref,const SCLocation &_loc, 00094 PrgAdr prealloc_size=0); 00096 ~Function(); 00097 }; 00098 00099 private: 00101 LinkedList<Function> flist; 00102 00103 private: 00105 ProgramStorage(const ProgramStorage &); 00107 void operator=(const ProgramStorage &); 00108 public: 00110 ProgramStorage(); 00112 ~ProgramStorage(); 00113 00115 inline Function *FirstFunction() 00116 { return(flist.first()); } 00117 00125 void AddFunction(Function *f); 00126 }; 00127 00128 } // end of namespace VM 00129 00130 #endif /* _VM_PROGRAM_H_ */