Index: trunk/ab5.0/abdev/ab_common/include/Environment.h
===================================================================
--- trunk/ab5.0/abdev/ab_common/include/Environment.h	(revision 636)
+++ trunk/ab5.0/abdev/ab_common/include/Environment.h	(revision 637)
@@ -27,4 +27,5 @@
 {
 	static std::string rootPath;
+	static bool isRemoveExternal;
 public:
 	static void SetAbdevRootPath( const std::string &rootPath );
@@ -38,4 +39,13 @@
 
 	static const std::string GetCompilerExePath( Platform::EnumType platform );
+
+	static bool IsRemoveExternal()
+	{
+		return isRemoveExternal;
+	}
+	static void SetRemoveExternalMark( bool isRemoveExternalMark )
+	{
+		Environment::isRemoveExternal = isRemoveExternalMark;
+	}
 };
 
Index: trunk/ab5.0/abdev/ab_common/include/Lexical/Class.h
===================================================================
--- trunk/ab5.0/abdev/ab_common/include/Lexical/Class.h	(revision 636)
+++ trunk/ab5.0/abdev/ab_common/include/Lexical/Class.h	(revision 637)
@@ -18,6 +18,6 @@
 
 public:
-	ClassPrototype( const NamespaceScopes &namespaceScopes, const std::string &name )
-		: Prototype( namespaceScopes, name )
+	ClassPrototype( const Symbol &symbol )
+		: Prototype( symbol )
 		, DynamicMethodsPrototype()
 	{
@@ -92,4 +92,14 @@
 
 		ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( ClassPrototype );
+
+		if( ActiveBasic::Common::Environment::IsRemoveExternal() )
+		{
+			if( this->IsExternal() )
+			{
+				this->NeedResolve();
+				return;
+			}
+		}
+
 		ar & BOOST_SERIALIZATION_NVP( classType );
 		ar & BOOST_SERIALIZATION_NVP( importedNamespaces );
@@ -112,8 +122,8 @@
 public:
 
-	CClass( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const std::string &name );
-	CClass( const NamespaceScopes &namespaceScopes,
+	CClass( const Symbol &symbol, const NamespaceScopesCollection &importedNamespaces );
+	CClass( const Symbol &symbol,
 		const NamespaceScopesCollection &importedNamespaces,
-		const std::string &name, ClassType classType,
+		ClassType classType,
 		const GenericTypes &formalGenericTypes,
 		const Types &superClassActualTypeParameters,
@@ -455,4 +465,6 @@
 	std::string GetStaticDefiningStringAsMemberOffsets() const;
 	void GetReferenceOffsetsInitializeBuffer( std::string &referenceOffsetsBuffer, int &numOfReference, int baseOffset = 0 ) const;
+
+	virtual bool Resolve();
 };
 
Index: trunk/ab5.0/abdev/ab_common/include/Lexical/Const.h
===================================================================
--- trunk/ab5.0/abdev/ab_common/include/Lexical/Const.h	(revision 636)
+++ trunk/ab5.0/abdev/ab_common/include/Lexical/Const.h	(revision 637)
@@ -2,5 +2,7 @@
 
 //定数
-class CConst : public Symbol, public Jenga::Common::ObjectInHashmap<CConst>
+class CConst
+	: public RelationalObjectModuleItem
+	, public Jenga::Common::ObjectInHashmap<CConst>
 {
 	Type type;
@@ -14,5 +16,15 @@
 		trace_for_serialize( "serializing - CConst" );
 
-		ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Symbol );
+		ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( RelationalObjectModuleItem );
+
+		if( ActiveBasic::Common::Environment::IsRemoveExternal() )
+		{
+			if( this->IsExternal() )
+			{
+				this->NeedResolve();
+				return;
+			}
+		}
+
 		ar & BOOST_SERIALIZATION_NVP( type );
 		ar & BOOST_SERIALIZATION_NVP( i64data );
@@ -20,12 +32,12 @@
 
 public:
-	CConst( const NamespaceScopes &namespaceScopes, const std::string &name, const Type &newType, _int64 i64data)
-		: Symbol( namespaceScopes, name )
+	CConst( const Symbol &symbol, const Type &newType, _int64 i64data)
+		: RelationalObjectModuleItem( symbol )
 		, type( newType )
 		, i64data( i64data )
 	{
 	}
-	CConst( const NamespaceScopes &namespaceScopes, const std::string &name, int value)
-		: Symbol( namespaceScopes, name )
+	CConst( const Symbol &symbol, int value)
+		: RelationalObjectModuleItem( symbol )
 		, type( Type(DEF_LONG) )
 		, i64data( value )
@@ -53,4 +65,6 @@
 	}
 	double GetDoubleData();
+
+	virtual bool Resolve();
 };
 class Consts : public Jenga::Common::Hashmap<CConst>
