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

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

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

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() || pVar->IsByValStructParameter() )
437 {
438 // 参照型
439 pRelativeVar->dwKind = VAR_REFLOCAL;
440 }
441 else pRelativeVar->dwKind=VAR_LOCAL;
442 resultType = pVar->GetType();
443 pSubscripts = &pVar->GetSubscripts();
444 bConst = pVar->IsConst();
445
446 /////////////////////////////////////////////////////////
447 // ☆★☆ ジェネリクスサポート ☆★☆
448
449 if( resultType.IsTypeParameter() )
450 {
451 // 型パラメータだったとき
452
453 int ptrLevel = PTR_LEVEL( resultType.GetBasicType() );
454
455 // 制約クラス(指定されていないときはObjectクラス)にセットする
456 resultType.SetBasicType( DEF_OBJECT );
457
458 for( int i=0; i<ptrLevel; i++ )
459 {
460 resultType.PtrLevelUp();
461 }
462 }
463
464 //
465 /////////////////////////////////////////////////////////
466
467 goto ok;
468 }
469 }
470
471 if( compiler.IsCompilingClass() ){
472 //////////////////////
473 // クラスメンバの参照
474 //////////////////////
475
476 if(lstrcmpi(variable,"This")==0){
477 //自身のオブジェクトのThisポインタをr11にコピー
478 SetThisPtrToReg(REG_R11);
479
480 pRelativeVar->dwKind=VAR_DIRECTMEM;
481
482 resultType.SetType( DEF_OBJECT, &compiler.GetCompilingClass() );
483 return true;
484 }
485
486 if(memicmp(variable,"This.",5)==0){
487 //Thisオブジェクトのメンバを参照するとき
488 SlideString(variable+5,-5);
489 lstrcpy(VarName,variable);
490 }
491 else{
492 //クラス内の動的メンバを参照するとき(通常)
493
494 if( !compiler.GetCompilingClass().HasDynamicMember( VarName ) )
495 {
496 goto NonClassMember;
497 }
498 }
499
500 //Const修飾子のメソッド内でメンバ書き込みアクセスが発生したとき
501 //(コンストラクタ、デストラクタ内を除く)
502 const CMethod *pMethod = &compiler.GetCompilingUserProc().GetMethod();
503 if( isWriteAccess &&
504 pMethod->IsConst() &&
505 compiler.GetCompilingClass().IsCompilingConstructor() == false &&
506 compiler.GetCompilingClass().IsCompilingDestructor() == false
507 ){
508 compiler.errorMessenger.Output(131, NULL, cp );
509 }
510
511 //自身のオブジェクトのThisポインタをr11にコピー
512 SetThisPtrToReg(REG_R11);
513
514 pRelativeVar->dwKind=VAR_DIRECTMEM;
515 if(!_member_offset(
516 isErrorEnabled,
517 isWriteAccess,
518 Type( DEF_OBJECT, compiler.GetCompilingClass() ),
519 variable,
520 pRelativeVar,
521 resultType,1)) return false;
522 return true;
523 }
524
525NonClassMember:
526
527 {
528 const Variable *pVar;
529
530 //////////////////////////
531 // 静的ローカル変数
532 // ※"Static.Object.Method.Variable"
533 //////////////////////////
534
535 char temporary[VN_SIZE];
536 if( compiler.IsLocalAreaCompiling() ){
537 GetNowStaticVarFullName(VarName,temporary);
538
539 pVar = compiler.GetObjectModule().meta.GetGlobalVars().Find( LexicalAnalyzer::FullNameToSymbol( temporary ) );
540 if( pVar ){
541 goto GlobalOk;
542 }
543 }
544
545
546 //////////////////////////
547 // クラスの静的メンバ
548 //////////////////////////
549
550 if(member[0]){
551 lstrcpy(temporary,member);
552
553 // TODO: 名前空間を考慮したコードになっていない
554
555 char tempMember[VN_SIZE];
556 char tempArray[VN_SIZE];
557 {
558 ReferenceKind refType;
559 GetVarFormatString(temporary,tempArray,lpPtrOffset,tempMember, refType );
560 }
561
562 const TypeDef *pTypeDef = compiler.GetObjectModule().meta.GetTypeDefs().Find(
563 LexicalAnalyzer::FullNameToSymbol( VarName )
564 );
565 if( pTypeDef )
566 {
567 // TypeDef後の型名だったとき
568 lstrcpy( VarName, pTypeDef->GetBaseName().c_str() );
569 }
570
571 char temp2[VN_SIZE];
572 sprintf(temp2,"%s.%s",VarName,temporary);
573 pVar = compiler.GetObjectModule().meta.GetGlobalVars().Find( LexicalAnalyzer::FullNameToSymbol( temp2 ) );
574 if( pVar ){
575 lstrcpy(member,tempMember);
576 lstrcpy(array,tempArray);
577 goto GlobalOk;
578 }
579 }
580
581 if( compiler.IsCompilingClass() ){
582 //自身のクラスから静的メンバを参照する場合
583 char temp2[VN_SIZE];
584 sprintf(temp2,"%s.%s",compiler.GetCompilingClass().GetName().c_str(),VarName);
585 pVar = compiler.GetObjectModule().meta.GetGlobalVars().Find( LexicalAnalyzer::FullNameToSymbol( temp2 ) );
586 if( pVar ){
587 goto GlobalOk;
588 }
589 }
590
591 /////////////////////
592 // グローバル変数
593 /////////////////////
594
595 pVar = compiler.GetObjectModule().meta.GetGlobalVars().BackSearch(
596 LexicalAnalyzer::FullNameToSymbol( VarName ),
597 compiler.codeGenerator.lexicalScopes.GetNowLevel()
598 );
599 if( pVar ){
600 goto GlobalOk;
601 }
602
603 if(isErrorEnabled) compiler.errorMessenger.Output(3,variable,cp);
604 pRelativeVar->dwKind=NON_VAR;
605 return false;
606
607
608
609GlobalOk:
610 //ポインタ変数の場合
611 if( pVar->GetType().IsPointer() ){
612 if( !pVar->IsArray() ){
613 lstrcpy(lpPtrOffset,array);
614 array[0]=0;
615 }
616 }
617 else{
618 if(lpPtrOffset[0]){
619 compiler.errorMessenger.Output(16,variable,cp);
620 pRelativeVar->dwKind=NON_VAR;
621 return false;
622 }
623 }
624
625 pRelativeVar->offset=pVar->GetOffsetAddress();
626 pRelativeVar->bOffsetOffset=0;
627 if( pVar->IsRef() ){
628 // 参照型
629 pRelativeVar->dwKind = VAR_REFGLOBAL;
630 }
631 else pRelativeVar->dwKind=VAR_GLOBAL;
632 resultType = pVar->GetType();
633 pSubscripts=&pVar->GetSubscripts();
634 bConst = pVar->IsConst();
635 }
636
637
638
639ok:
640
641 if( bConst && isWriteAccess ){
642 //Const定義の変数に書き込みアクセスをしようとした場合
643 if( resultType.IsObject() ){
644 //オブジェクト定数
645 compiler.errorMessenger.Output(130, VarName, cp );
646 }
647 else{
648 //一般のConst変数
649 compiler.errorMessenger.Output(61,VarName,cp);
650 }
651 }
652
653 if( array[0] == 0 && pSubscripts->size() > 0 ){
654 //配列の先頭ポインタを示す場合
655 resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR );
656
657 if( pResultSubscripts )
658 {
659 (*pResultSubscripts) = *pSubscripts;
660 }
661 return true;
662 }
663
664 if( array[0] || member[0] ){
665 //xor r11,r11(r11を0に初期化する)
666 //※r11は変数ベースアドレスからの相対オフセットを示す
667 compiler.codeGenerator.op_zero_reg(REG_R11);
668
669 pRelativeVar->bOffsetOffset=1;
670 }
671 if(array[0]){
672 if(!GetArrayOffset(*pSubscripts,array,resultType)){
673 compiler.errorMessenger.Output(14,variable,cp);
674 pRelativeVar->dwKind=NON_VAR;
675 return false;
676 }
677 }
678 if(member[0]){
679 if( resultType.IsObject() || resultType.IsStruct() ){
680 //実態オブジェクトのメンバを参照(obj.member)
681 if( refType != RefDot ){
682 compiler.errorMessenger.Output(104,VarName,cp);
683 pRelativeVar->dwKind=NON_VAR;
684 return false;
685 }
686
687 if( resultType.IsObject() ){
688 // 参照内容へのポインタを抽出
689 SetRelativeOffset( *pRelativeVar );
690 }
691 }
692 else if( resultType.IsObjectPtr() || resultType.IsStructPtr() ){
693 //ポインタオブジェクトが示すメンバを参照
694 if(lpPtrOffset[0]){
695 //pObj[n].member
696 if( refType != RefDot ){
697 compiler.errorMessenger.Output(104,VarName,cp);
698 pRelativeVar->dwKind=NON_VAR;
699 return false;
700 }
701 SetRelativeOffset(resultType,pRelativeVar,lpPtrOffset);
702 pRelativeVar->dwKind=VAR_DIRECTMEM;
703 }
704 else{
705 //pObj->member
706 if( refType != RefPointer ){
707 compiler.errorMessenger.Output(104,VarName,cp);
708 pRelativeVar->dwKind=NON_VAR;
709 return false;
710 }
711
712 SetVarPtrToReg(REG_R12,pRelativeVar);
713 pRelativeVar->dwKind=VAR_DIRECTMEM;
714
715 //mov r11,qword ptr[r12]
716 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_R12,0,MOD_BASE);
717 }
718 }
719 else if( resultType.GetBasicType()==MAKE_PTR_TYPE(DEF_OBJECT,2) || resultType.GetBasicType()==MAKE_PTR_TYPE(DEF_STRUCT,2)){
720 //ポインタオブジェクトが示すメンバを参照
721 if(lpPtrOffset[0]){
722 //ppObj[n]->member
723 if( refType != RefPointer ){
724 compiler.errorMessenger.Output(104,VarName,cp);
725 pRelativeVar->dwKind=NON_VAR;
726 return false;
727 }
728
729 SetRelativeOffset(resultType,pRelativeVar,lpPtrOffset);
730 pRelativeVar->dwKind=VAR_DIRECTMEM;
731
732
733 SetVarPtrToReg(REG_R12,pRelativeVar);
734
735 //mov r11,qword ptr[r12]
736 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_R12,0,MOD_BASE);
737 }
738 else{
739 compiler.errorMessenger.Output(104,VarName,cp);
740 pRelativeVar->dwKind=NON_VAR;
741 return false;
742 }
743 }
744 else{
745 compiler.errorMessenger.Output(102,VarName,cp);
746 pRelativeVar->dwKind=NON_VAR;
747 return false;
748 }
749
750 if(!_member_offset(
751 isErrorEnabled,
752 isWriteAccess,
753 resultType,
754 member,pRelativeVar,resultType,0)) return false;
755
756 return true;
757 }
758
759 if(lpPtrOffset[0]){
760 SetRelativeOffset(resultType,pRelativeVar,lpPtrOffset);
761 pRelativeVar->dwKind=VAR_DIRECTMEM;
762 }
763
764 return true;
765}
766
767bool SetInitGlobalData(int offset,const Type &type,const Subscripts &subscripts,const char *lpszInitBuf){
768 int i2,i3;
769 char temporary[VN_SIZE];
770 char InitBuf[VN_SIZE];
771 lstrcpy( InitBuf, lpszInitBuf );
772
773 if(InitBuf[0]=='['){
774 SlideString(InitBuf+1,-1);
775 InitBuf[lstrlen(InitBuf)-1]=0;
776
777 int typeSize = type.GetSize();
778
779 if( subscripts.size() > 0 ){
780 Subscripts nestSubscripts;
781 for( int i=1; i<(int)subscripts.size(); i++ )
782 {
783 nestSubscripts.push_back( subscripts[i] );
784 }
785
786 typeSize*=JumpSubScripts( nestSubscripts );
787 {
788 int i=0;
789 i2=0;
790 while(1){
791 if( subscripts[0] < i2 ){
792 compiler.errorMessenger.Output(41,0,cp);
793 return 0;
794 }
795 i=GetOneParameter(InitBuf,i,temporary);
796 if(!SetInitGlobalData(
797 offset+i2*typeSize,
798 type,
799 nestSubscripts,
800 temporary)) return false;
801 i2++;
802 if(InitBuf[i]=='\0') break;
803 }
804 }
805 return true;
806 }
807
808 if(type.IsStruct()){
809 const CClass &objClass = type.GetClass();
810
811 int i = 0;
812 BOOST_FOREACH( Member *pMember, objClass.GetDynamicMembers() ){
813 if(InitBuf[i]=='\0'){
814 compiler.errorMessenger.Output(41,0,cp);
815 return false;
816 }
817
818 i=GetOneParameter(InitBuf,i,temporary);
819
820 i3=objClass.GetMemberOffset( pMember->GetName().c_str() );
821
822 if(!SetInitGlobalData(offset+i3,
823 pMember->GetType(),
824 pMember->GetSubscripts(),
825 temporary)) return false;
826 }
827 return true;
828 }
829
830 compiler.errorMessenger.Output(41,0,cp);
831 return false;
832 }
833
834
835 ///////////////////////////////////////
836 // 単発式([]で囲まれていない)
837 ///////////////////////////////////////
838
839 if( subscripts.size() > 0 ){
840 compiler.errorMessenger.Output(41,0,cp);
841 return false;
842 }
843
844 double dbl;
845 _int64 i64data;
846 Type calcType;
847
848 if( !StaticCalculation(false, InitBuf,type.GetBasicType(),&i64data,calcType) ){
849 //動的データだった場合
850 return false;
851 }
852 if( calcType.IsReal() ){
853 memcpy(&dbl,&i64data,sizeof(double));
854 i64data=(_int64)dbl;
855 }
856 else dbl=(double)i64data;
857
858 //型チェック
859 CheckDifferentType(
860 type,
861 calcType,
862 0,0);
863
864 if( type.IsDouble() ){
865 compiler.GetObjectModule().meta.GetGlobalVars().initAreaBuffer.Overwrite(
866 offset,
867 (const char *)&dbl,
868 sizeof(double)
869 );
870 }
871 else if( type.IsSingle() ){
872 float flt = (float)dbl;
873 compiler.GetObjectModule().meta.GetGlobalVars().initAreaBuffer.Overwrite(
874 offset,
875 (const char *)&flt,
876 sizeof(float)
877 );
878 }
879 else if( type.Is64() || type.IsPointer() ){
880 if( type.GetBasicType() == typeOfPtrChar && type.GetIndex() == LITERAL_STRING ){
881 //文字列定数のとき
882
883 char *temp;
884 temp=(char *)i64data;
885 if( compiler.IsUnicode() )
886 {
887 i2 = compiler.GetObjectModule().dataTable.AddWString( Jenga::Common::ToWString( temp ) );
888 }
889 else
890 {
891 i2 = compiler.GetObjectModule().dataTable.AddString( temp );
892 }
893 HeapDefaultFree(temp);
894
895 //mov rax,DataPos
896 compiler.codeGenerator.op_mov_RV(sizeof(_int64),REG_RAX,i2, Schedule::DataTable );
897
898 //mov qword ptr[offset],rax
899 compiler.codeGenerator.op_mov_MR(sizeof(_int64),REG_RAX,0,offset,MOD_DISP32, Schedule::GlobalVar );
900 }
901 else{
902 compiler.GetObjectModule().meta.GetGlobalVars().initAreaBuffer.Overwrite(
903 offset,
904 (const char *)&i64data,
905 sizeof(_int64)
906 );
907 }
908 }
909 else if( type.IsDWord() || type.IsLong() ){
910 long l = (long)i64data;
911 compiler.GetObjectModule().meta.GetGlobalVars().initAreaBuffer.Overwrite(
912 offset,
913 (const char *)&l,
914 sizeof(long)
915 );
916 }
917 else if( type.IsWord() || type.IsInteger() ){
918 short s = (short)i64data;
919 compiler.GetObjectModule().meta.GetGlobalVars().initAreaBuffer.Overwrite(
920 offset,
921 (const char *)&s,
922 sizeof(short)
923 );
924 }
925 else if( type.IsSByte() || type.IsByte() || type.IsBoolean() ){
926 char c = (char)i64data;
927 compiler.GetObjectModule().meta.GetGlobalVars().initAreaBuffer.Overwrite(
928 offset,
929 (const char *)&c,
930 sizeof(char)
931 );
932 }
933
934 return true;
935}
936bool InitLocalVar(int offset,const Type &type,const Subscripts &subscripts,const char *lpszInitBuf){
937 int i2,i3;
938 char temporary[VN_SIZE];
939 char InitBuf[VN_SIZE];
940 lstrcpy( InitBuf, lpszInitBuf );
941
942 if(InitBuf[0]=='['){
943 SlideString(InitBuf+1,-1);
944 InitBuf[lstrlen(InitBuf)-1]=0;
945
946 int typeSize = type.GetSize();
947
948 if( subscripts.size() > 0 ){
949 Subscripts nestSubscripts;
950 for( int i=1; i<(int)subscripts.size(); i++ )
951 {
952 nestSubscripts.push_back( subscripts[i] );
953 }
954
955 typeSize*=JumpSubScripts( nestSubscripts );
956 {
957 int i=0;
958 i2=0;
959 while(1){
960 if( subscripts[0] < i2 ){
961 compiler.errorMessenger.Output(41,0,cp);
962 return 0;
963 }
964 i=GetOneParameter(InitBuf,i,temporary);
965 if(!InitLocalVar(
966 offset+i2*typeSize,
967 type,
968 nestSubscripts,
969 temporary)) return false;
970 i2++;
971 if(InitBuf[i]=='\0') break;
972 }
973 }
974 return true;
975 }
976
977 if(type.IsStruct()){
978 const CClass &objClass = type.GetClass();
979
980 int i = 0;
981 BOOST_FOREACH( Member *pMember, objClass.GetDynamicMembers() ){
982 if(InitBuf[i]=='\0'){
983 compiler.errorMessenger.Output(41,0,cp);
984 return false;
985 }
986
987 i=GetOneParameter(InitBuf,i,temporary);
988
989 i3=objClass.GetMemberOffset( pMember->GetName().c_str() );
990
991 if(!InitLocalVar(offset+i3,
992 pMember->GetType(),
993 pMember->GetSubscripts(),
994 temporary)) return false;
995
996 if(InitBuf[i]=='\0') break;
997 }
998 return true;
999 }
1000
1001 compiler.errorMessenger.Output(41,0,cp);
1002 return false;
1003 }
1004
1005
1006 ///////////////////////////////////////
1007 // 単発式([]で囲まれていない)
1008 ///////////////////////////////////////
1009
1010 if( subscripts.size() > 0 ){
1011 compiler.errorMessenger.Output(41,0,cp);
1012 return false;
1013 }
1014
1015 double dbl;
1016 _int64 i64data;
1017 Type calcType;
1018
1019 if( !StaticCalculation(false, InitBuf,type.GetBasicType(),&i64data,calcType) ){
1020 //動的データだった場合
1021 return false;
1022 }
1023 if( calcType.IsReal() ){
1024 memcpy(&dbl,&i64data,sizeof(double));
1025 i64data=(_int64)dbl;
1026 }
1027 else dbl=(double)i64data;
1028
1029 //型チェック
1030 CheckDifferentType(
1031 type,
1032 calcType,
1033 0,0);
1034
1035 if( type.IsDouble() ){
1036 memcpy(&i64data,&dbl,sizeof(double));
1037
1038 //mov rax,i64data
1039 compiler.codeGenerator.op_mov_RV64(REG_RAX,i64data);
1040
1041 //mov qword ptr[rsp+offset],rax
1042 compiler.codeGenerator.localVarPertialSchedules.push_back(
1043 compiler.codeGenerator.op_mov_MR(sizeof(_int64),REG_RAX,REG_RSP,offset,MOD_BASE_DISP32, Schedule::None, true )
1044 );
1045 }
1046 else if( type.IsSingle() ){
1047 float flt;
1048 flt=(float)dbl;
1049
1050 //mov dword ptr[rsp+offset],value
1051 compiler.codeGenerator.localVarPertialSchedules.push_back(
1052 compiler.codeGenerator.op_mov_MV(sizeof(long),REG_RSP,offset, Schedule::None, true, USE_OFFSET,*(int *)&flt)
1053 );
1054 }
1055 else if( type.Is64() || type.IsPointer() ){
1056 if( type.GetBasicType() == typeOfPtrChar && type.GetIndex() == LITERAL_STRING ){
1057 //文字列定数のとき
1058
1059 char *temp;
1060 temp=(char *)i64data;
1061 if( compiler.IsUnicode() )
1062 {
1063 i2 = compiler.GetObjectModule().dataTable.AddWString( Jenga::Common::ToWString( temp ) );
1064 }
1065 else
1066 {
1067 i2 = compiler.GetObjectModule().dataTable.AddString( temp );
1068 }
1069 HeapDefaultFree(temp);
1070
1071 //mov rax,i2
1072 compiler.codeGenerator.op_mov_RV(sizeof(_int64),REG_RAX,i2, Schedule::DataTable );
1073
1074 //mov qword ptr[rsp+offset],rax
1075 compiler.codeGenerator.localVarPertialSchedules.push_back(
1076 compiler.codeGenerator.op_mov_MR(sizeof(_int64),REG_RAX,REG_RSP,offset,MOD_BASE_DISP32, Schedule::None, true )
1077 );
1078 }
1079 else{
1080 if(i64data&0xFFFFFFFF00000000){
1081 //mov rax,i64data
1082 compiler.codeGenerator.op_mov_RV64(REG_RAX,i64data);
1083
1084 //mov qword ptr[rsp+offset],rax
1085 compiler.codeGenerator.localVarPertialSchedules.push_back(
1086 compiler.codeGenerator.op_mov_MR(sizeof(_int64),REG_RAX,REG_RSP,offset,MOD_BASE_DISP32, Schedule::None, true )
1087 );
1088 }
1089 else{
1090 //mov qword ptr[rsp+offset],value
1091 compiler.codeGenerator.localVarPertialSchedules.push_back(
1092 compiler.codeGenerator.op_mov_MV(sizeof(_int64),REG_RSP,offset, Schedule::None, true, USE_OFFSET,(int)i64data)
1093 );
1094 }
1095 }
1096 }
1097 else if( type.IsDWord() || type.IsLong() ){
1098 //mov dword ptr[rsp+offset],value
1099 compiler.codeGenerator.localVarPertialSchedules.push_back(
1100 compiler.codeGenerator.op_mov_MV(sizeof(long),REG_RSP,offset, Schedule::None, true, USE_OFFSET,(int)i64data)
1101 );
1102 }
1103 else if( type.IsWord() || type.IsInteger() ){
1104 //mov word ptr[rsp+offset],value
1105 compiler.codeGenerator.localVarPertialSchedules.push_back(
1106 compiler.codeGenerator.op_mov_MV(sizeof(short),REG_RSP,offset, Schedule::None, true, USE_OFFSET,(int)i64data)
1107 );
1108 }
1109 else if( type.IsSByte() || type.IsByte() || type.IsBoolean() ){
1110 //mov byte ptr[rsp+offset],value
1111 compiler.codeGenerator.localVarPertialSchedules.push_back(
1112 compiler.codeGenerator.op_mov_MV(sizeof(char),REG_RSP,offset, Schedule::None, true, USE_OFFSET,(int)i64data)
1113 );
1114 }
1115 return true;
1116}
1117
1118void dim( char *VarName, const Subscripts &subscripts, const Type &type,const char *InitBuf,const char *ConstractParameter,DWORD dwFlags)
1119{
1120 if( compiler.IsGlobalAreaCompiling() ){
1121 /////////////////////////
1122 // グローバル変数
1123 /////////////////////////
1124
1125 AddGlobalVariable(VarName,subscripts,type,InitBuf,ConstractParameter,dwFlags);
1126 }
1127 else{
1128 /////////////////
1129 // ローカル変数
1130 /////////////////
1131
1132 if( compiler.GetCompilingUserProc().GetLocalVars().DuplicateCheck( LexicalAnalyzer::FullNameToSymbol( VarName ), compiler.codeGenerator.lexicalScopes.GetNowLevel() ) ){
1133 //2重定義のエラー
1134 compiler.errorMessenger.Output(15,VarName,cp);
1135 return;
1136 }
1137
1138 bool isConst = ( dwFlags & DIMFLAG_CONST ) ? true:false;
1139
1140 Variable *pVar = new Variable(
1141 ActiveBasic::Compiler::LexicalAnalyzer::FullNameToSymbol( VarName ),
1142 type,
1143 isConst,
1144 false,
1145 ConstractParameter,
1146 false
1147 );
1148
1149 if( subscripts.size() > 0 ){
1150 //配列あり
1151 pVar->SetArray( subscripts );
1152 }
1153
1154 //レキシカルスコープ
1155 pVar->SetScopeLevel( compiler.codeGenerator.lexicalScopes.GetNowLevel() );
1156 pVar->SetScopeStartAddress( compiler.codeGenerator.lexicalScopes.GetStartAddress() );
1157 pVar->isLiving = true;
1158
1159 //エラー用
1160 pVar->source_code_address=cp;
1161
1162 // 変数を追加
1163 compiler.GetCompilingUserProc().GetLocalVars().push_back( pVar );
1164
1165 //アラインメントを考慮
1166 if( pVar->GetType().IsStruct() ){
1167 int alignment = pVar->GetType().GetClass().GetFixedAlignment();
1168
1169 if( alignment ){
1170 if( AllLocalVarSize % alignment ){
1171 AllLocalVarSize += alignment - (AllLocalVarSize % alignment);
1172 }
1173 }
1174
1175 if( alignment == PTR_SIZE*2 ){
1176 // ポインタに要するサイズよりも一回り大きなアラインメントが指定されているとき
1177 // (例:CONTEXT構造体など)
1178 // 呼び出し側のオフセットズレを考慮する
1179
1180 if( 0 == ( compiler.GetCompilingUserProc().RealParams().GetMemorySize() + PTR_SIZE /* ret分 */ ) % alignment ){
1181 AllLocalVarSize += PTR_SIZE;
1182 }
1183 }
1184 }
1185
1186 AllLocalVarSize += pVar->GetMemorySize();
1187 pVar->SetOffsetAddress( AllLocalVarSize );
1188
1189 //レキシカルスコープ
1190 pVar->SetScopeLevel( compiler.codeGenerator.lexicalScopes.GetNowLevel() );
1191 pVar->SetScopeStartAddress( compiler.codeGenerator.lexicalScopes.GetStartAddress() );
1192 pVar->isLiving = true;
1193
1194 if(InitBuf[0]){
1195 //初期代入時のみ、書き込みアクセスを許可する
1196 if( isConst ){
1197 pVar->ConstOff();
1198 }
1199
1200 int result = 0;
1201 if( !pVar->GetType().IsObject() ){
1202 result = InitLocalVar(-pVar->GetOffsetAddress(),
1203 pVar->GetType(),
1204 pVar->GetSubscripts(),
1205 InitBuf);
1206 }
1207
1208 if(!result){
1209 //動的な式だった場合は代入演算を行う
1210 char temporary[8192];
1211 sprintf(temporary,"%s=%s",VarName,InitBuf);
1212 OpcodeCalc(temporary);
1213 }
1214
1215 if( isConst ){
1216 pVar->ConstOn();
1217 }
1218 }
1219 else{
1220 //0初期化
1221
1222 //mov r8, 0
1223 compiler.codeGenerator.op_zero_reg( REG_R8 );
1224
1225 //mov rdx, VarSize
1226 compiler.codeGenerator.op_mov_RV( sizeof(_int64), REG_RDX, pVar->GetMemorySize() );
1227
1228 //mov rcx, rsp
1229 compiler.codeGenerator.op_mov_RR( REG_RCX, REG_RSP );
1230
1231 //add rcx, offset
1232 compiler.codeGenerator.localVarPertialSchedules.push_back(
1233 compiler.codeGenerator.op_add_RV( REG_RCX, -pVar->GetOffsetAddress(), Schedule::None, true )
1234 );
1235
1236 //call FillMemory
1237 DllProc *pDllProc;
1238 pDllProc=GetDeclareHash("FillMemory");
1239 compiler.codeGenerator.op_call( pDllProc );
1240 }
1241 }
1242
1243 //New呼び出し
1244 if( type.IsObject()
1245 && !type.IsInterface() && !type.IsComInterface()
1246 &&(dwFlags&DIMFLAG_NONCALL_CONSTRACTOR)==0
1247 &&InitBuf[0]=='\0')
1248 {
1249 char objectSize[255];
1250 if( subscripts.size() == 0 ){
1251 objectSize[0] = 0;
1252 }
1253 else{
1254 if( subscripts.size() > 1 ){
1255 compiler.errorMessenger.Output(300,NULL,cp);
1256 }
1257 sprintf( objectSize, "%d", subscripts[0] );
1258 }
1259 Operator_New( type.GetClass(), objectSize, ConstractParameter, type );
1260
1261 Type tempType;
1262 RELATIVE_VAR RelativeVar;
1263 GetVarOffset( true, false, VarName, &RelativeVar, tempType );
1264 if( RelativeVar.dwKind == VAR_DIRECTMEM ){
1265 compiler.errorMessenger.OutputFatalError();
1266 }
1267 SetVariableFromRax( Type( DEF_OBJECT, *compiler.GetObjectModule().meta.GetClasses().GetObjectClassPtr() ), DEF_OBJECT, &RelativeVar );
1268 }
1269}
1270void SetVarPtrToReg(int reg,RELATIVE_VAR *pRelativeVar){
1271 if(!IsGeneralReg(reg)) compiler.errorMessenger.Output(300,NULL,cp);
1272
1273 if(pRelativeVar->dwKind==VAR_GLOBAL){
1274 if(pRelativeVar->bOffsetOffset){
1275 //add r11,offset
1276 compiler.codeGenerator.op_add_RV( REG_R11, (long)pRelativeVar->offset, Schedule::GlobalVar );
1277
1278 //mov reg,r11
1279 compiler.codeGenerator.op_mov_RR(reg,REG_R11);
1280 }
1281 else{
1282 //mov reg,offset
1283 compiler.codeGenerator.op_mov_RV( sizeof(_int64), reg, (long)pRelativeVar->offset, Schedule::GlobalVar );
1284 }
1285 }
1286 else if( pRelativeVar->dwKind == VAR_REFGLOBAL ){
1287 if(pRelativeVar->bOffsetOffset){
1288 //add r11,qword ptr[offset]
1289 compiler.codeGenerator.op_add_RM( sizeof(_int64), REG_R11, REG_NON, (int)pRelativeVar->offset, MOD_DISP32, Schedule::GlobalVar );
1290 }
1291 else{
1292 //mov r11,qword ptr[offset]
1293 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_NON,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar );
1294 }
1295
1296 goto directmem;
1297 }
1298 else if(pRelativeVar->dwKind==VAR_LOCAL){
1299 if(pRelativeVar->bOffsetOffset){
1300 //add r11,offset
1301 compiler.codeGenerator.localVarPertialSchedules.push_back(
1302 compiler.codeGenerator.op_add_RV( REG_R11, (long)pRelativeVar->offset, Schedule::None, true )
1303 );
1304
1305 //add r11,rsp
1306 compiler.codeGenerator.op_add_RR(REG_R11,REG_RSP);
1307
1308 //mov reg,r11
1309 compiler.codeGenerator.op_mov_RR(reg,REG_R11);
1310 }
1311 else{
1312 //mov reg,rsp
1313 compiler.codeGenerator.op_mov_RR(reg,REG_RSP);
1314
1315 //add reg,offset
1316 compiler.codeGenerator.localVarPertialSchedules.push_back(
1317 compiler.codeGenerator.op_add_RV(reg,(long)pRelativeVar->offset, Schedule::None, true )
1318 );
1319 }
1320 }
1321 else if( pRelativeVar->dwKind == VAR_REFLOCAL ){
1322 if(pRelativeVar->bOffsetOffset){
1323 //add r11,qword ptr[rsp+offset]
1324 compiler.codeGenerator.localVarPertialSchedules.push_back(
1325 compiler.codeGenerator.op_add_RM( sizeof(_int64), REG_R11, REG_RSP, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::None, true )
1326 );
1327 }
1328 else{
1329 //mov r11,qword ptr[rsp+offset]
1330 compiler.codeGenerator.localVarPertialSchedules.push_back(
1331 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true )
1332 );
1333 }
1334
1335 goto directmem;
1336 }
1337 else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
1338directmem:
1339 //mov reg,r11
1340 compiler.codeGenerator.op_mov_RR(reg,REG_R11);
1341 }
1342}
1343
1344bool Compile_AddGlobalRootsForGc()
1345{
1346 const UserProc *pUserProc_AddGlobalRootPtr = GetClassMethod( "_System_CGarbageCollection", "AddGlobalRootPtr" );
1347 if( !pUserProc_AddGlobalRootPtr )
1348 {
1349 compiler.errorMessenger.Output(3, "_System_CGarbageCollection.AddGlobalRootPtr", -1 );
1350 return false;
1351 }
1352
1353 BOOST_FOREACH( const Variable *pVar, compiler.GetObjectModule().meta.GetGlobalVars() ){
1354 if( pVar->GetType().IsObject() || pVar->GetType().IsPointer() || pVar->GetType().IsStruct() ){
1355 // オブジェクトまたはポインタだったとき
1356 // ※構造体も含む(暫定対応)
1357
1358 // 変数領域に要するLONG_PTR単位の個数を引き渡す
1359 //mov r8,count
1360 compiler.codeGenerator.op_mov_RV(sizeof(_int64), REG_R8,pVar->GetMemorySize()/PTR_SIZE);
1361
1362 // ルートポインタを引き渡す
1363 //mov rdx,offset
1364 compiler.codeGenerator.op_mov_RV(sizeof(_int64), REG_RDX,(int)pVar->GetOffsetAddress(), Schedule::GlobalVar );
1365
1366 // Thisポインタを引き渡す
1367 SetThisPtrToReg(REG_RCX);
1368
1369 // call AddGlobalRootPtr
1370 compiler.codeGenerator.op_call( pUserProc_AddGlobalRootPtr );
1371 }
1372 }
1373
1374 return true;
1375}
Note: See TracBrowser for help on using the repository browser.