Changeset 525 in dev for trunk/ab5.0/abdev
- Timestamp:
- May 1, 2008, 11:46:43 PM (17 years ago)
- Location:
- trunk/ab5.0/abdev
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/abdev/BasicCompiler_Common/include/Delegate.h
r524 r525 1 1 #pragma once 2 3 class Delegates;4 2 5 3 class Delegate … … 7 5 , public Jenga::Common::ObjectInHashmap<Delegate> 8 6 { 9 friend Delegates;10 11 7 // importされている名前空間 12 8 NamespaceScopesCollection importedNamespaces; … … 43 39 } 44 40 41 const std::string &GetParamStr() const 42 { 43 return paramStr; 44 } 45 const std::string &GetReturnTypeName() const 46 { 47 return returnTypeName; 48 } 49 45 50 void RefleshParameterAndReturnType(); 46 51 … … 61 66 bool IsSimilar( const Delegate &dgt ) const; 62 67 }; 63 64 class Delegates : public Jenga::Common::Hashmap<Delegate> 65 { 66 public: 67 void Collect( const BasicSource &source ); 68 void GenerateSourceCode( std::string &destSource ); 69 void RefleshParameterAndReturnType(); 70 }; 68 typedef Jenga::Common::Hashmap<Delegate> Delegates; -
trunk/ab5.0/abdev/BasicCompiler_Common/include/LexicalAnalyzer.h
r511 r525 30 30 static UserProc* ParseUserProc( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,bool isVirtual,CClass *pobj_c, bool isStatic, char *interfaceName = NULL ); 31 31 static void CollectProcedures( const BasicSource &source, UserProcs &userProcs, DllProcs &dllProcs ); 32 33 // デリゲートを収集する 34 static void CollectDelegates( const BasicSource &source, Delegates &delegates ); 35 static std::string GenerateDelegatesSourceCode( const Delegates &delegates ); 36 static void RefleshDelegatesParameterAndReturnType( Delegates &delegates ); 32 37 }; 33 38 -
trunk/ab5.0/abdev/BasicCompiler_Common/src/Delegate.cpp
r523 r525 42 42 return false; 43 43 } 44 45 void Delegates::Collect( const BasicSource &source )46 {47 int i2;48 char temporary[VN_SIZE];49 50 // 名前空間管理51 NamespaceScopes &namespaceScopes = compiler.GetNamespaceSupporter().GetLivingNamespaceScopes();52 namespaceScopes.clear();53 54 // Importsされた名前空間の管理55 NamespaceScopesCollection &importedNamespaces = compiler.GetNamespaceSupporter().GetImportedNamespaces();56 importedNamespaces.clear();57 58 for( int i=0; i<source.GetLength(); i++ )59 {60 if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){61 for(i+=2,i2=0;;i2++,i++){62 if( IsCommandDelimitation( source[i] ) ){63 temporary[i2]=0;64 break;65 }66 temporary[i2]=source[i];67 }68 namespaceScopes.push_back( temporary );69 70 continue;71 }72 else if( source[i] == 1 && source[i+1] == ESC_ENDNAMESPACE ){73 if( namespaceScopes.size() <= 0 ){74 compiler.errorMessenger.Output(12, "End Namespace", i );75 }76 else{77 namespaceScopes.pop_back();78 }79 80 i += 2;81 continue;82 }83 else if( source[i] == 1 && source[i+1] == ESC_IMPORTS ){84 for(i+=2,i2=0;;i2++,i++){85 if( IsCommandDelimitation( source[i] ) ){86 temporary[i2]=0;87 break;88 }89 temporary[i2]=source[i];90 }91 if( !compiler.GetNamespaceSupporter().ImportsNamespace( temporary ) )92 {93 compiler.errorMessenger.Output(64,temporary,i );94 }95 96 continue;97 }98 else if( source[i] == 1 && source[i+1] == ESC_CLEARNAMESPACEIMPORTED ){99 importedNamespaces.clear();100 continue;101 }102 103 else if( source[i] == 1 && source[i+1] == ESC_DELEGATE )104 {105 int nowLine = i;106 107 i += 2;108 if( !( source[i] == 1 && ( source[i+1] == ESC_SUB || source[i+1] == ESC_FUNCTION ) ) )109 {110 compiler.errorMessenger.Output(1,NULL,i);111 continue;112 }113 114 Procedure::Kind procKind = Procedure::Sub;115 if( source[i+1] == ESC_FUNCTION )116 {117 procKind = Procedure::Function;118 }119 i += 2;120 121 // 名前122 char name[VN_SIZE];123 GetIdentifierToken( name, source.GetBuffer(), i );124 125 if( source[i] != '(' )126 {127 compiler.errorMessenger.Output(1,NULL,nowLine);128 continue;129 }130 131 // パラメータ文字列132 char paramStr[8192];133 i += GetStringInPare( paramStr, source.GetBuffer() + i, true );134 135 // 戻り値の型の文字列136 char returnTypeName[VN_SIZE] = "";137 if( source[i] == 1 && source[i+1] == ESC_AS )138 {139 i += 2;140 GetCommandToken( returnTypeName, source.GetBuffer(), i );141 142 if( procKind != Procedure::Function )143 {144 compiler.errorMessenger.Output(38,name,nowLine);145 }146 }147 else148 {149 if( procKind == Procedure::Function )150 {151 compiler.errorMessenger.Output(-104,name,nowLine);152 lstrcpy( returnTypeName, "Double" );153 }154 }155 156 this->Put( new Delegate( namespaceScopes, importedNamespaces, name, procKind, paramStr, returnTypeName, nowLine ) );157 }158 }159 }160 161 void Delegates::GenerateSourceCode( std::string &destSource )162 {163 destSource = "";164 165 SourceTemplate sourceTemplate( ActiveBasic::Common::Environment::GetAbdevSystemDirPath() + "\\templates\\delegate_class.tab" );166 167 this->Iterator_Reset();168 while( this->Iterator_HasNext() )169 {170 const Delegate &dg = *this->Iterator_GetNext();171 172 if( !dg.isTargetObjectModule )173 {174 // 静的リンクライブラリの場合は飛ばす(既にインスタンスが定義済みであるため)175 continue;176 }177 178 std::map<std::string,std::string> values;179 180 if( dg.GetNamespaceScopes().size() )181 {182 std::string namespaceScopesCommandStr = "";183 std::string endNamespaceScopesCommandStr = "";184 BOOST_FOREACH( const std::string &namespaceStr, dg.GetNamespaceScopes() )185 {186 if( namespaceScopesCommandStr.size() )187 {188 namespaceScopesCommandStr += ":";189 endNamespaceScopesCommandStr += ":";190 }191 namespaceScopesCommandStr += "Namespace " + namespaceStr;192 endNamespaceScopesCommandStr += "End Namespace";193 }194 195 values.insert( std::map<std::string,std::string>::value_type(196 "#namespace_begin#",197 namespaceScopesCommandStr198 ) );199 values.insert( std::map<std::string,std::string>::value_type(200 "#namespace_end#",201 endNamespaceScopesCommandStr202 ) );203 }204 else205 {206 values.insert( std::map<std::string,std::string>::value_type( "#namespace_begin#", "" ) );207 values.insert( std::map<std::string,std::string>::value_type( "#namespace_end#", "" ) );208 }209 210 values.insert( std::map<std::string,std::string>::value_type( "#name#", dg.GetName() ) );211 212 if( dg.IsFunction() )213 {214 values.insert( std::map<std::string,std::string>::value_type(215 "#call_method_begin#",216 (std::string)"Function Call(" + dg.paramStr + ") As " + dg.returnTypeName217 ) );218 219 values.insert( std::map<std::string,std::string>::value_type(220 "#call_method_end#",221 "End Function"222 ) );223 224 values.insert( std::map<std::string,std::string>::value_type( "#result#", "Call=" ) );225 }226 else227 {228 values.insert( std::map<std::string,std::string>::value_type(229 "#call_method_begin#",230 (std::string)"Sub Call(" + dg.paramStr + ")"231 ) );232 233 values.insert( std::map<std::string,std::string>::value_type(234 "#call_method_end#",235 "End Sub"236 ) );237 238 values.insert( std::map<std::string,std::string>::value_type( "#result#", "" ) );239 }240 241 values.insert( std::map<std::string,std::string>::value_type( "#params#", dg.paramStr ) );242 243 destSource += sourceTemplate.GetResult( values );244 }245 /*246 std::ofstream ofs( ( Jenga::Common::Environment::GetAppDir() + "\\generated_delegate_code.log" ).c_str() );247 ofs << destSource;248 ofs.close();249 */250 }251 252 void Delegates::RefleshParameterAndReturnType()253 {254 this->Iterator_Reset();255 while( this->Iterator_HasNext() )256 {257 Delegate &dg = *this->Iterator_GetNext();258 dg.RefleshParameterAndReturnType();259 }260 } -
trunk/ab5.0/abdev/BasicCompiler_Common/src/ObjectModule.cpp
r524 r525 75 75 #include <Variable.h> 76 76 #include <Procedure.h> 77 #include <LexicalAnalyzer.h>78 77 #include <Program.h> 79 78 #include <TypeDef.h> … … 84 83 #include <Exception.h> 85 84 #include <Meta.h> 85 86 86 #include <CodeGenerator.h> 87 87 #include <Messenger.h> … … 91 91 #include <Debugger.h> 92 92 #include <Program.h> 93 #include <LexicalAnalyzer.h> 94 93 95 94 96 -
trunk/ab5.0/abdev/compiler_x86/MakePeHdr.cpp
r523 r525 156 156 // デリゲートに関する情報を収集 157 157 { 158 compiler.GetObjectModule().meta.GetDelegates().Collect( 159 compiler.GetObjectModule().GetCurrentSource() 158 ActiveBasic::Compiler::LexicalAnalyzer::CollectDelegates( 159 compiler.GetObjectModule().GetCurrentSource(), 160 compiler.GetObjectModule().meta.GetDelegates() 160 161 ); 161 162 compiler.GetObjectModule().meta.GetDelegates().Iterator_Init(); 162 163 163 164 // デリゲートからクラスコードを生成 164 std::string tempSource; 165 compiler.GetObjectModule().meta.GetDelegates().GenerateSourceCode( tempSource ); 165 std::string tempSource = ActiveBasic::Compiler::LexicalAnalyzer::GenerateDelegatesSourceCode( 166 compiler.GetObjectModule().meta.GetDelegates() 167 ); 166 168 AddSourceCode( tempSource.c_str() ); 167 169 } … … 183 185 型情報に依存するパラメータ情報を取得できないため、ここでの再取得が必要 184 186 */ 185 compiler.GetObjectModule().meta.GetDelegates().RefleshParameterAndReturnType(); 187 ActiveBasic::Compiler::LexicalAnalyzer::RefleshDelegatesParameterAndReturnType( 188 compiler.GetObjectModule().meta.GetDelegates() 189 ); 186 190 187 191 //定数情報を取得 -
trunk/ab5.0/abdev/compiler_x86/compiler_x86.vcproj
r514 r525 1261 1261 </File> 1262 1262 <File 1263 RelativePath="..\BasicCompiler_Common\src\LexicalAnalyzer_Delegate.cpp" 1264 > 1265 </File> 1266 <File 1263 1267 RelativePath="..\BasicCompiler_Common\src\Linker.cpp" 1264 1268 > … … 1272 1276 > 1273 1277 <File 1274 RelativePath="..\BasicCompiler_Common\src\Class.cpp"1275 >1276 </File>1277 <File1278 1278 RelativePath="..\BasicCompiler_Common\src\Const.cpp" 1279 1279 > … … 1308 1308 </File> 1309 1309 <File 1310 RelativePath="..\BasicCompiler_Common\src\Method.cpp"1311 >1312 </File>1313 <File1314 1310 RelativePath="..\BasicCompiler_Common\src\NativeCode.cpp" 1315 1311 > … … 1345 1341 <File 1346 1342 RelativePath="..\BasicCompiler_Common\src\Source.cpp" 1347 >1348 </File>1349 <File1350 RelativePath="..\BasicCompiler_Common\src\Type.cpp"1351 1343 > 1352 1344 </File> … … 1477 1469 > 1478 1470 <File 1479 RelativePath="..\BasicCompiler_Common\include\Class.h"1480 >1481 </File>1482 <File1483 1471 RelativePath="..\BasicCompiler_Common\include\Const.h" 1484 1472 > … … 1509 1497 </File> 1510 1498 <File 1511 RelativePath="..\BasicCompiler_Common\include\Member.h"1512 >1513 </File>1514 <File1515 1499 RelativePath="..\BasicCompiler_Common\include\Meta.h" 1516 1500 > 1517 1501 </File> 1518 1502 <File 1519 RelativePath="..\BasicCompiler_Common\include\Method.h"1520 >1521 </File>1522 <File1523 1503 RelativePath="..\BasicCompiler_Common\include\NativeCode.h" 1524 1504 > … … 1538 1518 <File 1539 1519 RelativePath="..\BasicCompiler_Common\include\Source.h" 1540 >1541 </File>1542 <File1543 RelativePath="..\BasicCompiler_Common\include\Type.h"1544 1520 > 1545 1521 </File> -
trunk/ab5.0/abdev/compiler_x86/stdafx.h
r524 r525 55 55 #include <Variable.h> 56 56 #include <Procedure.h> 57 #include <LexicalAnalyzer.h>58 57 #include <Program.h> 59 58 #include <TypeDef.h> … … 64 63 #include <Exception.h> 65 64 #include <Meta.h> 65 66 66 #include <CodeGenerator.h> 67 67 #include <Messenger.h> … … 71 71 #include <Debugger.h> 72 72 #include <Program.h> 73 #include <LexicalAnalyzer.h>
Note:
See TracChangeset
for help on using the changeset viewer.