@@ -69,6 +83,6 @@
 public:
 
-	void Add( const NamespaceScopes &namespaceScopes, const std::string &name, _int64 i64data, const Type &type );
-	void Add( const NamespaceScopes &namespaceScopes, const std::string &name, int value);
+	void Add( const Symbol &symbol, _int64 i64data, const Type &type );
+	void Add( const Symbol &symbol, int value);
 
 private:
@@ -83,5 +97,7 @@
 
 //定数マクロ
-class ConstMacro : public Symbol, public Jenga::Common::ObjectInHashmap<ConstMacro>
+class ConstMacro
+	: public RelationalObjectModuleItem
+	, public Jenga::Common::ObjectInHashmap<ConstMacro>
 {
 	std::vector<std::string> parameters;
@@ -95,5 +111,15 @@
 		trace_for_serialize( "serializing - ConstMacro" );
 
-		ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Symbol );
+		ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( RelationalObjectModuleItem );
+
+		if( ActiveBasic::Common::Environment::IsRemoveExternal() )
+		{
+			if( this->IsExternal() )
+			{
+				this->NeedResolve();
+				return;
+			}
+		}
+
 		ar & BOOST_SERIALIZATION_NVP( parameters );
 		ar & BOOST_SERIALIZATION_NVP( expression );
@@ -101,6 +127,6 @@
 
 public:
-	ConstMacro( const NamespaceScopes &namespaceScopes, const std::string &name, const std::vector<std::string> &parameters, const std::string &expression )
-		: Symbol( namespaceScopes, name )
+	ConstMacro( const Symbol &symbol, const std::vector<std::string> &parameters, const std::string &expression )
+		: RelationalObjectModuleItem( symbol )
 		, parameters( parameters )
 		, expression( expression )
@@ -127,6 +153,9 @@
 		return expression;
 	}
+
+	virtual bool Resolve();
 };
-class ConstMacros : public Jenga::Common::Hashmap<ConstMacro>
+class ConstMacros
+	: public Jenga::Common::Hashmap<ConstMacro>
 {
 	// XMLシリアライズ用
@@ -142,5 +171,5 @@
 
 public:
-	bool Add( const NamespaceScopes &namespaceScopes, const std::string &name, const char *parameterStr );
+	bool Add( const Symbol &symbol, const char *parameterStr );
 	ConstMacro *Find( const Symbol &name );
 };
Index: trunk/ab5.0/abdev/ab_common/include/Lexical/DataTable.h
===================================================================
--- trunk/ab5.0/abdev/ab_common/include/Lexical/DataTable.h	(revision 636)
+++ trunk/ab5.0/abdev/ab_common/include/Lexical/DataTable.h	(revision 637)
@@ -149,3 +149,5 @@
 
 	void ResetDataSectionBaseOffset( long dataSectionBaseOffset );
+
+	void Resolve();
 };
Index: trunk/ab5.0/abdev/ab_common/include/Lexical/Delegate.h
===================================================================
--- trunk/ab5.0/abdev/ab_common/include/Lexical/Delegate.h	(revision 636)
+++ trunk/ab5.0/abdev/ab_common/include/Lexical/Delegate.h	(revision 637)
@@ -22,4 +22,14 @@
 
 		ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Procedure );
+
+		if( ActiveBasic::Common::Environment::IsRemoveExternal() )
+		{
+			if( this->IsExternal() )
+			{
+				this->NeedResolve();
+				return;
+			}
+		}
+
 		ar & BOOST_SERIALIZATION_NVP( importedNamespaces );
 		ar & BOOST_SERIALIZATION_NVP( dynamicParams );
@@ -27,6 +37,6 @@
 
 public:
