source: dev/trunk/ab5.0/abdev/BasicCompiler_Common/VarList.cpp@ 490

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

いくつかのグローバル変数をProgram/Debuggerクラスにまとめた。

File size: 40.5 KB
Line 
1#include "stdafx.h"
2
3#include <Compiler.h>
4
5#include "../BasicCompiler_Common/common.h"
6
7//デバッグ用
8#include "../BasicCompiler_Common/debug.h"
9
10//変数リストのツリーハンドル
11HWND hVarTree_Global,hVarTree_Local,hVarTree_This;
12
13int VarList_Array(HWND hVarTree,HTREEITEM hParent,LONG_PTR offset,const Type &type,const Subscripts &subscripts);
14void VarList_Member(HWND hVarTree,HTREEITEM hParent,LONG_PTR pTopOffset,const CClass &objClass,BOOL bPtr);
15void VarList_Insert(HWND hVarTree,TV_INSERTSTRUCT *lptv,const char *VarName,const Type &type,LONG_PTR offset){
16 extern HANDLE hDebugProcess;
17 int i2;
18 char temporary[255],temp2[255];
19 LONG_PTR pData;
20 SIZE_T accessBytes;
21 double dbl;
22 float flt;
23 WORD wData;
24 BYTE byteData;
25 HTREEITEM hParent;
26 _int64 i64data;
27
28 if( type.IsObject() || type.IsStruct() ){
29 i2=1;
30 if( type.IsObject() ){
31 // 参照型ということを考慮する
32 i2=ReadProcessMemory(hDebugProcess,(void *)offset,&pData,sizeof(void *),&accessBytes);
33 offset = pData;
34 }
35
36 sprintf(lptv->item.pszText,"%s %s(&H%X)",VarName,STRING_OBJECT,(ULONG_PTR)offset);
37 lptv->item.iImage=1;
38 lptv->item.iSelectedImage=1;
39 hParent=TreeView_InsertItem(hVarTree,lptv);
40
41 if(i2 && offset) VarList_Member(hVarTree,hParent,offset,type.GetClass(),0);
42 return;
43 }
44 else if( type.IsObjectPtr() || type.IsStructPtr() ){
45 i2=ReadProcessMemory(hDebugProcess,(void *)offset,&pData,sizeof(void *),&accessBytes);
46
47 sprintf(lptv->item.pszText,"%s %s(&H%X)",VarName,STRING_POINTEROFOBJECT,(ULONG_PTR)pData);
48 lptv->item.iImage=4;
49 lptv->item.iSelectedImage=4;
50 hParent=TreeView_InsertItem(hVarTree,lptv);
51
52 if(i2) VarList_Member(hVarTree,hParent,pData,type.GetClass(),1);
53 return;
54 }
55 else{
56 if(type.GetBasicType()==MAKE_PTR_TYPE(DEF_SBYTE,1)||type.GetBasicType()==MAKE_PTR_TYPE(DEF_BYTE,1)){
57 if(ReadProcessMemory(hDebugProcess,(void *)offset,&pData,sizeof(void *),&accessBytes)){
58 for(i2=0;;i2++){
59 if(!ReadProcessMemory(hDebugProcess,(void *)(pData+i2),&temporary[i2],1,&accessBytes)){
60 i2=-1;
61 break;
62 }
63 if(temporary[i2]=='\0') break;
64 if(i2==64){
65 lstrcpy(temporary+i2,"...");
66 break;
67 }
68 }
69 if(i2==-1) sprintf(lptv->item.pszText,"%s %d(&H%X)",VarName,(ULONG_PTR)pData,(ULONG_PTR)pData);
70 else sprintf(lptv->item.pszText,"%s %d(&H%X) \"%s\"",VarName,(ULONG_PTR)pData,(ULONG_PTR)pData,temporary);
71 }
72 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
73 }
74 else if(type.IsDouble()){
75 if(ReadProcessMemory(hDebugProcess,(void *)offset,&dbl,sizeof(double),&accessBytes)){
76 sprintf(lptv->item.pszText,"%s %.15g",VarName,dbl);
77 }
78 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
79 }
80 else if(type.IsSingle()){
81 if(ReadProcessMemory(hDebugProcess,(void *)offset,&flt,sizeof(float),&accessBytes)){
82 sprintf(lptv->item.pszText,"%s %.6g",VarName,flt);
83 }
84 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
85 }
86 else if(type.IsInt64()){
87 _int64 i64data;
88 if(ReadProcessMemory(hDebugProcess,(void *)offset,&i64data,sizeof(_int64),&accessBytes)){
89 _i64toa(i64data,temporary,10);
90 _i64toa(i64data,temp2,16);
91 CharUpper(temp2);
92 sprintf(lptv->item.pszText,"%s %s(&H%s)",VarName,temporary,temp2);
93 }
94 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
95 }
96 else if(type.IsQWord()||(type.IsPointer()&&PTR_SIZE==sizeof(_int64))){
97 if(ReadProcessMemory(hDebugProcess,(void *)offset,&i64data,sizeof(_int64),&accessBytes)){
98 _ui64toa(i64data,temporary,10);
99 _ui64toa(i64data,temp2,16);
100 CharUpper(temp2);
101 sprintf(lptv->item.pszText,"%s %s(&H%s)",VarName,temporary,temp2);
102 }
103 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
104 }
105 else if(type.IsLong()){
106 long l;
107 if(ReadProcessMemory(hDebugProcess,(void *)offset,&l,sizeof(long),&accessBytes)){
108 sprintf(lptv->item.pszText,"%s %d(&H%X)",VarName,l,l);
109 }
110 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
111 }
112 else if(type.IsDWord()||(type.IsPointer()&&PTR_SIZE==sizeof(long))){
113 if(ReadProcessMemory(hDebugProcess,(void *)offset,&i64data,sizeof(_int64),&accessBytes)){
114 sprintf(lptv->item.pszText,"%s %u(&H%X)",VarName,(int)i64data,(int)i64data);
115 }
116 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
117 }
118 else if(type.IsInteger()){
119 if(ReadProcessMemory(hDebugProcess,(void *)offset,&wData,sizeof(WORD),&accessBytes)){
120 sprintf(lptv->item.pszText,"%s %d(&H%X)",VarName,(short)wData,(short)wData);
121 }
122 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
123 }
124 else if(type.IsWord()){
125 if(ReadProcessMemory(hDebugProcess,(void *)offset,&wData,sizeof(WORD),&accessBytes)){
126 sprintf(lptv->item.pszText,"%s %u(&H%X)",VarName,wData,wData);
127 }
128 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
129 }
130 else if(type.IsSByte()){
131 if(ReadProcessMemory(hDebugProcess,(void *)offset,&byteData,sizeof(BYTE),&accessBytes)){
132 temporary[0]=byteData;
133 temporary[1]=0;
134 sprintf(lptv->item.pszText,"%s %d(&H%X)'%s'",VarName,(char)byteData,byteData,temporary);
135 }
136 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
137 }
138 else if(type.IsByte()){
139 if(ReadProcessMemory(hDebugProcess,(void *)offset,&byteData,sizeof(BYTE),&accessBytes)){
140 temporary[0]=byteData;
141 temporary[1]=0;
142 sprintf(lptv->item.pszText,"%s %d(&H%X)'%s'",VarName,byteData,byteData,temporary);
143 }
144 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
145 }
146 else if(type.IsBoolean()){
147 if(ReadProcessMemory(hDebugProcess,(void *)offset,&byteData,sizeof(BYTE),&accessBytes)){
148 if( byteData ) lstrcpy( temporary, "True" );
149 else lstrcpy( temporary, "False" );
150
151 wsprintf(lptv->item.pszText,"%s %s",VarName,temporary);
152 }
153 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
154 }
155 lptv->item.iImage=2;
156 lptv->item.iSelectedImage=2;
157 }
158 TreeView_InsertItem(hVarTree,lptv);
159}
160void VarList_Member(HWND hVarTree,HTREEITEM hParent,LONG_PTR pTopOffset,const CClass &objClass,BOOL bPtr)
161{
162 char VarData[VN_SIZE],VarName[VN_SIZE];
163 if( objClass.HasSuperClass() )
164 {
165 TV_INSERTSTRUCT tv;
166
167 memset(&tv,0,sizeof(TV_INSERTSTRUCT));
168 tv.hInsertAfter=TVI_LAST;
169 tv.item.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
170 tv.hParent=hParent;
171 tv.item.pszText=VarData;
172
173 // 基底クラス
174 sprintf(tv.item.pszText,"Inherits %s",objClass.GetSuperClass().GetName().c_str());
175 tv.item.iImage=1;
176 tv.item.iSelectedImage=1;
177 HTREEITEM hTempParent=TreeView_InsertItem(hVarTree,&tv);
178
179 VarList_Member(hVarTree,hTempParent,pTopOffset,objClass.GetSuperClass(),0);
180 }
181
182 TV_INSERTSTRUCT tv;
183
184 memset(&tv,0,sizeof(TV_INSERTSTRUCT));
185 tv.hInsertAfter=TVI_LAST;
186 tv.item.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
187 tv.hParent=hParent;
188 tv.item.pszText=VarData;
189
190 BOOST_FOREACH( CMember *pMember, objClass.GetDynamicMembers() ){
191 if(bPtr){
192 lstrcpy(VarName,"->");
193 lstrcat(VarName,pMember->GetName().c_str());
194 }
195 else{
196 lstrcpy(VarName,".");
197 lstrcat(VarName,pMember->GetName().c_str());
198 }
199
200 LONG_PTR offset;
201 offset=objClass.GetMemberOffset( pMember->GetName().c_str() );
202
203 if( pMember->GetSubscripts().size() > 0 ){
204 //構造体内の配列
205 sprintf(VarData,"%s %s(&H%X)",VarName,STRING_ARRAY,pTopOffset+offset);
206 tv.item.iImage=0;
207 tv.item.iSelectedImage=0;
208 hParent=TreeView_InsertItem(hVarTree,&tv);
209
210 VarList_Array(
211 hVarTree,
212 hParent,
213 pTopOffset + offset,
214 pMember->GetType(),
215 pMember->GetSubscripts()
216 );
217 }
218 else{
219 //メンバ変数
220 VarList_Insert(hVarTree,
221 &tv,
222 VarName,
223 pMember->GetType(),
224 pTopOffset+offset);
225 }
226 }
227}
228int VarList_Array(HWND hVarTree,HTREEITEM hParent,LONG_PTR offset,const Type &type, const Subscripts &subscripts ){
229 int i,i2,i3,ElementNum,MemCounter,UseCount[255];
230 char temporary[VN_SIZE],temp2[DIGIT_SIZE];
231
232 TV_INSERTSTRUCT tv;
233 memset(&tv,0,sizeof(TV_INSERTSTRUCT));
234 tv.hInsertAfter=TVI_LAST;
235 tv.item.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
236 tv.hParent=hParent;
237 tv.item.pszText=temporary;
238
239 for(i=0;i<(int)subscripts.size();i++){
240 UseCount[i]=0;
241 }
242 UseCount[i]=-2;
243 MemCounter=0;
244 i--;
245 while(1){
246 UseCount[i]++;
247 for(ElementNum=0;subscripts[i-ElementNum]<UseCount[i-ElementNum];ElementNum++){
248 UseCount[i-ElementNum]=0;
249 if(i-ElementNum-1<0) return MemCounter;
250 UseCount[i-ElementNum-1]++;
251 }
252
253 if(MemCounter<50){
254 temporary[0]='[';
255 temporary[1]=0;
256 for(i2=0;i2<i;i2++){
257 sprintf(temp2,"%d",UseCount[i2]);
258 lstrcat(temporary,temp2);
259 lstrcat(temporary,",");
260 }
261 i3=lstrlen(temporary);
262 temporary[i3-1]=']';
263 temporary[i3]=0;
264
265 VarList_Insert(hVarTree,&tv,temporary,type,
266 offset+MemCounter*type.GetSize());
267 }
268
269 MemCounter++;
270 if(MemCounter==50){
271 lstrcpy(tv.item.pszText,"...");
272 TreeView_InsertItem(hVarTree,&tv);
273 }
274 }
275 return 0;
276}
277void RefreshGlobalVar(void){
278 extern DWORD ImageBase;
279 char temporary[VN_SIZE];
280 TV_INSERTSTRUCT tv;
281 HTREEITEM hParent;
282
283 TreeView_DeleteAllItems(hVarTree_Global);
284
285 memset(&tv,0,sizeof(TV_INSERTSTRUCT));
286 tv.hInsertAfter=TVI_LAST;
287 tv.item.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
288 tv.hParent=TVI_ROOT;
289 tv.item.pszText=temporary;
290
291 extern HANDLE hDebugProcess;
292 extern int MemPos_RWSection;
293
294 BOOST_FOREACH( Variable *pVar, compiler.GetObjectModule().meta.GetGlobalVars() ){
295
296 //スコープ外の場合は無視
297 if(pVar->GetScopeLevel()!=0){
298 if(rva_to_real(pVar->GetScopeStartAddress()) <= pobj_dti->lplpObp[0] &&
299 pobj_dti->lplpObp[0] < rva_to_real(pVar->GetScopeEndAddress())){
300 //範囲内
301 }
302 else{
303 //範囲外
304 continue;
305 }
306 }
307
308
309 if(!pobj_nv->bShow_DefaultSystem_Var){
310 if(memcmp(pVar->GetName().c_str(),"_System_",8)==0||
311 memcmp(pVar->GetName().c_str(),"_DebugSys_",10)==0||
312 memcmp(pVar->GetName().c_str(),"_PromptSys_",11)==0) continue;
313 }
314 if(!pobj_nv->bShow_Rad_Var){
315 if(memcmp(pVar->GetName().c_str(),"_RadSys_",8)==0) continue;
316 }
317 if(!pobj_nv->bShow_GUID_Var){
318 if(memcmp(pVar->GetName().c_str(),"GUID_",5)==0||
319 memcmp(pVar->GetName().c_str(),"IID_",4)==0||
320 memcmp(pVar->GetName().c_str(),"CLSID_",6)==0) continue;
321 }
322
323 //静的メンバ
324 if(strstr(pVar->GetName().c_str(),".")) continue;
325
326 if(pVar->IsArray()){
327 sprintf(temporary,"%s %s(&H%X)",
328 pVar->GetName().c_str(),
329 STRING_ARRAY,
330 ImageBase+MemPos_RWSection+pVar->GetOffsetAddress());
331 tv.item.iImage=0;
332 tv.item.iSelectedImage=0;
333 hParent=TreeView_InsertItem(hVarTree_Global,&tv);
334
335 VarList_Array(
336 hVarTree_Global,
337 hParent,
338 (LONG_PTR)(ImageBase+MemPos_RWSection + pVar->GetOffsetAddress()),
339 pVar->GetType(),
340 pVar->GetSubscripts()
341 );
342 }
343 else{
344 VarList_Insert(hVarTree_Global,
345 &tv,
346 pVar->GetName().c_str(),
347 pVar->GetType(),
348 (LONG_PTR)(ImageBase+MemPos_RWSection+pVar->GetOffsetAddress()));
349 }
350 }
351}
352void RefreshLocalVar(void){
353 int i2;
354 char temporary[VN_SIZE];
355 TV_INSERTSTRUCT tv;
356 HTREEITEM hParent;
357 LONG_PTR offset;
358 SIZE_T accessBytes;
359 LONG_PTR lpData;
360
361 TreeView_DeleteAllItems(hVarTree_Local);
362
363 memset(&tv,0,sizeof(TV_INSERTSTRUCT));
364 tv.hInsertAfter=TVI_LAST;
365 tv.item.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
366 tv.hParent=TVI_ROOT;
367 tv.item.pszText=temporary;
368
369 extern HANDLE hDebugProcess;
370 extern HWND hDebugWnd;
371 i2=(int)SendDlgItemMessage(hDebugWnd,IDC_PROCCOMBO,CB_GETCURSEL,0,0);
372 i2=pobj_dti->iProcLevel-i2;
373
374 if(pobj_dti->lplpSpBase[i2]==0) return;
375
376 UserProc *pUserProc = NULL;
377 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset();
378 while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() )
379 {
380 pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();
381 if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2] &&
382 pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->GetEndOpAddress())){
383 break;
384 }
385 }
386 if(!pUserProc) return;
387
388 BOOST_FOREACH( Variable *pVar, pUserProc->GetLocalVars() ){
389
390 //スコープ外の場合は無視
391 int scopeBeginAddressRva = pUserProc->GetBeginOpAddress() + pVar->GetScopeStartAddress();
392 int scopeEndAddressRva = pUserProc->GetBeginOpAddress() + pVar->GetScopeEndAddress();
393 if(pVar->GetScopeLevel()!=0)
394 {
395 if( rva_to_real( scopeBeginAddressRva ) <= pobj_dti->lplpObp[i2]
396 && pobj_dti->lplpObp[i2] < rva_to_real( scopeEndAddressRva ) )
397 {
398 //範囲内
399 }
400 else{
401 //範囲外
402 continue;
403 }
404 }
405
406 if(pVar->IsArray()){
407 sprintf(temporary,"%s %s(&H%X)",
408 pVar->GetName().c_str(),
409 STRING_ARRAY,
410 pobj_dti->lplpSpBase[i2]+pVar->GetOffsetAddress());
411 tv.item.iImage=0;
412 tv.item.iSelectedImage=0;
413 hParent=TreeView_InsertItem(hVarTree_Local,&tv);
414
415 VarList_Array(
416 hVarTree_Local,
417 hParent,
418 pobj_dti->lplpSpBase[i2] + pVar->GetOffsetAddress(),
419 pVar->GetType(),
420 pVar->GetSubscripts()
421 );
422 }
423 else{
424 offset=pobj_dti->lplpSpBase[i2]+pVar->GetOffsetAddress();
425 if(pVar->IsRef()){
426 ReadProcessMemory(hDebugProcess,(void *)offset,&lpData,sizeof(LONG_PTR),&accessBytes);
427 offset=lpData;
428 }
429 VarList_Insert(hVarTree_Local,&tv,
430 pVar->GetName().c_str(),
431 pVar->GetType(),
432 offset);
433 }
434 }
435
436
437
438 /////////////////////////////
439 // Thisオブジェクトのリスト
440 /////////////////////////////
441
442 TreeView_DeleteAllItems(hVarTree_This);
443 if( pUserProc->IsGlobalProcedure() ) return;
444
445 //Thisポインタを取得
446 LONG_PTR pThis;
447 const Variable *pVar = pUserProc->GetLocalVars().Find( Symbol( "_System_LocalThis" ) );
448 if( !pVar ){
449 return;
450 }
451 lpData=pobj_dti->lplpSpBase[i2]+pVar->GetOffsetAddress();
452 ReadProcessMemory(hDebugProcess,(void *)lpData,&pThis,sizeof(LONG_PTR),&accessBytes);
453
454 if( pUserProc->GetParentClassPtr()->HasSuperClass() )
455 {
456 TV_INSERTSTRUCT tv;
457
458 memset(&tv,0,sizeof(TV_INSERTSTRUCT));
459 tv.hInsertAfter=TVI_LAST;
460 tv.item.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
461 tv.hParent=NULL;
462 tv.item.pszText=temporary;
463
464 // 基底クラス
465 sprintf(tv.item.pszText,"Inherits %s",pUserProc->GetParentClassPtr()->GetSuperClass().GetName().c_str());
466 tv.item.iImage=1;
467 tv.item.iSelectedImage=1;
468 HTREEITEM hTempParent=TreeView_InsertItem(hVarTree_This,&tv);
469
470 VarList_Member(hVarTree_This,hTempParent,pThis,pUserProc->GetParentClassPtr()->GetSuperClass(),0);
471 }
472
473 BOOST_FOREACH( CMember *pMember, pUserProc->GetParentClassPtr()->GetDynamicMembers() ){
474 offset=pUserProc->GetParentClassPtr()->GetMemberOffset( pMember->GetName().c_str());
475
476 if( pMember->GetSubscripts().size() > 0 ){
477 //配列
478 sprintf(temporary,"%s %s(&H%X)",
479 pMember->GetName().c_str(),
480 STRING_ARRAY,
481 (ULONG_PTR)offset);
482 tv.item.iImage=0;
483 tv.item.iSelectedImage=0;
484 hParent=TreeView_InsertItem(hVarTree_This,&tv);
485
486 VarList_Array(
487 hVarTree_This,
488 hParent,
489 pThis + offset,
490 pMember->GetType(),
491 pMember->GetSubscripts()
492 );
493 }
494 else{
495 VarList_Insert(hVarTree_This,&tv,
496 pMember->GetName().c_str(),
497 pMember->GetType(),
498 pThis+offset);
499 }
500 }
501}
502void RefreshGlobalVar_with_WindowLock(void){
503 extern HWND hDebugWnd;
504
505 //処理時間を短くするため、一時的に非表示にする
506 LockWindowUpdate(hDebugWnd);
507 ShowWindow(GetParent(hVarTree_Global),SW_HIDE);
508
509 //リフレッシュ
510 RefreshGlobalVar();
511
512 LockWindowUpdate(NULL);
513 ShowWindow(GetParent(hVarTree_Global),SW_SHOW);
514}
515void RefreshLocalVar_with_WindowLock(void){
516 extern HWND hDebugWnd;
517
518 //処理時間を短くするため、一時的に非表示にする
519 LockWindowUpdate(hDebugWnd);
520 ShowWindow(GetParent(hVarTree_Local),SW_HIDE);
521
522 //リフレッシュ
523 RefreshLocalVar();
524
525 LockWindowUpdate(NULL);
526 ShowWindow(GetParent(hVarTree_Local),SW_SHOW);
527}
528
529void SetCalcToWatchList(HWND hListView,int iItem,char *buffer){
530 char temporary[255],temp2[255];
531
532 //エスケープシーケンスをセット
533 SetEscapeSequenceFormat(buffer);
534
535 KillStringSpaces(buffer);
536
537 //カッコを相互チェック
538 if(!CheckParenthesis2(buffer)){
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557 ListView_SetItemText(hListView,iItem,1,"式の解析に失敗");
558 return;
559 }
560
561 double dbl;
562 _int64 i64data;
563 Type resultType;
564 bool isMemoryAccessError;
565 if( !StaticCalculation(true, buffer,0,&i64data,resultType,1,&isMemoryAccessError) ){
566 ListView_SetItemText(hListView,iItem,1,"式の解析に失敗");
567 }
568 else if(isMemoryAccessError){
569 ListView_SetItemText(hListView,iItem,1,"アクセスできません");
570 }
571 else{
572 if(resultType.IsReal()){
573 memcpy(&dbl,&i64data,sizeof(double));
574 sprintf(temporary,"%.15g (&H%08X)",dbl,(int)dbl);
575 }
576 else if(resultType.Is64()){
577 _i64toa(i64data,temporary,10);
578 _i64toa(i64data,temp2,16);
579 CharUpper(temp2);
580 sprintf(temporary+lstrlen(temporary)," (&H%s)",temp2);
581 }
582 else sprintf(temporary,"%d (&H%08X)",(long)i64data,(long)i64data);
583
584 ListView_SetItemText(hListView,iItem,1,temporary);
585 }
586}
587void RefreshWatchList(void){
588 extern HWND hDebugWnd;
589 HWND hListView;
590 int i,i2;
591 char temporary[VN_SIZE];
592
593 hListView=GetDlgItem(hDebugWnd,IDC_WATCHLIST);
594 i2=ListView_GetItemCount(hListView);
595 for(i=0;i<i2-1;i++){
596 ListView_GetItemText(hListView,i,0,temporary,VN_SIZE);
597
598 //演算結果を表示
599 SetCalcToWatchList(hListView,i,temporary);
600 }
601}
602
603BOOL SetDebugProcCombo(HWND hProcCombo){
604 int i2,i3;
605 char temporary[255];
606
607 extern DWORD ImageBase;
608 extern int MemPos_CodeSection;
609
610 //行番号情報
611 extern SourceLines oldSourceLines;
612 for(i3=0;i3<(int)pobj_dti->iProcLevel+1;i3++){
613 for(i2=0;i2<(int)oldSourceLines.size()-2;i2++){
614 if((ULONG_PTR)(oldSourceLines[i2].GetNativeCodePos()+ImageBase+MemPos_CodeSection)<=pobj_dti->lplpObp[i3]&&
615 pobj_dti->lplpObp[i3]<=(ULONG_PTR)(oldSourceLines[i2+1].GetNativeCodePos()+ImageBase+MemPos_CodeSection)) break;
616 }
617 if(i2==oldSourceLines.size()-1) pobj_dti->lpdwCp[i3]=-1;
618 else
619 {
620 pobj_dti->lpdwCp[i3]=oldSourceLines[i2].GetSourceCodePos();
621 pobj_dti->lpdwSourceIndex[i3]=oldSourceLines[i2].GetSourceIndex();
622 }
623 }
624 for(i3=0;i3<(int)pobj_dti->iProcLevel+1;i3++){
625 if(pobj_dti->lpdwCp[i3]==-1){
626 pobj_dti->iProcLevel--;
627 for(i2=i3;i2<(int)pobj_dti->iProcLevel+1;i2++){
628 pobj_dti->lplpObp[i2]=pobj_dti->lplpObp[i2+1];
629 pobj_dti->lplpSpBase[i2]=pobj_dti->lplpSpBase[i2+1];
630 pobj_dti->lpdwCp[i2]=pobj_dti->lpdwCp[i2+1];
631 pobj_dti->lpdwSourceIndex[i2]=pobj_dti->lpdwSourceIndex[i2+1];
632 }
633 i3--;
634 continue;
635 }
636 }
637
638 std::string dummyStr;
639 if(!compiler.GetObjectModule().GetSource( pobj_dti->lpdwSourceIndex[pobj_dti->iProcLevel] ).GetLineInfo( pobj_dti->lpdwCp[pobj_dti->iProcLevel], i2, dummyStr )){
640 extern HWND hMainDlg;
641 //"デバッグ情報の取得に失敗"
642 MessageBox(hMainDlg,STRING_DEBUG_FAILED,"ActiveBasic error",MB_OK);
643 return 0;
644 }
645 ShowErrorLine(i2,dummyStr.c_str());
646
647 //プロシージャ コンボボックス
648 SendMessage(hProcCombo,CB_RESETCONTENT,0,0);
649 for(i2=pobj_dti->iProcLevel;i2>=0;i2--){
650
651 UserProc *pUserProc = NULL;
652 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset();
653 while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() )
654 {
655 pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();
656
657 if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2] &&
658 pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->GetEndOpAddress()))
659 {
660 lstrcpy(temporary,pUserProc->GetName().c_str());
661 break;
662 }
663 }
664 if(!pUserProc){
665 if(i2==0){
666 lstrcpy(temporary,"Global");
667 pobj_dti->lplpSpBase[i2]=0;
668 }
669 else lstrcpy(temporary,"error");
670 }
671 SendMessage(hProcCombo,CB_ADDSTRING,0,(LPARAM)temporary);
672 }
673 SendMessage(hProcCombo,CB_SETCURSEL,0,0);
674
675 return pobj_dti->iProcLevel;
676}
677
678//IDC_THREADCOMBOプロシージャ
679LRESULT CALLBACK ThreadComboProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
680 extern WNDPROC OldThreadComboProc;
681 int i2;
682 DWORD dwThreadID;
683 char temporary[255];
684
685 switch(message){
686 case WM_COMMAND:
687 if(HIWORD(wParam)==CBN_SELCHANGE){
688 SendMessage(hwnd,CB_GETLBTEXT,SendMessage(hwnd,CB_GETCURSEL,0,0),(LPARAM)temporary);
689 sscanf(temporary+2,"%X",&dwThreadID);
690
691 extern DWORD _DebugSys_dwThreadID[256];
692 i2=0;
693 while(_DebugSys_dwThreadID[i2]!=dwThreadID) i2++;
694
695 //次回のステップ実行対象を指定
696 extern int NextStepThreadNum;
697 NextStepThreadNum=i2;
698
699 //スレッド情報をリフレッシュ
700 pobj_dti->Reflesh(i2);
701
702 SetDebugProcCombo(GetDlgItem(GetParent(hwnd),IDC_PROCCOMBO));
703
704 SendDlgItemMessage(GetParent(hwnd),IDC_PROCCOMBO,WM_COMMAND,MAKELONG(0,CBN_SELCHANGE),0);
705 }
706 break;
707 }
708 return CallWindowProc(OldThreadComboProc,hwnd,message,wParam,lParam);
709}
710//IDC_PROCCOMBOプロシージャ
711LRESULT CALLBACK ProcComboProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
712 extern WNDPROC OldProcComboProc;
713 int i2,i3;
714
715 switch(message){
716 case WM_COMMAND:
717 if(HIWORD(wParam)==CBN_SELCHANGE){
718 i2=(int)SendMessage(hwnd,CB_GETCURSEL,0,0);
719
720 std::string dummyStr;
721 compiler.GetObjectModule().GetSource( pobj_dti->lpdwSourceIndex[pobj_dti->iProcLevel] ).GetLineInfo( pobj_dti->lpdwCp[pobj_dti->iProcLevel-i2], i3, dummyStr );
722 ShowErrorLine(i3,dummyStr.c_str());
723
724 RefreshLocalVar_with_WindowLock();
725 }
726 break;
727 }
728 return CallWindowProc(OldProcComboProc,hwnd,message,wParam,lParam);
729}
730void InitVarList(DWORD dwThreadId){
731 extern HWND hDebugWnd;
732 int i2,i5;
733 char temporary[255];
734
735
736 //スレッド
737 SendDlgItemMessage(hDebugWnd,IDC_THREADCOMBO,CB_RESETCONTENT,0,0);
738 extern DWORD _DebugSys_dwThreadID[256];
739 for(i2=0;i2<256;i2++){
740 if(_DebugSys_dwThreadID[i2]){
741 sprintf(temporary,"&H%08X",_DebugSys_dwThreadID[i2]);
742 SendDlgItemMessage(hDebugWnd,IDC_THREADCOMBO,CB_ADDSTRING,0,(LPARAM)temporary);
743 if(_DebugSys_dwThreadID[i2]==dwThreadId){
744 extern int NextStepThreadNum;
745 NextStepThreadNum=i2;
746 }
747 }
748 }
749 sprintf(temporary,"&H%08X",dwThreadId);
750 i5=(int)SendDlgItemMessage(hDebugWnd,IDC_THREADCOMBO,CB_FINDSTRING,0,(LPARAM)temporary);
751 SendDlgItemMessage(hDebugWnd,IDC_THREADCOMBO,CB_SETCURSEL,i5,0);
752
753 i2=SetDebugProcCombo(GetDlgItem(hDebugWnd,IDC_PROCCOMBO));
754
755
756 ///////////////////////////////////////////////
757 // 実行中のプロシージャのローカル変数をセット
758 ///////////////////////////////////////////////
759
760 i2=(int)SendDlgItemMessage(hDebugWnd,IDC_PROCCOMBO,CB_GETCURSEL,0,0);
761 i2=pobj_dti->iProcLevel-i2;
762
763 if(pobj_dti->lplpSpBase[i2]){
764
765 UserProc *pUserProc = NULL;
766 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset();
767 while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() )
768 {
769 pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();
770
771 if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2] &&
772 pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->GetEndOpAddress())){
773 break;
774 }
775 }
776
777 if(pUserProc){
778 compiler.pCompilingClass = pUserProc->GetParentClassPtr();
779 UserProc::CompileStartForUserProc( pUserProc );
780 }
781 }
782
783
784 ////////////////////////
785 // 変数リストを再表示
786 ////////////////////////
787
788 //処理時間を短くするため、一時的に非表示にする
789 LockWindowUpdate(hDebugWnd);
790 ShowWindow(GetParent(hVarTree_Global),SW_HIDE);
791 ShowWindow(GetDlgItem(hDebugWnd,IDC_WATCHLIST),SW_HIDE);
792
793 //リフレッシュ
794 RefreshLocalVar();
795 RefreshGlobalVar();
796 RefreshWatchList();
797
798 LockWindowUpdate(NULL);
799 ShowWindow(GetParent(hVarTree_Global),SW_SHOW);
800 ShowWindow(GetDlgItem(hDebugWnd,IDC_WATCHLIST),SW_SHOW);
801}
802
803
804
805
806//////////////////////////////////////
807// エディタに埋め込み表示のデバッガ
808//////////////////////////////////////
809
810BOOL CALLBACK DebuggerButtonsProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
811 extern HINSTANCE hInst;
812 extern DWORD dwStepRun;
813
814 //デバッガ用ツールバー
815#define BMPNUM_DEBUGGERTOOLBAR 3
816#define BTNNUM_DEBUGGERTOOLBAR 4
817 TBBUTTON DebuggerToolBar[]={
818 {0,IDC_DEBUG_START,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
819 {0,0,TBSTATE_ENABLED,TBSTYLE_SEP,0,0},
820 {1,IDC_DEBUG_STEPOVER,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
821 {2,IDC_DEBUG_STEPIN,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
822 };
823 TOOLTIPTEXT *pTipText;
824
825 static HIMAGELIST hImageList,hImageList_Disabled;
826
827 switch(message){
828 case WM_INITDIALOG:
829 //ツールバーを生成
830 extern HWND hDebuggerToolbar;
831 hDebuggerToolbar=CreateToolbarEx(hwnd,WS_CHILD|WS_VISIBLE|CCS_NODIVIDER|TBSTYLE_FLAT|TBSTYLE_TOOLTIPS|WS_CLIPSIBLINGS,
832 NULL,
833 0,0,0,
834 DebuggerToolBar,
835 BTNNUM_DEBUGGERTOOLBAR, /*アイテムの個数*/
836 0,0,16,15,sizeof(TBBUTTON));
837
838 hImageList = ImageList_LoadImage(hInst, MAKEINTRESOURCE(IDR_DEBUGGERTOOLBAR),
839 16, 0, RGB(192,192,192),IMAGE_BITMAP, LR_CREATEDIBSECTION);
840 SendMessage(hDebuggerToolbar, TB_SETIMAGELIST, 0, (LPARAM)hImageList);
841 hImageList_Disabled = ImageList_LoadImage(hInst, MAKEINTRESOURCE(IDR_DEBUGGERTOOLBAR_DISABLED),
842 16, 0, RGB(192,192,192),IMAGE_BITMAP, LR_CREATEDIBSECTION);
843 SendMessage(hDebuggerToolbar, TB_SETDISABLEDIMAGELIST, 0, (LPARAM)hImageList_Disabled);
844
845 break;
846 case WM_COMMAND:
847 switch(LOWORD(wParam)){
848 case IDC_DEBUG_START:
849 DestroyWindow(GetParent(hwnd));
850 return 1;
851 case IDC_DEBUG_STEPIN:
852 dwStepRun=1;
853 return 1;
854 case IDC_DEBUG_STEPOVER:
855 dwStepRun=2;
856 return 1;
857 }
858 break;
859 case WM_NOTIFY:
860 pTipText=(TOOLTIPTEXT *)lParam;
861 if(pTipText->hdr.code==TTN_NEEDTEXT){
862 //ツールチップを表示
863 switch(pTipText->hdr.idFrom){
864 case IDC_DEBUG_START:
865 pTipText->lpszText="実行";
866 break;
867 case IDC_DEBUG_STEPOVER:
868 pTipText->lpszText="ステップ アウト";
869 break;
870 case IDC_DEBUG_STEPIN:
871 pTipText->lpszText="ステップ イン";
872 break;
873 }
874 }
875 break;
876 case WM_SIZE:
877 MoveWindow(hDebuggerToolbar,0,0,LOWORD(lParam),HIWORD(lParam),1);
878 return 1;
879
880 case WM_DESTROY:
881 ImageList_Destroy(hImageList);
882 ImageList_Destroy(hImageList_Disabled);
883 return 1;
884 }
885 return 0;
886}
887
888WNDPROC OldTabProc;
889LRESULT CALLBACK TabProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
890 extern HINSTANCE hInst;
891
892 static HMENU hDummyMenu,hMenu=0;
893
894 switch(message){
895 case WM_CONTEXTMENU:
896 if(hMenu==0){
897 hDummyMenu=LoadMenu(hInst,MAKEINTRESOURCE(IDR_DEBUGGER_VARLIST_MENU));
898 hMenu=GetSubMenu(hDummyMenu,0);
899 }
900
901 MENUITEMINFO mi;
902 mi.cbSize=sizeof(MENUITEMINFO);
903 mi.fMask=MIIM_STATE;
904 mi.fState=MFS_CHECKED;
905
906 if(pobj_nv->bShow_DefaultSystem_Var)
907 SetMenuItemInfo(hMenu,IDM_SHOW_DEFAULTSYSTEM_VAR,0,&mi);
908 if(pobj_nv->bShow_Rad_Var)
909 SetMenuItemInfo(hMenu,IDM_SHOW_RAD_VAR,0,&mi);
910 if(pobj_nv->bShow_GUID_Var)
911 SetMenuItemInfo(hMenu,IDM_SHOW_GUID_VAR,0,&mi);
912
913 TrackPopupMenu(hMenu,TPM_LEFTALIGN,LOWORD(lParam),HIWORD(lParam),0,hwnd,0);
914
915 break;
916 case WM_COMMAND:
917 mi.cbSize=sizeof(MENUITEMINFO);
918 mi.fMask=MIIM_STATE;
919 switch(LOWORD(wParam)){
920 case IDM_SHOW_DEFAULTSYSTEM_VAR:
921 if(pobj_nv->bShow_DefaultSystem_Var){
922 pobj_nv->bShow_DefaultSystem_Var=0;
923 mi.fState=MFS_UNCHECKED;
924 }
925 else{
926 pobj_nv->bShow_DefaultSystem_Var=1;
927 mi.fState=MFS_CHECKED;
928 }
929 SetMenuItemInfo(hMenu,IDM_SHOW_DEFAULTSYSTEM_VAR,0,&mi);
930 RefreshGlobalVar_with_WindowLock();
931 break;
932 case IDM_SHOW_RAD_VAR:
933 if(pobj_nv->bShow_Rad_Var){
934 pobj_nv->bShow_Rad_Var=0;
935 mi.fState=MFS_UNCHECKED;
936 }
937 else{
938 pobj_nv->bShow_Rad_Var=1;
939 mi.fState=MFS_CHECKED;
940 }
941 SetMenuItemInfo(hMenu,IDM_SHOW_RAD_VAR,0,&mi);
942 RefreshGlobalVar_with_WindowLock();
943 break;
944 case IDM_SHOW_GUID_VAR:
945 if(pobj_nv->bShow_GUID_Var){
946 pobj_nv->bShow_GUID_Var=0;
947 mi.fState=MFS_UNCHECKED;
948 }
949 else{
950 pobj_nv->bShow_GUID_Var=1;
951 mi.fState=MFS_CHECKED;
952 }
953 SetMenuItemInfo(hMenu,IDM_SHOW_GUID_VAR,0,&mi);
954 RefreshGlobalVar_with_WindowLock();
955 break;
956 }
957 break;
958 case WM_DESTROY:
959 DestroyMenu(hMenu);
960 hMenu=0;
961 break;
962 }
963 return CallWindowProc(OldTabProc,hwnd,message,wParam,lParam);
964}
965
966BOOL CALLBACK DlgDebugger(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
967 extern HANDLE hHeap;
968 extern HINSTANCE hInst;
969 extern DWORD dwStepRun;
970 extern double width_ratio_VarList;
971 RECT rect;
972 int i,i2,i3;
973 char temporary[VN_SIZE];
974 LV_DISPINFO *lvinfo;
975 LVITEM ListView_Item;
976
977 static POINT pos_VarList;
978 static POINT pos_WatchList;
979
980 switch(message){
981 case WM_INITDIALOG:
982 extern HWND hDebugWnd;
983 hDebugWnd=hwnd;
984
985 //変数リストの初期位置を取得
986 GetWindowRect(GetDlgItem(hwnd,IDC_VARPOS),&rect);
987 pos_VarList.x=rect.left;
988 pos_VarList.y=rect.top;
989 ScreenToClient(hwnd,&pos_VarList);
990
991 //ウォッチリストの初期位置を取得
992 pos_WatchList.x=pos_VarList.x+(rect.right-rect.left)+LEVER_THICK;
993 pos_WatchList.y=0;
994
995 //ツールバーのベースウィンドウを生成
996 static HWND hBase_ToolBar;
997 hBase_ToolBar=CreateDialog(hInst,MAKEINTRESOURCE(IDD_DEBUGGER_TOOLBARBASE),hwnd,(DLGPROC)DebuggerButtonsProc);
998 MoveWindow(hBase_ToolBar,50,0,20*BTNNUM_DEBUGGERTOOLBAR,22,1);
999
1000 extern WNDPROC OldThreadComboProc;
1001 OldThreadComboProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hwnd,IDC_THREADCOMBO),GWLP_WNDPROC);
1002 SetWindowLongPtr(GetDlgItem(hwnd,IDC_THREADCOMBO),GWLP_WNDPROC,(LONG_PTR)ThreadComboProc);
1003
1004 extern WNDPROC OldProcComboProc;
1005 OldProcComboProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hwnd,IDC_PROCCOMBO),GWLP_WNDPROC);
1006 SetWindowLongPtr(GetDlgItem(hwnd,IDC_PROCCOMBO),GWLP_WNDPROC,(LONG_PTR)ProcComboProc);
1007
1008
1009 ///////////////////////////
1010 // タブコントロールを生成
1011 ///////////////////////////
1012
1013 static HWND hTab;
1014 HFONT hFont;
1015 hFont=(HFONT)SendMessage(hwnd,WM_GETFONT,0,0);
1016 hTab=CreateWindow(WC_TABCONTROL,NULL,
1017 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE,
1018 0,0,0,0,hwnd,0,hInst,0);
1019 SendMessage(hTab,WM_SETFONT,(WPARAM)hFont,0);
1020 OldTabProc=(WNDPROC)GetWindowLongPtr(hTab,GWLP_WNDPROC);
1021 SetWindowLongPtr(hTab,GWLP_WNDPROC,(LONG_PTR)TabProc);
1022
1023 //タブを設定
1024 TC_ITEM tcItem;
1025 tcItem.mask=TCIF_TEXT;
1026 tcItem.pszText="グローバル";
1027 SendMessage(hTab,TCM_INSERTITEM,0,(LPARAM)&tcItem);
1028 tcItem.mask=TCIF_TEXT;
1029 tcItem.pszText="ローカル";
1030 SendMessage(hTab,TCM_INSERTITEM,1,(LPARAM)&tcItem);
1031 tcItem.mask=TCIF_TEXT;
1032 tcItem.pszText="This";
1033 SendMessage(hTab,TCM_INSERTITEM,2,(LPARAM)&tcItem);
1034
1035 //グローバル変数リストのツリーを作成
1036 hVarTree_Global=CreateWindowEx(WS_EX_CLIENTEDGE,WC_TREEVIEW,"",
1037 WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_SHOWSELALWAYS,
1038 0,0,0,0,
1039 hTab,0,hInst,0);
1040
1041 //ローカル変数リストのツリーを作成
1042 hVarTree_Local=CreateWindowEx(WS_EX_CLIENTEDGE,WC_TREEVIEW,"",
1043 WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_SHOWSELALWAYS,
1044 0,0,0,0,
1045 hTab,0,hInst,0);
1046
1047 //This変数リストのツリーを作成
1048 hVarTree_This=CreateWindowEx(WS_EX_CLIENTEDGE,WC_TREEVIEW,"",
1049 WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_SHOWSELALWAYS,
1050 0,0,0,0,
1051 hTab,0,hInst,0);
1052
1053 ShowWindow(hVarTree_Global,SW_SHOW);
1054
1055
1056 //イメージリスト読み込み、設定
1057 static HIMAGELIST hVariOrderImageList;
1058 hVariOrderImageList=ImageList_Create(16,16,ILC_COLOR4|ILC_MASK,4,0);
1059 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARARRAY)));
1060 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTRUCT)));
1061 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARDATA)));
1062 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTR)));
1063 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARPTRSTRUCT)));
1064 TreeView_SetImageList(hVarTree_Global,hVariOrderImageList,TVSIL_NORMAL);
1065 TreeView_SetImageList(hVarTree_Local,hVariOrderImageList,TVSIL_NORMAL);
1066 TreeView_SetImageList(hVarTree_This,hVariOrderImageList,TVSIL_NORMAL);
1067
1068
1069 /////////////////////////
1070 // ウォッチリスト
1071 /////////////////////////
1072
1073 //コラムの設定
1074 static HWND hListView;
1075 LV_COLUMN ListView_Column;
1076 DWORD dwStyle;
1077
1078 hListView=GetDlgItem(hwnd,IDC_WATCHLIST);
1079 GetClientRect(hListView,&rect);
1080 dwStyle=ListView_GetExtendedListViewStyle(hListView);
1081 dwStyle|=LVS_EX_FULLROWSELECT;
1082 ListView_SetExtendedListViewStyle(hListView,dwStyle);
1083
1084 ListView_Column.mask=LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
1085 ListView_Column.fmt=LVCFMT_LEFT;
1086
1087 extern int width_WatchColumn_Expression;
1088 ListView_Column.cx=width_WatchColumn_Expression;
1089 ListView_Column.pszText="ウォッチ式";
1090 ListView_Column.iSubItem=0;
1091 ListView_InsertColumn(hListView,0,&ListView_Column);
1092
1093 extern int width_WatchColumn_Value;
1094 ListView_Column.cx=width_WatchColumn_Value;
1095 ListView_Column.pszText="値";
1096 ListView_Column.iSubItem=1;
1097 ListView_InsertColumn(hListView,1,&ListView_Column);
1098
1099 //アイテムの設定
1100 ListView_Item.mask=LVIF_TEXT;
1101 ListView_Item.iSubItem=0;
1102 for(i=0;i<pobj_nv->WatchNum;i++){
1103 ListView_Item.pszText=pobj_nv->ppWatchStr[i];
1104 ListView_Item.iItem=i;
1105 ListView_InsertItem(hListView,&ListView_Item);
1106 }
1107 ListView_Item.pszText="...";
1108 ListView_Item.iItem=i;
1109 ListView_InsertItem(hListView,&ListView_Item);
1110
1111
1112 ///////////////////////
1113 // 変数リストの初期化
1114 ///////////////////////
1115 InitVarList((DWORD)lParam);
1116
1117 break;
1118 case WM_NOTIFY:
1119 NMHDR *hdr;
1120 hdr=(NMHDR *)lParam;
1121 if(hdr->hwndFrom==hTab&&hdr->code==TCN_SELCHANGE){
1122 i=TabCtrl_GetCurSel(hTab);
1123
1124 if(i==0){
1125 //グローバル変数を表示
1126 ShowWindow(hVarTree_Global,SW_SHOW);
1127 ShowWindow(hVarTree_Local,SW_HIDE);
1128 ShowWindow(hVarTree_This,SW_HIDE);
1129 }
1130 else if(i==1){
1131 //ローカル変数を表示
1132 ShowWindow(hVarTree_Global,SW_HIDE);
1133 ShowWindow(hVarTree_Local,SW_SHOW);
1134 ShowWindow(hVarTree_This,SW_HIDE);
1135 }
1136 else if(i==2){
1137 //This変数を表示
1138 ShowWindow(hVarTree_Global,SW_HIDE);
1139 ShowWindow(hVarTree_Local,SW_HIDE);
1140 ShowWindow(hVarTree_This,SW_SHOW);
1141 }
1142 }
1143
1144 if(hdr->hwndFrom==hListView){
1145 lvinfo=(LV_DISPINFO *)hdr;
1146 if(hdr->code==NM_DBLCLK){
1147 i2=ListView_GetItemCount(hListView);
1148 for(i=0;i<i2;i++){
1149 if(ListView_GetItemState(hListView,i,LVIS_SELECTED)) break;
1150 }
1151 if(i==i2) break;
1152
1153 ListView_EditLabel(hListView,i);
1154 }
1155
1156 static HWND hEdit;
1157 if(hdr->code==LVN_BEGINLABELEDIT){
1158 hEdit=ListView_GetEditControl(hListView);
1159
1160 GetWindowText(hEdit,temporary,VN_SIZE);
1161 if(lstrcmp(temporary,"...")==0) SetWindowText(hEdit,"");
1162 }
1163 if(hdr->code==LVN_ENDLABELEDIT){
1164 GetWindowText(hEdit,temporary,VN_SIZE);
1165 if(temporary[0]=='\0'){
1166 if(ListView_GetItemCount(hListView)-1==lvinfo->item.iItem) break;
1167
1168 //空白入力の場合はそのアイテムを削除する
1169 ListView_DeleteItem(hListView,lvinfo->item.iItem);
1170 break;
1171 }
1172 ListView_SetItemText(hListView,lvinfo->item.iItem,0,temporary);
1173
1174 //演算結果を表示
1175 SetCalcToWatchList(hListView,lvinfo->item.iItem,temporary);
1176
1177 if(lvinfo->item.iItem==ListView_GetItemCount(hListView)-1){
1178 //リストアイテムを追加
1179 ListView_Item.mask=LVIF_TEXT;
1180 ListView_Item.pszText="...";
1181 ListView_Item.iItem=lvinfo->item.iItem+1;
1182 ListView_Item.iSubItem=0;
1183 ListView_InsertItem(hListView,&ListView_Item);
1184 }
1185 }
1186
1187 if(hdr->code==LVN_KEYDOWN){
1188 LV_KEYDOWN *plvKeydown;
1189 plvKeydown=(LV_KEYDOWN *)hdr;
1190 if(plvKeydown->wVKey==VK_DELETE){
1191 i2=ListView_GetItemCount(hListView);
1192 for(i=i2-2;i>=0;i--){
1193 if(ListView_GetItemState(hListView,i,LVIS_SELECTED)){
1194 ListView_DeleteItem(hListView,i);
1195 i3=i;
1196 }
1197 }
1198
1199 ListView_SetItemState(hListView,i3,LVIS_SELECTED,LVIS_SELECTED);
1200 }
1201 }
1202 }
1203 break;
1204
1205 case WM_SIZE:
1206 //変数リストの位置
1207 int width_VarList;
1208 width_VarList=
1209 (int)((double)(LOWORD(lParam)-pos_VarList.x)*width_ratio_VarList);
1210
1211 MoveWindow(hTab,
1212 pos_VarList.x,
1213 pos_VarList.y,
1214 width_VarList,
1215 HIWORD(lParam)-pos_VarList.y,
1216 1);
1217
1218 GetClientRect(hTab,&rect);
1219 TabCtrl_AdjustRect(hTab,FALSE,&rect);
1220 rect.left-=2;
1221 rect.right++;
1222 rect.bottom++;
1223
1224 MoveWindow(hVarTree_Global,
1225 rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,1);
1226 MoveWindow(hVarTree_Local,
1227 rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,1);
1228 MoveWindow(hVarTree_This,
1229 rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,1);
1230
1231 pos_WatchList.x=pos_VarList.x+width_VarList+LEVER_THICK;
1232 pos_WatchList.y=0;
1233
1234 //ウォッチリストの位置
1235 MoveWindow(GetDlgItem(hwnd,IDC_WATCHLIST),
1236 pos_WatchList.x,
1237 pos_WatchList.y,
1238 LOWORD(lParam)-pos_WatchList.x,
1239 HIWORD(lParam)-pos_WatchList.y,
1240 1);
1241
1242 return 1;
1243
1244 case WM_VARLIST_CLOSE:
1245 DestroyWindow(hwnd);
1246 return 1;
1247 case WM_DESTROY:
1248 ImageList_Destroy(hVariOrderImageList);
1249
1250
1251 //////////////////////////////////////////////////////////////
1252 // ウォッチリストの以前の内容を破棄し、新しい内容に書き換える
1253 //////////////////////////////////////////////////////////////
1254
1255 for(i=0;i<pobj_nv->WatchNum;i++){
1256 HeapDefaultFree(pobj_nv->ppWatchStr[i]);
1257 }
1258 HeapDefaultFree(pobj_nv->ppWatchStr);
1259
1260 pobj_nv->WatchNum=ListView_GetItemCount(hListView)-1;
1261 pobj_nv->ppWatchStr=(char **)HeapAlloc(hHeap,0,pobj_nv->WatchNum*sizeof(char *)+1);
1262 for(i=0;i<pobj_nv->WatchNum;i++){
1263 ListView_GetItemText(hListView,i,0,temporary,VN_SIZE);
1264 pobj_nv->ppWatchStr[i]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
1265 lstrcpy(pobj_nv->ppWatchStr[i],temporary);
1266 }
1267
1268
1269 //////////////////////////////
1270 // デバッグダイアログを破棄
1271 //////////////////////////////
1272
1273 hDebugWnd=0;
1274
1275 if( program.IsClipCompileView() ){
1276 extern HWND hOwnerEditor;
1277 SendMessage(hOwnerEditor,WM_DESTROYDEBUGGERVIEW,0,0);
1278 }
1279
1280 return 1;
1281
1282
1283
1284 ///////////////////////
1285 // デバッグコマンド
1286 ///////////////////////
1287
1288 case WM_DEBUG_CONTINUE:
1289 DestroyWindow(hwnd);
1290 return 1;
1291 case WM_STEP_IN:
1292 Debugger_StepIn();
1293 return 1;
1294 case WM_STEP_OVER:
1295 Debugger_StepOver();
1296 return 1;
1297 case WM_STEP_CURSOR:
1298 Debugger_StepCursor();
1299 return 1;
1300 }
1301 return 0;
1302}
1303
1304
1305
1306
1307//////////////////////////////////
1308// ポップアップ表示の変数リスト
1309//////////////////////////////////
1310
1311BOOL CALLBACK DlgVarList(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
1312 extern HANDLE hHeap;
1313 extern HINSTANCE hInst;
1314 extern DWORD dwStepRun;
1315 RECT rect;
1316 POINT pos;
1317 SIZE size;
1318
1319 switch(message){
1320 case WM_INITDIALOG:
1321 extern HWND hDebugWnd;
1322 hDebugWnd=hwnd;
1323
1324 pos.x=pobj_nv->VarDlgRect.left;
1325 pos.y=pobj_nv->VarDlgRect.top;
1326 size.cx=pobj_nv->VarDlgRect.right-pobj_nv->VarDlgRect.left;
1327 size.cy=pobj_nv->VarDlgRect.bottom-pobj_nv->VarDlgRect.top;
1328 MoveWindow(hwnd,pos.x,pos.y,size.cx,size.cy,1);
1329
1330 extern WNDPROC OldThreadComboProc;
1331 OldThreadComboProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hwnd,IDC_THREADCOMBO),GWLP_WNDPROC);
1332 SetWindowLongPtr(GetDlgItem(hwnd,IDC_THREADCOMBO),GWLP_WNDPROC,(LONG_PTR)ThreadComboProc);
1333
1334 extern WNDPROC OldProcComboProc;
1335 OldProcComboProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hwnd,IDC_PROCCOMBO),GWLP_WNDPROC);
1336 SetWindowLongPtr(GetDlgItem(hwnd,IDC_PROCCOMBO),GWLP_WNDPROC,(LONG_PTR)ProcComboProc);
1337
1338 //イメージリスト読み込み、設定
1339 static HIMAGELIST hVariOrderImageList;
1340 hVariOrderImageList=ImageList_Create(16,16,ILC_COLOR4|ILC_MASK,4,0);
1341 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARARRAY)));
1342 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTRUCT)));
1343 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARDATA)));
1344 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTR)));
1345 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARPTRSTRUCT)));
1346 TreeView_SetImageList(GetDlgItem(hwnd,IDC_VARTREE),hVariOrderImageList,TVSIL_NORMAL);
1347
1348 InitVarList((DWORD)lParam);
1349 break;
1350 case WM_COMMAND:
1351 switch(LOWORD(wParam)){
1352 case IDCANCEL:
1353 DestroyWindow(hwnd);
1354 return 1;
1355 case IDC_STEPIN:
1356 dwStepRun=1;
1357 return 1;
1358 case IDC_STEPOVER:
1359 dwStepRun=2;
1360 return 1;
1361 }
1362 break;
1363 case WM_SIZE:
1364 GetWindowRect(GetDlgItem(hwnd,IDC_VARTREE),&rect);
1365 pos.x=rect.left;
1366 pos.y=rect.top;
1367 ScreenToClient(hwnd,&pos);
1368 MoveWindow(GetDlgItem(hwnd,IDC_VARTREE),0,pos.y,LOWORD(lParam),HIWORD(lParam)-pos.y,TRUE);
1369 SetWindowPos(GetDlgItem(hwnd,IDCANCEL),0,LOWORD(lParam)-91,9,0,0,SWP_NOSIZE);
1370 return 1;
1371 case WM_VARLIST_CLOSE:
1372 DestroyWindow(hwnd);
1373 return 1;
1374 case WM_DESTROY:
1375 ImageList_Destroy(hVariOrderImageList);
1376
1377 GetWindowRect(hwnd,&pobj_nv->VarDlgRect);
1378
1379 hDebugWnd=0;
1380
1381 return 1;
1382 }
1383 return 0;
1384}
Note: See TracBrowser for help on using the repository browser.