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

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

クラス継承を行う際、dynamicMembersの中身をコピーする方式をやめ、基底クラスのものを参照するように修正した。

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