-	Delegate( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const std::string &name, Procedure::Kind procKind, const char *paramStr, const std::string &returnTypeName, int sourceIndex )
-		: Procedure( namespaceScopes, name, procKind, false )
+	Delegate( const Symbol &symbol, const NamespaceScopesCollection &importedNamespaces, Procedure::Kind procKind, const char *paramStr, const std::string &returnTypeName, int sourceIndex )
+		: Procedure( symbol, procKind, false )
 		, importedNamespaces( importedNamespaces )
 		, paramStr( paramStr )
@@ -81,4 +91,6 @@
 	*/
 	bool IsSimilar( const Delegate &dgt ) const;
+
+	virtual bool Resolve();
 };
 typedef Jenga::Common::Hashmap<Delegate> Delegates;
Index: trunk/ab5.0/abdev/ab_common/include/Lexical/Meta.h
===================================================================
--- trunk/ab5.0/abdev/ab_common/include/Lexical/Meta.h	(revision 636)
+++ trunk/ab5.0/abdev/ab_common/include/Lexical/Meta.h	(revision 637)
@@ -157,3 +157,5 @@
 
 	const CClass *FindClassSupportedTypeDef( const Symbol &symbol );
+
+	void Resolve();
 };
Index: trunk/ab5.0/abdev/ab_common/include/Lexical/NativeCode.h
===================================================================
--- trunk/ab5.0/abdev/ab_common/include/Lexical/NativeCode.h	(revision 636)
+++ trunk/ab5.0/abdev/ab_common/include/Lexical/NativeCode.h	(revision 637)
@@ -123,9 +123,7 @@
 class SourceLine
 {
-	int lineNum;
 	long nativeCodePos;
-	int relationalObjectModuleIndex;
-	long sourceCodePos;
 	DWORD codeType;
+	SourceCodePosition sourceCodePosition;
 
 	// XMLシリアライズ用
@@ -136,18 +134,14 @@
 		trace_for_serialize( "serializing - SourceLine" );
 
-		ar & BOOST_SERIALIZATION_NVP( lineNum );
 		ar & BOOST_SERIALIZATION_NVP( nativeCodePos );
-		ar & BOOST_SERIALIZATION_NVP( relationalObjectModuleIndex );
-		ar & BOOST_SERIALIZATION_NVP( sourceCodePos );
 		ar & BOOST_SERIALIZATION_NVP( codeType );
-	}
-
-public:
-	SourceLine( int lineNum, int nativeCodePos, int relationalObjectModuleIndex, int sourceCodePos, DWORD codeType )
-		: lineNum( lineNum )
-		, nativeCodePos( nativeCodePos )
-		, relationalObjectModuleIndex( relationalObjectModuleIndex )
-		, sourceCodePos( sourceCodePos )
+		ar & BOOST_SERIALIZATION_NVP( sourceCodePosition );
+	}
+
+public:
+	SourceLine( int nativeCodePos, DWORD codeType, const SourceCodePosition &sourceCodePosition )
+		: nativeCodePos( nativeCodePos )
 		, codeType( codeType )
+		, sourceCodePosition( sourceCodePosition )
 	{
 	}
@@ -156,31 +150,23 @@
 	}
 
-	int GetLineNum() const
-	{
-		return lineNum;
-	}
 	long GetNativeCodePos() const
 	{
 		return nativeCodePos;
 	}
-	int GetRelationalObjectModuleIndex() const
-	{
-		return relationalObjectModuleIndex;
-	}
-	void SetRelationalObjectModuleIndex( int relationalObjectModuleIndex )
-	{
-		this->relationalObjectModuleIndex = relationalObjectModuleIndex;
-	}
-	long GetSourceCodePos() const
-	{
-		return sourceCodePos;
-	}
-	void SetSourceCodePos( int sourceCodePos )
-	{
-		this->sourceCodePos = sourceCodePos;
-	}
 	DWORD GetCodeType() const
 	{
 		return codeType;
+	}
+	const SourceCodePosition &GetSourceCodePosition() const
+	{
+		return sourceCodePosition;
+	}
+	SourceCodePosition &GetSourceCodePosition()
+	{
+		return sourceCodePosition;
+	}
+	void SetSourceCodePosition( const SourceCodePosition &sourceCodePosition )
+	{
+		this->sourceCodePosition = sourceCodePosition;
 	}
 	bool IsInSystemProc() const
@@ -256,7 +242,9 @@
 		return sourceLines;
 	}
-	void NextSourceLine( int currentSourceIndex, int nowLine );
+	void NextSourceLine( const SourceCodePosition &sourceCodePosition );
 
 	void ResetDataSectionBaseOffset( long dataSectionBaseOffset );
