Changeset 40 in dev for BasicCompiler_Common/Class.cpp
- Timestamp:
- Jan 28, 2007, 3:48:22 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler_Common/Class.cpp
r31 r40 18 18 19 19 20 CMember::CMember( CClass *pobj_c, DWORD access, bool isConst, char *buffer, int NowLine ){20 CMember::CMember( CClass *pobj_c, DWORD access, bool isConst, bool isRef, char *buffer, int NowLine ){ 21 21 extern int cp; 22 22 … … 25 25 char init_buf[VN_SIZE]; 26 26 char constract_parameter[VN_SIZE]; 27 GetDimentionFormat(buffer, VarName,SubScripts,&TypeInfo,init_buf,constract_parameter);27 GetDimentionFormat(buffer,isRef,VarName,SubScripts,&TypeInfo,init_buf,constract_parameter); 28 28 29 29 //重複チェック … … 49 49 this->isConst = isConst; 50 50 51 //参照型かどうか 52 this->isRef = isRef; 53 51 54 //初期データ 52 55 InitBuf=(char *)HeapAlloc(hHeap,0,lstrlen(init_buf)+1); … … 70 73 //定数扱いかどうか 71 74 isConst = pobj->isConst; 75 76 //参照型かどうか 77 isRef = pobj->isRef; 72 78 73 79 //SubScripts … … 91 97 bool CMember::IsConst(){ 92 98 return isConst; 99 } 100 bool CMember::IsRef(){ 101 return isRef; 102 } 103 104 int CMember::GetSize(){ 105 if( IsRef() ){ 106 // 参照型 107 return PTR_SIZE; 108 } 109 110 //メンバサイズを取得 111 return GetTypeSize(TypeInfo.type,TypeInfo.u.lpIndex); 93 112 } 94 113 … … 264 283 pobj_InheritsClass = pInheritsClass; 265 284 } 266 void CClass::AddMember( DWORD dwAccess, bool isConst, char *buffer ){285 void CClass::AddMember( DWORD dwAccess, bool isConst, bool isRef, char *buffer ){ 267 286 ppobj_Member = (CMember **)HeapReAlloc( hHeap, 0, ppobj_Member, ( iMemberNum + 1 ) * sizeof(CMember *) ); 268 ppobj_Member[iMemberNum] = new CMember( this, dwAccess, isConst, buffer );287 ppobj_Member[iMemberNum] = new CMember( this, dwAccess, isConst, isRef, buffer ); 269 288 iMemberNum++; 270 289 } 271 void CClass::AddStaticMember( DWORD dwAccess, bool isConst, char *buffer, int NowLine ){290 void CClass::AddStaticMember( DWORD dwAccess, bool isConst, bool isRef, char *buffer, int NowLine ){ 272 291 ppobj_StaticMember=(CMember **)HeapReAlloc(hHeap,0,ppobj_StaticMember,(iStaticMemberNum+1)*sizeof(CMember *)); 273 ppobj_StaticMember[iStaticMemberNum]=new CMember( this, dwAccess, isConst, buffer, NowLine );292 ppobj_StaticMember[iStaticMemberNum]=new CMember( this, dwAccess, isConst, isRef, buffer, NowLine ); 274 293 iStaticMemberNum++; 275 294 } … … 439 458 //コンポジションの関係にあるメンバも検査する 440 459 for(int i=0;i < iMemberNum;i++){ 441 if(ppobj_Member[i]->TypeInfo.type==DEF_OBJECT ){460 if(ppobj_Member[i]->TypeInfo.type==DEF_OBJECT && ppobj_Member[i]->IsRef() == false){ 442 461 if(ppobj_Member[i]->TypeInfo.u.pobj_Class->IsAbstract()) 443 462 return true; … … 809 828 int i,i2,bRet=1; 810 829 for(i=0;i<pobj_c->iMemberNum;i++){ 811 if(pobj_c->ppobj_Member[i]->TypeInfo.type==DEF_OBJECT){ 830 CMember *pMember = pobj_c->ppobj_Member[i]; 831 if(pMember->TypeInfo.type==DEF_OBJECT && pMember->IsRef()==false ){ 812 832 //循環参照でないかをチェック 813 if(pobj_LoopRefCheck->check(p obj_c->ppobj_Member[i]->TypeInfo.u.pobj_Class->name)){833 if(pobj_LoopRefCheck->check(pMember->TypeInfo.u.pobj_Class->name)){ 814 834 extern int cp; 815 SetError(12 3,pobj_c->ppobj_Member[i]->TypeInfo.u.pobj_Class->name,cp);835 SetError(124,pMember->TypeInfo.u.pobj_Class->name,cp); 816 836 return 0; 817 837 } … … 819 839 pobj_LoopRefCheck->add(pobj_c->name); 820 840 821 i2=MemberVar_LoopRefCheck(p obj_c->ppobj_Member[i]->TypeInfo.u.pobj_Class);841 i2=MemberVar_LoopRefCheck(pMember->TypeInfo.u.pobj_Class); 822 842 if(bRet==1) bRet=i2; 823 843 … … 1132 1152 } 1133 1153 1154 //Ref修飾子 1155 bool isRef = false; 1156 if( basbuf[i] == 1 && basbuf[i + 1] == ESC_BYREF ){ 1157 isRef = true; 1158 i += 2; 1159 } 1160 1134 1161 if(basbuf[i]==1&&( 1135 1162 basbuf[i+1]==ESC_ABSTRACT||basbuf[i+1]==ESC_VIRTUAL||basbuf[i+1]==ESC_OVERRIDE|| … … 1209 1236 //静的メンバを追加 1210 1237 cp=i; //エラー用 1211 pobj_c->AddStaticMember( dwAccess, isConst, temporary, i);1238 pobj_c->AddStaticMember( dwAccess, isConst, isRef, temporary, i); 1212 1239 } 1213 1240 else{ 1214 1241 //メンバを追加 1215 1242 cp=i; //エラー用 1216 pobj_c->AddMember( dwAccess, isConst, temporary );1243 pobj_c->AddMember( dwAccess, isConst, isRef, temporary ); 1217 1244 1218 1245 … … 1237 1264 } 1238 1265 else{ 1266 // 文法エラーチェック 1267 if( isRef ){ 1268 SetError(1,NULL,cp); 1269 } 1270 1239 1271 //メソッドを追加 1240 1272 cp=i; //エラー用
Note:
See TracChangeset
for help on using the changeset viewer.