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

Last change on this file since 696 was 677, checked in by dai_9181, 16 years ago

値渡しの構造体パラメータが正常に引き渡されない不具合を修正。

File size: 40.8 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() || pVar->IsByValStructParameter() )
428 {
429 ReadProcessMemory(hDebugProcess,(void *)offset,&lpData,sizeof(LONG_PTR),&accessBytes);
430 offset=lpData;
431 }
432 VarList_Insert(hVarTree_Local,&tv,
433 pVar->GetName().c_str(),
434 pVar->GetType(),
435 offset);
436 }
437 }
438
439
440
441 /////////////////////////////
442 // Thisオブジェクトのリスト
443 /////////////////////////////
444
445 TreeView_DeleteAllItems(hVarTree_This);
446 if( pUserProc->IsGlobalProcedure() ) return;
447
448 //Thisポインタを取得
449 LONG_PTR pThis;
450 const Variable *pVar = pUserProc->GetLocalVars().Find( LexicalAnalyzer::FullNameToSymbol( "_System_LocalThis" ) );
451 if( !pVar ){
452 return;
453 }
454 lpData=pobj_dti->lplpSpBase[i2]+pVar->GetOffsetAddress();
455 ReadProcessMemory(hDebugProcess,(void *)lpData,&pThis,sizeof(LONG_PTR),&accessBytes);
456
457 if( pUserProc->GetParentClassPtr()->HasSuperClass() )
458 {
459 TV_INSERTSTRUCT tv;
460
461 memset(&tv,0,sizeof(TV_INSERTSTRUCT));
462 tv.hInsertAfter=TVI_LAST;
463 tv.item.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
464 tv.hParent=NULL;
465 tv.item.pszText=temporary;
466
467 // 基底クラス
468 sprintf(tv.item.pszText,"Inherits %s",pUserProc->GetParentClassPtr()->GetSuperClass().GetName().c_str());
469 tv.item.iImage=1;
470 tv.item.iSelectedImage=1;
471 HTREEITEM hTempParent=TreeView_InsertItem(hVarTree_This,&tv);
472
473 VarList_Member(hVarTree_This,hTempParent,pThis,pUserProc->GetParentClassPtr()->GetSuperClass(),0);
474 }
475
476 BOOST_FOREACH( Member *pMember, pUserProc->GetParentClassPtr()->GetDynamicMembers() ){
477 offset=pUserProc->GetParentClassPtr()->GetMemberOffset( pMember->GetName().c_str());
478
479 if( pMember->GetSubscripts().size() > 0 ){
480 //配列
481 sprintf(temporary,"%s %s(&H%X)",
482 pMember->GetName().c_str(),
483 STRING_ARRAY,
484 (ULONG_PTR)offset);
485 tv.item.iImage=0;
486 tv.item.iSelectedImage=0;
487 hParent=TreeView_InsertItem(hVarTree_This,&tv);
488
489 VarList_Array(
490 hVarTree_This,
491 hParent,
492 pThis + offset,
493 pMember->GetType(),
494 pMember->GetSubscripts()
495 );
496 }
497 else{
498 VarList_Insert(hVarTree_This,&tv,
499 pMember->GetName().c_str(),
500 pMember->GetType(),
501 pThis+offset);
502 }
503 }
504}
505void RefreshGlobalVar_with_WindowLock(void){
506 extern HWND hDebugWnd;
507
508 //処理時間を短くするため、一時的に非表示にする
509 LockWindowUpdate(hDebugWnd);
510 ShowWindow(GetParent(hVarTree_Global),SW_HIDE);
511
512 //リフレッシュ
513 RefreshGlobalVar();
514
515 LockWindowUpdate(NULL);
516 ShowWindow(GetParent(hVarTree_Global),SW_SHOW);
517}
518void RefreshLocalVar_with_WindowLock(void){
519 extern HWND hDebugWnd;
520
521 //処理時間を短くするため、一時的に非表示にする
522 LockWindowUpdate(hDebugWnd);
523 ShowWindow(GetParent(hVarTree_Local),SW_HIDE);
524
525 //リフレッシュ
526 RefreshLocalVar();
527
528 LockWindowUpdate(NULL);
529 ShowWindow(GetParent(hVarTree_Local),SW_SHOW);
530}
531
532void SetCalcToWatchList(HWND hListView,int iItem,char *buffer){
533 char temporary[255],temp2[255];
534
535 //エスケープシーケンスをセット
536 SetEscapeSequenceFormat(buffer);
537
538 KillStringSpaces(buffer);
539
540 //カッコを相互チェック
541 if(!CheckParenthesis2(buffer)){
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560 ListView_SetItemText(hListView,iItem,1,"式の解析に失敗");
561 return;
562 }
563
564 double dbl;
565 _int64 i64data;
566 Type resultType;
567 bool isMemoryAccessError;
568 if( !StaticCalculation(true, buffer,0,&i64data,resultType,1,&isMemoryAccessError) ){
569 ListView_SetItemText(hListView,iItem,1,"式の解析に失敗");
570 }
571 else if(isMemoryAccessError){
572 ListView_SetItemText(hListView,iItem,1,"アクセスできません");
573 }
574 else{
575 if(resultType.IsReal()){
576 memcpy(&dbl,&i64data,sizeof(double));
577 sprintf(temporary,"%.15g (&H%08X)",dbl,(int)dbl);
578 }
579 else if(resultType.Is64()){
580 _i64toa(i64data,temporary,10);
581 _i64toa(i64data,temp2,16);
582 CharUpper(temp2);
583 sprintf(temporary+lstrlen(temporary)," (&H%s)",temp2);
584 }
585 else sprintf(temporary,"%d (&H%08X)",(long)i64data,(long)i64data);
586
587 ListView_SetItemText(hListView,iItem,1,temporary);
588 }
589}
590void RefreshWatchList(void){
591 extern HWND hDebugWnd;
592 HWND hListView;
593 int i,i2;
594 char temporary[VN_SIZE];
595
596 hListView=GetDlgItem(hDebugWnd,IDC_WATCHLIST);
597 i2=ListView_GetItemCount(hListView);
598 for(i=0;i<i2-1;i++){
599 ListView_GetItemText(hListView,i,0,temporary,VN_SIZE);
600
601 //演算結果を表示
602 SetCalcToWatchList(hListView,i,temporary);
603 }
604}
605
606BOOL SetDebugProcCombo(HWND hProcCombo){
607 int i2,i3;
608 char temporary[255];
609
610 extern DWORD ImageBase;
611 extern int MemPos_CodeSection;
612
613 //行番号情報
614 extern SourceLines oldSourceLines;
615 for(i3=0;i3<(int)pobj_dti->iProcLevel+1;i3++){
616 for(i2=0;i2<(int)oldSourceLines.size()-2;i2++){
617 if((ULONG_PTR)(oldSourceLines[i2].GetNativeCodePos()+ImageBase+MemPos_CodeSection)<=pobj_dti->lplpObp[i3]&&
618 pobj_dti->lplpObp[i3]<=(ULONG_PTR)(oldSourceLines[i2+1].GetNativeCodePos()+ImageBase+MemPos_CodeSection)) break;
619 }
620 if(i2==oldSourceLines.size()-1) pobj_dti->lpdwCp[i3]=-1;
621 else
622 {
623 pobj_dti->lpdwCp[i3]=oldSourceLines[i2].GetSourceCodePosition().GetPos();
624 pobj_dti->relationalObjectModuleIndexes[i3]=oldSourceLines[i2].GetSourceCodePosition().GetRelationalObjectModuleIndex();
625 }
626 }
627 for(i3=0;i3<(int)pobj_dti->iProcLevel+1;i3++){
628 if(pobj_dti->lpdwCp[i3]==-1){
629 pobj_dti->iProcLevel--;
630 for(i2=i3;i2<(int)pobj_dti->iProcLevel+1;i2++){
631 pobj_dti->lplpObp[i2]=pobj_dti->lplpObp[i2+1];
632 pobj_dti->lplpSpBase[i2]=pobj_dti->lplpSpBase[i2+1];
633 pobj_dti->lpdwCp[i2]=pobj_dti->lpdwCp[i2+1];
634 pobj_dti->relationalObjectModuleIndexes[i2]=pobj_dti->relationalObjectModuleIndexes[i2+1];
635 }
636 i3--;
637 continue;
638 }
639 }
640
641 std::string dummyStr;
642 extern BasicSources sourcesLinkRelationalObjectModule;
643 if(!sourcesLinkRelationalObjectModule[pobj_dti->relationalObjectModuleIndexes[pobj_dti->iProcLevel]].GetLineInfo( pobj_dti->lpdwCp[pobj_dti->iProcLevel], i2, dummyStr )){
644 extern HWND hMainDlg;
645 //"デバッグ情報の取得に失敗"
646 MessageBox(hMainDlg,STRING_DEBUG_FAILED,"ActiveBasic error",MB_OK);
647 return 0;
648 }
649 ShowErrorLine(i2,dummyStr.c_str());
650
651 //プロシージャ コンボボックス
652 SendMessage(hProcCombo,CB_RESETCONTENT,0,0);
653 for(i2=pobj_dti->iProcLevel;i2>=0;i2--){
654
655 UserProc *pUserProc = NULL;
656 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset();
657 while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() )
658 {
659 pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();
660
661 if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2] &&
662 pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->GetEndOpAddress()))
663 {
664 lstrcpy(temporary,pUserProc->GetName().c_str());
665 break;
666 }
667 }
668 if(!pUserProc){
669 if(i2==0){
670 lstrcpy(temporary,"Global");
671 pobj_dti->lplpSpBase[i2]=0;
672 }
673 else lstrcpy(temporary,"error");
674 }
675 SendMessage(hProcCombo,CB_ADDSTRING,0,(LPARAM)temporary);
676 }
677 SendMessage(hProcCombo,CB_SETCURSEL,0,0);
678
679 return pobj_dti->iProcLevel;
680}
681
682//IDC_THREADCOMBOプロシージャ
683LRESULT CALLBACK ThreadComboProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
684 extern WNDPROC OldThreadComboProc;
685 int i2;
686 DWORD dwThreadID;
687 char temporary[255];
688
689 switch(message){
690 case WM_COMMAND:
691 if(HIWORD(wParam)==CBN_SELCHANGE){
692 SendMessage(hwnd,CB_GETLBTEXT,SendMessage(hwnd,CB_GETCURSEL,0,0),(LPARAM)temporary);
693 sscanf(temporary+2,"%X",&dwThreadID);
694
695 extern DWORD _DebugSys_dwThreadID[256];
696 i2=0;
697 while(_DebugSys_dwThreadID[i2]!=dwThreadID) i2++;
698
699 //次回のステップ実行対象を指定
700 extern int NextStepThreadNum;
701 NextStepThreadNum=i2;
702
703 //スレッド情報をリフレッシュ
704 pobj_dti->Reflesh(i2);
705
706 SetDebugProcCombo(GetDlgItem(GetParent(hwnd),IDC_PROCCOMBO));
707
708 SendDlgItemMessage(GetParent(hwnd),IDC_PROCCOMBO,WM_COMMAND,MAKELONG(0,CBN_SELCHANGE),0);
709 }
710 break;
711 }
712 return CallWindowProc(OldThreadComboProc,hwnd,message,wParam,lParam);
713}
714//IDC_PROCCOMBOプロシージャ
715LRESULT CALLBACK ProcComboProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
716 extern WNDPROC OldProcComboProc;
717 int i2,i3;
718
719 switch(message){
720 case WM_COMMAND:
721 if(HIWORD(wParam)==CBN_SELCHANGE){
722 i2=(int)SendMessage(hwnd,CB_GETCURSEL,0,0);
723
724 std::string dummyStr;
725 extern BasicSources sourcesLinkRelationalObjectModule;
726 sourcesLinkRelationalObjectModule[pobj_dti->relationalObjectModuleIndexes[pobj_dti->iProcLevel]].GetLineInfo( pobj_dti->lpdwCp[pobj_dti->iProcLevel-i2], i3, dummyStr );
727 ShowErrorLine(i3,dummyStr.c_str());
728
729 RefreshLocalVar_with_WindowLock();
730 }
731 break;
732 }
733 return CallWindowProc(OldProcComboProc,hwnd,message,wParam,lParam);
734}
735void InitVarList(DWORD dwThreadId){
736 extern HWND hDebugWnd;
737 int i2,i5;
738 char temporary[255];
739
740
741 //スレッド
742 SendDlgItemMessage(hDebugWnd,IDC_THREADCOMBO,CB_RESETCONTENT,0,0);
743 extern DWORD _DebugSys_dwThreadID[256];
744 for(i2=0;i2<256;i2++){
745 if(_DebugSys_dwThreadID[i2]){
746 sprintf(temporary,"&H%08X",_DebugSys_dwThreadID[i2]);
747 SendDlgItemMessage(hDebugWnd,IDC_THREADCOMBO,CB_ADDSTRING,0,(LPARAM)temporary);
748 if(_DebugSys_dwThreadID[i2]==dwThreadId){
749 extern int NextStepThreadNum;
750 NextStepThreadNum=i2;
751 }
752 }
753 }
754 sprintf(temporary,"&H%08X",dwThreadId);
755 i5=(int)SendDlgItemMessage(hDebugWnd,IDC_THREADCOMBO,CB_FINDSTRING,0,(LPARAM)temporary);
756 SendDlgItemMessage(hDebugWnd,IDC_THREADCOMBO,CB_SETCURSEL,i5,0);
757
758 i2=SetDebugProcCombo(GetDlgItem(hDebugWnd,IDC_PROCCOMBO));
759
760
761 ///////////////////////////////////////////////
762 // 実行中のプロシージャのローカル変数をセット
763 ///////////////////////////////////////////////
764
765 i2=(int)SendDlgItemMessage(hDebugWnd,IDC_PROCCOMBO,CB_GETCURSEL,0,0);
766 i2=pobj_dti->iProcLevel-i2;
767
768 if(pobj_dti->lplpSpBase[i2]){
769
770 UserProc *pUserProc = NULL;
771 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset();
772 while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() )
773 {
774 pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();
775
776 if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2] &&
777 pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->GetEndOpAddress())){
778 break;
779 }
780 }
781
782 if(pUserProc){
783 compiler.StartProcedureCompile( pUserProc );
784 }
785 }
786
787
788 ////////////////////////
789 // 変数リストを再表示
790 ////////////////////////
791
792 //処理時間を短くするため、一時的に非表示にする
793 LockWindowUpdate(hDebugWnd);
794 ShowWindow(GetParent(hVarTree_Global),SW_HIDE);
795 ShowWindow(GetDlgItem(hDebugWnd,IDC_WATCHLIST),SW_HIDE);
796
797 //リフレッシュ
798 RefreshLocalVar();
799 RefreshGlobalVar();
800 RefreshWatchList();
801
802 LockWindowUpdate(NULL);
803 ShowWindow(GetParent(hVarTree_Global),SW_SHOW);
804 ShowWindow(GetDlgItem(hDebugWnd,IDC_WATCHLIST),SW_SHOW);
805}
806
807
808
809
810//////////////////////////////////////
811// エディタに埋め込み表示のデバッガ
812//////////////////////////////////////
813
814BOOL CALLBACK DebuggerButtonsProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
815 extern HINSTANCE hInst;
816 extern DWORD dwStepRun;
817
818 //デバッガ用ツールバー
819#define BMPNUM_DEBUGGERTOOLBAR 3
820#define BTNNUM_DEBUGGERTOOLBAR 4
821 TBBUTTON DebuggerToolBar[]={
822 {0,IDC_DEBUG_START,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
823 {0,0,TBSTATE_ENABLED,TBSTYLE_SEP,0,0},
824 {1,IDC_DEBUG_STEPOVER,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
825 {2,IDC_DEBUG_STEPIN,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
826 };
827 TOOLTIPTEXT *pTipText;
828
829 static HIMAGELIST hImageList,hImageList_Disabled;
830
831 switch(message){
832 case WM_INITDIALOG:
833 //ツールバーを生成
834 extern HWND hDebuggerToolbar;
835 hDebuggerToolbar=CreateToolbarEx(hwnd,WS_CHILD|WS_VISIBLE|CCS_NODIVIDER|TBSTYLE_FLAT|TBSTYLE_TOOLTIPS|WS_CLIPSIBLINGS,
836 NULL,
837 0,0,0,
838 DebuggerToolBar,
839 BTNNUM_DEBUGGERTOOLBAR, /*アイテムの個数*/
840 0,0,16,15,sizeof(TBBUTTON));
841
842 hImageList = ImageList_LoadImage(hInst, MAKEINTRESOURCE(IDR_DEBUGGERTOOLBAR),
843 16, 0, RGB(192,192,192),IMAGE_BITMAP, LR_CREATEDIBSECTION);
844 SendMessage(hDebuggerToolbar, TB_SETIMAGELIST, 0, (LPARAM)hImageList);
845 hImageList_Disabled = ImageList_LoadImage(hInst, MAKEINTRESOURCE(IDR_DEBUGGERTOOLBAR_DISABLED),
846 16, 0, RGB(192,192,192),IMAGE_BITMAP, LR_CREATEDIBSECTION);
847 SendMessage(hDebuggerToolbar, TB_SETDISABLEDIMAGELIST, 0, (LPARAM)hImageList_Disabled);
848
849 break;
850 case WM_COMMAND:
851 switch(LOWORD(wParam)){
852 case IDC_DEBUG_START:
853 DestroyWindow(GetParent(hwnd));
854 return 1;
855 case IDC_DEBUG_STEPIN:
856 dwStepRun=1;
857 return 1;
858 case IDC_DEBUG_STEPOVER:
859 dwStepRun=2;
860 return 1;
861 }
862 break;
863 case WM_NOTIFY:
864 pTipText=(TOOLTIPTEXT *)lParam;
865 if(pTipText->hdr.code==TTN_NEEDTEXT){
866 //ツールチップを表示
867 switch(pTipText->hdr.idFrom){
868 case IDC_DEBUG_START:
869 pTipText->lpszText="実行";
870 break;
871 case IDC_DEBUG_STEPOVER:
872 pTipText->lpszText="ステップ アウト";
873 break;
874 case IDC_DEBUG_STEPIN:
875 pTipText->lpszText="ステップ イン";
876 break;
877 }
878 }
879 break;
880 case WM_SIZE:
881 MoveWindow(hDebuggerToolbar,0,0,LOWORD(lParam),HIWORD(lParam),1);
882 return 1;
883
884 case WM_DESTROY:
885 ImageList_Destroy(hImageList);
886 ImageList_Destroy(hImageList_Disabled);
887 return 1;
888 }
889 return 0;
890}
891
892WNDPROC OldTabProc;
893LRESULT CALLBACK TabProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
894 extern HINSTANCE hInst;
895
896 static HMENU hDummyMenu,hMenu=0;
897
898 switch(message){
899 case WM_CONTEXTMENU:
900 if(hMenu==0){
901 hDummyMenu=LoadMenu(hInst,MAKEINTRESOURCE(IDR_DEBUGGER_VARLIST_MENU));
902 hMenu=GetSubMenu(hDummyMenu,0);
903 }
904
905 MENUITEMINFO mi;
906 mi.cbSize=sizeof(MENUITEMINFO);
907 mi.fMask=MIIM_STATE;
908 mi.fState=MFS_CHECKED;
909
910 if(pobj_nv->bShow_DefaultSystem_Var)
911 SetMenuItemInfo(hMenu,IDM_SHOW_DEFAULTSYSTEM_VAR,0,&mi);
912 if(pobj_nv->bShow_Rad_Var)
913 SetMenuItemInfo(hMenu,IDM_SHOW_RAD_VAR,0,&mi);
914 if(pobj_nv->bShow_GUID_Var)
915 SetMenuItemInfo(hMenu,IDM_SHOW_GUID_VAR,0,&mi);
916
917 TrackPopupMenu(hMenu,TPM_LEFTALIGN,LOWORD(lParam),HIWORD(lParam),0,hwnd,0);
918
919 break;
920 case WM_COMMAND:
921 mi.cbSize=sizeof(MENUITEMINFO);
922 mi.fMask=MIIM_STATE;
923 switch(LOWORD(wParam)){
924 case IDM_SHOW_DEFAULTSYSTEM_VAR:
925 if(pobj_nv->bShow_DefaultSystem_Var){
926 pobj_nv->bShow_DefaultSystem_Var=0;
927 mi.fState=MFS_UNCHECKED;
928 }
929 else{
930 pobj_nv->bShow_DefaultSystem_Var=1;
931 mi.fState=MFS_CHECKED;
932 }
933 SetMenuItemInfo(hMenu,IDM_SHOW_DEFAULTSYSTEM_VAR,0,&mi);
934 RefreshGlobalVar_with_WindowLock();
935 break;
936 case IDM_SHOW_RAD_VAR:
937 if(pobj_nv->bShow_Rad_Var){
938 pobj_nv->bShow_Rad_Var=0;
939 mi.fState=MFS_UNCHECKED;
940 }
941 else{
942 pobj_nv->bShow_Rad_Var=1;
943 mi.fState=MFS_CHECKED;
944 }
945 SetMenuItemInfo(hMenu,IDM_SHOW_RAD_VAR,0,&mi);
946 RefreshGlobalVar_with_WindowLock();
947 break;
948 case IDM_SHOW_GUID_VAR:
949 if(pobj_nv->bShow_GUID_Var){
950 pobj_nv->bShow_GUID_Var=0;
951 mi.fState=MFS_UNCHECKED;
952 }
953 else{
954 pobj_nv->bShow_GUID_Var=1;
955 mi.fState=MFS_CHECKED;
956 }
957 SetMenuItemInfo(hMenu,IDM_SHOW_GUID_VAR,0,&mi);
958 RefreshGlobalVar_with_WindowLock();
959 break;
960 }
961 break;
962 case WM_DESTROY:
963 DestroyMenu(hMenu);
964 hMenu=0;
965 break;
966 }
967 return CallWindowProc(OldTabProc,hwnd,message,wParam,lParam);
968}
969
970BOOL CALLBACK DlgDebugger(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
971 extern HANDLE hHeap;
972 extern HINSTANCE hInst;
973 extern DWORD dwStepRun;
974 extern double width_ratio_VarList;
975 RECT rect;
976 int i,i2,i3;
977 char temporary[VN_SIZE];
978 LV_DISPINFO *lvinfo;
979 LVITEM ListView_Item;
980
981 static POINT pos_VarList;
982 static POINT pos_WatchList;
983
984 switch(message){
985 case WM_INITDIALOG:
986 extern HWND hDebugWnd;
987 hDebugWnd=hwnd;
988
989 //変数リストの初期位置を取得
990 GetWindowRect(GetDlgItem(hwnd,IDC_VARPOS),&rect);
991 pos_VarList.x=rect.left;
992 pos_VarList.y=rect.top;
993 ScreenToClient(hwnd,&pos_VarList);
994
995 //ウォッチリストの初期位置を取得
996 pos_WatchList.x=pos_VarList.x+(rect.right-rect.left)+LEVER_THICK;
997 pos_WatchList.y=0;
998
999 //ツールバーのベースウィンドウを生成
1000 static HWND hBase_ToolBar;
1001 hBase_ToolBar=CreateDialog(hInst,MAKEINTRESOURCE(IDD_DEBUGGER_TOOLBARBASE),hwnd,(DLGPROC)DebuggerButtonsProc);
1002 MoveWindow(hBase_ToolBar,50,0,20*BTNNUM_DEBUGGERTOOLBAR,22,1);
1003
1004 extern WNDPROC OldThreadComboProc;
1005 OldThreadComboProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hwnd,IDC_THREADCOMBO),GWLP_WNDPROC);
1006 SetWindowLongPtr(GetDlgItem(hwnd,IDC_THREADCOMBO),GWLP_WNDPROC,(LONG_PTR)ThreadComboProc);
1007
1008 extern WNDPROC OldProcComboProc;
1009 OldProcComboProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hwnd,IDC_PROCCOMBO),GWLP_WNDPROC);
1010 SetWindowLongPtr(GetDlgItem(hwnd,IDC_PROCCOMBO),GWLP_WNDPROC,(LONG_PTR)ProcComboProc);
1011
1012
1013 ///////////////////////////
1014 // タブコントロールを生成
1015 ///////////////////////////
1016
1017 static HWND hTab;
1018 HFONT hFont;
1019 hFont=(HFONT)SendMessage(hwnd,WM_GETFONT,0,0);
1020 hTab=CreateWindow(WC_TABCONTROL,NULL,
1021 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE,
1022 0,0,0,0,hwnd,0,hInst,0);
1023 SendMessage(hTab,WM_SETFONT,(WPARAM)hFont,0);
1024 OldTabProc=(WNDPROC)GetWindowLongPtr(hTab,GWLP_WNDPROC);
1025 SetWindowLongPtr(hTab,GWLP_WNDPROC,(LONG_PTR)TabProc);
1026
1027 //タブを設定
1028 TC_ITEM tcItem;
1029 tcItem.mask=TCIF_TEXT;
1030 tcItem.pszText="グローバル";
1031 SendMessage(hTab,TCM_INSERTITEM,0,(LPARAM)&tcItem);
1032 tcItem.mask=TCIF_TEXT;
1033 tcItem.pszText="ローカル";
1034 SendMessage(hTab,TCM_INSERTITEM,1,(LPARAM)&tcItem);
1035 tcItem.mask=TCIF_TEXT;
1036 tcItem.pszText="This";
1037 SendMessage(hTab,TCM_INSERTITEM,2,(LPARAM)&tcItem);
1038
1039 //グローバル変数リストのツリーを作成
1040 hVarTree_Global=CreateWindowEx(WS_EX_CLIENTEDGE,WC_TREEVIEW,"",
1041 WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_SHOWSELALWAYS,
1042 0,0,0,0,
1043 hTab,0,hInst,0);
1044
1045 //ローカル変数リストのツリーを作成
1046 hVarTree_Local=CreateWindowEx(WS_EX_CLIENTEDGE,WC_TREEVIEW,"",
1047 WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_SHOWSELALWAYS,
1048 0,0,0,0,
1049 hTab,0,hInst,0);
1050
1051 //This変数リストのツリーを作成
1052 hVarTree_This=CreateWindowEx(WS_EX_CLIENTEDGE,WC_TREEVIEW,"",
1053 WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_SHOWSELALWAYS,
1054 0,0,0,0,
1055 hTab,0,hInst,0);
1056
1057 ShowWindow(hVarTree_Global,SW_SHOW);
1058
1059
1060 //イメージリスト読み込み、設定
1061 static HIMAGELIST hVariOrderImageList;
1062 hVariOrderImageList=ImageList_Create(16,16,ILC_COLOR4|ILC_MASK,4,0);
1063 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARARRAY)));
1064 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTRUCT)));
1065 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARDATA)));
1066 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTR)));
1067 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARPTRSTRUCT)));
1068 TreeView_SetImageList(hVarTree_Global,hVariOrderImageList,TVSIL_NORMAL);
1069 TreeView_SetImageList(hVarTree_Local,hVariOrderImageList,TVSIL_NORMAL);
1070 TreeView_SetImageList(hVarTree_This,hVariOrderImageList,TVSIL_NORMAL);
1071
1072
1073 /////////////////////////
1074 // ウォッチリスト
1075 /////////////////////////
1076
1077 //コラムの設定
1078 static HWND hListView;
1079 LV_COLUMN ListView_Column;
1080 DWORD dwStyle;
1081
1082 hListView=GetDlgItem(hwnd,IDC_WATCHLIST);
1083 GetClientRect(hListView,&rect);
1084 dwStyle=ListView_GetExtendedListViewStyle(hListView);
1085 dwStyle|=LVS_EX_FULLROWSELECT;
1086 ListView_SetExtendedListViewStyle(hListView,dwStyle);
1087
1088 ListView_Column.mask=LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
1089 ListView_Column.fmt=LVCFMT_LEFT;
1090
1091 extern int width_WatchColumn_Expression;
1092 ListView_Column.cx=width_WatchColumn_Expression;
1093 ListView_Column.pszText="ウォッチ式";
1094 ListView_Column.iSubItem=0;
1095 ListView_InsertColumn(hListView,0,&ListView_Column);
1096
1097 extern int width_WatchColumn_Value;
1098 ListView_Column.cx=width_WatchColumn_Value;
1099 ListView_Column.pszText="値";
1100 ListView_Column.iSubItem=1;
1101 ListView_InsertColumn(hListView,1,&ListView_Column);
1102
1103 //アイテムの設定
1104 ListView_Item.mask=LVIF_TEXT;
1105 ListView_Item.iSubItem=0;
1106 for(i=0;i<pobj_nv->WatchNum;i++){
1107 ListView_Item.pszText=pobj_nv->ppWatchStr[i];
1108 ListView_Item.iItem=i;
1109 ListView_InsertItem(hListView,&ListView_Item);
1110 }
1111 ListView_Item.pszText="...";
1112 ListView_Item.iItem=i;
1113 ListView_InsertItem(hListView,&ListView_Item);
1114
1115
1116 ///////////////////////
1117 // 変数リストの初期化
1118 ///////////////////////
1119 InitVarList((DWORD)lParam);
1120
1121 break;
1122 case WM_NOTIFY:
1123 NMHDR *hdr;
1124 hdr=(NMHDR *)lParam;
1125 if(hdr->hwndFrom==hTab&&hdr->code==TCN_SELCHANGE){
1126 i=TabCtrl_GetCurSel(hTab);
1127
1128 if(i==0){
1129 //グローバル変数を表示
1130 ShowWindow(hVarTree_Global,SW_SHOW);
1131 ShowWindow(hVarTree_Local,SW_HIDE);
1132 ShowWindow(hVarTree_This,SW_HIDE);
1133 }
1134 else if(i==1){
1135 //ローカル変数を表示
1136 ShowWindow(hVarTree_Global,SW_HIDE);
1137 ShowWindow(hVarTree_Local,SW_SHOW);
1138 ShowWindow(hVarTree_This,SW_HIDE);
1139 }
1140 else if(i==2){
1141 //This変数を表示
1142 ShowWindow(hVarTree_Global,SW_HIDE);
1143 ShowWindow(hVarTree_Local,SW_HIDE);
1144 ShowWindow(hVarTree_This,SW_SHOW);
1145 }
1146 }
1147
1148 if(hdr->hwndFrom==hListView){
1149 lvinfo=(LV_DISPINFO *)hdr;
1150 if(hdr->code==NM_DBLCLK){
1151 i2=ListView_GetItemCount(hListView);
1152 for(i=0;i<i2;i++){
1153 if(ListView_GetItemState(hListView,i,LVIS_SELECTED)) break;
1154 }
1155 if(i==i2) break;
1156
1157 ListView_EditLabel(hListView,i);
1158 }
1159
1160 static HWND hEdit;
1161 if(hdr->code==LVN_BEGINLABELEDIT){
1162 hEdit=ListView_GetEditControl(hListView);
1163
1164 GetWindowText(hEdit,temporary,VN_SIZE);
1165 if(lstrcmp(temporary,"...")==0) SetWindowText(hEdit,"");
1166 }
1167 if(hdr->code==LVN_ENDLABELEDIT){
1168 GetWindowText(hEdit,temporary,VN_SIZE);
1169 if(temporary[0]=='\0'){
1170 if(ListView_GetItemCount(hListView)-1==lvinfo->item.iItem) break;
1171
1172 //空白入力の場合はそのアイテムを削除する
1173 ListView_DeleteItem(hListView,lvinfo->item.iItem);
1174 break;
1175 }
1176 ListView_SetItemText(hListView,lvinfo->item.iItem,0,temporary);
1177
1178 //演算結果を表示
1179 SetCalcToWatchList(hListView,lvinfo->item.iItem,temporary);
1180
1181 if(lvinfo->item.iItem==ListView_GetItemCount(hListView)-1){
1182 //リストアイテムを追加
1183 ListView_Item.mask=LVIF_TEXT;
1184 ListView_Item.pszText="...";
1185 ListView_Item.iItem=lvinfo->item.iItem+1;
1186 ListView_Item.iSubItem=0;
1187 ListView_InsertItem(hListView,&ListView_Item);
1188 }
1189 }
1190
1191 if(hdr->code==LVN_KEYDOWN){
1192 LV_KEYDOWN *plvKeydown;
1193 plvKeydown=(LV_KEYDOWN *)hdr;
1194 if(plvKeydown->wVKey==VK_DELETE){
1195 i2=ListView_GetItemCount(hListView);
1196 for(i=i2-2;i>=0;i--){
1197 if(ListView_GetItemState(hListView,i,LVIS_SELECTED)){
1198 ListView_DeleteItem(hListView,i);
1199 i3=i;
1200 }
1201 }
1202
1203 ListView_SetItemState(hListView,i3,LVIS_SELECTED,LVIS_SELECTED);
1204 }
1205 }
1206 }
1207 break;
1208
1209 case WM_SIZE:
1210 //変数リストの位置
1211 int width_VarList;
1212 width_VarList=
1213 (int)((double)(LOWORD(lParam)-pos_VarList.x)*width_ratio_VarList);
1214
1215 MoveWindow(hTab,
1216 pos_VarList.x,
1217 pos_VarList.y,
1218 width_VarList,
1219 HIWORD(lParam)-pos_VarList.y,
1220 1);
1221
1222 GetClientRect(hTab,&rect);
1223 TabCtrl_AdjustRect(hTab,FALSE,&rect);
1224 rect.left-=2;
1225 rect.right++;
1226 rect.bottom++;
1227
1228 MoveWindow(hVarTree_Global,
1229 rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,1);
1230 MoveWindow(hVarTree_Local,
1231 rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,1);
1232 MoveWindow(hVarTree_This,
1233 rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,1);
1234
1235 pos_WatchList.x=pos_VarList.x+width_VarList+LEVER_THICK;
1236 pos_WatchList.y=0;
1237
1238 //ウォッチリストの位置
1239 MoveWindow(GetDlgItem(hwnd,IDC_WATCHLIST),
1240 pos_WatchList.x,
1241 pos_WatchList.y,
1242 LOWORD(lParam)-pos_WatchList.x,
1243 HIWORD(lParam)-pos_WatchList.y,
1244 1);
1245
1246 return 1;
1247
1248 case WM_VARLIST_CLOSE:
1249 DestroyWindow(hwnd);
1250 return 1;
1251 case WM_DESTROY:
1252 ImageList_Destroy(hVariOrderImageList);
1253
1254
1255 //////////////////////////////////////////////////////////////
1256 // ウォッチリストの以前の内容を破棄し、新しい内容に書き換える
1257 //////////////////////////////////////////////////////////////
1258
1259 for(i=0;i<pobj_nv->WatchNum;i++){
1260 HeapDefaultFree(pobj_nv->ppWatchStr[i]);
1261 }
1262 HeapDefaultFree(pobj_nv->ppWatchStr);
1263
1264 pobj_nv->WatchNum=ListView_GetItemCount(hListView)-1;
1265 pobj_nv->ppWatchStr=(char **)HeapAlloc(hHeap,0,pobj_nv->WatchNum*sizeof(char *)+1);
1266 for(i=0;i<pobj_nv->WatchNum;i++){
1267 ListView_GetItemText(hListView,i,0,temporary,VN_SIZE);
1268 pobj_nv->ppWatchStr[i]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
1269 lstrcpy(pobj_nv->ppWatchStr[i],temporary);
1270 }
1271
1272
1273 //////////////////////////////
1274 // デバッグダイアログを破棄
1275 //////////////////////////////
1276
1277 hDebugWnd=0;
1278
1279 if( program.IsClipCompileView() ){
1280 extern HWND hOwnerEditor;
1281 SendMessage(hOwnerEditor,WM_DESTROYDEBUGGERVIEW,0,0);
1282 }
1283
1284 return 1;
1285
1286
1287
1288 ///////////////////////
1289 // デバッグコマンド
1290 ///////////////////////
1291
1292 case WM_DEBUG_CONTINUE:
1293 DestroyWindow(hwnd);
1294 return 1;
1295 case WM_STEP_IN:
1296 Debugger_StepIn();
1297 return 1;
1298 case WM_STEP_OVER:
1299 Debugger_StepOver();
1300 return 1;
1301 case WM_STEP_CURSOR:
1302 Debugger_StepCursor();
1303 return 1;
1304 }
1305 return 0;
1306}
1307
1308
1309
1310
1311//////////////////////////////////
1312// ポップアップ表示の変数リスト
1313//////////////////////////////////
1314
1315BOOL CALLBACK DlgVarList(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
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.