source: dev/BasicCompiler32/Compile_Var.cpp@ 35

Last change on this file since 35 was 34, checked in by dai_9181, 18 years ago

スコープ処理を統一した。関数の途中でReturnしても、スコープにあるローカルオブジェクトを正確に破棄できるようにした。

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