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

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

DllProcsクラスを追加。

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