Changeset 40 in dev for BasicCompiler32/Compile_Var.cpp
- Timestamp:
- Jan 28, 2007, 3:48:22 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler32/Compile_Var.cpp
r36 r40 179 179 } 180 180 181 CMember *pMember=pobj_c->ppobj_Member[i]; 182 181 183 //アクセシビリティをチェック 182 184 if(pobj_c==pobj_CompilingClass){ 183 185 //同一クラスオブジェクトの場合はプライベートアクセスを容認する 184 if(p obj_c->ppobj_Member[i]->dwAccess==ACCESS_NON){186 if(pMember->dwAccess==ACCESS_NON){ 185 187 if(isErrorEnabled) SetError(107,VarName,cp); 186 188 return 0; … … 188 190 } 189 191 else{ 190 if((bPrivateAccess==0&&p obj_c->ppobj_Member[i]->dwAccess==ACCESS_PRIVATE)||191 p obj_c->ppobj_Member[i]->dwAccess==ACCESS_NON){192 if((bPrivateAccess==0&&pMember->dwAccess==ACCESS_PRIVATE)|| 193 pMember->dwAccess==ACCESS_NON){ 192 194 if(isErrorEnabled) SetError(107,VarName,cp); 193 195 return 0; 194 196 } 195 else if(bPrivateAccess==0&&p obj_c->ppobj_Member[i]->dwAccess==ACCESS_PROTECTED){197 else if(bPrivateAccess==0&&pMember->dwAccess==ACCESS_PROTECTED){ 196 198 if(isErrorEnabled) SetError(108,VarName,cp); 197 199 return 0; … … 201 203 //Const定義の場合は書き込みアクセスを制限する 202 204 //※コンストラクタをコンパイル中の場合は例外的に許可する 203 if( p obj_c->ppobj_Member[i]->IsConst() && //定数メンバである205 if( pMember->IsConst() && //定数メンバである 204 206 isWriteAccess && //書き込みアクセスを要求されている 205 207 pobj_c->IsCompilingConstructor() == false //コンストラクタ コンパイル中を除く … … 209 211 } 210 212 211 *pType=p obj_c->ppobj_Member[i]->TypeInfo.type;212 *plpNestIndex=p obj_c->ppobj_Member[i]->TypeInfo.u.lpIndex;213 *pType=pMember->TypeInfo.type; 214 *plpNestIndex=pMember->TypeInfo.u.lpIndex; 213 215 214 216 //ポインタ変数の場合 215 217 if(IsPtrType(*pType)){ 216 if(p obj_c->ppobj_Member[i]->SubScripts[0]==-1){218 if(pMember->SubScripts[0]==-1){ 217 219 lstrcpy(lpPtrOffset,array); 218 220 array[0]=0; … … 236 238 if(array[0]){ 237 239 //配列オフセット 238 if(!GetArrayOffset(p obj_c->ppobj_Member[i]->SubScripts,array,*pType,pobj_c->ppobj_Member[i]->TypeInfo.u.lpIndex))240 if(!GetArrayOffset(pMember->SubScripts,array,*pType,pMember->TypeInfo.u.lpIndex)) 239 241 if(isErrorEnabled) SetError(14,member,cp); 240 242 } 241 else if(p obj_c->ppobj_Member[i]->SubScripts[0]!=-1){243 else if(pMember->SubScripts[0]!=-1){ 242 244 *pType|=FLAG_PTR; 243 245 } … … 320 322 isErrorEnabled, 321 323 isWriteAccess, 322 p obj_c->ppobj_Member[i]->TypeInfo.u.pobj_Class,324 pMember->TypeInfo.u.pobj_Class, 323 325 NestMember, 324 326 pType, … … 357 359 } 358 360 359 BOOL GetVarOffset(bool isErrorEnabled, bool isWriteAccess, c har *NameBuffer, int *pType, RELATIVE_VAR *pRelativeVar, LONG_PTR *plpIndex, int *pss){361 BOOL GetVarOffset(bool isErrorEnabled, bool isWriteAccess, const char *NameBuffer, int *pType, RELATIVE_VAR *pRelativeVar, LONG_PTR *plpIndex, int *pss){ 360 362 extern BOOL bCompilingGlobal; 361 363 int i,RefType; … … 907 909 /////////////////////////////////////// 908 910 909 if( type == DEF_OBJECT){910 //オブジェクトの場合はありえない911 SetError(300,NULL,cp);912 return 0;913 }914 915 911 if(SubScripts[0]!=-1){ 916 912 SetError(41,0,cp); … … 1064 1060 } 1065 1061 1066 void dim(char *Parameter,DWORD dwFlag ){1062 void dim(char *Parameter,DWORD dwFlags){ 1067 1063 extern BOOL bCompilingGlobal; 1068 1064 extern HANDLE hHeap; … … 1071 1067 1072 1068 1073 if(dwFlag & DIMFLAG_CONST){ 1069 //参照型かどうか 1070 bool isRef = false; 1071 1072 i2 = 0; 1073 1074 if( Parameter[i2] == 1 && Parameter[i2+1] == ESC_BYREF ){ 1075 //参照型 1076 isRef = true; 1077 Parameter += 2; 1078 } 1079 1080 1081 if(dwFlags & DIMFLAG_CONST){ 1074 1082 ////////////////////////////////// 1075 1083 // 定数変数の場合を考慮 1076 1084 ////////////////////////////////// 1077 for( i2=0;;i2++){1085 for(;;i2++){ 1078 1086 if(Parameter[i2] == '=' || 1079 1087 Parameter[i2] == 1 && Parameter[i2] == ESC_AS || … … 1102 1110 char InitBuf[8192]; 1103 1111 char ConstractParameter[VN_SIZE]; 1104 if(!GetDimentionFormat(Parameter, VarName,SubScripts,&TypeInfo,InitBuf,ConstractParameter))1112 if(!GetDimentionFormat(Parameter, isRef, VarName,SubScripts,&TypeInfo,InitBuf,ConstractParameter)) 1105 1113 return; 1106 1114 … … 1123 1131 TypeSize=GetTypeSize(TypeInfo.type,TypeInfo.u.lpIndex); 1124 1132 1125 if(dwFlag &DIMFLAG_STATIC){1133 if(dwFlags&DIMFLAG_STATIC){ 1126 1134 if(bCompilingGlobal){ 1127 1135 SetError(60,NULL,cp); … … 1137 1145 GetNowStaticVarFullName(VarName,temporary); 1138 1146 1139 AddGlobalVariable(temporary,SubScripts,&TypeInfo,TypeSize,InitBuf,ConstractParameter,dwFlag );1147 AddGlobalVariable(temporary,SubScripts,&TypeInfo,TypeSize,InitBuf,ConstractParameter,dwFlags); 1140 1148 1141 1149 /* … … 1150 1158 ///////////////////////// 1151 1159 1152 AddGlobalVariable(VarName,SubScripts,&TypeInfo,TypeSize,InitBuf,ConstractParameter,dwFlag );1160 AddGlobalVariable(VarName,SubScripts,&TypeInfo,TypeSize,InitBuf,ConstractParameter,dwFlags); 1153 1161 } 1154 1162 else{ … … 1168 1176 1169 1177 LocalVar=(VARIABLE *)HeapReAlloc(hHeap,0,LocalVar,(MaxLocalVarNum+1)*sizeof(VARIABLE)); 1178 VARIABLE *pVar = &LocalVar[MaxLocalVarNum]; 1179 MaxLocalVarNum++; 1180 1181 if( isRef ){ 1182 //参照型 1183 pVar->fRef = REF_VARIABLE; 1184 TypeSize = PTR_SIZE; 1185 } 1186 else pVar->fRef=0; 1170 1187 1171 1188 for(i2=1,i3=0;i3<255;i3++){ 1172 1189 //配列要素数 1173 LocalVar[MaxLocalVarNum].SubScripts[i3]=SubScripts[i3];1190 pVar->SubScripts[i3]=SubScripts[i3]; 1174 1191 1175 1192 if(SubScripts[i3]==-1) break; … … 1179 1196 if(VarSize%4) VarSize+=4-(VarSize%4); 1180 1197 1181 VARIABLE *pVar = &LocalVar[MaxLocalVarNum];1182 1183 MaxLocalVarNum++;1184 1185 1198 //変数データを追加 1186 1199 lstrcpy(pVar->name,VarName); 1187 pVar->fRef=0; 1188 if(dwFlag & DIMFLAG_CONST) pVar->bConst = true; 1200 if(dwFlags & DIMFLAG_CONST) pVar->bConst = true; 1189 1201 else pVar->bConst = false; 1190 1202 if(SubScripts[0]==-1) pVar->bArray=0; … … 1212 1224 1213 1225 if(!result){ 1214 //動的な式だった場合は代入演算を行う 1215 char temporary[8192]; 1216 sprintf(temporary,"%s=%s",VarName,InitBuf); 1217 OpcodeCalc(temporary); 1226 if( isRef ){ 1227 SetRefVariable( VarName, InitBuf ); 1228 } 1229 else{ 1230 char temporary[8192]; 1231 sprintf(temporary,"%s=%s",VarName,InitBuf); 1232 OpcodeCalc(temporary); 1233 } 1218 1234 } 1219 1235 … … 1252 1268 1253 1269 //コンストラクタ呼び出し 1254 if(TypeInfo.type==DEF_OBJECT&&(dwFlag &DIMFLAG_NONCALL_CONSTRACTOR)==0){1270 if(TypeInfo.type==DEF_OBJECT&&(dwFlags&DIMFLAG_NONCALL_CONSTRACTOR)==0&& isRef == false ){ 1255 1271 CallConstractor(VarName,SubScripts,TypeInfo,ConstractParameter); 1256 1272 } … … 1264 1280 } 1265 1281 } 1266 void OpcodeDim(char *Parameter,DWORD dwFlag ){1282 void OpcodeDim(char *Parameter,DWORD dwFlags){ 1267 1283 int i,i2,i3,IsStr=0; 1268 1284 char temporary[8192]; … … 1286 1302 temporary[i2]=0; 1287 1303 1288 dim(temporary,dwFlag );1304 dim(temporary,dwFlags); 1289 1305 1290 1306 if(Parameter[i]=='\0') break;
Note:
See TracChangeset
for help on using the changeset viewer.