-	void ResetSourceIndexes( const std::vector<int> &relationTable );
+	void ResetRelationalObjectModuleIndex( const std::vector<int> &relationTable );
+
+	void Resolve();
 };
Index: trunk/ab5.0/abdev/ab_common/include/Lexical/ObjectModule.h
===================================================================
--- trunk/ab5.0/abdev/ab_common/include/Lexical/ObjectModule.h	(revision 636)
+++ trunk/ab5.0/abdev/ab_common/include/Lexical/ObjectModule.h	(revision 637)
@@ -43,5 +43,4 @@
 
 public:
-	void StaticLink( ObjectModule &objectModule );
 
 	const std::string &GetName() const
@@ -62,4 +61,10 @@
 	}
 
+	// 静的リンクを行う
+	void StaticLink( ObjectModule &objectModule, bool isSll );
+
+	// 依存関係の解決を行う
+	void Resolve();
+
 	// 下記の関連になるようなテーブルを取得する
 	// 要素 = 古いインデックス、値 = 新しいインデックス
Index: trunk/ab5.0/abdev/ab_common/include/Lexical/Procedure.h
===================================================================
--- trunk/ab5.0/abdev/ab_common/include/Lexical/Procedure.h	(revision 636)
+++ trunk/ab5.0/abdev/ab_common/include/Lexical/Procedure.h	(revision 637)
@@ -1,5 +1,6 @@
 #pragma once
 
-class Procedure : public Symbol
+class Procedure
+	: public RelationalObjectModuleItem
 {
 public:
@@ -35,5 +36,5 @@
 		trace_for_serialize( "serializing - Procedure" );
 
-		ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Symbol );
+		ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( RelationalObjectModuleItem );
 		ar & BOOST_SERIALIZATION_NVP( kind );
 		ar & BOOST_SERIALIZATION_NVP( isCdecl );
@@ -45,6 +46,6 @@
 
 public:
-	Procedure( const NamespaceScopes &namespaceScopes, const std::string &name, Kind kind, bool isCdecl )
-		: Symbol( namespaceScopes, name )
+	Procedure( const Symbol &symbol, Kind kind, bool isCdecl )
+		: RelationalObjectModuleItem( symbol )
 		, kind( kind )
 		, isCdecl( isCdecl )
@@ -91,4 +92,5 @@
 		this->sourceCodePosition = sourceCodePosition;
 	}
+	virtual void ResetRelationalObjectModuleIndex( const std::vector<int> &relationTable );
 
 	const Parameters &Params() const
@@ -156,4 +158,14 @@
 
 		ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Procedure );
+
+		if( ActiveBasic::Common::Environment::IsRemoveExternal() )
+		{
+			if( this->IsExternal() )
+			{
+				this->NeedResolve();
+				return;
+			}
+		}
+
 		ar & BOOST_SERIALIZATION_NVP( _paramStr );
 		ar & BOOST_SERIALIZATION_NVP( importedNamespaces );
@@ -178,5 +190,5 @@
 public:
 
-	UserProc( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const std::string &name, Kind kind, bool isMacro, bool isCdecl, bool isExport );
+	UserProc( const Symbol &symbol, const NamespaceScopesCollection &importedNamespaces, Kind kind, bool isMacro, bool isCdecl, bool isExport );
 	UserProc( const UserProc &userProc, const CClass *pParentClass );
 	UserProc();
@@ -206,4 +218,6 @@
 	}
 
