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

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

[585][586]をリバース。NativeCodeクラスとMetaクラスは依存関係があるので分離しない方針とする。

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
10using namespace ActiveBasic::Compiler;
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( Member *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( LexicalAnalyzer::FullNameToSymbol( "_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( Member *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.StartProcedureCompile( pUserProc );
781 }
782 }
783
784
785 ////////////////////////
786 // 変数リストを再表示
787 ////////////////////////
788
789 //処理時間を短くするため、一時的に非表示にする
790 LockWindowUpdate(hDebugWnd);
791 ShowWindow(GetParent(hVarTree_Global),SW_HIDE);
792 ShowWindow(GetDlgItem(hDebugWnd,IDC_WATCHLIST),SW_HIDE);
793
794 //リフレッシュ
795 RefreshLocalVar();
796 RefreshGlobalVar();
797 RefreshWatchList();
798
799 LockWindowUpdate(NULL);
800 ShowWindow(GetParent(hVarTree_Global),SW_SHOW);
801 ShowWindow(GetDlgItem(hDebugWnd,IDC_WATCHLIST),SW_SHOW);
802}
803
804
805
806
807//////////////////////////////////////
808// エディタに埋め込み表示のデバッガ
809//////////////////////////////////////
810
811BOOL CALLBACK DebuggerButtonsProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
812 extern HINSTANCE hInst;
813 extern DWORD dwStepRun;
814
815 //デバッガ用ツールバー
816#define BMPNUM_DEBUGGERTOOLBAR 3
817#define BTNNUM_DEBUGGERTOOLBAR 4
818 TBBUTTON DebuggerToolBar[]={
819 {0,IDC_DEBUG_START,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
820 {0,0,TBSTATE_ENABLED,TBSTYLE_SEP,0,0},
821 {1,IDC_DEBUG_STEPOVER,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
822 {2,IDC_DEBUG_STEPIN,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
823 };
824 TOOLTIPTEXT *pTipText;
825
826 static HIMAGELIST hImageList,hImageList_Disabled;
827
828 switch(message){
829 case WM_INITDIALOG:
830 //ツールバーを生成
831 extern HWND hDebuggerToolbar;
832 hDebuggerToolbar=CreateToolbarEx(hwnd,WS_CHILD|WS_VISIBLE|CCS_NODIVIDER|TBSTYLE_FLAT|TBSTYLE_TOOLTIPS|WS_CLIPSIBLINGS,
833 NULL,
834 0,0,0,
835 DebuggerToolBar,
836 BTNNUM_DEBUGGERTOOLBAR, /*アイテムの個数*/
837 0,0,16,15,sizeof(TBBUTTON));
838
839 hImageList = ImageList_LoadImage(hInst, MAKEINTRESOURCE(IDR_DEBUGGERTOOLBAR),
840 16, 0, RGB(192,192,192),IMAGE_BITMAP, LR_CREATEDIBSECTION);
841 SendMessage(hDebuggerToolbar, TB_SETIMAGELIST, 0, (LPARAM)hImageList);
842 hImageList_Disabled = ImageList_LoadImage(hInst, MAKEINTRESOURCE(IDR_DEBUGGERTOOLBAR_DISABLED),
843 16, 0, RGB(192,192,192),IMAGE_BITMAP, LR_CREATEDIBSECTION);
844 SendMessage(hDebuggerToolbar, TB_SETDISABLEDIMAGELIST, 0, (LPARAM)hImageList_Disabled);
845
846 break;
847 case WM_COMMAND:
848 switch(LOWORD(wParam)){
849 case IDC_DEBUG_START:
850 DestroyWindow(GetParent(hwnd));
851 return 1;
852 case IDC_DEBUG_STEPIN:
853 dwStepRun=1;
854 return 1;
855 case IDC_DEBUG_STEPOVER:
856 dwStepRun=2;
857 return 1;
858 }
859 break;
860 case WM_NOTIFY:
861 pTipText=(TOOLTIPTEXT *)lParam;
862 if(pTipText->hdr.code==TTN_NEEDTEXT){
863 //ツールチップを表示
864 switch(pTipText->hdr.idFrom){
865 case IDC_DEBUG_START:
866 pTipText->lpszText="実行";
867 break;
868 case IDC_DEBUG_STEPOVER:
869 pTipText->lpszText="ステップ アウト";
870 break;
871 case IDC_DEBUG_STEPIN:
872 pTipText->lpszText="ステップ イン";
873 break;
874 }
875 }
876 break;
877 case WM_SIZE:
878 MoveWindow(hDebuggerToolbar,0,0,LOWORD(lParam),HIWORD(lParam),1);
879 return 1;
880
881 case WM_DESTROY:
882 ImageList_Destroy(hImageList);
883 ImageList_Destroy(hImageList_Disabled);
884 return 1;
885 }
886 return 0;
887}
888
889WNDPROC OldTabProc;
890LRESULT CALLBACK TabProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
891 extern HINSTANCE hInst;
892
893 static HMENU hDummyMenu,hMenu=0;
894
895 switch(message){
896 case WM_CONTEXTMENU:
897 if(hMenu==0){
898 hDummyMenu=LoadMenu(hInst,MAKEINTRESOURCE(IDR_DEBUGGER_VARLIST_MENU));
899 hMenu=GetSubMenu(hDummyMenu,0);
900 }
901
902 MENUITEMINFO mi;
903 mi.cbSize=sizeof(MENUITEMINFO);
904 mi.fMask=MIIM_STATE;
905 mi.fState=MFS_CHECKED;
906
907 if(pobj_nv->bShow_DefaultSystem_Var)
908 SetMenuItemInfo(hMenu,IDM_SHOW_DEFAULTSYSTEM_VAR,0,&mi);
909 if(pobj_nv->bShow_Rad_Var)
910 SetMenuItemInfo(hMenu,IDM_SHOW_RAD_VAR,0,&mi);
911 if(pobj_nv->bShow_GUID_Var)
912 SetMenuItemInfo(hMenu,IDM_SHOW_GUID_VAR,0,&mi);
913
914 TrackPopupMenu(hMenu,TPM_LEFTALIGN,LOWORD(lParam),HIWORD(lParam),0,hwnd,0);
915
916 break;
917 case WM_COMMAND:
918 mi.cbSize=sizeof(MENUITEMINFO);
919 mi.fMask=MIIM_STATE;
920 switch(LOWORD(wParam)){
921 case IDM_SHOW_DEFAULTSYSTEM_VAR:
922 if(pobj_nv->bShow_DefaultSystem_Var){
923 pobj_nv->bShow_DefaultSystem_Var=0;
924 mi.fState=MFS_UNCHECKED;
925 }
926 else{
927 pobj_nv->bShow_DefaultSystem_Var=1;
928 mi.fState=MFS_CHECKED;
929 }
930 SetMenuItemInfo(hMenu,IDM_SHOW_DEFAULTSYSTEM_VAR,0,&mi);
931 RefreshGlobalVar_with_WindowLock();
932 break;
933 case IDM_SHOW_RAD_VAR:
934 if(pobj_nv->bShow_Rad_Var){
935 pobj_nv->bShow_Rad_Var=0;
936 mi.fState=MFS_UNCHECKED;
937 }
938 else{
939 pobj_nv->bShow_Rad_Var=1;
940 mi.fState=MFS_CHECKED;
941 }
942 SetMenuItemInfo(hMenu,IDM_SHOW_RAD_VAR,0,&mi);
943 RefreshGlobalVar_with_WindowLock();
944 break;
945 case IDM_SHOW_GUID_VAR:
946 if(pobj_nv->bShow_GUID_Var){
947 pobj_nv->bShow_GUID_Var=0;
948 mi.fState=MFS_UNCHECKED;
949 }
950 else{
951 pobj_nv->bShow_GUID_Var=1;
952 mi.fState=MFS_CHECKED;
953 }
954 SetMenuItemInfo(hMenu,IDM_SHOW_GUID_VAR,0,&mi);
955 RefreshGlobalVar_with_WindowLock();
956 break;
957 }
958 break;
959 case WM_DESTROY:
960 DestroyMenu(hMenu);
961 hMenu=0;
962 break;
963 }
964 return CallWindowProc(OldTabProc,hwnd,message,wParam,lParam);
965}
966
967BOOL CALLBACK DlgDebugger(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
968 extern HANDLE hHeap;
969 extern HINSTANCE hInst;
970 extern DWORD dwStepRun;
971 extern double width_ratio_VarList;
972 RECT rect;
973 int i,i2,i3;
974 char temporary[VN_SIZE];
975 LV_DISPINFO *lvinfo;
976 LVITEM ListView_Item;
977
978 static POINT pos_VarList;
979 static POINT pos_WatchList;
980
981 switch(message){
982 case WM_INITDIALOG:
983 extern HWND hDebugWnd;
984 hDebugWnd=hwnd;
985
986 //変数リストの初期位置を取得
987 GetWindowRect(GetDlgItem(hwnd,IDC_VARPOS),&rect);
988 pos_VarList.x=rect.left;
989 pos_VarList.y=rect.top;
990 ScreenToClient(hwnd,&pos_VarList);
991
992 //ウォッチリストの初期位置を取得
993 pos_WatchList.x=pos_VarList.x+(rect.right-rect.left)+LEVER_THICK;
994 pos_WatchList.y=0;
995
996 //ツールバーのベースウィンドウを生成
997 static HWND hBase_ToolBar;
998 hBase_ToolBar=CreateDialog(hInst,MAKEINTRESOURCE(IDD_DEBUGGER_TOOLBARBASE),hwnd,(DLGPROC)DebuggerButtonsProc);
999 MoveWindow(hBase_ToolBar,50,0,20*BTNNUM_DEBUGGERTOOLBAR,22,1);
1000
1001 extern WNDPROC OldThreadComboProc;
1002 OldThreadComboProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hwnd,IDC_THREADCOMBO),GWLP_WNDPROC);
1003 SetWindowLongPtr(GetDlgItem(hwnd,IDC_THREADCOMBO),GWLP_WNDPROC,(LONG_PTR)ThreadComboProc);
1004
1005 extern WNDPROC OldProcComboProc;
1006 OldProcComboProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hwnd,IDC_PROCCOMBO),GWLP_WNDPROC);
1007 SetWindowLongPtr(GetDlgItem(hwnd,IDC_PROCCOMBO),GWLP_WNDPROC,(LONG_PTR)ProcComboProc);
1008
1009
1010 ///////////////////////////
1011 // タブコントロールを生成
1012 ///////////////////////////
1013
1014 static HWND hTab;
1015 HFONT hFont;
1016 hFont=(HFONT)SendMessage(hwnd,WM_GETFONT,0,0);
1017 hTab=CreateWindow(WC_TABCONTROL,NULL,
1018 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE,
1019 0,0,0,0,hwnd,0,hInst,0);
1020 SendMessage(hTab,WM_SETFONT,(WPARAM)hFont,0);
1021 OldTabProc=(WNDPROC)GetWindowLongPtr(hTab,GWLP_WNDPROC);
1022 SetWindowLongPtr(hTab,GWLP_WNDPROC,(LONG_PTR)TabProc);
1023
1024 //タブを設定
1025 TC_ITEM tcItem;
1026 tcItem.mask=TCIF_TEXT;
1027 tcItem.pszText="グローバル";
1028 SendMessage(hTab,TCM_INSERTITEM,0,(LPARAM)&tcItem);
1029 tcItem.mask=TCIF_TEXT;
1030 tcItem.pszText="ローカル";
1031 SendMessage(hTab,TCM_INSERTITEM,1,(LPARAM)&tcItem);
1032 tcItem.mask=TCIF_TEXT;
1033 tcItem.pszText="This";
1034 SendMessage(hTab,TCM_INSERTITEM,2,(LPARAM)&tcItem);
1035
1036 //グローバル変数リストのツリーを作成
1037 hVarTree_Global=CreateWindowEx(WS_EX_CLIENTEDGE,WC_TREEVIEW,"",
1038 WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_SHOWSELALWAYS,
1039 0,0,0,0,
1040 hTab,0,hInst,0);
1041
1042 //ローカル変数リストのツリーを作成
1043 hVarTree_Local=CreateWindowEx(WS_EX_CLIENTEDGE,WC_TREEVIEW,"",
1044 WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_SHOWSELALWAYS,
1045 0,0,0,0,
1046 hTab,0,hInst,0);
1047
1048 //This変数リストのツリーを作成
1049 hVarTree_This=CreateWindowEx(WS_EX_CLIENTEDGE,WC_TREEVIEW,"",
1050 WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_SHOWSELALWAYS,
1051 0,0,0,0,
1052 hTab,0,hInst,0);
1053
1054 ShowWindow(hVarTree_Global,SW_SHOW);
1055
1056
1057 //イメージリスト読み込み、設定
1058 static HIMAGELIST hVariOrderImageList;
1059 hVariOrderImageList=ImageList_Create(16,16,ILC_COLOR4|ILC_MASK,4,0);
1060 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARARRAY)));
1061 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTRUCT)));
1062 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARDATA)));
1063 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTR)));
1064 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARPTRSTRUCT)));
1065 TreeView_SetImageList(hVarTree_Global,hVariOrderImageList,TVSIL_NORMAL);
1066 TreeView_SetImageList(hVarTree_Local,hVariOrderImageList,TVSIL_NORMAL);
1067 TreeView_SetImageList(hVarTree_This,hVariOrderImageList,TVSIL_NORMAL);
1068
1069
1070 /////////////////////////
1071 // ウォッチリスト
1072 /////////////////////////
1073
1074 //コラムの設定
1075 static HWND hListView;
1076 LV_COLUMN ListView_Column;
1077 DWORD dwStyle;
1078
1079 hListView=GetDlgItem(hwnd,IDC_WATCHLIST);
1080 GetClientRect(hListView,&rect);
1081 dwStyle=ListView_GetExtendedListViewStyle(hListView);
1082 dwStyle|=LVS_EX_FULLROWSELECT;
1083 ListView_SetExtendedListViewStyle(hListView,dwStyle);
1084
1085 ListView_Column.mask=LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
1086 ListView_Column.fmt=LVCFMT_LEFT;
1087
1088 extern int width_WatchColumn_Expression;
1089 ListView_Column.cx=width_WatchColumn_Expression;
1090 ListView_Column.pszText="ウォッチ式";
1091 ListView_Column.iSubItem=0;
1092 ListView_InsertColumn(hListView,0,&ListView_Column);
1093
1094 extern int width_WatchColumn_Value;
1095 ListView_Column.cx=width_WatchColumn_Value;
1096 ListView_Column.pszText="値";
1097 ListView_Column.iSubItem=1;
1098 ListView_InsertColumn(hListView,1,&ListView_Column);
1099
1100 //アイテムの設定
1101 ListView_Item.mask=LVIF_TEXT;
1102 ListView_Item.iSubItem=0;
1103 for(i=0;i<pobj_nv->WatchNum;i++){
1104 ListView_Item.pszText=pobj_nv->ppWatchStr[i];
1105 ListView_Item.iItem=i;
1106 ListView_InsertItem(hListView,&ListView_Item);
1107 }
1108 ListView_Item.pszText="...";
1109 ListView_Item.iItem=i;
1110 ListView_InsertItem(hListView,&ListView_Item);
1111
1112
1113 ///////////////////////
1114 // 変数リストの初期化
1115 ///////////////////////
1116 InitVarList((DWORD)lParam);
1117
1118 break;
1119 case WM_NOTIFY:
1120 NMHDR *hdr;
1121 hdr=(NMHDR *)lParam;
1122 if(hdr->hwndFrom==hTab&&hdr->code==TCN_SELCHANGE){
1123 i=TabCtrl_GetCurSel(hTab);
1124
1125 if(i==0){
1126 //グローバル変数を表示
1127 ShowWindow(hVarTree_Global,SW_SHOW);
1128 ShowWindow(hVarTree_Local,SW_HIDE);
1129 ShowWindow(hVarTree_This,SW_HIDE);
1130 }
1131 else if(i==1){
1132 //ローカル変数を表示
1133 ShowWindow(hVarTree_Global,SW_HIDE);
1134 ShowWindow(hVarTree_Local,SW_SHOW);
1135 ShowWindow(hVarTree_This,SW_HIDE);
1136 }
1137 else if(i==2){
1138 //This変数を表示
1139 ShowWindow(hVarTree_Global,SW_HIDE);
1140 ShowWindow(hVarTree_Local,SW_HIDE);
1141 ShowWindow(hVarTree_This,SW_SHOW);
1142 }
1143 }
1144
1145 if(hdr->hwndFrom==hListView){
1146 lvinfo=(LV_DISPINFO *)hdr;
1147 if(hdr->code==NM_DBLCLK){
1148 i2=ListView_GetItemCount(hListView);
1149 for(i=0;i<i2;i++){
1150 if(ListView_GetItemState(hListView,i,LVIS_SELECTED)) break;
1151 }
1152 if(i==i2) break;
1153
1154 ListView_EditLabel(hListView,i);
1155 }
1156
1157 static HWND hEdit;
1158 if(hdr->code==LVN_BEGINLABELEDIT){
1159 hEdit=ListView_GetEditControl(hListView);
1160
1161 GetWindowText(hEdit,temporary,VN_SIZE);
1162 if(lstrcmp(temporary,"...")==0) SetWindowText(hEdit,"");
1163 }
1164 if(hdr->code==LVN_ENDLABELEDIT){
1165 GetWindowText(hEdit,temporary,VN_SIZE);
1166 if(temporary[0]=='\0'){
1167 if(ListView_GetItemCount(hListView)-1==lvinfo->item.iItem) break;
1168
1169 //空白入力の場合はそのアイテムを削除する
1170 ListView_DeleteItem(hListView,lvinfo->item.iItem);
1171 break;
1172 }
1173 ListView_SetItemText(hListView,lvinfo->item.iItem,0,temporary);
1174
1175 //演算結果を表示
1176 SetCalcToWatchList(hListView,lvinfo->item.iItem,temporary);
1177
1178 if(lvinfo->item.iItem==ListView_GetItemCount(hListView)-1){
1179 //リストアイテムを追加
1180 ListView_Item.mask=LVIF_TEXT;
1181 ListView_Item.pszText="...";
1182 ListView_Item.iItem=lvinfo->item.iItem+1;
1183 ListView_Item.iSubItem=0;
1184 ListView_InsertItem(hListView,&ListView_Item);
1185 }
1186 }
1187
1188 if(hdr->code==LVN_KEYDOWN){
1189 LV_KEYDOWN *plvKeydown;
1190 plvKeydown=(LV_KEYDOWN *)hdr;
1191 if(plvKeydown->wVKey==VK_DELETE){
1192 i2=ListView_GetItemCount(hListView);
1193 for(i=i2-2;i>=0;i--){
1194 if(ListView_GetItemState(hListView,i,LVIS_SELECTED)){
1195 ListView_DeleteItem(hListView,i);
1196 i3=i;
1197 }
1198 }
1199
1200 ListView_SetItemState(hListView,i3,LVIS_SELECTED,LVIS_SELECTED);
1201 }
1202 }
1203 }
1204 break;
1205
1206 case WM_SIZE:
1207 //変数リストの位置
1208 int width_VarList;
1209 width_VarList=
1210 (int)((double)(LOWORD(lParam)-pos_VarList.x)*width_ratio_VarList);
1211
1212 MoveWindow(hTab,
1213 pos_VarList.x,
1214 pos_VarList.y,
1215 width_VarList,
1216 HIWORD(lParam)-pos_VarList.y,
1217 1);
1218
1219 GetClientRect(hTab,&rect);
1220 TabCtrl_AdjustRect(hTab,FALSE,&rect);
1221 rect.left-=2;
1222 rect.right++;
1223 rect.bottom++;
1224
1225 MoveWindow(hVarTree_Global,
1226 rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,1);
1227 MoveWindow(hVarTree_Local,
1228 rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,1);
1229 MoveWindow(hVarTree_This,
1230 rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,1);
1231
1232 pos_WatchList.x=pos_VarList.x+width_VarList+LEVER_THICK;
1233 pos_WatchList.y=0;
1234
1235 //ウォッチリストの位置
1236 MoveWindow(GetDlgItem(hwnd,IDC_WATCHLIST),
1237 pos_WatchList.x,
1238 pos_WatchList.y,
1239 LOWORD(lParam)-pos_WatchList.x,
1240 HIWORD(lParam)-pos_WatchList.y,
1241 1);
1242
1243 return 1;
1244
1245 case WM_VARLIST_CLOSE:
1246 DestroyWindow(hwnd);
1247 return 1;
1248 case WM_DESTROY:
1249 ImageList_Destroy(hVariOrderImageList);
1250
1251
1252 //////////////////////////////////////////////////////////////
1253 // ウォッチリストの以前の内容を破棄し、新しい内容に書き換える
1254 //////////////////////////////////////////////////////////////
1255
1256 for(i=0;i<pobj_nv->WatchNum;i++){
1257 HeapDefaultFree(pobj_nv->ppWatchStr[i]);
1258 }
1259 HeapDefaultFree(pobj_nv->ppWatchStr);
1260
1261 pobj_nv->WatchNum=ListView_GetItemCount(hListView)-1;
1262 pobj_nv->ppWatchStr=(char **)HeapAlloc(hHeap,0,pobj_nv->WatchNum*sizeof(char *)+1);
1263 for(i=0;i<pobj_nv->WatchNum;i++){
1264 ListView_GetItemText(hListView,i,0,temporary,VN_SIZE);
1265 pobj_nv->ppWatchStr[i]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
1266 lstrcpy(pobj_nv->ppWatchStr[i],temporary);
1267 }
1268
1269
1270 //////////////////////////////
1271 // デバッグダイアログを破棄
1272 //////////////////////////////
1273
1274 hDebugWnd=0;
1275
1276 if( program.IsClipCompileView() ){
1277 extern HWND hOwnerEditor;
1278 SendMessage(hOwnerEditor,WM_DESTROYDEBUGGERVIEW,0,0);
1279 }
1280
1281 return 1;
1282
1283
1284
1285 ///////////////////////
1286 // デバッグコマンド
1287 ///////////////////////
1288
1289 case WM_DEBUG_CONTINUE:
1290 DestroyWindow(hwnd);
1291 return 1;
1292 case WM_STEP_IN:
1293 Debugger_StepIn();
1294 return 1;
1295 case WM_STEP_OVER:
1296 Debugger_StepOver();
1297 return 1;
1298 case WM_STEP_CURSOR:
1299 Debugger_StepCursor();
1300 return 1;
1301 }
1302 return 0;
1303}
1304
1305
1306
1307
1308//////////////////////////////////
1309// ポップアップ表示の変数リスト
1310//////////////////////////////////
1311
1312BOOL CALLBACK DlgVarList(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
1313 extern HANDLE hHeap;
1314 extern HINSTANCE hInst;
1315 extern DWORD dwStepRun;
1316 RECT rect;
1317 POINT pos;
1318 SIZE size;
1319
1320 switch(message){
1321 case WM_INITDIALOG:
1322 extern HWND hDebugWnd;
1323 hDebugWnd=hwnd;
1324
1325 pos.x=pobj_nv->VarDlgRect.left;
1326 pos.y=pobj_nv->VarDlgRect.top;
1327 size.cx=pobj_nv->VarDlgRect.right-pobj_nv->VarDlgRect.left;
1328 size.cy=pobj_nv->VarDlgRect.bottom-pobj_nv->VarDlgRect.top;
1329 MoveWindow(hwnd,pos.x,pos.y,size.cx,size.cy,1);
1330
1331 extern WNDPROC OldThreadComboProc;
1332 OldThreadComboProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hwnd,IDC_THREADCOMBO),GWLP_WNDPROC);
1333 SetWindowLongPtr(GetDlgItem(hwnd,IDC_THREADCOMBO),GWLP_WNDPROC,(LONG_PTR)ThreadComboProc);
1334
1335 extern WNDPROC OldProcComboProc;
1336 OldProcComboProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hwnd,IDC_PROCCOMBO),GWLP_WNDPROC);
1337 SetWindowLongPtr(GetDlgItem(hwnd,IDC_PROCCOMBO),GWLP_WNDPROC,(LONG_PTR)ProcComboProc);
1338
1339 //イメージリスト読み込み、設定
1340 static HIMAGELIST hVariOrderImageList;
1341 hVariOrderImageList=ImageList_Create(16,16,ILC_COLOR4|ILC_MASK,4,0);
1342 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARARRAY)));
1343 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTRUCT)));
1344 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARDATA)));
1345 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTR)));
1346 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARPTRSTRUCT)));
1347 TreeView_SetImageList(GetDlgItem(hwnd,IDC_VARTREE),hVariOrderImageList,TVSIL_NORMAL);
1348
1349 InitVarList((DWORD)lParam);
1350 break;
1351 case WM_COMMAND:
1352 switch(LOWORD(wParam)){
1353 case IDCANCEL:
1354 DestroyWindow(hwnd);
1355 return 1;
1356 case IDC_STEPIN:
1357 dwStepRun=1;
1358 return 1;
1359 case IDC_STEPOVER:
1360 dwStepRun=2;
1361 return 1;
1362 }
1363 break;
1364 case WM_SIZE:
1365 GetWindowRect(GetDlgItem(hwnd,IDC_VARTREE),&rect);
1366 pos.x=rect.left;
1367 pos.y=rect.top;
1368 ScreenToClient(hwnd,&pos);
1369 MoveWindow(GetDlgItem(hwnd,IDC_VARTREE),0,pos.y,LOWORD(lParam),HIWORD(lParam)-pos.y,TRUE);
1370 SetWindowPos(GetDlgItem(hwnd,IDCANCEL),0,LOWORD(lParam)-91,9,0,0,SWP_NOSIZE);
1371 return 1;
1372 case WM_VARLIST_CLOSE:
1373 DestroyWindow(hwnd);
1374 return 1;
1375 case WM_DESTROY:
1376 ImageList_Destroy(hVariOrderImageList);
1377
1378 GetWindowRect(hwnd,&pobj_nv->VarDlgRect);
1379
1380 hDebugWnd=0;
1381
1382 return 1;
1383 }
1384 return 0;
1385}
Note: See TracBrowser for help on using the repository browser.