00001 /* 00002 FALCON - The Falcon Programming Language. 00003 FILE: vmmaps.hm_currentModule 00004 00005 The Representation of module live data once linked in a VM 00006 ------------------------------------------------------------------- 00007 Author: Giancarlo Niccolai 00008 Begin: Fri, 03 Apr 2009 23:09:55 +0200 00009 00010 ------------------------------------------------------------------- 00011 (C) Copyright 2009: the FALCON developers (see list in AUTHORS file) 00012 00013 See LICENSE file for licensing details. 00014 */ 00015 00020 #ifndef FALCON_LIVEMODULE_H 00021 #define FALCON_LIVEMODULE_H 00022 00023 #include <falcon/setup.h> 00024 #include <falcon/types.h> 00025 #include <falcon/carray.h> 00026 #include <falcon/genericmap.h> 00027 #include <falcon/symbol.h> 00028 #include <falcon/string.h> 00029 #include <falcon/module.h> 00030 #include <falcon/basealloc.h> 00031 #include <falcon/strtable.h> 00032 00033 namespace Falcon 00034 { 00035 00068 class FALCON_DYN_CLASS LiveModule: public Garbageable 00069 { 00070 Module *m_module; 00071 mutable CoreString** m_strings; 00072 mutable uint32 m_strCount; 00073 mutable uint32 m_aacc; 00074 mutable int32 m_iacc; 00075 ItemArray m_globals; 00076 ItemArray m_wkitems; 00077 bool m_bPrivate; 00078 bool m_bAlive; 00079 bool m_needsCompleteLink; 00080 00081 ItemArray m_userItems; 00082 00083 public: 00084 typedef enum { 00085 init_none, 00086 init_trav, 00087 init_complete 00088 } t_initState; 00089 00090 private: 00091 t_initState m_initState; 00092 00093 public: 00094 LiveModule( Module *mod, bool bPrivate=false ); 00095 ~LiveModule(); 00096 00097 virtual bool finalize(); 00098 00099 const Module *module() const { return m_module; } 00100 const ItemArray &globals() const { return m_globals; } 00101 ItemArray &globals() { return m_globals; } 00102 00103 const ItemArray &wkitems() const { return m_wkitems; } 00104 ItemArray &wkitems() { return m_wkitems; } 00105 00107 const String &name() const { return m_module->name(); } 00108 00110 void detachModule(); 00111 00116 bool isAlive() const { return m_bAlive; } 00117 00124 Item *findModuleItem( const String &symName ) const; 00125 00133 bool isPrivate() const { return m_bPrivate; } 00134 00140 void setPrivate( bool mode ) { m_bPrivate = mode; } 00141 00142 t_initState initialized() const { return m_initState; } 00143 void initialized( t_initState tis ) { m_initState = tis; } 00144 00147 String* getString( uint32 stringId ) const; 00148 00150 bool needsCompleteLink() const { return m_needsCompleteLink; } 00151 00153 void needsCompleteLink( bool l ) { m_needsCompleteLink = l; } 00154 00155 void gcMark( uint32 mark ); 00156 00169 ItemArray& userItems() { return m_userItems; } 00170 const ItemArray& userItems() const { return m_userItems; } 00171 }; 00172 00173 00174 class LiveModulePtrTraits: public ElementTraits 00175 { 00176 public: 00177 virtual ~LiveModulePtrTraits() {} 00178 virtual uint32 memSize() const; 00179 virtual void init( void *itemZone ) const; 00180 virtual void copy( void *targetZone, const void *sourceZone ) const; 00181 virtual int compare( const void *first, const void *second ) const; 00182 virtual void destroy( void *item ) const; 00183 virtual bool owning() const; 00184 }; 00185 00186 } 00187 00188 #endif 00189 00190 /* end of livemodule.h */