+	virtual void ResetRelationalObjectModuleIndex( const std::vector<int> &relationTable );
+
 	/*!
 	@brief	オーバーライド用に関数同士が等しいかどうかをチェックする
@@ -360,4 +374,5 @@
 	const CMethod &GetMethod() const;
 
+	virtual bool Resolve();
 
 	static const UserProc *pGlobalProc;
@@ -389,5 +404,7 @@
 };
 
-class DllProc : public Procedure, public Jenga::Common::ObjectInHashmap<DllProc>
+class DllProc
+	: public Procedure
+	, public Jenga::Common::ObjectInHashmap<DllProc>
 {
 	std::string dllFileName;
@@ -403,4 +420,14 @@
 
 		ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Procedure );
+
+		if( ActiveBasic::Common::Environment::IsRemoveExternal() )
+		{
+			if( this->IsExternal() )
+			{
+				this->NeedResolve();
+				return;
+			}
+		}
+
 		ar & BOOST_SERIALIZATION_NVP( dllFileName );
 		ar & BOOST_SERIALIZATION_NVP( alias );
@@ -409,6 +436,6 @@
 
 public:
-	DllProc( const NamespaceScopes &namespaceScopes, const std::string &name, Kind kind, bool isCdecl, const std::string &dllFileName, const std::string &alias )
-		: Procedure( namespaceScopes, name, kind, isCdecl )
+	DllProc( const Symbol &symbol, Kind kind, bool isCdecl, const std::string &dllFileName, const std::string &alias )
+		: Procedure( symbol, kind, isCdecl )
 		, dllFileName( dllFileName )
 		, alias( alias )
@@ -454,4 +481,6 @@
 		return lookupAddress;
 	}
+
+	virtual bool Resolve();
 };
 class DllProcs : public Jenga::Common::Hashmap<DllProc>
@@ -469,5 +498,6 @@
 };
 
-class ProcPointer : public Procedure
+class ProcPointer
+	: public Procedure
 {
 	// XMLシリアライズ用
@@ -483,5 +513,5 @@
 public:
 	ProcPointer( Kind kind )
-		: Procedure( NamespaceScopes(), std::string(), kind, false )
+		: Procedure( Symbol( NamespaceScopes(), std::string() ), kind, false )
 	{
 	}
@@ -489,5 +519,9 @@
 	{
 	}
-	~ProcPointer(){}
+	~ProcPointer()
+	{
+	}
+
+	virtual bool Resolve();
 };
 
Index: trunk/ab5.0/abdev/ab_common/include/Lexical/Prototype.h
===================================================================
--- trunk/ab5.0/abdev/ab_common/include/Lexical/Prototype.h	(revision 636)
+++ trunk/ab5.0/abdev/ab_common/include/Lexical/Prototype.h	(revision 637)
@@ -4,5 +4,6 @@
 
 
-class Prototype : public Symbol
+class Prototype
+	: public RelationalObjectModuleItem
 {
 public:
@@ -23,5 +24,5 @@
 	template<class Archive> void serialize(Archive& ar, const unsigned int version)
 	{
-		ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Symbol );
+		ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( RelationalObjectModuleItem );
 		ar & BOOST_SERIALIZATION_NVP( isUsing );
 	}
@@ -30,11 +31,10 @@
 public:
 
-	Prototype( const NamespaceScopes &namespaceScopes, const std::string &name )
-		: Symbol( namespaceScopes, name )
+	Prototype( const Symbol &symbol )
+		: RelationalObjectModuleItem( symbol )
 		, isUsing( false )
 	{
 	}
 	Prototype()
-		: Symbol()
 	{
 	}
Index: trunk/ab5.0/abdev/ab_common/include/Lexical/RelationalObjectModuleItem.h
===================================================================
--- trunk/ab5.0/abdev/ab_common/include/Lexical/RelationalObjectModuleItem.h	(revision 637)
+++ trunk/ab5.0/abdev/ab_common/include/Lexical/RelationalObjectModuleItem.h	(revision 637)
@@ -0,0 +1,72 @@
+#pragma once
+
+namespace ActiveBasic{ namespace Common{ namespace Lexical{
+
+
+class RelationalObjectModuleItem
+	: public Symbol
+{
+	int relationalObjectModuleIndex;
+
+	// XMLシリアライズ用
+private:
+	friend class boost::serialization::access;
+	template<class Archive> void serialize(Archive& ar, const unsigned int version)
+	{
+		ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Symbol );
+		ar & BOOST_SERIALIZATION_NVP( relationalObjectModuleIndex );
+	}
+
+public:
+	RelationalObjectModuleItem( const RelationalObjectModuleItem &relationalObjectModuleItem )
+		: Symbol( relationalObjectModuleItem )
+		, relationalObjectModuleIndex( relationalObjectModuleItem.relationalObjectModuleIndex )
+		, isNeedResolve( false )
+	{
+	}
+	RelationalObjectModuleItem( const Symbol &symbol )
+		: Symbol( symbol )
+		, relationalObjectModuleIndex( 0 )
+		, isNeedResolve( false )
+	{
+	}
+	RelationalObjectModuleItem()
+		: relationalObjectModuleIndex( -1 )
+		, isNeedResolve( false )
+	{
+	}
+
+	int GetRelationalObjectModuleIndex() const
+	{
+		return relationalObjectModuleIndex;
+	}
+	void SetRelationalObjectModuleIndex( int relationalObjectModuleIndex )
+	{
+		this->relationalObjectModuleIndex = relationalObjectModuleIndex;
+	}
+
+	virtual void ResetRelationalObjectModuleIndex( const std::vector<int> &relationTable )
+	{
+		this->relationalObjectModuleIndex = relationTable[this->relationalObjectModuleIndex];
+	}
+
+	bool IsExternal() const
+	{
+		return ( relationalObjectModuleIndex != 0 );
+	}
+
+	bool isNeedResolve;
+	bool IsNeedResolve() const
+	{
+		return isNeedResolve;
+	}
+	void NeedResolve()
+	{
+		isNeedResolve = true;
+	}
+
+	virtual bool Resolve() = 0;
+};
+
+
+}}}
Index: trunk/ab5.0/abdev/ab_common/include/Lexical/Source.h
===================================================================
--- trunk/ab5.0/abdev/ab_common/include/Lexical/Source.h	(revision 636)
+++ trunk/ab5.0/abdev/ab_common/include/Lexical/Source.h	(revision 637)
@@ -265,5 +265,5 @@
 class SourceCodePosition
 {
-	std::string objectModuleName;
+	int relationalObjectModuleIndex;
 	int pos;
 
@@ -273,24 +273,24 @@
 	template<class Archive> void serialize(Archive& ar, const unsigned int version)
 	{
-		trace_for_serialize( "serializing - IncludedFilesRelation" );
-
-		ar & BOOST_SERIALIZATION_NVP( objectModuleName );
+		ar & BOOST_SERIALIZATION_NVP( relationalObjectModuleIndex );
 		ar & BOOST_SERIALIZATION_NVP( pos );
 	}
 
 public:
-	SourceCodePosition( const std::string &objectModuleName, int pos )
-		: objectModuleName( objectModuleName )
+	SourceCodePosition( int relationalObjectModuleIndex, int pos )
+		: relationalObjectModuleIndex( relationalObjectModuleIndex )
 		, pos( pos )
 	{
 	}
 	SourceCodePosition()
-		: pos( -1 )
-	{
-	}
-
-	const std::string &GetObjectModuleName() const
-	{
-		return objectModuleName;
+		: relationalObjectModuleIndex( -1 )
+		, pos( -1 )
+	{
+	}
+
+	int GetRelationalObjectModuleIndex() const;
+	void SetRelationalObjectModuleIndex( int relationalObjectModuleIndex )
+	{
+		this->relationalObjectModuleIndex = relationalObjectModuleIndex;
 	}
 	int GetPos() const
@@ -298,3 +298,9 @@
 		return pos;
 	}
-};
+	void SetPos( int pos )
+	{
+		this->pos = pos;
+	}
+
+	bool IsNothing() const;
+};
Index: trunk/ab5.0/abdev/ab_common/include/Lexical/Symbol.h
===================================================================
--- trunk/ab5.0/abdev/ab_common/include/Lexical/Symbol.h	(revision 636)
+++ trunk/ab5.0/abdev/ab_common/include/Lexical/Symbol.h	(revision 637)
@@ -38,9 +38,7 @@
 
 public:
-	bool isTargetObjectModule;
 	Symbol( const NamespaceScopes &namespaceScopes, const std::string &name )
 		: namespaceScopes( namespaceScopes )
 		, name( name )
-		, isTargetObjectModule( true )
 	{
 	}
@@ -48,9 +46,7 @@
 		: namespaceScopes( symbol.namespaceScopes )
 		, name( symbol.name )
-		, isTargetObjectModule( true )
 	{
 	}
 	Symbol()
-		: isTargetObjectModule( true )
 	{
 	}
Index: trunk/ab5.0/abdev/ab_common/include/Lexical/Type.h
===================================================================
--- trunk/ab5.0/abdev/ab_common/include/Lexical/Type.h	(revision 636)
+++ trunk/ab5.0/abdev/ab_common/include/Lexical/Type.h	(revision 637)
@@ -318,13 +318,10 @@
 
 public:
-	bool isTargetObjectModule;
 	BlittableType( const Type &basicType, CClass *pClass )
 		: basicType( basicType )
 		, pClass( pClass )
-		, isTargetObjectModule( true )
 	{
 	}
 	BlittableType()
-		: isTargetObjectModule( true )
 	{
 	}
Index: trunk/ab5.0/abdev/ab_common/include/Lexical/TypeDef.h
===================================================================
--- trunk/ab5.0/abdev/ab_common/include/Lexical/TypeDef.h	(revision 636)
+++ trunk/ab5.0/abdev/ab_common/include/Lexical/TypeDef.h	(revision 637)
@@ -3,5 +3,6 @@
 class TypeDefCollection;
 
-class TypeDef : public Symbol
+class TypeDef
+	: public RelationalObjectModuleItem
 {
 	friend TypeDefCollection;
@@ -17,5 +18,15 @@
 		trace_for_serialize( "serializing - TypeDef" );
 
-		ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Symbol );
+		ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( RelationalObjectModuleItem );
+
+		if( ActiveBasic::Common::Environment::IsRemoveExternal() )
+		{
+			if( this->IsExternal() )
+			{
+				this->NeedResolve();
+				return;
+			}
+		}
+
 		ar & BOOST_SERIALIZATION_NVP( baseName );
 		ar & BOOST_SERIALIZATION_NVP( baseType );
@@ -23,5 +34,5 @@
 
 public:
-	TypeDef( const NamespaceScopes &namespaceScopes, const std::string &name, const std::string &baseName, const Type &baseType );
+	TypeDef( const Symbol &symbol, const std::string &baseName, const Type &baseType );
 	TypeDef()
 	{
@@ -39,4 +50,6 @@
 		return baseType;
 	}
+
+	virtual bool Resolve();
 };
 
@@ -58,5 +71,5 @@
 	~TypeDefCollection();
 
-	void Add( const NamespaceScopes &namespaceScopes, const std::string &name, const std::string &baseName, int nowLine );
+	void Add( const Symbol &symbol, const std::string &baseName, int nowLine );
 	const TypeDef *Find( const Symbol &symbol ) const;
 };
Index: trunk/ab5.0/abdev/ab_common/include/Lexical/Variable.h
===================================================================
--- trunk/ab5.0/abdev/ab_common/include/Lexical/Variable.h	(revision 636)
+++ trunk/ab5.0/abdev/ab_common/include/Lexical/Variable.h	(revision 637)
@@ -1,5 +1,6 @@
 #pragma once
 
-class Variable : public Symbol
+class Variable
+	: public RelationalObjectModuleItem
 {
 	Type type;
@@ -36,5 +37,15 @@
 		trace_for_serialize( "serializing - Variable" );
 
-		ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Symbol );
+		ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( RelationalObjectModuleItem );
+
+		if( ActiveBasic::Common::Environment::IsRemoveExternal() )
+		{
+			if( this->IsExternal() )
+			{
+				this->NeedResolve();
+				return;
+			}
+		}
+
 		ar & BOOST_SERIALIZATION_NVP( type );
 		ar & BOOST_SERIALIZATION_NVP( isConst );
@@ -53,5 +64,4 @@
 public:
 	Variable( const Symbol &symbol, const Type &type, bool isConst, bool isRef, const std::string &paramStrForConstructor, bool hasInitData );
-	Variable( const NamespaceScopes &namespaceScopes, const std::string &name, const Type &type, bool isConst, bool isRef, const std::string &paramStrForConstructor, bool hasInitData );
 	Variable( const Variable &var );
 	Variable();
@@ -165,4 +175,6 @@
 	}
 
+	virtual bool Resolve();
+
 
 	bool isLiving;
Index: trunk/ab5.0/abdev/ab_common/include/ab_common.h
===================================================================
--- trunk/ab5.0/abdev/ab_common/include/ab_common.h	(revision 636)
+++ trunk/ab5.0/abdev/ab_common/include/ab_common.h	(revision 637)
@@ -8,4 +8,5 @@
 #include "Lexical/NamespaceSupporter.h"
 #include "Lexical/Symbol.h"
+#include "Lexical/RelationalObjectModuleItem.h"
 #include "Lexical/Prototype.h"
 #include "Lexical/TypeMisc.h"
@@ -13,6 +14,6 @@
 using namespace ActiveBasic::Common::Lexical;
 
+#include "Lexical/Source.h"
 #include "Lexical/NativeCode.h"
-#include "Lexical/Source.h"
 #include "Lexical/Type.h"
 #include "Lexical/Method.h"
