#include "stdafx.h" using namespace ActiveBasic::Compiler; void LexicalAnalyzer::CollectDelegates( const char *source, Delegates &delegates ) { int i2; char temporary[VN_SIZE]; // 名前空間管理 NamespaceScopes &namespaceScopes = compiler.GetNamespaceSupporter().GetLivingNamespaceScopes(); namespaceScopes.clear(); // Importsされた名前空間の管理 NamespaceScopesCollection &importedNamespaces = compiler.GetNamespaceSupporter().GetImportedNamespaces(); importedNamespaces.clear(); int length = lstrlen( source ); for( int i=0; i 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#", (std::string)"Function Call(" + dg.GetParamStr() + ") As " + dg.GetReturnTypeName() ) ); 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#", (std::string)"Sub Call(" + dg.GetParamStr() + ")" ) ); 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.GetParamStr() ) ); destSource += sourceTemplate.GetResult( values ); } /* std::ofstream ofs( ( Jenga::Common::Environment::GetAppDir() + "\\generated_delegate_code.log" ).c_str() ); ofs << destSource; ofs.close(); */ return destSource; } void LexicalAnalyzer::RefleshDelegateParameterAndReturnType( Delegate &dg ) { compiler.GetNamespaceSupporter().SetImportedNamespaces( dg.GetImportedNamespaces() ); compiler.GetNamespaceSupporter().SetLivingNamespaceScopes( dg.GetNamespaceScopes() ); // パラメータを解析 Jenga::Common::Strings parameterStrings; SplitParameter( dg.GetParamStr(), parameterStrings ); int sourceIndex; ActiveBasic::Compiler::LexicalAnalyzer::AnalyzeParameter( dg.GetParameters(), parameterStrings, sourceIndex ); dg.SetSourceIndex( sourceIndex ); // 動的パラメータを作る dg.GetDynamicParams() = dg.GetParameters(); dg.GetDynamicParams().insert( dg.GetDynamicParams().begin(), new Parameter( "_System_LocalThis", Type( DEF_PTR_VOID ) ) ); if( dg.IsFunction() ) { // 戻り値を取得 Type returnType; if( !compiler.StringToType( dg.GetReturnTypeName(), returnType ) ) { compiler.errorMessenger.Output(3,dg.GetReturnTypeName(),sourceIndex); } else { dg.SetReturnType( returnType ); } } } void LexicalAnalyzer::RefleshDelegatesParameterAndReturnType( Delegates &delegates ) { delegates.Iterator_Reset(); while( delegates.Iterator_HasNext() ) { Delegate &dg = *delegates.Iterator_GetNext(); RefleshDelegateParameterAndReturnType( dg ); } }