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

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

[636][637][640][641][642]を64bit版にマージ。

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