#include "stdafx.h" #include void Delegate::RefleshParameterAndReturnType() { compiler.GetNamespaceSupporter().SetImportedNamespaces( this->importedNamespaces ); compiler.GetNamespaceSupporter().SetLivingNamespaceScopes( this->GetNamespaceScopes() ); // パラメータを解析 params.Analyze( paramStr.c_str(), sourceIndex ); // 動的パラメータを作る dynamicParams = params; dynamicParams.insert( dynamicParams.begin(), new Parameter( "_System_LocalThis", Type( DEF_PTR_VOID ) ) ); if( IsFunction() ) { // 戻り値を取得 if( !compiler.StringToType( returnTypeName, returnType ) ) { SetError(3,returnTypeName,sourceIndex); } } } bool Delegate::IsSimilar( const Delegate &dgt ) const { if( this->Params().Equals( dgt.Params(), true ) ) // パラメータが等しい、もしくは反変 { if( this->returnType.Equals( dgt.returnType ) ) { // 戻り値が等しい return true; } else if( this->returnType.IsCovariant( dgt.returnType ) ) { // 戻り値が共変 return true; } } return false; } void Delegates::Collect( const BasicSource &source ) { int i2; char temporary[VN_SIZE]; // 名前空間管理 NamespaceScopes &namespaceScopes = compiler.GetNamespaceSupporter().GetLivingNamespaceScopes(); namespaceScopes.clear(); // Importsされた名前空間の管理 NamespaceScopesCollection &importedNamespaces = compiler.GetNamespaceSupporter().GetImportedNamespaces(); importedNamespaces.clear(); for( int i=0; iPut( new Delegate( namespaceScopes, importedNamespaces, name, procKind, paramStr, returnTypeName, nowLine ) ); } } } void Delegates::GenerateSourceCode( std::string &destSource ) { destSource = ""; SourceTemplate sourceTemplate( "\\SubOperation\\templates\\delegate_class.tab" ); this->Iterator_Reset(); while( this->Iterator_HasNext() ) { const Delegate &dg = *this->Iterator_GetNext(); if( !dg.isTargetObjectModule ) { // 静的リンクライブラリの場合は飛ばす(既にインスタンスが定義済みであるため) continue; } std::map values; if( dg.GetNamespaceScopes().size() ) { std::string namespaceScopesCommandStr = ""; std::string endNamespaceScopesCommandStr = ""; BOOST_FOREACH( const std::string &namespaceStr, dg.GetNamespaceScopes() ) { if( namespaceScopesCommandStr.size() ) { namespaceScopesCommandStr += ":"; endNamespaceScopesCommandStr += ":"; } namespaceScopesCommandStr += "Namespace " + namespaceStr; endNamespaceScopesCommandStr += "End Namespace"; } values.insert( std::map::value_type( "#namespace_begin#", namespaceScopesCommandStr ) ); values.insert( std::map::value_type( "#namespace_end#", endNamespaceScopesCommandStr ) ); } else { values.insert( std::map::value_type( "#namespace_begin#", "" ) ); values.insert( std::map::value_type( "#namespace_end#", "" ) ); } values.insert( std::map::value_type( "#name#", dg.GetName() ) ); if( dg.IsFunction() ) { values.insert( std::map::value_type( "#call_method_begin#", (string)"Function Call(" + dg.paramStr + ") As " + dg.returnTypeName ) ); values.insert( std::map::value_type( "#call_method_end#", "End Function" ) ); values.insert( std::map::value_type( "#result#", "Call=" ) ); } else { values.insert( std::map::value_type( "#call_method_begin#", (string)"Sub Call(" + dg.paramStr + ")" ) ); values.insert( std::map::value_type( "#call_method_end#", "End Sub" ) ); values.insert( std::map::value_type( "#result#", "" ) ); } values.insert( std::map::value_type( "#params#", dg.paramStr ) ); destSource += sourceTemplate.GetResult( values ); } /* ofstream ofs( ( Jenga::Common::Environment::GetAppDir() + "\\generated_delegate_code.log" ).c_str() ); ofs << destSource; ofs.close(); */ } void Delegates::RefleshParameterAndReturnType() { this->Iterator_Reset(); while( this->Iterator_HasNext() ) { Delegate &dg = *this->Iterator_GetNext(); dg.RefleshParameterAndReturnType(); } }