Changeset 40 in dev for BasicCompiler64/Compile_Var.cpp
- Timestamp:
- Jan 28, 2007, 3:48:22 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler64/Compile_Var.cpp
r36 r40 206 206 } 207 207 208 CMember *pMember=pobj_c->ppobj_Member[i]; 209 208 210 209 211 //アクセシビリティをチェック 210 212 if(pobj_c==pobj_CompilingClass){ 211 213 //同一クラスオブジェクトの場合はプライベートアクセスを容認する 212 if(p obj_c->ppobj_Member[i]->dwAccess==ACCESS_NON){214 if(pMember->dwAccess==ACCESS_NON){ 213 215 if(isErrorEnabled) SetError(107,VarName,cp); 214 216 return 0; … … 216 218 } 217 219 else{ 218 if((bPrivateAccess==0&&p obj_c->ppobj_Member[i]->dwAccess==ACCESS_PRIVATE)||219 p obj_c->ppobj_Member[i]->dwAccess==ACCESS_NON){220 if((bPrivateAccess==0&&pMember->dwAccess==ACCESS_PRIVATE)|| 221 pMember->dwAccess==ACCESS_NON){ 220 222 if(isErrorEnabled) SetError(107,VarName,cp); 221 223 return 0; 222 224 } 223 else if(bPrivateAccess==0&&p obj_c->ppobj_Member[i]->dwAccess==ACCESS_PROTECTED){225 else if(bPrivateAccess==0&&pMember->dwAccess==ACCESS_PROTECTED){ 224 226 if(isErrorEnabled) SetError(108,VarName,cp); 225 227 return 0; … … 229 231 //Const定義の場合は書き込みアクセスを制限する 230 232 //※コンストラクタをコンパイル中の場合は例外的に許可する 231 if( p obj_c->ppobj_Member[i]->IsConst() && //定数メンバである233 if( pMember->IsConst() && //定数メンバである 232 234 isWriteAccess && //書き込みアクセスを要求されている 233 235 pobj_c->IsCompilingConstructor() == false //コンストラクタ コンパイル中を除く … … 237 239 } 238 240 239 *pType=p obj_c->ppobj_Member[i]->TypeInfo.type;240 *plpNestIndex=p obj_c->ppobj_Member[i]->TypeInfo.u.lpIndex;241 *pType=pMember->TypeInfo.type; 242 *plpNestIndex=pMember->TypeInfo.u.lpIndex; 241 243 242 244 //ポインタ変数の場合 243 245 if(IsPtrType(*pType)){ 244 if(p obj_c->ppobj_Member[i]->SubScripts[0]==-1){246 if(pMember->SubScripts[0]==-1){ 245 247 lstrcpy(lpPtrOffset,array); 246 248 array[0]=0; … … 265 267 if(array[0]){ 266 268 //配列オフセット 267 if(!GetArrayOffset(p obj_c->ppobj_Member[i]->SubScripts,array,*pType,pobj_c->ppobj_Member[i]->TypeInfo.u.lpIndex)){269 if(!GetArrayOffset(pMember->SubScripts,array,*pType,pMember->TypeInfo.u.lpIndex)){ 268 270 if(isErrorEnabled) SetError(14,member,cp); 269 271 } 270 272 } 271 else if(p obj_c->ppobj_Member[i]->SubScripts[0]!=-1){273 else if(pMember->SubScripts[0]!=-1){ 272 274 *pType|=FLAG_PTR; 273 275 } … … 276 278 //入れ子構造の場合 277 279 278 if(*pType==DEF_OBJECT ){280 if(*pType==DEF_OBJECT && pMember->IsRef() == false){ 279 281 if(RefType!=DEF_OBJECT){ 280 282 if(isErrorEnabled) SetError(104,member,cp); … … 282 284 } 283 285 } 284 else if(*pType==DEF_PTR_OBJECT ){286 else if(*pType==DEF_PTR_OBJECT || ( *pType==DEF_OBJECT && pMember->IsRef() )){ 285 287 //構造体ポインタ型メンバ変数 286 288 287 289 if(lpPtrOffset[0]){ 288 290 //pObj[n].member 289 if( RefType!=DEF_OBJECT){291 if(*pType==DEF_PTR_OBJECT&&RefType!=DEF_OBJECT){ 290 292 if(isErrorEnabled) SetError(104,member,cp); 291 293 return 0; … … 300 302 else{ 301 303 //pObj->member 302 if( RefType!=DEF_PTR_OBJECT){304 if(*pType==DEF_PTR_OBJECT&&RefType!=DEF_PTR_OBJECT){ 303 305 if(isErrorEnabled) SetError(104,member,cp); 304 306 return 0; … … 347 349 isErrorEnabled, 348 350 isWriteAccess, 349 p obj_c->ppobj_Member[i]->TypeInfo.u.pobj_Class,351 pMember->TypeInfo.u.pobj_Class, 350 352 NestMember, 351 353 pType, … … 383 385 SetReg_WholeVariable(DEF_PTR_VOID,&RelativeVar,reg); 384 386 } 385 BOOL GetVarOffset(bool isErrorEnabled,bool isWriteAccess,c har *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss){387 BOOL GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss){ 386 388 extern BOOL bCompilingGlobal; 387 389 int i,RefType; … … 432 434 pRelativeVar->offset=-LocalVar[i].offset; 433 435 pRelativeVar->bOffsetOffset=0; 434 if(LocalVar[i].fRef) pRelativeVar->dwKind=VAR_REFLOCAL; 436 if(LocalVar[i].fRef){ 437 // 参照型 438 pRelativeVar->dwKind = VAR_REFLOCAL; 439 } 435 440 else pRelativeVar->dwKind=VAR_LOCAL; 436 441 *pType=LocalVar[i].type; … … 1045 1050 1046 1051 1047 void dim(char *Parameter,DWORD dwFlag ){1052 void dim(char *Parameter,DWORD dwFlags){ 1048 1053 extern BOOL bCompilingGlobal; 1049 1054 extern HANDLE hHeap; … … 1051 1056 char VarName[VN_SIZE]; 1052 1057 1053 1054 if(dwFlag & DIMFLAG_CONST){ 1058 //参照型かどうか 1059 bool isRef = false; 1060 1061 i2 = 0; 1062 1063 if( Parameter[i2] == 1 && Parameter[i2+1] == ESC_BYREF ){ 1064 //参照型 1065 isRef = true; 1066 Parameter += 2; 1067 } 1068 1069 if(dwFlags & DIMFLAG_CONST){ 1070 1055 1071 ////////////////////////////////// 1056 1072 // 定数変数の場合を考慮 1057 1073 ////////////////////////////////// 1058 for( i2=0;;i2++){1074 for(;;i2++){ 1059 1075 if(Parameter[i2] == '=' || 1060 1076 Parameter[i2] == 1 && Parameter[i2] == ESC_AS || … … 1083 1099 char InitBuf[8192]; 1084 1100 char ConstractParameter[VN_SIZE]; 1085 if(!GetDimentionFormat(Parameter, VarName,SubScripts,&TypeInfo,InitBuf,ConstractParameter))1101 if(!GetDimentionFormat(Parameter, isRef , VarName,SubScripts,&TypeInfo,InitBuf,ConstractParameter)) 1086 1102 return; 1087 1103 … … 1104 1120 TypeSize=GetTypeSize(TypeInfo.type,TypeInfo.u.lpIndex); 1105 1121 1106 if(dwFlag &DIMFLAG_STATIC){1122 if(dwFlags&DIMFLAG_STATIC){ 1107 1123 if(bCompilingGlobal){ 1108 1124 SetError(60,NULL,cp); … … 1118 1134 GetNowStaticVarFullName(VarName,temporary); 1119 1135 1120 AddGlobalVariable(temporary,SubScripts,&TypeInfo,TypeSize,InitBuf,ConstractParameter,dwFlag );1136 AddGlobalVariable(temporary,SubScripts,&TypeInfo,TypeSize,InitBuf,ConstractParameter,dwFlags); 1121 1137 1122 1138 /* … … 1131 1147 ///////////////////////// 1132 1148 1133 AddGlobalVariable(VarName,SubScripts,&TypeInfo,TypeSize,InitBuf,ConstractParameter,dwFlag );1149 AddGlobalVariable(VarName,SubScripts,&TypeInfo,TypeSize,InitBuf,ConstractParameter,dwFlags); 1134 1150 } 1135 1151 else{ … … 1149 1165 1150 1166 LocalVar=(VARIABLE *)HeapReAlloc(hHeap,0,LocalVar,(MaxLocalVarNum+1)*sizeof(VARIABLE)); 1167 VARIABLE *pVar = &LocalVar[MaxLocalVarNum]; 1168 MaxLocalVarNum++; 1169 1170 if( isRef ){ 1171 //参照型 1172 pVar->fRef = REF_VARIABLE; 1173 TypeSize = PTR_SIZE; 1174 } 1175 else pVar->fRef=0; 1151 1176 1152 1177 for(i2=1,i3=0;i3<255;i3++){ 1153 1178 //配列要素数 1154 LocalVar[MaxLocalVarNum].SubScripts[i3]=SubScripts[i3];1179 pVar->SubScripts[i3]=SubScripts[i3]; 1155 1180 1156 1181 if(SubScripts[i3]==-1) break; … … 1160 1185 if(VarSize%8) VarSize+=8-(VarSize%8); 1161 1186 1162 VARIABLE *pVar = &LocalVar[MaxLocalVarNum];1163 1164 MaxLocalVarNum++;1165 1166 1187 //変数データを追加 1167 1188 lstrcpy(pVar->name,VarName); 1168 pVar->fRef=0; 1169 if(dwFlag & DIMFLAG_CONST) pVar->bConst = true; 1189 if(dwFlags & DIMFLAG_CONST) pVar->bConst = true; 1170 1190 else pVar->bConst = false; 1171 1191 if(SubScripts[0]==-1) pVar->bArray=0; … … 1194 1214 if(!result){ 1195 1215 //動的な式だった場合は代入演算を行う 1196 char temporary[8192]; 1197 sprintf(temporary,"%s=%s",VarName,InitBuf); 1198 OpcodeCalc(temporary); 1216 if( isRef ){ 1217 SetRefVariable( VarName, InitBuf ); 1218 } 1219 else{ 1220 char temporary[8192]; 1221 sprintf(temporary,"%s=%s",VarName,InitBuf); 1222 OpcodeCalc(temporary); 1223 } 1199 1224 } 1200 1225 … … 1227 1252 1228 1253 //コンストラクタ呼び出し 1229 if(TypeInfo.type==DEF_OBJECT&&(dwFlag &DIMFLAG_NONCALL_CONSTRACTOR)==0){1254 if(TypeInfo.type==DEF_OBJECT&&(dwFlags&DIMFLAG_NONCALL_CONSTRACTOR)==0&& isRef == false ){ 1230 1255 CallConstractor(VarName,SubScripts,TypeInfo,ConstractParameter); 1231 1256 } … … 1239 1264 } 1240 1265 } 1241 void OpcodeDim(char *Parameter,DWORD dwFlag ){1266 void OpcodeDim(char *Parameter,DWORD dwFlags){ 1242 1267 int i,i2,i3,IsStr=0; 1243 1268 char temporary[8192]; … … 1261 1286 temporary[i2]=0; 1262 1287 1263 dim(temporary,dwFlag );1288 dim(temporary,dwFlags); 1264 1289 1265 1290 if(Parameter[i]=='\0') break; … … 1322 1347 } 1323 1348 } 1324 else if( pRelativeVar->dwKind==VAR_REFLOCAL){1349 else if( pRelativeVar->dwKind == VAR_REFLOCAL ){ 1325 1350 if(pRelativeVar->bOffsetOffset){ 1326 1351 //add r11,qword ptr[rsp+offset]
Note:
See TracChangeset
for help on using the changeset viewer.