source: dev/trunk/abdev/BasicCompiler_Common/MakeExe.cpp@ 266

Last change on this file since 266 was 266, checked in by dai_9181, 17 years ago

BasicSourceのシリアライズがうまくいっていない

File size: 5.3 KB
Line 
1#include "stdafx.h"
2
3#include <jenga/include/smoothie/Smoothie.h>
4
5#include <Compiler.h>
6
7#include "common.h"
8
9void StepCompileProgress(void){
10 extern HWND hMainDlg;
11 PostMessage(GetDlgItem(hMainDlg,IDC_PROGRESS),PBM_STEPIT,0,0);
12}
13
14void AddSourceCode(char *buffer){
15 char *temp;
16 temp=(char *)HeapAlloc(hHeap,0,lstrlen(buffer)+8192);
17 lstrcpy(temp,buffer);
18
19 //エスケープシーケンス設定
20 SetEscapeSequenceFormat(temp);
21
22 //コマンド対応
23 ChangeCommandToCode(temp);
24
25 //最後尾に貼り付け
26 compiler.GetObjectModule().source.Addition( temp );
27
28 HeapDefaultFree(temp);
29}
30
31void OutputExe(void){
32 extern HANDLE hHeap;
33 extern char *basbuf;
34 extern int ErrorNum;
35 extern BOOL bStopCompile;
36 extern HWND hMainDlg;
37 int i2,i3;
38 char temp2[MAX_PATH];
39
40 // 開始時刻を記録
41 DWORD beforeTickCount = GetTickCount();
42
43 //プログレスバーの設定
44 PostMessage(GetDlgItem(hMainDlg,IDC_PROGRESS),PBM_SETRANGE,0,MAKELPARAM(0,6));
45 PostMessage(GetDlgItem(hMainDlg,IDC_PROGRESS),PBM_SETSTEP,1,0);
46
47 //"中断"
48 SetDlgItemText(hMainDlg,IDOK,STRING_STOP);
49
50 //中断フラグを初期化
51 bStopCompile=0;
52
53 //サブシステムのタイプ
54 extern unsigned short TypeOfSubSystem;
55 TypeOfSubSystem=IMAGE_SUBSYSTEM_WINDOWS_GUI;
56
57 //プログラムをファイルから読み込む
58 extern char SourceFileName[MAX_PATH];
59 if( !compiler.GetObjectModule().source.ReadFile( SourceFileName ) ){
60 SetError(201,SourceFileName,-1);
61 goto EndCompile;
62 }
63
64 //イメージベースの設定
65 extern DWORD ImageBase;
66 if(compiler.IsDll()) ImageBase=0x10000000;
67 else ImageBase=0x00400000;
68
69 extern BOOL bError;
70 if(bError||bStopCompile) goto EndCompile;
71
72
73 //////////////////////////
74 // 中間コードの生成を開始
75 extern BOOL bClipCompileView;
76
77 //"最適化中..."
78 CompileMessage(STRING_COMPILE_OPTIMIZING);
79
80 //カッコを相互チェック(ダブルクォートチェックチェックを含む)
81 CheckParenthesis(basbuf);
82
83 if(bError||bStopCompile) goto EndCompile;
84
85 //コンパイルダイアログのプログレスバーを上げる
86 StepCompileProgress();
87
88 //ディレクティブ
89 DirectiveCheck();
90
91 //Next命令語を正規表現に変換
92 //NextCommandFormat(basbuf);
93
94 //エスケープシーケンス設定
95 SetEscapeSequenceFormat(basbuf);
96
97 //Def命令語をFunction命令語に変換
98 DefCommandFormat(basbuf);
99
100 //すべてのIf命令語をブロック形式に変換
101 IfCommandFormat(basbuf);
102
103 //対になる命令語を相互チェック
104 //CheckPareCommand();
105
106 if(bError||bStopCompile) goto EndCompile;
107
108 //コンパイルダイアログのプログレスバーを上げる
109 StepCompileProgress();
110
111 //重複エラー情報管理のメモリを確保
112 extern char **SynonymErrorWords;
113 extern int SynonymErrorNum;
114 SynonymErrorNum=0;
115 SynonymErrorWords=(char **)HeapAlloc(hHeap,0,1);
116
117 ChangeCommandToCode(basbuf);
118
119 //重複エラー情報管理のメモリを解放
120 for(i3=0;i3<SynonymErrorNum;i3++) HeapDefaultFree(SynonymErrorWords[i3]);
121 HeapDefaultFree(SynonymErrorWords);
122 SynonymErrorWords=0;
123
124 if(bError||bStopCompile){
125 //定数に関する情報を解放
126 goto EndCompile;
127 }
128
129 StepCompileProgress();
130
131
132 ///////////////////////
133 // コンパイル開始
134
135 //"コンパイル中..."
136 CompileMessage(STRING_COMPILE_COMPILING);
137
138 //グローバル変数に関する情報
139 extern int AllGlobalVarSize;
140 extern int AllInitGlobalVarSize;
141 compiler.GetObjectModule().meta.GetGlobalVars().clear();
142 AllGlobalVarSize=0;
143 AllInitGlobalVarSize=0;
144
145
146 /*
147 int t,t2;
148 t=GetTickCount();
149 Compile();
150 t2=GetTickCount();
151 t2-=t;
152 char s[100];
153 sprintf(s,"%d",t2);
154 MessageBox(0,s,"test",0);*/
155 Compile();
156
157 //リソース情報を解放
158 extern RESOURCEDATAINFO *pCursorResourceInfo;
159 extern RESOURCEDATAINFO *pIconResourceInfo;
160 extern RESOURCEDATAINFO *pBitmapResourceInfo;
161 HeapDefaultFree(pCursorResourceInfo);
162 HeapDefaultFree(pBitmapResourceInfo);
163 HeapDefaultFree(pIconResourceInfo);
164
165 //コンパイルダイアログのプログレスバーを上げる
166 StepCompileProgress();
167
168
169 //////////////////////////
170 // 終了処理
171EndCompile:
172 if(bStopCompile){
173 PostMessage(GetDlgItem(hMainDlg,IDC_PROGRESS),PBM_SETPOS,0,0);
174
175 //"コンパイルはユーザーにより中断されました。"
176 CompileMessage(STRING_COMPILE_STOP);
177 }
178 else{
179 extern int CompileMsgNum;
180 extern int WarningNum;
181 if(bError==0){
182 //"コンパイルは正常に完了しました(エラー:%d、警告:%d)"
183 sprintf(temp2,
184 STRING_COMPILE_SUCCESS,
185 ErrorNum-CompileMsgNum-WarningNum,
186 WarningNum,
187 ((double)(GetTickCount() - beforeTickCount))/1000
188 );
189 }
190 else{
191 //"コンパイルは中断されました(エラー:%d、警告:%d)"
192 sprintf(temp2,STRING_COMPILE_ERROR,ErrorNum-CompileMsgNum-WarningNum,WarningNum);
193 }
194
195 CompileMessage("");
196 CompileMessage("-----------------------------------------------------");
197 CompileMessage(temp2);
198 }
199
200 //"閉じる"
201 SetDlgItemText(hMainDlg,IDOK,STRING_CLOSE);
202
203#ifdef _DEBUG
204 // デバッグモードのときはダイアログが隠れている
205 ShowWindow(hMainDlg,SW_SHOW);
206#endif
207
208 //#include情報を解放
209 extern INCLUDEFILEINFO IncludeFileInfo;
210 for(i2=0;i2<IncludeFileInfo.FilesNum;i2++)
211 {
212 free(IncludeFileInfo.ppFileNames[i2]);
213 }
214 free(IncludeFileInfo.ppFileNames);
215}
216int MainThread(DWORD dummy){
217 extern BOOL bDebugCompile;
218 extern BOOL bDebugRun;
219 extern int bError;
220
221 if(bDebugRun){
222 if(bDebugCompile){
223 bDebugRun=0;
224
225 //デバッグコンパイル
226 OutputExe();
227
228 bDebugRun=1;
229 }
230
231 //デバッグ実行
232 if(bError==0) DebugProgram();
233 }
234 else{
235 //リリースコンパイル
236 OutputExe();
237 }
238
239 return 0;
240}
Note: See TracBrowser for help on using the repository browser.