#include "stdafx.h" #include Delegate::Delegate( const NamespaceScopes &namespaceScopes, const std::string &name, Procedure::Kind procKind, const char *paramStr, const Type &returnType, int nowLine ) : Procedure( namespaceScopes, name, procKind, false ) { this->returnType = returnType; params.Analyze( paramStr, nowLine ); } 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, name, procKind, paramStr, returnType, 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(); 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() ) ); std::string paramsStr = dg.Params().GetString(); if( dg.IsFunction() ) { values.insert( std::map::value_type( "#call_method_begin#", (string)"Function Call(" + paramsStr + ") As " + compiler.TypeToString( dg.ReturnType() ) ) ); 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(" + paramsStr + ")" ) ); 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#", paramsStr ) ); destSource += sourceTemplate.GetResult( values ); } }