source: dev/BasicCompiler32/Compile_Var.cpp@ 47

Last change on this file since 47 was 40, checked in by dai_9181, 18 years ago

ByRef修飾子を関数戻り値とDimステートメントで指定可能にした。

File size: 32.0 KB
Line 
1#include "../BasicCompiler_Common/common.h"
2#include "Opcode.h"
3
4//変数
5VARIABLE *GlobalVar;
6int MaxGlobalVarNum;
7int AllGlobalVarSize;
8int AllInitGlobalVarSize;
9VARIABLE *LocalVar;
10int MaxLocalVarNum;
11int AllLocalVarSize;
12
13void SetRelativeOffset(int *pType,LONG_PTR lpIndex,RELATIVE_VAR *pRelativeVar,char *lpPtrOffset){
14 int i2;
15
16 PushLongVariable(pRelativeVar);
17
18 i2=NumOpe(lpPtrOffset,0,0,0);
19 ChangeTypeToLong(i2);
20
21 //pop ebx
22 op_pop(REG_EBX);
23
24 if(PTR_LEVEL(*pType)){
25 *pType=MAKE_PTR_TYPE(NATURAL_TYPE(*pType),PTR_LEVEL(*pType)-1);
26 if((*pType)==DEF_OBJECT){
27 //imul ebx,objsize
28 OpBuffer[obp++]=(char)0x69;
29 OpBuffer[obp++]=(char)0xDB;
30 *((long *)(OpBuffer+obp))=GetSizeOfClassMember((CClass *)lpIndex,NULL,NULL);
31 obp+=sizeof(long);
32 }
33 else{
34 i2=GetTypeSize(*pType,-1);
35 if(i2>=2){
36 //imul ebx,i2
37 OpBuffer[obp++]=(char)0x6B;
38 OpBuffer[obp++]=(char)0xDB;
39 OpBuffer[obp++]=(char)i2;
40 }
41 }
42 }
43 else{
44 //エラー
45 SetError(1,NULL,cp);
46 return;
47 }
48
49 //pop ecx
50 op_pop(REG_ECX);
51
52 //add ecx,ebx
53 OpBuffer[obp++]=(char)0x03;
54 OpBuffer[obp++]=(char)0xCB;
55}
56BOOL GetArrayOffset(int *SubScripts,char *array,int type,LONG_PTR lpIndex){
57 extern HANDLE hHeap;
58 int i,i2,i3,i4,TypeSize;
59 char temporary[VN_SIZE],*pParm[MAX_PARMS];
60
61 for(i=0,i2=0,i3=0;;i++,i2++){
62 if(array[i]=='('){
63 i4=GetStringInPare(temporary+i2,array+i);
64 i+=i4-1;
65 i2+=i4-1;
66 continue;
67 }
68 if(array[i]=='['){
69 i4=GetStringInBracket(temporary+i2,array+i);
70 i+=i4-1;
71 i2+=i4-1;
72 continue;
73 }
74 if(array[i]==','||array[i]=='\0'){
75 if(SubScripts[i3]==-1){
76 for(i3--;i3>=0;i3--) HeapDefaultFree(pParm[i3]);
77 return 0;
78 }
79
80 temporary[i2]=0;
81
82 pParm[i3]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
83 lstrcpy(pParm[i3],temporary);
84
85 i3++;
86
87 if(array[i]=='\0'){
88 if(SubScripts[i3]!=-1){
89 for(i3--;i3>=0;i3--) HeapDefaultFree(pParm[i3]);
90 return 0;
91 }
92 break;
93 }
94
95 i2=-1;
96 continue;
97 }
98 temporary[i2]=array[i];
99 }
100
101 //push ecx
102 op_push(REG_ECX);
103
104 //push 0
105 op_push_value(0);
106
107 for(i=i3-1;i>=0;i--){
108 TYPEINFO TypeInfo;
109 BOOL bUseHeap;
110 TypeInfo.type=NumOpe(pParm[i],DEF_LONG,-1,&TypeInfo.u.lpIndex,&bUseHeap);
111 if(TypeInfo.type==DEF_OBJECT){
112 //キャスト演算子のオーバーロードに対応する
113 CallCastOperatorProc(
114 TypeInfo.type,TypeInfo.u.lpIndex,
115 bUseHeap,DEF_LONG,-1);
116 TypeInfo.type=DEF_LONG;
117 }
118 ChangeTypeToLong(TypeInfo.type);
119
120 //pop eax
121 op_pop(REG_EAX);
122
123 for(i2=i+1,i4=1;i2<i3;i2++) i4*=SubScripts[i2]+1;
124
125 //imul eax,i4
126 OpBuffer[obp++]=(char)0x69;
127 OpBuffer[obp++]=(char)0xC0;
128 *((long *)(OpBuffer+obp))=i4;
129 obp+=sizeof(long);
130
131 //add dword ptr[esp],eax
132 OpBuffer[obp++]=(char)0x01;
133 OpBuffer[obp++]=(char)0x04;
134 OpBuffer[obp++]=(char)0x24;
135
136 HeapDefaultFree(pParm[i]);
137 }
138
139 //pop eax
140 op_pop(REG_EAX);
141
142 TypeSize=GetTypeSize(type,lpIndex);
143
144 //imul eax,TypeSize
145 OpBuffer[obp++]=(char)0x69;
146 OpBuffer[obp++]=(char)0xC0;
147 *((long *)(OpBuffer+obp))=TypeSize;
148 obp+=sizeof(long);
149
150 //pop ecx
151 op_pop(REG_ECX);
152
153 //add ecx,eax
154 OpBuffer[obp++]=(char)0x03;
155 OpBuffer[obp++]=(char)0xC8;
156
157 return 1;
158}
159BOOL GetMemberOffset(bool isErrorEnabled, bool isWriteAccess, CClass *pobj_c, char *member, int *pType, RELATIVE_VAR *pRelativeVar, LONG_PTR *plpNestIndex, BOOL bPrivateAccess){
160 int i,offset;
161
162 //クラス、配列の構成要素を解析する
163 char VarName[VN_SIZE]; //変数名
164 char array[VN_SIZE]; //第1次配列
165 char lpPtrOffset[VN_SIZE]; //第2次配列
166 char NestMember[VN_SIZE]; //入れ子メンバ
167 int RefType; //"."参照のときは0、"->"参照のときは1
168 lstrcpy(VarName,member);
169 if(!GetVarFormatString(VarName,array,lpPtrOffset,NestMember,&RefType)) return 0;
170
171 ////////////////////////////
172 // メンバオフセットを取得
173 ////////////////////////////
174
175 offset=GetSizeOfClassMember(pobj_c,VarName,&i);
176 if(i==pobj_c->iMemberNum){
177 if(isErrorEnabled) SetError(103,VarName,cp);
178 return 0;
179 }
180
181 CMember *pMember=pobj_c->ppobj_Member[i];
182
183 //アクセシビリティをチェック
184 if(pobj_c==pobj_CompilingClass){
185 //同一クラスオブジェクトの場合はプライベートアクセスを容認する
186 if(pMember->dwAccess==ACCESS_NON){
187 if(isErrorEnabled) SetError(107,VarName,cp);
188 return 0;
189 }
190 }
191 else{
192 if((bPrivateAccess==0&&pMember->dwAccess==ACCESS_PRIVATE)||
193 pMember->dwAccess==ACCESS_NON){
194 if(isErrorEnabled) SetError(107,VarName,cp);
195 return 0;
196 }
197 else if(bPrivateAccess==0&&pMember->dwAccess==ACCESS_PROTECTED){
198 if(isErrorEnabled) SetError(108,VarName,cp);
199 return 0;
200 }
201 }
202
203 //Const定義の場合は書き込みアクセスを制限する
204 //※コンストラクタをコンパイル中の場合は例外的に許可する
205 if( pMember->IsConst() && //定数メンバである
206 isWriteAccess && //書き込みアクセスを要求されている
207 pobj_c->IsCompilingConstructor() == false //コンストラクタ コンパイル中を除く
208 ){
209 //Const定義の変数に書き込みアクセスをしようとした場合
210 SetError(61,VarName,cp);
211 }
212
213 *pType=pMember->TypeInfo.type;
214 *plpNestIndex=pMember->TypeInfo.u.lpIndex;
215
216 //ポインタ変数の場合
217 if(IsPtrType(*pType)){
218 if(pMember->SubScripts[0]==-1){
219 lstrcpy(lpPtrOffset,array);
220 array[0]=0;
221 }
222 }
223 else{
224 if(lpPtrOffset[0]){
225 if(isErrorEnabled) SetError(16,member,cp);
226 return 0;
227 }
228 }
229
230 if(offset){
231 //add ecx,offset
232 OpBuffer[obp++]=(char)0x81;
233 OpBuffer[obp++]=(char)0xC1;
234 *((long *)(OpBuffer+obp))=offset;
235 obp+=sizeof(long);
236 }
237
238 if(array[0]){
239 //配列オフセット
240 if(!GetArrayOffset(pMember->SubScripts,array,*pType,pMember->TypeInfo.u.lpIndex))
241 if(isErrorEnabled) SetError(14,member,cp);
242 }
243 else if(pMember->SubScripts[0]!=-1){
244 *pType|=FLAG_PTR;
245 }
246
247 if(NestMember[0]){
248 //入れ子構造の場合
249
250 if(*pType==DEF_OBJECT){
251 if(RefType!=DEF_OBJECT){
252 if(isErrorEnabled) SetError(104,member,cp);
253 return 0;
254 }
255 }
256 else if(*pType==DEF_PTR_OBJECT){
257 //構造体ポインタ型メンバ変数
258
259 if(lpPtrOffset[0]){
260 //pObj[n].member
261 if(RefType!=DEF_OBJECT){
262 if(isErrorEnabled) SetError(104,member,cp);
263 return 0;
264 }
265
266 //直接参照に切り替え
267 SetRelativeOffset(pType,*plpNestIndex,pRelativeVar,lpPtrOffset);
268 pRelativeVar->dwKind=VAR_DIRECTMEM;
269
270 lpPtrOffset[0]=0;
271 }
272 else{
273 //pObj->member
274 if(RefType!=DEF_PTR_OBJECT){
275 if(isErrorEnabled) SetError(104,member,cp);
276 return 0;
277 }
278
279 if(pRelativeVar->dwKind==VAR_DIRECTMEM){
280 //mov ecx,dword ptr[ecx]
281 OpBuffer[obp++]=(char)0x8B;
282 OpBuffer[obp++]=(char)0x09;
283 }
284 else{
285 //直接参照に切り替え
286 SetVarPtrToEax(pRelativeVar);
287 pRelativeVar->dwKind=VAR_DIRECTMEM;
288
289 //mov ecx,dword ptr[eax]
290 OpBuffer[obp++]=(char)0x8B;
291 OpBuffer[obp++]=(char)0x08;
292 }
293 }
294 }
295 else if(*pType==MAKE_PTR_TYPE(DEF_OBJECT,2)){
296 //構造体ポインタのポインタ型メンバ変数
297
298 if(lpPtrOffset[0]){
299 //ppObj[n]->member
300 if(RefType!=DEF_PTR_OBJECT){
301 if(isErrorEnabled) SetError(104,member,cp);
302 return 0;
303 }
304
305 //直接参照に切り替え
306 SetRelativeOffset(pType,*plpNestIndex,pRelativeVar,lpPtrOffset);
307 pRelativeVar->dwKind=VAR_DIRECTMEM;
308
309 lpPtrOffset[0]=0;
310
311 //mov ecx,dword ptr[ecx]
312 OpBuffer[obp++]=(char)0x8B;
313 OpBuffer[obp++]=(char)0x09;
314 }
315 else{
316 if(isErrorEnabled) SetError(104,member,cp);
317 return 0;
318 }
319 }
320
321 if(!GetMemberOffset(
322 isErrorEnabled,
323 isWriteAccess,
324 pMember->TypeInfo.u.pobj_Class,
325 NestMember,
326 pType,
327 pRelativeVar,
328 plpNestIndex,
329 0)) return 0;
330 }
331
332 if(lpPtrOffset[0]){
333 SetRelativeOffset(pType,*plpNestIndex,pRelativeVar,lpPtrOffset);
334 pRelativeVar->dwKind=VAR_DIRECTMEM;
335 }
336
337 return 1;
338}
339void GetWithName(char *buffer){
340 extern WITHINFO WithInfo;
341 int i;
342
343 buffer[0]=0;
344 for(i=0;i<WithInfo.num;i++)
345 lstrcat(buffer,WithInfo.ppName[i]);
346}
347
348int LocalVar_ThisPtrOffset;
349void SetThisPtrToReg(int reg){
350 //自身のオブジェクトのThisポインタをregにコピー
351
352 extern VARIABLE *LocalVar;
353 RELATIVE_VAR RelativeVar;
354 RelativeVar.dwKind=VAR_LOCAL;
355 RelativeVar.bOffsetOffset=0;
356 RelativeVar.offset=-LocalVar_ThisPtrOffset;
357
358 SetReg_WholeVariable(DEF_PTR_VOID,&RelativeVar,reg);
359}
360
361BOOL GetVarOffset(bool isErrorEnabled, bool isWriteAccess, const char *NameBuffer, int *pType, RELATIVE_VAR *pRelativeVar, LONG_PTR *plpIndex, int *pss){
362 extern BOOL bCompilingGlobal;
363 int i,RefType;
364 char variable[VN_SIZE],member[VN_SIZE],VarName[VN_SIZE],array[VN_SIZE],lpPtrOffset[VN_SIZE];
365
366 if(NameBuffer[0]=='.'){
367 GetWithName(variable);
368 lstrcat(variable,NameBuffer);
369 }
370 else lstrcpy(variable,NameBuffer);
371
372 lstrcpy(VarName,variable);
373 GetVarFormatString(VarName,array,lpPtrOffset,member,&RefType);
374
375 LONG_PTR lpIndex;
376 int *pSubScripts;
377 bool bConst;
378
379 if(bCompilingGlobal==0){
380 ////////////////////
381 // ローカル変数
382 ////////////////////
383
384 for(i=MaxLocalVarNum-1;i>=0;i--){ //レキシカルスコープを考慮してバックサーチ
385 if( LocalVar[i].bLiving //現在のスコープで有効なもの
386 && LocalVar[i].ScopeLevel <= obj_LexScopes.GetNowLevel() //現在のスコープレベルを超さないもの(Returnによる解放処理中を考慮)
387 ){
388 if(lstrcmp(VarName,LocalVar[i].name)==0) break;
389 }
390 }
391 if(i>=0){
392 //ポインタ変数の場合
393 if(IsPtrType(LocalVar[i].type)){
394 if(LocalVar[i].SubScripts[0]==-1){
395 lstrcpy(lpPtrOffset,array);
396 array[0]=0;
397 }
398 }
399 else{
400 if(lpPtrOffset[0]){
401 SetError(16,variable,cp);
402 pRelativeVar->dwKind=NON_VAR;
403 return 0;
404 }
405 }
406
407 pRelativeVar->offset=-LocalVar[i].offset;
408 pRelativeVar->bOffsetOffset=0;
409 if(LocalVar[i].fRef) pRelativeVar->dwKind=VAR_REFLOCAL;
410 else pRelativeVar->dwKind=VAR_LOCAL;
411 *pType=LocalVar[i].type;
412 lpIndex=LocalVar[i].u.index;
413 if(plpIndex) *plpIndex=lpIndex;
414 pSubScripts=LocalVar[i].SubScripts;
415 bConst = LocalVar[i].bConst;
416
417 goto ok;
418 }
419 }
420
421 if(pobj_CompilingClass){
422 //////////////////////
423 // クラスメンバの参照
424 //////////////////////
425
426 if(lstrcmpi(variable,"This")==0){
427 //Thisオブジェクト
428
429 //Thisポインタをecxにコピー
430 SetThisPtrToReg(REG_ECX);
431
432 *pType=DEF_OBJECT;
433 pRelativeVar->dwKind=VAR_DIRECTMEM;
434
435 if(plpIndex) *plpIndex=(LONG_PTR)pobj_CompilingClass;
436 return 1;
437 }
438
439 if(_memicmp(variable,"This.",5)==0){
440 //Thisオブジェクトのメンバを参照するとき
441 SlideString(variable+5,-5);
442 lstrcpy(VarName,variable);
443 }
444 else{
445 //クラス内メンバを参照するとき(通常)
446
447 for(i=0;i<pobj_CompilingClass->iMemberNum;i++){
448 if(lstrcmp(VarName,pobj_CompilingClass->ppobj_Member[i]->name)==0) break;
449 }
450 if(i==pobj_CompilingClass->iMemberNum) goto NonClassMember;
451 }
452
453 //Const修飾子のメソッド内でメンバ書き込みアクセスが発生したとき
454 //(コンストラクタ、デストラクタ内を除く)
455 CMethod *pMethod = pobj_DBClass->GetNowCompilingMethodInfo();
456 if( isWriteAccess &&
457 pMethod->isConst &&
458 pobj_CompilingClass->IsCompilingConstructor() == false &&
459 pobj_CompilingClass->IsCompilingDestructor() == false
460 ){
461 SetError(131, NULL, cp );
462 }
463
464 /////////////////////////////
465 // thisポインタをecxにセット
466
467 //Thisポインタをecxにコピー
468 SetThisPtrToReg(REG_ECX);
469
470 pRelativeVar->dwKind=VAR_DIRECTMEM;
471 if(!GetMemberOffset(
472 isErrorEnabled,
473 isWriteAccess,
474 pobj_CompilingClass,
475 variable,
476 pType,
477 pRelativeVar,
478 &lpIndex,1)) return 0;
479 if(plpIndex) *plpIndex=lpIndex;
480 return 1;
481 }
482
483NonClassMember:
484
485 //////////////////////////
486 // 静的ローカル変数
487 // ※"Static.Object.Method.Variable"
488 //////////////////////////
489
490 char temporary[VN_SIZE];
491 extern SUBINFO *pCompilingSubInfo;
492 if(pCompilingSubInfo){
493 GetNowStaticVarFullName(VarName,temporary);
494
495 for(i=0;i<MaxGlobalVarNum;i++){
496 if(lstrcmp(temporary,GlobalVar[i].name)==0) break;
497 }
498 if(i!=MaxGlobalVarNum){
499 goto GlobalOk;
500 }
501 }
502
503
504 //////////////////////////
505 // クラスの静的メンバ
506 //////////////////////////
507
508 if(member[0]){
509 lstrcpy(temporary,member);
510 char tempMember[VN_SIZE];
511 char tempArray[VN_SIZE];
512 GetVarFormatString(temporary,tempArray,lpPtrOffset,tempMember,&i);
513
514 char temp2[VN_SIZE];
515 sprintf(temp2,"%s.%s",VarName,temporary);
516 for(i=0;i<MaxGlobalVarNum;i++){
517 if(lstrcmp(temp2,GlobalVar[i].name)==0) break;
518 }
519
520 if(i!=MaxGlobalVarNum){
521 lstrcpy(member,tempMember);
522 lstrcpy(array,tempArray);
523 goto GlobalOk;
524 }
525 }
526
527 if(pobj_CompilingClass){
528 //自身のクラスから静的メンバを参照する場合
529 char temp2[VN_SIZE];
530 sprintf(temp2,"%s.%s",pobj_CompilingClass->name,VarName);
531 for(i=0;i<MaxGlobalVarNum;i++){
532 if(lstrcmp(temp2,GlobalVar[i].name)==0) break;
533 }
534
535 if(i!=MaxGlobalVarNum){
536 goto GlobalOk;
537 }
538 }
539
540
541 ////////////////////
542 // グローバル変数
543 ////////////////////
544
545 for(i=MaxGlobalVarNum-1;i>=0;i--){ //レキシカルスコープを考慮してバックサーチ
546 if( GlobalVar[i].bLiving //現在のスコープで有効なもの
547 && GlobalVar[i].ScopeLevel <= obj_LexScopes.GetNowLevel() //現在のスコープレベルを超さないもの(Returnによる解放処理中を考慮)
548 ){
549 if(lstrcmp(VarName,GlobalVar[i].name)==0) break;
550 }
551 }
552 if(i>=0){
553 goto GlobalOk;
554 }
555
556
557 if(isErrorEnabled) SetError(3,variable,cp);
558 pRelativeVar->dwKind=NON_VAR;
559 return 0;
560
561
562GlobalOk:
563
564 //ポインタ変数の場合
565 if(IsPtrType(GlobalVar[i].type)){
566 if(GlobalVar[i].SubScripts[0]==-1){
567 lstrcpy(lpPtrOffset,array);
568 array[0]=0;
569 }
570 }
571 else{
572 if(lpPtrOffset[0]){
573 SetError(16,variable,cp);
574 pRelativeVar->dwKind=NON_VAR;
575 return 0;
576 }
577 }
578
579 pRelativeVar->offset=GlobalVar[i].offset;
580 pRelativeVar->bOffsetOffset=0;
581 pRelativeVar->dwKind=VAR_GLOBAL;
582 *pType=GlobalVar[i].type;
583 lpIndex=GlobalVar[i].u.index;
584 if(plpIndex) *plpIndex=lpIndex;
585 pSubScripts=GlobalVar[i].SubScripts;
586 bConst = GlobalVar[i].bConst;
587
588
589ok:
590
591 if( bConst && isWriteAccess ){
592 //Const定義の変数に書き込みアクセスをしようとした場合
593 if( *pType == DEF_OBJECT ){
594 //オブジェクト定数
595 SetError(130, VarName, cp );
596 }
597 else{
598 //一般のConst変数
599 SetError(61,VarName,cp);
600 }
601 }
602
603 if(array[0]==0&&pSubScripts[0]!=-1){
604 //配列の先頭ポインタを示す場合
605 *pType|=FLAG_PTR;
606 if(pss) memcpy(pss,pSubScripts,MAX_ARRAYDIM);
607 return 1;
608 }
609
610 if(array[0]||member[0]){
611 //xor ecx,ecx(ecxを0に初期化する)
612 //※ecxは変数ベースアドレスからの相対オフセットを示す
613 op_zero_reg(REG_ECX);
614
615 pRelativeVar->bOffsetOffset=1;
616 }
617 if(array[0]){
618 if(!GetArrayOffset(pSubScripts,array,*pType,lpIndex)){
619 SetError(14,variable,cp);
620 pRelativeVar->dwKind=NON_VAR;
621 return 0;
622 }
623 }
624 if(member[0]){
625 if(*pType==DEF_OBJECT){
626 //実態オブジェクトのメンバを参照(obj.member)
627 if(RefType!=DEF_OBJECT){
628 SetError(104,VarName,cp);
629 pRelativeVar->dwKind=NON_VAR;
630 return 0;
631 }
632 }
633 else if(*pType==DEF_PTR_OBJECT){
634 //ポインタオブジェクトが示すメンバを参照
635 if(lpPtrOffset[0]){
636 //pObj[n].member
637 if(RefType!=DEF_OBJECT){
638 SetError(104,VarName,cp);
639 pRelativeVar->dwKind=NON_VAR;
640 return 0;
641 }
642 SetRelativeOffset(pType,lpIndex,pRelativeVar,lpPtrOffset);
643 pRelativeVar->dwKind=VAR_DIRECTMEM;
644 }
645 else{
646 //pObj->member
647 if(RefType!=DEF_PTR_OBJECT){
648 SetError(104,VarName,cp);
649 pRelativeVar->dwKind=NON_VAR;
650 return 0;
651 }
652
653 SetVarPtrToEax(pRelativeVar);
654 pRelativeVar->dwKind=VAR_DIRECTMEM;
655
656 //mov ecx,dword ptr[eax]
657 OpBuffer[obp++]=(char)0x8B;
658 OpBuffer[obp++]=(char)0x08;
659 }
660 }
661 else if(*pType==MAKE_PTR_TYPE(DEF_OBJECT,2)){
662 //ポインタオブジェクトが示すメンバを参照
663 if(lpPtrOffset[0]){
664 //ppObj[n]->member
665 if(RefType!=DEF_PTR_OBJECT){
666 SetError(104,VarName,cp);
667 pRelativeVar->dwKind=NON_VAR;
668 return 0;
669 }
670
671 SetRelativeOffset(pType,lpIndex,pRelativeVar,lpPtrOffset);
672 pRelativeVar->dwKind=VAR_DIRECTMEM;
673
674
675 SetVarPtrToEax(pRelativeVar);
676
677 //mov ecx,dword ptr[eax]
678 OpBuffer[obp++]=(char)0x8B;
679 OpBuffer[obp++]=(char)0x08;
680 }
681 else{
682 SetError(104,VarName,cp);
683 pRelativeVar->dwKind=NON_VAR;
684 return 0;
685 }
686 }
687 else{
688 SetError(102,VarName,cp);
689 pRelativeVar->dwKind=NON_VAR;
690 return 0;
691 }
692
693 LONG_PTR lp2;
694 if(!GetMemberOffset(
695 isErrorEnabled,
696 isWriteAccess,
697 (CClass *)lpIndex,
698 member,pType,pRelativeVar,&lp2,0)) return 0;
699 if(plpIndex) *plpIndex=lp2;
700
701 return 1;
702 }
703
704 if(lpPtrOffset[0]){
705 SetRelativeOffset(pType,lpIndex,pRelativeVar,lpPtrOffset);
706 pRelativeVar->dwKind=VAR_DIRECTMEM;
707 }
708
709 return 1;
710}
711
712BOOL SetInitGlobalData(int offset,int type,LONG_PTR lpIndex,int *SubScripts,char *InitBuf){
713 extern BYTE *initGlobalBuf;
714 int i,i2,i3,TypeSize;
715 char temporary[VN_SIZE];
716
717 if(InitBuf[0]=='['){
718 SlideString(InitBuf+1,-1);
719 InitBuf[lstrlen(InitBuf)-1]=0;
720
721 TypeSize=GetTypeSize(type,lpIndex);
722
723 if(SubScripts[0]!=-1){
724 TypeSize*=JumpSubScripts(SubScripts+1);
725 i=0;
726 i2=0;
727 while(1){
728 if(SubScripts[0]<i2){
729 SetError(41,0,cp);
730 return 0;
731 }
732 i=GetOneParameter(InitBuf,i,temporary);
733 if(!SetInitGlobalData(
734 offset+i2*TypeSize,
735 type,
736 lpIndex,
737 SubScripts+1,
738 temporary)) return 0;
739 i2++;
740 if(InitBuf[i]=='\0') break;
741 }
742 return -1;
743 }
744
745 if(type==DEF_OBJECT){
746 CClass *pobj_c;
747 pobj_c=(CClass *)lpIndex;
748
749 for(i=0,i2=0;i2<pobj_c->iMemberNum;i2++){
750 i=GetOneParameter(InitBuf,i,temporary);
751
752 i3=GetSizeOfClassMember(pobj_c,pobj_c->ppobj_Member[i2]->name,NULL);
753
754 if(!SetInitGlobalData(offset+i3,
755 pobj_c->ppobj_Member[i2]->TypeInfo.type,
756 pobj_c->ppobj_Member[i2]->TypeInfo.u.lpIndex,
757 pobj_c->ppobj_Member[i2]->SubScripts,
758 temporary)) return 0;
759
760 if(InitBuf[i]=='\0') break;
761 }
762 if(i2+1!=pobj_c->iMemberNum){
763 SetError(41,0,cp);
764 return 0;
765 }
766 return 1;
767 }
768
769 SetError(41,0,cp);
770 return 0;
771 }
772
773
774 ///////////////////////////////////////
775 // 単発式([]で囲まれていない)
776 ///////////////////////////////////////
777
778 if( type == DEF_OBJECT){
779 //オブジェクトの場合はありえない
780 SetError(300,NULL,cp);
781 return 0;
782 }
783
784 if(SubScripts[0]!=-1){
785 SetError(41,0,cp);
786 return 0;
787 }
788
789 double dbl;
790 _int64 i64data;
791 int CalcType;
792 LONG_PTR lpCalcIndex;
793 CalcType=StaticCalculation(true, InitBuf,type,&i64data,&lpCalcIndex);
794 if(IsRealNumberType(CalcType)){
795 memcpy(&dbl,&i64data,sizeof(double));
796 i64data=(_int64)dbl;
797 }
798 else dbl=(double)i64data;
799
800 //型チェック
801 CheckDifferentType(
802 type,
803 lpIndex,
804 CalcType,
805 lpCalcIndex,
806 0,0);
807
808 if(type==DEF_DOUBLE)
809 *(double *)(initGlobalBuf+offset)=(double)dbl;
810 else if(type==DEF_SINGLE)
811 *(float *)(initGlobalBuf+offset)=(float)dbl;
812 else if(type==DEF_INT64||type==DEF_QWORD)
813 *(_int64 *)(initGlobalBuf+offset)=i64data;
814 else if(type==DEF_LONG||type==DEF_DWORD||IsPtrType(type)){
815 if(type==DEF_PTR_BYTE&&lpCalcIndex==LITERAL_STRING){
816 //文字列定数のとき
817
818 char *temp;
819 temp=(char *)i64data;
820 i2=AddDataTable(temp,lstrlen(temp));
821 HeapDefaultFree(temp);
822
823 //mov eax,DataPos
824 OpBuffer[obp++]=(char)0xB8;
825 *((long *)(OpBuffer+obp))=(long)i2;
826 pobj_DataTableSchedule->add();
827 obp+=sizeof(long);
828
829 //mov dword ptr[offset],eax
830 OpBuffer[obp++]=(char)0xA3;
831 *((long *)(OpBuffer+obp))=offset;
832 pobj_GlobalVarSchedule->add();
833 obp+=sizeof(long);
834 }
835 else{
836 *(DWORD *)(initGlobalBuf+offset)=(DWORD)i64data;
837 }
838 }
839 else if(type==DEF_INTEGER||type==DEF_WORD)
840 *(WORD *)(initGlobalBuf+offset)=(WORD)i64data;
841 else if(type==DEF_CHAR||type==DEF_BYTE||type==DEF_BOOLEAN)
842 *(BYTE *)(initGlobalBuf+offset)=(BYTE)i64data;
843 //String型が未完成
844 return 1;
845}
846BOOL InitLocalVar(int offset,int type,LONG_PTR lpIndex,int *SubScripts,char *InitBuf){
847 int i,i2,i3,TypeSize;
848 char temporary[VN_SIZE];
849
850 if(InitBuf[0]=='['){
851 SlideString(InitBuf+1,-1);
852 InitBuf[lstrlen(InitBuf)-1]=0;
853
854 TypeSize=GetTypeSize(type,lpIndex);
855
856 if(SubScripts[0]!=-1){
857 TypeSize*=JumpSubScripts(SubScripts+1);
858 i=0;
859 i2=0;
860 while(1){
861 if(SubScripts[0]<i2){
862 SetError(41,0,cp);
863 return 0;
864 }
865 i=GetOneParameter(InitBuf,i,temporary);
866 if(!InitLocalVar(
867 offset+i2*TypeSize,
868 type,
869 lpIndex,
870 SubScripts+1,
871 temporary)) return 0;
872 i2++;
873 if(InitBuf[i]=='\0') break;
874 }
875 return -1;
876 }
877
878 if(type==DEF_OBJECT){
879 CClass *pobj_c;
880 pobj_c=(CClass *)lpIndex;
881
882 for(i=0,i2=0;i2<pobj_c->iMemberNum;i2++){
883 i=GetOneParameter(InitBuf,i,temporary);
884
885 i3=GetSizeOfClassMember(pobj_c,pobj_c->ppobj_Member[i2]->name,NULL);
886
887 if(!InitLocalVar(offset+i3,
888 pobj_c->ppobj_Member[i2]->TypeInfo.type,
889 pobj_c->ppobj_Member[i2]->TypeInfo.u.lpIndex,
890 pobj_c->ppobj_Member[i2]->SubScripts,
891 temporary)) return 0;
892
893 if(InitBuf[i]=='\0') break;
894 }
895 if(i2+1!=pobj_c->iMemberNum){
896 SetError(41,0,cp);
897 return 0;
898 }
899 return 1;
900 }
901
902 SetError(41,0,cp);
903 return 0;
904 }
905
906
907 ///////////////////////////////////////
908 // 単発式([]で囲まれていない)
909 ///////////////////////////////////////
910
911 if(SubScripts[0]!=-1){
912 SetError(41,0,cp);
913 return 0;
914 }
915
916 double dbl;
917 _int64 i64data;
918 int CalcType;
919 LONG_PTR lpCalcIndex;
920 CalcType=StaticCalculation(false, InitBuf,type,&i64data,&lpCalcIndex);
921 if(!CalcType){
922 //動的データだった場合
923 return 0;
924 }
925 if(IsRealNumberType(CalcType)){
926 memcpy(&dbl,&i64data,sizeof(double));
927 i64data=(_int64)dbl;
928 }
929 else dbl=(double)i64data;
930
931 //型チェック
932 CheckDifferentType(
933 type,
934 lpIndex,
935 CalcType,
936 lpCalcIndex,
937 0,0);
938
939 if(type==DEF_DOUBLE){
940 //mov eax,HILONG(dbl)
941 OpBuffer[obp++]=(char)0xB8;
942 *((long *)(OpBuffer+obp))=(long)*(long *)(((char *)(&dbl))+4);
943 obp+=sizeof(long);
944
945 //mov dword ptr[ebp+offset+sizeof(long)],eax
946 OpBuffer[obp++]=(char)0x89;
947 OpBuffer[obp++]=(char)0x85;
948 *((long *)(OpBuffer+obp))=offset+sizeof(long);
949 AddLocalVarAddrSchedule();
950 obp+=sizeof(long);
951
952 //mov eax,LOLONG(dbl)
953 OpBuffer[obp++]=(char)0xB8;
954 *((long *)(OpBuffer+obp))=*(long *)(&dbl);
955 obp+=sizeof(long);
956
957 //mov dword ptr[ebp+offset],eax
958 OpBuffer[obp++]=(char)0x89;
959 OpBuffer[obp++]=(char)0x85;
960 *((long *)(OpBuffer+obp))=offset;
961 AddLocalVarAddrSchedule();
962 obp+=sizeof(long);
963 }
964 else if(type==DEF_SINGLE){
965 float flt;
966 flt=(float)dbl;
967 //mov eax,InitValue
968 OpBuffer[obp++]=(char)0xB8;
969 *((long *)(OpBuffer+obp))=*(long *)&flt;
970 obp+=sizeof(long);
971
972 //mov dword ptr[ebp+offset],eax
973 OpBuffer[obp++]=(char)0x89;
974 OpBuffer[obp++]=(char)0x85;
975 *((long *)(OpBuffer+obp))=offset;
976 AddLocalVarAddrSchedule();
977 obp+=sizeof(long);
978 }
979 else if(type==DEF_INT64||type==DEF_QWORD){
980 //mov eax,HILONG(i64data)
981 OpBuffer[obp++]=(char)0xB8;
982 *((long *)(OpBuffer+obp))=(long)*(long *)(((char *)(&i64data))+4);
983 obp+=sizeof(long);
984
985 //mov dword ptr[ebp+offset+sizeof(long)],eax
986 OpBuffer[obp++]=(char)0x89;
987 OpBuffer[obp++]=(char)0x85;
988 *((long *)(OpBuffer+obp))=offset+sizeof(long);
989 AddLocalVarAddrSchedule();
990 obp+=sizeof(long);
991
992 //mov eax,LOLONG(i64data)
993 OpBuffer[obp++]=(char)0xB8;
994 *((long *)(OpBuffer+obp))=*(long *)(&i64data);
995 obp+=sizeof(long);
996
997 //mov dword ptr[ebp+offset],eax
998 OpBuffer[obp++]=(char)0x89;
999 OpBuffer[obp++]=(char)0x85;
1000 *((long *)(OpBuffer+obp))=offset;
1001 AddLocalVarAddrSchedule();
1002 obp+=sizeof(long);
1003 }
1004 else if(type==DEF_LONG||type==DEF_DWORD||IsPtrType(type)){
1005 if(type==DEF_PTR_BYTE&&lpCalcIndex==LITERAL_STRING){
1006 //文字列定数のとき
1007
1008 char *temp;
1009 temp=(char *)i64data;
1010 i2=AddDataTable(temp,lstrlen(temp));
1011 HeapDefaultFree(temp);
1012
1013 //mov eax,DataPos
1014 OpBuffer[obp++]=(char)0xB8;
1015 *((long *)(OpBuffer+obp))=(long)i2;
1016 pobj_DataTableSchedule->add();
1017 obp+=sizeof(long);
1018 }
1019 else{
1020 //mov eax,InitValue
1021 OpBuffer[obp++]=(char)0xB8;
1022 *((long *)(OpBuffer+obp))=(long)i64data;
1023 obp+=sizeof(long);
1024 }
1025
1026 //mov dword ptr[ebp+offset],eax
1027 OpBuffer[obp++]=(char)0x89;
1028 OpBuffer[obp++]=(char)0x85;
1029 *((long *)(OpBuffer+obp))=offset;
1030 AddLocalVarAddrSchedule();
1031 obp+=sizeof(long);
1032 }
1033 else if(type==DEF_INTEGER||type==DEF_WORD){
1034 //mov ax,InitValue
1035 OpBuffer[obp++]=(char)0x66;
1036 OpBuffer[obp++]=(char)0xB8;
1037 *((WORD *)(OpBuffer+obp))=(WORD)i64data;
1038 obp+=sizeof(WORD);
1039
1040 //mov word ptr[ebp+offset],ax
1041 OpBuffer[obp++]=(char)0x66;
1042 OpBuffer[obp++]=(char)0x89;
1043 OpBuffer[obp++]=(char)0x85;
1044 *((long *)(OpBuffer+obp))=offset;
1045 AddLocalVarAddrSchedule();
1046 obp+=sizeof(long);
1047 }
1048 else if(type==DEF_CHAR||type==DEF_BYTE||type==DEF_BOOLEAN){
1049 //mov byte ptr[ebp+offset],InitValue
1050 OpBuffer[obp++]=(char)0xC6;
1051 OpBuffer[obp++]=(char)0x85;
1052 *((long *)(OpBuffer+obp))=offset;
1053 AddLocalVarAddrSchedule();
1054 obp+=sizeof(long);
1055 *((BYTE *)(OpBuffer+obp))=(BYTE)i64data;
1056 obp+=sizeof(BYTE);
1057 }
1058 //String型が未完成
1059 return 1;
1060}
1061
1062void dim(char *Parameter,DWORD dwFlags){
1063 extern BOOL bCompilingGlobal;
1064 extern HANDLE hHeap;
1065 int i2,i3,VarSize;
1066 char VarName[VN_SIZE];
1067
1068
1069 //参照型かどうか
1070 bool isRef = false;
1071
1072 i2 = 0;
1073
1074 if( Parameter[i2] == 1 && Parameter[i2+1] == ESC_BYREF ){
1075 //参照型
1076 isRef = true;
1077 Parameter += 2;
1078 }
1079
1080
1081 if(dwFlags & DIMFLAG_CONST){
1082 //////////////////////////////////
1083 // 定数変数の場合を考慮
1084 //////////////////////////////////
1085 for(;;i2++){
1086 if(Parameter[i2] == '=' ||
1087 Parameter[i2] == 1 && Parameter[i2] == ESC_AS ||
1088 Parameter[i2] =='('){
1089 VarName[i2] = 0;
1090 break;
1091 }
1092 VarName[i2] = Parameter[i2];
1093 }
1094
1095 //定数と2重定義されていないる場合は抜け出す
1096 if(CDBConst::obj.GetType(VarName)){
1097 return;
1098 }
1099
1100 //定数マクロとして定義されている場合は抜け出す
1101 if(GetConstHash(VarName)){
1102 return;
1103 }
1104 }
1105
1106
1107 //構文を解析
1108 int SubScripts[MAX_ARRAYDIM];
1109 TYPEINFO TypeInfo;
1110 char InitBuf[8192];
1111 char ConstractParameter[VN_SIZE];
1112 if(!GetDimentionFormat(Parameter, isRef, VarName,SubScripts,&TypeInfo,InitBuf,ConstractParameter))
1113 return;
1114
1115
1116 //定数と2重定義されていないかを調べる
1117 if(CDBConst::obj.GetType(VarName)){
1118 SetError(15,VarName,cp);
1119 return;
1120 }
1121
1122 //定数マクロとして定義されている場合
1123 if(GetConstHash(VarName)){
1124 SetError(15,VarName,cp);
1125 return;
1126 }
1127
1128
1129 //タイプサイズを取得
1130 int TypeSize;
1131 TypeSize=GetTypeSize(TypeInfo.type,TypeInfo.u.lpIndex);
1132
1133 if(dwFlags&DIMFLAG_STATIC){
1134 if(bCompilingGlobal){
1135 SetError(60,NULL,cp);
1136 return;
1137 }
1138
1139 /////////////////////
1140 // Static変数
1141 // ※"Static.Object.Method.Variable"
1142 /////////////////////
1143
1144 char temporary[VN_SIZE];
1145 GetNowStaticVarFullName(VarName,temporary);
1146
1147 AddGlobalVariable(temporary,SubScripts,&TypeInfo,TypeSize,InitBuf,ConstractParameter,dwFlags);
1148
1149 /*
1150 Note: 静的変数のコンストラクタ呼び出しは
1151 _System_InitStaticLocalVariables関数内で一括して行う
1152 */
1153 }
1154 else{
1155 if(bCompilingGlobal){
1156 /////////////////////////
1157 // グローバル変数
1158 /////////////////////////
1159
1160 AddGlobalVariable(VarName,SubScripts,&TypeInfo,TypeSize,InitBuf,ConstractParameter,dwFlags);
1161 }
1162 else{
1163 /////////////////
1164 // ローカル変数
1165 /////////////////
1166
1167 for(i2=0;i2<MaxLocalVarNum;i2++){
1168 if(LocalVar[i2].bLiving&&obj_LexScopes.GetNowLevel()==LocalVar[i2].ScopeLevel){
1169 if(lstrcmp(LocalVar[i2].name,VarName)==0){
1170 //2重定義のエラー
1171 SetError(15,VarName,cp);
1172 return;
1173 }
1174 }
1175 }
1176
1177 LocalVar=(VARIABLE *)HeapReAlloc(hHeap,0,LocalVar,(MaxLocalVarNum+1)*sizeof(VARIABLE));
1178 VARIABLE *pVar = &LocalVar[MaxLocalVarNum];
1179 MaxLocalVarNum++;
1180
1181 if( isRef ){
1182 //参照型
1183 pVar->fRef = REF_VARIABLE;
1184 TypeSize = PTR_SIZE;
1185 }
1186 else pVar->fRef=0;
1187
1188 for(i2=1,i3=0;i3<255;i3++){
1189 //配列要素数
1190 pVar->SubScripts[i3]=SubScripts[i3];
1191
1192 if(SubScripts[i3]==-1) break;
1193 i2*=SubScripts[i3]+1;
1194 }
1195 VarSize=TypeSize*i2;
1196 if(VarSize%4) VarSize+=4-(VarSize%4);
1197
1198 //変数データを追加
1199 lstrcpy(pVar->name,VarName);
1200 if(dwFlags & DIMFLAG_CONST) pVar->bConst = true;
1201 else pVar->bConst = false;
1202 if(SubScripts[0]==-1) pVar->bArray=0;
1203 else pVar->bArray=1;
1204 pVar->type=TypeInfo.type;
1205 pVar->u.index=TypeInfo.u.lpIndex;
1206 AllLocalVarSize+=VarSize;
1207 pVar->offset=AllLocalVarSize;
1208
1209 //レキシカルスコープ
1210 pVar->ScopeLevel=obj_LexScopes.GetNowLevel();
1211 pVar->ScopeStartAddress=obj_LexScopes.GetStartAddress();
1212 pVar->bLiving=TRUE;
1213
1214 if(InitBuf[0]){
1215 //初期代入時のみ、書き込みアクセスを許可する
1216 bool bConstBack = pVar->bConst;
1217 pVar->bConst = false;
1218
1219 int result = InitLocalVar(-pVar->offset,
1220 pVar->type,
1221 pVar->u.index,
1222 pVar->SubScripts,
1223 InitBuf);
1224
1225 if(!result){
1226 if( isRef ){
1227 SetRefVariable( VarName, InitBuf );
1228 }
1229 else{
1230 char temporary[8192];
1231 sprintf(temporary,"%s=%s",VarName,InitBuf);
1232 OpcodeCalc(temporary);
1233 }
1234 }
1235
1236 pVar->bConst = bConstBack;
1237 }
1238 else{
1239 //push 0
1240 op_push_value(0);
1241
1242 //push VarSize
1243 op_push_value(VarSize);
1244
1245 //mov eax,ebp
1246 OpBuffer[obp++]=(char)0x8B;
1247 OpBuffer[obp++]=(char)0xC5;
1248
1249 //add eax,offset
1250 OpBuffer[obp++]=(char)0x05;
1251 *((long *)(OpBuffer+obp))=-pVar->offset;
1252 AddLocalVarAddrSchedule();
1253 obp+=sizeof(long);
1254
1255 //push eax
1256 op_push(REG_EAX);
1257
1258 //call FillMemory
1259 OpBuffer[obp++]=(char)0xFF;
1260 OpBuffer[obp++]=(char)0x15;
1261 DECLAREINFO *pdi;
1262 pdi=GetDeclareHash("FillMemory");
1263 pdi->bUse=1;
1264 pobj_ImportAddrSchedule->add(pdi);
1265 obp+=sizeof(long);
1266 }
1267 }
1268
1269 //コンストラクタ呼び出し
1270 if(TypeInfo.type==DEF_OBJECT&&(dwFlags&DIMFLAG_NONCALL_CONSTRACTOR)==0&& isRef == false ){
1271 CallConstractor(VarName,SubScripts,TypeInfo,ConstractParameter);
1272 }
1273 }
1274
1275 if(TypeInfo.type==DEF_OBJECT){
1276 if(TypeInfo.u.pobj_Class->IsAbstract()){
1277 //抽象クラスだったとき
1278 SetError(125,TypeInfo.u.pobj_Class->name,cp);
1279 }
1280 }
1281}
1282void OpcodeDim(char *Parameter,DWORD dwFlags){
1283 int i,i2,i3,IsStr=0;
1284 char temporary[8192];
1285
1286 for(i=0,i2=0;;i++,i2++){
1287 if(Parameter[i]=='\"') IsStr^=1;
1288 if(Parameter[i]=='('&&IsStr==0){
1289 i3=GetStringInPare(temporary+i2,Parameter+i);
1290 i+=i3-1;
1291 i2+=i3-1;
1292 continue;
1293 }
1294 if(Parameter[i]=='['&&IsStr==0){
1295 i3=GetStringInBracket(temporary+i2,Parameter+i);
1296 i+=i3-1;
1297 i2+=i3-1;
1298 continue;
1299 }
1300 if((Parameter[i]==','&&IsStr==0)||
1301 Parameter[i]=='\0'){
1302 temporary[i2]=0;
1303
1304 dim(temporary,dwFlags);
1305
1306 if(Parameter[i]=='\0') break;
1307 i2=-1;
1308 continue;
1309 }
1310 temporary[i2]=Parameter[i];
1311 }
1312}
1313
1314void SetVarPtrToEax(RELATIVE_VAR *pRelativeVar){
1315 if(pRelativeVar->dwKind==VAR_GLOBAL){
1316 if(pRelativeVar->bOffsetOffset){
1317 //lea eax,dword ptr[ecx+offset]
1318 OpBuffer[obp++]=(char)0x8D;
1319 OpBuffer[obp++]=(char)0x81;
1320 *((long *)(OpBuffer+obp))=pRelativeVar->offset;
1321 pobj_GlobalVarSchedule->add();
1322 obp+=sizeof(long);
1323 }
1324 else{
1325 //mov eax,offset
1326 OpBuffer[obp++]=(char)0xB8;
1327 *((long *)(OpBuffer+obp))=pRelativeVar->offset;
1328 pobj_GlobalVarSchedule->add();
1329 obp+=sizeof(long);
1330 }
1331 }
1332 else if(pRelativeVar->dwKind==VAR_LOCAL){
1333 if(pRelativeVar->bOffsetOffset){
1334 //add ecx,offset
1335 OpBuffer[obp++]=(char)0x81;
1336 OpBuffer[obp++]=(char)0xC1;
1337 *((long *)(OpBuffer+obp))=pRelativeVar->offset;
1338 AddLocalVarAddrSchedule();
1339 obp+=sizeof(long);
1340
1341 //lea eax,dword ptr[ebp+ecx]
1342 OpBuffer[obp++]=(char)0x8D;
1343 OpBuffer[obp++]=(char)0x44;
1344 OpBuffer[obp++]=(char)0x0D;
1345 OpBuffer[obp++]=(char)0x00;
1346 }
1347 else{
1348 //lea eax,dword ptr[ebp+offset]
1349 OpBuffer[obp++]=(char)0x8D;
1350 OpBuffer[obp++]=(char)0x85;
1351 *((long *)(OpBuffer+obp))=pRelativeVar->offset;
1352 AddLocalVarAddrSchedule();
1353 obp+=sizeof(long);
1354 }
1355 }
1356 else if(pRelativeVar->dwKind==VAR_REFLOCAL){
1357 if(pRelativeVar->bOffsetOffset){
1358 //mov eax,ecx
1359 OpBuffer[obp++]=(char)0x8B;
1360 OpBuffer[obp++]=(char)0xC1;
1361
1362 //add eax,dword ptr[ebp+offset]
1363 OpBuffer[obp++]=(char)0x03;
1364 OpBuffer[obp++]=(char)0x85;
1365 *((long *)(OpBuffer+obp))=pRelativeVar->offset;
1366 AddLocalVarAddrSchedule();
1367 obp+=sizeof(long);
1368 }
1369 else{
1370 //mov eax,dword ptr[ebp+offset]
1371 OpBuffer[obp++]=(char)0x8B;
1372 OpBuffer[obp++]=(char)0x85;
1373 *((long *)(OpBuffer+obp))=pRelativeVar->offset;
1374 AddLocalVarAddrSchedule();
1375 obp+=sizeof(long);
1376 }
1377 }
1378 else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
1379 //mov eax,ecx
1380 OpBuffer[obp++]=(char)0x8B;
1381 OpBuffer[obp++]=(char)0xC1;
1382 }
1383}
Note: See TracBrowser for help on using the repository browser.