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

Last change on this file since 660 was 649, checked in by dai_9181, 16 years ago

不要なhHeap宣言を除去

File size: 40.7 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].GetSourceCodePosition().GetPos();
623 pobj_dti->relationalObjectModuleIndexes[i3]=oldSourceLines[i2].GetSourceCodePosition().GetRelationalObjectModuleIndex();
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->relationalObjectModuleIndexes[i2]=pobj_dti->relationalObjectModuleIndexes[i2+1];
634 }
635 i3--;
636 continue;
637 }
638 }
639
640 std::string dummyStr;
641 extern BasicSources sourcesLinkRelationalObjectModule;
642 if(!sourcesLinkRelationalObjectModule[pobj_dti->relationalObjectModuleIndexes[pobj_dti->iProcLevel]].GetLineInfo( pobj_dti->lpdwCp[pobj_dti->iProcLevel], i2, dummyStr )){
643 extern HWND hMainDlg;
644 //"デバッグ情報の取得に失敗"
645 MessageBox(hMainDlg,STRING_DEBUG_FAILED,"ActiveBasic error",MB_OK);
646 return 0;
647 }
648 ShowErrorLine(i2,dummyStr.c_str());
649
650 //プロシージャ コンボボックス
651 SendMessage(hProcCombo,CB_RESETCONTENT,0,0);
652 for(i2=pobj_dti->iProcLevel;i2>=0;i2--){
653
654 UserProc *pUserProc = NULL;
655 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset();
656 while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() )
657 {
658 pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();
659
660 if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2] &&
661 pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->GetEndOpAddress()))
662 {
663 lstrcpy(temporary,pUserProc->GetName().c_str());
664 break;
665 }
666 }
667 if(!pUserProc){
668 if(i2==0){
669 lstrcpy(temporary,"Global");
670 pobj_dti->lplpSpBase[i2]=0;
671 }
672 else lstrcpy(temporary,"error");
673 }
674 SendMessage(hProcCombo,CB_ADDSTRING,0,(LPARAM)temporary);
675 }
676 SendMessage(hProcCombo,CB_SETCURSEL,0,0);
677
678 return pobj_dti->iProcLevel;
679}
680
681//IDC_THREADCOMBOプロシージャ
682LRESULT CALLBACK ThreadComboProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
683 extern WNDPROC OldThreadComboProc;
684 int i2;
685 DWORD dwThreadID;
686 char temporary[255];
687
688 switch(message){
689 case WM_COMMAND:
690 if(HIWORD(wParam)==CBN_SELCHANGE){
691 SendMessage(hwnd,CB_GETLBTEXT,SendMessage(hwnd,CB_GETCURSEL,0,0),(LPARAM)temporary);
692 sscanf(temporary+2,"%X",&dwThreadID);
693
694 extern DWORD _DebugSys_dwThreadID[256];
695 i2=0;
696 while(_DebugSys_dwThreadID[i2]!=dwThreadID) i2++;
697
698 //次回のステップ実行対象を指定
699 extern int NextStepThreadNum;
700 NextStepThreadNum=i2;
701
702 //スレッド情報をリフレッシュ
703 pobj_dti->Reflesh(i2);
704
705 SetDebugProcCombo(GetDlgItem(GetParent(hwnd),IDC_PROCCOMBO));
706
707 SendDlgItemMessage(GetParent(hwnd),IDC_PROCCOMBO,WM_COMMAND,MAKELONG(0,CBN_SELCHANGE),0);
708 }
709 break;
710 }
711 return CallWindowProc(OldThreadComboProc,hwnd,message,wParam,lParam);
712}
713//IDC_PROCCOMBOプロシージャ
714LRESULT CALLBACK ProcComboProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
715 extern WNDPROC OldProcComboProc;
716 int i2,i3;
717
718 switch(message){
719 case WM_COMMAND:
720 if(HIWORD(wParam)==CBN_SELCHANGE){
721 i2=(int)SendMessage(hwnd,CB_GETCURSEL,0,0);
722
723 std::string dummyStr;
724 extern BasicSources sourcesLinkRelationalObjectModule;
725 sourcesLinkRelationalObjectModule[pobj_dti->relationalObjectModuleIndexes[pobj_dti->iProcLevel]].GetLineInfo( pobj_dti->lpdwCp[pobj_dti->iProcLevel-i2], i3, dummyStr );
726 ShowErrorLine(i3,dummyStr.c_str());
727
728 RefreshLocalVar_with_WindowLock();
729 }
730 break;
731 }
732 return CallWindowProc(OldProcComboProc,hwnd,message,wParam,lParam);
733}
734void InitVarList(DWORD dwThreadId){
735 extern HWND hDebugWnd;
736 int i2,i5;
737 char temporary[255];
738
739
740 //スレッド
741 SendDlgItemMessage(hDebugWnd,IDC_THREADCOMBO,CB_RESETCONTENT,0,0);
742 extern DWORD _DebugSys_dwThreadID[256];
743 for(i2=0;i2<256;i2++){
744 if(_DebugSys_dwThreadID[i2]){
745 sprintf(temporary,"&H%08X",_DebugSys_dwThreadID[i2]);
746 SendDlgItemMessage(hDebugWnd,IDC_THREADCOMBO,CB_ADDSTRING,0,(LPARAM)temporary);
747 if(_DebugSys_dwThreadID[i2]==dwThreadId){
748 extern int NextStepThreadNum;
749 NextStepThreadNum=i2;
750 }
751 }
752 }
753 sprintf(temporary,"&H%08X",dwThreadId);
754 i5=(int)SendDlgItemMessage(hDebugWnd,IDC_THREADCOMBO,CB_FINDSTRING,0,(LPARAM)temporary);
755 SendDlgItemMessage(hDebugWnd,IDC_THREADCOMBO,CB_SETCURSEL,i5,0);
756
757 i2=SetDebugProcCombo(GetDlgItem(hDebugWnd,IDC_PROCCOMBO));
758
759
760 ///////////////////////////////////////////////
761 // 実行中のプロシージャのローカル変数をセット
762 ///////////////////////////////////////////////
763
764 i2=(int)SendDlgItemMessage(hDebugWnd,IDC_PROCCOMBO,CB_GETCURSEL,0,0);
765 i2=pobj_dti->iProcLevel-i2;
766
767 if(pobj_dti->lplpSpBase[i2]){
768
769 UserProc *pUserProc = NULL;
770 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset();
771 while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() )
772 {
773 pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();
774
775 if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2] &&
776 pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->GetEndOpAddress())){
777 break;
778 }
779 }
780
781 if(pUserProc){
782 compiler.StartProcedureCompile( pUserProc );
783 }
784 }
785
786
787 ////////////////////////
788 // 変数リストを再表示
789 ////////////////////////
790
791 //処理時間を短くするため、一時的に非表示にする
792 LockWindowUpdate(hDebugWnd);
793 ShowWindow(GetParent(hVarTree_Global),SW_HIDE);
794 ShowWindow(GetDlgItem(hDebugWnd,IDC_WATCHLIST),SW_HIDE);
795
796 //リフレッシュ
797 RefreshLocalVar();
798 RefreshGlobalVar();
799 RefreshWatchList();
800
801 LockWindowUpdate(NULL);
802 ShowWindow(GetParent(hVarTree_Global),SW_SHOW);
803 ShowWindow(GetDlgItem(hDebugWnd,IDC_WATCHLIST),SW_SHOW);
804}
805
806
807
808
809//////////////////////////////////////
810// エディタに埋め込み表示のデバッガ
811//////////////////////////////////////
812
813BOOL CALLBACK DebuggerButtonsProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
814 extern HINSTANCE hInst;
815 extern DWORD dwStepRun;
816
817 //デバッガ用ツールバー
818#define BMPNUM_DEBUGGERTOOLBAR 3
819#define BTNNUM_DEBUGGERTOOLBAR 4
820 TBBUTTON DebuggerToolBar[]={
821 {0,IDC_DEBUG_START,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
822 {0,0,TBSTATE_ENABLED,TBSTYLE_SEP,0,0},
823 {1,IDC_DEBUG_STEPOVER,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
824 {2,IDC_DEBUG_STEPIN,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
825 };
826 TOOLTIPTEXT *pTipText;
827
828 static HIMAGELIST hImageList,hImageList_Disabled;
829
830 switch(message){
831 case WM_INITDIALOG:
832 //ツールバーを生成
833 extern HWND hDebuggerToolbar;
834 hDebuggerToolbar=CreateToolbarEx(hwnd,WS_CHILD|WS_VISIBLE|CCS_NODIVIDER|TBSTYLE_FLAT|TBSTYLE_TOOLTIPS|WS_CLIPSIBLINGS,
835 NULL,
836 0,0,0,
837 DebuggerToolBar,
838 BTNNUM_DEBUGGERTOOLBAR, /*アイテムの個数*/
839 0,0,16,15,sizeof(TBBUTTON));
840
841 hImageList = ImageList_LoadImage(hInst, MAKEINTRESOURCE(IDR_DEBUGGERTOOLBAR),
842 16, 0, RGB(192,192,192),IMAGE_BITMAP, LR_CREATEDIBSECTION);
843 SendMessage(hDebuggerToolbar, TB_SETIMAGELIST, 0, (LPARAM)hImageList);
844 hImageList_Disabled = ImageList_LoadImage(hInst, MAKEINTRESOURCE(IDR_DEBUGGERTOOLBAR_DISABLED),
845 16, 0, RGB(192,192,192),IMAGE_BITMAP, LR_CREATEDIBSECTION);
846 SendMessage(hDebuggerToolbar, TB_SETDISABLEDIMAGELIST, 0, (LPARAM)hImageList_Disabled);
847
848 break;
849 case WM_COMMAND:
850 switch(LOWORD(wParam)){
851 case IDC_DEBUG_START:
852 DestroyWindow(GetParent(hwnd));
853 return 1;
854 case IDC_DEBUG_STEPIN:
855 dwStepRun=1;
856 return 1;
857 case IDC_DEBUG_STEPOVER:
858 dwStepRun=2;
859 return 1;
860 }
861 break;
862 case WM_NOTIFY:
863 pTipText=(TOOLTIPTEXT *)lParam;
864 if(pTipText->hdr.code==TTN_NEEDTEXT){
865 //ツールチップを表示
866 switch(pTipText->hdr.idFrom){
867 case IDC_DEBUG_START:
868 pTipText->lpszText="実行";
869 break;
870 case IDC_DEBUG_STEPOVER:
871 pTipText->lpszText="ステップ アウト";
872 break;
873 case IDC_DEBUG_STEPIN:
874 pTipText->lpszText="ステップ イン";
875 break;
876 }
877 }
878 break;
879 case WM_SIZE:
880 MoveWindow(hDebuggerToolbar,0,0,LOWORD(lParam),HIWORD(lParam),1);
881 return 1;
882
883 case WM_DESTROY:
884 ImageList_Destroy(hImageList);
885 ImageList_Destroy(hImageList_Disabled);
886 return 1;
887 }
888 return 0;
889}
890
891WNDPROC OldTabProc;
892LRESULT CALLBACK TabProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
893 extern HINSTANCE hInst;
894
895 static HMENU hDummyMenu,hMenu=0;
896
897 switch(message){
898 case WM_CONTEXTMENU:
899 if(hMenu==0){
900 hDummyMenu=LoadMenu(hInst,MAKEINTRESOURCE(IDR_DEBUGGER_VARLIST_MENU));
901 hMenu=GetSubMenu(hDummyMenu,0);
902 }
903
904 MENUITEMINFO mi;
905 mi.cbSize=sizeof(MENUITEMINFO);
906 mi.fMask=MIIM_STATE;
907 mi.fState=MFS_CHECKED;
908
909 if(pobj_nv->bShow_DefaultSystem_Var)
910 SetMenuItemInfo(hMenu,IDM_SHOW_DEFAULTSYSTEM_VAR,0,&mi);
911 if(pobj_nv->bShow_Rad_Var)
912 SetMenuItemInfo(hMenu,IDM_SHOW_RAD_VAR,0,&mi);
913 if(pobj_nv->bShow_GUID_Var)
914 SetMenuItemInfo(hMenu,IDM_SHOW_GUID_VAR,0,&mi);
915
916 TrackPopupMenu(hMenu,TPM_LEFTALIGN,LOWORD(lParam),HIWORD(lParam),0,hwnd,0);
917
918 break;
919 case WM_COMMAND:
920 mi.cbSize=sizeof(MENUITEMINFO);
921 mi.fMask=MIIM_STATE;
922 switch(LOWORD(wParam)){
923 case IDM_SHOW_DEFAULTSYSTEM_VAR:
924 if(pobj_nv->bShow_DefaultSystem_Var){
925 pobj_nv->bShow_DefaultSystem_Var=0;
926 mi.fState=MFS_UNCHECKED;
927 }
928 else{
929 pobj_nv->bShow_DefaultSystem_Var=1;
930 mi.fState=MFS_CHECKED;
931 }
932 SetMenuItemInfo(hMenu,IDM_SHOW_DEFAULTSYSTEM_VAR,0,&mi);
933 RefreshGlobalVar_with_WindowLock();
934 break;
935 case IDM_SHOW_RAD_VAR:
936 if(pobj_nv->bShow_Rad_Var){
937 pobj_nv->bShow_Rad_Var=0;
938 mi.fState=MFS_UNCHECKED;
939 }
940 else{
941 pobj_nv->bShow_Rad_Var=1;
942 mi.fState=MFS_CHECKED;
943 }
944 SetMenuItemInfo(hMenu,IDM_SHOW_RAD_VAR,0,&mi);
945 RefreshGlobalVar_with_WindowLock();
946 break;
947 case IDM_SHOW_GUID_VAR:
948 if(pobj_nv->bShow_GUID_Var){
949 pobj_nv->bShow_GUID_Var=0;
950 mi.fState=MFS_UNCHECKED;
951 }
952 else{
953 pobj_nv->bShow_GUID_Var=1;
954 mi.fState=MFS_CHECKED;
955 }
956 SetMenuItemInfo(hMenu,IDM_SHOW_GUID_VAR,0,&mi);
957 RefreshGlobalVar_with_WindowLock();
958 break;
959 }
960 break;
961 case WM_DESTROY:
962 DestroyMenu(hMenu);
963 hMenu=0;
964 break;
965 }
966 return CallWindowProc(OldTabProc,hwnd,message,wParam,lParam);
967}
968
969BOOL CALLBACK DlgDebugger(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
970 extern HANDLE hHeap;
971 extern HINSTANCE hInst;
972 extern DWORD dwStepRun;
973 extern double width_ratio_VarList;
974 RECT rect;
975 int i,i2,i3;
976 char temporary[VN_SIZE];
977 LV_DISPINFO *lvinfo;
978 LVITEM ListView_Item;
979
980 static POINT pos_VarList;
981 static POINT pos_WatchList;
982
983 switch(message){
984 case WM_INITDIALOG:
985 extern HWND hDebugWnd;
986 hDebugWnd=hwnd;
987
988 //変数リストの初期位置を取得
989 GetWindowRect(GetDlgItem(hwnd,IDC_VARPOS),&rect);
990 pos_VarList.x=rect.left;
991 pos_VarList.y=rect.top;
992 ScreenToClient(hwnd,&pos_VarList);
993
994 //ウォッチリストの初期位置を取得
995 pos_WatchList.x=pos_VarList.x+(rect.right-rect.left)+LEVER_THICK;
996 pos_WatchList.y=0;
997
998 //ツールバーのベースウィンドウを生成
999 static HWND hBase_ToolBar;
1000 hBase_ToolBar=CreateDialog(hInst,MAKEINTRESOURCE(IDD_DEBUGGER_TOOLBARBASE),hwnd,(DLGPROC)DebuggerButtonsProc);
1001 MoveWindow(hBase_ToolBar,50,0,20*BTNNUM_DEBUGGERTOOLBAR,22,1);
1002
1003 extern WNDPROC OldThreadComboProc;
1004 OldThreadComboProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hwnd,IDC_THREADCOMBO),GWLP_WNDPROC);
1005 SetWindowLongPtr(GetDlgItem(hwnd,IDC_THREADCOMBO),GWLP_WNDPROC,(LONG_PTR)ThreadComboProc);
1006
1007 extern WNDPROC OldProcComboProc;
1008 OldProcComboProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hwnd,IDC_PROCCOMBO),GWLP_WNDPROC);
1009 SetWindowLongPtr(GetDlgItem(hwnd,IDC_PROCCOMBO),GWLP_WNDPROC,(LONG_PTR)ProcComboProc);
1010
1011
1012 ///////////////////////////
1013 // タブコントロールを生成
1014 ///////////////////////////
1015
1016 static HWND hTab;
1017 HFONT hFont;
1018 hFont=(HFONT)SendMessage(hwnd,WM_GETFONT,0,0);
1019 hTab=CreateWindow(WC_TABCONTROL,NULL,
1020 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE,
1021 0,0,0,0,hwnd,0,hInst,0);
1022 SendMessage(hTab,WM_SETFONT,(WPARAM)hFont,0);
1023 OldTabProc=(WNDPROC)GetWindowLongPtr(hTab,GWLP_WNDPROC);
1024 SetWindowLongPtr(hTab,GWLP_WNDPROC,(LONG_PTR)TabProc);
1025
1026 //タブを設定
1027 TC_ITEM tcItem;
1028 tcItem.mask=TCIF_TEXT;
1029 tcItem.pszText="グローバル";
1030 SendMessage(hTab,TCM_INSERTITEM,0,(LPARAM)&tcItem);
1031 tcItem.mask=TCIF_TEXT;
1032 tcItem.pszText="ローカル";
1033 SendMessage(hTab,TCM_INSERTITEM,1,(LPARAM)&tcItem);
1034 tcItem.mask=TCIF_TEXT;
1035 tcItem.pszText="This";
1036 SendMessage(hTab,TCM_INSERTITEM,2,(LPARAM)&tcItem);
1037
1038 //グローバル変数リストのツリーを作成
1039 hVarTree_Global=CreateWindowEx(WS_EX_CLIENTEDGE,WC_TREEVIEW,"",
1040 WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_SHOWSELALWAYS,
1041 0,0,0,0,
1042 hTab,0,hInst,0);
1043
1044 //ローカル変数リストのツリーを作成
1045 hVarTree_Local=CreateWindowEx(WS_EX_CLIENTEDGE,WC_TREEVIEW,"",
1046 WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_SHOWSELALWAYS,
1047 0,0,0,0,
1048 hTab,0,hInst,0);
1049
1050 //This変数リストのツリーを作成
1051 hVarTree_This=CreateWindowEx(WS_EX_CLIENTEDGE,WC_TREEVIEW,"",
1052 WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_SHOWSELALWAYS,
1053 0,0,0,0,
1054 hTab,0,hInst,0);
1055
1056 ShowWindow(hVarTree_Global,SW_SHOW);
1057
1058
1059 //イメージリスト読み込み、設定
1060 static HIMAGELIST hVariOrderImageList;
1061 hVariOrderImageList=ImageList_Create(16,16,ILC_COLOR4|ILC_MASK,4,0);
1062 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARARRAY)));
1063 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTRUCT)));
1064 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARDATA)));
1065 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTR)));
1066 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARPTRSTRUCT)));
1067 TreeView_SetImageList(hVarTree_Global,hVariOrderImageList,TVSIL_NORMAL);
1068 TreeView_SetImageList(hVarTree_Local,hVariOrderImageList,TVSIL_NORMAL);
1069 TreeView_SetImageList(hVarTree_This,hVariOrderImageList,TVSIL_NORMAL);
1070
1071
1072 /////////////////////////
1073 // ウォッチリスト
1074 /////////////////////////
1075
1076 //コラムの設定
1077 static HWND hListView;
1078 LV_COLUMN ListView_Column;
1079 DWORD dwStyle;
1080
1081 hListView=GetDlgItem(hwnd,IDC_WATCHLIST);
1082 GetClientRect(hListView,&rect);
1083 dwStyle=ListView_GetExtendedListViewStyle(hListView);
1084 dwStyle|=LVS_EX_FULLROWSELECT;
1085 ListView_SetExtendedListViewStyle(hListView,dwStyle);
1086
1087 ListView_Column.mask=LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
1088 ListView_Column.fmt=LVCFMT_LEFT;
1089
1090 extern int width_WatchColumn_Expression;
1091 ListView_Column.cx=width_WatchColumn_Expression;
1092 ListView_Column.pszText="ウォッチ式";
1093 ListView_Column.iSubItem=0;
1094 ListView_InsertColumn(hListView,0,&ListView_Column);
1095
1096 extern int width_WatchColumn_Value;
1097 ListView_Column.cx=width_WatchColumn_Value;
1098 ListView_Column.pszText="値";
1099 ListView_Column.iSubItem=1;
1100 ListView_InsertColumn(hListView,1,&ListView_Column);
1101
1102 //アイテムの設定
1103 ListView_Item.mask=LVIF_TEXT;
1104 ListView_Item.iSubItem=0;
1105 for(i=0;i<pobj_nv->WatchNum;i++){
1106 ListView_Item.pszText=pobj_nv->ppWatchStr[i];
1107 ListView_Item.iItem=i;
1108 ListView_InsertItem(hListView,&ListView_Item);
1109 }
1110 ListView_Item.pszText="...";
1111 ListView_Item.iItem=i;
1112 ListView_InsertItem(hListView,&ListView_Item);
1113
1114
1115 ///////////////////////
1116 // 変数リストの初期化
1117 ///////////////////////
1118 InitVarList((DWORD)lParam);
1119
1120 break;
1121 case WM_NOTIFY:
1122 NMHDR *hdr;
1123 hdr=(NMHDR *)lParam;
1124 if(hdr->hwndFrom==hTab&&hdr->code==TCN_SELCHANGE){
1125 i=TabCtrl_GetCurSel(hTab);
1126
1127 if(i==0){
1128 //グローバル変数を表示
1129 ShowWindow(hVarTree_Global,SW_SHOW);
1130 ShowWindow(hVarTree_Local,SW_HIDE);
1131 ShowWindow(hVarTree_This,SW_HIDE);
1132 }
1133 else if(i==1){
1134 //ローカル変数を表示
1135 ShowWindow(hVarTree_Global,SW_HIDE);
1136 ShowWindow(hVarTree_Local,SW_SHOW);
1137 ShowWindow(hVarTree_This,SW_HIDE);
1138 }
1139 else if(i==2){
1140 //This変数を表示
1141 ShowWindow(hVarTree_Global,SW_HIDE);
1142 ShowWindow(hVarTree_Local,SW_HIDE);
1143 ShowWindow(hVarTree_This,SW_SHOW);
1144 }
1145 }
1146
1147 if(hdr->hwndFrom==hListView){
1148 lvinfo=(LV_DISPINFO *)hdr;
1149 if(hdr->code==NM_DBLCLK){
1150 i2=ListView_GetItemCount(hListView);
1151 for(i=0;i<i2;i++){
1152 if(ListView_GetItemState(hListView,i,LVIS_SELECTED)) break;
1153 }
1154 if(i==i2) break;
1155
1156 ListView_EditLabel(hListView,i);
1157 }
1158
1159 static HWND hEdit;
1160 if(hdr->code==LVN_BEGINLABELEDIT){
1161 hEdit=ListView_GetEditControl(hListView);
1162
1163 GetWindowText(hEdit,temporary,VN_SIZE);
1164 if(lstrcmp(temporary,"...")==0) SetWindowText(hEdit,"");
1165 }
1166 if(hdr->code==LVN_ENDLABELEDIT){
1167 GetWindowText(hEdit,temporary,VN_SIZE);
1168 if(temporary[0]=='\0'){
1169 if(ListView_GetItemCount(hListView)-1==lvinfo->item.iItem) break;
1170
1171 //空白入力の場合はそのアイテムを削除する
1172 ListView_DeleteItem(hListView,lvinfo->item.iItem);
1173 break;
1174 }
1175 ListView_SetItemText(hListView,lvinfo->item.iItem,0,temporary);
1176
1177 //演算結果を表示
1178 SetCalcToWatchList(hListView,lvinfo->item.iItem,temporary);
1179
1180 if(lvinfo->item.iItem==ListView_GetItemCount(hListView)-1){
1181 //リストアイテムを追加
1182 ListView_Item.mask=LVIF_TEXT;
1183 ListView_Item.pszText="...";
1184 ListView_Item.iItem=lvinfo->item.iItem+1;
1185 ListView_Item.iSubItem=0;
1186 ListView_InsertItem(hListView,&ListView_Item);
1187 }
1188 }
1189
1190 if(hdr->code==LVN_KEYDOWN){
1191 LV_KEYDOWN *plvKeydown;
1192 plvKeydown=(LV_KEYDOWN *)hdr;
1193 if(plvKeydown->wVKey==VK_DELETE){
1194 i2=ListView_GetItemCount(hListView);
1195 for(i=i2-2;i>=0;i--){
1196 if(ListView_GetItemState(hListView,i,LVIS_SELECTED)){
1197 ListView_DeleteItem(hListView,i);
1198 i3=i;
1199 }
1200 }
1201
1202 ListView_SetItemState(hListView,i3,LVIS_SELECTED,LVIS_SELECTED);
1203 }
1204 }
1205 }
1206 break;
1207
1208 case WM_SIZE:
1209 //変数リストの位置
1210 int width_VarList;
1211 width_VarList=
1212 (int)((double)(LOWORD(lParam)-pos_VarList.x)*width_ratio_VarList);
1213
1214 MoveWindow(hTab,
1215 pos_VarList.x,
1216 pos_VarList.y,
1217 width_VarList,
1218 HIWORD(lParam)-pos_VarList.y,
1219 1);
1220
1221 GetClientRect(hTab,&rect);
1222 TabCtrl_AdjustRect(hTab,FALSE,&rect);
1223 rect.left-=2;
1224 rect.right++;
1225 rect.bottom++;
1226
1227 MoveWindow(hVarTree_Global,
1228 rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,1);
1229 MoveWindow(hVarTree_Local,
1230 rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,1);
1231 MoveWindow(hVarTree_This,
1232 rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,1);
1233
1234 pos_WatchList.x=pos_VarList.x+width_VarList+LEVER_THICK;
1235 pos_WatchList.y=0;
1236
1237 //ウォッチリストの位置
1238 MoveWindow(GetDlgItem(hwnd,IDC_WATCHLIST),
1239 pos_WatchList.x,
1240 pos_WatchList.y,
1241 LOWORD(lParam)-pos_WatchList.x,
1242 HIWORD(lParam)-pos_WatchList.y,
1243 1);
1244
1245 return 1;
1246
1247 case WM_VARLIST_CLOSE:
1248 DestroyWindow(hwnd);
1249 return 1;
1250 case WM_DESTROY:
1251 ImageList_Destroy(hVariOrderImageList);
1252
1253
1254 //////////////////////////////////////////////////////////////
1255 // ウォッチリストの以前の内容を破棄し、新しい内容に書き換える
1256 //////////////////////////////////////////////////////////////
1257
1258 for(i=0;i<pobj_nv->WatchNum;i++){
1259 HeapDefaultFree(pobj_nv->ppWatchStr[i]);
1260 }
1261 HeapDefaultFree(pobj_nv->ppWatchStr);
1262
1263 pobj_nv->WatchNum=ListView_GetItemCount(hListView)-1;
1264 pobj_nv->ppWatchStr=(char **)HeapAlloc(hHeap,0,pobj_nv->WatchNum*sizeof(char *)+1);
1265 for(i=0;i<pobj_nv->WatchNum;i++){
1266 ListView_GetItemText(hListView,i,0,temporary,VN_SIZE);
1267 pobj_nv->ppWatchStr[i]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
1268 lstrcpy(pobj_nv->ppWatchStr[i],temporary);
1269 }
1270
1271
1272 //////////////////////////////
1273 // デバッグダイアログを破棄
1274 //////////////////////////////
1275
1276 hDebugWnd=0;
1277
1278 if( program.IsClipCompileView() ){
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 HINSTANCE hInst;
1316 extern DWORD dwStepRun;
1317 RECT rect;
1318 POINT pos;
1319 SIZE size;
1320
1321 switch(message){
1322 case WM_INITDIALOG:
1323 extern HWND hDebugWnd;
1324 hDebugWnd=hwnd;
1325
1326 pos.x=pobj_nv->VarDlgRect.left;
1327 pos.y=pobj_nv->VarDlgRect.top;
1328 size.cx=pobj_nv->VarDlgRect.right-pobj_nv->VarDlgRect.left;
1329 size.cy=pobj_nv->VarDlgRect.bottom-pobj_nv->VarDlgRect.top;
1330 MoveWindow(hwnd,pos.x,pos.y,size.cx,size.cy,1);
1331
1332 extern WNDPROC OldThreadComboProc;
1333 OldThreadComboProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hwnd,IDC_THREADCOMBO),GWLP_WNDPROC);
1334 SetWindowLongPtr(GetDlgItem(hwnd,IDC_THREADCOMBO),GWLP_WNDPROC,(LONG_PTR)ThreadComboProc);
1335
1336 extern WNDPROC OldProcComboProc;
1337 OldProcComboProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hwnd,IDC_PROCCOMBO),GWLP_WNDPROC);
1338 SetWindowLongPtr(GetDlgItem(hwnd,IDC_PROCCOMBO),GWLP_WNDPROC,(LONG_PTR)ProcComboProc);
1339
1340 //イメージリスト読み込み、設定
1341 static HIMAGELIST hVariOrderImageList;
1342 hVariOrderImageList=ImageList_Create(16,16,ILC_COLOR4|ILC_MASK,4,0);
1343 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARARRAY)));
1344 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTRUCT)));
1345 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARDATA)));
1346 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTR)));
1347 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARPTRSTRUCT)));
1348 TreeView_SetImageList(GetDlgItem(hwnd,IDC_VARTREE),hVariOrderImageList,TVSIL_NORMAL);
1349
1350 InitVarList((DWORD)lParam);
1351 break;
1352 case WM_COMMAND:
1353 switch(LOWORD(wParam)){
1354 case IDCANCEL:
1355 DestroyWindow(hwnd);
1356 return 1;
1357 case IDC_STEPIN:
1358 dwStepRun=1;
1359 return 1;
1360 case IDC_STEPOVER:
1361 dwStepRun=2;
1362 return 1;
1363 }
1364 break;
1365 case WM_SIZE:
1366 GetWindowRect(GetDlgItem(hwnd,IDC_VARTREE),&rect);
1367 pos.x=rect.left;
1368 pos.y=rect.top;
1369 ScreenToClient(hwnd,&pos);
1370 MoveWindow(GetDlgItem(hwnd,IDC_VARTREE),0,pos.y,LOWORD(lParam),HIWORD(lParam)-pos.y,TRUE);
1371 SetWindowPos(GetDlgItem(hwnd,IDCANCEL),0,LOWORD(lParam)-91,9,0,0,SWP_NOSIZE);
1372 return 1;
1373 case WM_VARLIST_CLOSE:
1374 DestroyWindow(hwnd);
1375 return 1;
1376 case WM_DESTROY:
1377 ImageList_Destroy(hVariOrderImageList);
1378
1379 GetWindowRect(hwnd,&pobj_nv->VarDlgRect);
1380
1381 hDebugWnd=0;
1382
1383 return 1;
1384 }
1385 return 0;
1386}
Note: See TracBrowser for help on using the repository browser.