#include "stdafx.h" #include #include #include #include "common.h" void StepCompileProgress(void){ extern HWND hMainDlg; PostMessage(GetDlgItem(hMainDlg,IDC_PROGRESS),PBM_STEPIT,0,0); } void AddSourceCode(char *buffer){ char *temp; temp=(char *)HeapAlloc(hHeap,0,lstrlen(buffer)+8192); lstrcpy(temp,buffer); //エスケープシーケンス設定 SetEscapeSequenceFormat(temp); //コマンド対応 ChangeCommandToCode(temp); //最後尾に貼り付け compiler.GetObjectModule().GetCurrentSource().Addition( temp ); HeapDefaultFree(temp); } void OutputExe(void){ extern HANDLE hHeap; extern char *basbuf; extern int ErrorNum; extern BOOL bStopCompile; extern HWND hMainDlg; int i3; char temp2[MAX_PATH]; // 開始時刻を記録 DWORD beforeTickCount = GetTickCount(); //プログレスバーの設定 PostMessage(GetDlgItem(hMainDlg,IDC_PROGRESS),PBM_SETRANGE,0,MAKELPARAM(0,6)); PostMessage(GetDlgItem(hMainDlg,IDC_PROGRESS),PBM_SETSTEP,1,0); //"中断" SetDlgItemText(hMainDlg,IDOK,STRING_STOP); //中断フラグを初期化 bStopCompile=0; //サブシステムのタイプ extern unsigned short TypeOfSubSystem; TypeOfSubSystem=IMAGE_SUBSYSTEM_WINDOWS_GUI; //プログラムをファイルから読み込む extern char SourceFileName[MAX_PATH]; compiler.GetObjectModule().SetCurrentSourceIndex( (int)compiler.GetObjectModule().GetSources().size() ); compiler.GetObjectModule().GetSources().push_back( BasicSource() ); if( !compiler.GetObjectModule().GetCurrentSource().ReadFile( SourceFileName ) ){ SetError(201,SourceFileName,-1); goto EndCompile; } //イメージベースの設定 extern DWORD ImageBase; if(compiler.IsDll()) ImageBase=0x10000000; else ImageBase=0x00400000; extern BOOL bError; if(bError||bStopCompile) goto EndCompile; ////////////////////////// // 中間コードの生成を開始 extern BOOL bClipCompileView; //"最適化中..." CompileMessage(STRING_COMPILE_OPTIMIZING); //カッコを相互チェック(ダブルクォートチェックチェックを含む) CheckParenthesis(basbuf); if(bError||bStopCompile) goto EndCompile; //コンパイルダイアログのプログレスバーを上げる StepCompileProgress(); //ディレクティブ DirectiveCheck(); //Next命令語を正規表現に変換 //NextCommandFormat(basbuf); //エスケープシーケンス設定 SetEscapeSequenceFormat(basbuf); //Def命令語をFunction命令語に変換 DefCommandFormat(basbuf); //すべてのIf命令語をブロック形式に変換 IfCommandFormat(basbuf); //対になる命令語を相互チェック //CheckPareCommand(); if(bError||bStopCompile) goto EndCompile; //コンパイルダイアログのプログレスバーを上げる StepCompileProgress(); //重複エラー情報管理のメモリを確保 extern char **SynonymErrorWords; extern int SynonymErrorNum; SynonymErrorNum=0; SynonymErrorWords=(char **)HeapAlloc(hHeap,0,1); ChangeCommandToCode(basbuf); compiler.GetObjectModule().GetSources()[0]._ResetLength(); //重複エラー情報管理のメモリを解放 for(i3=0;i3Read( coreFilePath ); Jenga::Common::Path path( coreFilePath ); CompileMessage( ((string)"\"" + path.GetFileName() + path.GetExt() + "\" を読み込みました。").c_str() ); } BOOST_FOREACH( const std::string &filePath, compiler.staticLibraryFilePaths ) { compiler.staticLibraries.push_back( new ObjectModule() ); compiler.staticLibraries.back()->Read( filePath ); Jenga::Common::Path path( filePath ); CompileMessage( ((string)"\"" + path.GetFileName() + path.GetExt() + "\" を読み込みました。").c_str() ); } /////////////////////// // コンパイル開始 //"コンパイル中..." CompileMessage(STRING_COMPILE_COMPILING); Compile(); //リソース情報を解放 extern RESOURCEDATAINFO *pCursorResourceInfo; extern RESOURCEDATAINFO *pIconResourceInfo; extern RESOURCEDATAINFO *pBitmapResourceInfo; HeapDefaultFree(pCursorResourceInfo); HeapDefaultFree(pBitmapResourceInfo); HeapDefaultFree(pIconResourceInfo); //コンパイルダイアログのプログレスバーを上げる StepCompileProgress(); ////////////////////////// // 終了処理 EndCompile: if(bStopCompile){ PostMessage(GetDlgItem(hMainDlg,IDC_PROGRESS),PBM_SETPOS,0,0); //"コンパイルはユーザーにより中断されました。" CompileMessage(STRING_COMPILE_STOP); } else{ extern int CompileMsgNum; extern int WarningNum; if(bError==0){ //"コンパイルは正常に完了しました(エラー:%d、警告:%d)" sprintf(temp2, STRING_COMPILE_SUCCESS, ErrorNum-CompileMsgNum-WarningNum, WarningNum, ((double)(GetTickCount() - beforeTickCount))/1000 ); } else{ //"コンパイルは中断されました(エラー:%d、警告:%d)" sprintf(temp2,STRING_COMPILE_ERROR,ErrorNum-CompileMsgNum-WarningNum,WarningNum); } CompileMessage(""); CompileMessage("-----------------------------------------------------"); CompileMessage(temp2); } //"閉じる" SetDlgItemText(hMainDlg,IDOK,STRING_CLOSE); #ifdef _DEBUG // デバッグモードのときはダイアログが隠れている ShowWindow(hMainDlg,SW_SHOW); #endif } int MainThread(DWORD dummy){ extern BOOL bDebugCompile; extern BOOL bDebugRun; extern int bError; if(bDebugRun){ if(bDebugCompile){ bDebugRun=0; //デバッグコンパイル OutputExe(); bDebugRun=1; } //デバッグ実行 if(bError==0) DebugProgram(); } else{ //リリースコンパイル OutputExe(); } return 0; }