Changeset 206 in dev for trunk/abdev
- Timestamp:
- Jul 12, 2007, 2:58:26 AM (17 years ago)
- Location:
- trunk/abdev
- Files:
-
- 13 added
- 3 deleted
- 96 edited
- 6 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler32/BasicCompiler.vcproj
r195 r206 53 53 BasicRuntimeChecks="3" 54 54 RuntimeLibrary="1" 55 UsePrecompiledHeader="2" 55 56 PrecompiledHeaderFile=".\Debug/BasicCompiler.pch" 56 57 AssemblerListingLocation=".\Debug/" 57 58 ObjectFile=".\Debug/" 58 59 ProgramDataBaseFileName=".\Debug/" 59 BrowseInformation=" 1"60 BrowseInformation="0" 60 61 WarningLevel="3" 61 62 SuppressStartupBanner="true" … … 155 156 EnableFunctionLevelLinking="true" 156 157 RuntimeTypeInfo="true" 158 UsePrecompiledHeader="2" 157 159 PrecompiledHeaderFile=".\Release/BasicCompiler.pch" 158 160 AssemblerListingLocation=".\Release/" … … 242 244 </FileConfiguration> 243 245 </File> 246 <File 247 RelativePath=".\stdafx.cpp" 248 > 249 <FileConfiguration 250 Name="Debug|Win32" 251 > 252 <Tool 253 Name="VCCLCompilerTool" 254 UsePrecompiledHeader="1" 255 /> 256 </FileConfiguration> 257 <FileConfiguration 258 Name="Release|Win32" 259 > 260 <Tool 261 Name="VCCLCompilerTool" 262 UsePrecompiledHeader="1" 263 /> 264 </FileConfiguration> 265 </File> 244 266 <Filter 245 267 Name="32及び64共通" … … 776 798 <File 777 799 RelativePath="..\BasicCompiler_Common\PESchedule.h" 778 >779 </File>780 </Filter>781 <Filter782 Name="Constant"783 >784 <File785 RelativePath="..\BasicCompiler_Common\Const.cpp"786 >787 <FileConfiguration788 Name="Debug|Win32"789 >790 <Tool791 Name="VCCLCompilerTool"792 PreprocessorDefinitions=""793 />794 </FileConfiguration>795 <FileConfiguration796 Name="Release|Win32"797 >798 <Tool799 Name="VCCLCompilerTool"800 PreprocessorDefinitions=""801 />802 </FileConfiguration>803 </File>804 <File805 RelativePath="..\BasicCompiler_Common\Const.h"806 800 > 807 801 </File> … … 1252 1246 > 1253 1247 <File 1254 RelativePath="..\BasicCompiler_Common\src\Class Impl.cpp"1248 RelativePath="..\BasicCompiler_Common\src\Class.cpp" 1255 1249 > 1256 1250 </File> … … 1264 1258 </File> 1265 1259 <File 1260 RelativePath="..\BasicCompiler_Common\src\Const.cpp" 1261 > 1262 </File> 1263 <File 1266 1264 RelativePath="..\BasicCompiler_Common\src\DataTable.cpp" 1267 1265 > … … 1276 1274 </File> 1277 1275 <File 1276 RelativePath="..\BasicCompiler_Common\src\Method.cpp" 1277 > 1278 </File> 1279 <File 1278 1280 RelativePath="..\BasicCompiler_Common\src\NamespaceSupporter.cpp" 1279 1281 > 1280 1282 </File> 1281 1283 <File 1282 RelativePath="..\BasicCompiler_Common\src\Procedure Impl.cpp"1284 RelativePath="..\BasicCompiler_Common\src\Procedure.cpp" 1283 1285 > 1284 1286 </File> … … 1292 1294 </File> 1293 1295 <File 1296 RelativePath="..\BasicCompiler_Common\src\Symbol.cpp" 1297 > 1298 </File> 1299 <File 1300 RelativePath="..\BasicCompiler_Common\src\Type.cpp" 1301 > 1302 </File> 1303 <File 1294 1304 RelativePath="..\BasicCompiler_Common\src\TypeDef.cpp" 1295 1305 > 1296 1306 </File> 1297 1307 <File 1298 RelativePath="..\BasicCompiler_Common\src\Variable Impl.cpp"1308 RelativePath="..\BasicCompiler_Common\src\Variable.cpp" 1299 1309 > 1300 1310 </File> … … 1310 1320 </File> 1311 1321 <File 1312 RelativePath="..\BasicCompiler_Common\BasicFixed.h"1313 >1314 </File>1315 <File1316 1322 RelativePath="CommandValue.h" 1317 1323 > … … 1327 1333 <File 1328 1334 RelativePath="..\BasicCompiler_Common\include\option.h" 1335 > 1336 </File> 1337 <File 1338 RelativePath=".\stdafx.h" 1329 1339 > 1330 1340 </File> … … 1353 1363 > 1354 1364 <File 1355 RelativePath="..\BasicCompiler_Common\include\Class Impl.h"1365 RelativePath="..\BasicCompiler_Common\include\Class.h" 1356 1366 > 1357 1367 </File> … … 1365 1375 </File> 1366 1376 <File 1377 RelativePath="..\BasicCompiler_Common\include\Const.h" 1378 > 1379 </File> 1380 <File 1367 1381 RelativePath="..\BasicCompiler_Common\include\DataTable.h" 1368 1382 > … … 1377 1391 </File> 1378 1392 <File 1393 RelativePath="..\BasicCompiler_Common\include\Member.h" 1394 > 1395 </File> 1396 <File 1379 1397 RelativePath="..\BasicCompiler_Common\include\MetaImpl.h" 1380 1398 > 1381 1399 </File> 1382 1400 <File 1401 RelativePath="..\BasicCompiler_Common\include\Method.h" 1402 > 1403 </File> 1404 <File 1383 1405 RelativePath="..\BasicCompiler_Common\include\NamespaceSupporter.h" 1384 1406 > 1385 1407 </File> 1386 1408 <File 1387 RelativePath="..\BasicCompiler_Common\include\ProcedureImpl.h" 1409 RelativePath="..\BasicCompiler_Common\include\Parameter.h" 1410 > 1411 </File> 1412 <File 1413 RelativePath="..\BasicCompiler_Common\include\Procedure.h" 1388 1414 > 1389 1415 </File> … … 1393 1419 </File> 1394 1420 <File 1421 RelativePath="..\BasicCompiler_Common\include\Prototype.h" 1422 > 1423 </File> 1424 <File 1395 1425 RelativePath="..\BasicCompiler_Common\include\SmoothieImpl.h" 1396 1426 > 1397 1427 </File> 1398 1428 <File 1429 RelativePath="..\BasicCompiler_Common\include\Symbol.h" 1430 > 1431 </File> 1432 <File 1433 RelativePath="..\BasicCompiler_Common\include\Type.h" 1434 > 1435 </File> 1436 <File 1399 1437 RelativePath="..\BasicCompiler_Common\include\TypeDef.h" 1400 1438 > 1401 1439 </File> 1402 1440 <File 1403 RelativePath="..\BasicCompiler_Common\include\Variable Impl.h"1441 RelativePath="..\BasicCompiler_Common\include\Variable.h" 1404 1442 > 1405 1443 </File> -
trunk/abdev/BasicCompiler32/CParameter.cpp
r76 r206 1 #include "stdafx.h" 2 1 3 #include "../BasicCompiler_Common/common.h" 2 4 #include "opcode.h" … … 108 110 109 111 //call free 110 extern UserProc *pSub_free;112 extern const UserProc *pSub_free; 111 113 op_call(pSub_free); 112 114 } … … 135 137 136 138 //call calloc 137 extern UserProc *pSub_calloc;139 extern const UserProc *pSub_calloc; 138 140 op_call(pSub_calloc); 139 141 -
trunk/abdev/BasicCompiler32/Compile_Calc.cpp
r193 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 #include <jenga/include/smoothie/LexicalAnalysis.h> … … 481 483 } 482 484 else{ 483 if(GetConstHash(variable)){ 485 if( compiler.GetMeta().GetGlobalConsts().IsExist(variable) 486 || compiler.GetMeta().GetGlobalConstMacros().IsExist(variable) ) 487 { 484 488 //定数リストに該当したとき 485 489 SetError(1,NULL,cp); … … 626 630 if( varType.IsObject() && compiler.GetMeta().GetBlittableTypes().IsExist( calcType ) ){ 627 631 // Blittable型をオブジェクトとして扱う 628 vector< UserProc *> userProcs;632 vector<const UserProc *> userProcs; 629 633 compiler.GetMeta().GetBlittableTypes().GetClass( calcType ).GetStaticMethods().Enum( "_Create", userProcs ); 630 634 if( userProcs.size() != 1 ){ … … 632 636 return; 633 637 } 634 UserProc *pUserProc = userProcs[0];638 const UserProc *pUserProc = userProcs[0]; 635 639 636 640 // call System.[TypeClass]._Create -
trunk/abdev/BasicCompiler32/Compile_Calc_PushVar.cpp
r97 r206 1 #include "stdafx.h" 2 1 3 #include "../BasicCompiler_Common/common.h" 2 4 #include "Opcode.h" -
trunk/abdev/BasicCompiler32/Compile_CallProc.cpp
r193 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 … … 12 14 void Call_DebugSys_SaveContext(){ 13 15 //call _System_GetEip 14 extern UserProc *pSub_System_GetEip;16 extern const UserProc *pSub_System_GetEip; 15 17 op_call(pSub_System_GetEip); 16 18 … … 22 24 23 25 //call _DebugSys_SaveContext 24 extern UserProc *pSub_DebugSys_SaveContext;26 extern const UserProc *pSub_DebugSys_SaveContext; 25 27 op_call(pSub_DebugSys_SaveContext); 26 28 } … … 95 97 } 96 98 97 bool Opcode_CallProc(const char *Parameter, UserProc *pUserProc,DWORD dwFlags,const char *ObjectName,int RefType){99 bool Opcode_CallProc(const char *Parameter,const UserProc *pUserProc,DWORD dwFlags,const char *ObjectName,int RefType){ 98 100 int i2; 99 101 … … 123 125 if(lstrcmpi(ObjectName,"Super")==0){ 124 126 //クラスメンバ関数内から基底クラスの呼び出し 125 pobj_c= Smoothie::Temp::pCompilingClass;127 pobj_c=compiler.pCompilingClass; 126 128 } 127 129 else{ … … 148 150 else{ 149 151 //クラスメンバ関数内から同一クラスのメンバ関数の呼び出し 150 pobj_c= Smoothie::Temp::pCompilingClass;152 pobj_c=compiler.pCompilingClass; 151 153 } 152 154 } … … 177 179 if(ObjectName[0]){ 178 180 //外部からの呼び出し 179 if(pobj_c== Smoothie::Temp::pCompilingClass){181 if(pobj_c==compiler.pCompilingClass){ 180 182 //同一クラスオブジェクトの場合はプライベートアクセスを容認する 181 183 if( pMethod->IsNoneAccess() ){ … … 261 263 262 264 //call calloc 263 extern UserProc *pSub_calloc;265 extern const UserProc *pSub_calloc; 264 266 op_call(pSub_calloc); 265 267 -
trunk/abdev/BasicCompiler32/Compile_Func.cpp
r193 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 … … 196 198 } 197 199 198 int SubScripts[MAX_ARRAYDIM];200 Subscripts subscripts; 199 201 RELATIVE_VAR RelativeVar; 200 if(!GetVarOffsetReadOnly(tempParm,&RelativeVar,type, SubScripts)) return;202 if(!GetVarOffsetReadOnly(tempParm,&RelativeVar,type,&subscripts)) return; 201 203 202 204 if(type.GetBasicType()&FLAG_PTR){ … … 209 211 int typeSize = type.GetSize(); 210 212 211 if(bArrayHead) typeSize*=JumpSubScripts( SubScripts);213 if(bArrayHead) typeSize*=JumpSubScripts(subscripts); 212 214 213 215 //mov eax,TypeSize … … 218 220 void Opcode_Func_AddressOf( const char *name ){ 219 221 extern int cp; 220 UserProc *pUserProc;222 const UserProc *pUserProc; 221 223 222 224 extern LONG_PTR ProcPtr_BaseIndex; … … 224 226 //左辺の型にのっとり、オーバーロードを解決 225 227 226 std::vector< UserProc *> subs;228 std::vector<const UserProc *> subs; 227 229 GetOverloadSubHash( name, subs ); 228 230 if( subs.size() == 0 ){ … … 284 286 SetThisPtrToReg(REG_RCX); 285 287 286 pobj_c= Smoothie::Temp::pCompilingClass;288 pobj_c=compiler.pCompilingClass; 287 289 } 288 290 -
trunk/abdev/BasicCompiler32/Compile_Object.cpp
r140 r206 1 #include "stdafx.h" 2 1 3 #include "../BasicCompiler_Common/common.h" 2 4 #include "opcode.h" … … 35 37 //////////////////////// 36 38 37 std::vector< UserProc *> subs;39 std::vector<const UserProc *> subs; 38 40 pobj_c->GetMethods().Enum( pobj_c->GetName().c_str(), subs ); 39 41 40 UserProc *pUserProc;42 const UserProc *pUserProc; 41 43 if( subs.size() > 0 ){ 42 44 //オーバーロードを解決 … … 161 163 162 164 //call _System_GC_malloc_ForObject 163 extern UserProc *pSub_System_GC_malloc_ForObject;165 extern const UserProc *pSub_System_GC_malloc_ForObject; 164 166 op_call(pSub_System_GC_malloc_ForObject); 165 167 } … … 169 171 170 172 //call _System_GC_malloc_ForObjectPtr 171 extern UserProc *pSub_System_GC_malloc_ForObjectPtr;173 extern const UserProc *pSub_System_GC_malloc_ForObjectPtr; 172 174 op_call(pSub_System_GC_malloc_ForObjectPtr); 173 175 } … … 213 215 //mov ecx,DestructorProcAddr 214 216 OpBuffer[obp++]=(char)0xB9; 215 pobj_SubAddrSchedule->add( method->pUserProc,0);216 method-> pUserProc->Using();217 pobj_SubAddrSchedule->add(&method->GetUserProc(),0); 218 method->GetUserProc().Using(); 217 219 obp+=sizeof(long); 218 220 … … 351 353 if( isSweeping ){ 352 354 //call _System_GC_free_for_SweepingDelete 353 extern UserProc *pSub_System_GC_free_for_SweepingDelete;355 extern const UserProc *pSub_System_GC_free_for_SweepingDelete; 354 356 op_call(pSub_System_GC_free_for_SweepingDelete); 355 357 } 356 358 else{ 357 359 //call free 358 extern UserProc *pSub_free;360 extern const UserProc *pSub_free; 359 361 op_call(pSub_free); 360 362 } -
trunk/abdev/BasicCompiler32/Compile_ProcOp.cpp
r204 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 #include <jenga/include/smoothie/LexicalAnalysis.h> … … 5 7 #include <Compiler.h> 6 8 #include <LexicalScopingImpl.h> 7 #include <Class Impl.h>8 #include <Variable Impl.h>9 #include <Class.h> 10 #include <Variable.h> 9 11 #include <NamespaceSupporter.h> 10 12 … … 36 38 } 37 39 38 UserProc *pBackUserProc;40 const UserProc *pBackUserProc; 39 41 pBackUserProc = &UserProc::CompilingUserProc(); 40 42 UserProc::CompileStartForGlobalArea(); … … 54 56 55 57 //_System_StartupProgramの呼び出し 56 extern UserProc *pSub_System_StartupProgram;58 extern const UserProc *pSub_System_StartupProgram; 57 59 op_call(pSub_System_StartupProgram); 58 60 … … 71 73 //静的ローカルオブジェクトのコンストラクタ呼び出し 72 74 73 BOOST_FOREACH( Variable *pVar, globalVars){75 BOOST_FOREACH( Variable *pVar, compiler.GetMeta().GetGlobalVars() ){ 74 76 if(memicmp(pVar->GetName().c_str(),"Static%",7)==0){ 75 77 //コンストラクタ呼び出し 76 if( pVar-> IsObject() ){78 if( pVar->GetType().IsObject() ){ 77 79 78 80 //エラー用 … … 81 83 CallConstructor( 82 84 pVar->GetName().c_str(), 83 pVar->GetSub ScriptsPtr(),84 *pVar,85 pVar-> paramStrForConstructor.c_str());85 pVar->GetSubscripts(), 86 pVar->GetType(), 87 pVar->GetParamStrForConstructor().c_str()); 86 88 } 87 89 } … … 93 95 else if( userProc.GetName() == "_System_Call_Destructor_of_GlobalObject" ){ 94 96 95 UserProc *pBackUserProc;97 const UserProc *pBackUserProc; 96 98 pBackUserProc = &UserProc::CompilingUserProc(); 97 99 UserProc::CompileStartForGlobalArea(); … … 222 224 } 223 225 } 224 void AutoGeneration( UserProc &userProc){226 void AutoGeneration( const UserProc &userProc){ 225 227 if( userProc.GetName() == "InitializeUserTypes" 226 228 && userProc.HasParentClass() … … 240 242 } 241 243 242 void _compile_proc( UserProc *pUserProc){244 void _compile_proc(const UserProc *pUserProc){ 243 245 extern char *basbuf; 244 246 extern HANDLE hHeap; 245 extern GlobalProc **ppSubHash;246 247 extern BOOL bDebugCompile; 247 248 int i3,i4,LocalVarSchedule,EspOffsetSchedule,BaseOffset; … … 250 251 if( pUserProc->IsUsing() == false || pUserProc->IsCompiled() ) return; 251 252 252 if( pUserProc-> localVars.size() ){253 if( pUserProc->GetLocalVars().size() ){ 253 254 SetError(); 254 255 return; 255 256 } 257 258 trace_for_sourcecodestep( "★★★ " << pUserProc->GetFullName() << "のコンパイルを開始" ); 256 259 257 260 pUserProc->CompleteCompile(); … … 270 273 else bDebugSupportProc=0; 271 274 272 pUserProc-> beginOpAddress=obp;275 pUserProc->SetBeginOpAddress( obp ); 273 276 274 277 //コンパイル中の関数が属するクラス 275 Smoothie::Temp::pCompilingClass=pUserProc->GetParentClassPtr();278 compiler.pCompilingClass=pUserProc->GetParentClassPtr(); 276 279 277 280 //コンパイルスタートをクラス管理クラスに追加 … … 297 300 SystemProc(*pUserProc); 298 301 299 pUserProc-> endOpAddress=obp;302 pUserProc->SetEndOpAddress( obp ); 300 303 return; 301 304 } … … 321 324 Parameter ¶m = *pUserProc->RealParams()[i3]; 322 325 323 Variable *pVar = new Variable Impl( param.GetVarName(), param, false, param.IsRef());326 Variable *pVar = new Variable( param.GetVarName(), param, false, param.IsRef(), "" ); 324 327 325 328 if( param.IsArray() ){ 326 pVar->SetArray( param.GetSub ScriptsPtr() );329 pVar->SetArray( param.GetSubscripts() ); 327 330 } 328 331 … … 342 345 } 343 346 AllLocalVarSize+=varSize; 344 pVar-> offset=AllLocalVarSize;347 pVar->SetOffsetAddress( AllLocalVarSize ); 345 348 346 349 //レキシカルスコープ情報 347 pVar->S copeLevel=GetLexicalScopes().GetNowLevel();348 pVar->S copeStartAddress=GetLexicalScopes().GetStartAddress();350 pVar->SetScopeLevel( GetLexicalScopes().GetNowLevel() ); 351 pVar->SetScopeStartAddress( GetLexicalScopes().GetStartAddress() ); 349 352 pVar->bLiving=TRUE; 350 353 351 pUserProc-> localVars.push_back( pVar );354 pUserProc->GetLocalVars().push_back( pVar ); 352 355 } 353 356 … … 456 459 457 460 //call _DebugSys_StartProc 458 extern UserProc *pSub_DebugSys_StartProc;461 extern const UserProc *pSub_DebugSys_StartProc; 459 462 op_call(pSub_DebugSys_StartProc); 460 463 } 461 464 462 if( Smoothie::Temp::pCompilingClass){463 if( pUserProc->GetName() == Smoothie::Temp::pCompilingClass->GetName() ){465 if(compiler.pCompilingClass){ 466 if( pUserProc->GetName() == compiler.pCompilingClass->GetName() ){ 464 467 //////////////////////////////////// 465 468 // コンストラクタをコンパイルするとき … … 467 470 468 471 //コンストラクタのコンパイル開始を通知 469 Smoothie::Temp::pCompilingClass->NotifyStartConstructorCompile();472 compiler.pCompilingClass->NotifyStartConstructorCompile(); 470 473 471 474 //基底クラスかどうかの識別 472 475 //(継承元がインターフェイスの場合も基底クラスと見なす) 473 476 BOOL bThisIsSuperClass; 474 if( ! Smoothie::Temp::pCompilingClass->HasSuperClass() ) bThisIsSuperClass=1;475 else if( Smoothie::Temp::pCompilingClass->GetSuperClass().GetConstructorMethod() == NULL ){477 if( !compiler.pCompilingClass->HasSuperClass() ) bThisIsSuperClass=1; 478 else if( compiler.pCompilingClass->GetSuperClass().GetConstructorMethod() == NULL ){ 476 479 //インターフェイスを継承したときはコンストラクタを持たない 477 480 bThisIsSuperClass=1; … … 492 495 temporary[i4]=basbuf[i3]; 493 496 } 494 if( Smoothie::Temp::pCompilingClass->GetSuperClass().GetName() == temporary ){497 if( compiler.pCompilingClass->GetSuperClass().GetName() == temporary ){ 495 498 //基底クラスのコンストラクタを呼び出す 496 499 cp=i3; … … 509 512 Type dummyType; 510 513 CallProc( PROC_DEFAULT 511 , Smoothie::Temp::pCompilingClass->GetSuperClass().GetConstructorMethod()->pUserProc512 , Smoothie::Temp::pCompilingClass->GetSuperClass().GetConstructorMethod()->pUserProc->GetName().c_str()514 , &compiler.pCompilingClass->GetSuperClass().GetConstructorMethod()->GetUserProc() 515 , compiler.pCompilingClass->GetSuperClass().GetConstructorMethod()->GetUserProc().GetName().c_str() 513 516 , temporary 514 517 , dummyType ); … … 517 520 //基底クラスのコンストラクタを暗黙的に呼び出す 518 521 Opcode_CallProc("", 519 Smoothie::Temp::pCompilingClass->GetSuperClass().GetConstructorMethod()->pUserProc,522 &compiler.pCompilingClass->GetSuperClass().GetConstructorMethod()->GetUserProc(), 520 523 0, 521 524 "", … … 525 528 526 529 //仮想関数テーブルを初期化 527 if( Smoothie::Temp::pCompilingClass->IsExistVirtualFunctions()528 && ! Smoothie::Temp::pCompilingClass->IsAbstract() ){530 if( compiler.pCompilingClass->IsExistVirtualFunctions() 531 && !compiler.pCompilingClass->IsAbstract() ){ 529 532 //関数テーブルに値をセット 530 int offset = (int) Smoothie::Temp::pCompilingClass->GetVtblGlobalOffset();533 int offset = (int)compiler.pCompilingClass->GetVtblGlobalOffset(); 531 534 532 535 //mov eax,offset … … 548 551 549 552 //デストラクタのコンパイル開始を通知 550 Smoothie::Temp::pCompilingClass->NotifyStartDestructorCompile();553 compiler.pCompilingClass->NotifyStartDestructorCompile(); 551 554 } 552 555 } … … 574 577 ////////////////////////////////////////// 575 578 576 if( Smoothie::Temp::pCompilingClass ){577 578 if( Smoothie::Temp::pCompilingClass->IsCompilingConstructor() ){579 if( compiler.pCompilingClass ){ 580 581 if( compiler.pCompilingClass->IsCompilingConstructor() ){ 579 582 // コンストラクタをコンパイルしていたとき 580 583 581 584 // コンストラクタのコンパイルが完了したことを通知 582 Smoothie::Temp::pCompilingClass->NotifyFinishConstructorCompile();585 compiler.pCompilingClass->NotifyFinishConstructorCompile(); 583 586 } 584 587 else if( pUserProc->IsDestructor() ){ … … 588 591 589 592 // デストラクタのコンパイルが完了したことを通知 590 Smoothie::Temp::pCompilingClass->NotifyFinishDestructorCompile();591 592 if( Smoothie::Temp::pCompilingClass->HasSuperClass() ){593 compiler.pCompilingClass->NotifyFinishDestructorCompile(); 594 595 if( compiler.pCompilingClass->HasSuperClass() ){ 593 596 /* サブクラスのデストラクタをコンパイルしているときは、 594 597 基底クラスのデストラクタを呼び出す */ 595 598 596 const CMethod *method = Smoothie::Temp::pCompilingClass->GetSuperClass().GetDestructorMethod();599 const CMethod *method = compiler.pCompilingClass->GetSuperClass().GetDestructorMethod(); 597 600 if( method ){ 598 601 Opcode_CallProc("", 599 method->pUserProc,602 &method->GetUserProc(), 600 603 0, 601 604 "", … … 649 652 650 653 //call _DebugSys_EndProc 651 extern UserProc *pSub_DebugSys_EndProc;654 extern const UserProc *pSub_DebugSys_EndProc; 652 655 op_call(pSub_DebugSys_EndProc); 653 656 } … … 742 745 } 743 746 HeapDefaultFree(pLocalVarAddrSchedule); 744 BOOST_FOREACH( Variable *pVar, pUserProc-> localVars){747 BOOST_FOREACH( Variable *pVar, pUserProc->GetLocalVars() ){ 745 748 //後にデバッグで利用する 746 pVar-> offset = AllLocalVarSize - pVar->offset;749 pVar->SetOffsetAddress( AllLocalVarSize - pVar->GetOffsetAddress() ); 747 750 } 748 751 … … 771 774 772 775 //call _esp_error 773 extern UserProc *pSub_esp_error;776 extern const UserProc *pSub_esp_error; 774 777 op_call( pSub_esp_error ); 775 778 … … 799 802 800 803 801 pUserProc-> endOpAddress=obp;804 pUserProc->SetEndOpAddress( obp ); 802 805 803 806 … … 811 814 } 812 815 813 void CompileBufferInProcedure( UserProc &userProc ){816 void CompileBufferInProcedure( const UserProc &userProc ){ 814 817 if( userProc.IsUsing() == false || userProc.IsCompiled() ) return; 815 818 … … 827 830 } 828 831 void CompileLocal(){ 829 extern GlobalProc **ppSubHash;830 int i2;831 832 832 extern BOOL bDll; 833 833 if(bDll){ 834 834 //DLLの場合はグローバル変数を初期化するための関数を一番初めにコンパイルする 835 UserProc *pUserProc=GetSubHash("_System_InitDllGlobalVariables");835 const UserProc *pUserProc=GetSubHash("_System_InitDllGlobalVariables"); 836 836 if(pUserProc){ 837 837 CompileBufferInProcedure( *pUserProc ); … … 841 841 842 842 //_System_TypeBase_InitializeUserTypesは一番最後にコンパイル 843 extern UserProc *pSubStaticMethod_System_TypeBase_InitializeUserTypes;843 extern const UserProc *pSubStaticMethod_System_TypeBase_InitializeUserTypes; 844 844 pSubStaticMethod_System_TypeBase_InitializeUserTypes->CompleteCompile(); 845 845 846 846 //_System_InitStaticLocalVariablesは一番最後にコンパイル 847 847 //※一般関数内の静的変数オブジェクトをすべて収集しなければならない 848 extern UserProc *pSub_System_InitStaticLocalVariables;848 extern const UserProc *pSub_System_InitStaticLocalVariables; 849 849 pSub_System_InitStaticLocalVariables->CompleteCompile(); 850 850 851 851 //_System_Call_Destructor_of_GlobalObjectは一番最後にコンパイル 852 extern UserProc *pSub_System_Call_Destructor_of_GlobalObject;852 extern const UserProc *pSub_System_Call_Destructor_of_GlobalObject; 853 853 pSub_System_Call_Destructor_of_GlobalObject->CompleteCompile(); 854 854 855 855 repeat: 856 GlobalProc *pGlobalProc; 857 for(i2=0;i2<MAX_HASH;i2++){ 858 pGlobalProc=ppSubHash[i2]; 859 while(pGlobalProc){ 860 CompileBufferInProcedure( *pGlobalProc ); 861 pGlobalProc=pGlobalProc->pNextData; 862 } 856 compiler.GetMeta().GetUserProcs().Iterator_Reset(); 857 while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() ) 858 { 859 UserProc *pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext(); 860 CompileBufferInProcedure( *pUserProc ); 863 861 } 864 862 … … 874 872 if( IsNeedProcCompile() ){ 875 873 //プロシージャコンパイルによって、プロシージャコンパイルが必要になる場合 876 for(i2=0;i2<MAX_HASH;i2++){ 877 pGlobalProc=ppSubHash[i2];878 while(pGlobalProc){879 CompileBufferInProcedure( *pGlobalProc );880 pGlobalProc=pGlobalProc->pNextData;881 }874 875 compiler.GetMeta().GetUserProcs().Iterator_Reset(); 876 while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() ) 877 { 878 UserProc *pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext(); 879 CompileBufferInProcedure( *pUserProc ); 882 880 } 883 881 } -
trunk/abdev/BasicCompiler32/Compile_Set_Var.cpp
r183 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 … … 40 42 41 43 //call free 42 extern UserProc *pSub_free;44 extern const UserProc *pSub_free; 43 45 op_call(pSub_free); 44 46 } -
trunk/abdev/BasicCompiler32/Compile_Statement.cpp
r183 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/LexicalAnalysis.h> 2 4 … … 9 11 void OpcodeOthers( const char *Command ){ 10 12 int i,i2; 11 UserProc *pUserProc;12 13 13 14 char leftTerm[8192]; … … 59 60 ////////////////////////////// 60 61 61 pUserProc=GetSubHash(Command);62 const UserProc *pUserProc = GetSubHash(Command); 62 63 63 64 //GetSubHash内でエラー提示が行われた場合 … … 1079 1080 1080 1081 if(type1.IsObject()){ 1081 std::vector< UserProc *> subs;1082 std::vector<const UserProc *> subs; 1082 1083 type1.GetClass().GetMethods().Enum( CALC_EQUAL, subs ); 1083 1084 if( subs.size() == 0 ){ … … 1089 1090 1090 1091 //オーバーロードを解決 1091 UserProc *pUserProc; 1092 pUserProc=OverloadSolution("==",subs, params, NULL); 1092 const UserProc *pUserProc = OverloadSolution("==",subs, params, NULL); 1093 1093 1094 1094 delete params[0]; … … 1326 1326 //戻り値をセット 1327 1327 if(Parameter[0]){ 1328 UserProc &proc = UserProc::CompilingUserProc();1328 const UserProc &proc = UserProc::CompilingUserProc(); 1329 1329 1330 1330 const char *temp = "_System_ReturnValue"; -
trunk/abdev/BasicCompiler32/Compile_Var.cpp
r193 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 #include <jenga/include/smoothie/LexicalAnalysis.h> … … 5 7 #include <CodeGenerator.h> 6 8 #include <Compiler.h> 7 #include <Variable Impl.h>9 #include <Variable.h> 8 10 9 11 #include "../BasicCompiler_Common/common.h" … … 11 13 12 14 //変数 13 Variables globalVars; 15 // TODO: xml未完成 14 16 int AllGlobalVarSize; 15 17 int AllInitGlobalVarSize; … … 64 66 } 65 67 } 66 bool GetArrayOffset(const int *SubScripts,char *array, const Type &type){68 bool GetArrayOffset(const Subscripts &subscripts,char *array, const Type &type){ 67 69 extern HANDLE hHeap; 68 70 int i,i2,i3,i4; … … 83 85 } 84 86 if(array[i]==','||array[i]=='\0'){ 85 if(SubScripts[i3]==-1){ 87 if( i3 >= (int)subscripts.size() ) 88 { 86 89 for(i3--;i3>=0;i3--) HeapDefaultFree(pParm[i3]); 87 90 return 0; … … 96 99 97 100 if(array[i]=='\0'){ 98 if(SubScripts[i3]!=-1){ 101 if( i3 < (int)subscripts.size() ) 102 { 99 103 for(i3--;i3>=0;i3--) HeapDefaultFree(pParm[i3]); 100 104 return 0; … … 131 135 op_pop(REG_EAX); 132 136 133 for(i2=i+1,i4=1;i2<i3;i2++) i4*= SubScripts[i2]+1;137 for(i2=i+1,i4=1;i2<i3;i2++) i4*=subscripts[i2]+1; 134 138 135 139 //imul eax,i4 … … 175 179 char lpPtrOffset[VN_SIZE]; //第2次配列 176 180 char NestMember[VN_SIZE]; //入れ子メンバ 177 CClass::RefTyperefType;181 ReferenceKind refType; 178 182 lstrcpy(VarName,member); 179 183 if(!GetVarFormatString(VarName,array,lpPtrOffset,NestMember,refType)) return false; … … 195 199 196 200 //アクセシビリティをチェック 197 if(&objClass== Smoothie::Temp::pCompilingClass){201 if(&objClass==compiler.pCompilingClass){ 198 202 //同一クラスオブジェクトの場合はプライベートアクセスを容認する 199 203 if(pMember->IsNoneAccess()){ … … 228 232 //ポインタ変数の場合 229 233 if( resultType.IsPointer() ){ 230 if( pMember->SubScripts[0]==-1){234 if( pMember->GetSubscripts().size() == 0 ){ 231 235 lstrcpy(lpPtrOffset,array); 232 236 array[0]=0; … … 250 254 if(array[0]){ 251 255 //配列オフセット 252 if(!GetArrayOffset(pMember-> SubScripts,array,pMember->GetType())){256 if(!GetArrayOffset(pMember->GetSubscripts(),array,pMember->GetType())){ 253 257 if(isErrorEnabled) SetError(14,member,cp); 254 258 } 255 259 } 256 else if( pMember->SubScripts[0]!=-1){260 else if( pMember->GetSubscripts().size() > 0 ){ 257 261 resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR ); 258 262 } … … 262 266 263 267 if( resultType.IsObject() || resultType.IsStruct() ){ 264 if( refType != CClass::Dot ){268 if( refType != RefDot ){ 265 269 if(isErrorEnabled) SetError(104,member,cp); 266 270 return false; … … 278 282 //pObj[n].member 279 283 if( ( resultType.IsObjectPtr() || resultType.IsStructPtr() ) 280 && refType != CClass::Dot ){284 && refType != RefDot ){ 281 285 if(isErrorEnabled) SetError(104,member,cp); 282 286 return false; … … 292 296 //pObj->member 293 297 if( ( resultType.IsObjectPtr() || resultType.IsStructPtr() ) 294 && refType != CClass::Pointer ){298 && refType != RefPointer ){ 295 299 if(isErrorEnabled) SetError(104,member,cp); 296 300 return false; … … 306 310 if(lpPtrOffset[0]){ 307 311 //ppObj[n]->member 308 if( refType != CClass::Pointer ){312 if( refType != RefPointer ){ 309 313 if(isErrorEnabled) SetError(104,member,cp); 310 314 return false; … … 357 361 } 358 362 359 bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, int *pss){363 bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts ){ 360 364 char variable[VN_SIZE]; 361 365 … … 371 375 372 376 // 先頭オブジェクトまたはクラス名と入れ子メンバに分割 373 CClass::RefTyperefType;377 ReferenceKind refType; 374 378 char member[VN_SIZE],array[VN_SIZE],lpPtrOffset[VN_SIZE]; 375 379 GetVarFormatString(simpleName,array,lpPtrOffset,member,refType); … … 384 388 } 385 389 386 const int *pSubScripts;390 const Subscripts *pSubscripts; 387 391 bool bConst = false; 388 392 … … 393 397 ////////////////// 394 398 395 const Variable *pVar = UserProc::CompilingUserProc(). localVars.BackSearch( Symbol( VarName ) );399 const Variable *pVar = UserProc::CompilingUserProc().GetLocalVars().BackSearch( Symbol( VarName ) ); 396 400 if( pVar ){ 397 401 //ポインタ変数の場合 398 if( pVar-> IsPointer() ){402 if( pVar->GetType().IsPointer() ){ 399 403 if( !pVar->IsArray() ){ 400 404 lstrcpy(lpPtrOffset,array); … … 410 414 } 411 415 412 pRelativeVar->offset=-pVar-> offset;416 pRelativeVar->offset=-pVar->GetOffsetAddress(); 413 417 pRelativeVar->bOffsetOffset=0; 414 418 if( pVar->IsRef() ){ … … 417 421 } 418 422 else pRelativeVar->dwKind=VAR_LOCAL; 419 resultType = *pVar;420 pSub Scripts=pVar->GetSubScriptsPtr();423 resultType = pVar->GetType(); 424 pSubscripts = &pVar->GetSubscripts(); 421 425 bConst = pVar->IsConst(); 422 426 … … 425 429 } 426 430 427 if( Smoothie::Temp::pCompilingClass){431 if(compiler.pCompilingClass){ 428 432 ////////////////////// 429 433 // クラスメンバの参照 … … 438 442 pRelativeVar->dwKind=VAR_DIRECTMEM; 439 443 440 resultType.SetType( DEF_OBJECT, Smoothie::Temp::pCompilingClass );444 resultType.SetType( DEF_OBJECT, compiler.pCompilingClass ); 441 445 return true; 442 446 } … … 451 455 452 456 bool isFound = false; 453 BOOST_FOREACH( CMember *pMember, Smoothie::Temp::pCompilingClass->GetDynamicMembers() ){457 BOOST_FOREACH( CMember *pMember, compiler.pCompilingClass->GetDynamicMembers() ){ 454 458 if( pMember->GetName() == VarName ){ 455 459 isFound = true; … … 465 469 if( isWriteAccess && 466 470 pMethod->IsConst() && 467 Smoothie::Temp::pCompilingClass->IsCompilingConstructor() == false &&468 Smoothie::Temp::pCompilingClass->IsCompilingDestructor() == false471 compiler.pCompilingClass->IsCompilingConstructor() == false && 472 compiler.pCompilingClass->IsCompilingDestructor() == false 469 473 ){ 470 474 SetError(131, NULL, cp ); … … 481 485 isErrorEnabled, 482 486 isWriteAccess, 483 * Smoothie::Temp::pCompilingClass,487 *compiler.pCompilingClass, 484 488 variable, 485 489 pRelativeVar, … … 502 506 GetNowStaticVarFullName(VarName,temporary); 503 507 504 pVar = globalVars.Find( Symbol( temporary ) );508 pVar = compiler.GetMeta().GetGlobalVars().Find( Symbol( temporary ) ); 505 509 if( pVar ){ 506 510 goto GlobalOk; … … 521 525 char tempArray[VN_SIZE]; 522 526 { 523 CClass::RefTyperefType;527 ReferenceKind refType; 524 528 GetVarFormatString(temporary,tempArray,lpPtrOffset,tempMember, refType ); 525 529 } … … 533 537 char temp2[VN_SIZE]; 534 538 sprintf(temp2,"%s.%s",VarName,temporary); 535 pVar = globalVars.Find( Symbol( temp2 ) );539 pVar = compiler.GetMeta().GetGlobalVars().Find( Symbol( temp2 ) ); 536 540 if( pVar ){ 537 541 lstrcpy(member,tempMember); … … 541 545 } 542 546 543 if( Smoothie::Temp::pCompilingClass){547 if(compiler.pCompilingClass){ 544 548 //自身のクラスから静的メンバを参照する場合 545 549 char temp2[VN_SIZE]; 546 sprintf(temp2,"%s.%s", Smoothie::Temp::pCompilingClass->GetName().c_str(),VarName);547 pVar = globalVars.Find( Symbol( temp2 ) );550 sprintf(temp2,"%s.%s",compiler.pCompilingClass->GetName().c_str(),VarName); 551 pVar = compiler.GetMeta().GetGlobalVars().Find( Symbol( temp2 ) ); 548 552 if( pVar ){ 549 553 goto GlobalOk; … … 555 559 ///////////////////// 556 560 557 pVar = globalVars.BackSearch( Symbol( VarName ) );561 pVar = compiler.GetMeta().GetGlobalVars().BackSearch( Symbol( VarName ) ); 558 562 if( pVar ){ 559 563 goto GlobalOk; … … 568 572 GlobalOk: 569 573 //ポインタ変数の場合 570 if( pVar-> IsPointer() ){574 if( pVar->GetType().IsPointer() ){ 571 575 if( !pVar->IsArray() ){ 572 576 lstrcpy(lpPtrOffset,array); … … 582 586 } 583 587 584 pRelativeVar->offset=pVar-> offset;588 pRelativeVar->offset=pVar->GetOffsetAddress(); 585 589 pRelativeVar->bOffsetOffset=0; 586 590 if( pVar->IsRef() ){ … … 589 593 } 590 594 else pRelativeVar->dwKind=VAR_GLOBAL; 591 resultType = *pVar;592 pSub Scripts=pVar->GetSubScriptsPtr();595 resultType = pVar->GetType(); 596 pSubscripts=&pVar->GetSubscripts(); 593 597 bConst = pVar->IsConst(); 594 598 } … … 610 614 } 611 615 612 if( array[0]==0&&pSubScripts[0]!=-1){616 if( array[0] == 0 && pSubscripts->size() > 0 ){ 613 617 //配列の先頭ポインタを示す場合 614 618 resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR ); 615 if(pss) memcpy(pss,pSubScripts,MAX_ARRAYDIM); 619 620 if( pResultSubscripts ) 621 { 622 (*pResultSubscripts) = *pSubscripts; 623 } 616 624 return true; 617 625 } … … 625 633 } 626 634 if(array[0]){ 627 if(!GetArrayOffset( pSubScripts,array,resultType)){635 if(!GetArrayOffset(*pSubscripts,array,resultType)){ 628 636 SetError(14,variable,cp); 629 637 pRelativeVar->dwKind=NON_VAR; … … 634 642 if( resultType.IsObject() || resultType.IsStruct() ){ 635 643 //実態オブジェクトのメンバを参照(obj.member) 636 if( refType != CClass::Dot ){644 if( refType != RefDot ){ 637 645 SetError(104,VarName,cp); 638 646 pRelativeVar->dwKind=NON_VAR; … … 649 657 if(lpPtrOffset[0]){ 650 658 //pObj[n].member 651 if( refType != CClass::Dot ){659 if( refType != RefDot ){ 652 660 SetError(104,VarName,cp); 653 661 pRelativeVar->dwKind=NON_VAR; … … 659 667 else{ 660 668 //pObj->member 661 if( refType != CClass::Pointer ){669 if( refType != RefPointer ){ 662 670 SetError(104,VarName,cp); 663 671 pRelativeVar->dwKind=NON_VAR; … … 677 685 if(lpPtrOffset[0]){ 678 686 //ppObj[n]->member 679 if( refType != CClass::Pointer ){687 if( refType != RefPointer ){ 680 688 SetError(104,VarName,cp); 681 689 pRelativeVar->dwKind=NON_VAR; … … 722 730 } 723 731 724 bool SetInitGlobalData(int offset,const Type &type,const int *SubScripts,const char *lpszInitBuf){732 bool SetInitGlobalData(int offset,const Type &type,const Subscripts &subscripts,const char *lpszInitBuf){ 725 733 extern BYTE *initGlobalBuf; 726 734 int i2,i3; … … 735 743 int typeSize = type.GetSize(); 736 744 737 if(SubScripts[0]!=-1){ 738 typeSize*=JumpSubScripts(SubScripts+1); 739 int i=0; 740 i2=0; 741 while(1){ 742 if(SubScripts[0]<i2){ 743 SetError(41,0,cp); 744 return 0; 745 } 746 i=GetOneParameter(InitBuf,i,temporary); 747 if(!SetInitGlobalData( 748 offset+i2*typeSize, 749 type, 750 SubScripts+1, 751 temporary)) return false; 752 i2++; 753 if(InitBuf[i]=='\0') break; 745 if( subscripts.size() > 0 ){ 746 Subscripts nestSubscripts; 747 for( int i=1; i<(int)subscripts.size(); i++ ) 748 { 749 nestSubscripts.push_back( subscripts[i] ); 750 } 751 752 typeSize*=JumpSubScripts( nestSubscripts ); 753 { 754 int i=0; 755 i2=0; 756 while(1){ 757 if( subscripts[0] < i2 ){ 758 SetError(41,0,cp); 759 return 0; 760 } 761 i=GetOneParameter(InitBuf,i,temporary); 762 if(!SetInitGlobalData( 763 offset+i2*typeSize, 764 type, 765 nestSubscripts, 766 temporary)) return false; 767 i2++; 768 if(InitBuf[i]=='\0') break; 769 } 754 770 } 755 771 return true; … … 772 788 if(!SetInitGlobalData(offset+i3, 773 789 pMember->GetType(), 774 pMember-> SubScripts,790 pMember->GetSubscripts(), 775 791 temporary)) return false; 776 792 } … … 793 809 } 794 810 795 if( SubScripts[0]!=-1){811 if( subscripts.size() > 0 ){ 796 812 SetError(41,0,cp); 797 813 return false; … … 861 877 return true; 862 878 } 863 bool InitLocalVar(int offset,const Type &type,const int *SubScripts,const char *lpszInitBuf){864 int i ,i2,i3;879 bool InitLocalVar(int offset,const Type &type,const Subscripts &subscripts,const char *lpszInitBuf){ 880 int i2,i3; 865 881 char temporary[VN_SIZE]; 866 882 char InitBuf[VN_SIZE]; … … 873 889 int typeSize = type.GetSize(); 874 890 875 if(SubScripts[0]!=-1){ 876 typeSize*=JumpSubScripts(SubScripts+1); 877 i=0; 878 i2=0; 879 while(1){ 880 if(SubScripts[0]<i2){ 881 SetError(41,0,cp); 882 return false; 883 } 884 i=GetOneParameter(InitBuf,i,temporary); 885 if(!InitLocalVar( 886 offset+i2*typeSize, 887 type, 888 SubScripts+1, 889 temporary)) return false; 890 i2++; 891 if(InitBuf[i]=='\0') break; 891 if( subscripts.size() > 0 ){ 892 Subscripts nestSubscripts; 893 for( int i=1; i<(int)subscripts.size(); i++ ) 894 { 895 nestSubscripts.push_back( subscripts[i] ); 896 } 897 898 typeSize*=JumpSubScripts( nestSubscripts ); 899 { 900 int i=0; 901 i2=0; 902 while(1){ 903 if( subscripts[0] < i2 ){ 904 SetError(41,0,cp); 905 return 0; 906 } 907 i=GetOneParameter(InitBuf,i,temporary); 908 if(!InitLocalVar( 909 offset+i2*typeSize, 910 type, 911 nestSubscripts, 912 temporary)) return false; 913 i2++; 914 if(InitBuf[i]=='\0') break; 915 } 892 916 } 893 917 return true; … … 910 934 if(!InitLocalVar(offset+i3, 911 935 pMember->GetType(), 912 pMember-> SubScripts,936 pMember->GetSubscripts(), 913 937 temporary)) return false; 914 938 … … 927 951 /////////////////////////////////////// 928 952 929 if( SubScripts[0]!=-1){953 if( subscripts.size() > 0 ){ 930 954 SetError(41,0,cp); 931 955 return false; … … 1075 1099 } 1076 1100 1077 void dim( char *VarName, int *SubScripts,Type &type,const char *InitBuf,const char *ConstractParameter,DWORD dwFlags){1101 void dim( char *VarName, const Subscripts &subscripts, Type &type,const char *InitBuf,const char *ConstractParameter,DWORD dwFlags){ 1078 1102 if( UserProc::IsGlobalAreaCompiling() ){ 1079 1103 ///////////////////////// … … 1081 1105 ///////////////////////// 1082 1106 1083 AddGlobalVariable(VarName, SubScripts,type,InitBuf,ConstractParameter,dwFlags);1107 AddGlobalVariable(VarName,subscripts,type,InitBuf,ConstractParameter,dwFlags); 1084 1108 } 1085 1109 else{ … … 1088 1112 ///////////////// 1089 1113 1090 if( UserProc::CompilingUserProc(). localVars.DuplicateCheck( Symbol( VarName ) ) ){1114 if( UserProc::CompilingUserProc().GetLocalVars().DuplicateCheck( Symbol( VarName ) ) ){ 1091 1115 //2重定義のエラー 1092 1116 SetError(15,VarName,cp); … … 1096 1120 bool isConst = ( dwFlags & DIMFLAG_CONST ) ? true:false; 1097 1121 1098 Variable *pVar = new Variable Impl( VarName, type, isConst);1099 1100 if( SubScripts[0] != -1){1122 Variable *pVar = new Variable( VarName, type, isConst, false, ConstractParameter ); 1123 1124 if( subscripts.size() > 0 ){ 1101 1125 //配列あり 1102 pVar->SetArray( SubScripts ); 1103 } 1104 1105 //コンストラクタ用パラメータ 1106 pVar->paramStrForConstructor = ConstractParameter; 1126 pVar->SetArray( subscripts ); 1127 } 1107 1128 1108 1129 //レキシカルスコープ 1109 pVar->S copeLevel=GetLexicalScopes().GetNowLevel();1110 pVar->S copeStartAddress=GetLexicalScopes().GetStartAddress();1130 pVar->SetScopeLevel( GetLexicalScopes().GetNowLevel() ); 1131 pVar->SetScopeStartAddress( GetLexicalScopes().GetStartAddress() ); 1111 1132 pVar->bLiving=TRUE; 1112 1133 … … 1115 1136 1116 1137 // 変数を追加 1117 UserProc::CompilingUserProc(). localVars.push_back( pVar );1138 UserProc::CompilingUserProc().GetLocalVars().push_back( pVar ); 1118 1139 1119 1140 //アラインメントを考慮 1120 if( pVar-> IsStruct() ){1121 int alignment = pVar->Get Class().iAlign;1141 if( pVar->GetType().IsStruct() ){ 1142 int alignment = pVar->GetType().GetClass().iAlign; 1122 1143 1123 1144 if( alignment ){ … … 1139 1160 1140 1161 AllLocalVarSize += pVar->GetMemorySize(); 1141 pVar-> offset = AllLocalVarSize;1162 pVar->SetOffsetAddress( AllLocalVarSize ); 1142 1163 1143 1164 //レキシカルスコープ 1144 pVar->S copeLevel=GetLexicalScopes().GetNowLevel();1145 pVar->S copeStartAddress=GetLexicalScopes().GetStartAddress();1165 pVar->SetScopeLevel( GetLexicalScopes().GetNowLevel() ); 1166 pVar->SetScopeStartAddress( GetLexicalScopes().GetStartAddress() ); 1146 1167 pVar->bLiving=TRUE; 1147 1168 … … 1153 1174 1154 1175 int result = 0; 1155 if( !pVar-> IsObject() ){1156 result = InitLocalVar(-pVar-> offset,1157 *pVar,1158 pVar->GetSub ScriptsPtr(),1176 if( !pVar->GetType().IsObject() ){ 1177 result = InitLocalVar(-pVar->GetOffsetAddress(), 1178 pVar->GetType(), 1179 pVar->GetSubscripts(), 1159 1180 InitBuf); 1160 1181 } … … 1184 1205 //add eax,offset 1185 1206 OpBuffer[obp++]=(char)0x05; 1186 *((long *)(OpBuffer+obp))=-pVar-> offset;1207 *((long *)(OpBuffer+obp))=-pVar->GetOffsetAddress(); 1187 1208 AddLocalVarAddrSchedule(); 1188 1209 obp+=sizeof(long); … … 1204 1225 if( type.IsObject() &&(dwFlags&DIMFLAG_NONCALL_CONSTRACTOR)==0&&InitBuf[0]=='\0'){ 1205 1226 char objectSize[255]; 1206 if( SubScripts[0] == -1){1227 if( subscripts.size() == 0 ){ 1207 1228 objectSize[0] = 0; 1208 1229 } 1209 1230 else{ 1210 if( SubScripts[1] != -1 ){1231 if( subscripts.size() > 1 ){ 1211 1232 SetError(300,NULL,cp); 1212 1233 } 1213 sprintf( objectSize, "%d", SubScripts[0] );1234 sprintf( objectSize, "%d", subscripts[0] ); 1214 1235 } 1215 1236 Operator_New( type.GetClass(), objectSize, ConstractParameter, type ); … … 1323 1344 1324 1345 bool Compile_AddGlobalRootsForGc(){ 1325 UserProc *pUserProc_AddGlobalRootPtr = GetClassMethod( "_System_CGarbageCollection", "AddGlobalRootPtr" );1346 const UserProc *pUserProc_AddGlobalRootPtr = GetClassMethod( "_System_CGarbageCollection", "AddGlobalRootPtr" ); 1326 1347 if( !pUserProc_AddGlobalRootPtr ){ 1327 1348 SetError(3, "_System_CGarbageCollection.AddGlobalRootPtr", -1 ); … … 1329 1350 } 1330 1351 1331 BOOST_FOREACH( const Variable *pVar, globalVars){1332 if( pVar-> IsObject() || pVar->IsPointer() || pVar->IsStruct() ){1352 BOOST_FOREACH( const Variable *pVar, compiler.GetMeta().GetGlobalVars() ){ 1353 if( pVar->GetType().IsObject() || pVar->GetType().IsPointer() || pVar->GetType().IsStruct() ){ 1333 1354 // オブジェクトまたはポインタだったとき 1334 1355 // ※構造体も含む(暫定対応) … … 1342 1363 1343 1364 //mov eax,offset 1344 op_mov_RV(REG_EAX,(int)pVar-> offset);1365 op_mov_RV(REG_EAX,(int)pVar->GetOffsetAddress()); 1345 1366 obp-=sizeof(long); 1346 1367 pobj_GlobalVarSchedule->add(); -
trunk/abdev/BasicCompiler32/MakePeHdr.cpp
r201 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/common/Environment.h> 2 4 … … 4 6 5 7 #include <LexicalScopingImpl.h> 6 #include <Class Impl.h>8 #include <Class.h> 7 9 #include <Compiler.h> 8 10 #include <NamespaceSupporter.h> 9 11 12 #include <../Enum.h> 13 10 14 #include "../BasicCompiler_Common/common.h" 15 #include "../BasicCompiler_Common/DebugSection.h" 11 16 #include "Opcode.h" 12 17 … … 19 24 20 25 // グローバル関数、静的メソッド 21 UserProc26 const UserProc 22 27 *pSub_System_StartupProgram, 23 28 *pSub_DebugSys_StartProc, … … 51 56 52 57 // 動的メソッド 53 UserProc58 const UserProc 54 59 *pUserProc_System_CGarbageCollection_RegisterGlobalRoots; 55 60 … … 176 181 177 182 //クラス名を取得(詳細情報はGetAllClassInfoで取得) 178 // GetSubInfo関数の中で参照されるオブジェクト名を事前に取得する。183 // CollectUserProcs関数の中で参照されるオブジェクト名を事前に取得する。 179 184 // ※オブジェクトの内容までは取得しない 180 185 compiler.GetMeta().GetClasses().CollectClassesForNameOnly( Smoothie::Lexical::source ); … … 186 191 GetConstInfo(); 187 192 188 // サブルーチン(ユーザー定義、DLL関数)の識別子、アドレスを取得189 Smoothie::Temp::pCompilingClass=0;190 GetSubInfo();191 192 // クラス情報を取得(※注 - GetSubInfoの後に呼び出す)193 // サブルーチン(ユーザー定義、DLL関数)の識別子、アドレスを取得 194 compiler.pCompilingClass=0; 195 UserProcs::CollectUserProcs( Smoothie::Lexical::source, compiler.GetMeta().GetUserProcs() ); 196 197 // クラス情報を取得(※注 - CollectUserProcsの後に呼び出す) 193 198 compiler.GetMeta().GetClasses().GetAllClassInfo(); 199 200 // サブルーチン(ユーザー定義、DLL関数)のイテレータの準備 201 compiler.GetMeta().GetUserProcs().Iterator_Init(); 194 202 195 203 if( !compiler.GetMeta().Write( Jenga::Common::Environment::GetAppDir() + "\\meta_test.xml" ) ) … … 197 205 MessageBox(0,"XML書き込みに失敗","test",0); 198 206 } 199 MetaImpl tempMeta;200 if( ! tempMeta.Read( Jenga::Common::Environment::GetAppDir() + "\\meta_test.xml" ) )207 MetaImpl *pTempMeta = new MetaImpl(); 208 if( !pTempMeta->Read( Jenga::Common::Environment::GetAppDir() + "\\meta_test.xml" ) ) 201 209 { 202 210 MessageBox(0,"XML読み込みに失敗","test",0); 203 211 } 212 compiler.GetMeta() = (*pTempMeta); 204 213 205 214 //コードと行番号の関係 … … 401 410 extern DWORD dwContinueAddress; 402 411 dwContinueAddress=-1; 412 413 trace_for_sourcecodestep( "★★★ グローバル領域のコンパイルを開始" ); 403 414 404 415 … … 451 462 452 463 //call _System_End 453 extern UserProc *pSub_System_End;464 extern const UserProc *pSub_System_End; 454 465 op_call(pSub_System_End); 455 466 … … 593 604 ExportNamesLength=lstrlen(lpExportNames)+1; 594 605 595 extern GlobalProc **ppSubHash; 596 GlobalProc *pUserProc,*psi2; 606 UserProc *pUserProc,*psi2; 597 607 while(1){ 598 608 //辞書順にサーチ 599 609 temporary[0]=0; 600 for(i=0,psi2=0;i<MAX_HASH;i++){ 601 pUserProc=ppSubHash[i]; 602 while(pUserProc){ 603 if(pUserProc->IsExport()){ 604 if(temporary[0]=='\0'){ 610 compiler.GetMeta().GetUserProcs().Iterator_Reset(); 611 while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() ) 612 { 613 pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext(); 614 if(pUserProc->IsExport()){ 615 if(temporary[0]=='\0'){ 616 lstrcpy(temporary,pUserProc->GetName().c_str()); 617 psi2=pUserProc; 618 } 619 else{ 620 i3=lstrlen(temporary); 621 i4=(int)pUserProc->GetName().size(); 622 if(i3<i4) i3=i4; 623 if(memcmp(temporary,pUserProc->GetName().c_str(),i3)>0){ 605 624 lstrcpy(temporary,pUserProc->GetName().c_str()); 606 625 psi2=pUserProc; 607 626 } 608 else{609 i3=lstrlen(temporary);610 i4=(int)pUserProc->GetName().size();611 if(i3<i4) i3=i4;612 if(memcmp(temporary,pUserProc->GetName().c_str(),i3)>0){613 lstrcpy(temporary,pUserProc->GetName().c_str());614 psi2=pUserProc;615 }616 }617 627 } 618 pUserProc=pUserProc->pNextData;619 628 } 620 629 } … … 625 634 626 635 if( pUserProc->GetName() == "DllMain" ){ 627 DllMain_EntryPoint=pUserProc-> beginOpAddress;636 DllMain_EntryPoint=pUserProc->GetBeginOpAddress(); 628 637 } 629 638 630 639 lpdwExportAddressTable=(DWORD *)HeapReAlloc(hHeap,0,lpdwExportAddressTable,(ExportNum+1)*sizeof(DWORD)); 631 lpdwExportAddressTable[ExportNum]=pUserProc-> beginOpAddress;640 lpdwExportAddressTable[ExportNum]=pUserProc->GetBeginOpAddress(); 632 641 633 642 lpdwExportNamePointerTable=(DWORD *)HeapReAlloc(hHeap,0,lpdwExportNamePointerTable,(ExportNum+1)*sizeof(DWORD)); … … 808 817 //(デバッグ情報で利用される) 809 818 extern int AllInitGlobalVarSize; 810 BOOST_FOREACH( Variable *pVar, globalVars){811 if(pVar-> offset&0x80000000){812 pVar-> offset=(pVar->offset&0x7FFFFFFF)+AllInitGlobalVarSize;819 BOOST_FOREACH( Variable *pVar, compiler.GetMeta().GetGlobalVars() ){ 820 if(pVar->GetOffsetAddress()&0x80000000){ 821 pVar->SetOffsetAddress( (pVar->GetOffsetAddress()&0x7FFFFFFF)+AllInitGlobalVarSize ); 813 822 } 814 823 } … … 1110 1119 // プロシージャポインタスケジュール 1111 1120 for(i=0;i<pobj_SubAddrSchedule->num;i++){ 1112 if(pobj_SubAddrSchedule->ppsi[i]-> beginOpAddress==01113 &&pobj_SubAddrSchedule->ppsi[i]-> endOpAddress==0){1121 if(pobj_SubAddrSchedule->ppsi[i]->GetBeginOpAddress()==0 1122 &&pobj_SubAddrSchedule->ppsi[i]->GetEndOpAddress()==0){ 1114 1123 SetError(300,NULL,-1); 1115 1124 } … … 1117 1126 if(pobj_SubAddrSchedule->pbCall[i]){ 1118 1127 *((long *)(OpBuffer+pobj_SubAddrSchedule->pObpValues[i]))= 1119 pobj_SubAddrSchedule->ppsi[i]-> beginOpAddress-(pobj_SubAddrSchedule->pObpValues[i]+sizeof(long));1128 pobj_SubAddrSchedule->ppsi[i]->GetBeginOpAddress()-(pobj_SubAddrSchedule->pObpValues[i]+sizeof(long)); 1120 1129 } 1121 1130 else{ 1122 1131 *((long *)(OpBuffer+pobj_SubAddrSchedule->pObpValues[i]))= 1123 pobj_SubAddrSchedule->ppsi[i]-> beginOpAddress+ImageBase+MemPos_CodeSection;1132 pobj_SubAddrSchedule->ppsi[i]->GetBeginOpAddress()+ImageBase+MemPos_CodeSection; 1124 1133 } 1125 1134 } -
trunk/abdev/BasicCompiler32/NumOpe.cpp
r193 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 #include <jenga/include/smoothie/LexicalAnalysis.h> … … 179 181 // 動的メソッドを検索 180 182 /////////////////////////////////////////////////////////////////// 181 vector< UserProc *> userProcs;183 vector<const UserProc *> userProcs; 182 184 183 185 char methodName[VN_SIZE], lpPtrOffset[VN_SIZE], parameter[VN_SIZE], dummy[1]; 184 CClass::RefTyperefType;186 ReferenceKind refType; 185 187 lstrcpy( methodName, member ); 186 188 GetVarFormatString(methodName,parameter,lpPtrOffset,dummy,refType); 187 189 188 190 objClass.GetMethods().Enum( methodName, userProcs ); 189 UserProc *pUserProc;190 191 if(userProcs.size()){ 191 192 //オーバーロードを解決 192 pUserProc=OverloadSolutionWithStrParam(termFull,userProcs,parameter,termLeft);193 const UserProc *pUserProc = OverloadSolutionWithStrParam(termFull,userProcs,parameter,termLeft); 193 194 194 195 if( pUserProc ){ … … 248 249 // パース 249 250 char member[VN_SIZE]; 250 CClass::RefTyperefType;251 if( CClass::SplitName( termFull, termLeft, member, refType ) ){251 ReferenceKind refType; 252 if( SplitMemberName( termFull, termLeft, member, refType ) ){ 252 253 /////////////////////////////////////////////////////////////////// 253 254 // オブジェクトとメンバに分解できるとき … … 312 313 if(lstrcmpi(termFull,"This")==0 && isProcedureCallOnly == false ){ 313 314 //Thisオブジェクト 314 resultType.SetType( DEF_OBJECT, Smoothie::Temp::pCompilingClass );315 resultType.SetType( DEF_OBJECT, compiler.pCompilingClass ); 315 316 316 317 SetThisPtrToReg( useReg ); … … 386 387 return true; 387 388 } 388 else if(GetConstCalcBuffer(procName,parameter,temporary)){ 389 ///////////////////////// 390 // マクロ関数 391 ///////////////////////// 392 393 //閉じカッコ")"に続く文字がNULLでないときはエラーにする 394 if(termFull[i2+1+i4+1]!='\0') SetError(42,NULL,cp); 395 396 //マクロ関数の場合 397 NumOpe(useReg, temporary,Type(),resultType); 398 399 if(!IS_LITERAL(resultType.GetIndex())){ 400 //リテラル値ではなかったとき 401 isLiteral = false; 389 ConstMacro *pConstMacro = compiler.GetMeta().GetGlobalConstMacros().Find( procName ); 390 if( pConstMacro ) 391 { 392 if( pConstMacro->GetCalcBuffer( parameter, temporary ) ) 393 { 394 ///////////////////////// 395 // マクロ関数 396 ///////////////////////// 397 398 //閉じカッコ")"に続く文字がNULLでないときはエラーにする 399 if(termFull[i2+1+i4+1]!='\0') SetError(42,NULL,cp); 400 401 //マクロ関数の場合 402 NumOpe(useReg, temporary,Type(),resultType); 403 404 if(!IS_LITERAL(resultType.GetIndex())){ 405 //リテラル値ではなかったとき 406 isLiteral = false; 407 } 408 409 return true; 402 410 } 403 404 return true;405 411 } 406 412 } … … 855 861 ////////////// 856 862 857 i3 = CDBConst::obj.GetBasicType(term);863 i3 = compiler.GetMeta().GetGlobalConsts().GetBasicType(term); 858 864 if(i3){ 859 if( CDBConst::obj.IsStringPtr( term ) ){865 if( compiler.GetMeta().GetGlobalConsts().IsStringPtr( term ) ){ 860 866 //リテラル文字列 861 867 862 double dbl = CDBConst::obj.GetDoubleData(term);868 double dbl = compiler.GetMeta().GetGlobalConsts().GetDoubleData(term); 863 869 memcpy(&i64data,&dbl,sizeof(double)); 864 870 … … 874 880 if(IsRealNumberType(i3)){ 875 881 //実数 876 double dbl = CDBConst::obj.GetDoubleData(term);882 double dbl = compiler.GetMeta().GetGlobalConsts().GetDoubleData(term); 877 883 memcpy(&i64data,&dbl,sizeof(double)); 878 884 goto Literal; … … 880 886 else if(IsWholeNumberType(i3)){ 881 887 //整数 882 i64data = CDBConst::obj.GetWholeData(term);888 i64data = compiler.GetMeta().GetGlobalConsts().GetWholeData(term); 883 889 goto Literal; 884 890 } -
trunk/abdev/BasicCompiler32/NumOpe_Arithmetic.cpp
r75 r206 1 #include "stdafx.h" 2 1 3 #include "../BasicCompiler_Common/common.h" 2 4 #include "Opcode.h" … … 270 272 271 273 //call _allmul 272 extern UserProc *pSub_allmul;274 extern const UserProc *pSub_allmul; 273 275 op_call(pSub_allmul); 274 276 … … 460 462 461 463 //call _aullrem 462 extern UserProc *pSub_aullrem;464 extern const UserProc *pSub_aullrem; 463 465 op_call(pSub_aullrem); 464 466 } … … 467 469 468 470 //call _allrem 469 extern UserProc *pSub_allrem;471 extern const UserProc *pSub_allrem; 470 472 op_call(pSub_allrem); 471 473 } … … 720 722 721 723 //call _aulldiv 722 extern UserProc *pSub_aulldiv;724 extern const UserProc *pSub_aulldiv; 723 725 op_call(pSub_aulldiv); 724 726 } … … 727 729 728 730 //call _alldiv 729 extern UserProc *pSub_alldiv;731 extern const UserProc *pSub_alldiv; 730 732 op_call(pSub_alldiv); 731 733 } … … 1000 1002 1001 1003 //call pow 1002 extern UserProc *pSub_pow;1004 extern const UserProc *pSub_pow; 1003 1005 op_call(pSub_pow); 1004 1006 … … 1156 1158 1157 1159 //call _allshl 1158 extern UserProc *pSub_allshl;1160 extern const UserProc *pSub_allshl; 1159 1161 op_call(pSub_allshl); 1160 1162 … … 1361 1363 1362 1364 //call _aullshr 1363 extern UserProc *pSub_aullshr;1365 extern const UserProc *pSub_aullshr; 1364 1366 op_call(pSub_aullshr); 1365 1367 } … … 1368 1370 1369 1371 //call _allshr 1370 extern UserProc *pSub_allshr;1372 extern const UserProc *pSub_allshr; 1371 1373 op_call(pSub_allshr); 1372 1374 } -
trunk/abdev/BasicCompiler32/NumOpe_Logical.cpp
r36 r206 1 #include "stdafx.h" 2 1 3 #include "../BasicCompiler_Common/common.h" 2 4 #include "Opcode.h" -
trunk/abdev/BasicCompiler32/NumOpe_Relation.cpp
r97 r206 1 #include "stdafx.h" 2 1 3 #include "../BasicCompiler_Common/common.h" 2 4 #include "Opcode.h" -
trunk/abdev/BasicCompiler32/NumOpe_TypeOperation.cpp
r183 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 -
trunk/abdev/BasicCompiler32/Opcode.h
r142 r206 1 //Opcode.h 1 #pragma once 2 3 #include <Type.h> 4 #include <Procedure.h> 5 2 6 3 7 //未定義の定数情報 … … 201 205 bool _member_offset(bool isErrorEnabled, bool isWriteAccess, const CClass &objClass, const char *member, RELATIVE_VAR *pRelativeVar, Type &resultType, BOOL bPrivateAccess); 202 206 void SetThisPtrToReg(int reg); 203 bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, int *pss = 0);204 bool SetInitGlobalData(int offset,const Type &type,const int *SubScripts,const char *InitBuf);207 bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts = NULL ); 208 bool SetInitGlobalData(int offset,const Type &type,const Subscripts &subscripts,const char *InitBuf); 205 209 #define DIMFLAG_INITDEBUGVAR 1 206 210 #define DIMFLAG_NONCALL_CONSTRACTOR 2 207 211 #define DIMFLAG_STATIC 4 208 212 #define DIMFLAG_CONST 8 209 void dim( char *VarName, int *SubScripts,Type &type, const char *InitBuf,const char *ConstractParameter,DWORD dwFlags);213 void dim( char *VarName, const Subscripts &subscripts, Type &type, const char *InitBuf,const char *ConstractParameter,DWORD dwFlags); 210 214 void SetVarPtrToEax(RELATIVE_VAR *pRelativeVar); 211 215 void SetVarPtrToReg(int reg,RELATIVE_VAR *pRelativeVar); … … 234 238 bool EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType ); 235 239 public: 236 UserProc *_OverloadSolution( const char *name, std::vector<UserProc *> &subs, bool isEnabledReturnType = false );237 UserProc *OverloadSolution( const char *name, std::vector<UserProc *> &subs, bool isEnabledReturnType = false );240 const UserProc *_OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType = false ); 241 const UserProc *OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType = false ); 238 242 239 243 void ApplyDefaultParameters( const Parameters ¶ms ); … … 252 256 #define PROCFLAG_NEW 1 253 257 bool Opcode_CallProcPtr( const char *variable, const char *lpszParms,ProcPointer *pProcPointer); 254 bool Opcode_CallProc(const char *Parameter, UserProc *pUserProc,DWORD dwFlags,const char *ObjectName,int RefType);258 bool Opcode_CallProc(const char *Parameter,const UserProc *pUserProc,DWORD dwFlags,const char *ObjectName,int RefType); 255 259 bool Opcode_CallDllProc( const char *lpszParms, DllProc *pDllProc ); 256 260 … … 351 355 void fpu_cast_end(); 352 356 353 void op_call( UserProc *pUserProc);357 void op_call(const UserProc *pUserProc); 354 358 void op_ret(); -
trunk/abdev/BasicCompiler32/OperatorProc.cpp
r135 r206 1 #include "stdafx.h" 2 3 #include <jenga/include/smoothie/LexicalAnalysis.h> 4 1 5 #include "../BasicCompiler_Common/common.h" 2 6 #include "Opcode.h" … … 11 15 12 16 //call DestructorProcAddr 13 op_call( method->pUserProc);17 op_call( &method->GetUserProc() ); 14 18 } 15 19 … … 18 22 19 23 //call free 20 extern UserProc *pSub_free;24 extern const UserProc *pSub_free; 21 25 op_call(pSub_free); 22 26 } … … 27 31 pobj_c=(CClass *)index_stack[sp-2]; 28 32 29 std::vector< UserProc *> subs;33 std::vector<const UserProc *> subs; 30 34 pobj_c->GetMethods().Enum( idCalc, subs ); 31 35 if( subs.size() == 0 ){ … … 53 57 if(idCalc==CALC_EQUAL) lstrcpy(temporary,"=="); 54 58 else GetCalcName(idCalc,temporary); 55 UserProc *pUserProc = OverloadSolution( temporary, subs, params, baseType );59 const UserProc *pUserProc = OverloadSolution( temporary, subs, params, baseType ); 56 60 57 61 if(!pUserProc){ … … 107 111 108 112 //call calloc 109 extern UserProc *pSub_calloc;113 extern const UserProc *pSub_calloc; 110 114 op_call(pSub_calloc); 111 115 … … 249 253 } 250 254 void CallIndexerGetterProc(const CClass *pobj_Class,char *ObjectName,char *Parameter,Type &resultType){ 251 std::vector< UserProc *> subs;255 std::vector<const UserProc *> subs; 252 256 pobj_Class->GetMethods().Enum( CALC_ARRAY_GET, subs ); 253 257 if( subs.size() == 0 ){ -
trunk/abdev/BasicCompiler32/increment.cpp
r129 r206 1 #include "stdafx.h" 2 1 3 #include "../BasicCompiler_Common/common.h" 2 4 #include "Opcode.h" -
trunk/abdev/BasicCompiler32/op32_main.cpp
r142 r206 1 #include "stdafx.h" 2 1 3 #include "../BasicCompiler_Common/common.h" 2 4 #include "Opcode.h" … … 980 982 ///////////////////////////// 981 983 982 void op_call( UserProc *pUserProc){984 void op_call(const UserProc *pUserProc){ 983 985 OpBuffer[obp++]=(char)0xE8; 984 986 pobj_SubAddrSchedule->add(pUserProc,1); -
trunk/abdev/BasicCompiler64/BasicCompiler.vcproj
r198 r206 55 55 RuntimeLibrary="1" 56 56 RuntimeTypeInfo="true" 57 UsePrecompiledHeader=" 0"57 UsePrecompiledHeader="2" 58 58 PrecompiledHeaderFile=".\Debug/BasicCompiler.pch" 59 59 AssemblerListingLocation=".\Debug/" … … 167 167 RuntimeLibrary="1" 168 168 RuntimeTypeInfo="true" 169 UsePrecompiledHeader=" 0"169 UsePrecompiledHeader="2" 170 170 PrecompiledHeaderFile=".\Release/BasicCompiler.pch" 171 171 AssemblerListingLocation=".\Release/" … … 246 246 </File> 247 247 <File 248 RelativePath="..\BasicCompiler_Common\BasicFixed.h"249 >250 </File>251 <File252 248 RelativePath="CommandValue.h" 253 249 > … … 263 259 <File 264 260 RelativePath="..\BasicCompiler_Common\include\option.h" 261 > 262 </File> 263 <File 264 RelativePath=".\stdafx.h" 265 265 > 266 266 </File> … … 289 289 > 290 290 <File 291 RelativePath="..\BasicCompiler_Common\include\Class Impl.h"291 RelativePath="..\BasicCompiler_Common\include\Class.h" 292 292 > 293 293 </File> … … 301 301 </File> 302 302 <File 303 RelativePath="..\BasicCompiler_Common\include\Const.h" 304 > 305 </File> 306 <File 303 307 RelativePath="..\BasicCompiler_Common\include\DataTable.h" 304 308 > … … 313 317 </File> 314 318 <File 319 RelativePath="..\BasicCompiler_Common\include\Member.h" 320 > 321 </File> 322 <File 315 323 RelativePath="..\BasicCompiler_Common\include\MetaImpl.h" 316 324 > 317 325 </File> 318 326 <File 327 RelativePath="..\BasicCompiler_Common\include\Method.h" 328 > 329 </File> 330 <File 319 331 RelativePath="..\BasicCompiler_Common\include\NamespaceSupporter.h" 320 332 > 321 333 </File> 322 334 <File 323 RelativePath="..\BasicCompiler_Common\include\ProcedureImpl.h" 335 RelativePath="..\BasicCompiler_Common\include\Parameter.h" 336 > 337 </File> 338 <File 339 RelativePath="..\BasicCompiler_Common\include\Procedure.h" 324 340 > 325 341 </File> … … 329 345 </File> 330 346 <File 347 RelativePath="..\BasicCompiler_Common\include\Prototype.h" 348 > 349 </File> 350 <File 331 351 RelativePath="..\BasicCompiler_Common\include\SmoothieImpl.h" 332 352 > 333 353 </File> 334 354 <File 355 RelativePath="..\BasicCompiler_Common\include\Symbol.h" 356 > 357 </File> 358 <File 359 RelativePath="..\BasicCompiler_Common\include\Type.h" 360 > 361 </File> 362 <File 335 363 RelativePath="..\BasicCompiler_Common\include\TypeDef.h" 336 364 > 337 365 </File> 338 366 <File 339 RelativePath="..\BasicCompiler_Common\include\Variable Impl.h"367 RelativePath="..\BasicCompiler_Common\include\Variable.h" 340 368 > 341 369 </File> … … 396 424 Name="VCResourceCompilerTool" 397 425 PreprocessorDefinitions="_DEBUG;JPN;$(NoInherit)" 426 /> 427 </FileConfiguration> 428 </File> 429 <File 430 RelativePath=".\stdafx.cpp" 431 > 432 <FileConfiguration 433 Name="Debug|Win32" 434 > 435 <Tool 436 Name="VCCLCompilerTool" 437 UsePrecompiledHeader="1" 438 /> 439 </FileConfiguration> 440 <FileConfiguration 441 Name="Release|Win32" 442 > 443 <Tool 444 Name="VCCLCompilerTool" 445 UsePrecompiledHeader="1" 398 446 /> 399 447 </FileConfiguration> … … 981 1029 </Filter> 982 1030 <Filter 983 Name="Constant"984 >985 <File986 RelativePath="..\BasicCompiler_Common\Const.cpp"987 >988 </File>989 <File990 RelativePath="..\BasicCompiler_Common\Const.h"991 >992 </File>993 </Filter>994 <Filter995 1031 Name="Variable" 996 1032 > … … 1021 1057 > 1022 1058 <File 1023 RelativePath="..\BasicCompiler_Common\src\Class Impl.cpp"1059 RelativePath="..\BasicCompiler_Common\src\Class.cpp" 1024 1060 > 1025 1061 </File> … … 1033 1069 </File> 1034 1070 <File 1071 RelativePath="..\BasicCompiler_Common\src\Const.cpp" 1072 > 1073 </File> 1074 <File 1035 1075 RelativePath="..\BasicCompiler_Common\src\DataTable.cpp" 1036 1076 > … … 1045 1085 </File> 1046 1086 <File 1087 RelativePath="..\BasicCompiler_Common\src\Method.cpp" 1088 > 1089 </File> 1090 <File 1047 1091 RelativePath="..\BasicCompiler_Common\src\NamespaceSupporter.cpp" 1048 1092 > 1049 1093 </File> 1050 1094 <File 1051 RelativePath="..\BasicCompiler_Common\src\Procedure Impl.cpp"1095 RelativePath="..\BasicCompiler_Common\src\Procedure.cpp" 1052 1096 > 1053 1097 </File> … … 1061 1105 </File> 1062 1106 <File 1107 RelativePath="..\BasicCompiler_Common\src\Symbol.cpp" 1108 > 1109 </File> 1110 <File 1111 RelativePath="..\BasicCompiler_Common\src\Type.cpp" 1112 > 1113 </File> 1114 <File 1063 1115 RelativePath="..\BasicCompiler_Common\src\TypeDef.cpp" 1064 1116 > 1065 1117 </File> 1066 1118 <File 1067 RelativePath="..\BasicCompiler_Common\src\Variable Impl.cpp"1119 RelativePath="..\BasicCompiler_Common\src\Variable.cpp" 1068 1120 > 1069 1121 </File> -
trunk/abdev/BasicCompiler64/CLockParameter.cpp
r3 r206 1 #include "stdafx.h" 2 1 3 #include "../BasicCompiler_Common/common.h" 2 4 #include "opcode.h" -
trunk/abdev/BasicCompiler64/CParameter.cpp
r75 r206 1 #include "stdafx.h" 2 1 3 #include "../BasicCompiler_Common/common.h" 2 4 #include "opcode.h" … … 110 112 111 113 //call free 112 extern UserProc *pSub_free;114 extern const UserProc *pSub_free; 113 115 op_call(pSub_free); 114 116 } … … 133 135 134 136 //call calloc 135 extern UserProc *pSub_calloc;137 extern const UserProc *pSub_calloc; 136 138 op_call(pSub_calloc); 137 139 -
trunk/abdev/BasicCompiler64/Compile_Calc.cpp
r198 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 #include <jenga/include/smoothie/LexicalAnalysis.h> … … 94 96 } 95 97 else{ 96 if(GetConstHash(variable)){ 98 if( compiler.GetMeta().GetGlobalConsts().IsExist(variable) 99 || compiler.GetMeta().GetGlobalConstMacros().IsExist(variable) ) 100 { 97 101 //定数リストに該当したとき 98 102 SetError(1,NULL,cp); … … 234 238 if( varType.IsObject() && compiler.GetMeta().GetBlittableTypes().IsExist( calcType ) ){ 235 239 // Blittable型をオブジェクトとして扱う 236 vector< UserProc *> userProcs;240 vector<const UserProc *> userProcs; 237 241 compiler.GetMeta().GetBlittableTypes().GetClass( calcType ).GetStaticMethods().Enum( "_Create", userProcs ); 238 242 if( userProcs.size() != 1 ){ … … 240 244 return; 241 245 } 242 UserProc *pUserProc = userProcs[0];246 const UserProc *pUserProc = userProcs[0]; 243 247 244 248 // mov rcx, rax -
trunk/abdev/BasicCompiler64/Compile_Calc_PushVar.cpp
r66 r206 1 #include "stdafx.h" 2 1 3 #include "../BasicCompiler_Common/common.h" 2 4 #include "Opcode.h" -
trunk/abdev/BasicCompiler64/Compile_CallProc.cpp
r198 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 … … 12 14 void Call_DebugSys_SaveContext(){ 13 15 //call _System_GetEip 14 extern UserProc *pSub_System_GetEip;16 extern const UserProc *pSub_System_GetEip; 15 17 op_call(pSub_System_GetEip); 16 18 … … 22 24 23 25 //call _DebugSys_SaveContext 24 extern UserProc *pSub_DebugSys_SaveContext;26 extern const UserProc *pSub_DebugSys_SaveContext; 25 27 op_call(pSub_DebugSys_SaveContext); 26 28 } … … 99 101 } 100 102 101 bool Opcode_CallProc(const char *Parameter, UserProc *pUserProc,DWORD dwFlags,const char *ObjectName,int RefType){103 bool Opcode_CallProc(const char *Parameter,const UserProc *pUserProc,DWORD dwFlags,const char *ObjectName,int RefType){ 102 104 // TODO: RefTypeは不必要なので削除する 103 105 int i2; … … 128 130 if(lstrcmpi(ObjectName,"Super")==0){ 129 131 //クラスメンバ関数内から基底クラスの呼び出し 130 pobj_c= Smoothie::Temp::pCompilingClass;132 pobj_c=compiler.pCompilingClass; 131 133 } 132 134 else{ … … 153 155 else{ 154 156 //クラスメンバ関数内から同一クラスのメンバ関数の呼び出し 155 pobj_c= Smoothie::Temp::pCompilingClass;157 pobj_c=compiler.pCompilingClass; 156 158 } 157 159 } … … 182 184 if(ObjectName[0]){ 183 185 //外部からの呼び出し 184 if(pobj_c== Smoothie::Temp::pCompilingClass){186 if(pobj_c==compiler.pCompilingClass){ 185 187 //同一クラスオブジェクトの場合はプライベートアクセスを容認する 186 188 if( pMethod->IsNoneAccess() ){ … … 279 281 280 282 //call calloc 281 extern UserProc *pSub_calloc;283 extern const UserProc *pSub_calloc; 282 284 op_call(pSub_calloc); 283 285 -
trunk/abdev/BasicCompiler64/Compile_Func.cpp
r198 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 … … 46 48 } 47 49 48 int SubScripts[MAX_ARRAYDIM];50 Subscripts subscripts; 49 51 RELATIVE_VAR RelativeVar; 50 if(!GetVarOffsetReadOnly(tempParm,&RelativeVar,type, SubScripts)) return;52 if(!GetVarOffsetReadOnly(tempParm,&RelativeVar,type,&subscripts)) return; 51 53 52 54 if(type.GetBasicType()&FLAG_PTR){ … … 59 61 int typeSize = type.GetSize(); 60 62 61 if(bArrayHead) typeSize*=JumpSubScripts( SubScripts);63 if(bArrayHead) typeSize*=JumpSubScripts(subscripts); 62 64 63 65 //mov rax,TypeSize … … 68 70 void Opcode_Func_AddressOf( const char *name ){ 69 71 extern int cp; 70 UserProc *pUserProc;72 const UserProc *pUserProc; 71 73 72 74 extern LONG_PTR ProcPtr_BaseIndex; … … 74 76 //左辺の型にのっとり、オーバーロードを解決 75 77 76 std::vector< UserProc *> subs;78 std::vector<const UserProc *> subs; 77 79 GetOverloadSubHash( name, subs ); 78 80 if( subs.size() == 0 ){ … … 131 133 SetThisPtrToReg(REG_RCX); 132 134 133 pobj_c= Smoothie::Temp::pCompilingClass;135 pobj_c=compiler.pCompilingClass; 134 136 } 135 137 -
trunk/abdev/BasicCompiler64/Compile_Interface.cpp
r132 r206 1 #include "stdafx.h" 2 1 3 #include "../BasicCompiler_Common/common.h" 2 4 #include "opcode.h" -
trunk/abdev/BasicCompiler64/Compile_Object.cpp
r140 r206 1 #include "stdafx.h" 2 1 3 #include "../BasicCompiler_Common/common.h" 2 4 #include "opcode.h" … … 33 35 //////////////////////// 34 36 35 std::vector< UserProc *> subs;37 std::vector<const UserProc *> subs; 36 38 pobj_c->GetMethods().Enum( pobj_c->GetName().c_str(), subs ); 37 39 38 UserProc *pUserProc;40 const UserProc *pUserProc; 39 41 if( subs.size() > 0 ){ 40 42 //オーバーロードを解決 … … 142 144 143 145 //call _System_GC_malloc_ForObject 144 extern UserProc *pSub_System_GC_malloc_ForObject;146 extern const UserProc *pSub_System_GC_malloc_ForObject; 145 147 op_call(pSub_System_GC_malloc_ForObject); 146 148 } … … 150 152 151 153 //call _System_GC_malloc_ForObjectPtr 152 extern UserProc *pSub_System_GC_malloc_ForObjectPtr;154 extern const UserProc *pSub_System_GC_malloc_ForObjectPtr; 153 155 op_call(pSub_System_GC_malloc_ForObjectPtr); 154 156 } … … 185 187 op_mov_RV(sizeof(_int64),REG_RCX,0); 186 188 obp-=sizeof(long); 187 pobj_SubAddrSchedule->add( method->pUserProc,0);188 method-> pUserProc->Using();189 pobj_SubAddrSchedule->add(&method->GetUserProc(),0); 190 method->GetUserProc().Using(); 189 191 obp+=sizeof(long); 190 192 … … 299 301 if( isSweeping ){ 300 302 //call _System_GC_free_for_SweepingDelete 301 extern UserProc *pSub_System_GC_free_for_SweepingDelete;303 extern const UserProc *pSub_System_GC_free_for_SweepingDelete; 302 304 op_call(pSub_System_GC_free_for_SweepingDelete); 303 305 } 304 306 else{ 305 307 //call free 306 extern UserProc *pSub_free;308 extern const UserProc *pSub_free; 307 309 op_call(pSub_free); 308 310 } -
trunk/abdev/BasicCompiler64/Compile_ProcOp.cpp
r204 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 #include <jenga/include/smoothie/LexicalAnalysis.h> … … 5 7 #include <Compiler.h> 6 8 #include <LexicalScopingImpl.h> 7 #include <ClassImpl.h> 8 #include <VariableImpl.h> 9 #include <Class.h> 9 10 10 11 #include "../BasicCompiler_Common/common.h" … … 31 32 } 32 33 33 UserProc *pBackUserProc; 34 pBackUserProc = &UserProc::CompilingUserProc(); 34 const UserProc *pBackUserProc = &UserProc::CompilingUserProc(); 35 35 UserProc::CompileStartForGlobalArea(); 36 36 … … 54 54 55 55 //_System_StartupProgramの呼び出し 56 extern UserProc *pSub_System_StartupProgram;56 extern const UserProc *pSub_System_StartupProgram; 57 57 op_call(pSub_System_StartupProgram); 58 58 … … 82 82 StackFrameSchedule=obp-sizeof(long); 83 83 84 BOOST_FOREACH( Variable *pVar, globalVars){84 BOOST_FOREACH( Variable *pVar, compiler.GetMeta().GetGlobalVars() ){ 85 85 if(memicmp(pVar->GetName().c_str(),"Static%",7)==0){ 86 86 //コンストラクタ呼び出し 87 if( pVar-> IsObject() ){87 if( pVar->GetType().IsObject() ){ 88 88 89 89 //エラー用 … … 92 92 CallConstructor( 93 93 pVar->GetName().c_str(), 94 pVar->GetSub ScriptsPtr(),95 *pVar,96 pVar-> paramStrForConstructor.c_str());94 pVar->GetSubscripts(), 95 pVar->GetType(), 96 pVar->GetParamStrForConstructor().c_str()); 97 97 } 98 98 } … … 113 113 114 114 115 UserProc *pBackUserProc; 116 pBackUserProc = &UserProc::CompilingUserProc(); 115 const UserProc *pBackUserProc = &UserProc::CompilingUserProc(); 117 116 UserProc::CompileStartForGlobalArea(); 118 117 … … 212 211 } 213 212 } 214 void AutoGeneration( UserProc &userProc){213 void AutoGeneration(const UserProc &userProc){ 215 214 if( userProc.GetName() == "InitializeUserTypes" 216 215 && userProc.HasParentClass() … … 229 228 } 230 229 } 231 void _compile_proc( UserProc *pUserProc){230 void _compile_proc(const UserProc *pUserProc){ 232 231 extern char *basbuf; 233 232 extern HANDLE hHeap; 234 extern GlobalProc **ppSubHash;235 233 extern BOOL bDebugCompile; 236 234 int i3,i4; … … 239 237 if( pUserProc->IsUsing() == false || pUserProc->IsCompiled() ) return; 240 238 241 if( pUserProc-> localVars.size() ){239 if( pUserProc->GetLocalVars().size() ){ 242 240 SetError(); 243 241 return; 244 242 } 243 244 trace_for_sourcecodestep( "★★★ " << pUserProc->GetFullName() << "のコンパイルを開始" ); 245 245 246 246 pUserProc->CompleteCompile(); … … 259 259 else bDebugSupportProc=0; 260 260 261 pUserProc-> beginOpAddress=obp;261 pUserProc->SetBeginOpAddress( obp ); 262 262 263 263 //コンパイル中の関数が属するクラス 264 Smoothie::Temp::pCompilingClass=pUserProc->GetParentClassPtr();264 compiler.pCompilingClass=pUserProc->GetParentClassPtr(); 265 265 266 266 //コンパイルスタートをクラス管理クラスに追加 … … 294 294 pobj_sf=0; 295 295 296 pUserProc-> endOpAddress=obp;296 pUserProc->SetEndOpAddress( obp ); 297 297 return; 298 298 } … … 360 360 Parameter ¶m = *pUserProc->RealParams()[i3]; 361 361 362 Variable *pVar = new Variable Impl( param.GetVarName(), param, false, param.IsRef());362 Variable *pVar = new Variable( param.GetVarName(), param, false, param.IsRef(), "" ); 363 363 364 364 if( param.IsArray() ){ 365 pVar->SetArray( param.GetSub ScriptsPtr() );365 pVar->SetArray( param.GetSubscripts() ); 366 366 } 367 367 … … 381 381 } 382 382 AllLocalVarSize+=varSize; 383 pVar-> offset=AllLocalVarSize;383 pVar->SetOffsetAddress( AllLocalVarSize ); 384 384 385 385 //レキシカルスコープ情報 386 pVar->S copeLevel=GetLexicalScopes().GetNowLevel();387 pVar->S copeStartAddress=GetLexicalScopes().GetStartAddress();386 pVar->SetScopeLevel( GetLexicalScopes().GetNowLevel() ); 387 pVar->SetScopeStartAddress( GetLexicalScopes().GetStartAddress() ); 388 388 pVar->bLiving=TRUE; 389 389 390 pUserProc-> localVars.push_back( pVar );390 pUserProc->GetLocalVars().push_back( pVar ); 391 391 } 392 392 … … 507 507 508 508 //call _DebugSys_StartProc 509 extern UserProc *pSub_DebugSys_StartProc;509 extern const UserProc *pSub_DebugSys_StartProc; 510 510 op_call(pSub_DebugSys_StartProc); 511 511 } 512 512 513 if( Smoothie::Temp::pCompilingClass){514 if( pUserProc->GetName() == Smoothie::Temp::pCompilingClass->GetName() ){513 if(compiler.pCompilingClass){ 514 if( pUserProc->GetName() == compiler.pCompilingClass->GetName() ){ 515 515 //////////////////////////////////// 516 516 // コンストラクタをコンパイルするとき … … 518 518 519 519 //コンストラクタのコンパイル開始を通知 520 Smoothie::Temp::pCompilingClass->NotifyStartConstructorCompile();520 compiler.pCompilingClass->NotifyStartConstructorCompile(); 521 521 522 522 //基底クラスかどうかの識別 523 523 //(継承元がインターフェイスの場合も基底クラスと見なす) 524 524 BOOL bThisIsSuperClass; 525 if( ! Smoothie::Temp::pCompilingClass->HasSuperClass() ) bThisIsSuperClass=1;526 else if( Smoothie::Temp::pCompilingClass->GetSuperClass().GetConstructorMethod() == NULL ){525 if( !compiler.pCompilingClass->HasSuperClass() ) bThisIsSuperClass=1; 526 else if( compiler.pCompilingClass->GetSuperClass().GetConstructorMethod() == NULL ){ 527 527 //インターフェイスを継承したときはコンストラクタを持たない 528 528 bThisIsSuperClass=1; … … 543 543 temporary[i4]=basbuf[i3]; 544 544 } 545 if( Smoothie::Temp::pCompilingClass->GetSuperClass().GetName() == temporary ){545 if( compiler.pCompilingClass->GetSuperClass().GetName() == temporary ){ 546 546 //基底クラスのコンストラクタを呼び出す 547 547 cp=i3; … … 560 560 Type dummyType; 561 561 CallProc( PROC_DEFAULT 562 , Smoothie::Temp::pCompilingClass->GetSuperClass().GetConstructorMethod()->pUserProc563 , Smoothie::Temp::pCompilingClass->GetSuperClass().GetConstructorMethod()->pUserProc->GetName().c_str()562 , &compiler.pCompilingClass->GetSuperClass().GetConstructorMethod()->GetUserProc() 563 , compiler.pCompilingClass->GetSuperClass().GetConstructorMethod()->GetUserProc().GetName().c_str() 564 564 , temporary 565 565 , dummyType ); … … 568 568 //基底クラスのコンストラクタを暗黙的に呼び出す 569 569 Opcode_CallProc("", 570 Smoothie::Temp::pCompilingClass->GetSuperClass().GetConstructorMethod()->pUserProc,570 &compiler.pCompilingClass->GetSuperClass().GetConstructorMethod()->GetUserProc(), 571 571 0, 572 572 "", … … 576 576 577 577 //仮想関数テーブルを初期化 578 if( Smoothie::Temp::pCompilingClass->IsExistVirtualFunctions()579 && ! Smoothie::Temp::pCompilingClass->IsAbstract() ){578 if( compiler.pCompilingClass->IsExistVirtualFunctions() 579 && !compiler.pCompilingClass->IsAbstract() ){ 580 580 //関数テーブルに値をセット 581 int offset = (int) Smoothie::Temp::pCompilingClass->GetVtblGlobalOffset();581 int offset = (int)compiler.pCompilingClass->GetVtblGlobalOffset(); 582 582 583 583 //mov rax,offset … … 598 598 599 599 //デストラクタのコンパイル開始を通知 600 Smoothie::Temp::pCompilingClass->NotifyStartDestructorCompile();600 compiler.pCompilingClass->NotifyStartDestructorCompile(); 601 601 } 602 602 } … … 624 624 ////////////////////////////////////////// 625 625 626 if( Smoothie::Temp::pCompilingClass ){627 628 if( Smoothie::Temp::pCompilingClass->IsCompilingConstructor() ){626 if( compiler.pCompilingClass ){ 627 628 if( compiler.pCompilingClass->IsCompilingConstructor() ){ 629 629 // コンストラクタをコンパイルしていたとき 630 630 631 631 // コンストラクタのコンパイルが完了したことを通知 632 Smoothie::Temp::pCompilingClass->NotifyFinishConstructorCompile();632 compiler.pCompilingClass->NotifyFinishConstructorCompile(); 633 633 } 634 634 else if( pUserProc->IsDestructor() ){ … … 638 638 639 639 // デストラクタのコンパイルが完了したことを通知 640 Smoothie::Temp::pCompilingClass->NotifyFinishDestructorCompile();641 642 if( Smoothie::Temp::pCompilingClass->HasSuperClass() ){640 compiler.pCompilingClass->NotifyFinishDestructorCompile(); 641 642 if( compiler.pCompilingClass->HasSuperClass() ){ 643 643 /* サブクラスのデストラクタをコンパイルしているときは、 644 644 基底クラスのデストラクタを呼び出す */ 645 645 646 const CMethod *method = Smoothie::Temp::pCompilingClass->GetSuperClass().GetDestructorMethod();646 const CMethod *method = compiler.pCompilingClass->GetSuperClass().GetDestructorMethod(); 647 647 if( method ){ 648 648 Opcode_CallProc("", 649 method->pUserProc,649 &method->GetUserProc(), 650 650 0, 651 651 "", … … 694 694 if(bDebugCompile&&bDebugSupportProc==0){ 695 695 //call _DebugSys_EndProc 696 extern UserProc *pSub_DebugSys_EndProc;696 extern const UserProc *pSub_DebugSys_EndProc; 697 697 op_call(pSub_DebugSys_EndProc); 698 698 } … … 745 745 } 746 746 HeapDefaultFree(pLocalVarAddrSchedule); 747 BOOST_FOREACH( Variable *pVar, pUserProc-> localVars){747 BOOST_FOREACH( Variable *pVar, pUserProc->GetLocalVars() ){ 748 748 //後にデバッグで利用する 749 pVar->offset = AllLocalVarSize + pobj_sf->GetFrameSize() - pVar->offset; 749 pVar->SetOffsetAddress( 750 AllLocalVarSize + pobj_sf->GetFrameSize() - pVar->GetOffsetAddress() 751 ); 750 752 } 751 753 … … 785 787 786 788 787 pUserProc-> endOpAddress=obp;789 pUserProc->SetEndOpAddress( obp ); 788 790 789 791 … … 793 795 } 794 796 795 void CompileBufferInProcedure( UserProc &userProc ){797 void CompileBufferInProcedure( const UserProc &userProc ){ 796 798 if( userProc.IsUsing() == false || userProc.IsCompiled() ) return; 797 799 … … 809 811 } 810 812 void CompileLocal(){ 811 extern GlobalProc **ppSubHash;812 int i2;813 814 813 extern BOOL bDll; 815 814 if(bDll){ 816 815 //DLLの場合はグローバル変数を初期化するための関数を一番初めにコンパイルする 817 UserProc *pUserProc=GetSubHash("_System_InitDllGlobalVariables");816 const UserProc *pUserProc = GetSubHash("_System_InitDllGlobalVariables"); 818 817 if(pUserProc){ 819 818 CompileBufferInProcedure( *pUserProc ); … … 823 822 824 823 //_System_TypeBase_InitializeUserTypesは一番最後にコンパイル 825 extern UserProc *pSubStaticMethod_System_TypeBase_InitializeUserTypes;824 extern const UserProc *pSubStaticMethod_System_TypeBase_InitializeUserTypes; 826 825 pSubStaticMethod_System_TypeBase_InitializeUserTypes->CompleteCompile(); 827 826 828 827 //_System_InitStaticLocalVariablesは一番最後にコンパイル 829 828 //※一般関数内の静的変数オブジェクトをすべて収集しなければならない 830 extern UserProc *pSub_System_InitStaticLocalVariables;829 extern const UserProc *pSub_System_InitStaticLocalVariables; 831 830 pSub_System_InitStaticLocalVariables->CompleteCompile(); 832 831 833 832 //_System_Call_Destructor_of_GlobalObjectは一番最後にコンパイル 834 extern UserProc *pSub_System_Call_Destructor_of_GlobalObject;833 extern const UserProc *pSub_System_Call_Destructor_of_GlobalObject; 835 834 pSub_System_Call_Destructor_of_GlobalObject->CompleteCompile(); 836 835 837 836 repeat: 838 GlobalProc *pGlobalProc; 839 for(i2=0;i2<MAX_HASH;i2++){ 840 pGlobalProc=ppSubHash[i2]; 841 while(pGlobalProc){ 842 CompileBufferInProcedure( *pGlobalProc ); 843 pGlobalProc=pGlobalProc->pNextData; 844 } 837 compiler.GetMeta().GetUserProcs().Iterator_Reset(); 838 while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() ) 839 { 840 UserProc *pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext(); 841 CompileBufferInProcedure( *pUserProc ); 845 842 } 846 843 … … 856 853 if( IsNeedProcCompile() ){ 857 854 //プロシージャコンパイルによって、プロシージャコンパイルが必要になる場合 858 for(i2=0;i2<MAX_HASH;i2++){ 859 pGlobalProc=ppSubHash[i2];860 while(pGlobalProc){861 CompileBufferInProcedure( *pGlobalProc );862 pGlobalProc=pGlobalProc->pNextData;863 }855 856 compiler.GetMeta().GetUserProcs().Iterator_Reset(); 857 while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() ) 858 { 859 UserProc *pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext(); 860 CompileBufferInProcedure( *pUserProc ); 864 861 } 865 862 } -
trunk/abdev/BasicCompiler64/Compile_Set_Var.cpp
r96 r206 1 #include "stdafx.h" 2 1 3 #include "../BasicCompiler_Common/common.h" 2 4 #include "Opcode.h" … … 78 80 79 81 //call free 80 extern UserProc *pSub_free;82 extern const UserProc *pSub_free; 81 83 op_call(pSub_free); 82 84 } -
trunk/abdev/BasicCompiler64/Compile_Statement.cpp
r198 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/LexicalAnalysis.h> 2 4 … … 9 11 void OpcodeOthers(const char *Command){ 10 12 int i,i2; 11 UserProc *pUserProc;12 13 13 14 char leftTerm[8192]; … … 59 60 ////////////////////////////// 60 61 61 pUserProc=GetSubHash(Command);62 const UserProc *pUserProc=GetSubHash(Command); 62 63 63 64 //GetSubHash内でエラー提示が行われた場合 … … 737 738 738 739 if(type1.IsObject()){ 739 std::vector< UserProc *> subs;740 std::vector<const UserProc *> subs; 740 741 type1.GetClass().GetMethods().Enum( CALC_EQUAL, subs ); 741 742 if( subs.size() == 0 ){ … … 747 748 748 749 //オーバーロードを解決 749 UserProc *pUserProc; 750 pUserProc=OverloadSolution("==",subs, params, NULL); 750 const UserProc *pUserProc = OverloadSolution("==",subs, params, NULL); 751 751 752 752 delete params[0]; … … 892 892 893 893 //call _System_GetEip 894 extern UserProc *pSub_System_GetEip;894 extern const UserProc *pSub_System_GetEip; 895 895 op_call(pSub_System_GetEip); 896 896 … … 953 953 //戻り値をセット 954 954 if(Parameter[0]){ 955 UserProc &proc = UserProc::CompilingUserProc();955 const UserProc &proc = UserProc::CompilingUserProc(); 956 956 957 957 const char *temp = "_System_ReturnValue"; -
trunk/abdev/BasicCompiler64/Compile_Var.cpp
r198 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 #include <jenga/include/smoothie/LexicalAnalysis.h> … … 5 7 #include <CodeGenerator.h> 6 8 #include <Compiler.h> 7 #include <Variable Impl.h>9 #include <Variable.h> 8 10 9 11 #include "../BasicCompiler_Common/common.h" … … 11 13 12 14 //変数 13 Variables globalVars; 15 // TODO: xml未完成 14 16 int AllGlobalVarSize; 15 17 int AllInitGlobalVarSize; … … 86 88 } 87 89 } 88 bool GetArrayOffset(const int *SubScripts,char *array, const Type &type){90 bool GetArrayOffset(const Subscripts &subscripts,char *array, const Type &type){ 89 91 extern HANDLE hHeap; 90 92 int i,i2,i3,i4; … … 105 107 } 106 108 if(array[i]==','||array[i]=='\0'){ 107 if(SubScripts[i3]==-1){ 109 if( i3 >= (int)subscripts.size() ) 110 { 108 111 for(i3--;i3>=0;i3--) HeapDefaultFree(pParm[i3]); 109 112 return false; … … 118 121 119 122 if(array[i]=='\0'){ 120 if(SubScripts[i3]!=-1){ 123 if( i3 < (int)subscripts.size() ) 124 { 121 125 for(i3--;i3>=0;i3--) HeapDefaultFree(pParm[i3]); 122 126 return false; … … 166 170 pobj_sf->pop(REG_R12); 167 171 168 for(i2=i+1,i4=1;i2<i3;i2++) i4*= SubScripts[i2]+1;172 for(i2=i+1,i4=1;i2<i3;i2++) i4*=subscripts[i2]+1; 169 173 170 174 //imul reg,i4 … … 204 208 char lpPtrOffset[VN_SIZE]; //第2次配列 205 209 char NestMember[VN_SIZE]; //入れ子メンバ 206 CClass::RefTyperefType;210 ReferenceKind refType; 207 211 lstrcpy(VarName,member); 208 212 if(!GetVarFormatString(VarName,array,lpPtrOffset,NestMember,refType)) return false; … … 224 228 225 229 //アクセシビリティをチェック 226 if(&objClass== Smoothie::Temp::pCompilingClass){230 if(&objClass==compiler.pCompilingClass){ 227 231 //同一クラスオブジェクトの場合はプライベートアクセスを容認する 228 232 if(pMember->IsNoneAccess()){ … … 257 261 //ポインタ変数の場合 258 262 if( resultType.IsPointer() ){ 259 if( pMember->SubScripts[0]==-1){263 if( pMember->GetSubscripts().size() == 0 ){ 260 264 lstrcpy(lpPtrOffset,array); 261 265 array[0]=0; … … 280 284 if(array[0]){ 281 285 //配列オフセット 282 if(!GetArrayOffset(pMember-> SubScripts,array,pMember->GetType())){286 if(!GetArrayOffset(pMember->GetSubscripts(),array,pMember->GetType())){ 283 287 if(isErrorEnabled) SetError(14,member,cp); 284 288 } 285 289 } 286 else if( pMember->SubScripts[0]!=-1){290 else if( pMember->GetSubscripts().size() > 0 ){ 287 291 resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR ); 288 292 } … … 292 296 293 297 if( resultType.IsObject() || resultType.IsStruct() ){ 294 if( refType != CClass::Dot ){298 if( refType != RefDot ){ 295 299 if(isErrorEnabled) SetError(104,member,cp); 296 300 return false; … … 308 312 //pObj[n].member 309 313 if( ( resultType.IsObjectPtr() || resultType.IsStructPtr() ) 310 && refType != CClass::Dot ){314 && refType != RefDot ){ 311 315 if(isErrorEnabled) SetError(104,member,cp); 312 316 return false; … … 322 326 //pObj->member 323 327 if( (resultType.IsObjectPtr() || resultType.IsStructPtr() ) 324 && refType != CClass::Pointer ){328 && refType != RefPointer ){ 325 329 if(isErrorEnabled) SetError(104,member,cp); 326 330 return false; … … 336 340 if(lpPtrOffset[0]){ 337 341 //ppObj[n]->member 338 if( refType != CClass::Pointer ){342 if( refType != RefPointer ){ 339 343 if(isErrorEnabled) SetError(104,member,cp); 340 344 return false; … … 385 389 SetReg_WholeVariable(DEF_PTR_VOID,&RelativeVar,reg); 386 390 } 387 bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, int *pss){391 bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts ){ 388 392 char variable[VN_SIZE]; 389 393 … … 399 403 400 404 // 先頭オブジェクトまたはクラス名と入れ子メンバに分割 401 CClass::RefTyperefType;405 ReferenceKind refType; 402 406 char member[VN_SIZE],array[VN_SIZE],lpPtrOffset[VN_SIZE]; 403 407 GetVarFormatString(simpleName,array,lpPtrOffset,member,refType); … … 412 416 } 413 417 414 const int *pSubScripts;418 const Subscripts *pSubscripts; 415 419 bool bConst = false; 416 420 … … 421 425 ////////////////// 422 426 423 const Variable *pVar = UserProc::CompilingUserProc(). localVars.BackSearch( VarName);427 const Variable *pVar = UserProc::CompilingUserProc().GetLocalVars().BackSearch( Symbol( VarName ) ); 424 428 if( pVar ){ 425 429 //ポインタ変数の場合 426 if( pVar-> IsPointer() ){430 if( pVar->GetType().IsPointer() ){ 427 431 if( !pVar->IsArray() ){ 428 432 lstrcpy(lpPtrOffset,array); … … 438 442 } 439 443 440 pRelativeVar->offset=-pVar-> offset;444 pRelativeVar->offset=-pVar->GetOffsetAddress(); 441 445 pRelativeVar->bOffsetOffset=0; 442 446 if( pVar->IsRef() ){ … … 445 449 } 446 450 else pRelativeVar->dwKind=VAR_LOCAL; 447 resultType = *pVar;448 pSub Scripts=pVar->GetSubScriptsPtr();451 resultType = pVar->GetType(); 452 pSubscripts = &pVar->GetSubscripts(); 449 453 bConst = pVar->IsConst(); 450 454 … … 454 458 455 459 456 if( Smoothie::Temp::pCompilingClass){460 if(compiler.pCompilingClass){ 457 461 ////////////////////// 458 462 // クラスメンバの参照 … … 465 469 pRelativeVar->dwKind=VAR_DIRECTMEM; 466 470 467 resultType.SetType( DEF_OBJECT, Smoothie::Temp::pCompilingClass );471 resultType.SetType( DEF_OBJECT, compiler.pCompilingClass ); 468 472 return true; 469 473 } … … 478 482 479 483 bool isFound = false; 480 BOOST_FOREACH( CMember *pMember, Smoothie::Temp::pCompilingClass->GetDynamicMembers() ){484 BOOST_FOREACH( CMember *pMember, compiler.pCompilingClass->GetDynamicMembers() ){ 481 485 if( pMember->GetName() == VarName ){ 482 486 isFound = true; … … 492 496 if( isWriteAccess && 493 497 pMethod->IsConst() && 494 Smoothie::Temp::pCompilingClass->IsCompilingConstructor() == false &&495 Smoothie::Temp::pCompilingClass->IsCompilingDestructor() == false498 compiler.pCompilingClass->IsCompilingConstructor() == false && 499 compiler.pCompilingClass->IsCompilingDestructor() == false 496 500 ){ 497 501 SetError(131, NULL, cp ); … … 505 509 isErrorEnabled, 506 510 isWriteAccess, 507 * Smoothie::Temp::pCompilingClass,511 *compiler.pCompilingClass, 508 512 variable, 509 513 pRelativeVar, … … 526 530 GetNowStaticVarFullName(VarName,temporary); 527 531 528 pVar = globalVars.Find( temporary);532 pVar = compiler.GetMeta().GetGlobalVars().Find( Symbol( temporary ) ); 529 533 if( pVar ){ 530 534 goto GlobalOk; … … 545 549 char tempArray[VN_SIZE]; 546 550 { 547 CClass::RefTyperefType;551 ReferenceKind refType; 548 552 GetVarFormatString(temporary,tempArray,lpPtrOffset,tempMember, refType ); 549 553 } … … 557 561 char temp2[VN_SIZE]; 558 562 sprintf(temp2,"%s.%s",VarName,temporary); 559 pVar = globalVars.Find( temp2);563 pVar = compiler.GetMeta().GetGlobalVars().Find( Symbol( temp2 ) ); 560 564 if( pVar ){ 561 565 lstrcpy(member,tempMember); … … 565 569 } 566 570 567 if( Smoothie::Temp::pCompilingClass){571 if(compiler.pCompilingClass){ 568 572 //自身のクラスから静的メンバを参照する場合 569 573 char temp2[VN_SIZE]; 570 sprintf(temp2,"%s.%s", Smoothie::Temp::pCompilingClass->GetName().c_str(),VarName);571 pVar = globalVars.Find( temp2);574 sprintf(temp2,"%s.%s",compiler.pCompilingClass->GetName().c_str(),VarName); 575 pVar = compiler.GetMeta().GetGlobalVars().Find( Symbol( temp2 ) ); 572 576 if( pVar ){ 573 577 goto GlobalOk; … … 579 583 ///////////////////// 580 584 581 pVar = globalVars.BackSearch( VarName);585 pVar = compiler.GetMeta().GetGlobalVars().BackSearch( Symbol( VarName ) ); 582 586 if( pVar ){ 583 587 goto GlobalOk; … … 592 596 GlobalOk: 593 597 //ポインタ変数の場合 594 if( pVar-> IsPointer() ){598 if( pVar->GetType().IsPointer() ){ 595 599 if( !pVar->IsArray() ){ 596 600 lstrcpy(lpPtrOffset,array); … … 606 610 } 607 611 608 pRelativeVar->offset=pVar-> offset;612 pRelativeVar->offset=pVar->GetOffsetAddress(); 609 613 pRelativeVar->bOffsetOffset=0; 610 614 if( pVar->IsRef() ){ … … 613 617 } 614 618 else pRelativeVar->dwKind=VAR_GLOBAL; 615 resultType = *pVar;616 pSub Scripts=pVar->GetSubScriptsPtr();619 resultType = pVar->GetType(); 620 pSubscripts=&pVar->GetSubscripts(); 617 621 bConst = pVar->IsConst(); 618 622 } … … 634 638 } 635 639 636 if( array[0]==0&&pSubScripts[0]!=-1){640 if( array[0] == 0 && pSubscripts->size() > 0 ){ 637 641 //配列の先頭ポインタを示す場合 638 642 resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR ); 639 if(pss) memcpy(pss,pSubScripts,MAX_ARRAYDIM); 643 644 if( pResultSubscripts ) 645 { 646 (*pResultSubscripts) = *pSubscripts; 647 } 640 648 return true; 641 649 } … … 649 657 } 650 658 if(array[0]){ 651 if(!GetArrayOffset( pSubScripts,array,resultType)){659 if(!GetArrayOffset(*pSubscripts,array,resultType)){ 652 660 SetError(14,variable,cp); 653 661 pRelativeVar->dwKind=NON_VAR; … … 658 666 if( resultType.IsObject() || resultType.IsStruct() ){ 659 667 //実態オブジェクトのメンバを参照(obj.member) 660 if( refType != CClass::Dot ){668 if( refType != RefDot ){ 661 669 SetError(104,VarName,cp); 662 670 pRelativeVar->dwKind=NON_VAR; … … 673 681 if(lpPtrOffset[0]){ 674 682 //pObj[n].member 675 if( refType != CClass::Dot ){683 if( refType != RefDot ){ 676 684 SetError(104,VarName,cp); 677 685 pRelativeVar->dwKind=NON_VAR; … … 683 691 else{ 684 692 //pObj->member 685 if( refType != CClass::Pointer ){693 if( refType != RefPointer ){ 686 694 SetError(104,VarName,cp); 687 695 pRelativeVar->dwKind=NON_VAR; … … 700 708 if(lpPtrOffset[0]){ 701 709 //ppObj[n]->member 702 if( refType != CClass::Pointer ){710 if( refType != RefPointer ){ 703 711 SetError(104,VarName,cp); 704 712 pRelativeVar->dwKind=NON_VAR; … … 744 752 } 745 753 746 bool SetInitGlobalData(int offset,const Type &type,const int *SubScripts,const char *lpszInitBuf){754 bool SetInitGlobalData(int offset,const Type &type,const Subscripts &subscripts,const char *lpszInitBuf){ 747 755 extern BYTE *initGlobalBuf; 748 int i ,i2,i3;756 int i2,i3; 749 757 char temporary[VN_SIZE]; 750 758 char InitBuf[VN_SIZE]; … … 757 765 int typeSize = type.GetSize(); 758 766 759 if(SubScripts[0]!=-1){ 760 typeSize*=JumpSubScripts(SubScripts+1); 761 i=0; 762 i2=0; 763 while(1){ 764 if(SubScripts[0]<i2){ 765 SetError(41,0,cp); 766 return 0; 767 } 768 i=GetOneParameter(InitBuf,i,temporary); 769 if(!SetInitGlobalData( 770 offset+i2*typeSize, 771 type, 772 SubScripts+1, 773 temporary)) return false; 774 i2++; 775 if(InitBuf[i]=='\0') break; 767 if( subscripts.size() > 0 ){ 768 Subscripts nestSubscripts; 769 for( int i=1; i<(int)subscripts.size(); i++ ) 770 { 771 nestSubscripts.push_back( subscripts[i] ); 772 } 773 774 typeSize*=JumpSubScripts( nestSubscripts ); 775 { 776 int i=0; 777 i2=0; 778 while(1){ 779 if( subscripts[0] < i2 ){ 780 SetError(41,0,cp); 781 return 0; 782 } 783 i=GetOneParameter(InitBuf,i,temporary); 784 if(!SetInitGlobalData( 785 offset+i2*typeSize, 786 type, 787 nestSubscripts, 788 temporary)) return false; 789 i2++; 790 if(InitBuf[i]=='\0') break; 791 } 776 792 } 777 793 return true; … … 794 810 if(!SetInitGlobalData(offset+i3, 795 811 pMember->GetType(), 796 pMember-> SubScripts,812 pMember->GetSubscripts(), 797 813 temporary)) return false; 798 814 } … … 815 831 } 816 832 817 if( SubScripts[0]!=-1){833 if( subscripts.size() > 0 ){ 818 834 SetError(41,0,cp); 819 835 return false; … … 883 899 return true; 884 900 } 885 bool InitLocalVar(int offset,const Type &type,const int *SubScripts,const char *lpszInitBuf){886 int i ,i2,i3;901 bool InitLocalVar(int offset,const Type &type,const Subscripts &subscripts,const char *lpszInitBuf){ 902 int i2,i3; 887 903 char temporary[VN_SIZE]; 888 904 char InitBuf[VN_SIZE]; … … 895 911 int typeSize = type.GetSize(); 896 912 897 if(SubScripts[0]!=-1){ 898 typeSize*=JumpSubScripts(SubScripts+1); 899 i=0; 900 i2=0; 901 while(1){ 902 if(SubScripts[0]<i2){ 903 SetError(41,0,cp); 904 return false; 905 } 906 i=GetOneParameter(InitBuf,i,temporary); 907 if(!InitLocalVar( 908 offset+i2*typeSize, 909 type, 910 SubScripts+1, 911 temporary)) return false; 912 i2++; 913 if(InitBuf[i]=='\0') break; 913 if( subscripts.size() > 0 ){ 914 Subscripts nestSubscripts; 915 for( int i=1; i<(int)subscripts.size(); i++ ) 916 { 917 nestSubscripts.push_back( subscripts[i] ); 918 } 919 920 typeSize*=JumpSubScripts( nestSubscripts ); 921 { 922 int i=0; 923 i2=0; 924 while(1){ 925 if( subscripts[0] < i2 ){ 926 SetError(41,0,cp); 927 return 0; 928 } 929 i=GetOneParameter(InitBuf,i,temporary); 930 if(!InitLocalVar( 931 offset+i2*typeSize, 932 type, 933 nestSubscripts, 934 temporary)) return false; 935 i2++; 936 if(InitBuf[i]=='\0') break; 937 } 914 938 } 915 939 return true; … … 932 956 if(!InitLocalVar(offset+i3, 933 957 pMember->GetType(), 934 pMember-> SubScripts,958 pMember->GetSubscripts(), 935 959 temporary)) return false; 936 960 … … 949 973 /////////////////////////////////////// 950 974 951 if( SubScripts[0]!=-1){975 if( subscripts.size() > 0 ){ 952 976 SetError(41,0,cp); 953 977 return false; … … 1061 1085 } 1062 1086 1063 void dim( char *VarName, int *SubScripts,Type &type,const char *InitBuf,const char *ConstractParameter,DWORD dwFlags){1087 void dim( char *VarName, const Subscripts &subscripts, Type &type,const char *InitBuf,const char *ConstractParameter,DWORD dwFlags){ 1064 1088 if( UserProc::IsGlobalAreaCompiling() ){ 1065 1089 ///////////////////////// … … 1067 1091 ///////////////////////// 1068 1092 1069 //OpcodeOthers( ( (string)"OutputDebugString(Ex\"" + VarName + "\r\n\")" ).c_str() ); 1070 AddGlobalVariable(VarName,SubScripts,type,InitBuf,ConstractParameter,dwFlags); 1093 AddGlobalVariable(VarName,subscripts,type,InitBuf,ConstractParameter,dwFlags); 1071 1094 } 1072 1095 else{ … … 1075 1098 ///////////////// 1076 1099 1077 if( UserProc::CompilingUserProc(). localVars.DuplicateCheck( VarName ) ){1100 if( UserProc::CompilingUserProc().GetLocalVars().DuplicateCheck( VarName ) ){ 1078 1101 //2重定義のエラー 1079 1102 SetError(15,VarName,cp); … … 1083 1106 bool isConst = ( dwFlags & DIMFLAG_CONST ) ? true:false; 1084 1107 1085 Variable *pVar = new Variable Impl( VarName, type, isConst);1086 1087 if( SubScripts[0] != -1){1108 Variable *pVar = new Variable( VarName, type, isConst, false, ConstractParameter ); 1109 1110 if( subscripts.size() > 0 ){ 1088 1111 //配列あり 1089 pVar->SetArray( SubScripts ); 1090 } 1091 1092 //コンストラクタ用パラメータ 1093 pVar->paramStrForConstructor = ConstractParameter; 1112 pVar->SetArray( subscripts ); 1113 } 1094 1114 1095 1115 //レキシカルスコープ 1096 pVar->S copeLevel=GetLexicalScopes().GetNowLevel();1097 pVar->S copeStartAddress=GetLexicalScopes().GetStartAddress();1116 pVar->SetScopeLevel( GetLexicalScopes().GetNowLevel() ); 1117 pVar->SetScopeStartAddress( GetLexicalScopes().GetStartAddress() ); 1098 1118 pVar->bLiving=TRUE; 1099 1119 … … 1102 1122 1103 1123 // 変数を追加 1104 UserProc::CompilingUserProc(). localVars.push_back( pVar );1124 UserProc::CompilingUserProc().GetLocalVars().push_back( pVar ); 1105 1125 1106 1126 //アラインメントを考慮 1107 if( pVar-> IsStruct() ){1108 int alignment = pVar->Get Class().iAlign;1127 if( pVar->GetType().IsStruct() ){ 1128 int alignment = pVar->GetType().GetClass().iAlign; 1109 1129 1110 1130 if( alignment ){ … … 1126 1146 1127 1147 AllLocalVarSize += pVar->GetMemorySize(); 1128 pVar-> offset = AllLocalVarSize;1148 pVar->SetOffsetAddress( AllLocalVarSize ); 1129 1149 1130 1150 //レキシカルスコープ 1131 pVar->S copeLevel=GetLexicalScopes().GetNowLevel();1132 pVar->S copeStartAddress=GetLexicalScopes().GetStartAddress();1151 pVar->SetScopeLevel( GetLexicalScopes().GetNowLevel() ); 1152 pVar->SetScopeStartAddress( GetLexicalScopes().GetStartAddress() ); 1133 1153 pVar->bLiving=TRUE; 1134 1154 … … 1140 1160 1141 1161 int result = 0; 1142 if( !pVar-> IsObject() ){1143 result = InitLocalVar(-pVar-> offset,1144 *pVar,1145 pVar->GetSub ScriptsPtr(),1162 if( !pVar->GetType().IsObject() ){ 1163 result = InitLocalVar(-pVar->GetOffsetAddress(), 1164 pVar->GetType(), 1165 pVar->GetSubscripts(), 1146 1166 InitBuf); 1147 1167 } … … 1171 1191 1172 1192 //add rcx, offset 1173 op_add_RV( REG_RCX, -pVar-> offset);1193 op_add_RV( REG_RCX, -pVar->GetOffsetAddress() ); 1174 1194 obp-=sizeof(long); 1175 1195 AddLocalVarAddrSchedule(); … … 1186 1206 if( type.IsObject() &&(dwFlags&DIMFLAG_NONCALL_CONSTRACTOR)==0&&InitBuf[0]=='\0'){ 1187 1207 char objectSize[255]; 1188 if( SubScripts[0] == -1){1208 if( subscripts.size() == 0 ){ 1189 1209 objectSize[0] = 0; 1190 1210 } 1191 1211 else{ 1192 if( SubScripts[1] != -1 ){1212 if( subscripts.size() > 1 ){ 1193 1213 SetError(300,NULL,cp); 1194 1214 } 1195 sprintf( objectSize, "%d", SubScripts[0] );1215 sprintf( objectSize, "%d", subscripts[0] ); 1196 1216 } 1197 1217 Operator_New( type.GetClass(), objectSize, ConstractParameter, type ); … … 1304 1324 1305 1325 bool Compile_AddGlobalRootsForGc(){ 1306 UserProc *pUserProc_AddGlobalRootPtr = GetClassMethod( "_System_CGarbageCollection", "AddGlobalRootPtr" );1326 const UserProc *pUserProc_AddGlobalRootPtr = GetClassMethod( "_System_CGarbageCollection", "AddGlobalRootPtr" ); 1307 1327 if( !pUserProc_AddGlobalRootPtr ){ 1308 1328 SetError(3, "_System_CGarbageCollection.AddGlobalRootPtr", -1 ); … … 1310 1330 } 1311 1331 1312 BOOST_FOREACH( const Variable *pVar, globalVars){1313 if( pVar-> IsObject() || pVar->IsPointer() || pVar->IsStruct() ){1332 BOOST_FOREACH( const Variable *pVar, compiler.GetMeta().GetGlobalVars() ){ 1333 if( pVar->GetType().IsObject() || pVar->GetType().IsPointer() || pVar->GetType().IsStruct() ){ 1314 1334 // オブジェクトまたはポインタだったとき 1315 1335 // ※構造体も含む(暫定対応) … … 1321 1341 // ルートポインタを引き渡す 1322 1342 //mov rdx,offset 1323 op_mov_RV(sizeof(_int64), REG_RDX,(int)pVar-> offset);1343 op_mov_RV(sizeof(_int64), REG_RDX,(int)pVar->GetOffsetAddress()); 1324 1344 obp-=sizeof(long); 1325 1345 pobj_GlobalVarSchedule->add(); -
trunk/abdev/BasicCompiler64/MakePeHdr.cpp
r202 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/common/Environment.h> 2 4 … … 4 6 5 7 #include <LexicalScopingImpl.h> 6 #include <Class Impl.h>8 #include <Class.h> 7 9 #include <Compiler.h> 8 10 11 #include <../Enum.h> 12 9 13 #include "../BasicCompiler_Common/common.h" 14 #include "../BasicCompiler_Common/DebugSection.h" 10 15 #include "Opcode.h" 11 16 … … 16 21 17 22 // グローバル関数、静的メソッド 18 UserProc23 const UserProc 19 24 *pSub_System_StartupProgram, 20 25 *pSub_DebugSys_StartProc, … … 36 41 37 42 // 動的メソッド 38 UserProc43 const UserProc 39 44 *pUserProc_System_CGarbageCollection_RegisterGlobalRoots; 40 45 … … 160 165 161 166 //クラス名を取得(詳細情報はGetAllClassInfoで取得) 162 // GetSubInfo関数の中で参照されるオブジェクト名を事前に取得する。167 // CollectUserProcs関数の中で参照されるオブジェクト名を事前に取得する。 163 168 // ※オブジェクトの内容までは取得しない 164 169 compiler.GetMeta().GetClasses().CollectClassesForNameOnly( Smoothie::Lexical::source ); … … 171 176 172 177 //サブルーチン(ユーザー定義、DLL関数)の識別子、アドレスを取得 173 Smoothie::Temp::pCompilingClass = NULL;174 GetSubInfo();175 176 // クラス情報を取得(※注 - GetSubInfoの後に呼び出す)178 compiler.pCompilingClass = NULL; 179 UserProcs::CollectUserProcs( Smoothie::Lexical::source, compiler.GetMeta().GetUserProcs() ); 180 181 // クラス情報を取得(※注 - CollectUserProcsの後に呼び出す) 177 182 compiler.GetMeta().GetClasses().GetAllClassInfo(); 178 183 179 compiler.GetMeta().AutoWrite( Jenga::Common::Environment::GetAppDir() + "\\meta_test.xml" ); 184 // サブルーチン(ユーザー定義、DLL関数)のイテレータの準備 185 compiler.GetMeta().GetUserProcs().Iterator_Init(); 186 187 /* 188 if( !compiler.GetMeta().Write( Jenga::Common::Environment::GetAppDir() + "\\meta_test.xml" ) ) 189 { 190 MessageBox(0,"XML書き込みに失敗","test",0); 191 } 192 MetaImpl *pTempMeta = new MetaImpl(); 193 if( !pTempMeta->Read( Jenga::Common::Environment::GetAppDir() + "\\meta_test.xml" ) ) 194 { 195 MessageBox(0,"XML読み込みに失敗","test",0); 196 } 197 compiler.GetMeta() = (*pTempMeta); 198 */ 180 199 181 200 //コードと行番号の関係 … … 347 366 extern CStackFrame *pobj_sf; 348 367 pobj_sf=new CStackFrame(); 368 369 trace_for_sourcecodestep( "★★★ グローバル領域のコンパイルを開始" ); 349 370 350 371 … … 399 420 400 421 //call _System_Call_Destructor_of_GlobalObject 401 extern UserProc *pSub_System_Call_Destructor_of_GlobalObject;422 extern const UserProc *pSub_System_Call_Destructor_of_GlobalObject; 402 423 op_call(pSub_System_Call_Destructor_of_GlobalObject); 403 424 … … 557 578 ExportNamesLength=lstrlen(lpExportNames)+1; 558 579 559 extern GlobalProc **ppSubHash; 560 GlobalProc *pUserProc,*psi2; 580 UserProc *pUserProc,*psi2; 561 581 while(1){ 562 582 //辞書順にサーチ 563 583 temporary[0]=0; 564 for(i=0,psi2=0;i<MAX_HASH;i++){ 565 pUserProc=ppSubHash[i]; 566 while(pUserProc){ 567 if(pUserProc->IsExport()){ 568 if(temporary[0]=='\0'){ 584 compiler.GetMeta().GetUserProcs().Iterator_Reset(); 585 while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() ) 586 { 587 pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext(); 588 if(pUserProc->IsExport()){ 589 if(temporary[0]=='\0'){ 590 lstrcpy(temporary,pUserProc->GetName().c_str()); 591 psi2=pUserProc; 592 } 593 else{ 594 i3=lstrlen(temporary); 595 i4=(int)pUserProc->GetName().size(); 596 if(i3<i4) i3=i4; 597 if(memcmp(temporary,pUserProc->GetName().c_str(),i3)>0){ 569 598 lstrcpy(temporary,pUserProc->GetName().c_str()); 570 599 psi2=pUserProc; 571 600 } 572 else{573 i3=lstrlen(temporary);574 i4=(int)pUserProc->GetName().size();575 if(i3<i4) i3=i4;576 if(memcmp(temporary,pUserProc->GetName().c_str(),i3)>0){577 lstrcpy(temporary,pUserProc->GetName().c_str());578 psi2=pUserProc;579 }580 }581 601 } 582 pUserProc=pUserProc->pNextData;583 602 } 584 603 } … … 589 608 590 609 if( pUserProc->GetName() == "DllMain" ){ 591 DllMain_EntryPoint=pUserProc-> beginOpAddress;610 DllMain_EntryPoint=pUserProc->GetBeginOpAddress(); 592 611 } 593 612 594 613 lpdwExportAddressTable=(DWORD *)HeapReAlloc(hHeap,0,lpdwExportAddressTable,(ExportNum+1)*sizeof(DWORD)); 595 lpdwExportAddressTable[ExportNum]=pUserProc-> beginOpAddress;614 lpdwExportAddressTable[ExportNum]=pUserProc->GetBeginOpAddress(); 596 615 597 616 lpdwExportNamePointerTable=(DWORD *)HeapReAlloc(hHeap,0,lpdwExportNamePointerTable,(ExportNum+1)*sizeof(DWORD)); … … 800 819 //(デバッグ情報で利用される) 801 820 extern int AllInitGlobalVarSize; 802 BOOST_FOREACH( Variable *pVar, globalVars ){ 803 if(pVar->offset&0x80000000){ 804 pVar->offset=(pVar->offset&0x7FFFFFFF)+AllInitGlobalVarSize; 821 BOOST_FOREACH( Variable *pVar, compiler.GetMeta().GetGlobalVars() ){ 822 if(pVar->GetOffsetAddress()&0x80000000){ 823 pVar->SetOffsetAddress( 824 (pVar->GetOffsetAddress()&0x7FFFFFFF)+AllInitGlobalVarSize 825 ); 805 826 } 806 827 } … … 1088 1109 // ※x86はRVAからのオフセット。x64はRPI(実行中アドレス)からのオフセット 1089 1110 for(i=0;i<pobj_ImportAddrSchedule->num;i++){ 1090 DllProc *pDllProc; 1091 pDllProc=pobj_ImportAddrSchedule->ppdi[i]; 1111 const DllProc *pDllProc = pobj_ImportAddrSchedule->ppdi[i]; 1092 1112 *((long *)(OpBuffer+pobj_ImportAddrSchedule->pObpValues[i]))= 1093 1113 MemPos_ImportSection+ … … 1101 1121 // プロシージャポインタスケジュール 1102 1122 for(i=0;i<pobj_SubAddrSchedule->num;i++){ 1103 if(pobj_SubAddrSchedule->ppsi[i]-> beginOpAddress==01104 &&pobj_SubAddrSchedule->ppsi[i]-> endOpAddress==0){1123 if(pobj_SubAddrSchedule->ppsi[i]->GetBeginOpAddress()==0 1124 &&pobj_SubAddrSchedule->ppsi[i]->GetEndOpAddress()==0){ 1105 1125 SetError(300,NULL,-1); 1106 1126 } … … 1108 1128 if(pobj_SubAddrSchedule->pbCall[i]){ 1109 1129 *((long *)(OpBuffer+pobj_SubAddrSchedule->pObpValues[i]))= 1110 pobj_SubAddrSchedule->ppsi[i]-> beginOpAddress-(pobj_SubAddrSchedule->pObpValues[i]+sizeof(long));1130 pobj_SubAddrSchedule->ppsi[i]->GetBeginOpAddress()-(pobj_SubAddrSchedule->pObpValues[i]+sizeof(long)); 1111 1131 } 1112 1132 else{ 1113 1133 *((long *)(OpBuffer+pobj_SubAddrSchedule->pObpValues[i]))= 1114 pobj_SubAddrSchedule->ppsi[i]-> beginOpAddress+ImageBase+MemPos_CodeSection;1134 pobj_SubAddrSchedule->ppsi[i]->GetBeginOpAddress()+ImageBase+MemPos_CodeSection; 1115 1135 } 1116 1136 } -
trunk/abdev/BasicCompiler64/NumOpe.cpp
r198 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 #include <jenga/include/smoothie/LexicalAnalysis.h> … … 164 166 // 動的メソッドを検索 165 167 /////////////////////////////////////////////////////////////////// 166 vector< UserProc *> userProcs;168 vector<const UserProc *> userProcs; 167 169 168 170 char methodName[VN_SIZE], lpPtrOffset[VN_SIZE], parameter[VN_SIZE], dummy[1]; 169 CClass::RefTyperefType;171 ReferenceKind refType; 170 172 lstrcpy( methodName, member ); 171 173 GetVarFormatString(methodName,parameter,lpPtrOffset,dummy,refType); 172 174 173 175 objClass.GetMethods().Enum( methodName, userProcs ); 174 UserProc *pUserProc;175 176 if(userProcs.size()){ 176 177 //オーバーロードを解決 177 pUserProc=OverloadSolutionWithStrParam(termFull,userProcs,parameter,termLeft);178 const UserProc *pUserProc = OverloadSolutionWithStrParam(termFull,userProcs,parameter,termLeft); 178 179 179 180 if( pUserProc ){ … … 245 246 // パース 246 247 char member[VN_SIZE]; 247 CClass::RefTyperefType;248 if( CClass::SplitName( termFull, termLeft, member, refType ) ){248 ReferenceKind refType; 249 if( SplitMemberName( termFull, termLeft, member, refType ) ){ 249 250 /////////////////////////////////////////////////////////////////// 250 251 // オブジェクトとメンバに分解できるとき … … 309 310 if(lstrcmpi(termFull,"This")==0 && isProcedureCallOnly == false ){ 310 311 //Thisオブジェクト 311 resultType.SetType( DEF_OBJECT, Smoothie::Temp::pCompilingClass );312 resultType.SetType( DEF_OBJECT, compiler.pCompilingClass ); 312 313 313 314 SetThisPtrToReg( UseReg ); … … 385 386 return true; 386 387 } 387 else if(GetConstCalcBuffer(procName,parameter,temporary)){ 388 ///////////////////////// 389 // マクロ関数 390 ///////////////////////// 391 392 //閉じカッコ")"に続く文字がNULLでないときはエラーにする 393 if(termFull[i2+1+i4+1]!='\0') SetError(42,NULL,cp); 394 395 //マクロ関数の場合 396 NumOpe(&UseReg,temporary,Type(),resultType); 397 398 if(!IS_LITERAL(resultType.GetIndex())){ 399 //リテラル値ではなかったとき 400 isLiteral = false; 401 } 402 403 return true; 388 389 ConstMacro *pConstMacro = compiler.GetMeta().GetGlobalConstMacros().Find( procName ); 390 if( pConstMacro ) 391 { 392 if( pConstMacro->GetCalcBuffer( parameter, temporary ) ) 393 { 394 ///////////////////////// 395 // マクロ関数 396 ///////////////////////// 397 398 //閉じカッコ")"に続く文字がNULLでないときはエラーにする 399 if(termFull[i2+1+i4+1]!='\0') SetError(42,NULL,cp); 400 401 //マクロ関数の場合 402 NumOpe(&UseReg, temporary,Type(),resultType); 403 404 if(!IS_LITERAL(resultType.GetIndex())){ 405 //リテラル値ではなかったとき 406 isLiteral = false; 407 } 408 409 return true; 410 } 404 411 } 405 412 } … … 905 912 ////////////// 906 913 907 i3 = CDBConst::obj.GetBasicType(term);914 i3 = compiler.GetMeta().GetGlobalConsts().GetBasicType(term); 908 915 if(i3){ 909 if( CDBConst::obj.IsStringPtr( term ) ){916 if( compiler.GetMeta().GetGlobalConsts().IsStringPtr( term ) ){ 910 917 //リテラル文字列 911 918 912 double dbl = CDBConst::obj.GetDoubleData(term);919 double dbl = compiler.GetMeta().GetGlobalConsts().GetDoubleData(term); 913 920 memcpy(&i64data,&dbl,sizeof(double)); 914 921 … … 924 931 if(IsRealNumberType(i3)){ 925 932 //実数 926 double dbl = CDBConst::obj.GetDoubleData(term);933 double dbl = compiler.GetMeta().GetGlobalConsts().GetDoubleData(term); 927 934 memcpy(&i64data,&dbl,sizeof(double)); 928 935 goto Literal; … … 930 937 else if(IsWholeNumberType(i3)){ 931 938 //整数 932 i64data = CDBConst::obj.GetWholeData(term);939 i64data = compiler.GetMeta().GetGlobalConsts().GetWholeData(term); 933 940 goto Literal; 934 941 } -
trunk/abdev/BasicCompiler64/NumOpe_Arithmetic.cpp
r198 r206 1 #include "stdafx.h" 2 1 3 #include <Compiler.h> 2 4 … … 561 563 562 564 //call pow 563 extern UserProc *pSub_pow;565 extern const UserProc *pSub_pow; 564 566 op_call(pSub_pow); 565 567 -
trunk/abdev/BasicCompiler64/NumOpe_Logical.cpp
r64 r206 1 #include "stdafx.h" 2 1 3 #include "../BasicCompiler_Common/common.h" 2 4 #include "Opcode.h" -
trunk/abdev/BasicCompiler64/NumOpe_Relation.cpp
r36 r206 1 #include "stdafx.h" 2 1 3 #include "../BasicCompiler_Common/common.h" 2 4 #include "Opcode.h" -
trunk/abdev/BasicCompiler64/NumOpe_TypeOperation.cpp
r198 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 -
trunk/abdev/BasicCompiler64/Opcode.h
r142 r206 1 //Opcode.h 1 #pragma once 2 3 #include <Type.h> 4 #include <Procedure.h> 2 5 3 6 … … 323 326 bool _member_offset(bool isErrorEnabled, bool isWriteAccess, const CClass &objClass, const char *member, RELATIVE_VAR *pRelativeVar, Type &resultType, BOOL bPrivateAccess); 324 327 void SetThisPtrToReg(int reg); 325 bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, int *pss = NULL);326 bool SetInitGlobalData(int offset,const Type &type,const int *SubScripts,const char *InitBuf);328 bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts = NULL ); 329 bool SetInitGlobalData(int offset,const Type &type,const Subscripts &subscripts,const char *InitBuf); 327 330 #define DIMFLAG_INITDEBUGVAR 0x01 328 331 #define DIMFLAG_NONCALL_CONSTRACTOR 0x02 329 332 #define DIMFLAG_STATIC 0x04 330 333 #define DIMFLAG_CONST 0x08 331 void dim( char *VarName, int *SubScripts,Type &type, const char *InitBuf,const char *ConstractParameter,DWORD dwFlags);334 void dim( char *VarName, const Subscripts &subscripts, Type &type, const char *InitBuf,const char *ConstractParameter,DWORD dwFlags); 332 335 void SetVarPtrToReg(int reg,RELATIVE_VAR *pRelativeVar); 333 336 bool Compile_AddGlobalRootsForGc(); … … 356 359 357 360 public: 358 UserProc *_OverloadSolution( const char *name, std::vector<UserProc *> &subs, bool isEnabledReturnType = false );359 UserProc *OverloadSolution( const char *name, std::vector<UserProc *> &subs, bool isEnabledReturnType = false );361 const UserProc *_OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType = false ); 362 const UserProc *OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType = false ); 360 363 361 364 void ApplyDefaultParameters( const Parameters ¶ms ); … … 389 392 #define PROCFLAG_NEW 1 390 393 bool Opcode_CallProcPtr(const char *variable, const char *lpszParms,ProcPointer *pProcPointer); 391 bool Opcode_CallProc(const char *Parameter, UserProc *pUserProc,DWORD dwFlags,const char *ObjectName,int RefType);394 bool Opcode_CallProc(const char *Parameter,const UserProc *pUserProc,DWORD dwFlags,const char *ObjectName,int RefType); 392 395 bool Opcode_CallDllProc( const char *lpszParms,DllProc *pDllProc); 393 396 … … 401 404 //OperatorProc.cpp 402 405 void FreeTempObject(int reg,const CClass *pobj_c); 403 int CallOperatorProc( intidCalc, const Type &baseType, int *type_stack,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp);406 int CallOperatorProc(BYTE idCalc, const Type &baseType, int *type_stack,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp); 404 407 void CallCastOperatorProc(int reg,Type &calcType,BOOL bCalcUseHeap,const Type &toType); 405 408 void CallIndexerGetterProc(int reg,const CClass *pobj_Class,char *ObjectName,char *Parameter,Type &resultType); … … 512 515 void op_fld_ptr_esp(int type); 513 516 void op_zero_reg(int reg); 514 void op_call( UserProc *pUserProc );515 void op_call( DllProc *pDllProc );517 void op_call( const UserProc *pUserProc ); 518 void op_call( const DllProc *pDllProc ); 516 519 void op_ret(); -
trunk/abdev/BasicCompiler64/OperatorProc.cpp
r135 r206 1 #include "stdafx.h" 2 3 #include <jenga/include/smoothie/LexicalAnalysis.h> 4 1 5 #include "../BasicCompiler_Common/common.h" 2 6 #include "Opcode.h" … … 16 20 17 21 //call DestructorProcAddr 18 op_call( method->pUserProc);22 op_call( &method->GetUserProc() ); 19 23 } 20 24 … … 23 27 24 28 //call free 25 extern UserProc *pSub_free;29 extern const UserProc *pSub_free; 26 30 op_call(pSub_free); 27 31 } 28 32 29 int CallOperatorProc( intidCalc, const Type &baseType, int *type_stack,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp){33 int CallOperatorProc(BYTE idCalc, const Type &baseType, int *type_stack,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp){ 30 34 //オーバーロードされたオペレータ関数を呼び出す 31 35 CClass *pobj_c; 32 36 pobj_c=(CClass *)index_stack[sp-2]; 33 37 34 std::vector< UserProc *> subs;38 std::vector<const UserProc *> subs; 35 39 pobj_c->GetMethods().Enum( idCalc, subs ); 36 40 if( subs.size() == 0 ){ … … 58 62 if(idCalc==CALC_EQUAL) lstrcpy(temporary,"=="); 59 63 else GetCalcName(idCalc,temporary); 60 UserProc *pUserProc = OverloadSolution( temporary, subs, params, baseType );64 const UserProc *pUserProc = OverloadSolution( temporary, subs, params, baseType ); 61 65 62 66 if(!pUserProc){ … … 118 122 119 123 //call calloc 120 extern UserProc *pSub_calloc;124 extern const UserProc *pSub_calloc; 121 125 op_call(pSub_calloc); 122 126 … … 319 323 void CallIndexerGetterProc(int reg,const CClass *pobj_Class,char *ObjectName,char *Parameter,Type &resultType ){ 320 324 321 std::vector< UserProc *> subs;325 std::vector<const UserProc *> subs; 322 326 pobj_Class->GetMethods().Enum( CALC_ARRAY_GET, subs ); 323 327 if( subs.size() == 0 ){ -
trunk/abdev/BasicCompiler64/Register.cpp
r131 r206 1 #include "stdafx.h" 2 1 3 #include "../BasicCompiler_Common/common.h" 2 4 #include "Opcode.h" -
trunk/abdev/BasicCompiler64/amd64_main.cpp
r142 r206 1 #include "stdafx.h" 2 1 3 #include "../BasicCompiler_Common/common.h" 2 4 #include "Opcode.h" … … 1791 1793 ///////////////////////////// 1792 1794 1793 void op_call( UserProc *pUserProc ){1795 void op_call( const UserProc *pUserProc ){ 1794 1796 OpBuffer[obp++] = (char)0xE8; 1795 1797 pobj_SubAddrSchedule->add( pUserProc, 1 ); … … 1797 1799 obp += sizeof(long); 1798 1800 } 1799 void op_call( DllProc *pDllProc ){1801 void op_call( const DllProc *pDllProc ){ 1800 1802 OpBuffer[obp++] = (char)0xFF; 1801 1803 OpBuffer[obp++] = (char)0x15; -
trunk/abdev/BasicCompiler64/increment.cpp
r129 r206 1 #include "stdafx.h" 2 1 3 #include "../BasicCompiler_Common/common.h" 2 4 #include "Opcode.h" -
trunk/abdev/BasicCompiler64/stack_frame.cpp
r66 r206 1 #include "stdafx.h" 2 1 3 #include "../BasicCompiler_Common/common.h" 2 4 #include "Opcode.h" -
trunk/abdev/BasicCompiler_Common/BasicCompiler.cpp
r188 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 … … 548 550 } 549 551 552 void _Test() 553 { 554 Jenga::Common::LoggerSetting loggerSetting; 555 bool result = loggerSetting.Read( Jenga::Common::Environment::GetAppDir() + "\\logger.setting.xml" ); 556 557 MessageBeep(0); 558 } 559 550 560 int PASCAL WinMain(HINSTANCE hThisInst,HINSTANCE hPrevInst,LPSTR lpCmdLine,int nShowCmd){ 551 561 int i,i2; 552 562 char temporary[1024],temp2[MAX_PATH]; 563 564 //_Test(); 553 565 554 566 //MessageBox(0,"starting compiler/debugger","ActiveBasic",MB_OK); -
trunk/abdev/BasicCompiler_Common/BasicCompiler.h
r182 r206 23 23 DWORD ImageBase; 24 24 INCLUDEFILEINFO IncludeFileInfo; 25 GlobalProc **ppSubHash;26 int SubNum;27 char **ppMacroNames;28 int MacroNum;29 25 DllProc **ppDeclareHash; 30 CONSTINFO **ppConstHash;31 26 32 27 ERRORINFO *pErrorInfo; -
trunk/abdev/BasicCompiler_Common/BreakPoint.cpp
r165 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/common/Environment.h> 4 #include <jenga/include/smoothie/Source.h> 2 5 3 6 #include "common.h" -
trunk/abdev/BasicCompiler_Common/CDebugThreadInfo.cpp
r4 r206 1 #include "stdafx.h" 2 1 3 #include "common.h" 4 #include "DebugSection.h" 2 5 3 6 -
trunk/abdev/BasicCompiler_Common/CommandFormat.cpp
r75 r206 1 #include "stdafx.h" 2 1 3 #include "common.h" 2 4 -
trunk/abdev/BasicCompiler_Common/Compile.cpp
r199 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 #include <jenga/include/smoothie/LexicalAnalysis.h> … … 126 128 int i,i2; 127 129 128 if(Command[0]=='\0') return; 130 if(Command[0]=='\0') 131 { 132 return; 133 } 134 135 trace_for_sourcecodestep( FormatEscapeSequenceStringToDefaultString(Command) ); 136 129 137 if(Command[0]=='*'&&IsVariableTopChar(Command[1])){ 130 138 //Goto先ラベル -
trunk/abdev/BasicCompiler_Common/Debug.cpp
r165 r206 1 #include "stdafx.h" 2 3 #include <Compiler.h> 4 1 5 #include "../BasicCompiler_Common/common.h" 6 #include "../BasicCompiler_Common/DebugSection.h" 2 7 3 8 //デバッグ用 … … 224 229 SendDlgItemMessage(hMainDlg,IDC_DEBUGLIST,EM_REPLACESEL,0,(LPARAM)buffer); 225 230 } 226 GlobalProc *GetSubFromObp(ULONG_PTR pos){ 227 extern GlobalProc **ppSubHash; 228 GlobalProc *pUserProc; 229 int i2; 230 231 for(i2=0;i2<MAX_HASH;i2++){ 232 pUserProc=ppSubHash[i2]; 233 while(pUserProc){ 234 if(rva_to_real(pUserProc->beginOpAddress) <= pos && 235 pos < rva_to_real(pUserProc->endOpAddress)) 236 return pUserProc; 237 238 pUserProc=pUserProc->pNextData; 239 } 240 } 241 return 0; 231 UserProc *GetSubFromObp(ULONG_PTR pos){ 232 compiler.GetMeta().GetUserProcs().Iterator_Reset(); 233 while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() ) 234 { 235 UserProc *pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext(); 236 237 if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pos && 238 pos < rva_to_real(pUserProc->GetEndOpAddress())) 239 { 240 return pUserProc; 241 } 242 } 243 return NULL; 242 244 } 243 245 void ReleaseSingleStep(DWORD dwBeforeStepRun,HANDLE hThread,CONTEXT *pContext){ … … 447 449 pobj_dti=new CDebugThreadInfo(); 448 450 449 GlobalProc *pUserProc;451 UserProc *pUserProc; 450 452 451 453 extern DWORD dwStepRun; … … 681 683 if(!bRet) MessageBox(hMainDlg,"プロセスメモリーの読み込みに失敗","error",MB_OK); 682 684 683 extern UserProc *pSub_DebugSys_EndProc;685 extern const UserProc *pSub_DebugSys_EndProc; 684 686 if((BYTE)temporary[0]==0xE8&& 685 *((long *)(temporary+1))+5==(long)rva_to_real(pSub_DebugSys_EndProc-> beginOpAddress)-(long)EIP_RIP(Context)){687 *((long *)(temporary+1))+5==(long)rva_to_real(pSub_DebugSys_EndProc->GetBeginOpAddress())-(long)EIP_RIP(Context)){ 686 688 //プロシージャの終端位置の場合はステップインを行う 687 689 goto StepIn; … … 704 706 //シングルステップON 705 707 WriteProcessMemory(hDebugProcess, 706 (void *)rva_to_real(pUserProc-> beginOpAddress),707 pobj_DBDebugSection->pobj_now->SingleStepCodeBuffer+pUserProc-> beginOpAddress,708 pUserProc-> endOpAddress-pUserProc->beginOpAddress,708 (void *)rva_to_real(pUserProc->GetBeginOpAddress()), 709 pobj_DBDebugSection->pobj_now->SingleStepCodeBuffer+pUserProc->GetBeginOpAddress(), 710 pUserProc->GetEndOpAddress()-pUserProc->GetBeginOpAddress(), 709 711 &lpAccBytes); 710 712 } -
trunk/abdev/BasicCompiler_Common/DebugMiddleFile.cpp
r201 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 3 5 #include <Compiler.h> 4 #include <Class Impl.h>5 #include <Variable Impl.h>6 #include <Class.h> 7 #include <Variable.h> 6 8 7 9 #include "../BasicCompiler_Common/common.h" 10 #include "../BasicCompiler_Common/DebugSection.h" 8 11 9 12 #ifdef _AMD64_ … … 44 47 45 48 46 CDebugSection::CDebugSection(){47 memset(this,0,sizeof(CDebugSection));48 }49 49 CDebugSection::~CDebugSection(){ 50 50 if(pobj_DBClass) DeleteDebugInfo(); … … 56 56 void CDebugSection::make(void){ 57 57 extern INCLUDEFILEINFO IncludeFileInfo; 58 int i2,i3, i5,BufferSize;58 int i2,i3,BufferSize; 59 59 60 60 if(buffer){ … … 159 159 160 160 //グローバル変数情報 161 *(long *)(buffer+i2)=(int) ::globalVars.size();162 i2+=sizeof(long); 163 BOOST_FOREACH( Variable *pVar, ::globalVars){161 *(long *)(buffer+i2)=(int)compiler.GetMeta().GetGlobalVars().size(); 162 i2+=sizeof(long); 163 BOOST_FOREACH( Variable *pVar, compiler.GetMeta().GetGlobalVars() ){ 164 164 //変数名 165 165 lstrcpy(buffer+i2,pVar->GetName().c_str()); … … 167 167 168 168 //型 169 *(long *)(buffer+i2)=pVar->Get BasicType();169 *(long *)(buffer+i2)=pVar->GetType().GetBasicType(); 170 170 i2+=sizeof(long); 171 171 172 172 //型の拡張情報 173 SetLpIndex_DebugFile(buffer,&i2, *pVar);173 SetLpIndex_DebugFile(buffer,&i2,pVar->GetType()); 174 174 175 175 buffer[i2++] = pVar->IsRef() ? 1 : 0; … … 178 178 179 179 if(pVar->IsArray()){ 180 for(i5=0;;i5++){ 181 *(long *)(buffer+i2)=pVar->GetSubScriptsPtr()[i5]; 180 *(long *)(buffer+i2)=(int)pVar->GetSubscripts().size(); 181 i2+=sizeof(long); 182 BOOST_FOREACH( int indexMax, pVar->GetSubscripts() ) 183 { 184 *(long *)(buffer+i2)=indexMax; 182 185 i2+=sizeof(long); 183 if(pVar->GetSubScriptsPtr()[i5]==-1) break;184 186 } 185 187 } 186 188 187 189 //レキシカルスコープ情報 188 *(long *)(buffer+i2)=pVar-> ScopeStartAddress;189 i2+=sizeof(long); 190 *(long *)(buffer+i2)=pVar-> ScopeEndAddress;191 i2+=sizeof(long); 192 *(long *)(buffer+i2)=pVar-> ScopeLevel;190 *(long *)(buffer+i2)=pVar->GetScopeStartAddress(); 191 i2+=sizeof(long); 192 *(long *)(buffer+i2)=pVar->GetScopeEndAddress(); 193 i2+=sizeof(long); 194 *(long *)(buffer+i2)=pVar->GetScopeLevel(); 193 195 i2+=sizeof(long); 194 196 195 197 //メモリ位置 196 *(long *)(buffer+i2)=pVar-> offset;198 *(long *)(buffer+i2)=pVar->GetOffsetAddress(); 197 199 i2+=sizeof(long); 198 200 … … 210 212 211 213 //プロシージャ情報 212 extern GlobalProc **ppSubHash; 213 extern int SubNum; 214 GlobalProc *pUserProc; 215 *(long *)(buffer+i2)=SubNum; 216 i2+=sizeof(long); 217 for(i3=0;i3<MAX_HASH;i3++){ 218 pUserProc=ppSubHash[i3]; 219 while(pUserProc){ 220 if(pUserProc->GetParentClassPtr()){ 221 lstrcpy(buffer+i2,pUserProc->GetParentClassPtr()->GetName().c_str()); 222 i2+=lstrlen(buffer+i2)+1; 223 } 224 else{ 225 lstrcpy(buffer+i2,""); 226 i2+=lstrlen(buffer+i2)+1; 227 } 228 229 //ID 230 *(long *)(buffer+i2)=pUserProc->id; 231 i2+=sizeof(long); 232 233 //関数名 234 lstrcpy(buffer+i2,pUserProc->GetName().c_str()); 214 *(long *)(buffer+i2) = compiler.GetMeta().GetUserProcs().Iterator_GetMaxCount(); 215 i2+=sizeof(long); 216 compiler.GetMeta().GetUserProcs().Iterator_Reset(); 217 while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() ) 218 { 219 UserProc *pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext(); 220 221 if(pUserProc->GetParentClassPtr()){ 222 lstrcpy(buffer+i2,pUserProc->GetParentClassPtr()->GetName().c_str()); 235 223 i2+=lstrlen(buffer+i2)+1; 236 237 *(long *)(buffer+i2)=pUserProc->beginOpAddress; 238 i2+=sizeof(long); 239 *(long *)(buffer+i2)=pUserProc->endOpAddress; 240 i2+=sizeof(long); 241 242 //ローカル変数情報 243 *(long *)(buffer+i2)=(int)pUserProc->localVars.size(); 244 i2+=sizeof(long); 224 } 225 else{ 226 lstrcpy(buffer+i2,""); 227 i2+=lstrlen(buffer+i2)+1; 228 } 229 230 //ID 231 *(long *)(buffer+i2)=pUserProc->GetId(); 232 i2+=sizeof(long); 233 234 //関数名 235 lstrcpy(buffer+i2,pUserProc->GetName().c_str()); 236 i2+=lstrlen(buffer+i2)+1; 237 238 *(long *)(buffer+i2)=pUserProc->GetBeginOpAddress(); 239 i2+=sizeof(long); 240 *(long *)(buffer+i2)=pUserProc->GetEndOpAddress(); 241 i2+=sizeof(long); 242 243 //ローカル変数情報 244 *(long *)(buffer+i2)=(int)pUserProc->GetLocalVars().size(); 245 i2+=sizeof(long); 246 247 //バッファが足りない場合は再確保 248 if(BufferSize<i2+32768){ 249 BufferSize+=32768; 250 buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize); 251 } 252 253 BOOST_FOREACH( Variable *pVar, pUserProc->GetLocalVars() ){ 254 lstrcpy(buffer+i2,pVar->GetName().c_str()); 255 i2+=lstrlen(buffer+i2)+1; 256 257 //型 258 *(long *)(buffer+i2)=pVar->GetType().GetBasicType(); 259 i2+=sizeof(long); 260 261 //型の拡張情報 262 SetLpIndex_DebugFile(buffer,&i2,pVar->GetType()); 263 264 //参照型パラメータかどうか 265 buffer[i2++] = pVar->IsRef() ? 1 : 0; 266 267 //配列かどうか 268 buffer[i2++] = pVar->IsArray() ? 1 : 0; 269 270 //配列要素 271 if(pVar->IsArray()){ 272 *(long *)(buffer+i2)=(int)pVar->GetSubscripts().size(); 273 i2+=sizeof(long); 274 BOOST_FOREACH( int indexMax, pVar->GetSubscripts() ) 275 { 276 *(long *)(buffer+i2)=indexMax; 277 i2+=sizeof(long); 278 } 279 } 280 281 //レキシカルスコープ情報 282 *(long *)(buffer+i2)=pVar->GetScopeStartAddress(); 283 i2+=sizeof(long); 284 *(long *)(buffer+i2)=pVar->GetScopeEndAddress(); 285 i2+=sizeof(long); 286 *(long *)(buffer+i2)=pVar->GetScopeLevel(); 287 i2+=sizeof(long); 288 289 //メモリ位置 290 *(long *)(buffer+i2)=pVar->GetOffsetAddress(); 291 i2+=sizeof(long); 292 293 294 245 295 246 296 //バッファが足りない場合は再確保 … … 249 299 buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize); 250 300 } 251 252 BOOST_FOREACH( Variable *pVar, pUserProc->localVars ){253 lstrcpy(buffer+i2,pVar->GetName().c_str());254 i2+=lstrlen(buffer+i2)+1;255 256 //型257 *(long *)(buffer+i2)=pVar->GetBasicType();258 i2+=sizeof(long);259 260 //型の拡張情報261 SetLpIndex_DebugFile(buffer,&i2,*pVar);262 263 //参照型パラメータかどうか264 buffer[i2++] = pVar->IsRef() ? 1 : 0;265 266 //配列かどうか267 buffer[i2++] = pVar->IsArray() ? 1 : 0;268 269 //配列要素270 if(pVar->IsArray()){271 for(i5=0;;i5++){272 *(long *)(buffer+i2)=pVar->GetSubScriptsPtr()[i5];273 i2+=sizeof(long);274 if(pVar->GetSubScriptsPtr()[i5]==-1) break;275 }276 }277 278 //レキシカルスコープ情報279 *(long *)(buffer+i2)=pVar->ScopeStartAddress;280 i2+=sizeof(long);281 *(long *)(buffer+i2)=pVar->ScopeEndAddress;282 i2+=sizeof(long);283 *(long *)(buffer+i2)=pVar->ScopeLevel;284 i2+=sizeof(long);285 286 //メモリ位置287 *(long *)(buffer+i2)=pVar->offset;288 i2+=sizeof(long);289 290 291 292 293 //バッファが足りない場合は再確保294 if(BufferSize<i2+32768){295 BufferSize+=32768;296 buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);297 }298 }299 300 pUserProc=pUserProc->pNextData;301 301 } 302 302 } … … 328 328 i2+=sizeof(long); 329 329 330 // メンバ330 // 動的メンバ 331 331 *(long *)(buffer+i2)=(int)pobj_c->GetDynamicMembers().size(); 332 332 i2+=sizeof(long); … … 347 347 i2+=sizeof(Prototype::Accessibility); 348 348 349 memcpy(buffer+i2,member->SubScripts,sizeof(int)*MAX_ARRAYDIM); 350 i2+=sizeof(int)*MAX_ARRAYDIM; 349 *(long *)(buffer+i2)=(int)member->GetSubscripts().size(); 350 i2+=sizeof(long); 351 BOOST_FOREACH( int indexMax, member->GetSubscripts() ) 352 { 353 *(long *)(buffer+i2)=indexMax; 354 i2+=sizeof(long); 355 } 351 356 352 357 //バッファが足りない場合は再確保 … … 357 362 } 358 363 359 // メソッド364 // 動的メソッド 360 365 *(long *)(buffer+i2)=(long)pobj_c->GetMethods().size(); 361 366 i2+=sizeof(long); … … 371 376 i2+=lstrlen(buffer+i2)+1; 372 377 } 373 lstrcpy(buffer+i2,pMethod-> pUserProc->GetName().c_str());378 lstrcpy(buffer+i2,pMethod->GetUserProc().GetName().c_str()); 374 379 i2+=lstrlen(buffer+i2)+1; 375 380 } … … 394 399 i2+=sizeof(Prototype::Accessibility); 395 400 396 memcpy(buffer+i2,member->SubScripts,sizeof(int)*MAX_ARRAYDIM); 397 i2+=sizeof(int)*MAX_ARRAYDIM; 401 // 配列 402 *(long *)(buffer+i2)=(int)member->GetSubscripts().size(); 403 i2+=sizeof(long); 404 BOOST_FOREACH( int indexMax, member->GetSubscripts() ) 405 { 406 *(long *)(buffer+i2)=indexMax; 407 i2+=sizeof(long); 408 } 398 409 399 410 //バッファが足りない場合は再確保 … … 434 445 } 435 446 BOOL CDebugSection::__load(void){ 436 int i2,i3,i4, i5,num;447 int i2,i3,i4,num; 437 448 char temp2[MAX_PATH],*temp5; 438 449 439 Smoothie::Temp::pCompilingClass = NULL;450 compiler.pCompilingClass = NULL; 440 451 441 452 i2=0; … … 487 498 /////////////////////////////////////////// 488 499 489 this->pobj_DBClass=new Classes Impl();500 this->pobj_DBClass=new Classes(); 490 501 491 502 int iMaxClassCount; … … 524 535 //定数を取得 525 536 GetConstInfo(); 526 extern CONSTINFO **ppConstHash; 527 this->ppConstHash=ppConstHash; 528 537 this->globalConsts = compiler.GetMeta().GetGlobalConsts(); 538 this->globalConstMacros = compiler.GetMeta().GetGlobalConstMacros(); 529 539 530 540 //グローバル変数情報 531 globalVars.clear();541 compiler.GetMeta().GetGlobalVars().clear(); 532 542 int maxGlobalVars=*(long *)(buffer+i2); 533 543 i2+=sizeof(long); … … 548 558 bool isArray = (buffer[i2++]) ? true:false; 549 559 550 Variable *pVar = new Variable Impl( name, type, false, isRef);560 Variable *pVar = new Variable( name, type, false, isRef, "" ); 551 561 552 562 if(isArray){ 553 int SubScripts[MAX_ARRAYDIM]; 554 for(i4=0;;i4++){ 555 SubScripts[i4]=*(long *)(buffer+i2); 563 Subscripts subscripts; 564 int nSubScriptsNum = *(long *)(buffer+i2); 565 i2+=sizeof(long); 566 for( int i=0; i<nSubScriptsNum; i++ ) 567 { 568 subscripts.push_back( *(long *)(buffer+i2) ); 556 569 i2+=sizeof(long); 557 558 if(SubScripts[i4]==-1) break; 559 } 560 561 pVar->SetArray( SubScripts ); 570 } 571 572 pVar->SetArray( subscripts ); 562 573 } 563 574 564 575 //レキシカルスコープ情報 565 pVar->S copeStartAddress=*(long *)(buffer+i2);566 i2+=sizeof(long); 567 pVar->S copeEndAddress=*(long *)(buffer+i2);568 i2+=sizeof(long); 569 pVar->S copeLevel=*(long *)(buffer+i2);576 pVar->SetScopeStartAddress( *(long *)(buffer+i2) ); 577 i2+=sizeof(long); 578 pVar->SetScopeEndAddress( *(long *)(buffer+i2) ); 579 i2+=sizeof(long); 580 pVar->SetScopeLevel( *(long *)(buffer+i2) ); 570 581 i2+=sizeof(long); 571 582 572 583 //メモリ位置 573 pVar-> offset=*(long *)(buffer+i2);584 pVar->SetOffsetAddress( *(long *)(buffer+i2) ); 574 585 i2+=sizeof(long); 575 586 576 587 //変数を追加 577 globalVars.push_back( pVar );588 compiler.GetMeta().GetGlobalVars().push_back( pVar ); 578 589 } 579 590 … … 583 594 584 595 //プロシージャ情報 585 GlobalProc *pUserProc; 586 SubNum=*(long *)(buffer+i2); 587 i2+=sizeof(long); 588 ppSubHash=(GlobalProc **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(GlobalProc *)); 589 for(int i6=0;i6<SubNum;i6++){ 596 userProcs.Clear(); 597 int subNum = *(long *)(buffer+i2); 598 i2+=sizeof(long); 599 for(int i6=0;i6<subNum;i6++){ 590 600 char szParentClassName[VN_SIZE]; 591 601 lstrcpy(szParentClassName,buffer+i2); … … 607 617 // オブジェクトを生成 608 618 // TODO: 名前空間が未完成 609 pUserProc = new GlobalProc( NamespaceScopes(), NamespaceScopesCollection(), name, Procedure::Function, false, false, false ); 610 pUserProc->pNextData=0; 611 pUserProc->id=id; 619 UserProc *pUserProc = new UserProc( NamespaceScopes(), NamespaceScopesCollection(), name, Procedure::Function, false, false, false, id ); 612 620 pUserProc->SetParentClass( pClass ); 613 621 614 pUserProc-> beginOpAddress=*(long *)(buffer+i2);615 i2+=sizeof(long); 616 pUserProc-> endOpAddress=*(long *)(buffer+i2);622 pUserProc->SetBeginOpAddress( *(long *)(buffer+i2) ); 623 i2+=sizeof(long); 624 pUserProc->SetEndOpAddress( *(long *)(buffer+i2) ); 617 625 i2+=sizeof(long); 618 626 … … 620 628 621 629 //ローカル変数情報 622 pUserProc-> localVars.clear();630 pUserProc->GetLocalVars().clear(); 623 631 int maxLocalVar=*(long *)(buffer+i2); 624 632 i2+=sizeof(long); … … 638 646 bool isArray = (buffer[i2++]) ? true:false; 639 647 640 Variable *pVar = new Variable Impl( name, type, false, isRef);648 Variable *pVar = new Variable( name, type, false, isRef, "" ); 641 649 642 650 if(isArray){ 643 int SubScripts[MAX_ARRAYDIM]; 644 for(i4=0;;i4++){ 645 SubScripts[i4]=*(long *)(buffer+i2); 651 Subscripts subscripts; 652 int nSubScriptsNum = *(long *)(buffer+i2); 653 i2+=sizeof(long); 654 for( int i=0; i<nSubScriptsNum; i++ ) 655 { 656 subscripts.push_back( *(long *)(buffer+i2) ); 646 657 i2+=sizeof(long); 647 648 if(SubScripts[i4]==-1) break;649 658 } 650 659 651 pVar->SetArray( SubScripts );660 pVar->SetArray( subscripts ); 652 661 } 653 662 654 663 //レキシカルスコープ情報 655 pVar->S copeStartAddress=*(long *)(buffer+i2);656 i2+=sizeof(long); 657 pVar->S copeEndAddress=*(long *)(buffer+i2);658 i2+=sizeof(long); 659 pVar->S copeLevel=*(long *)(buffer+i2);664 pVar->SetScopeStartAddress( *(long *)(buffer+i2) ); 665 i2+=sizeof(long); 666 pVar->SetScopeEndAddress( *(long *)(buffer+i2) ); 667 i2+=sizeof(long); 668 pVar->SetScopeLevel( *(long *)(buffer+i2) ); 660 669 i2+=sizeof(long); 661 670 662 671 //メモリ位置 663 pVar-> offset=*(long *)(buffer+i2);672 pVar->SetOffsetAddress( *(long *)(buffer+i2) ); 664 673 i2+=sizeof(long); 665 674 666 675 //変数を追加 667 pUserProc-> localVars.push_back( pVar );676 pUserProc->GetLocalVars().push_back( pVar ); 668 677 } 669 678 … … 673 682 ///////////////////////////////// 674 683 675 i4=hash_default(pUserProc->GetName().c_str()); 676 677 GlobalProc *psi2; 678 if(ppSubHash[i4]){ 679 psi2=ppSubHash[i4]; 680 while(1){ 681 if(psi2->pNextData==0){ 682 psi2->pNextData=pUserProc; 683 break; 684 } 685 psi2=psi2->pNextData; 686 } 687 } 688 else{ 689 ppSubHash[i4]=pUserProc; 690 } 691 } 684 // ハッシュに追加 685 if( !userProcs.Insert( pUserProc, -1 ) ) 686 { 687 //return NULL; 688 } 689 } 690 userProcs.Iterator_Init(); 692 691 693 692 //クラス情報 … … 709 708 i2+=sizeof(long); 710 709 711 // 静的メンバ710 // 動的メンバ 712 711 int nDynamicMember = *(long *)(buffer+i2); 713 712 i2+=sizeof(long); … … 728 727 i2+=sizeof(Prototype::Accessibility); 729 728 730 CMember *member=new CMember( accessibility, name, type, false, "", "" ); 731 732 memcpy(member->SubScripts,buffer+i2,sizeof(int)*MAX_ARRAYDIM); 733 i2+=sizeof(int)*MAX_ARRAYDIM; 729 Subscripts subscripts; 730 int nSubScriptsNum = *(long *)(buffer+i2); 731 i2+=sizeof(long); 732 for( int i=0; i<nSubScriptsNum; i++ ) 733 { 734 subscripts.push_back( *(long *)(buffer+i2) ); 735 i2+=sizeof(long); 736 } 737 738 CMember *member=new CMember( accessibility, name, type, false, subscripts, "", "" ); 734 739 735 740 pobj_c->GetDynamicMembers().push_back( member ); 736 741 } 737 742 738 // メソッド743 // 動的メソッド 739 744 int nMethod = *(long *)(buffer+i2); 740 745 i2+=sizeof(long); … … 759 764 pobj_temp_c=pobj_InheritsClass; 760 765 if(pobj_temp_c==0) pobj_temp_c=pobj_c; 761 i5=hash_default(temp2); 762 pUserProc=ppSubHash[i5]; 763 while(1){ 764 if( pUserProc->GetName() == temp2 &&pUserProc->GetParentClassPtr()==pobj_temp_c) break; 765 pUserProc=pUserProc->pNextData; 766 767 UserProc *pUserProc = compiler.GetMeta().GetUserProcs().GetHashArrayElement( temp2 ); 768 while(pUserProc){ 769 if( pUserProc->GetName() == temp2 &&pUserProc->GetParentClassPtr()==pobj_temp_c) 770 { 771 break; 772 } 773 774 pUserProc=pUserProc->GetChainNext(); 766 775 } 767 776 … … 790 799 i2+=sizeof(Prototype::Accessibility); 791 800 792 CMember *member=new CMember( accessibility, name, type, false, "", "" ); 793 794 memcpy(member->SubScripts,buffer+i2,sizeof(int)*MAX_ARRAYDIM); 795 i2+=sizeof(int)*MAX_ARRAYDIM; 801 // 配列 802 Subscripts subscripts; 803 int nSubScriptsNum = *(long *)(buffer+i2); 804 i2+=sizeof(long); 805 for( int i=0; i<nSubScriptsNum; i++ ) 806 { 807 subscripts.push_back( *(long *)(buffer+i2) ); 808 i2+=sizeof(long); 809 } 810 811 CMember *member=new CMember( accessibility, name, type, false, subscripts, "", "" ); 796 812 797 813 pobj_c->GetStaticMembers().push_back( member ); … … 805 821 806 822 807 extern GlobalProc **ppSubHash; 808 ppSubHash=this->ppSubHash; 823 compiler.GetMeta().GetUserProcs() = userProcs; 809 824 pSub_DebugSys_EndProc=GetSubHash("_DebugSys_EndProc"); 810 825 … … 950 965 951 966 //定数を取得 952 extern CONSTINFO **ppConstHash;953 ppConstHash=this->ppConstHash;967 compiler.GetMeta().GetGlobalConsts() = this->globalConsts; 968 compiler.GetMeta().GetGlobalConstMacros() = this->globalConstMacros; 954 969 955 970 //グローバル実行領域のサイズ … … 958 973 959 974 //プロシージャ 960 extern char **ppMacroNames; 961 ppMacroNames=0; 962 extern GlobalProc **ppSubHash; 963 extern int SubNum; 964 ppSubHash=this->ppSubHash; 965 SubNum=this->SubNum; 966 967 extern UserProc *pSub_DebugSys_EndProc; 975 compiler.GetMeta().GetUserProcs() = userProcs; 976 977 extern const UserProc *pSub_DebugSys_EndProc; 968 978 pSub_DebugSys_EndProc=this->pSub_DebugSys_EndProc; 969 979 … … 986 996 delete this->pobj_DBClass; 987 997 this->pobj_DBClass=0; 988 989 //サブルーチン情報のメモリ解放990 DeleteSubInfo(ppSubHash,0,0);991 992 //定数に関する情報を解放993 DeleteConstInfo(ppConstHash);994 998 995 999 //コードと行番号の関係を解放 -
trunk/abdev/BasicCompiler_Common/DebugSection.h
r182 r206 2 2 3 3 #include <jenga/include/smoothie/Source.h> 4 #include <jenga/include/smoothie/Class.h>5 4 6 #include <ProcedureImpl.h> 5 #include <Class.h> 6 #include <Procedure.h> 7 #include <Const.h> 7 8 8 9 … … 42 43 43 44 //定数を取得 44 CONSTINFO **ppConstHash; 45 Consts globalConsts; 46 ConstMacros globalConstMacros; 45 47 46 48 //グローバル実行領域のサイズ … … 48 50 49 51 //プロシージャ 50 GlobalProc **ppSubHash; 51 int SubNum; 52 UserProcs userProcs; 52 53 53 UserProc *pSub_DebugSys_EndProc;54 const UserProc *pSub_DebugSys_EndProc; 54 55 55 56 //ネイティブコードバッファ … … 66 67 67 68 68 CDebugSection(); 69 CDebugSection() 70 : buffer( NULL ) 71 , length( 0 ) 72 , dwImageBase( 0 ) 73 , dwRVA_RWSection( 0 ) 74 , dwRVA_CodeSection( 0 ) 75 , SizeOf_CodeSection( 0 ) 76 , pobj_DBClass( NULL ) 77 , GlobalOpBufferSize( 0 ) 78 , pSub_DebugSys_EndProc( NULL ) 79 , OpBuffer( NULL ) 80 , SingleStepCodeBuffer( NULL ) 81 , BreakStepCodeBuffer( NULL ) 82 { 83 szNowFilePath[0]=0; 84 } 69 85 ~CDebugSection(); 70 86 -
trunk/abdev/BasicCompiler_Common/Diagnose.cpp
r193 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 … … 38 40 int codeSizeOfGlobalProc = 0; 39 41 int codeSizeOfClassMethod = 0; 40 for(int i2=0;i2<MAX_HASH;i2++){ 41 extern GlobalProc **ppSubHash; 42 GlobalProc *pUserProc = ppSubHash[i2]; 43 while(pUserProc){ 44 if( pUserProc->IsCompiled() ){ 45 if( pUserProc->HasParentClass() ){ 46 codeSizeOfClassMethod += pUserProc->GetCodeSize(); 47 } 48 else{ 49 codeSizeOfGlobalProc += pUserProc->GetCodeSize(); 50 } 42 compiler.GetMeta().GetUserProcs().Iterator_Reset(); 43 while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() ) 44 { 45 UserProc *pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext(); 46 if( pUserProc->IsCompiled() ){ 47 if( pUserProc->HasParentClass() ){ 48 codeSizeOfClassMethod += pUserProc->GetCodeSize(); 51 49 } 52 53 pUserProc=pUserProc->pNextData; 50 else{ 51 codeSizeOfGlobalProc += pUserProc->GetCodeSize(); 52 } 54 53 } 55 54 } … … 83 82 // 動的メソッド 84 83 BOOST_FOREACH( const CMethod *pMethod, objClass.GetMethods() ){ 85 if( pMethod-> pUserProc->IsCompiled() ){86 codeSizeOfClass += pMethod-> pUserProc->GetCodeSize();84 if( pMethod->GetUserProc().IsCompiled() ){ 85 codeSizeOfClass += pMethod->GetUserProc().GetCodeSize(); 87 86 } 88 87 } … … 90 89 // 静的メソッド 91 90 BOOST_FOREACH( const CMethod *pMethod, objClass.GetStaticMethods() ){ 92 codeSizeOfClass += pMethod-> pUserProc->GetCodeSize();91 codeSizeOfClass += pMethod->GetUserProc().GetCodeSize(); 93 92 } 94 93 … … 118 117 // 動的メソッド 119 118 BOOST_FOREACH( const CMethod *pMethod, objClass.GetMethods() ){ 120 if( pMethod-> pUserProc->IsCompiled() ){121 codeSizeOfClass += pMethod-> pUserProc->GetCodeSize();119 if( pMethod->GetUserProc().IsCompiled() ){ 120 codeSizeOfClass += pMethod->GetUserProc().GetCodeSize(); 122 121 } 123 122 } … … 125 124 // 静的メソッド 126 125 BOOST_FOREACH( const CMethod *pMethod, objClass.GetStaticMethods() ){ 127 codeSizeOfClass += pMethod-> pUserProc->GetCodeSize();126 codeSizeOfClass += pMethod->GetUserProc().GetCodeSize(); 128 127 } 129 128 -
trunk/abdev/BasicCompiler_Common/Enum.cpp
r199 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/common/logger.h> 2 4 … … 5 7 6 8 #include <Compiler.h> 9 #include <../Enum.h> 7 10 8 11 #include "common.h" … … 293 296 294 297 // ログを生成 295 Jenga::Common::Logger logger( Jenga::Common::Environment::GetAppDir() + "\\enum_generated.log" );298 Jenga::Common::Logger logger( Jenga::Common::Environment::GetAppDir() + "\\enum_generated.log", false ); 296 299 logger << buffer << endl; 297 300 -
trunk/abdev/BasicCompiler_Common/Intermediate_Step1.cpp
r182 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 #include <jenga/include/smoothie/LexicalAnalysis.h> -
trunk/abdev/BasicCompiler_Common/Intermediate_Step2.cpp
r199 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 #include <jenga/include/smoothie/LexicalAnalysis.h> … … 6 8 #include "../BasicCompiler_Common/common.h" 7 9 8 CONSTINFO *GetNewConstHash(char *name){ 9 extern int cp; 10 CONSTINFO *pci; 11 12 int key; 13 key=hash_default(name); 14 15 extern CONSTINFO **ppConstHash; 16 if(ppConstHash[key]){ 17 pci=ppConstHash[key]; 18 while(1){ 19 if(lstrcmp(pci->name,name)==0){ 20 //重複エラー 21 SetError(15,name,cp); 22 return 0; 23 } 24 25 if(pci->pNextData==0){ 26 pci->pNextData=(CONSTINFO *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,sizeof(CONSTINFO)); 27 break; 28 } 29 pci=pci->pNextData; 30 } 31 pci=pci->pNextData; 32 } 33 else{ 34 ppConstHash[key]=(CONSTINFO *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,sizeof(CONSTINFO)); 35 pci=ppConstHash[key]; 36 } 37 38 return pci; 39 } 40 41 // マクロ定数を追加するための関数 42 void AddConstData(char *Command){ 43 extern HANDLE hHeap; 44 extern int cp; 45 int i,i2; 46 char temporary[VN_SIZE]; 47 48 for(i=0;;i++){ 49 if(Command[i]=='\0'){ 50 SetError(10,"Const",cp); 51 return; 52 } 53 if(Command[i]=='=' || Command[i] == 1 && Command[i+1] == ESC_AS ){ 54 //定数定義は新しいクラスモジュール(CDBConst)へ移行 55 // ※この関数はマクロ定数のみを扱う 56 return; 57 } 58 if(Command[i]=='('){ 59 temporary[i]=0; 60 break; 61 } 62 temporary[i]=Command[i]; 63 } 64 65 66 ///////////////////////////////// 67 // 格納位置を計算してpciにセット 68 ///////////////////////////////// 69 70 CONSTINFO *pci; 71 pci=GetNewConstHash(temporary); 72 if(!pci) return; 73 74 75 76 //////////////////// 77 // 定数情報を取得 78 //////////////////// 79 80 //定数名 81 pci->name=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1); 82 lstrcpy(pci->name,temporary); 83 84 if(Command[i]=='('){ 85 pci->ppParm=(char **)HeapAlloc(hHeap,0,1); 86 pci->ParmNum=0; 87 for(i++,i2=0;;i++,i2++){ 88 if(Command[i]=='\0'){ 89 SetError(1,NULL,cp); 90 return; 91 } 92 if(Command[i]==','||Command[i]==')'){ 93 temporary[i2]=0; 94 pci->ppParm=(char **)HeapReAlloc(hHeap,0,pci->ppParm,(pci->ParmNum+1)*sizeof(char *)); 95 pci->ppParm[pci->ParmNum]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1); 96 lstrcpy(pci->ppParm[pci->ParmNum],temporary); 97 pci->ParmNum++; 98 if(Command[i]==')'){ 99 i++; 100 if(Command[i]!='='){ 101 SetError(1,NULL,cp); 102 return; 103 } 104 break; 105 } 106 107 i2=-1; 108 continue; 109 } 110 temporary[i2]=Command[i]; 111 } 112 } 113 else pci->ParmNum=0; 114 115 //データ 116 lstrcpy(temporary,Command+i+1); 117 if(pci->ParmNum){ 118 pci->StrValue=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1); 119 lstrcpy(pci->StrValue,temporary); 120 } 121 else if(temporary[0]=='\"'){ 122 //文字列定数 123 RemoveStringQuotes(temporary); 124 i2=lstrlen(temporary); 125 126 pci->StrValue=(char *)HeapAlloc(hHeap,0,i2+1); 127 memcpy(pci->StrValue,temporary,i2); 128 pci->StrValue[i2]=0; 129 130 pci->DblValue=(double)i2; 131 132 pci->type=DEF_STRING; 133 pci->lpIndex=-1; 134 } 135 else if((temporary[0]=='e'||temporary[0]=='E')&& 136 (temporary[1]=='x'||temporary[1]=='X')&& 137 temporary[2]=='\"'){ 138 //文字列定数 139 RemoveStringQuotes(temporary+2); 140 i2=FormatString_EscapeSequence(temporary+2); 141 pci->StrValue=(char *)HeapAlloc(hHeap,0,i2+1); 142 memcpy(pci->StrValue,temporary+2,i2); 143 pci->StrValue[i2]=0; 144 145 pci->DblValue=(double)i2; 146 147 pci->type=DEF_STRING; 148 pci->lpIndex=-1; 149 } 150 else{ 151 //数値定数 152 _int64 i64data; 153 Type resultType; 154 StaticCalculation(true, temporary,0,&i64data,resultType); 155 pci->type=resultType.GetBasicType(); 156 if(IsRealNumberType(pci->type)){ 157 //実数型 158 memcpy(&pci->DblValue,&i64data,sizeof(double)); 159 } 160 else if(Is64Type(pci->type)){ 161 //64ビット型 162 pci->i64Value=i64data; 163 } 164 else if(IsWholeNumberType(pci->type)){ 165 //その他整数型 166 pci->DblValue=(double)i64data; 167 } 168 169 pci->StrValue=0; 170 } 171 } 10 172 11 void AddConstEnum( const NamespaceScopes &namespaceScopes, char *buffer){ 173 12 extern int cp; … … 240 79 241 80 //定数を追加 242 CDBConst::obj.AddConst( namespaceScopes, temporary, NextValue);81 compiler.GetMeta().GetGlobalConsts().Add( namespaceScopes, temporary, NextValue); 243 82 } 244 83 } … … 255 94 namespaceScopes.clear(); 256 95 257 //定数に関する情報 258 extern CONSTINFO **ppConstHash;259 ppConstHash=(CONSTINFO **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(CONSTINFO *));96 //定数に関する情報を初期化 97 compiler.GetMeta().GetGlobalConsts().Clear(); 98 compiler.GetMeta().GetGlobalConstMacros().Clear(); 260 99 261 100 extern char *basbuf; … … 315 154 temporary[i2]=basbuf[i]; 316 155 } 317 CDBConst::obj.Add( namespaceScopes, temporary);156 AddConst( namespaceScopes, temporary); 318 157 if(basbuf[i]=='\0') break; 319 158 } … … 331 170 } 332 171 } 172 173 // イテレータを初期化 174 compiler.GetMeta().GetGlobalConsts().Iterator_Init(); 175 compiler.GetMeta().GetGlobalConstMacros().Iterator_Init(); 176 333 177 return true; 334 178 } -
trunk/abdev/BasicCompiler_Common/MakeExe.cpp
r191 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 4 5 #include <Compiler.h> 2 6 3 7 #include "common.h" … … 6 10 extern HWND hMainDlg; 7 11 PostMessage(GetDlgItem(hMainDlg,IDC_PROGRESS),PBM_STEPIT,0,0); 8 }9 10 void Delete_ci(CONSTINFO *pci){11 int i;12 13 HeapDefaultFree(pci->name);14 if(pci->StrValue) HeapDefaultFree(pci->StrValue);15 if(pci->ParmNum){16 for(i=0;i<pci->ParmNum;i++)17 HeapDefaultFree(pci->ppParm[i]);18 HeapDefaultFree(pci->ppParm);19 }20 21 if(pci->pNextData){22 Delete_ci(pci->pNextData);23 }24 25 HeapDefaultFree(pci);26 }27 void DeleteConstInfo(CONSTINFO **ppConstHash){28 int i;29 30 for(i=0;i<MAX_HASH;i++){31 if(ppConstHash[i]){32 Delete_ci(ppConstHash[i]);33 }34 }35 HeapDefaultFree(ppConstHash);36 12 } 37 13 … … 128 104 if(bError||bStopCompile) goto EndCompile; 129 105 130 /*未完成131 //定数に関する情報132 extern CONSTINFO **ppConstHash;133 ppConstHash=(CONSTINFO **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(CONSTINFO *));134 */135 136 106 //コンパイルダイアログのプログレスバーを上げる 137 107 StepCompileProgress(); … … 167 137 extern int AllGlobalVarSize; 168 138 extern int AllInitGlobalVarSize; 169 globalVars.clear();139 compiler.GetMeta().GetGlobalVars().clear(); 170 140 AllGlobalVarSize=0; 171 141 AllInitGlobalVarSize=0; … … 195 165 HeapDefaultFree(pLineInfo); 196 166 197 //サブルーチン(ユーザー定義)情報のメモリ解放198 extern GlobalProc **ppSubHash;199 extern char **ppMacroNames;200 extern int MacroNum;201 DeleteSubInfo(ppSubHash,ppMacroNames,MacroNum);202 203 167 //Declare(DLL関数)情報のメモリ解放 204 168 DeleteDeclareInfo(); 205 206 //定数に関する情報を解放207 extern CONSTINFO **ppConstHash;208 DeleteConstInfo(ppConstHash);209 169 210 170 //コンパイルダイアログのプログレスバーを上げる -
trunk/abdev/BasicCompiler_Common/NonVolatile.cpp
r165 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/common/Environment.h> 2 4 -
trunk/abdev/BasicCompiler_Common/NumOpe_GetType.cpp
r198 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 #include <jenga/include/smoothie/LexicalAnalysis.h> … … 198 200 pobj_c=(CClass *)index_stack[sp-2]; 199 201 200 std::vector< UserProc *> subs;202 std::vector<const UserProc *> subs; 201 203 pobj_c->GetMethods().Enum( idCalc, subs ); 202 204 if( subs.size() == 0 ){ … … 228 230 if(idCalc==CALC_EQUAL) lstrcpy(temporary,"=="); 229 231 else GetCalcName(idCalc,temporary); 230 UserProc *pUserProc = OverloadSolution( temporary, subs, params, baseType );232 const UserProc *pUserProc = OverloadSolution( temporary, subs, params, baseType ); 231 233 232 234 if(bTwoTerm){ … … 315 317 // パース 316 318 char member[VN_SIZE]; 317 CClass::RefTyperefType;318 if( CClass::SplitName( termFull, termLeft, member, refType ) ){319 ReferenceKind refType; 320 if( SplitMemberName( termFull, termLeft, member, refType ) ){ 319 321 /////////////////////////////////////////////////////////////////// 320 322 // オブジェクトとメンバに分解できるとき … … 371 373 // 動的メソッドを検索 372 374 /////////////////////////////////////////////////////////////////// 373 vector<UserProc *> userProcs;374 375 375 char methodName[VN_SIZE] ,lpPtrOffset[VN_SIZE]; 376 376 lstrcpy( methodName, member ); 377 377 GetVarFormatString(methodName,parameter,lpPtrOffset,member,refType); 378 378 379 vector<const UserProc *> userProcs; 379 380 objClass.GetMethods().Enum( methodName, userProcs ); 380 UserProc *pUserProc;381 381 if(userProcs.size()){ 382 382 //オーバーロードを解決 383 pUserProc=OverloadSolutionWithStrParam(termFull,userProcs,parameter,termLeft);383 const UserProc *pUserProc = OverloadSolutionWithStrParam(termFull,userProcs,parameter,termLeft); 384 384 385 385 if( pUserProc ){ … … 413 413 if(lstrcmpi(termFull,"This")==0){ 414 414 //Thisオブジェクト 415 resultType.SetType( DEF_OBJECT, Smoothie::Temp::pCompilingClass );415 resultType.SetType( DEF_OBJECT, compiler.pCompilingClass ); 416 416 isLiteral = false; 417 417 return true; … … 455 455 return true; 456 456 } 457 else if(GetConstCalcBuffer(procName,parameter,temporary)){ 458 ///////////////////////// 459 // マクロ関数 460 ///////////////////////// 461 462 //閉じカッコ")"に続く文字がNULLでないときはエラーにする 463 if(termFull[i2+1+i4+1]!='\0') SetError(42,NULL,cp); 464 465 //マクロ関数の場合 466 if( !NumOpe_GetType(temporary,Type(),resultType) ){ 467 return false; 468 } 469 470 if( !IS_LITERAL( resultType.GetIndex() ) ){ 471 //リテラル値ではなかったとき 472 isLiteral = false; 473 } 474 475 return true; 457 else 458 { 459 ConstMacro *pConstMacro = compiler.GetMeta().GetGlobalConstMacros().Find( procName ); 460 if( pConstMacro ) 461 { 462 if( pConstMacro->GetCalcBuffer( parameter, temporary ) ) 463 { 464 ///////////////////////// 465 // マクロ関数 466 ///////////////////////// 467 468 //閉じカッコ")"に続く文字がNULLでないときはエラーにする 469 if(termFull[i2+1+i4+1]!='\0') SetError(42,NULL,cp); 470 471 //マクロ関数の場合 472 if( !NumOpe_GetType(temporary,Type(),resultType) ){ 473 return false; 474 } 475 476 if( !IS_LITERAL( resultType.GetIndex() ) ){ 477 //リテラル値ではなかったとき 478 isLiteral = false; 479 } 480 481 return true; 482 } 483 } 476 484 } 477 485 } … … 732 740 ////////////// 733 741 734 i3 = CDBConst::obj.GetBasicType(term);742 i3 = compiler.GetMeta().GetGlobalConsts().GetBasicType(term); 735 743 if(i3){ 736 if( CDBConst::obj.IsStringPtr( term ) ){744 if( compiler.GetMeta().GetGlobalConsts().IsStringPtr( term ) ){ 737 745 //リテラル文字列 738 746 goto StrLiteral; -
trunk/abdev/BasicCompiler_Common/Object.cpp
r198 r206 1 #include "stdafx.h" 2 1 3 #include <Compiler.h> 2 4 … … 11 13 extern HANDLE hHeap; 12 14 13 void CallConstructor( const char *ObjectName,const int *SubScripts,const Type &type,const char *Parameter){15 void CallConstructor( const char *ObjectName,const Subscripts &subscripts,const Type &type,const char *Parameter){ 14 16 if( !type.IsObject() ){ 15 17 return; … … 21 23 ///////////////////////////////////// 22 24 23 UserProc *pUserProc; 24 pUserProc=GetMethodHash(ObjectName,type.GetClass().GetName().c_str(),Parameter); 25 const UserProc *pUserProc = GetMethodHash(ObjectName,type.GetClass().GetName().c_str(),Parameter); 25 26 if(!pUserProc){ 26 27 if(Parameter[0]) SetError(113,type.GetClass().GetName().c_str(),cp); … … 31 32 char temporary[VN_SIZE]; 32 33 33 if( SubScripts[0]!=-1){34 if( subscripts.size() > 0 ){ 34 35 int ss[MAX_ARRAYDIM]; 35 36 memset(ss,0,MAX_ARRAYDIM*sizeof(int)); 36 37 while(1){ 37 38 int i3; 38 for(i3=0;;i3++){ 39 if(SubScripts[i3]==-1) break; 40 41 if(ss[i3]>SubScripts[i3]){ 39 for(i3=0; i3<(int)subscripts.size(); i3++){ 40 if(ss[i3]>subscripts[i3]){ 42 41 ss[i3]=0; 43 42 ss[i3+1]++; … … 45 44 else break; 46 45 } 47 if(SubScripts[i3]==-1) break; 46 if( i3 == subscripts.size() ) 47 { 48 break; 49 } 48 50 sprintf(temporary,"%s[%d",ObjectName,ss[0]); 49 for(i3=1;;i3++){ 50 if(SubScripts[i3]==-1) break; 51 51 for(i3=1; i3<(int)subscripts.size(); i3++){ 52 52 sprintf(temporary+lstrlen(temporary),",%d",ss[i3]); 53 53 } -
trunk/abdev/BasicCompiler_Common/OldStatement.cpp
r97 r206 1 #include "stdafx.h" 2 1 3 #include "common.h" 2 4 … … 116 118 OpcodeCalc(temp2); 117 119 118 UserProc *pUserProc;120 const UserProc *pUserProc; 119 121 if(bFile) pUserProc=GetSubHash("INPUT_FromFile"); 120 122 else pUserProc=GetSubHash("INPUT_FromPrompt"); … … 218 220 OpcodeCalc(temp2); 219 221 220 UserProc *pUserProc;222 const UserProc *pUserProc; 221 223 if(bFile) pUserProc=GetSubHash("PRINTUSING_ToFile"); 222 224 else pUserProc=GetSubHash("PRINTUSING_ToPrompt"); … … 322 324 if(sw) lstrcat(buffer,"+Ex\"\\r\\n\""); 323 325 324 UserProc *pUserProc;326 const UserProc *pUserProc; 325 327 if(bFile) pUserProc=GetSubHash("PRINT_ToFile"); 326 328 else pUserProc=GetSubHash("PRINT_ToPrompt"); -
trunk/abdev/BasicCompiler_Common/Overload.cpp
r182 r206 1 #include "stdafx.h" 2 1 3 #include "../BasicCompiler_Common/common.h" 2 4 … … 7 9 #endif 8 10 9 UserProc *OverloadSolutionWithStrParam(11 const UserProc *OverloadSolutionWithStrParam( 10 12 const char *name, 11 std::vector< UserProc *> &subs,13 std::vector<const UserProc *> &subs, 12 14 const char *Parameter, 13 15 const char *ObjectName){ … … 26 28 27 29 char MethodName[VN_SIZE]; 28 if( ! CClass::SplitName( name, NULL, MethodName ) ) lstrcpy( MethodName, name );30 if( !SplitMemberName( name, NULL, MethodName ) ) lstrcpy( MethodName, name ); 29 31 /* 30 32 //メソッドの場合は静的かどうかを調べる … … 39 41 40 42 41 UserProc *pUserProc; 42 pUserProc=pobj_parameter->OverloadSolution(name,subs); 43 const UserProc *pUserProc = pobj_parameter->OverloadSolution(name,subs); 43 44 44 45 … … 49 50 return pUserProc; 50 51 } 51 UserProc *OverloadSolution(52 const UserProc *OverloadSolution( 52 53 const char *name, 53 std::vector< UserProc *> &subs,54 std::vector<const UserProc *> &subs, 54 55 const Parameters ¶ms, 55 56 const Type &returnType ){ … … 66 67 } 67 68 68 UserProc *pUserProc; 69 pUserProc=pobj_Parameter->OverloadSolution(name,subs); 69 const UserProc *pUserProc = pobj_Parameter->OverloadSolution(name,subs); 70 70 71 71 delete pobj_Parameter; -
trunk/abdev/BasicCompiler_Common/PESchedule.cpp
r75 r206 1 #include "stdafx.h" 2 1 3 #include "../BasicCompiler_Common/common.h" 2 4 … … 197 199 198 200 CImportAddrSchedule::CImportAddrSchedule(){ 199 ppdi=( DllProc **)HeapAlloc(hHeap,0,1);201 ppdi=(const DllProc **)HeapAlloc(hHeap,0,1); 200 202 } 201 203 CImportAddrSchedule::~CImportAddrSchedule(){ … … 203 205 } 204 206 205 void CImportAddrSchedule::add( DllProc *pDllProc){206 ppdi=( DllProc **)HeapReAlloc(hHeap,0,ppdi,(num+1)*sizeof(DllProc *));207 void CImportAddrSchedule::add(const DllProc *pDllProc){ 208 ppdi=(const DllProc **)HeapReAlloc(hHeap,0,ppdi,(num+1)*sizeof(DllProc *)); 207 209 ppdi[num]=pDllProc; 208 210 … … 220 222 221 223 CSubAddrSchedule::CSubAddrSchedule(){ 222 ppsi=( UserProc **)HeapAlloc(hHeap,0,1);224 ppsi=(const UserProc **)HeapAlloc(hHeap,0,1); 223 225 pbCall=(BOOL *)HeapAlloc(hHeap,0,1); 224 226 } … … 228 230 } 229 231 230 void CSubAddrSchedule::add( UserProc *pUserProc,BOOL bCall){232 void CSubAddrSchedule::add(const UserProc *pUserProc,BOOL bCall){ 231 233 if(!pUserProc) return; 232 234 233 ppsi=( UserProc **)HeapReAlloc(hHeap,0,ppsi,(num+1)*sizeof(UserProc *));235 ppsi=(const UserProc **)HeapReAlloc(hHeap,0,ppsi,(num+1)*sizeof(UserProc *)); 234 236 ppsi[num]=pUserProc; 235 237 pbCall=(BOOL *)HeapReAlloc(hHeap,0,pbCall,(num+1)*sizeof(BOOL)); -
trunk/abdev/BasicCompiler_Common/PESchedule.h
r182 r206 1 1 #pragma once 2 2 3 #include <jenga/include/smoothie/Procedure.h> 3 4 class UserProc; 5 class DllProc; 6 4 7 5 8 /////////////////////// … … 65 68 class CImportAddrSchedule:public CSchedule{ 66 69 public: 67 DllProc **ppdi;70 const DllProc **ppdi; 68 71 69 72 CImportAddrSchedule(); 70 73 ~CImportAddrSchedule(); 71 74 72 void add( DllProc *pDllProc);75 void add(const DllProc *pDllProc); 73 76 }; 74 77 extern CImportAddrSchedule *pobj_ImportAddrSchedule; … … 81 84 class CSubAddrSchedule:public CSchedule{ 82 85 public: 83 UserProc **ppsi;86 const UserProc **ppsi; 84 87 BOOL *pbCall; 85 88 … … 87 90 ~CSubAddrSchedule(); 88 91 89 void add( UserProc *pUserProc,BOOL bCall);92 void add(const UserProc *pUserProc,BOOL bCall); 90 93 }; 91 94 extern CSubAddrSchedule *pobj_SubAddrSchedule; -
trunk/abdev/BasicCompiler_Common/ParamImpl.cpp
r182 r206 1 #include "stdafx.h" 2 1 3 #include <Program.h> 2 4 … … 197 199 } 198 200 199 UserProc *ParamImpl::_OverloadSolution( const char *name, std::vector<UserProc *> &subs, bool isEnabledReturnType ){201 const UserProc *ParamImpl::_OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType ){ 200 202 int sw=0; 201 UserProc *pUserProc;203 const UserProc *pUserProc; 202 204 pUserProc=0; 203 205 204 206 for( int level=OVERLOAD_MIN_LEVEL; level<=OVERLOAD_MAX_LEVEL; level++ ){ 205 207 206 BOOST_FOREACH( UserProc *pTempUserProc, subs ){208 BOOST_FOREACH( const UserProc *pTempUserProc, subs ){ 207 209 208 210 if(EvaluateOverloadScore( level, pTempUserProc->Params(), isEnabledReturnType?pTempUserProc->ReturnType():Type() )){ … … 237 239 238 240 if(!sw){ 239 BOOST_FOREACH( UserProc *pTempUserProc, subs ){241 BOOST_FOREACH( const UserProc *pTempUserProc, subs ){ 240 242 241 243 //エラーチェック … … 261 263 return pUserProc; 262 264 } 263 UserProc *ParamImpl::OverloadSolution( const char *name, std::vector<UserProc *> &subs, bool isEnabledReturnType ){265 const UserProc *ParamImpl::OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType ){ 264 266 trace_for_overload( "" ); 265 267 trace_for_overload( "■■■■■■■■■■■■■■■■■■" ); 266 268 trace_for_overload( "■■■ オーバーロード解決(" << name << ")" ); 267 269 268 UserProc *result = _OverloadSolution( name, subs, isEnabledReturnType );270 const UserProc *result = _OverloadSolution( name, subs, isEnabledReturnType ); 269 271 270 272 trace_for_overload( "■■■ ここまで" ); -
trunk/abdev/BasicCompiler_Common/RSrcSection.cpp
r4 r206 1 #include "stdafx.h" 2 1 3 #include "../BasicCompiler_Common/common.h" 2 4 -
trunk/abdev/BasicCompiler_Common/Resource.cpp
r182 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/LexicalAnalysis.h> 4 5 #include <Type.h> 2 6 3 7 #include "common.h" -
trunk/abdev/BasicCompiler_Common/StrOperation.cpp
r182 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/LexicalAnalysis.h> 4 #include <jenga/include/smoothie/Source.h> 2 5 3 6 #include "../BasicCompiler_Common/common.h" … … 406 409 } 407 410 } 408 void GetCalcName(int idCalc,char *name){ 409 switch(idCalc){ 410 case CALC_XOR: 411 lstrcpy(name,"xor"); 412 break; 413 case CALC_OR: 414 lstrcpy(name,"or"); 415 break; 416 case CALC_AND: 417 lstrcpy(name,"and"); 418 break; 419 case CALC_NOT: 420 lstrcpy(name,"Not"); 421 break; 422 423 case CALC_PE: 424 lstrcpy(name,"<="); 425 break; 426 case CALC_QE: 427 lstrcpy(name,">="); 428 break; 429 case CALC_NOTEQUAL: 430 lstrcpy(name,"<>"); 431 break; 432 case CALC_SUBSITUATION: 433 case CALC_EQUAL: 434 lstrcpy(name,"="); 435 break; 436 case CALC_P: 437 lstrcpy(name,"<"); 438 break; 439 case CALC_Q: 440 lstrcpy(name,">"); 441 break; 442 443 case CALC_SHL: 444 lstrcpy(name,"<<"); 445 break; 446 case CALC_SHR: 447 lstrcpy(name,">>"); 448 break; 449 case CALC_ADDITION: 450 lstrcpy(name,"+"); 451 break; 452 case CALC_SUBTRACTION: 453 lstrcpy(name,"-"); 454 break; 455 case CALC_MOD: 456 lstrcpy(name,"mod"); 457 break; 458 case CALC_PRODUCT: 459 lstrcpy(name,"*"); 460 break; 461 case CALC_QUOTIENT: 462 lstrcpy(name,"/"); 463 break; 464 case CALC_INTQUOTIENT: 465 lstrcpy(name,"\\"); 466 break; 467 case CALC_AS: 468 lstrcpy(name,"As"); 469 break; 470 case CALC_BYVAL: 471 lstrcpy(name,"ByVal"); 472 break; 473 case CALC_MINUSMARK: 474 lstrcpy(name,"-"); 475 break; 476 case CALC_POWER: 477 lstrcpy(name,"^"); 478 break; 479 480 case CALC_ARRAY_GET: 481 lstrcpy(name,"[]"); 482 break; 483 case CALC_ARRAY_SET: 484 lstrcpy(name,"[]="); 485 break; 486 } 411 const std::string &FormatEscapeSequenceStringToDefaultString( const std::string &source ) 412 { 413 int maxLength = (int)source.size(); 414 415 char *temporary = (char *)malloc( source.size() + 8192 ); 416 lstrcpy( temporary, source.c_str() ); 417 418 for( int i=0; i<maxLength-1; i++ ) 419 { 420 if( temporary[i] == 1 ) 421 { 422 char temp2[255]; 423 GetDefaultNameFromES( temporary[i+1], temp2 ); 424 if( i>0 ) 425 { 426 char temp3[255]; 427 wsprintf( temp3, " %s", temp2 ); 428 lstrcpy( temp2, temp3 ); 429 } 430 if( i<maxLength-2 ) 431 { 432 lstrcat( temp2, " " ); 433 } 434 435 int length = lstrlen( temp2 ); 436 SlideString( temporary + i+2, length-2 ); 437 memcpy( temporary + i, temp2, length ); 438 maxLength = lstrlen( temporary ); 439 } 440 } 441 442 static std::string resultStr = ""; 443 resultStr = temporary; 444 445 free( temporary ); 446 447 return resultStr; 487 448 } 488 449 -
trunk/abdev/BasicCompiler_Common/Subroutine.cpp
r199 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 #include <jenga/include/smoothie/LexicalAnalysis.h> 3 5 4 6 #include <Compiler.h> 5 #include <Procedure Impl.h>7 #include <Procedure.h> 6 8 #include <NamespaceSupporter.h> 7 9 … … 103 105 ///////////////////// 104 106 105 UserProc *pUserProc = (UserProc *)pProc;107 const UserProc *pUserProc = (const UserProc *)pProc; 106 108 107 109 //オブジェクト名を取得 … … 115 117 //////////////////////// 116 118 117 std::vector< UserProc *> subs;119 std::vector<const UserProc *> subs; 118 120 GetOverloadSubHash(fullCallName,subs); 119 121 if(subs.size()){ … … 194 196 195 197 //オーバーロード用の関数リストを作成 196 std::vector< UserProc *> subs;198 std::vector<const UserProc *> subs; 197 199 GetOverloadSubHash(VarName,subs); 198 200 if(subs.size()==0){ … … 210 212 211 213 //オーバーロードを解決 212 UserProc *pUserProc; 213 pUserProc=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName); 214 const UserProc *pUserProc = OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName); 214 215 215 216 if(pUserProc){ … … 238 239 239 240 //オーバーロード用の関数リストを作成 240 std::vector< UserProc *> subs;241 std::vector<const UserProc *> subs; 241 242 GetOverloadSubHash(VarName,subs); 242 243 if(subs.size()==0){ … … 254 255 255 256 //オーバーロードを解決 256 UserProc *pUserProc; 257 pUserProc=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName); 257 const UserProc *pUserProc = OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName); 258 258 259 259 if(pUserProc){ … … 266 266 //インデクサ(getter)の戻り値を取得 267 267 bool GetReturnTypeOfIndexerGetterProc( const CClass &objClass, Type &resultType ){ 268 vector< UserProc *> subs;268 vector<const UserProc *> subs; 269 269 objClass.GetMethods().Enum( CALC_ARRAY_GET, subs ); 270 270 if( subs.size() == 0 ){ … … 369 369 370 370 // オブジェクトを生成 371 DllProc *pDllProc = new DllProc Impl( namespaceScopes, procName, kind, isCdecl, dllFileName, alias );371 DllProc *pDllProc = new DllProc( namespaceScopes, procName, kind, isCdecl, dllFileName, alias ); 372 372 373 373 // パラメータを解析 … … 429 429 } 430 430 431 GlobalProc *AddSubData( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,bool isVirtual,CClass *pobj_c, bool isStatic){ 432 int i2,i3; 433 char temporary[8192]; 434 435 int i=1; 436 437 Procedure::Kind kind = Procedure::Sub; 438 bool isMacro = false; 439 if(buffer[i]==ESC_FUNCTION) kind = Procedure::Function; 440 if(buffer[i]==ESC_MACRO){ 441 isMacro = true; 442 } 443 444 i++; 445 446 bool isCdecl = false; 447 bool isExport = false; 448 while(1){ 449 if(buffer[i]==1&&buffer[i+1]==ESC_CDECL&& isCdecl == false ){ 450 isCdecl = true; 451 452 i+=2; 453 } 454 else if(buffer[i]==1&&buffer[i+1]==ESC_EXPORT&& isExport == false ){ 455 isExport = true; 456 457 i+=2; 458 } 459 else break; 460 } 461 462 i2=0; 463 if(buffer[i]==1&&buffer[i+1]==ESC_OPERATOR){ 464 if(!pobj_c){ 465 SetError(126,NULL,nowLine); 466 return 0; 467 } 468 469 //オペレータの場合 470 temporary[i2++]=buffer[i++]; 471 temporary[i2++]=buffer[i++]; 472 473 int iCalcId; 474 if(buffer[i]=='='&&buffer[i+1]=='='){ 475 iCalcId=CALC_EQUAL; 476 i3=2; 477 } 478 else if(buffer[i]=='='){ 479 iCalcId=CALC_SUBSITUATION; 480 i3=1; 481 } 482 else if(buffer[i]=='('){ 483 iCalcId=CALC_AS; 484 i3=0; 485 } 486 else if(buffer[i]=='['&&buffer[i+1]==']'&&buffer[i+2]=='='){ 487 iCalcId=CALC_ARRAY_SET; 488 i3=3; 489 } 490 else if(buffer[i]=='['&&buffer[i+1]==']'){ 491 iCalcId=CALC_ARRAY_GET; 492 i3=2; 493 } 494 else{ 495 iCalcId=GetCalcId(buffer+i,&i3); 496 i3++; 497 } 498 if(!iCalcId){ 499 SetError(1,NULL,nowLine); 500 return 0; 501 } 502 temporary[i2++]=iCalcId; 503 temporary[i2]=0; 504 505 i+=i3; 506 } 507 else{ 508 if(pobj_c){ 509 //クラスメンバの場合、デストラクタには~が付くことを考慮 510 if(buffer[i]=='~'){ 511 temporary[i2]='~'; 512 i++; 513 i2++; 514 } 515 } 516 517 for(;;i++,i2++){ 518 if(!IsVariableChar(buffer[i])){ 519 temporary[i2]=0; 520 break; 521 } 522 temporary[i2]=buffer[i]; 523 } 524 } 525 526 if( isMacro ){ 527 //大文字に変換 528 CharUpper(temporary); 529 530 //マクロ関数の場合は名前リストに追加 531 extern char **ppMacroNames; 532 extern int MacroNum; 533 ppMacroNames=(char **)HeapReAlloc(hHeap,0,ppMacroNames,(MacroNum+1)*sizeof(char *)); 534 ppMacroNames[MacroNum]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1); 535 lstrcpy(ppMacroNames[MacroNum],temporary); 536 MacroNum++; 537 } 538 539 if(!pobj_c){ 540 //クラスメンバ以外の場合のみ 541 //重複チェック 542 543 if(GetDeclareHash(temporary)){ 544 SetError(15,temporary,nowLine); 545 return 0; 546 } 547 } 548 549 extern int SubNum; 550 SubNum++; 551 552 GlobalProc *pUserProc = new GlobalProc( namespaceScopes, importedNamespaces, temporary, kind, isMacro, isCdecl, isExport ); 553 pUserProc->SetParentClass( pobj_c ); 554 if( Smoothie::isFullCompile ){ 555 // すべての関数・メソッドをコンパイルする 556 pUserProc->Using(); 557 } 558 559 //ID 560 static int id_base=0; 561 pUserProc->id = (id_base++); 562 563 if(isExport){ 564 pUserProc->Using(); 565 } 566 567 // パラメータを解析 568 // ※第1パラメータにに指定するデータの例:"( s As String ) As String" 569 pUserProc->SetParamsAndReturnType( buffer + i, nowLine, isStatic ); 570 571 pUserProc->_paramStr = buffer + i; 572 573 574 ///////////////////////////////// 575 // ハッシュデータに追加 576 ///////////////////////////////// 577 578 int key; 579 key=hash_default(pUserProc->GetName().c_str()); 580 581 extern GlobalProc **ppSubHash; 582 if(ppSubHash[key]){ 583 GlobalProc *psi2; 584 psi2=ppSubHash[key]; 585 while(1){ 586 if(pobj_c==psi2->GetParentClassPtr()){ 587 //重複エラーチェックを行う 588 if( pUserProc->IsEqualSymbol( *psi2 ) ){ 589 if( psi2->Params().Equals( pUserProc->Params() ) ){ 590 SetError(15,pUserProc->GetName().c_str(),nowLine); 591 return 0; 592 } 593 } 594 } 595 596 if(psi2->pNextData==0) break; 597 psi2=psi2->pNextData; 598 } 599 psi2->pNextData=pUserProc; 600 } 601 else{ 602 ppSubHash[key]=pUserProc; 603 } 604 605 return pUserProc; 606 } 607 608 void GetSubInfo(void){ //サブルーチン情報を取得 431 void UserProcs::CollectUserProcs( const BasicSource &source, UserProcs &userProcs ) 432 { 609 433 extern HANDLE hHeap; 610 extern char *basbuf;611 434 int i,i2,i3; 612 435 char temporary[8192]; … … 617 440 618 441 //サブルーチン(ユーザー定義)情報を初期化 619 extern GlobalProc **ppSubHash; 620 extern int SubNum; 621 ppSubHash=(GlobalProc **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(GlobalProc *)); 622 SubNum=0; 623 624 //マクロ関数の名前リストを初期化 625 extern char **ppMacroNames; 626 extern int MacroNum; 627 ppMacroNames=(char **)HeapAlloc(hHeap,0,1); 628 MacroNum=0; 442 userProcs.Clear(); 629 443 630 444 // 名前空間管理 … … 640 454 i++; 641 455 642 if( basbuf[i]==1&&(basbuf[i+1]==ESC_CLASS||basbuf[i+1]==ESC_INTERFACE)){456 if(source[i]==1&&(source[i+1]==ESC_CLASS||source[i+1]==ESC_INTERFACE)){ 643 457 /* Class ~ End Class 644 458 Interface ~ End Interface 645 459 を飛び越す */ 646 i3=GetEndXXXCommand( basbuf[i+1]);460 i3=GetEndXXXCommand(source[i+1]); 647 461 for(i+=2,i2=0;;i++,i2++){ 648 if( basbuf[i]=='\0') break;649 if( basbuf[i]==1&&basbuf[i+1]==(char)i3){462 if(source[i]=='\0') break; 463 if(source[i]==1&&source[i+1]==(char)i3){ 650 464 i++; 651 465 break; 652 466 } 653 467 } 654 if( basbuf[i]=='\0') break;655 continue; 656 } 657 658 if( basbuf[i] == 1 && basbuf[i+1] == ESC_NAMESPACE ){468 if(source[i]=='\0') break; 469 continue; 470 } 471 472 if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){ 659 473 for(i+=2,i2=0;;i2++,i++){ 660 if( IsCommandDelimitation( basbuf[i] ) ){474 if( IsCommandDelimitation( source[i] ) ){ 661 475 temporary[i2]=0; 662 476 break; 663 477 } 664 temporary[i2]= basbuf[i];478 temporary[i2]=source[i]; 665 479 } 666 480 namespaceScopes.push_back( temporary ); … … 668 482 continue; 669 483 } 670 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_ENDNAMESPACE ){484 else if( source[i] == 1 && source[i+1] == ESC_ENDNAMESPACE ){ 671 485 if( namespaceScopes.size() <= 0 ){ 672 486 SetError(12, "End Namespace", i ); … … 679 493 continue; 680 494 } 681 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_IMPORTS ){495 else if( source[i] == 1 && source[i+1] == ESC_IMPORTS ){ 682 496 for(i+=2,i2=0;;i2++,i++){ 683 if( IsCommandDelimitation( basbuf[i] ) ){497 if( IsCommandDelimitation( source[i] ) ){ 684 498 temporary[i2]=0; 685 499 break; 686 500 } 687 temporary[i2]= basbuf[i];501 temporary[i2]=source[i]; 688 502 } 689 503 if( !compiler.GetNamespaceSupporter().ImportsNamespace( temporary ) ) … … 694 508 continue; 695 509 } 696 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_CLEARNAMESPACEIMPORTED ){510 else if( source[i] == 1 && source[i+1] == ESC_CLEARNAMESPACEIMPORTED ){ 697 511 importedNamespaces.clear(); 698 512 continue; 699 513 } 700 514 701 if( basbuf[i]==1&&basbuf[i+1]==ESC_DECLARE){515 if(source[i]==1&&source[i+1]==ESC_DECLARE){ 702 516 for(i+=2,i2=0;;i2++,i++){ 703 if( basbuf[i]=='\n'){517 if(source[i]=='\n'){ 704 518 temporary[i2]=0; 705 519 break; 706 520 } 707 temporary[i2]= basbuf[i];708 if( basbuf[i]=='\0') break;521 temporary[i2]=source[i]; 522 if(source[i]=='\0') break; 709 523 } 710 524 AddDeclareData(namespaceScopes,temporary,i); … … 712 526 continue; 713 527 } 714 if( basbuf[i]==1&&(basbuf[i+1]==ESC_SUB||basbuf[i+1]==ESC_FUNCTION||basbuf[i+1]==ESC_MACRO)){715 char statementChar = basbuf[i+1];528 if(source[i]==1&&(source[i+1]==ESC_SUB||source[i+1]==ESC_FUNCTION||source[i+1]==ESC_MACRO)){ 529 char statementChar = source[i+1]; 716 530 717 531 for(i2=0;;i2++,i++){ 718 if(IsCommandDelimitation( basbuf[i])){532 if(IsCommandDelimitation(source[i])){ 719 533 temporary[i2]=0; 720 534 break; 721 535 } 722 temporary[i2]= basbuf[i];723 if( basbuf[i]=='\0') break;724 } 725 AddSubData(namespaceScopes, importedNamespaces, temporary,i,0,0);536 temporary[i2]=source[i]; 537 if(source[i]=='\0') break; 538 } 539 userProcs.Add(namespaceScopes, importedNamespaces, temporary,i,false,NULL,false); 726 540 727 541 /* Sub ~ End Sub … … 731 545 char endStatementChar = GetEndXXXCommand( statementChar ); 732 546 for(i2=0;;i++,i2++){ 733 if( basbuf[i] == '\0' ) break;734 if( basbuf[i] == 1 && basbuf[i+1] == endStatementChar ){547 if( source[i] == '\0' ) break; 548 if( source[i] == 1 && source[i+1] == endStatementChar ){ 735 549 i++; 736 550 break; 737 551 } 738 552 } 739 if( basbuf[i]=='\0') break;553 if(source[i]=='\0') break; 740 554 continue; 741 555 } … … 743 557 //次の行 744 558 for(;;i++){ 745 if(IsCommandDelimitation( basbuf[i])) break;746 } 747 if( basbuf[i]=='\0') break;559 if(IsCommandDelimitation(source[i])) break; 560 } 561 if(source[i]=='\0') break; 748 562 } 749 563 … … 755 569 756 570 sprintf(temporary,"%c%c_allrem()",1,ESC_SUB); 757 AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);571 userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false); 758 572 759 573 sprintf(temporary,"%c%c_aullrem()",1,ESC_SUB); 760 AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);574 userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false); 761 575 762 576 sprintf(temporary,"%c%c_allmul()",1,ESC_SUB); 763 AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);577 userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false); 764 578 765 579 sprintf(temporary,"%c%c_alldiv()",1,ESC_SUB); 766 AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);580 userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false); 767 581 768 582 sprintf(temporary,"%c%c_aulldiv()",1,ESC_SUB); 769 AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);583 userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false); 770 584 771 585 sprintf(temporary,"%c%c_allshl()",1,ESC_SUB); 772 AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);586 userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false); 773 587 774 588 sprintf(temporary,"%c%c_allshr()",1,ESC_SUB); 775 AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);589 userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false); 776 590 777 591 sprintf(temporary,"%c%c_aullshr()",1,ESC_SUB); 778 AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);592 userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false); 779 593 780 594 sprintf(temporary,"%c%c_System_InitStaticLocalVariables()",1,ESC_SUB); 781 AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0); 782 } 783 void Delete_si(GlobalProc *pUserProc){ 784 if(pUserProc->pNextData) Delete_si(pUserProc->pNextData); 785 delete pUserProc; 786 } 787 void DeleteSubInfo(GlobalProc **ppSubHash,char **ppMacroNames,int MacroNum){ //サブルーチン情報のメモリ解放 788 int i; 789 for(i=0;i<MAX_HASH;i++){ 790 if(!ppSubHash[i]) continue; 791 792 Delete_si(ppSubHash[i]); 793 } 794 HeapDefaultFree(ppSubHash); 795 796 //マクロの名前リスト 797 if(ppMacroNames){ 798 for(i=0;i<MacroNum;i++){ 799 HeapDefaultFree(ppMacroNames[i]); 800 } 801 HeapDefaultFree(ppMacroNames); 802 } 595 userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false); 803 596 } 804 597 void Delete_di(DllProc *pDllProc){ … … 820 613 821 614 bool IsNeedProcCompile(){ 822 for(int i2=0;i2<MAX_HASH;i2++){ 823 extern GlobalProc **ppSubHash; 824 GlobalProc *pUserProc=ppSubHash[i2]; 825 while(pUserProc){ 826 if( pUserProc->IsUsing() && pUserProc->IsCompiled() == false ){ 827 return true; 828 } 829 830 pUserProc=pUserProc->pNextData; 615 compiler.GetMeta().GetUserProcs().Iterator_Reset(); 616 while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() ) 617 { 618 UserProc *pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext(); 619 if( pUserProc->IsUsing() && pUserProc->IsCompiled() == false ){ 620 return true; 831 621 } 832 622 } -
trunk/abdev/BasicCompiler_Common/VarList.cpp
r182 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 4 5 #include <Compiler.h> 2 6 3 7 #include "../BasicCompiler_Common/common.h" … … 9 13 HWND hVarTree_Global,hVarTree_Local,hVarTree_This; 10 14 11 int VarList_Array(HWND hVarTree,HTREEITEM hParent,LONG_PTR offset,const Type &type,const int *SubScripts);15 int VarList_Array(HWND hVarTree,HTREEITEM hParent,LONG_PTR offset,const Type &type,const Subscripts &subscripts); 12 16 void VarList_Member(HWND hVarTree,HTREEITEM hParent,LONG_PTR pTopOffset,const CClass &objClass,BOOL bPtr); 13 17 void VarList_Insert(HWND hVarTree,TV_INSERTSTRUCT *lptv,const char *VarName,const Type &type,LONG_PTR offset){ … … 180 184 offset=objClass.GetMemberOffset( pMember->GetName().c_str(), &i2 ); 181 185 182 if( pMember->SubScripts[0]!=-1){186 if( pMember->GetSubscripts().size() > 0 ){ 183 187 //構造体内の配列 184 188 sprintf(VarData,"%s %s(&H%X)",VarName,STRING_ARRAY,pTopOffset+offset); … … 187 191 hParent=TreeView_InsertItem(hVarTree,&tv); 188 192 189 VarList_Array(hVarTree,hParent, 190 pTopOffset+offset, 193 VarList_Array( 194 hVarTree, 195 hParent, 196 pTopOffset + offset, 191 197 pMember->GetType(), 192 pMember->SubScripts); 198 pMember->GetSubscripts() 199 ); 193 200 } 194 201 else{ … … 202 209 } 203 210 } 204 int VarList_Array(HWND hVarTree,HTREEITEM hParent,LONG_PTR offset,const Type &type, const int *SubScripts ){211 int VarList_Array(HWND hVarTree,HTREEITEM hParent,LONG_PTR offset,const Type &type, const Subscripts &subscripts ){ 205 212 int i,i2,i3,ElementNum,MemCounter,UseCount[255]; 206 213 char temporary[VN_SIZE],temp2[DIGIT_SIZE]; … … 213 220 tv.item.pszText=temporary; 214 221 215 for(i=0;i<255;i++){ 216 if(SubScripts[i]==-1) break; 222 for(i=0;i<(int)subscripts.size();i++){ 217 223 UseCount[i]=0; 218 224 } … … 221 227 while(1){ 222 228 UseCount[i]++; 223 for(ElementNum=0; SubScripts[i-ElementNum]<UseCount[i-ElementNum];ElementNum++){229 for(ElementNum=0;subscripts[i-ElementNum]<UseCount[i-ElementNum];ElementNum++){ 224 230 UseCount[i-ElementNum]=0; 225 231 if(i-ElementNum-1<0) return MemCounter; … … 268 274 extern int MemPos_RWSection; 269 275 270 BOOST_FOREACH( Variable *pVar, globalVars){276 BOOST_FOREACH( Variable *pVar, compiler.GetMeta().GetGlobalVars() ){ 271 277 272 278 //スコープ外の場合は無視 273 if(pVar-> ScopeLevel!=0){274 if(rva_to_real(pVar-> ScopeStartAddress) <= pobj_dti->lplpObp[0] &&275 pobj_dti->lplpObp[0] < rva_to_real(pVar-> ScopeEndAddress)){279 if(pVar->GetScopeLevel()!=0){ 280 if(rva_to_real(pVar->GetScopeStartAddress()) <= pobj_dti->lplpObp[0] && 281 pobj_dti->lplpObp[0] < rva_to_real(pVar->GetScopeEndAddress())){ 276 282 //範囲内 277 283 } … … 304 310 pVar->GetName().c_str(), 305 311 STRING_ARRAY, 306 ImageBase+MemPos_RWSection+pVar-> offset);312 ImageBase+MemPos_RWSection+pVar->GetOffsetAddress()); 307 313 tv.item.iImage=0; 308 314 tv.item.iSelectedImage=0; 309 315 hParent=TreeView_InsertItem(hVarTree_Global,&tv); 310 316 311 VarList_Array(hVarTree_Global,hParent, 312 (LONG_PTR)(ImageBase+MemPos_RWSection+pVar->offset), 313 *pVar, 314 pVar->GetSubScriptsPtr()); 317 VarList_Array( 318 hVarTree_Global, 319 hParent, 320 (LONG_PTR)(ImageBase+MemPos_RWSection + pVar->GetOffsetAddress()), 321 pVar->GetType(), 322 pVar->GetSubscripts() 323 ); 315 324 } 316 325 else{ … … 318 327 &tv, 319 328 pVar->GetName().c_str(), 320 *pVar,321 (LONG_PTR)(ImageBase+MemPos_RWSection+pVar-> offset));329 pVar->GetType(), 330 (LONG_PTR)(ImageBase+MemPos_RWSection+pVar->GetOffsetAddress())); 322 331 } 323 332 } 324 333 } 325 334 void RefreshLocalVar(void){ 326 int i2 ,i3,sw;335 int i2; 327 336 char temporary[VN_SIZE]; 328 337 TV_INSERTSTRUCT tv; … … 347 356 if(pobj_dti->lplpSpBase[i2]==0) return; 348 357 349 extern GlobalProc **ppSubHash; 350 GlobalProc *pUserProc; 351 for(i3=0,sw=0;i3<MAX_HASH;i3++){ 352 pUserProc=ppSubHash[i3]; 353 while(pUserProc){ 354 if(rva_to_real(pUserProc->beginOpAddress) <= pobj_dti->lplpObp[i2] && 355 pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->endOpAddress)){ 356 sw=1; 357 break; 358 } 359 360 pUserProc=pUserProc->pNextData; 361 } 362 if(sw) break; 358 UserProc *pUserProc = NULL; 359 compiler.GetMeta().GetUserProcs().Iterator_Reset(); 360 while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() ) 361 { 362 pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext(); 363 if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2] && 364 pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->GetEndOpAddress())){ 365 break; 366 } 363 367 } 364 368 if(!pUserProc) return; 365 369 366 BOOST_FOREACH( Variable *pVar, pUserProc-> localVars){370 BOOST_FOREACH( Variable *pVar, pUserProc->GetLocalVars() ){ 367 371 368 372 //スコープ外の場合は無視 369 if(pVar-> ScopeLevel!=0){370 if(rva_to_real(pVar-> ScopeStartAddress) <= pobj_dti->lplpObp[i2] &&371 pobj_dti->lplpObp[i2] < rva_to_real(pVar-> ScopeEndAddress)){373 if(pVar->GetScopeLevel()!=0){ 374 if(rva_to_real(pVar->GetScopeStartAddress()) <= pobj_dti->lplpObp[i2] && 375 pobj_dti->lplpObp[i2] < rva_to_real(pVar->GetScopeEndAddress())){ 372 376 //範囲内 373 377 } … … 382 386 pVar->GetName().c_str(), 383 387 STRING_ARRAY, 384 pobj_dti->lplpSpBase[i2]+pVar-> offset);388 pobj_dti->lplpSpBase[i2]+pVar->GetOffsetAddress()); 385 389 tv.item.iImage=0; 386 390 tv.item.iSelectedImage=0; 387 391 hParent=TreeView_InsertItem(hVarTree_Local,&tv); 388 392 389 VarList_Array(hVarTree_Local,hParent, 390 pobj_dti->lplpSpBase[i2]+pVar->offset, 391 *pVar, 392 pVar->GetSubScriptsPtr()); 393 VarList_Array( 394 hVarTree_Local, 395 hParent, 396 pobj_dti->lplpSpBase[i2] + pVar->GetOffsetAddress(), 397 pVar->GetType(), 398 pVar->GetSubscripts() 399 ); 393 400 } 394 401 else{ 395 offset=pobj_dti->lplpSpBase[i2]+pVar-> offset;402 offset=pobj_dti->lplpSpBase[i2]+pVar->GetOffsetAddress(); 396 403 if(pVar->IsRef()){ 397 404 ReadProcessMemory(hDebugProcess,(void *)offset,&lpData,sizeof(LONG_PTR),&accessBytes); … … 400 407 VarList_Insert(hVarTree_Local,&tv, 401 408 pVar->GetName().c_str(), 402 *pVar,409 pVar->GetType(), 403 410 offset); 404 411 } … … 416 423 //Thisポインタを取得 417 424 LONG_PTR pThis; 418 const Variable *pVar = pUserProc-> localVars.Find( Symbol( "_System_LocalThis" ) );425 const Variable *pVar = pUserProc->GetLocalVars().Find( Symbol( "_System_LocalThis" ) ); 419 426 if( !pVar ){ 420 427 return; 421 428 } 422 lpData=pobj_dti->lplpSpBase[i2]+pVar-> offset;429 lpData=pobj_dti->lplpSpBase[i2]+pVar->GetOffsetAddress(); 423 430 ReadProcessMemory(hDebugProcess,(void *)lpData,&pThis,sizeof(LONG_PTR),&accessBytes); 424 431 … … 426 433 offset=pUserProc->GetParentClassPtr()->GetMemberOffset( pMember->GetName().c_str(),&i2); 427 434 428 if( pMember->SubScripts[0]!=-1){435 if( pMember->GetSubscripts().size() > 0 ){ 429 436 //配列 430 437 sprintf(temporary,"%s %s(&H%X)", … … 436 443 hParent=TreeView_InsertItem(hVarTree_This,&tv); 437 444 438 VarList_Array(hVarTree_This,hParent, 439 pThis+offset, 445 VarList_Array( 446 hVarTree_This, 447 hParent, 448 pThis + offset, 440 449 pMember->GetType(), 441 pMember->SubScripts); 450 pMember->GetSubscripts() 451 ); 442 452 } 443 453 else{ … … 590 600 591 601 //プロシージャ コンボボックス 592 extern GlobalProc **ppSubHash;593 GlobalProc *pUserProc;594 int sw;595 602 SendMessage(hProcCombo,CB_RESETCONTENT,0,0); 596 603 for(i2=pobj_dti->iProcLevel;i2>=0;i2--){ 597 for(i3=0,sw=0;i3<MAX_HASH;i3++){ 598 pUserProc=ppSubHash[i3]; 599 while(pUserProc){ 600 if(rva_to_real(pUserProc->beginOpAddress) <= pobj_dti->lplpObp[i2] && 601 pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->endOpAddress)){ 602 lstrcpy(temporary,pUserProc->GetName().c_str()); 603 sw=1; 604 break; 605 } 606 pUserProc=pUserProc->pNextData; 607 } 608 if(sw) break; 604 605 UserProc *pUserProc = NULL; 606 compiler.GetMeta().GetUserProcs().Iterator_Reset(); 607 while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() ) 608 { 609 pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext(); 610 611 if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2] && 612 pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->GetEndOpAddress())) 613 { 614 lstrcpy(temporary,pUserProc->GetName().c_str()); 615 break; 616 } 609 617 } 610 618 if(!pUserProc){ … … 675 683 void InitVarList(DWORD dwThreadId){ 676 684 extern HWND hDebugWnd; 677 int i2,i 3,i5;685 int i2,i5; 678 686 char temporary[255]; 679 687 … … 703 711 /////////////////////////////////////////////// 704 712 705 int sw;706 707 713 i2=(int)SendDlgItemMessage(hDebugWnd,IDC_PROCCOMBO,CB_GETCURSEL,0,0); 708 714 i2=pobj_dti->iProcLevel-i2; 709 715 710 716 if(pobj_dti->lplpSpBase[i2]){ 711 extern GlobalProc **ppSubHash; 712 GlobalProc *pUserProc; 713 for(i3=0,sw=0;i3<MAX_HASH;i3++){ 714 pUserProc=ppSubHash[i3]; 715 while(pUserProc){ 716 if(rva_to_real(pUserProc->beginOpAddress) <= pobj_dti->lplpObp[i2] && 717 pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->endOpAddress)){ 718 sw=1; 719 break; 720 } 721 722 pUserProc=pUserProc->pNextData; 723 } 724 if(sw) break; 725 } 726 717 718 UserProc *pUserProc = NULL; 719 compiler.GetMeta().GetUserProcs().Iterator_Reset(); 720 while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() ) 721 { 722 pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext(); 723 724 if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2] && 725 pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->GetEndOpAddress())){ 726 break; 727 } 728 } 727 729 728 730 if(pUserProc){ 729 Smoothie::Temp::pCompilingClass = pUserProc->GetParentClassPtr();731 compiler.pCompilingClass = pUserProc->GetParentClassPtr(); 730 732 UserProc::CompileStartForUserProc( pUserProc ); 731 733 } -
trunk/abdev/BasicCompiler_Common/VariableOpe.cpp
r199 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 #include <jenga/include/smoothie/LexicalAnalysis.h> … … 4 6 #include <Compiler.h> 5 7 #include <LexicalScopingImpl.h> 6 #include <Variable Impl.h>8 #include <Variable.h> 7 9 #include <NamespaceSupporter.h> 8 10 … … 247 249 248 250 249 void GetArrange(char *variable,char *variAnswer, int *SubScripts){251 void GetArrange(char *variable,char *variAnswer, Subscripts &subscripts ){ 250 252 extern int cp; 251 int i,i2,i 3,i4;253 int i,i2,i4; 252 254 double dbl; 253 255 _int64 i64data; … … 261 263 262 264 variAnswer[i]=0; 263 for(i++,i2=0 ,i3=0;;i++,i2++){265 for(i++,i2=0;;i++,i2++){ 264 266 if(variable[i]==','){ 265 267 temporary[i2]=0; … … 274 276 } 275 277 276 if(i64data<0){ 278 if(i64data<0) 279 { 277 280 //error 278 SubScripts[i3]=0;281 subscripts.push_back( 0 ); 279 282 } 280 else SubScripts[i3]=(int)i64data; 281 i3++; 283 else 284 { 285 subscripts.push_back( (int)i64data ); 286 } 282 287 i2=-1; 283 288 continue; … … 299 304 temporary[i2]=0; 300 305 if(i2==0){ 301 SubScripts[i3]=-2;306 subscripts.push_back( -2 ); 302 307 break; 303 308 } … … 314 319 if(i64data<0){ 315 320 //error 316 SubScripts[i3]=0;321 subscripts.push_back( 0 ); 317 322 } 318 else SubScripts[i3]=(int)i64data; 319 SubScripts[i3+1]=-1; 323 else 324 { 325 subscripts.push_back( (int)i64data ); 326 } 320 327 break; 321 328 } … … 330 337 variAnswer[i]=variable[i]; 331 338 if(variable[i]=='\0'){ 332 SubScripts[0]=-1;333 339 break; 334 340 } … … 337 343 338 344 339 BOOL GetVarFormatString(char *buffer,char *array,char *array2,char *NestMember, CClass::RefType&refType){345 BOOL GetVarFormatString(char *buffer,char *array,char *array2,char *NestMember,ReferenceKind &refType){ 340 346 extern int cp; 341 347 int i,i2,i3; … … 403 409 if(buffer[i]=='.'){ 404 410 lstrcpy(NestMember,buffer+i+1); 405 refType = CClass::Dot;411 refType = RefDot; 406 412 buffer[i]=0; 407 413 break; … … 409 415 if(buffer[i]==1&&buffer[i+1]==ESC_PSMEM){ 410 416 lstrcpy(NestMember,buffer+i+2); 411 refType = CClass::Pointer;417 refType = RefPointer; 412 418 buffer[i]=0; 413 419 break; … … 459 465 } 460 466 461 int JumpSubScripts( const int *ss){467 int JumpSubScripts( const Subscripts &subscripts ){ 462 468 //DIMで定義された並んだ配列の数だけアドレスを進める 463 int i,i2; 464 for(i=0,i2=1;i<255;i++){ 465 if(ss[i]==-1) break; 466 i2*=ss[i]+1; 469 int i, i2; 470 for( i=0,i2=1; i<(int)subscripts.size(); i++ ){ 471 i2 *= subscripts[i] + 1; 467 472 } 468 473 return i2; … … 478 483 char lpPtrOffset[VN_SIZE]; //第2次配列 479 484 char NestMember[VN_SIZE]; //入れ子メンバ 480 CClass::RefType refType = CClass::Non;485 ReferenceKind refType = RefNon; 481 486 lstrcpy(VarName,lpszMember); 482 487 if(!GetVarFormatString(VarName,array,lpPtrOffset,NestMember,refType)) return false; … … 496 501 497 502 //アクセシビリティをチェック 498 if( &objClass == Smoothie::Temp::pCompilingClass ){503 if( &objClass == compiler.pCompilingClass ){ 499 504 //同一クラスオブジェクトの場合はプライベートアクセスを容認する 500 505 if( pMember->IsNoneAccess() ){ … … 519 524 //ポインタ変数の場合 520 525 if( resultType.IsPointer() ){ 521 if( pMember->SubScripts[0]==-1){526 if( pMember->GetSubscripts().size() == 0 ){ 522 527 lstrcpy(lpPtrOffset,array); 523 528 array[0]=0; … … 531 536 } 532 537 533 if( refType != CClass::Non ){538 if( refType != RefNon ){ 534 539 //入れ子構造の場合 535 540 … … 541 546 } 542 547 543 if( array[0]==0&&pMember->SubScripts[0]!=-1){548 if( array[0] == 0 && pMember->GetSubscripts().size() > 0 ){ 544 549 resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR ); 545 550 return true; … … 573 578 574 579 // 先頭オブジェクトまたはクラス名と入れ子メンバに分割 575 CClass::RefTyperefType;580 ReferenceKind refType; 576 581 char member[VN_SIZE],array[VN_SIZE],lpPtrOffset[VN_SIZE]; 577 582 GetVarFormatString(simpleName,array,lpPtrOffset,member,refType); … … 587 592 588 593 const Variable *pVar = NULL; 589 const int *pSubScripts;590 594 591 595 if( UserProc::IsLocalAreaCompiling() ){ … … 594 598 ///////////////// 595 599 596 pVar = UserProc::CompilingUserProc(). localVars.BackSearch( Symbol( VarName ) );600 pVar = UserProc::CompilingUserProc().GetLocalVars().BackSearch( Symbol( VarName ) ); 597 601 if( pVar ){ 598 602 goto ok; … … 600 604 } 601 605 602 if( Smoothie::Temp::pCompilingClass){606 if(compiler.pCompilingClass){ 603 607 /////////////////////// 604 608 // クラスメンバの参照 … … 607 611 if(lstrcmpi(variable,"This")==0){ 608 612 //Thisオブジェクト 609 resultType.SetType( DEF_OBJECT, Smoothie::Temp::pCompilingClass );613 resultType.SetType( DEF_OBJECT, compiler.pCompilingClass ); 610 614 return true; 611 615 } … … 620 624 621 625 bool isFound = false; 622 BOOST_FOREACH( CMember *pMember, Smoothie::Temp::pCompilingClass->GetDynamicMembers() ){626 BOOST_FOREACH( CMember *pMember, compiler.pCompilingClass->GetDynamicMembers() ){ 623 627 if( pMember->GetName() == VarName ){ 624 628 isFound = true; … … 629 633 } 630 634 631 return GetMemberType(* Smoothie::Temp::pCompilingClass,variable,resultType,1,isErrorEnabled);635 return GetMemberType(*compiler.pCompilingClass,variable,resultType,1,isErrorEnabled); 632 636 } 633 637 … … 643 647 GetNowStaticVarFullName(VarName,temporary); 644 648 645 pVar = globalVars.Find( Symbol( temporary ) );649 pVar = compiler.GetMeta().GetGlobalVars().Find( Symbol( temporary ) ); 646 650 if( pVar ){ 647 651 goto ok; … … 659 663 char tempArray[VN_SIZE]; 660 664 { 661 CClass::RefTyperefType;665 ReferenceKind refType; 662 666 GetVarFormatString(temporary,tempArray,lpPtrOffset,tempMember,refType); 663 667 } … … 672 676 sprintf(temp2,"%s.%s",VarName,temporary); 673 677 674 pVar = globalVars.Find( Symbol( temp2 ) );678 pVar = compiler.GetMeta().GetGlobalVars().Find( Symbol( temp2 ) ); 675 679 if( pVar ){ 676 680 lstrcpy(member,tempMember); … … 680 684 } 681 685 682 if( Smoothie::Temp::pCompilingClass){686 if(compiler.pCompilingClass){ 683 687 //自身のクラスから静的メンバを参照する場合 684 688 char temp2[VN_SIZE]; 685 sprintf(temp2,"%s.%s", Smoothie::Temp::pCompilingClass->GetName().c_str(),VarName);686 687 pVar = globalVars.Find( Symbol( temp2 ) );689 sprintf(temp2,"%s.%s",compiler.pCompilingClass->GetName().c_str(),VarName); 690 691 pVar = compiler.GetMeta().GetGlobalVars().Find( Symbol( temp2 ) ); 688 692 if( pVar ){ 689 693 goto ok; … … 696 700 //////////////////// 697 701 698 pVar = globalVars.BackSearch( Symbol( VarName ) );702 pVar = compiler.GetMeta().GetGlobalVars().BackSearch( Symbol( VarName ) ); 699 703 if( pVar ){ 700 704 goto ok; … … 708 712 709 713 //ポインタ変数の場合 710 if( pVar-> IsPointer() ){714 if( pVar->GetType().IsPointer() ){ 711 715 if( !pVar->IsArray() ){ 712 716 lstrcpy(lpPtrOffset,array); … … 721 725 } 722 726 723 resultType = (*pVar); 724 pSubScripts=pVar->GetSubScriptsPtr(); 725 727 resultType = pVar->GetType(); 726 728 727 729 if(member[0]){ … … 732 734 } 733 735 734 if( array[0]==0&&pSubScripts[0]!=-1){736 if( array[0] == 0 && pVar->GetSubscripts().size() > 0 ){ 735 737 //配列の先頭ポインタを示す場合 736 738 resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR ); … … 751 753 } 752 754 753 bool GetVarOffsetReadOnly(const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, int *pss ){755 bool GetVarOffsetReadOnly(const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts ){ 754 756 //読み取り専用で変数へアクセス 755 757 return GetVarOffset( … … 759 761 pRelativeVar, 760 762 resultType, 761 pss); 762 } 763 bool GetVarOffsetReadWrite(const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType,int *pss ){ 763 pResultSubscripts 764 ); 765 } 766 bool GetVarOffsetReadWrite(const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts ){ 764 767 //読み書き両用で変数へアクセス 765 768 return GetVarOffset( … … 769 772 pRelativeVar, 770 773 resultType, 771 pss); 774 pResultSubscripts 775 ); 772 776 } 773 777 … … 776 780 bool GetDimentionFormat( const char *buffer, 777 781 char *VarName, 778 int *SubScripts,782 Subscripts &subscripts, 779 783 Type &type, 780 784 char *InitBuf, … … 924 928 } 925 929 926 GetArrange(variable,VarName, SubScripts);930 GetArrange(variable,VarName,subscripts); 927 931 return true; 928 932 } … … 934 938 } 935 939 936 UserProc &proc = UserProc::CompilingUserProc();940 const UserProc &proc = UserProc::CompilingUserProc(); 937 941 938 942 //Static識別 … … 940 944 941 945 //クラス名 942 if( Smoothie::Temp::pCompilingClass){943 lstrcat(FullName, Smoothie::Temp::pCompilingClass->GetName().c_str());946 if(compiler.pCompilingClass){ 947 lstrcat(FullName,compiler.pCompilingClass->GetName().c_str()); 944 948 lstrcat(FullName,"%"); 945 949 } … … 951 955 //ID 952 956 char temp[255]; 953 sprintf(temp,"%x",proc. id);957 sprintf(temp,"%x",proc.GetId()); 954 958 lstrcat(FullName,temp); 955 959 lstrcat(FullName,"%"); … … 962 966 963 967 964 void AddGlobalVariable( const char *name, int *SubScripts, const Type &type,const char *InitBuf,const char *ConstractParameter,DWORD dwFlag){968 void AddGlobalVariable( const char *name, const Subscripts &subscripts, const Type &type,const char *InitBuf,const char *ConstractParameter,DWORD dwFlag){ 965 969 ///////////////////////// 966 970 // グローバル変数を追加 … … 969 973 extern int AllGlobalVarSize; 970 974 971 if( globalVars.DuplicateCheck( Symbol( name ) ) ){975 if( compiler.GetMeta().GetGlobalVars().DuplicateCheck( Symbol( name ) ) ){ 972 976 //2重定義のエラー 973 977 SetError(15,name,cp); … … 977 981 bool isConst = ( dwFlag & DIMFLAG_CONST ) ? true:false; 978 982 979 Variable *pVar = new Variable Impl( compiler.GetNamespaceSupporter().GetLivingNamespaceScopes(), name, type, isConst);980 981 if( SubScripts[0] != -1){983 Variable *pVar = new Variable( compiler.GetNamespaceSupporter().GetLivingNamespaceScopes(), name, type, isConst, false, ConstractParameter ); 984 985 if( subscripts.size() > 0 ){ 982 986 //配列あり 983 pVar->SetArray( SubScripts ); 984 } 985 986 //コンストラクタ用パラメータ 987 pVar->paramStrForConstructor = ConstractParameter; 987 pVar->SetArray( subscripts ); 988 } 988 989 989 990 //レキシカルスコープ 990 pVar->S copeLevel=GetLexicalScopes().GetNowLevel();991 pVar->S copeStartAddress=GetLexicalScopes().GetStartAddress();991 pVar->SetScopeLevel( GetLexicalScopes().GetNowLevel() ); 992 pVar->SetScopeStartAddress( GetLexicalScopes().GetStartAddress() ); 992 993 pVar->bLiving=TRUE; 993 994 … … 996 997 997 998 // 変数を追加 998 globalVars.push_back( pVar );999 compiler.GetMeta().GetGlobalVars().push_back( pVar ); 999 1000 1000 1001 //アラインメントを考慮 1001 1002 int alignment = 0; 1002 if( pVar-> IsStruct() ){1003 alignment = pVar->Get Class().iAlign;1003 if( pVar->GetType().IsStruct() ){ 1004 alignment = pVar->GetType().GetClass().iAlign; 1004 1005 } 1005 1006 … … 1013 1014 } 1014 1015 1015 pVar-> offset=AllInitGlobalVarSize;1016 pVar->SetOffsetAddress( AllInitGlobalVarSize ); 1016 1017 AllInitGlobalVarSize += pVar->GetMemorySize(); 1017 1018 } … … 1025 1026 } 1026 1027 1027 pVar-> offset=AllGlobalVarSize | 0x80000000;1028 pVar->SetOffsetAddress( AllGlobalVarSize | 0x80000000 ); 1028 1029 AllGlobalVarSize += pVar->GetMemorySize(); 1029 1030 } … … 1031 1032 if(InitBuf[0]){ 1032 1033 int result = 0; 1033 if( !pVar-> IsObject() ){1034 if( !pVar->GetType().IsObject() ){ 1034 1035 //初期バッファにデータをセット 1035 1036 extern BYTE *initGlobalBuf; … … 1039 1040 AllInitGlobalVarSize); 1040 1041 1041 result = SetInitGlobalData(pVar-> offset,1042 *pVar,1043 pVar->GetSub ScriptsPtr(),1042 result = SetInitGlobalData(pVar->GetOffsetAddress(), 1043 pVar->GetType(), 1044 pVar->GetSubscripts(), 1044 1045 InitBuf); 1045 1046 } … … 1070 1071 const CMethod *method = type.GetClass().GetDestructorMethod(); 1071 1072 if( method ){ 1072 method-> pUserProc->Using();1073 method->GetUserProc().Using(); 1073 1074 } 1074 1075 } … … 1104 1105 1105 1106 //定数と2重定義されていないる場合は抜け出す 1106 if( CDBConst::obj.GetBasicType(VarName)){1107 if(compiler.GetMeta().GetGlobalConsts().GetBasicType(VarName)){ 1107 1108 return; 1108 1109 } 1109 1110 1110 1111 //定数マクロとして定義されている場合は抜け出す 1111 if(GetConstHash(VarName)){ 1112 if( compiler.GetMeta().GetGlobalConstMacros().IsExist( VarName ) ) 1113 { 1112 1114 return; 1113 1115 } … … 1115 1117 1116 1118 //構文を解析 1117 int SubScripts[MAX_ARRAYDIM];1118 1119 Type type; 1119 1120 char InitBuf[8192]; 1120 1121 char ConstractParameter[VN_SIZE]; 1121 if(!GetDimentionFormat(Parameter, VarName,SubScripts,type,InitBuf,ConstractParameter)) 1122 Subscripts subscripts; 1123 if(!GetDimentionFormat(Parameter, VarName,subscripts,type,InitBuf,ConstractParameter)) 1122 1124 return; 1123 1125 1124 1126 1125 1127 //定数と2重定義されていないかを調べる 1126 if( CDBConst::obj.GetBasicType(VarName)){1128 if(compiler.GetMeta().GetGlobalConsts().GetBasicType(VarName)){ 1127 1129 SetError(15,VarName,cp); 1128 1130 return; … … 1130 1132 1131 1133 //定数マクロとして定義されている場合 1132 if( GetConstHash(VarName)){1134 if( compiler.GetMeta().GetGlobalConstMacros().IsExist( VarName ) ){ 1133 1135 SetError(15,VarName,cp); 1134 1136 return; … … 1165 1167 GetNowStaticVarFullName(VarName,temporary); 1166 1168 1167 dim( temporary, SubScripts,type,InitBuf,ConstractParameter,dwFlags );1169 dim( temporary,subscripts,type,InitBuf,ConstractParameter,dwFlags ); 1168 1170 1169 1171 /* … … 1173 1175 } 1174 1176 else{ 1175 dim( VarName, SubScripts,type,InitBuf,ConstractParameter,dwFlags );1177 dim( VarName,subscripts,type,InitBuf,ConstractParameter,dwFlags ); 1176 1178 } 1177 1179 } -
trunk/abdev/BasicCompiler_Common/VariableOpe.h
r193 r206 1 #pragma once 1 2 3 #include <jenga/include/smoothie/LexicalAnalysis.h> 4 5 class Type; 6 class CClass; 2 7 3 8 BOOL IsPtrType(int type); … … 14 19 Type GetStringTypeInfo(); 15 20 void GetWithName(char *buffer); 16 BOOL GetVarFormatString(char *buffer,char *array,char *array2,char *NestMember, CClass::RefType&refType );21 BOOL GetVarFormatString(char *buffer,char *array,char *array2,char *NestMember, ReferenceKind &refType ); 17 22 void GetArrayElement( const char *buffer,char *variable,char *array_element); 18 23 BOOL CheckVarNameError(char *name,int nowLine); 19 int JumpSubScripts( const int *ss);24 int JumpSubScripts( const Subscripts &subscripts ); 20 25 bool GetMemberType( const CClass &objClass, const char *lpszMember, Type &resultType, BOOL bPrivateAccess, bool isErrorEnabled); 21 26 bool GetVarType( const char *nameBuffer, Type &resultType, bool isError); 22 bool GetVarOffsetReadOnly(const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, int *pss = NULL );23 bool GetVarOffsetReadWrite(const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, int *pss = NULL );27 bool GetVarOffsetReadOnly(const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts = NULL ); 28 bool GetVarOffsetReadWrite(const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts = NULL ); 24 29 bool GetDimentionFormat( const char *buffer, 25 30 char *VarName, 26 int *SubScripts,31 Subscripts &subscripts, 27 32 Type &type, 28 33 char *InitBuf, 29 34 char *ConstractParameter ); 30 35 BOOL GetNowStaticVarFullName(char *VarName,char *FullName); 31 void AddGlobalVariable( const char *name, int *SubScripts, const Type &type,const char *InitBuf,const char *ConstractParameter,DWORD dwFlag);36 void AddGlobalVariable( const char *name, const Subscripts &subscripts, const Type &type,const char *InitBuf,const char *ConstractParameter,DWORD dwFlag); 32 37 void dim(char *Parameter,DWORD dwFlags); 33 38 void OpcodeDim(char *Parameter,DWORD dwFlags); -
trunk/abdev/BasicCompiler_Common/WatchList.cpp
r182 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 4 5 #include <Compiler.h> 2 6 3 7 #include "common.h" … … 12 16 #include "debug.h" 13 17 14 int Debugging_GetArray( const int *SubScripts,char *array,const Type &type,LONG_PTR *plpOffset);18 int Debugging_GetArray( const Subscripts &subscripts,char *array,const Type &type,LONG_PTR *plpOffset); 15 19 16 20 ULONG_PTR Debugging_GetVarPtr(RELATIVE_VAR *pRelativeVar){ … … 117 121 char lpPtrOffset[VN_SIZE]; //第2次配列 118 122 char NestMember[VN_SIZE]; //入れ子メンバ 119 CClass::RefTyperefType;123 ReferenceKind refType; 120 124 lstrcpy(VarName,member); 121 125 if(!GetVarFormatString(VarName,array,lpPtrOffset,NestMember, refType ) ) return 0; … … 145 149 //ポインタ変数の場合 146 150 if( resultType.IsPointer() ){ 147 if( pMember->SubScripts[0]==-1){151 if( pMember->GetSubscripts().size() == 0 ){ 148 152 lstrcpy(lpPtrOffset,array); 149 153 array[0]=0; … … 159 163 //配列オフセット 160 164 i2=Debugging_GetArray( 161 pMember-> SubScripts,165 pMember->GetSubscripts(), 162 166 array, 163 167 resultType, … … 172 176 } 173 177 } 174 else if( pMember->SubScripts[0]!=-1){178 else if( pMember->GetSubscripts().size() > 0 ){ 175 179 resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR ); 176 180 } … … 180 184 181 185 if( resultType.IsObject() || resultType.IsStruct() ){ 182 if( refType != CClass::Dot ) return 0;186 if( refType != RefDot ) return 0; 183 187 184 188 if( resultType.IsObject() ){ … … 195 199 196 200 if(lpPtrOffset[0]){ 197 if( refType != CClass::Dot ) return 0;201 if( refType != RefDot ) return 0; 198 202 199 203 //直接参照に切り替え … … 203 207 } 204 208 else{ 205 if( refType != CClass::Pointer ) return 0;209 if( refType != RefPointer ) return 0; 206 210 207 211 extern HANDLE hDebugProcess; … … 235 239 return 1; 236 240 } 237 int Debugging_GetArray( const int *SubScripts,char *array,const Type &type,LONG_PTR *plpOffset){241 int Debugging_GetArray( const Subscripts &subscripts,char *array,const Type &type,LONG_PTR *plpOffset){ 238 242 extern HANDLE hHeap; 239 243 int i,i2,i3,i4,i5,array_offset; … … 254 258 } 255 259 if(array[i]==','||array[i]=='\0'){ 256 if(SubScripts[i3]==-1){ 260 if( i3 >= (int)subscripts.size() ) 261 { 257 262 for(i3--;i3>=0;i3--) HeapDefaultFree(pParm[i3]); 258 263 return 0; … … 267 272 268 273 if(array[i]=='\0'){ 269 if(SubScripts[i3]!=-1){ 274 if( i3 < (int)subscripts.size() ) 275 { 270 276 for(i3--;i3>=0;i3--) HeapDefaultFree(pParm[i3]); 271 277 return 0; … … 302 308 i5=(int)i64data; 303 309 304 for(i2=i+1,i4=1;i2<i3;i2++) i4*= SubScripts[i2]+1;310 for(i2=i+1,i4=1;i2<i3;i2++) i4*=subscripts[i2]+1; 305 311 306 312 array_offset+=i5*i4; … … 316 322 } 317 323 ULONG_PTR Debugging_GetThisPtrOffset(LONG_PTR obp_Rip){ 318 GlobalProc *pUserProc = GetSubFromObp(obp_Rip);319 320 BOOST_FOREACH( Variable *pVar, pUserProc-> localVars){324 UserProc *pUserProc = GetSubFromObp(obp_Rip); 325 326 BOOST_FOREACH( Variable *pVar, pUserProc->GetLocalVars() ){ 321 327 if( pVar->GetName() == "_System_LocalThis" ){ 322 return pVar-> offset;328 return pVar->GetOffsetAddress(); 323 329 } 324 330 } 325 331 return 0; 326 332 } 327 int Debugging_GetVarOffset( char *variable,RELATIVE_VAR *pRelativeVar, Type &resultType, int *pss){333 int Debugging_GetVarOffset( char *variable,RELATIVE_VAR *pRelativeVar, Type &resultType, Subscripts *pResultSubscripts){ 328 334 extern HANDLE hDebugProcess; 329 335 int i2,i3; … … 333 339 334 340 lstrcpy(VarName,variable); 335 CClass::RefTyperefType;341 ReferenceKind refType; 336 342 GetVarFormatString(VarName,array,lpPtrOffset,member,refType); 337 343 338 const int *pSubScripts;344 const Subscripts *pSubscripts; 339 345 bool isArray; 340 346 … … 344 350 ///////////////// 345 351 if( UserProc::IsLocalAreaCompiling() ){ 346 const Variable *pVar = UserProc::CompilingUserProc(). localVars.Find( Symbol( VarName ) );352 const Variable *pVar = UserProc::CompilingUserProc().GetLocalVars().Find( Symbol( VarName ) ); 347 353 348 354 if( pVar ){ 349 355 //ポインタ変数の場合 350 if( pVar-> IsPointer() ){356 if( pVar->GetType().IsPointer() ){ 351 357 if( !pVar->IsArray() ){ 352 358 lstrcpy(lpPtrOffset,array); … … 358 364 } 359 365 360 pRelativeVar->offset = pVar-> offset;366 pRelativeVar->offset = pVar->GetOffsetAddress(); 361 367 if( pVar->IsRef() ){ 362 368 pRelativeVar->dwKind=VAR_REFLOCAL; … … 365 371 pRelativeVar->dwKind=VAR_LOCAL; 366 372 } 367 resultType = *pVar;373 resultType = pVar->GetType(); 368 374 isArray = pVar->IsArray(); 369 pSub Scripts = pVar->GetSubScriptsPtr();370 } 371 } 372 373 if( Smoothie::Temp::pCompilingClass){375 pSubscripts = &pVar->GetSubscripts(); 376 } 377 } 378 379 if(compiler.pCompilingClass){ 374 380 /////////////////////// 375 381 // クラスメンバの参照 … … 385 391 386 392 bool isFound = false; 387 BOOST_FOREACH( CMember *pMember, Smoothie::Temp::pCompilingClass->GetDynamicMembers() ){393 BOOST_FOREACH( CMember *pMember, compiler.pCompilingClass->GetDynamicMembers() ){ 388 394 if( pMember->GetName() == VarName ){ 389 395 isFound = true; … … 414 420 pRelativeVar->dwKind=VAR_DIRECTMEM; 415 421 416 i3=Debugging_GetMember(* Smoothie::Temp::pCompilingClass,variable,pRelativeVar,resultType,1);422 i3=Debugging_GetMember(*compiler.pCompilingClass,variable,pRelativeVar,resultType,1); 417 423 if(i3==0){ 418 424 //式エラー … … 434 440 /////////////////// 435 441 436 const Variable *pVar = globalVars.Find( VarName );442 const Variable *pVar = compiler.GetMeta().GetGlobalVars().Find( VarName ); 437 443 if( !pVar ){ 438 444 //一致しないとき … … 441 447 442 448 //ポインタ変数の場合 443 if( pVar-> IsPointer() ){449 if( pVar->GetType().IsPointer() ){ 444 450 if( !pVar->IsArray() ){ 445 451 lstrcpy(lpPtrOffset,array); … … 451 457 } 452 458 453 pRelativeVar->offset=pVar-> offset;459 pRelativeVar->offset=pVar->GetOffsetAddress(); 454 460 if(pVar->IsRef()) pRelativeVar->dwKind=VAR_REFGLOBAL; 455 461 else pRelativeVar->dwKind=VAR_GLOBAL; 456 resultType = *pVar;462 resultType = pVar->GetType(); 457 463 isArray = pVar->IsArray(); 458 pSub Scripts=pVar->GetSubScriptsPtr();464 pSubscripts = &pVar->GetSubscripts(); 459 465 } 460 466 … … 463 469 //配列の先頭ポインタを示す場合 464 470 resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR ); 465 if(pss) memcpy(pss,pSubScripts,MAX_ARRAYDIM*sizeof(int)); 471 if( pResultSubscripts ) 472 { 473 (*pResultSubscripts) = *pSubscripts; 474 } 466 475 return 1; 467 476 } 468 477 469 478 if(array[0]){ 470 i3=Debugging_GetArray( pSubScripts,array,resultType,&pRelativeVar->offset);479 i3=Debugging_GetArray( *pSubscripts, array,resultType,&pRelativeVar->offset); 471 480 if(i3==0){ 472 481 //式エラー … … 481 490 if( resultType.IsObject() || resultType.IsStruct() ){ 482 491 //実態オブジェクトのメンバを参照(obj.member) 483 if( refType != CClass::Dot ){492 if( refType != RefDot ){ 484 493 return 0; 485 494 } … … 499 508 if(lpPtrOffset[0]){ 500 509 //pObj[n].member 501 if( refType != CClass::Dot ) return 0;510 if( refType != RefDot ) return 0; 502 511 Debugging_SetRelativeOffset(resultType,pRelativeVar,lpPtrOffset); 503 512 … … 514 523 else{ 515 524 //pObj->member 516 if( refType != CClass::Pointer ) return 0;525 if( refType != RefPointer ) return 0; 517 526 518 527 pRelativeVar->offset=Debugging_GetVarPtr(pRelativeVar); -
trunk/abdev/BasicCompiler_Common/calculation.cpp
r198 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/LexicalAnalysis.h> 2 4 … … 498 500 //定数関数 499 501 500 if(!GetConstCalcBuffer(temporary,temp2,Parms)){ 502 ConstMacro *pConstMacro = compiler.GetMeta().GetGlobalConstMacros().Find( temporary ); 503 if( !pConstMacro ) 504 { 505 if(enableerror) SetError(3,temporary,cp); 506 return false; 507 } 508 if( !pConstMacro->GetCalcBuffer( temp2, Parms ) ) 509 { 501 510 if(enableerror) SetError(3,temporary,cp); 502 511 return false; … … 554 563 555 564 RELATIVE_VAR RelativeVar; 556 int ss[MAX_ARRAYDIM];557 565 void *offset; 558 566 DWORD dwData; … … 563 571 564 572 Type tempType; 565 i3=Debugging_GetVarOffset(Parms,&RelativeVar,tempType ,ss);573 i3=Debugging_GetVarOffset(Parms,&RelativeVar,tempType); 566 574 if(i3==0){ 567 575 //式エラー … … 657 665 ///////// 658 666 StrPtr[pnum]=0; 659 type[pnum] = CDBConst::obj.GetBasicType(Parms);667 type[pnum] = compiler.GetMeta().GetGlobalConsts().GetBasicType(Parms); 660 668 if(type[pnum]){ 661 669 if(IsRealNumberType(type[pnum])){ 662 670 //実数型 663 nums[pnum] = CDBConst::obj.GetDoubleData(Parms);671 nums[pnum] = compiler.GetMeta().GetGlobalConsts().GetDoubleData(Parms); 664 672 } 665 673 else if(IsWholeNumberType(type[pnum])){ 666 674 //整数 667 i64nums[pnum] = CDBConst::obj.GetWholeData(Parms);675 i64nums[pnum] = compiler.GetMeta().GetGlobalConsts().GetWholeData(Parms); 668 676 } 669 677 /* else if(type[pnum]==DEF_STRING){ … … 1108 1116 #pragma optimize("", on) 1109 1117 1110 BOOL GetConstCalcBuffer(const char *name,const char *Parameter,char *pCalcBuffer){1111 extern HANDLE hHeap;1112 int i2,i3,i4,num;1113 char temporary[VN_SIZE];1114 char *pParms[MAX_PARMS];1115 1116 CONSTINFO *pci;1117 pci=GetConstHash(name);1118 if(!pci) return 0;1119 1120 num=0;1121 i2=0;1122 while(1){1123 i2=GetOneParameter(Parameter,i2,temporary);1124 1125 pParms[num]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);1126 lstrcpy(pParms[num],temporary);1127 1128 num++;1129 if(Parameter[i2]=='\0') break;1130 }1131 if(num!=pci->ParmNum){1132 extern int cp;1133 for(i2=0;i2<num;i2++) HeapDefaultFree(pParms[i2]);1134 SetError(10,name,cp);1135 lstrcpy(pCalcBuffer,"0");1136 return 1;1137 }1138 1139 i2=0;1140 i4=0;1141 while(1){1142 1143 //数式内の項を取得1144 for(i3=0;;i2++,i3++){1145 if(!IsVariableChar(pci->StrValue[i2])){1146 temporary[i3]=0;1147 break;1148 }1149 temporary[i3]=pci->StrValue[i2];1150 }1151 1152 //パラメータと照合する1153 for(i3=0;i3<pci->ParmNum;i3++){1154 if(lstrcmp(pci->ppParm[i3],temporary)==0) break;1155 }1156 1157 if(i3==pci->ParmNum){1158 //パラメータでないとき1159 lstrcpy(pCalcBuffer+i4,temporary);1160 i4+=lstrlen(temporary);1161 }1162 else{1163 //パラメータのとき1164 lstrcpy(pCalcBuffer+i4,pParms[i3]);1165 i4+=lstrlen(pParms[i3]);1166 }1167 1168 //演算子をコピー1169 for(;;i2++,i4++){1170 if(pci->StrValue[i2]==1){1171 pCalcBuffer[i4++]=pci->StrValue[i2++];1172 pCalcBuffer[i4]=pci->StrValue[i2];1173 continue;1174 }1175 if(IsVariableTopChar(pci->StrValue[i2])) break;1176 pCalcBuffer[i4]=pci->StrValue[i2];1177 if(pci->StrValue[i2]=='\0') break;1178 }1179 1180 if(pci->StrValue[i2]=='\0') break;1181 }1182 1183 for(i2=0;i2<num;i2++) HeapDefaultFree(pParms[i2]);1184 1185 return 1;1186 }1187 DWORD GetConstValue(char *name,double *pDbl,char *buffer,LONG_PTR *plpIndex){1188 CONSTINFO *pci;1189 pci=GetConstHash(name);1190 if(pci){1191 //定数が見つかったとき1192 1193 if(pci->StrValue){1194 //文字列定数1195 1196 //バイト数1197 *pDbl=pci->DblValue;1198 1199 //データ1200 memcpy(buffer,pci->StrValue,(int)pci->DblValue);1201 1202 if(plpIndex) *plpIndex=pci->lpIndex;1203 1204 return DEF_STRING;1205 }1206 else{1207 if(pci->type==DEF_INT64){1208 memcpy(pDbl,&pci->i64Value,sizeof(_int64));1209 return DEF_INT64;1210 }1211 1212 if(plpIndex) *plpIndex=pci->lpIndex;1213 1214 *pDbl=pci->DblValue;1215 return pci->type;1216 }1217 }1218 1219 if(plpIndex) *plpIndex=-1;1220 1221 return -1;1222 }1223 1118 int IsStrCalculation(char *Command){ 1224 1119 int i,i2,i3,i4,PareNum; … … 1283 1178 1284 1179 //ユーザー定義関数 1285 UserProc *pUserProc; 1286 pUserProc=GetSubHash(temporary); 1180 const UserProc *pUserProc = GetSubHash(temporary); 1287 1181 if(pUserProc){ 1288 1182 if( pUserProc->ReturnType().IsStringClass() ){ … … 1300 1194 1301 1195 //定数 1302 CONSTINFO *pci; 1303 pci=GetConstHash(temporary); 1304 if(pci){ 1305 1306 if(pci->ParmNum){ 1307 //マクロ関数の場合 1308 GetStringInPare_RemovePare(temporary,Command+i2+i3+1); 1309 GetConstCalcBuffer(pci->name,temporary,temp2); 1310 return IsStrCalculation(temp2); 1311 } 1312 1313 if(pci->type==DEF_STRING) return 1; 1314 else return 0; 1196 ConstMacro *pConstMacro = compiler.GetMeta().GetGlobalConstMacros().Find( temporary ); 1197 if(pConstMacro){ 1198 //マクロ関数の場合 1199 GetStringInPare_RemovePare(temporary,Command+i2+i3+1); 1200 pConstMacro->GetCalcBuffer( temporary, temp2 ); 1201 return IsStrCalculation(temp2); 1315 1202 } 1316 1203 } 1317 1204 1318 1205 //定数 1319 i3 = CDBConst::obj.GetBasicType(Command+i2);1206 i3 = compiler.GetMeta().GetGlobalConsts().GetBasicType(Command+i2); 1320 1207 if(i3==DEF_STRING) return 1; //文字列 1321 1208 if(i3) return 0; //数値 -
trunk/abdev/BasicCompiler_Common/common.h
r182 r206 1 #pragma once 2 1 3 //#define _CRT_SECURE_NO_DEPRECATE 2 4 #pragma warning(disable : 4996) 3 5 4 6 #include <option.h> 5 6 #include <windows.h>7 #include <stdio.h>8 #include <string.h>9 #include <math.h>10 #include <commctrl.h>11 #include <time.h>12 #include <limits.h>13 #include <shlobj.h>14 #include <vector>15 #include <string>16 #include <fstream>17 18 //boost libraries19 #include <boost/foreach.hpp>20 7 21 8 using namespace std; … … 33 20 #endif 34 21 35 #include "../BasicCompiler_Common/BasicFixed.h"22 #include <jenga/include/smoothie/BasicFixed.h> 36 23 #include "../BasicCompiler_Common/NonVolatile.h" 37 24 #include "../BasicCompiler_Common/psapi.h" … … 139 126 140 127 141 // 列挙体管理用のクラス142 #include "Enum.h"143 144 // 定数管理用のクラス145 #include "Const.h"146 147 148 128 149 129 struct ERRORINFO{ … … 157 137 LONG_PTR offset; 158 138 BOOL bOffsetOffset; 159 };160 161 struct CONSTINFO{162 char *name;163 char *StrValue;164 165 double DblValue;166 _int64 i64Value;167 int type;168 LONG_PTR lpIndex;169 170 int ParmNum;171 char **ppParm;172 173 CONSTINFO *pNextData;174 139 }; 175 140 … … 245 210 246 211 #include "../BasicCompiler_Common/PESchedule.h" 247 #include "../BasicCompiler_Common/DebugSection.h"248 212 #include "../BasicCompiler_Common/VariableOpe.h" 249 213 … … 268 232 //hash.cpp 269 233 int hash_default(const char *name); 270 CONSTINFO *GetConstHash(const char *name);271 234 DllProc *GetDeclareHash(char *name); 272 void GetOverloadSubHash( const char *lpszName, std::vector< UserProc *> &subs );273 UserProc *GetSubHash(const char *name,BOOL bError=0);274 UserProc *GetMethodHash(const char *ObjectName,const char *MethodName,const char *Parameter,BOOL bError=0);275 UserProc *GetClassMethod( const char *className, const char *methodName );235 void GetOverloadSubHash( const char *lpszName, std::vector<const UserProc *> &subs ); 236 const UserProc *GetSubHash(const char *name,BOOL bError=0); 237 const UserProc *GetMethodHash(const char *ObjectName,const char *MethodName,const char *Parameter,BOOL bError=0); 238 const UserProc *GetClassMethod( const char *className, const char *methodName ); 276 239 277 240 //Object.cpp 278 void CallConstructor( const char *ObjectName,const int *SubScripts, const Type &type,const char *Parameter);241 void CallConstructor( const char *ObjectName,const Subscripts &subscripts, const Type &type,const char *Parameter); 279 242 bool Operator_New( const char *expression, const Type &baseType, Type &resultType ); 280 243 281 244 //Overload.sbp 282 UserProc *OverloadSolutionWithStrParam( 245 class Parameters; 246 const UserProc *OverloadSolutionWithStrParam( 283 247 const char *name, 284 std::vector< UserProc *> &subs,248 std::vector<const UserProc *> &subs, 285 249 const char *Parameter, 286 250 const char *ObjectName); 287 UserProc *OverloadSolution(251 const UserProc *OverloadSolution( 288 252 const char *name, 289 std::vector< UserProc *> &subs,253 std::vector<const UserProc *> &subs, 290 254 const Parameters ¶ms, 291 255 const Type &returnType ); … … 298 262 void Debugger_Pause(void); 299 263 ULONG_PTR rva_to_real(DWORD p); 300 GlobalProc *GetSubFromObp(ULONG_PTR pos);264 UserProc *GetSubFromObp(ULONG_PTR pos); 301 265 void ReadOpBuffer(); 302 266 void DebugProgram(void); … … 310 274 ULONG_PTR Debugging_GetVarPtr(RELATIVE_VAR *pRelativeVar); 311 275 ULONG_PTR Debugging_GetThisPtrOffset(LONG_PTR obp_Rip); 312 int Debugging_GetVarOffset( char *variable,RELATIVE_VAR *pRelativeVar, Type &resultType, int *pss);276 int Debugging_GetVarOffset( char *variable,RELATIVE_VAR *pRelativeVar, Type &resultType, Subscripts *pResultSubscripts = NULL ); 313 277 314 278 //MakeExe.cpp 315 279 void StepCompileProgress(void); 316 void DeleteConstInfo(CONSTINFO **ppConstHash);317 280 void DeleteDeclareInfo(void); 318 281 void AddSourceCode(char *buffer); … … 366 329 char GetEndXXXCommand(char es); 367 330 void GetDefaultNameFromES(char es,char *name); 368 void GetCalcName(int idCalc,char *name);331 const std::string &FormatEscapeSequenceStringToDefaultString( const std::string &source ); 369 332 BOOL IsFile(char *path); 370 333 BOOL ShortPathToLongPath(char ShortPath[MAX_PATH],char *LongPath); … … 382 345 int NeutralizationType(int type1,LONG_PTR index1,int type2,LONG_PTR index2); 383 346 DWORD GetLiteralValue(char *value,_int64 *pi64,int BaseType); 384 BOOL GetConstCalcBuffer(const char *name,const char *Parameter,char *pCalcBuffer);385 DWORD GetConstValue(char *name,double *dbl,char *buffer,LONG_PTR *plpIndex);386 347 int IsStrCalculation(char *Command); 387 348 BYTE GetCalcId(const char *Command,int *pi); … … 403 364 bool GetReturnTypeOfPropertyMethod( const char *variable, const char *rightSide, Type &resultType ); 404 365 bool GetReturnTypeOfIndexerGetterProc( const CClass &objClass, Type &resultType ); 405 GlobalProc *AddSubData( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,bool isVirtual,CClass *pobj_c, bool isStatic = false );406 void GetSubInfo(void);407 void DeleteSubInfo(GlobalProc **ppSubHash,char **ppMacroNames,int MacroNum);408 366 void DeleteDeclareInfo(void); 409 367 int AddProcPtrInfo( const string &typeExpression, int nowLine ); -
trunk/abdev/BasicCompiler_Common/error.cpp
r204 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/LexicalAnalysis.h> 2 4 3 5 #include <Program.h> 6 #include <Class.h> 4 7 5 8 #include "../BasicCompiler_Common/common.h" … … 301 304 if(num>-100){ 302 305 //エラーのみ 306 303 307 i2=0; 304 308 } -
trunk/abdev/BasicCompiler_Common/gc.cpp
r75 r206 1 #include "stdafx.h" 2 1 3 #include "common.h" 2 4 -
trunk/abdev/BasicCompiler_Common/hash.cpp
r193 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 … … 21 23 } 22 24 23 CONSTINFO *GetConstHash(const char *name){24 //ハッシュ値を取得25 int key;26 key=hash_default(name);27 28 //格納位置を取得29 extern CONSTINFO **ppConstHash;30 CONSTINFO *pci;31 pci=ppConstHash[key];32 while(pci){33 if(lstrcmp(pci->name,name)==0) break;34 35 pci=pci->pNextData;36 }37 38 return pci;39 }40 41 25 DllProc *GetDeclareHash(char *fullName){ 42 26 char ObjName[VN_SIZE]; //オブジェクト変数 43 27 char NestMember[VN_SIZE]; //入れ子メンバ 44 bool isObjectMember = CClass::SplitName( fullName, ObjName, NestMember );28 bool isObjectMember = SplitMemberName( fullName, ObjName, NestMember ); 45 29 46 30 //ハッシュ値を取得 … … 64 48 } 65 49 66 void GetOverloadSubHash( const char *lpszName, std::vector< UserProc *> &subs ){50 void GetOverloadSubHash( const char *lpszName, std::vector<const UserProc *> &subs ){ 67 51 char name[VN_SIZE]; 68 52 … … 75 59 char ObjName[VN_SIZE]; //オブジェクト変数 76 60 char NestMember[VN_SIZE]; //入れ子メンバ 77 bool isObjectMember = CClass::SplitName( name, ObjName, NestMember );61 bool isObjectMember = SplitMemberName( name, ObjName, NestMember ); 78 62 79 63 if(isObjectMember){ … … 84 68 if(lstrcmpi(ObjName,"Super")==0){ 85 69 //クラスメンバ関数内から基底クラスの呼び出し 86 pobj_c= Smoothie::Temp::pCompilingClass;70 pobj_c=compiler.pCompilingClass; 87 71 } 88 72 else{ … … 114 98 115 99 116 if( Smoothie::Temp::pCompilingClass){100 if(compiler.pCompilingClass){ 117 101 //自身のオブジェクトのメンバ関数を検索 118 102 119 103 // 静的メソッド 120 Smoothie::Temp::pCompilingClass->GetStaticMethods().Enum( name, subs );104 compiler.pCompilingClass->GetStaticMethods().Enum( name, subs ); 121 105 122 106 // 動的メソッド 123 Smoothie::Temp::pCompilingClass->GetMethods().Enum( name, subs );107 compiler.pCompilingClass->GetMethods().Enum( name, subs ); 124 108 } 125 109 126 110 127 ///////////////////////////128 111 // グローバル関数を検索 129 /////////////////////////// 130 131 //ハッシュ値を取得 132 int key; 133 key=hash_default(NestMember); 134 135 //格納位置を取得 136 extern GlobalProc **ppSubHash; 137 GlobalProc *pUserProc; 138 pUserProc=ppSubHash[key]; 139 while(pUserProc){ 140 if(!pUserProc->GetParentClassPtr()){ 141 if( pUserProc->IsEqualSymbol( name ) ){ 142 subs.push_back( pUserProc ); 143 } 144 } 145 146 pUserProc=pUserProc->pNextData; 147 } 112 compiler.GetMeta().GetUserProcs().EnumGlobalProcs( NestMember, name, subs ); 148 113 } 149 114 150 115 //オーバーロードされていない関数を取得(昔のコンパイラソースコードとの互換性保持) 151 UserProc *GetSubHash(const char *lpszName,BOOL bError){152 std::vector< UserProc *> subs;116 const UserProc *GetSubHash(const char *lpszName,BOOL bError){ 117 std::vector<const UserProc *> subs; 153 118 GetOverloadSubHash(lpszName,subs); 154 119 … … 166 131 } 167 132 168 UserProc *pUserProc; 169 pUserProc = subs[0]; 133 const UserProc *pUserProc = subs[0]; 170 134 171 135 return pUserProc; 172 136 } 173 UserProc *GetMethodHash(const char *ObjectName,const char *MethodName,const char *Parameter,BOOL bError){137 const UserProc *GetMethodHash(const char *ObjectName,const char *MethodName,const char *Parameter,BOOL bError){ 174 138 char temporary[VN_SIZE]; 175 139 sprintf(temporary,"%s.%s",ObjectName,MethodName); 176 140 177 std::vector<UserProc *> subs; 178 UserProc *pUserProc; 141 std::vector<const UserProc *> subs; 179 142 GetOverloadSubHash(temporary,subs); 180 143 … … 185 148 186 149 //オーバーロードを解決 187 pUserProc=OverloadSolutionWithStrParam(temporary,subs,Parameter,ObjectName);150 const UserProc *pUserProc = OverloadSolutionWithStrParam(temporary,subs,Parameter,ObjectName); 188 151 189 152 return pUserProc; 190 153 } 191 154 192 UserProc *GetClassMethod( const char *className, const char *methodName ){155 const UserProc *GetClassMethod( const char *className, const char *methodName ){ 193 156 const CClass *pClass = compiler.GetMeta().GetClasses().Find( className ); 194 157 if( pClass ){ 195 vector< UserProc *> userProcs;158 vector<const UserProc *> userProcs; 196 159 pClass->GetMethods().Enum( methodName, userProcs ); 197 160 if( userProcs.size() == 1 ){ -
trunk/abdev/BasicCompiler_Common/include/Class.h
r201 r206 1 1 #pragma once 2 2 3 #include <jenga/include/smoothie/Class.h> 4 5 class ClassImpl: public CClass 3 #include <option.h> 4 #include <Program.h> 5 #include <Prototype.h> 6 #include <Method.h> 7 #include <Member.h> 8 9 class UserProc; 10 11 class InheritedInterface 6 12 { 7 public: 8 ClassImpl( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const string &name ) 9 : CClass( namespaceScopes, importedNamespaces, name ) 10 { 11 } 12 ClassImpl() 13 : CClass() 14 { 15 } 16 17 virtual bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const; 13 CClass *pInterfaceClass; 14 int vtblOffset; 15 public: 16 InheritedInterface( CClass *pInterfaceClass, int vtblOffset ) 17 : pInterfaceClass( pInterfaceClass ) 18 , vtblOffset( vtblOffset ) 19 { 20 } 21 22 CClass &GetInterfaceClass() const{ 23 return *pInterfaceClass; 24 } 25 int GetVtblOffset() const 26 { 27 return vtblOffset; 28 } 29 }; 30 typedef vector<InheritedInterface> Interfaces; 31 32 class CClass: public Prototype 33 { 34 public: 35 // 型の種類 36 enum ClassType{ 37 Class, 38 Interface, 39 Enum, 40 Delegate, 41 Structure, 42 }; 43 44 private: 45 ClassType classType; 46 47 // importされている名前空間 48 NamespaceScopesCollection importedNamespaces; 49 50 // 継承クラス 51 const CClass *pSuperClass; 52 53 // Blittable型情報 54 Type blittableType; 55 56 // 実装するインターフェイス 57 Interfaces interfaces; 58 59 // 動的メンバ 60 Members dynamicMembers; 61 62 // 静的メンバ 63 Members staticMembers; 64 65 // 動的メソッド 66 Methods methods; 67 int ConstructorMemberSubIndex; 68 int DestructorMemberSubIndex; 69 int vtblNum; // 仮想関数の数 70 71 // 静的メソッド 72 Methods staticMethods; 73 74 // XMLシリアライズ用 75 private: 76 friend class boost::serialization::access; 77 template<class Archive> void serialize(Archive& ar, const unsigned int version) 78 { 79 trace_for_serialize( "serializing - CClass" ); 80 81 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Prototype ); 82 ar & BOOST_SERIALIZATION_NVP( classType ); 83 ar & BOOST_SERIALIZATION_NVP( importedNamespaces ); 84 ar & boost::serialization::make_nvp( "pSuperClass", const_cast<CClass *&>(pSuperClass) ); 85 ar & BOOST_SERIALIZATION_NVP( blittableType ); 86 //ar & BOOST_SERIALIZATION_NVP( interfaces ); 87 ar & BOOST_SERIALIZATION_NVP( dynamicMembers ); 88 ar & BOOST_SERIALIZATION_NVP( staticMembers ); 89 ar & BOOST_SERIALIZATION_NVP( methods ); 90 ar & BOOST_SERIALIZATION_NVP( ConstructorMemberSubIndex ); 91 ar & BOOST_SERIALIZATION_NVP( DestructorMemberSubIndex ); 92 ar & BOOST_SERIALIZATION_NVP( vtblNum ); 93 ar & BOOST_SERIALIZATION_NVP( staticMethods ); 94 } 95 96 bool isReady; 97 public: 98 99 //アラインメント値 100 int iAlign; 101 102 CClass( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const string &name ) 103 : Prototype( namespaceScopes, name ) 104 , importedNamespaces( importedNamespaces ) 105 , classType( Class ) 106 , pSuperClass( NULL ) 107 , isReady( false ) 108 , iAlign( 0 ) 109 , ConstructorMemberSubIndex( -1 ) 110 , DestructorMemberSubIndex( -1 ) 111 , vtblNum( 0 ) 112 , vtbl_offset( -1 ) 113 , isCompilingConstructor( false ) 114 , isCompilingDestructor( false ) 115 , pobj_NextClass( NULL ) 116 { 117 } 118 CClass() 119 : Prototype() 120 , importedNamespaces() 121 , classType() 122 , pSuperClass( NULL ) 123 , isReady( false ) 124 , iAlign( 0 ) 125 , ConstructorMemberSubIndex( -1 ) 126 , DestructorMemberSubIndex( -1 ) 127 , vtblNum( 0 ) 128 , vtbl_offset( -1 ) 129 , isCompilingConstructor( false ) 130 , isCompilingDestructor( false ) 131 , pobj_NextClass( NULL ) 132 { 133 } 134 ~CClass() 135 { 136 // 動的メンバ 137 BOOST_FOREACH( CMember *member, dynamicMembers ){ 138 delete member; 139 } 140 141 // 静的メンバ 142 BOOST_FOREACH( CMember *member, staticMembers ){ 143 delete member; 144 } 145 } 146 147 void Readed(){ 148 isReady = true; 149 } 150 bool IsReady() const{ 151 return isReady; 152 } 153 154 const NamespaceScopesCollection &GetImportedNamespaces() const 155 { 156 return importedNamespaces; 157 } 158 159 // 継承元クラス 160 bool HasSuperClass() const 161 { 162 return ( pSuperClass != NULL ); 163 } 164 const CClass &GetSuperClass() const 165 { 166 return *pSuperClass; 167 } 168 void SetSuperClass( const CClass *pSuperClass ) 169 { 170 this->pSuperClass = pSuperClass; 171 } 172 173 // Blittable型 174 bool IsBlittableType() const 175 { 176 return !blittableType.IsNull(); 177 } 178 const Type &GetBlittableType() const 179 { 180 return blittableType; 181 } 182 void SetBlittableType( const Type &type ){ 183 blittableType = type; 184 } 185 186 bool IsClass() const; 187 bool IsInterface() const; 188 bool IsEnum() const; 189 bool IsDelegate() const; 190 bool IsStructure() const; 191 void SetClassType( ClassType classType ) 192 { 193 this->classType = classType; 194 } 195 196 197 //コンストラクタをコンパイルしているかどうかのチェックフラグ 198 private: 199 mutable bool isCompilingConstructor; 200 public: 201 void NotifyStartConstructorCompile() const; 202 void NotifyFinishConstructorCompile() const; 203 bool IsCompilingConstructor() const; 204 205 //デストラクタをコンパイルしているかどうかのチェックフラグ 206 private: 207 mutable bool isCompilingDestructor; 208 public: 209 void NotifyStartDestructorCompile() const; 210 void NotifyFinishDestructorCompile() const; 211 bool IsCompilingDestructor() const; 212 213 214 //自身の派生クラスかどうかを確認 215 bool IsSubClass( const CClass *pClass ) const; 216 217 //自身と等しいまたは派生クラスかどうかを確認 218 bool IsEqualsOrSubClass( const CClass *pClass ) const; 219 220 // 自身と等しいまたは派生クラス、基底クラスかどうかを確認 221 bool IsEqualsOrSubClassOrSuperClass( const CClass &objClass ) const; 222 223 // インターフェイス 224 bool HasInterfaces() const 225 { 226 return ( interfaces.size() != 0 ); 227 } 228 bool IsInheritsInterface( const CClass *pInterfaceClass ) const; 18 229 19 230 //継承させる 20 virtualbool Inherits( const char *inheritNames, int nowLine );21 virtualbool InheritsClass( const CClass &inheritsClass, int nowLine );22 virtualbool InheritsInterface( const CClass &inheritsClass, int nowLine );231 bool Inherits( const char *inheritNames, int nowLine ); 232 bool InheritsClass( const CClass &inheritsClass, int nowLine ); 233 bool InheritsInterface( const CClass &inheritsClass, int nowLine ); 23 234 24 235 //メンバ、メソッドの追加 25 236 CMember *CreateMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine ); 26 v irtual void AddMember( Prototype::Accessibility accessibility, bool idConst, bool isRef, char *buffer, int nowLine );27 v irtual void AddStaticMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine );28 29 v irtual void AddMethod(CClass *pobj_c, Prototype::Accessibility accessibility, BOOL bStatic, bool isConst, bool isAbstract,237 void AddMember( Prototype::Accessibility accessibility, bool idConst, bool isRef, char *buffer, int nowLine ); 238 void AddStaticMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine ); 239 240 void AddMethod(CClass *pobj_c, Prototype::Accessibility accessibility, BOOL bStatic, bool isConst, bool isAbstract, 30 241 bool isVirtual, bool isOverride, char *buffer, int nowLine); 31 242 32 virtual LONG_PTR GetVtblGlobalOffset(void) const; 33 virtual void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection); 34 35 36 // XMLシリアライズ用 37 private: 38 friend class boost::serialization::access; 39 template<class Archive> void serialize(Archive& ar, const unsigned int version) 40 { 41 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( CClass ); 42 } 243 //重複チェック 244 bool DupliCheckAll(const char *name); 245 bool DupliCheckMember(const char *name); 246 247 const Members &GetDynamicMembers() const 248 { 249 return dynamicMembers; 250 } 251 const Members &GetStaticMembers() const 252 { 253 return staticMembers; 254 } 255 Members &GetDynamicMembers() 256 { 257 return dynamicMembers; 258 } 259 Members &GetStaticMembers() 260 { 261 return staticMembers; 262 } 263 264 const Methods &GetMethods() const 265 { 266 return methods; 267 } 268 const Methods &GetStaticMethods() const 269 { 270 return staticMethods; 271 } 272 Methods &GetMethods() 273 { 274 return methods; 275 } 276 Methods &GetStaticMethods() 277 { 278 return staticMethods; 279 } 280 281 //デフォルト コンストラクタ 282 const CMethod *GetConstructorMethod() const 283 { 284 if( ConstructorMemberSubIndex == -1 ) return NULL; 285 return methods[ConstructorMemberSubIndex]; 286 } 287 void SetConstructorMemberSubIndex( int constructorMemberSubIndex ) 288 { 289 this->ConstructorMemberSubIndex = constructorMemberSubIndex; 290 } 291 292 //デストラクタ メソッドを取得 293 const CMethod *GetDestructorMethod() const 294 { 295 if( DestructorMemberSubIndex == -1 ) return NULL; 296 return methods[DestructorMemberSubIndex]; 297 } 298 void SetDestructorMemberSubIndex( int destructorMemberSubIndex ) 299 { 300 this->DestructorMemberSubIndex = destructorMemberSubIndex; 301 } 302 303 // vtblに存在する仮想関数の数 304 int GetVtblNum() const 305 { 306 return vtblNum; 307 } 308 void SetVtblNum( int vtblNum ) 309 { 310 this->vtblNum = vtblNum; 311 } 312 void AddVtblNum( int vtblNum ) 313 { 314 this->vtblNum += vtblNum; 315 } 316 bool IsExistVirtualFunctions() const 317 { 318 return ( vtblNum > 0 ); 319 } 320 321 // メンバの総合サイズを取得 322 int GetSize() const; 323 324 // メンバのオフセットを取得 325 int GetMemberOffset( const char *memberName, int *pMemberNum = NULL ) const; 326 private: 327 // アラインメント値を取得 328 int GetAlignment() const; 329 330 //vtbl 331 protected: 332 mutable long vtbl_offset; 333 public: 334 int GetFuncNumInVtbl( const UserProc *pUserProc ) const; 335 LONG_PTR GetVtblGlobalOffset(void) const; 336 void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection); 337 bool IsAbstract() const; 338 339 340 //線形リスト用 341 CClass *pobj_NextClass; 43 342 }; 44 BOOST_IS_ABSTRACT( CClass ); 45 46 class Classes Impl : public Classes343 344 #define MAX_CLASS_HASH 65535 345 class Classes 47 346 { 48 public: 49 ClassesImpl() 50 : Classes() 51 { 52 } 53 54 virtual CClass *Create( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name); 55 virtual void CollectClassesForNameOnly( const BasicSource &source ); 56 57 virtual void InitStaticMember(); 58 59 private: 60 bool MemberVar_LoopRefCheck(const CClass &objClass); 61 public: 62 virtual void GetClass_recur(const char *lpszInheritsClass); 63 virtual void GetAllClassInfo(); 64 virtual void Compile_System_InitializeUserTypes(); 65 66 virtual const CClass *Find( const NamespaceScopes &namespaceScopes, const string &name ) const; 67 347 CClass *pobj_ClassHash[MAX_CLASS_HASH]; 348 int GetHashCode(const char *name) const; 68 349 69 350 // XMLシリアライズ用 … … 73 354 template<class Archive> void load(Archive& ar, const unsigned int version) 74 355 { 75 std::vector<ClassImpl *> vectorClasses; 356 trace_for_serialize( "serializing(load) - Classes" ); 357 358 std::vector<CClass *> vectorClasses; 76 359 ar & BOOST_SERIALIZATION_NVP( vectorClasses ); 77 360 … … 82 365 Insert( pClass ); 83 366 } 367 Iterator_Init(); 84 368 } 85 369 template<class Archive> void save(Archive& ar, const unsigned int version) const 86 370 { 371 trace_for_serialize( "serializing(save) - Classes" ); 372 87 373 // 保存準備 88 std::vector<C lassImpl*> vectorClasses;374 std::vector<CClass *> vectorClasses; 89 375 vectorClasses.clear(); 90 376 Iterator_Reset(); 91 377 while( Iterator_HasNext() ) 92 378 { 93 vectorClasses.push_back( dynamic_cast<C lassImpl*>(Iterator_GetNext()) );379 vectorClasses.push_back( dynamic_cast<CClass *>(Iterator_GetNext()) ); 94 380 } 95 381 96 382 ar & BOOST_SERIALIZATION_NVP( vectorClasses ); 97 383 } 384 385 public: 386 Classes() 387 : pCompilingMethod( NULL ) 388 , pStringClass( NULL ) 389 , pObjectClass( NULL ) 390 , ppobj_IteClass( NULL ) 391 , iIteMaxNum( 0 ) 392 , iIteNextNum( 0 ) 393 { 394 memset( pobj_ClassHash, 0, MAX_CLASS_HASH * sizeof(CClass *) ); 395 } 396 ~Classes() 397 { 398 for(int i=0;i<MAX_CLASS_HASH;i++){ 399 if(pobj_ClassHash[i]) DestroyClass(pobj_ClassHash[i]); 400 } 401 } 402 void DestroyClass(CClass *pobj_c) 403 { 404 if(pobj_c->pobj_NextClass){ 405 DestroyClass(pobj_c->pobj_NextClass); 406 } 407 408 delete pobj_c; 409 } 410 void Clear() 411 { 412 if(ppobj_IteClass) 413 { 414 free(ppobj_IteClass); 415 ppobj_IteClass = NULL; 416 } 417 // TODO: ここはこれでいいのか… 418 memset( pobj_ClassHash, 0, MAX_CLASS_HASH * sizeof(CClass *) ); 419 } 420 421 virtual CClass *Create( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name); 422 bool Insert( CClass *pClass ); 423 CClass *Add( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine); 424 virtual void CollectClassesForNameOnly( const BasicSource &source ); 425 426 void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection); 427 428 virtual void InitStaticMember(); 429 430 private: 431 bool MemberVar_LoopRefCheck(const CClass &objClass); 432 public: 433 virtual void GetClass_recur(const char *lpszInheritsClass); 434 virtual void GetAllClassInfo(); 435 virtual void Compile_System_InitializeUserTypes(); 436 437 const CClass *Find( const NamespaceScopes &namespaceScopes, const string &name ) const; 438 const CClass *Find( const string &fullName ) const; 439 440 441 ///////////////////////////// 442 // 現在コンパイル中の情報 443 ///////////////////////////// 444 private: 445 const CMethod *pCompilingMethod; 446 public: 447 void StartCompile( const UserProc *pUserProc ); 448 449 //現在コンパイル中のメソッド情報を取得 450 const CMethod *GetNowCompilingMethodInfo(){ 451 return pCompilingMethod; 452 } 453 454 455 ///////////////////////////// 456 // 特殊クラス 457 ///////////////////////////// 458 CClass *pStringClass; 459 CClass *pObjectClass; 460 CClass *GetStringClassPtr() const; 461 CClass *GetObjectClassPtr() const; 462 463 464 ///////////////////// 465 // イテレータ 466 ///////////////////// 467 private: 468 mutable CClass **ppobj_IteClass; 469 mutable int iIteMaxNum; 470 mutable int iIteNextNum; 471 public: 472 void Iterator_Init() const; 473 void Iterator_Reset() const; 474 BOOL Iterator_HasNext() const; 475 CClass *Iterator_GetNext() const; 476 int Iterator_GetMaxCount() const; 98 477 }; 99 BOOST_IS_ABSTRACT( Classes ); -
trunk/abdev/BasicCompiler_Common/include/Compiler.h
r199 r206 34 34 static bool StringToType( const std::string &typeName, Type &type ); 35 35 static const std::string TypeToString( const Type &type ); 36 37 // コンパイル中のクラス 38 const CClass *pCompilingClass; 36 39 }; 37 40 -
trunk/abdev/BasicCompiler_Common/include/Const.h
r201 r206 1 1 #pragma once 2 2 3 #include <jenga/include/smoothie/Type.h> 3 #include <Type.h> 4 #include <Symbol.h> 4 5 5 //定数の基底クラス 6 class ConstBase{ 7 const string name; 8 const NamespaceScopes namespaceScopes; 6 7 void AddConst( const NamespaceScopes &namespaceScopes, char *buffer ); 8 9 //定数 10 class CConst : public Symbol, public Jenga::Common::ObjectInHashmap<CConst> 11 { 12 Type type; 13 _int64 i64data; 14 15 // XMLシリアライズ用 16 private: 17 friend class boost::serialization::access; 18 template<class Archive> void serialize(Archive& ar, const unsigned int version) 19 { 20 trace_for_serialize( "serializing - CConst" ); 21 22 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Symbol ); 23 ar & BOOST_SERIALIZATION_NVP( type ); 24 ar & BOOST_SERIALIZATION_NVP( i64data ); 25 } 9 26 10 27 public: 11 28 12 ConstBase( const NamespaceScopes &namespaceScopes, const string &name ) 13 : namespaceScopes( namespaceScopes ) 14 , name( name ) 29 CConst( const NamespaceScopes &namespaceScopes, const std::string &name, const Type &newType, _int64 i64data) 30 : Symbol( namespaceScopes, name ) 31 , type( newType ) 32 , i64data( i64data ) 15 33 { 16 34 } 17 ~ConstBase() 35 CConst( const NamespaceScopes &namespaceScopes, const std::string &name, int value) 36 : Symbol( namespaceScopes, name ) 37 , type( Type(DEF_LONG) ) 38 , i64data( value ) 39 { 40 } 41 CConst() 42 { 43 } 44 ~CConst() 18 45 { 19 46 } 20 47 21 const string &GetName() const48 virtual const std::string &GetKeyName() const 22 49 { 23 return name;50 return GetName(); 24 51 } 25 52 26 bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const; 27 bool IsEqualSymbol( const string &name ) const; 28 }; 29 30 //定数 31 class CConst:public ConstBase{ 32 Type type; 33 _int64 i64data; 34 35 public: 36 CConst *pNext; 37 38 CConst( const NamespaceScopes &namespaceScopes, const string &name, const Type &newType, _int64 i64data); 39 CConst( const NamespaceScopes &namespaceScopes, const string &name, int value); 40 ~CConst(); 41 42 Type GetType(); 43 _int64 GetWholeData(); 53 Type GetType() 54 { 55 return type; 56 } 57 _int64 GetWholeData() 58 { 59 return i64data; 60 } 44 61 double GetDoubleData(); 45 62 }; 63 class Consts : public Jenga::Common::Hashmap<CConst> 64 { 65 // XMLシリアライズ用 66 private: 67 friend class boost::serialization::access; 68 template<class Archive> void serialize(Archive& ar, const unsigned int version) 69 { 70 trace_for_serialize( "serializing - Consts" ); 46 71 47 //定数マクロ 48 class CConstMacro:public ConstBase{ 49 int ParmNum; 50 char **ppParm; 51 public: 52 53 CConstMacro( const NamespaceScopes &namespaceScopes, const string &name, char *Expression); 54 ~CConstMacro(); 55 }; 56 57 //定数管理クラス 58 class CDBConst{ 59 CConst **ppHash; 60 61 CConstMacro **ppobj_Macro; 62 int NumOfMacro; 63 64 //シングルトンクラスなので、プライベートに置く 65 CDBConst(); 66 ~CDBConst(); 67 void _free(); 68 void Free(); 72 ar & boost::serialization::make_nvp("Hashmap_CConst", 73 boost::serialization::base_object<Jenga::Common::Hashmap<CConst>>(*this)); 74 } 69 75 70 76 public: 71 77 72 void Init();73 74 78 void Add( const NamespaceScopes &namespaceScopes, char *buffer); 75 private: 76 void AddConst( const string &name, CConst *newconst); 77 public: 78 void AddConst( const NamespaceScopes &namespaceScopes, const string &name, char *Expression); 79 void AddConst( const NamespaceScopes &namespaceScopes, const string &name, int value); 79 void Add( const NamespaceScopes &namespaceScopes, const string &name, char *Expression); 80 void Add( const NamespaceScopes &namespaceScopes, const string &name, int value); 80 81 81 82 private: … … 87 88 double GetDoubleData(char *Name); 88 89 bool IsStringPtr(char *Name); 90 }; 89 91 92 //定数マクロ 93 class ConstMacro : public Symbol, public Jenga::Common::ObjectInHashmap<ConstMacro> 94 { 95 std::vector<std::string> parameters; 96 std::string expression; 90 97 91 //シングルトンオブジェクト 92 static CDBConst obj; 98 // XMLシリアライズ用 99 private: 100 friend class boost::serialization::access; 101 template<class Archive> void serialize(Archive& ar, const unsigned int version) 102 { 103 trace_for_serialize( "serializing - ConstMacro" ); 104 105 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Symbol ); 106 ar & BOOST_SERIALIZATION_NVP( parameters ); 107 ar & BOOST_SERIALIZATION_NVP( expression ); 108 } 109 110 public: 111 ConstMacro( const NamespaceScopes &namespaceScopes, const std::string &name, const std::vector<std::string> ¶meters, const string &expression ) 112 : Symbol( namespaceScopes, name ) 113 , parameters( parameters ) 114 , expression( expression ) 115 { 116 } 117 ConstMacro() 118 { 119 } 120 ~ConstMacro() 121 { 122 } 123 124 virtual const std::string &GetKeyName() const 125 { 126 return GetName(); 127 } 128 129 const std::vector<std::string> &GetParameters() const 130 { 131 return parameters; 132 } 133 const std::string &GetExpression() const 134 { 135 return expression; 136 } 137 138 bool GetCalcBuffer( const char *parameterStr, char *dest ) const; 93 139 }; 140 class ConstMacros : public Jenga::Common::Hashmap<ConstMacro> 141 { 142 // XMLシリアライズ用 143 private: 144 friend class boost::serialization::access; 145 template<class Archive> void serialize(Archive& ar, const unsigned int version) 146 { 147 trace_for_serialize( "serializing - ConstMacros" ); 148 149 ar & boost::serialization::make_nvp("Hashmap_ConstMacro", 150 boost::serialization::base_object<Jenga::Common::Hashmap<ConstMacro>>(*this)); 151 } 152 153 public: 154 void Add( const NamespaceScopes &namespaceScopes, const std::string &name, const char *parameterStr ); 155 ConstMacro *Find( const std::string &name ); 156 }; -
trunk/abdev/BasicCompiler_Common/include/LexicalScopingImpl.h
r184 r206 26 26 public: 27 27 28 virtual void End(); 29 28 30 //スコープ終了時のデストラクタ呼び出し 29 31 virtual void CallDestructorsOfScopeEnd(); -
trunk/abdev/BasicCompiler_Common/include/MetaImpl.h
r201 r206 3 3 #include <jenga/include/common/BoostXmlSupport.h> 4 4 5 #include <jenga/include/smoothie/ObjectModule.h> 5 #include <option.h> 6 #include <Program.h> 7 #include <Class.h> 8 #include <Procedure.h> 9 #include <TypeDef.h> 10 #include <Variable.h> 11 #include <Const.h> 6 12 7 #include <ClassImpl.h> 8 #include <ProcedureImpl.h> 9 #include <TypeDef.h> 10 11 class MetaImpl : public Meta, public Jenga::Common::BoostXmlSupport<MetaImpl> 13 class MetaImpl : public Jenga::Common::BoostXmlSupport<MetaImpl> 12 14 { 13 15 // 名前空間 14 16 NamespaceScopesCollection namespaceScopesCollection; 15 17 18 // 関数・メソッド 19 UserProcs userProcs; 20 16 21 // クラス 17 ClassesImpl classesImpl; 18 Classes *pNowClassesForDebugger; 22 Classes classesImpl; 23 24 // グローバル変数 25 Variables globalVars; 26 27 // グローバル定数 28 Consts globalConsts; 29 30 // グローバル定数マクロ 31 ConstMacros globalConstMacros; 19 32 20 33 // blittable型 … … 24 37 TypeDefCollection typeDefs; 25 38 39 // 関数ポインタ 40 ProcPointers procPointers; 41 42 // XMLシリアライズ用 43 private: 44 virtual const char *RootTagName() const 45 { 46 return "metaImpl"; 47 } 48 friend class boost::serialization::access; 49 template<class Archive> void serialize(Archive& ar, const unsigned int version) 50 { 51 trace_for_serialize( "serializing - MetaImpl" ); 52 53 ar & BOOST_SERIALIZATION_NVP( namespaceScopesCollection ); 54 ar & BOOST_SERIALIZATION_NVP( userProcs ); 55 ar & BOOST_SERIALIZATION_NVP( classesImpl ); 56 ar & BOOST_SERIALIZATION_NVP( globalVars ); 57 ar & BOOST_SERIALIZATION_NVP( globalConsts ); 58 ar & BOOST_SERIALIZATION_NVP( globalConstMacros ); 59 ar & BOOST_SERIALIZATION_NVP( blittableTypes ); 60 ar & BOOST_SERIALIZATION_NVP( typeDefs ); 61 ar & BOOST_SERIALIZATION_NVP( procPointers ); 62 } 63 64 Classes *pNowClassesForDebugger; 65 26 66 public: 27 67 MetaImpl() 28 : Meta( new ProcPointersImpl() ) 29 , classesImpl() 68 : classesImpl() 30 69 , pNowClassesForDebugger( &classesImpl ) 31 70 { … … 41 80 } 42 81 43 virtual Classes &GetClasses() 82 const UserProcs &GetUserProcs() const 83 { 84 return userProcs; 85 } 86 UserProcs &GetUserProcs() 87 { 88 return userProcs; 89 } 90 91 Classes &GetClasses() 44 92 { 45 93 return *pNowClassesForDebugger; 46 94 } 47 v irtual void SetClasses( Classes *pClasses )95 void SetClasses( Classes *pClasses ) 48 96 { 49 97 this->pNowClassesForDebugger = pClasses; 98 } 99 100 const Variables &GetGlobalVars() const 101 { 102 return globalVars; 103 } 104 Variables &GetGlobalVars() 105 { 106 return globalVars; 107 } 108 109 const Consts &GetGlobalConsts() const 110 { 111 return globalConsts; 112 } 113 Consts &GetGlobalConsts() 114 { 115 return globalConsts; 116 } 117 118 const ConstMacros &GetGlobalConstMacros() const 119 { 120 return globalConstMacros; 121 } 122 ConstMacros &GetGlobalConstMacros() 123 { 124 return globalConstMacros; 50 125 } 51 126 … … 60 135 } 61 136 62 virtual bool AutoWrite( const std::string &filePath ) 137 // 関数ポインタ 138 ProcPointers &GetProcPointers() 139 { 140 return procPointers; 141 } 142 143 bool AutoWrite( const std::string &filePath ) 63 144 { 64 145 std::ofstream ofs( filePath.c_str() ); … … 82 163 return isSuccessful; 83 164 } 84 85 86 // XMLシリアライズ用87 private:88 virtual const char *RootTagName() const89 {90 return "metaImpl";91 }92 friend class boost::serialization::access;93 template<class Archive> void serialize(Archive& ar, const unsigned int version)94 {95 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Meta );96 ar & BOOST_SERIALIZATION_NVP( classesImpl );97 }98 165 }; 99 BOOST_IS_ABSTRACT( Meta ); -
trunk/abdev/BasicCompiler_Common/include/Procedure.h
r201 r206 1 1 #pragma once 2 2 3 #include <jenga/include/smoothie/Procedure.h> 4 5 6 class UserProcImpl : public UserProc 3 #include <jenga/include/common/Hashmap.h> 4 #include <jenga/include/smoothie/Source.h> 5 #include <jenga/include/smoothie/LexicalAnalysis.h> 6 7 #include <option.h> 8 #include <Program.h> 9 #include <Class.h> 10 #include <Method.h> 11 #include <Procedure.h> 12 #include <Parameter.h> 13 #include <Variable.h> 14 15 class CClass; 16 class CMethod; 17 18 class Procedure 7 19 { 8 20 public: 9 UserProcImpl( const string &name, Kind kind, bool isMacro, bool isCdecl, bool isExport ) 10 : UserProc( name, kind, isMacro, isCdecl, isExport ) 11 { 12 } 13 virtual bool SetParamsAndReturnType( const char *sourceOfParams, int nowLine, bool isStatic ); 21 // 種類 22 enum Kind{ 23 Sub, 24 Function, 25 }; 26 27 private: 28 string name; // プロシージャ名 29 30 Kind kind; 31 32 bool isCdecl; 33 mutable bool isUsing; 34 35 protected: 36 37 // パラメータ 38 Parameters params; 39 40 // 戻り値の型 41 Type returnType; 42 43 // ソースコードの位置 44 int codePos; 45 46 // XMLシリアライズ用 47 private: 48 private: 49 friend class boost::serialization::access; 50 BOOST_SERIALIZATION_SPLIT_MEMBER(); 51 template<class Archive> void load(Archive& ar, const unsigned int version) 52 { 53 trace_for_serialize( "serializing - Procedure" ); 54 55 std::string _name; 56 ar & BOOST_SERIALIZATION_NVP( _name ); 57 this->name = Operator_NaturalStringToCalcMarkString( _name ); 58 59 ar & BOOST_SERIALIZATION_NVP( kind ); 60 ar & BOOST_SERIALIZATION_NVP( isCdecl ); 61 ar & BOOST_SERIALIZATION_NVP( isUsing ); 62 ar & BOOST_SERIALIZATION_NVP( params ); 63 ar & BOOST_SERIALIZATION_NVP( returnType ); 64 ar & BOOST_SERIALIZATION_NVP( codePos ); 65 } 66 template<class Archive> void save(Archive& ar, const unsigned int version) const 67 { 68 trace_for_serialize( "serializing - Procedure" ); 69 70 std::string _name = Operator_CalcMarkStringToNaturalString( name ); 71 ar & BOOST_SERIALIZATION_NVP( _name ); 72 73 ar & BOOST_SERIALIZATION_NVP( kind ); 74 ar & BOOST_SERIALIZATION_NVP( isCdecl ); 75 ar & BOOST_SERIALIZATION_NVP( isUsing ); 76 ar & BOOST_SERIALIZATION_NVP( params ); 77 ar & BOOST_SERIALIZATION_NVP( returnType ); 78 ar & BOOST_SERIALIZATION_NVP( codePos ); 79 } 80 81 public: 82 Procedure( const string &name, Kind kind, bool isCdecl ) 83 : name( name ) 84 , kind( kind ) 85 , isCdecl( isCdecl ) 86 , isUsing( false ) 87 , codePos( -1 ) 88 { 89 } 90 Procedure() 91 { 92 } 93 ~Procedure(){ 94 BOOST_FOREACH( Parameter *pParam, params ){ 95 delete pParam; 96 } 97 } 98 99 const string &GetName() const 100 { 101 return name; 102 } 103 104 bool IsSub() const 105 { 106 return ( kind == Sub ); 107 } 108 bool IsFunction() const 109 { 110 return ( kind == Function ); 111 } 112 113 bool IsCdecl() const 114 { 115 return isCdecl; 116 } 117 void Using() const 118 { 119 isUsing = true; 120 } 121 bool IsUsing() const 122 { 123 return isUsing; 124 } 125 126 int GetCodePos() const 127 { 128 return codePos; 129 } 130 131 const Parameters &Params() const 132 { 133 return params; 134 } 135 const Type &ReturnType() const 136 { 137 return returnType; 138 } 14 139 }; 15 140 16 class GlobalProc : public UserProcImpl141 class UserProc : public Procedure, public Jenga::Common::ObjectInHashmap<UserProc> 17 142 { 18 const NamespaceScopes namespaceScopes; 19 const NamespaceScopesCollection importedNamespaces; 143 public: 144 string _paramStr; 145 146 private: 147 NamespaceScopes namespaceScopes; 148 NamespaceScopesCollection importedNamespaces; 149 150 // 親クラスと対応するメソッド 151 const CClass *pParentClass; 152 CMethod *pMethod; 153 154 bool isMacro; 155 156 // パラメータの追加情報 157 int secondParmNum; 158 Parameters realParams; 159 int realSecondParmNum; 160 161 // 各種フラグ 162 bool isExport; 163 mutable bool isSystem; 164 mutable bool isAutoGeneration; 165 mutable bool isCompiled; 166 167 mutable DWORD beginOpAddress; 168 mutable DWORD endOpAddress; 169 170 // ローカル変数 171 mutable Variables localVars; 172 173 // 識別ID 174 int id; 175 176 // XMLシリアライズ用 177 private: 178 friend class boost::serialization::access; 179 template<class Archive> void serialize(Archive& ar, const unsigned int version) 180 { 181 trace_for_serialize( "serializing - UserProc" ); 182 183 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Procedure ); 184 ar & BOOST_SERIALIZATION_NVP( _paramStr ); 185 ar & BOOST_SERIALIZATION_NVP( namespaceScopes ); 186 ar & BOOST_SERIALIZATION_NVP( importedNamespaces ); 187 ar & boost::serialization::make_nvp("pParentClass", const_cast<CClass *&>(pParentClass) ); 188 ar & BOOST_SERIALIZATION_NVP( pMethod ); 189 ar & BOOST_SERIALIZATION_NVP( isMacro ); 190 ar & BOOST_SERIALIZATION_NVP( secondParmNum ); 191 ar & BOOST_SERIALIZATION_NVP( realParams ); 192 ar & BOOST_SERIALIZATION_NVP( realSecondParmNum ); 193 ar & BOOST_SERIALIZATION_NVP( isExport ); 194 ar & BOOST_SERIALIZATION_NVP( isSystem ); 195 ar & BOOST_SERIALIZATION_NVP( isAutoGeneration ); 196 ar & BOOST_SERIALIZATION_NVP( isCompiled ); 197 ar & BOOST_SERIALIZATION_NVP( beginOpAddress ); 198 ar & BOOST_SERIALIZATION_NVP( endOpAddress ); 199 ar & BOOST_SERIALIZATION_NVP( localVars ); 200 ar & BOOST_SERIALIZATION_NVP( id ); 201 } 202 203 public: 204 205 UserProc( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const string &name, Kind kind, bool isMacro, bool isCdecl, bool isExport, int id ) 206 : Procedure( name, kind, isCdecl ) 207 , namespaceScopes( namespaceScopes ) 208 , importedNamespaces( importedNamespaces ) 209 , pParentClass( NULL ) 210 , pMethod( NULL ) 211 , isMacro( isMacro ) 212 , isExport( isExport ) 213 , isSystem( false ) 214 , isAutoGeneration( false ) 215 , isCompiled( false ) 216 , beginOpAddress( 0 ) 217 , endOpAddress( 0 ) 218 , id( id ) 219 { 220 } 221 UserProc() 222 { 223 } 224 ~UserProc() 225 { 226 BOOST_FOREACH( Parameter *pParam, realParams ){ 227 delete pParam; 228 } 229 } 230 231 virtual const std::string &GetKeyName() const 232 { 233 return GetName(); 234 } 235 236 bool IsMacro() const 237 { 238 return isMacro; 239 } 240 241 int GetSecondParmNum() const 242 { 243 return secondParmNum; 244 } 245 const Parameters &RealParams() const 246 { 247 return realParams; 248 } 249 int GetRealSecondParmNum() const 250 { 251 return realSecondParmNum; 252 } 253 254 void ExportOff(){ 255 isExport = false; 256 } 257 bool IsExport() const 258 { 259 return isExport; 260 } 261 void ThisIsSystemProc() const 262 { 263 isSystem = true; 264 } 265 bool IsSystem() const 266 { 267 return isSystem; 268 } 269 void ThisIsAutoGenerationProc() const 270 { 271 isAutoGeneration = true; 272 } 273 bool IsAutoGeneration() const 274 { 275 return isAutoGeneration; 276 } 277 void CompleteCompile() const 278 { 279 isCompiled = true; 280 } 281 void KillCompileStatus() const 282 { 283 isCompiled = false; 284 } 285 bool IsCompiled() const 286 { 287 return isCompiled; 288 } 289 bool IsDestructor() const 290 { 291 return ( GetName()[0] == '~' ); 292 } 293 294 // バイナリコード位置とサイズ 295 DWORD GetBeginOpAddress() const 296 { 297 return beginOpAddress; 298 } 299 void SetBeginOpAddress( DWORD beginOpAddress ) const 300 { 301 this->beginOpAddress = beginOpAddress; 302 } 303 DWORD GetEndOpAddress() const 304 { 305 return endOpAddress; 306 } 307 void SetEndOpAddress( DWORD endOpAddress ) const 308 { 309 this->endOpAddress = endOpAddress; 310 } 311 int GetCodeSize() const 312 { 313 return endOpAddress - beginOpAddress; 314 } 315 316 const NamespaceScopes &GetNamespaceScopes() const; 317 const NamespaceScopesCollection &GetImportedNamespaces() const; 318 319 Variables &GetLocalVars() const 320 { 321 return localVars; 322 } 323 324 int GetId() const 325 { 326 return id; 327 } 328 329 std::string GetFullName() const; 330 331 virtual bool IsDuplication( const UserProc *pUserProc ) const 332 { 333 if( this->GetParentClassPtr() == pUserProc->GetParentClassPtr() 334 && pUserProc->IsEqualSymbol( *this ) 335 && this->Params().Equals( pUserProc->Params() ) ) 336 { 337 return true; 338 } 339 return false; 340 } 341 342 bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const; 343 bool IsEqualSymbol( const UserProc &globalProc ) const; 344 bool IsEqualSymbol( const string &name ) const; 345 346 bool IsVirtual() const; 347 348 void SetParentClass( const CClass *pParentClass ){ 349 this->pParentClass = pParentClass; 350 } 351 const CClass *GetParentClassPtr() const 352 { 353 return pParentClass; 354 } 355 const CClass &GetParentClass() const 356 { 357 return *pParentClass; 358 } 359 bool HasParentClass() const 360 { 361 return ( pParentClass != NULL ); 362 } 363 void SetMethod( CMethod *pMethod ){ 364 this->pMethod = pMethod; 365 } 366 367 bool SetParamsAndReturnType( const char *sourceOfParams, int nowLine, bool isStatic ); 368 369 370 371 ///////////////////////////////////////////////////////////////// 372 // コンパイル中の関数を管理 373 ///////////////////////////////////////////////////////////////// 374 private: 375 static const UserProc *pCompilingUserProc; 376 public: 377 static void CompileStartForGlobalArea(){ 378 pCompilingUserProc = NULL; 379 } 380 static void CompileStartForUserProc( const UserProc *pUserProc ){ 381 pCompilingUserProc = pUserProc; 382 } 383 static bool IsGlobalAreaCompiling(){ 384 return ( pCompilingUserProc == NULL ); 385 } 386 static bool IsLocalAreaCompiling(){ 387 return ( pCompilingUserProc != NULL ); 388 } 389 static const UserProc &CompilingUserProc(){ 390 return *pCompilingUserProc; 391 } 392 }; 393 394 class UserProcs : public Jenga::Common::Hashmap<UserProc> 395 { 396 std::vector<std::string> macroNames; 397 398 // XMLシリアライズ用 399 private: 400 friend class boost::serialization::access; 401 template<class Archive> void serialize(Archive& ar, const unsigned int version) 402 { 403 trace_for_serialize( "serializing - UserProcs" ); 404 405 ar & boost::serialization::make_nvp("Hashmap_UserProcImpl", 406 boost::serialization::base_object<Jenga::Common::Hashmap<UserProc>>(*this)); 407 ar & BOOST_SERIALIZATION_NVP( macroNames ); 408 } 409 410 411 public: 412 UserProcs() 413 { 414 } 415 ~UserProcs() 416 { 417 } 418 419 bool Insert( UserProc *pUserProc, int nowLine ); 420 421 UserProc *Add( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,bool isVirtual,CClass *pobj_c, bool isStatic); 422 423 void EnumGlobalProcs( const char *simpleName, const char *localName, std::vector<const UserProc *> &subs ); 424 425 static void CollectUserProcs( const BasicSource &source, UserProcs &userProcs ); 426 }; 427 428 class DllProc : public Procedure 429 { 430 NamespaceScopes namespaceScopes; 431 432 string dllFileName; 433 string alias; 434 int lookupAddress; 435 436 // XMLシリアライズ用 437 private: 438 friend class boost::serialization::access; 439 template<class Archive> void serialize(Archive& ar, const unsigned int version) 440 { 441 trace_for_serialize( "serializing - DllProc" ); 442 443 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Procedure ); 444 ar & BOOST_SERIALIZATION_NVP( namespaceScopes ); 445 ar & BOOST_SERIALIZATION_NVP( dllFileName ); 446 ar & BOOST_SERIALIZATION_NVP( alias ); 447 ar & BOOST_SERIALIZATION_NVP( lookupAddress ); 448 } 449 20 450 public: 21 451 // ハッシュリスト用 22 GlobalProc *pNextData;23 24 GlobalProc( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const string &name, Kind kind, bool isMacro, bool isCdecl, bool isExport):25 UserProcImpl( name, kind, isMacro, isCdecl, isExport),452 DllProc *pNextData; 453 454 DllProc( const NamespaceScopes &namespaceScopes, const string &name, Kind kind, bool isCdecl, const string &dllFileName, const string &alias ): 455 Procedure( name, kind, isCdecl ), 26 456 namespaceScopes( namespaceScopes ), 27 importedNamespaces( importedNamespaces ), 457 dllFileName( dllFileName ), 458 alias( alias ), 459 lookupAddress( 0 ), 28 460 pNextData( NULL ) 29 {} 30 ~GlobalProc(){} 31 32 virtual const NamespaceScopes &GetNamespaceScopes() const; 33 virtual const NamespaceScopesCollection &GetImportedNamespaces() const 34 { 35 return importedNamespaces; 36 } 461 { 462 } 463 ~DllProc(){} 37 464 38 465 virtual bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const; 39 virtual bool IsEqualSymbol( const GlobalProc &globalProc ) const; 40 virtual bool IsEqualSymbol( const string &name ) const; 466 bool IsEqualSymbol( const string &name ) const; 467 468 const NamespaceScopes &GetNamespaceScopes() const 469 { 470 return namespaceScopes; 471 } 472 473 const string &GetDllFileName() const 474 { 475 return dllFileName; 476 } 477 const string &GetAlias() const 478 { 479 return alias; 480 } 481 482 void SetLookupAddress( int lookupAddress ){ 483 this->lookupAddress = lookupAddress; 484 } 485 int GetLookupAddress() const 486 { 487 return lookupAddress; 488 } 489 490 bool SetParamsAndReturnType( const char *sourceOfParams, int nowLine ); 41 491 }; 42 492 43 class DllProcImpl : public DllProc493 class ProcPointer : public Procedure 44 494 { 45 public: 46 DllProcImpl( const NamespaceScopes &namespaceScopes, const string &name, Kind kind, bool isCdecl, const string &dllFileName, const string &alias ) 47 : DllProc( namespaceScopes, name, kind, isCdecl, dllFileName, alias ) 48 { 49 } 50 51 virtual bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const; 495 // XMLシリアライズ用 496 private: 497 friend class boost::serialization::access; 498 template<class Archive> void serialize(Archive& ar, const unsigned int version) 499 { 500 trace_for_serialize( "serializing - ProcPointer" ); 501 502 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Procedure ); 503 } 504 505 public: 506 ProcPointer( Kind kind ) 507 : Procedure( "", kind, false ) 508 { 509 } 510 ProcPointer() 511 { 512 } 513 ~ProcPointer(){} 52 514 53 515 virtual bool SetParamsAndReturnType( const char *sourceOfParams, int nowLine ); 54 516 }; 55 517 56 class ProcPointer Impl : public ProcPointer518 class ProcPointers : public vector<ProcPointer *> 57 519 { 58 public: 59 ProcPointerImpl( Kind kind ):60 ProcPointer( kind )61 {62 }63 64 virtual bool SetParamsAndReturnType( const char *sourceOfParams, int nowLine ); 65 }; 66 67 class ProcPointersImpl : public ProcPointers 68 { 69 public: 70 ProcPointers Impl()71 { 72 } 73 ~ProcPointers Impl()520 // XMLシリアライズ用 521 private: 522 friend class boost::serialization::access; 523 template<class Archive> void serialize(Archive& ar, const unsigned int version) 524 { 525 trace_for_serialize( "serializing - ProcPointers" ); 526 527 ar & boost::serialization::make_nvp("vector_ProcPointer", 528 boost::serialization::base_object<vector<ProcPointer *>>(*this)); 529 } 530 531 public: 532 ProcPointers() 533 { 534 } 535 ~ProcPointers() 74 536 { 75 537 Clear(); -
trunk/abdev/BasicCompiler_Common/include/SmoothieImpl.h
r193 r206 2 2 3 3 #include <jenga/include/smoothie/Smoothie.h> 4 #include <jenga/include/smoothie/ObjectModule.h>5 4 6 5 #include <MetaImpl.h> -
trunk/abdev/BasicCompiler_Common/include/TypeDef.h
r193 r206 4 4 #include <string> 5 5 6 #include <jenga/include/smoothie/Type.h>7 6 #include <jenga/include/smoothie/Namespace.h> 7 8 #include <Type.h> 9 #include <Symbol.h> 8 10 9 11 using namespace std; … … 11 13 class TypeDefCollection; 12 14 13 class TypeDef{ 15 class TypeDef : public Symbol 16 { 14 17 friend TypeDefCollection; 15 18 16 NamespaceScopes namespaceScopes;17 18 string name;19 19 string baseName; 20 20 Type baseType; 21 22 // XMLシリアライズ用 23 private: 24 friend class boost::serialization::access; 25 template<class Archive> void serialize(Archive& ar, const unsigned int version) 26 { 27 trace_for_serialize( "serializing - TypeDef" ); 28 29 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Symbol ); 30 ar & BOOST_SERIALIZATION_NVP( baseName ); 31 ar & BOOST_SERIALIZATION_NVP( baseType ); 32 } 33 21 34 public: 22 35 TypeDef( const NamespaceScopes &namespaceScopes, const string &name, const string &baseName, int nowLine ); 23 ~TypeDef(); 36 TypeDef() 37 { 38 } 39 ~TypeDef() 40 { 41 } 24 42 25 const string &GetName() const26 {27 return name;28 }29 43 const string &GetBaseName() const 30 44 { … … 35 49 return baseType; 36 50 } 37 38 bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const;39 bool IsEqualSymbol( const string &name ) const;40 51 }; 41 52 42 class TypeDefCollection : public vector<TypeDef>53 class TypeDefCollection : public std::vector<TypeDef> 43 54 { 55 // XMLシリアライズ用 56 private: 57 friend class boost::serialization::access; 58 template<class Archive> void serialize(Archive& ar, const unsigned int version) 59 { 60 trace_for_serialize( "serializing - TypeDefCollection" ); 61 62 ar & boost::serialization::make_nvp("vector_TypeDef", 63 boost::serialization::base_object<std::vector<TypeDef>>(*this)); 64 } 65 44 66 public: 45 67 TypeDefCollection(); -
trunk/abdev/BasicCompiler_Common/include/option.h
r182 r206 23 23 24 24 // ログ生成しない場合はこの下の行をコメントアウトする 25 //#define USE_TRACE25 #define USE_TRACE 26 26 27 27 // オーバーロードに関するログを生成する 28 #define USE_TRACE_FOR_OVERLOAD28 //#define USE_TRACE_FOR_OVERLOAD 29 29 30 30 // モジュールサイズに関するログを生成する 31 #define USE_TRACE_FOR_SIZE 31 //#define USE_TRACE_FOR_SIZE 32 33 // XMLシリアライズに関するログを生成する 34 #define USE_TRACE_FOR_SERIALIZE 35 36 // ソースコードステップに関するログを生成する 37 #define USE_TRACE_FOR_SOURCECODESTEP 32 38 33 39 … … 53 59 #define trace_for_size(s) 54 60 #endif 61 62 #ifdef USE_TRACE_FOR_SERIALIZE 63 #define trace_for_serialize(s) trace(s) 64 #else 65 #define trace_for_serialize(s) 66 #endif 67 68 #ifdef USE_TRACE_FOR_SOURCECODESTEP 69 #define trace_for_sourcecodestep(s) trace( "[source code step] " << s) 70 #else 71 #define trace_for_sourcecodestep(s) 72 #endif -
trunk/abdev/BasicCompiler_Common/src/Class.cpp
r204 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 #include <jenga/include/smoothie/Class.h>3 4 #include <jenga/include/smoothie/Source.h> 4 5 #include <jenga/include/smoothie/SmoothieException.h> 5 6 #include <jenga/include/smoothie/LexicalAnalysis.h> 6 7 7 #include <Class Impl.h>8 #include <Class.h> 8 9 #include <Compiler.h> 9 10 #include <NamespaceSupporter.h> … … 15 16 #include "../../BasicCompiler32/opcode.h" 16 17 #endif 17 18 19 18 20 19 … … 77 76 78 77 79 bool ClassImpl::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const 80 { 81 if( GetName() != name ){ 78 bool CClass::IsClass() const 79 { 80 return classType == CClass::Class; 81 } 82 bool CClass::IsInterface() const 83 { 84 return classType == CClass::Interface; 85 } 86 bool CClass::IsEnum() const 87 { 88 return classType == CClass::Enum; 89 } 90 bool CClass::IsDelegate() const 91 { 92 return classType == CClass::Delegate; 93 } 94 bool CClass::IsStructure() const 95 { 96 return classType == CClass::Structure; 97 } 98 99 100 // コンストラクタのコンパイルを開始 101 void CClass::NotifyStartConstructorCompile() const 102 { 103 isCompilingConstructor = true; 104 } 105 106 //コンストラクタのコンパイルを終了 107 void CClass::NotifyFinishConstructorCompile() const 108 { 109 isCompilingConstructor = false; 110 } 111 112 //コンストラクタをコンパイル中かどうかを判別 113 bool CClass::IsCompilingConstructor() const 114 { 115 return isCompilingConstructor; 116 } 117 118 //デストラクタのコンパイルを開始 119 void CClass::NotifyStartDestructorCompile() const{ 120 isCompilingDestructor = true; 121 } 122 123 //デストラクタのコンパイルを終了 124 void CClass::NotifyFinishDestructorCompile() const{ 125 isCompilingDestructor = false; 126 } 127 128 //デストラクタをコンパイル中かどうかを判別 129 bool CClass::IsCompilingDestructor() const 130 { 131 return isCompilingDestructor; 132 } 133 134 //自身の派生クラスかどうかを確認 135 bool CClass::IsSubClass( const CClass *pClass ) const 136 { 137 if( !pClass->HasSuperClass() ) 138 { 82 139 return false; 83 140 } 84 141 85 return compiler.GetNamespaceSupporter().IsSameAreaNamespace( GetNamespaceScopes(), namespaceScopes ); 86 } 87 88 bool ClassImpl::Inherits( const char *inheritNames, int nowLine ){ 142 const CClass *pTempClass = &pClass->GetSuperClass(); 143 while( pTempClass ){ 144 if( this == pTempClass ) return true; 145 pTempClass = &pTempClass->GetSuperClass(); 146 } 147 return false; 148 } 149 150 //自身と等しいまたは派生クラスかどうかを確認 151 bool CClass::IsEqualsOrSubClass( const CClass *pClass ) const 152 { 153 if( IsEquals( pClass ) ) return true; 154 return IsSubClass( pClass ); 155 } 156 157 // 自身と等しいまたは派生クラス、基底クラスかどうかを確認 158 bool CClass::IsEqualsOrSubClassOrSuperClass( const CClass &objClass ) const 159 { 160 if( IsEquals( &objClass ) ) return true; 161 if( IsSubClass( &objClass ) ) return true; 162 if( objClass.IsSubClass( this ) ) return true; 163 return false; 164 } 165 166 bool CClass::IsInheritsInterface( const CClass *pInterfaceClass ) const 167 { 168 BOOST_FOREACH( const InheritedInterface &objInterface, interfaces ){ 169 if( pInterfaceClass == &objInterface.GetInterfaceClass() ){ 170 return true; 171 } 172 } 173 return false; 174 } 175 176 bool CClass::Inherits( const char *inheritNames, int nowLine ){ 89 177 int i = 0; 90 178 bool isInheritsClass = false; … … 183 271 return true; 184 272 } 185 bool C lassImpl::InheritsClass( const CClass &inheritsClass, int nowLine ){273 bool CClass::InheritsClass( const CClass &inheritsClass, int nowLine ){ 186 274 187 275 //ループ継承でないかをチェック … … 245 333 return true; 246 334 } 247 bool C lassImpl::InheritsInterface( const CClass &inheritsInterface, int nowLine ){335 bool CClass::InheritsInterface( const CClass &inheritsInterface, int nowLine ){ 248 336 249 337 //ループ継承でないかをチェック … … 291 379 return true; 292 380 } 293 CMember *C lassImpl::CreateMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine )381 CMember *CClass::CreateMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine ) 294 382 { 295 383 extern int cp; … … 299 387 char initBuffer[VN_SIZE]; 300 388 char lpszConstructParameter[VN_SIZE]; 301 int SubScripts[MAX_ARRAYDIM];389 Subscripts subscripts; 302 390 Type type; 303 GetDimentionFormat(buffer,VarName, SubScripts,type,initBuffer,lpszConstructParameter);391 GetDimentionFormat(buffer,VarName,subscripts,type,initBuffer,lpszConstructParameter); 304 392 305 393 //重複チェック … … 308 396 } 309 397 310 CMember *pMember = new CMember( accessibility, VarName, type, isConst, initBuffer, lpszConstructParameter );398 CMember *pMember = new CMember( accessibility, VarName, type, isConst, subscripts, initBuffer, lpszConstructParameter ); 311 399 pMember->source_code_address = nowLine; 312 memcpy( pMember->SubScripts, SubScripts, MAX_ARRAYDIM * sizeof(int) );313 400 return pMember; 314 401 } 315 void C lassImpl::AddMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine ){402 void CClass::AddMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine ){ 316 403 dynamicMembers.push_back( 317 404 CreateMember( accessibility, isConst, isRef, buffer, nowLine ) 318 405 ); 319 406 } 320 void C lassImpl::AddStaticMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine ){407 void CClass::AddStaticMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine ){ 321 408 staticMembers.push_back( 322 409 CreateMember( accessibility, isConst, isRef, buffer, nowLine ) … … 324 411 } 325 412 326 void C lassImpl::AddMethod(CClass *pobj_c, Prototype::Accessibility accessibility, BOOL bStatic, bool isConst, bool isAbstract,413 void CClass::AddMethod(CClass *pobj_c, Prototype::Accessibility accessibility, BOOL bStatic, bool isConst, bool isAbstract, 327 414 bool isVirtual, bool isOverride, char *buffer, int nowLine){ 328 415 int i,i2; … … 340 427 341 428 //関数ハッシュへ登録 342 GlobalProc *pUserProc; 343 pUserProc=AddSubData( NamespaceScopes(), NamespaceScopesCollection(), buffer,nowLine,isVirtual,pobj_c, (bStatic!=0) ); 429 UserProc *pUserProc = compiler.GetMeta().GetUserProcs().Add( NamespaceScopes(), NamespaceScopesCollection(), buffer,nowLine,isVirtual,pobj_c, (bStatic!=0) ); 344 430 if(!pUserProc) return; 345 431 … … 394 480 if( pMethod->GetInheritsClassPtr() ) continue; 395 481 396 if( pMethod-> pUserProc->GetName() == temporary ){397 if( pMethod-> pUserProc->Params().Equals( pUserProc->Params() ) ){482 if( pMethod->GetUserProc().GetName() == temporary ){ 483 if( pMethod->GetUserProc().Params().Equals( pUserProc->Params() ) ){ 398 484 //関数名、パラメータ属性が合致したとき 399 485 SetError(15,pUserProc->GetName().c_str(),nowLine); … … 408 494 //メソッドのオーバーライド 409 495 BOOST_FOREACH( CMethod *pMethod, pobj_c->GetMethods() ){ 410 if( pMethod-> pUserProc->GetName() == temporary ){411 if( pMethod-> pUserProc->Params().Equals( pUserProc->Params() ) ){496 if( pMethod->GetUserProc().GetName() == temporary ){ 497 if( pMethod->GetUserProc().Params().Equals( pUserProc->Params() ) ){ 412 498 413 499 if(pMethod->IsVirtual()){ 414 500 //メンバ関数を上書き 415 pMethod-> pUserProc=pUserProc;501 pMethod->SetUserProcPtr( pUserProc ); 416 502 pMethod->Override(); 417 503 … … 446 532 } 447 533 448 LONG_PTR ClassImpl::GetVtblGlobalOffset(void) const 534 bool CClass::DupliCheckAll(const char *name){ 535 //重複チェック 536 537 //メンバ 538 if(DupliCheckMember(name)) return 1; 539 540 //メソッド 541 BOOST_FOREACH( const CMethod *pMethod, methods ){ 542 if( lstrcmp( name, pMethod->GetUserProc().GetName().c_str() ) == 0 ){ 543 return 1; 544 } 545 } 546 547 return 0; 548 } 549 bool CClass::DupliCheckMember(const char *name){ 550 //重複チェック 551 552 // 動的メンバ 553 BOOST_FOREACH( CMember *pMember, dynamicMembers ){ 554 if( GetName() == pMember->GetName() ){ 555 return 1; 556 } 557 } 558 559 // 静的メンバ 560 BOOST_FOREACH( CMember *pMember, staticMembers ){ 561 if( GetName() == pMember->GetName() ){ 562 return 1; 563 } 564 } 565 566 return 0; 567 } 568 569 //サイズを取得 570 int CClass::GetSize() const 571 { 572 return GetMemberOffset( NULL, NULL ); 573 } 574 575 //メンバのオフセットを取得 576 int CClass::GetMemberOffset( const char *memberName, int *pMemberNum ) const 577 { 578 int i2; 579 580 //仮想関数が存在する場合は関数リストへのポインタのサイズを追加 581 int offset = IsExistVirtualFunctions() ? PTR_SIZE : 0; 582 583 int alignment; 584 if(iAlign) alignment=iAlign; 585 else alignment=1; 586 587 int iMaxAlign=0; 588 int i = -1; 589 BOOST_FOREACH( CMember *pMember, dynamicMembers ){ 590 i++; 591 592 i2 = pMember->GetType().GetSize(); 593 594 //アラインメントを算出 595 int member_size; 596 if( pMember->GetType().IsStruct() ){ 597 //メンバクラスのアラインメントを取得 598 member_size=pMember->GetType().GetClass().GetAlignment(); 599 } 600 else{ 601 //メンバサイズを取得 602 member_size=i2; 603 } 604 if(iMaxAlign<member_size) iMaxAlign=member_size; 605 606 //アラインメントを考慮 607 if(iAlign&&iAlign<member_size){ 608 if(offset%alignment) offset+=alignment-(offset%alignment); 609 } 610 else{ 611 if(alignment<member_size) alignment=member_size; 612 613 if(member_size==0){ 614 //メンバを持たないクラス 615 //※何もしない(オフセットの計算をしない) 616 } 617 else{ 618 if(offset%member_size) offset+=member_size-(offset%member_size); 619 } 620 } 621 622 if(memberName){ 623 //メンバ指定がある場合は、オフセットを返す 624 if( pMember->GetName() == memberName ){ 625 if(pMemberNum) *pMemberNum=i; 626 return offset; 627 } 628 } 629 630 //配列を考慮したメンバサイズを取得 631 member_size = i2 * Variable::GetSubScriptCounts( pMember->GetSubscripts() ); 632 633 //メンバサイズを加算 634 offset+= member_size; 635 } 636 637 if(iMaxAlign<alignment) alignment=iMaxAlign; 638 639 //アラインメントを考慮 640 if(alignment){ 641 if(offset%alignment) offset+=alignment-(offset%alignment); 642 } 643 644 if(pMemberNum) *pMemberNum=i; 645 return offset; 646 } 647 int CClass::GetAlignment() const 648 { 649 //仮想関数が存在する場合は関数リストへのポインタのサイズを追加 650 int alignment = IsExistVirtualFunctions() ? PTR_SIZE : 0; 651 652 BOOST_FOREACH( CMember *pMember, dynamicMembers ){ 653 int member_size; 654 if(pMember->GetType().IsStruct()){ 655 //メンバクラスのアラインメントを取得 656 member_size=pMember->GetType().GetClass().GetAlignment(); 657 } 658 else{ 659 //メンバサイズを取得 660 member_size = pMember->GetType().GetSize(); 661 } 662 663 //アラインメントをセット 664 if(alignment<member_size) alignment=member_size; 665 } 666 667 if(alignment==0) return 0; 668 669 if(iAlign) alignment=iAlign; 670 671 return alignment; 672 } 673 int CClass::GetFuncNumInVtbl( const UserProc *pUserProc ) const 674 { 675 int n = 0; 676 BOOST_FOREACH( const CMethod *pMethod, methods ){ 677 if( &pMethod->GetUserProc() == pUserProc ) break; 678 if( pMethod->IsVirtual() ) n++; 679 } 680 return n; 681 } 682 LONG_PTR CClass::GetVtblGlobalOffset(void) const 449 683 { 450 684 … … 458 692 ////////////////////////////////////// 459 693 460 UserProc **ppsi;461 ppsi=( UserProc **)malloc(GetVtblNum()*sizeof(UserProc *));694 const UserProc **ppsi; 695 ppsi=(const UserProc **)malloc(GetVtblNum()*sizeof(UserProc *)); 462 696 463 697 //関数テーブルに値をセット … … 465 699 BOOST_FOREACH( const CMethod *pMethod, methods ){ 466 700 if(pMethod->IsVirtual()){ 467 pMethod-> pUserProc->Using();701 pMethod->GetUserProc().Using(); 468 702 469 703 if(pMethod->IsAbstract()){ … … 474 708 } 475 709 else{ 476 ppsi[i2]= pMethod->pUserProc;710 ppsi[i2]=&pMethod->GetUserProc(); 477 711 } 478 712 i2++; … … 490 724 return vtbl_offset; 491 725 } 492 void C lassImpl::ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection){726 void CClass::ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection){ 493 727 if(vtbl_offset==-1) return; 494 728 … … 501 735 pUserProc=(UserProc *)pVtbl[i]; 502 736 if(!pUserProc) continue; 503 pVtbl[i]=pUserProc->beginOpAddress+ImageBase+MemPos_CodeSection; 504 } 505 } 506 507 CClass *ClassesImpl::Create( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name){ 508 return new ClassImpl(namespaceScopes, importedNamespaces, name); 509 } 510 511 void ClassesImpl::CollectClassesForNameOnly( const BasicSource &source ) 737 pVtbl[i]=pUserProc->GetBeginOpAddress()+ImageBase+MemPos_CodeSection; 738 } 739 } 740 bool CClass::IsAbstract() const 741 { 742 // 未実装(abstract)の仮想関数を持つ場合はtrueを返す 743 744 BOOST_FOREACH( const CMethod *pMethod, methods ){ 745 if(pMethod->IsVirtual()){ 746 if(pMethod->IsAbstract()){ 747 return true; 748 } 749 } 750 } 751 752 return false; 753 } 754 755 756 int Classes::GetHashCode(const char *name) const 757 { 758 int key; 759 760 for(key=0;*name!='\0';name++){ 761 key=((key<<8)+ *name )%MAX_CLASS_HASH; 762 } 763 764 return key; 765 } 766 767 CClass *Classes::Create( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name){ 768 return new CClass(namespaceScopes, importedNamespaces, name); 769 } 770 bool Classes::Insert( CClass *pClass ) 771 { 772 // キャッシュしておくクラス 773 if( pClass->GetName() == "String" ) 774 { 775 pStringClass=pClass; 776 } 777 else if( pClass->GetName() == "Object" ) 778 { 779 pObjectClass = pClass; 780 } 781 782 ///////////////////////////////// 783 // ハッシュデータに追加 784 ///////////////////////////////// 785 786 int key; 787 key=GetHashCode( pClass->GetName().c_str() ); 788 789 if(pobj_ClassHash[key]){ 790 CClass *pobj_c2; 791 pobj_c2=pobj_ClassHash[key]; 792 while(1){ 793 if( ((const Prototype *)pobj_c2)->IsEqualSymbol( *(const Prototype *)pClass ) ){ 794 //名前空間及びクラス名が重複した場合 795 SmoothieException::Throw(15,pClass->GetName()); 796 return false; 797 } 798 799 if(pobj_c2->pobj_NextClass==0) break; 800 pobj_c2=pobj_c2->pobj_NextClass; 801 } 802 pobj_c2->pobj_NextClass=pClass; 803 } 804 else{ 805 pobj_ClassHash[key]=pClass; 806 } 807 return true; 808 } 809 CClass *Classes::Add( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine){ 810 ////////////////////////////////////////////////////////////////////////// 811 // クラスを追加 812 // ※名前のみを登録。その他の情報はSetClassメソッドで! 813 ////////////////////////////////////////////////////////////////////////// 814 815 CClass *pClass = Create(namespaceScopes, importedNamespaces, name); 816 817 if( !Insert( pClass ) ) 818 { 819 return NULL; 820 } 821 822 return pClass; 823 } 824 825 void Classes::CollectClassesForNameOnly( const BasicSource &source ) 512 826 { 513 827 int i, i2; … … 641 955 } 642 956 643 void ClassesImpl::InitStaticMember(){ 957 void Classes::ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection){ 958 int i; 959 for(i=0;i<MAX_CLASS_HASH;i++){ 960 if(pobj_ClassHash[i]){ 961 CClass *pobj_c; 962 pobj_c=pobj_ClassHash[i]; 963 while(1){ 964 pobj_c->ActionVtblSchedule(ImageBase,MemPos_CodeSection); 965 966 if(pobj_c->pobj_NextClass==0) break; 967 pobj_c=pobj_c->pobj_NextClass; 968 } 969 } 970 } 971 } 972 973 974 void Classes::InitStaticMember(){ 644 975 //静的メンバをグローバル領域に作成 645 976 … … 662 993 dim( 663 994 temporary, 664 member-> SubScripts,995 member->GetSubscripts(), 665 996 member->GetType(), 666 997 member->GetInitializeExpression().c_str(), … … 679 1010 cp=back_cp; 680 1011 } 681 bool Classes Impl::MemberVar_LoopRefCheck(const CClass &objClass){1012 bool Classes::MemberVar_LoopRefCheck(const CClass &objClass){ 682 1013 bool result = true; 683 1014 BOOST_FOREACH( CMember *pMember, objClass.GetDynamicMembers() ){ … … 704 1035 return result; 705 1036 } 706 void Classes Impl::GetClass_recur(const char *lpszInheritsClass){1037 void Classes::GetClass_recur(const char *lpszInheritsClass){ 707 1038 extern char *basbuf; 708 1039 int i,i2,i3,sub_address,top_pos; … … 1156 1487 compiler.GetNamespaceSupporter().GetLivingNamespaceScopes() = backupNamespaceScopes; 1157 1488 } 1158 void Classes Impl::GetAllClassInfo(void){1489 void Classes::GetAllClassInfo(void){ 1159 1490 //ループ継承チェック用のクラス 1160 1491 pobj_LoopRefCheck=new CLoopRefCheck(); … … 1169 1500 this->Iterator_Init(); 1170 1501 } 1171 void Classes Impl::Compile_System_InitializeUserTypes(){1502 void Classes::Compile_System_InitializeUserTypes(){ 1172 1503 char temporary[VN_SIZE]; 1173 1504 … … 1296 1627 } 1297 1628 1298 const CClass *Classes Impl::Find( const NamespaceScopes &namespaceScopes, const string &name ) const1629 const CClass *Classes::Find( const NamespaceScopes &namespaceScopes, const string &name ) const 1299 1630 { 1300 1631 int key; … … 1333 1664 return NULL; 1334 1665 } 1666 const CClass *Classes::Find( const string &fullName ) const 1667 { 1668 char AreaName[VN_SIZE] = ""; //オブジェクト変数 1669 char NestName[VN_SIZE] = ""; //入れ子メンバ 1670 bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName ); 1671 1672 return Find( NamespaceScopes( AreaName ), NestName ); 1673 } 1674 void Classes::StartCompile( const UserProc *pUserProc ){ 1675 const CClass *pParentClass = pUserProc->GetParentClassPtr(); 1676 if( pParentClass ){ 1677 pParentClass->Using(); 1678 1679 pCompilingMethod = pParentClass->GetMethods().GetMethodPtr( pUserProc ); 1680 if( !pCompilingMethod ){ 1681 pCompilingMethod = pParentClass->GetStaticMethods().GetMethodPtr( pUserProc ); 1682 if( !pCompilingMethod ){ 1683 SmoothieException::Throw(300); 1684 } 1685 } 1686 } 1687 else{ 1688 pCompilingMethod = NULL; 1689 } 1690 } 1691 1692 CClass *Classes::GetStringClassPtr() const 1693 { 1694 if( !pStringClass ){ 1695 SmoothieException::Throw(); 1696 return NULL; 1697 } 1698 return pStringClass; 1699 } 1700 CClass *Classes::GetObjectClassPtr() const 1701 { 1702 if( !pObjectClass ){ 1703 SmoothieException::Throw(); 1704 return NULL; 1705 } 1706 return pObjectClass; 1707 } 1708 1709 1710 ////////////////////// 1711 // イテレータ 1712 ////////////////////// 1713 1714 void Classes::Iterator_Init() const 1715 { 1716 if(ppobj_IteClass) free(ppobj_IteClass); 1717 1718 iIteMaxNum=0; 1719 iIteNextNum=0; 1720 ppobj_IteClass=(CClass **)malloc(1); 1721 1722 int i; 1723 for(i=0;i<MAX_CLASS_HASH;i++){ 1724 if(pobj_ClassHash[i]){ 1725 CClass *pobj_c; 1726 pobj_c=pobj_ClassHash[i]; 1727 while(1){ 1728 ppobj_IteClass=(CClass **)realloc(ppobj_IteClass,(iIteMaxNum+1)*sizeof(CClass *)); 1729 ppobj_IteClass[iIteMaxNum]=pobj_c; 1730 iIteMaxNum++; 1731 1732 if(pobj_c->pobj_NextClass==0) break; 1733 pobj_c=pobj_c->pobj_NextClass; 1734 } 1735 } 1736 } 1737 } 1738 void Classes::Iterator_Reset() const 1739 { 1740 iIteNextNum = 0; 1741 } 1742 BOOL Classes::Iterator_HasNext() const 1743 { 1744 if(iIteNextNum<iIteMaxNum) return 1; 1745 return 0; 1746 } 1747 CClass *Classes::Iterator_GetNext() const 1748 { 1749 CClass *pobj_c = ppobj_IteClass[iIteNextNum]; 1750 iIteNextNum++; 1751 return pobj_c; 1752 } 1753 int Classes::Iterator_GetMaxCount() const 1754 { 1755 return iIteMaxNum; 1756 } -
trunk/abdev/BasicCompiler_Common/src/CodeGenerator.cpp
r184 r206 1 #include "stdafx.h" 2 1 3 #include <windows.h> 2 4 #include <stdlib.h> -
trunk/abdev/BasicCompiler_Common/src/Compiler.cpp
r196 r206 1 #include <jenga/include/smoothie/Type.h> 1 #include "stdafx.h" 2 2 3 #include <jenga/include/smoothie/SmoothieException.h> 3 4 4 5 #include <Compiler.h> 6 #include <Type.h> 5 7 6 8 Compiler compiler; -
trunk/abdev/BasicCompiler_Common/src/Const.cpp
r201 r206 1 #include "stdafx.h" 2 1 3 #include <Compiler.h> 2 #include <NamespaceSupporter.h> 3 4 #include "common.h" 5 #include OPCODE_H_PATH //opcode.h 6 7 8 //シングルトンオブジェクト 9 CDBConst CDBConst::obj; 10 11 12 bool ConstBase::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const 13 { 14 if( GetName() != name ){ 15 return false; 16 } 17 return compiler.GetNamespaceSupporter().IsSameAreaNamespace( this->namespaceScopes, namespaceScopes ); 18 } 19 bool ConstBase::IsEqualSymbol( const string &fullName ) const 20 { 21 char AreaName[VN_SIZE] = ""; //オブジェクト変数 22 char NestName[VN_SIZE] = ""; //入れ子メンバ 23 bool isNest = CClass::SplitName( fullName.c_str(), AreaName, NestName ); 24 25 return IsEqualSymbol( NamespaceScopes( AreaName ), NestName ); 26 } 27 28 29 30 31 CConst::CConst( const NamespaceScopes &namespaceScopes, const string &name, const Type &newType, _int64 i64data) 32 : ConstBase( namespaceScopes, name ) 33 , type( newType ) 34 , i64data( i64data ) 35 , pNext( NULL ) 36 { 37 } 38 CConst::CConst( const NamespaceScopes &namespaceScopes, const string &name, int value) 39 : ConstBase( namespaceScopes, name ) 40 , type( Type(DEF_LONG) ) 41 , i64data( value ) 42 , pNext( NULL ) 43 { 44 } 45 CConst::~CConst(){ 46 //連結先のオブジェクトを破棄 47 if(pNext){ 48 delete pNext; 49 pNext = 0; 50 } 51 } 52 53 Type CConst::GetType(){ 54 return type; 55 } 56 _int64 CConst::GetWholeData(){ 57 return i64data; 58 } 4 5 59 6 double CConst::GetDoubleData(){ 60 7 double dbl; … … 63 10 } 64 11 65 66 67 CConstMacro::CConstMacro( const NamespaceScopes &namespaceScopes, const string &name, char *Expression) 68 : ConstBase( namespaceScopes, name ) 69 { 70 } 71 CConstMacro::~CConstMacro(){ 72 } 73 74 75 76 77 78 CDBConst::CDBConst(){ 79 memset(this,0,sizeof(CDBConst)); 80 81 ppHash = (CConst **)calloc(MAX_HASH*sizeof(CConst *),1); 82 Init(); 83 } 84 CDBConst::~CDBConst(){ 85 Free(); 86 87 free(ppHash); 88 } 89 90 //解放 91 void CDBConst::Free(){ 12 void AddConst( const NamespaceScopes &namespaceScopes, char *buffer ){ 92 13 int i; 93 for(i=0; i<MAX_HASH; i++){94 if(ppHash[i]){95 delete ppHash[i];96 ppHash[i] = 0;97 }98 }99 }100 101 //初期化102 void CDBConst::Init(){103 Free();104 }105 106 void AddConstData(char *Command);107 void CDBConst::Add( const NamespaceScopes &namespaceScopes, char *buffer ){108 int i;109 14 110 15 //名前を取得 111 char Name[VN_SIZE];16 char name[VN_SIZE]; 112 17 for(i=0;;i++){ 113 18 if(buffer[i]=='\0'){ … … 116 21 } 117 22 if(buffer[i]=='='||buffer[i]=='('){ 118 Name[i]=0;23 name[i]=0; 119 24 break; 120 25 } 121 Name[i]=buffer[i];26 name[i]=buffer[i]; 122 27 } 123 28 124 29 //重複チェック 125 if(GetBasicType(Name)){ 126 SetError(15,Name,cp); 30 if( compiler.GetMeta().GetGlobalConstMacros().IsExist( name ) 31 || compiler.GetMeta().GetGlobalConsts().IsExist( name ) ) 32 { 33 SetError(15,name,cp); 127 34 return; 128 35 } … … 131 38 //定数マクロ 132 39 133 //未完成 134 AddConstData(buffer); 40 compiler.GetMeta().GetGlobalConstMacros().Add( namespaceScopes, name, buffer + i ); 135 41 } 136 42 else{ 137 43 //一般の定数 138 char *Expression = buffer + i + 1; 139 140 AddConst( namespaceScopes, Name,Expression); 141 } 142 } 143 144 void CDBConst::AddConst( const string &name, CConst *newconst){ 145 int key = hash_default(name.c_str()); 146 147 //ハッシュリストに追加 148 if(ppHash[key]){ 149 CConst *pConst = ppHash[key]; 150 while(pConst->pNext){ 151 pConst = pConst->pNext; 152 } 153 154 pConst->pNext = newconst; 155 } 156 else{ 157 ppHash[key] = newconst; 158 } 159 } 160 void CDBConst::AddConst( const NamespaceScopes &namespaceScopes, const string &name , char *Expression){ 44 char *expression = buffer + i + 1; 45 46 compiler.GetMeta().GetGlobalConsts().Add( namespaceScopes, name, expression ); 47 } 48 } 49 50 void Consts::Add( const NamespaceScopes &namespaceScopes, const string &name , char *Expression) 51 { 161 52 _int64 i64data; 162 53 Type resultType; … … 172 63 CConst *newconst = new CConst(namespaceScopes, name, resultType, i64data); 173 64 174 AddConst( name, newconst); 175 } 176 void CDBConst::AddConst(const NamespaceScopes &namespaceScopes, const string &name, int value){ 65 //ハッシュリストに追加 66 Put( newconst ); 67 } 68 void Consts::Add(const NamespaceScopes &namespaceScopes, const string &name, int value){ 177 69 CConst *newconst = new CConst( namespaceScopes, name, value); 178 70 179 AddConst(name, newconst); 180 } 181 182 CConst *CDBConst::GetObjectPtr( const string &name ){ 71 //ハッシュリストに追加 72 Put( newconst ); 73 } 74 75 CConst *Consts::GetObjectPtr( const string &name ){ 183 76 char ObjName[VN_SIZE]; //オブジェクト変数 184 77 char NestMember[VN_SIZE]; //入れ子メンバ 185 bool isObjectMember = CClass::SplitName( name.c_str(), ObjName, NestMember ); 186 187 //ハッシュ値を取得 188 int key; 189 key=hash_default( NestMember ); 190 191 //格納位置を取得 192 CConst *pConst; 193 pConst=ppHash[key]; 194 while(pConst){ 195 if( pConst->IsEqualSymbol( name ) ) break; 196 197 pConst=pConst->pNext; 78 bool isObjectMember = SplitMemberName( name.c_str(), ObjName, NestMember ); 79 80 CConst *pConst = GetHashArrayElement( NestMember ); 81 while( pConst ) 82 { 83 if( pConst->IsEqualSymbol( name ) ) 84 { 85 break; 86 } 87 pConst = pConst->GetChainNext(); 198 88 } 199 89 … … 202 92 203 93 204 int C DBConst::GetBasicType(char *Name){94 int Consts::GetBasicType(char *Name){ 205 95 CConst *pConst = GetObjectPtr(Name); 206 96 … … 209 99 return pConst->GetType().GetBasicType(); 210 100 } 211 _int64 C DBConst::GetWholeData(char *Name){101 _int64 Consts::GetWholeData(char *Name){ 212 102 CConst *pConst = GetObjectPtr(Name); 213 103 … … 216 106 return pConst->GetWholeData(); 217 107 } 218 double C DBConst::GetDoubleData(char *Name){108 double Consts::GetDoubleData(char *Name){ 219 109 CConst *pConst = GetObjectPtr(Name); 220 110 … … 223 113 return pConst->GetDoubleData(); 224 114 } 225 bool C DBConst::IsStringPtr( char *Name ){115 bool Consts::IsStringPtr( char *Name ){ 226 116 CConst *pConst = GetObjectPtr(Name); 227 117 … … 232 122 return ( type.GetBasicType() == typeOfPtrChar && type.GetIndex() == LITERAL_STRING ); 233 123 } 124 125 126 bool ConstMacro::GetCalcBuffer( const char *parameterStr, char *dest ) const 127 { 128 extern HANDLE hHeap; 129 int i2,i3,i4,num; 130 char temporary[VN_SIZE]; 131 char *pParms[MAX_PARMS]; 132 num=0; 133 i2=0; 134 while(1){ 135 i2=GetOneParameter(parameterStr,i2,temporary); 136 137 pParms[num]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1); 138 lstrcpy(pParms[num],temporary); 139 140 num++; 141 if(parameterStr[i2]=='\0') break; 142 } 143 if( num != this->GetParameters().size() ){ 144 extern int cp; 145 for(i2=0;i2<num;i2++) HeapDefaultFree(pParms[i2]); 146 SetError(10,GetName().c_str(),cp); 147 lstrcpy(dest,"0"); 148 return 1; 149 } 150 151 i2=0; 152 i4=0; 153 while(1){ 154 155 //数式内の項を取得 156 for(i3=0;;i2++,i3++){ 157 if(!IsVariableChar( this->GetExpression()[i2] )){ 158 temporary[i3]=0; 159 break; 160 } 161 temporary[i3] = this->GetExpression()[i2]; 162 } 163 164 //パラメータと照合する 165 for( i3=0; i3<(int)this->GetParameters().size(); i3++ ){ 166 if( this->GetParameters()[i3] == temporary ) break; 167 } 168 169 if( i3 == (int)this->GetParameters().size() ){ 170 //パラメータでないとき 171 lstrcpy(dest+i4,temporary); 172 i4+=lstrlen(temporary); 173 } 174 else{ 175 //パラメータのとき 176 lstrcpy(dest+i4,pParms[i3]); 177 i4+=lstrlen(pParms[i3]); 178 } 179 180 //演算子をコピー 181 for(;;i2++,i4++){ 182 if( this->GetExpression()[i2] == 1 ){ 183 dest[i4++] = this->GetExpression()[i2++]; 184 dest[i4] = this->GetExpression()[i2]; 185 continue; 186 } 187 if(IsVariableTopChar( this->GetExpression()[i2] )) break; 188 dest[i4] = this->GetExpression()[i2]; 189 if( this->GetExpression()[i2] == '\0' ) break; 190 } 191 192 if( this->GetExpression()[i2] == '\0' ) break; 193 } 194 195 for(i2=0;i2<num;i2++) HeapDefaultFree(pParms[i2]); 196 197 return 1; 198 } 199 200 // マクロ定数を追加するための関数 201 void ConstMacros::Add( const NamespaceScopes &namespaceScopes, const std::string &name, const char *parameterStr ) 202 { 203 std::vector<std::string> parameters; 204 205 int i = 0; 206 if(parameterStr[i]!='(') 207 { 208 SetError(); 209 return; 210 } 211 212 char temporary[VN_SIZE]; 213 int i2; 214 for(i++,i2=0;;i++,i2++){ 215 if(parameterStr[i]=='\0'){ 216 SetError(1,NULL,cp); 217 return; 218 } 219 if(parameterStr[i]==','||parameterStr[i]==')'){ 220 temporary[i2]=0; 221 222 parameters.push_back( temporary ); 223 224 if(parameterStr[i]==')'){ 225 i++; 226 if(parameterStr[i]!='='){ 227 extern int cp; 228 SetError(1,NULL,cp); 229 return; 230 } 231 break; 232 } 233 234 i2=-1; 235 continue; 236 } 237 temporary[i2]=parameterStr[i]; 238 } 239 240 //データ 241 lstrcpy(temporary,parameterStr+i+1); 242 243 Put( new ConstMacro( namespaceScopes, name, parameters, temporary ) ); 244 } 245 ConstMacro *ConstMacros::Find( const std::string &name ){ 246 char ObjName[VN_SIZE]; //オブジェクト変数 247 char NestMember[VN_SIZE]; //入れ子メンバ 248 bool isObjectMember = SplitMemberName( name.c_str(), ObjName, NestMember ); 249 250 ConstMacro *pConstMacro = GetHashArrayElement( NestMember ); 251 while( pConstMacro ) 252 { 253 if( pConstMacro->IsEqualSymbol( name ) ) 254 { 255 break; 256 } 257 pConstMacro = pConstMacro->GetChainNext(); 258 } 259 260 return pConstMacro; 261 } -
trunk/abdev/BasicCompiler_Common/src/DataTable.cpp
r184 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 -
trunk/abdev/BasicCompiler_Common/src/Exception.cpp
r125 r206 1 #include "stdafx.h" 2 1 3 #include <Exception.h> 2 4 -
trunk/abdev/BasicCompiler_Common/src/LexicalScopingImpl.cpp
r184 r206 1 #include "stdafx.h" 2 1 3 #include <LexicalScopingImpl.h> 4 #include <Compiler.h> 2 5 3 6 #include "../common.h" … … 29 32 } 30 33 34 void LexicalScopesImpl::End(){ 35 if( level <= 0 ){ 36 SetError(); 37 return; 38 } 39 40 //デストラクタを呼ぶ 41 CallDestructorsOfScopeEnd(); 42 43 Variables &vars = UserProc::IsGlobalAreaCompiling() ? 44 compiler.GetMeta().GetGlobalVars() : 45 UserProc::CompilingUserProc().GetLocalVars(); 46 47 //使用済みローカル変数の生存チェックを外す 48 BOOST_FOREACH( Variable *pVar, vars ){ 49 if(pVar->bLiving&&pVar->GetScopeLevel()==level){ 50 pVar->bLiving=0; 51 extern int obp; 52 pVar->SetScopeEndAddress( obp ); 53 } 54 } 55 56 57 //スコープ抜け出しスケジュール 58 ppScopes[level]->RunScheduleOfBreak(); 59 60 61 //スコープレベルを下げる 62 delete ppScopes[level]; 63 level--; 64 } 65 31 66 // スコープ終了時のデストラクタ呼び出し 32 67 void LexicalScopesImpl::CallDestructorsOfScopeEnd(){ 33 68 34 Variables &vars = UserProc::IsGlobalAreaCompiling() ?35 globalVars:36 UserProc::CompilingUserProc(). localVars;69 Variables &vars = UserProc::IsGlobalAreaCompiling() ? 70 compiler.GetMeta().GetGlobalVars() : 71 UserProc::CompilingUserProc().GetLocalVars(); 37 72 38 73 … … 52 87 //同一レベルのレキシカルスコープのみを検知 53 88 if(!pVar->bLiving) continue; 54 if( pVar-> ScopeLevel!= GetNowLevel() ) continue;89 if( pVar->GetScopeLevel() != GetNowLevel() ) continue; 55 90 56 if( pVar-> IsStruct() && pVar->IsParameter() ){91 if( pVar->GetType().IsStruct() && pVar->IsParameter() ){ 57 92 //構造体パラメータを持つとき 58 93 … … 64 99 //mov rcx,qword ptr[rsp+offset] 65 100 op_mov_RM(sizeof(_int64),REG_RCX,REG_RSP, 66 -pVar-> offset,101 -pVar->GetOffsetAddress(), 67 102 MOD_BASE_DISP32); 68 103 obp-=sizeof(long); … … 73 108 74 109 //mov ecx,dword ptr[ebp+offset] 75 op_mov_RM(sizeof(long),REG_ECX,REG_EBP,-pVar-> offset,MOD_BASE_DISP32);110 op_mov_RM(sizeof(long),REG_ECX,REG_EBP,-pVar->GetOffsetAddress(),MOD_BASE_DISP32); 76 111 obp-=sizeof(long); 77 112 AddLocalVarAddrSchedule(); … … 83 118 84 119 //call free 85 extern UserProc *pSub_free;120 extern const UserProc *pSub_free; 86 121 op_call(pSub_free); 87 122 … … 96 131 if(indexSystemGC!=-1){ 97 132 //_System_GCオブジェクトのデストラクタの呼び出し処理 98 const CMethod *method = vars[indexSystemGC]->Get Class().GetDestructorMethod();133 const CMethod *method = vars[indexSystemGC]->GetType().GetClass().GetDestructorMethod(); 99 134 if( method ){ 100 Opcode_CallProc("", method->pUserProc,0,vars[indexSystemGC]->GetName().c_str(),DEF_OBJECT);135 Opcode_CallProc("",&method->GetUserProc(),0,vars[indexSystemGC]->GetName().c_str(),DEF_OBJECT); 101 136 } 102 137 } -
trunk/abdev/BasicCompiler_Common/src/NamespaceSupporter.cpp
r199 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/SmoothieException.h> 4 #include <jenga/include/smoothie/LexicalAnalysis.h> 2 5 3 6 #include <Compiler.h> -
trunk/abdev/BasicCompiler_Common/src/Procedure.cpp
r201 r206 1 #include "stdafx.h" 2 3 #include <jenga/include/smoothie/Smoothie.h> 1 4 #include <jenga/include/smoothie/SmoothieException.h> 2 5 #include <jenga/include/smoothie/LexicalAnalysis.h> 3 6 4 7 #include <Compiler.h> 5 #include <Procedure Impl.h>8 #include <Procedure.h> 6 9 #include <NamespaceSupporter.h> 7 10 … … 13 16 #endif 14 17 15 bool UserProcImpl::SetParamsAndReturnType( const char *sourceOfParams, int nowLine, bool isStatic ){ 18 19 std::string UserProc::GetFullName() const 20 { 21 if( HasParentClass() ){ 22 return GetParentClass().GetName() + "." + GetName(); 23 } 24 25 return GetName(); 26 } 27 const NamespaceScopes &UserProc::GetNamespaceScopes() const 28 { 29 if( HasParentClass() ){ 30 return GetParentClassPtr()->GetNamespaceScopes(); 31 } 32 return namespaceScopes; 33 } 34 const NamespaceScopesCollection &UserProc::GetImportedNamespaces() const 35 { 36 return importedNamespaces; 37 } 38 bool UserProc::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const 39 { 40 if( GetName() != name ){ 41 return false; 42 } 43 44 return compiler.GetNamespaceSupporter().IsSameAreaNamespace( GetNamespaceScopes(), namespaceScopes ); 45 } 46 bool UserProc::IsEqualSymbol( const UserProc &globalProc ) const 47 { 48 return IsEqualSymbol( globalProc.GetNamespaceScopes(), globalProc.GetName() ); 49 } 50 bool UserProc::IsEqualSymbol( const string &fullName ) const 51 { 52 char AreaName[VN_SIZE] = ""; //オブジェクト変数 53 char NestName[VN_SIZE] = ""; //入れ子メンバ 54 bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName ); 55 56 return IsEqualSymbol( NamespaceScopes( AreaName ), NestName ); 57 } 58 bool UserProc::IsVirtual() const 59 { 60 if( pMethod == NULL ){ 61 return false; 62 } 63 return ( pMethod->IsVirtual() != 0 ); 64 } 65 66 bool UserProc::SetParamsAndReturnType( const char *sourceOfParams, int nowLine, bool isStatic ){ 16 67 int i = 0; 17 68 int i2,i3,sw; … … 51 102 //パラメータ名 52 103 bool isArray = false; 53 int subScripts[MAX_ARRAYDIM];104 Subscripts subscripts; 54 105 char name[VN_SIZE]; 55 106 sw=0; … … 83 134 84 135 if((name[i2-2]=='('&&name[i2-1]==')')|| 85 (name[i2-2]=='['&&name[i2-1]==']')) {86 subScripts[0]=LONG_MAX;87 sub Scripts[1]=-1;136 (name[i2-2]=='['&&name[i2-1]==']')) 137 { 138 subscripts.push_back( LONG_MAX ); 88 139 89 140 name[i2-2]=0; 90 141 } 91 142 else{ 92 GetArrange(name,temp2,sub Scripts);143 GetArrange(name,temp2,subscripts); 93 144 lstrcpy(name,temp2); 94 145 } … … 152 203 Parameter *pParam = new Parameter( name, type, isRef, initValue ); 153 204 if( isArray ){ 154 pParam->SetArray( sub Scripts );205 pParam->SetArray( subscripts ); 155 206 } 156 207 … … 189 240 //パラメータ名 190 241 bool isArray = false; 191 int subScripts[MAX_ARRAYDIM];242 Subscripts subscripts; 192 243 char name[VN_SIZE]; 193 244 sw=0; … … 221 272 222 273 if((name[i2-2]=='('&&name[i2-1]==')')|| 223 (name[i2-2]=='['&&name[i2-1]==']')) {224 subScripts[0]=LONG_MAX;225 sub Scripts[1]=-1;274 (name[i2-2]=='['&&name[i2-1]==']')) 275 { 276 subscripts.push_back( LONG_MAX ); 226 277 227 278 name[i2-2]=0; 228 279 } 229 280 else{ 230 GetArrange(name,temp2,sub Scripts);281 GetArrange(name,temp2,subscripts); 231 282 lstrcpy(name,temp2); 232 283 } … … 273 324 Parameter *pParam = new Parameter( name, type, isRef ); 274 325 if( isArray ){ 275 pParam->SetArray( sub Scripts );326 pParam->SetArray( subscripts ); 276 327 } 277 328 … … 376 427 } 377 428 378 const NamespaceScopes &GlobalProc::GetNamespaceScopes() const 379 { 380 if( HasParentClass() ){ 381 return GetParentClassPtr()->GetNamespaceScopes(); 382 } 383 return namespaceScopes; 384 } 385 bool GlobalProc::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const 429 const UserProc *UserProc::pCompilingUserProc = NULL; 430 431 432 bool UserProcs::Insert( UserProc *pUserProc, int nowLine ) 433 { 434 ///////////////////////////////// 435 // ハッシュデータに追加 436 ///////////////////////////////// 437 438 if( !Put( pUserProc ) ) 439 { 440 // 重複しているため、失敗 441 SetError(15,pUserProc->GetName().c_str(),nowLine); 442 return false; 443 } 444 445 return true; 446 } 447 UserProc *UserProcs::Add( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,bool isVirtual,CClass *pobj_c, bool isStatic) 448 { 449 int i2,i3; 450 char temporary[8192]; 451 452 int i=1; 453 454 Procedure::Kind kind = Procedure::Sub; 455 bool isMacro = false; 456 if(buffer[i]==ESC_FUNCTION) kind = Procedure::Function; 457 if(buffer[i]==ESC_MACRO){ 458 isMacro = true; 459 } 460 461 i++; 462 463 bool isCdecl = false; 464 bool isExport = false; 465 while(1){ 466 if(buffer[i]==1&&buffer[i+1]==ESC_CDECL&& isCdecl == false ){ 467 isCdecl = true; 468 469 i+=2; 470 } 471 else if(buffer[i]==1&&buffer[i+1]==ESC_EXPORT&& isExport == false ){ 472 isExport = true; 473 474 i+=2; 475 } 476 else break; 477 } 478 479 i2=0; 480 if(buffer[i]==1&&buffer[i+1]==ESC_OPERATOR){ 481 if(!pobj_c){ 482 SetError(126,NULL,nowLine); 483 return 0; 484 } 485 486 //オペレータの場合 487 temporary[i2++]=buffer[i++]; 488 temporary[i2++]=buffer[i++]; 489 490 int iCalcId; 491 if(buffer[i]=='='&&buffer[i+1]=='='){ 492 iCalcId=CALC_EQUAL; 493 i3=2; 494 } 495 else if(buffer[i]=='='){ 496 iCalcId=CALC_SUBSITUATION; 497 i3=1; 498 } 499 else if(buffer[i]=='('){ 500 iCalcId=CALC_AS; 501 i3=0; 502 } 503 else if(buffer[i]=='['&&buffer[i+1]==']'&&buffer[i+2]=='='){ 504 iCalcId=CALC_ARRAY_SET; 505 i3=3; 506 } 507 else if(buffer[i]=='['&&buffer[i+1]==']'){ 508 iCalcId=CALC_ARRAY_GET; 509 i3=2; 510 } 511 else{ 512 iCalcId=GetCalcId(buffer+i,&i3); 513 i3++; 514 } 515 if(!iCalcId){ 516 SetError(1,NULL,nowLine); 517 return 0; 518 } 519 temporary[i2++]=iCalcId; 520 temporary[i2]=0; 521 522 i+=i3; 523 } 524 else{ 525 if(pobj_c){ 526 //クラスメンバの場合、デストラクタには~が付くことを考慮 527 if(buffer[i]=='~'){ 528 temporary[i2]='~'; 529 i++; 530 i2++; 531 } 532 } 533 534 for(;;i++,i2++){ 535 if(!IsVariableChar(buffer[i])){ 536 temporary[i2]=0; 537 break; 538 } 539 temporary[i2]=buffer[i]; 540 } 541 } 542 543 if( isMacro ){ 544 //大文字に変換 545 CharUpper(temporary); 546 547 //マクロ関数の場合は名前リストに追加 548 macroNames.push_back( temporary ); 549 } 550 551 if(!pobj_c){ 552 //クラスメンバ以外の場合のみ 553 //重複チェック 554 555 if(GetDeclareHash(temporary)){ 556 SetError(15,temporary,nowLine); 557 return 0; 558 } 559 } 560 561 // 識別ID 562 static int id_base=0; 563 564 UserProc *pUserProc = new UserProc( namespaceScopes, importedNamespaces, temporary, kind, isMacro, isCdecl, isExport, (id_base++) ); 565 pUserProc->SetParentClass( pobj_c ); 566 if( Smoothie::isFullCompile ){ 567 // すべての関数・メソッドをコンパイルする 568 pUserProc->Using(); 569 } 570 571 if(isExport){ 572 pUserProc->Using(); 573 } 574 575 // パラメータを解析 576 // ※第1パラメータにに指定するデータの例:"( s As String ) As String" 577 pUserProc->SetParamsAndReturnType( buffer + i, nowLine, isStatic ); 578 579 pUserProc->_paramStr = buffer + i; 580 581 // ハッシュに追加 582 if( !Insert( pUserProc, nowLine ) ) 583 { 584 return NULL; 585 } 586 587 return pUserProc; 588 } 589 void UserProcs::EnumGlobalProcs( const char *simpleName, const char *localName, std::vector<const UserProc *> &subs ) 590 { 591 /////////////////////////// 592 // グローバル関数を検索 593 /////////////////////////// 594 595 // ハッシュ値を取得 596 UserProc *pUserProc = GetHashArrayElement( simpleName ); 597 while(pUserProc){ 598 if(!pUserProc->GetParentClassPtr()){ 599 if( pUserProc->IsEqualSymbol( localName ) ){ 600 subs.push_back( pUserProc ); 601 } 602 } 603 604 pUserProc=pUserProc->GetChainNext(); 605 } 606 } 607 608 609 bool DllProc::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const 386 610 { 387 611 if( GetName() != name ){ 388 612 return false; 389 613 } 390 391 return compiler.GetNamespaceSupporter().IsSameAreaNamespace( GetNamespaceScopes(), namespaceScopes ); 392 } 393 bool GlobalProc::IsEqualSymbol( const GlobalProc &globalProc ) const 394 { 395 return IsEqualSymbol( globalProc.GetNamespaceScopes(), globalProc.GetName() ); 396 } 397 bool GlobalProc::IsEqualSymbol( const string &fullName ) const 614 return compiler.GetNamespaceSupporter().IsSameAreaNamespace( this->GetNamespaceScopes(), namespaceScopes ); 615 } 616 bool DllProc::IsEqualSymbol( const string &fullName ) const 398 617 { 399 618 char AreaName[VN_SIZE] = ""; //オブジェクト変数 400 619 char NestName[VN_SIZE] = ""; //入れ子メンバ 401 bool isNest = CClass::SplitName( fullName.c_str(), AreaName, NestName ); 402 403 return IsEqualSymbol( NamespaceScopes( AreaName ), NestName ); 404 } 405 406 bool DllProcImpl::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const 407 { 408 if( GetName() != name ){ 409 return false; 410 } 411 return compiler.GetNamespaceSupporter().IsSameAreaNamespace( this->GetNamespaceScopes(), namespaceScopes ); 412 } 413 bool DllProcImpl::SetParamsAndReturnType( const char *sourceOfParams, int nowLine ){ 620 bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName ); 621 622 if( IsEqualSymbol( NamespaceScopes( AreaName ), NestName ) ){ 623 return true; 624 } 625 626 if( isNest ){ 627 // 静的メンバを考慮 628 629 char AreaName2[VN_SIZE] = ""; //オブジェクト変数 630 char NestName2[VN_SIZE] = ""; //入れ子メンバ 631 bool isNest = SplitMemberName( AreaName, AreaName2, NestName2 ); 632 lstrcat( NestName2, "." ); 633 lstrcat( NestName2, NestName ); 634 635 return IsEqualSymbol( NamespaceScopes( AreaName2 ), NestName2 ); 636 } 637 638 return false; 639 } 640 bool DllProc::SetParamsAndReturnType( const char *sourceOfParams, int nowLine ){ 414 641 int i = 0; 415 642 int i2,i3,sw; … … 443 670 //パラメータ名 444 671 bool isArray = false; 445 int subScripts[MAX_ARRAYDIM];672 Subscripts subscripts; 446 673 char name[VN_SIZE]; 447 674 sw=0; … … 475 702 476 703 if((name[i2-2]=='('&&name[i2-1]==')')|| 477 (name[i2-2]=='['&&name[i2-1]==']')) {478 subScripts[0]=LONG_MAX;479 sub Scripts[1]=-1;704 (name[i2-2]=='['&&name[i2-1]==']')) 705 { 706 subscripts.push_back( LONG_MAX ); 480 707 481 708 name[i2-2]=0; 482 709 } 483 710 else{ 484 GetArrange(name,temp2,sub Scripts);711 GetArrange(name,temp2,subscripts); 485 712 lstrcpy(name,temp2); 486 713 } … … 528 755 Parameter *pParam = new Parameter( name, type, isRef ); 529 756 if( isArray ){ 530 pParam->SetArray( sub Scripts );757 pParam->SetArray( subscripts ); 531 758 } 532 759 … … 584 811 } 585 812 586 bool ProcPointer Impl::SetParamsAndReturnType( const char *sourceOfParams, int nowLine ){813 bool ProcPointer::SetParamsAndReturnType( const char *sourceOfParams, int nowLine ){ 587 814 int i = 0; 588 815 int i2,i3,sw; … … 615 842 //パラメータ名 616 843 bool isArray = false; 617 int subScripts[MAX_ARRAYDIM];844 Subscripts subscripts; 618 845 char name[VN_SIZE]; 619 846 sw=0; … … 647 874 648 875 if((name[i2-2]=='('&&name[i2-1]==')')|| 649 (name[i2-2]=='['&&name[i2-1]==']')) {650 subScripts[0]=LONG_MAX;651 sub Scripts[1]=-1;876 (name[i2-2]=='['&&name[i2-1]==']')) 877 { 878 subscripts.push_back( LONG_MAX ); 652 879 653 880 name[i2-2]=0; 654 881 } 655 882 else{ 656 GetArrange(name,temp2,sub Scripts);883 GetArrange(name,temp2,subscripts); 657 884 lstrcpy(name,temp2); 658 885 } … … 699 926 Parameter *pParam = new Parameter( name, type, isRef ); 700 927 if( isArray ){ 701 pParam->SetArray( sub Scripts );928 pParam->SetArray( subscripts ); 702 929 } 703 930 … … 771 998 } 772 999 773 int ProcPointers Impl::Add( const string &typeExpression )1000 int ProcPointers::Add( const string &typeExpression ) 774 1001 { 775 1002 DWORD dwProcType = (DWORD)typeExpression[2]; … … 781 1008 } 782 1009 783 ProcPointer *pProcPointer = new ProcPointer Impl( kind );1010 ProcPointer *pProcPointer = new ProcPointer( kind ); 784 1011 785 1012 //buffer[0]は'('となっている … … 792 1019 } 793 1020 794 void ProcPointers Impl::Clear()795 { 796 ProcPointers Impl&procPointers = *this;1021 void ProcPointers::Clear() 1022 { 1023 ProcPointers &procPointers = *this; 797 1024 BOOST_FOREACH( ProcPointer *pProcPointer, procPointers ){ 798 1025 delete pProcPointer; -
trunk/abdev/BasicCompiler_Common/src/Program.cpp
r168 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/common/Environment.h> 2 4 3 5 #include <Program.h> 4 6 5 Jenga::Common::Logger Program::logger( Jenga::Common::Environment::GetAppDir() + "\\logger.log" );7 Jenga::Common::Logger Program::logger( Jenga::Common::Environment::GetAppDir() + "\\logger.log", true ); -
trunk/abdev/BasicCompiler_Common/src/SmoothieImpl.cpp
r193 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 4 3 5 #include <SmoothieImpl.h> 4 #include <Class Impl.h>5 #include <Procedure Impl.h>6 #include <Class.h> 7 #include <Procedure.h> 6 8 #include <LexicalScopingImpl.h> 7 9 -
trunk/abdev/BasicCompiler_Common/src/TypeDef.cpp
r199 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/smoothie/Smoothie.h> 2 #include <jenga/include/smoothie/Class.h>3 4 #include <jenga/include/smoothie/SmoothieException.h> 5 #include <jenga/include/smoothie/LexicalAnalysis.h> 4 6 5 7 #include <TypeDef.h> … … 8 10 9 11 TypeDef::TypeDef( const NamespaceScopes &namespaceScopes, const string &name, const string &baseName, int nowLine ) 10 : namespaceScopes( namespaceScopes ) 11 , name( name ) 12 : Symbol( namespaceScopes, name ) 12 13 , baseName( baseName ) 13 14 { … … 17 18 } 18 19 } 19 TypeDef::~TypeDef(){ 20 } 21 20 /* 22 21 bool TypeDef::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const 23 22 { … … 31 30 char AreaName[VN_SIZE] = ""; //オブジェクト変数 32 31 char NestName[VN_SIZE] = ""; //入れ子メンバ 33 bool isNest = CClass::SplitName( fullName.c_str(), AreaName, NestName );32 bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName ); 34 33 35 34 if( IsEqualSymbol( NamespaceScopes( AreaName ), NestName ) ){ … … 42 41 char AreaName2[VN_SIZE] = ""; //オブジェクト変数 43 42 char NestName2[VN_SIZE] = ""; //入れ子メンバ 44 bool isNest = CClass::SplitName( AreaName, AreaName2, NestName2 );43 bool isNest = SplitMemberName( AreaName, AreaName2, NestName2 ); 45 44 lstrcat( NestName2, "." ); 46 45 lstrcat( NestName2, NestName ); … … 50 49 51 50 return false; 52 } 51 }*/ 53 52 54 53 … … 74 73 char AreaName[VN_SIZE] = ""; //オブジェクト変数 75 74 char NestName[VN_SIZE] = ""; //入れ子メンバ 76 bool isNest = CClass::SplitName( fullName.c_str(), AreaName, NestName );75 bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName ); 77 76 78 77 return GetIndex( NamespaceScopes( AreaName ), NestName );
Note:
See TracChangeset
for help on using the changeset viewer.