source: dev/trunk/ab5.0/abdev/compiler_x64/Compile_Var.cpp@ 628

Last change on this file since 628 was 603, checked in by dai_9181, 16 years ago

ObjectModuleに関連するクラス一式をab_commonプロジェクトに移動した。

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