Changeset 376 in dev for trunk/abdev/BasicCompiler_Common/src/Class.cpp
- Timestamp:
- Nov 30, 2007, 8:31:42 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler_Common/src/Class.cpp
r375 r376 18 18 19 19 20 class CLoopRefCheck{ 21 char **names; 22 int num; 23 void init(){ 24 int i; 25 for(i=0;i<num;i++){ 26 free(names[i]); 27 } 28 free(names); 29 } 30 public: 31 CLoopRefCheck() 32 { 33 names=(char **)malloc(1); 34 num=0; 35 } 36 ~CLoopRefCheck() 37 { 38 init(); 39 } 40 void add(const char *lpszInheritsClass) 41 { 42 names=(char **)realloc(names,(num+1)*sizeof(char *)); 43 names[num]=(char *)malloc(lstrlen(lpszInheritsClass)+1); 44 lstrcpy(names[num],lpszInheritsClass); 45 num++; 46 } 47 void del(const char *lpszInheritsClass) 48 { 49 int i; 50 for(i=0;i<num;i++){ 51 if(lstrcmp(names[i],lpszInheritsClass)==0){ 52 free(names[i]); 53 break; 54 } 55 } 56 if(i!=num){ 57 num--; 58 for(;i<num;i++){ 59 names[i]=names[i+1]; 60 } 61 } 62 } 63 BOOL check(const CClass &inheritsClass) const 64 { 65 //ループ継承チェック 66 int i; 67 for(i=0;i<num;i++){ 68 if( inheritsClass.GetName() == names[i] ){ 69 return 1; 70 } 71 } 72 return 0; 73 } 74 }; 75 CLoopRefCheck *pobj_LoopRefCheck; 76 77 78 Interface::Interface( const CClass *pInterfaceClass ) 20 Interface::Interface( const CClass *pInterfaceClass, const Types &actualTypeParameters ) 79 21 : DynamicMethodsPrototype() 80 22 , pInterfaceClass( pInterfaceClass ) 81 23 , vtblOffset( -1 ) 24 , actualTypeParameters( actualTypeParameters ) 82 25 { 83 26 //メソッドをコピー … … 230 173 231 174 // 型パラメータ文字列から型データを取得 232 std::vector<Type>actualTypeParameters;175 Types actualTypeParameters; 233 176 BOOST_FOREACH( const std::string &typeParameterStr, typeParameterStrings ) 234 177 { … … 273 216 return true; 274 217 } 275 bool CClass::InheritsClass( const CClass &inheritsClass, const Types &actualTypeParameters, int nowLine ) {276 218 bool CClass::InheritsClass( const CClass &inheritsClass, const Types &actualTypeParameters, int nowLine ) 219 { 277 220 //ループ継承でないかをチェック 278 if(pobj_LoopRefCheck->check(inheritsClass)){ 221 if( !compiler.GetObjectModule().meta.GetClasses().LoopRefCheck(inheritsClass) ) 222 { 279 223 SmoothieException::Throw(123,inheritsClass.GetName(),nowLine); 280 224 return false; … … 283 227 if( !inheritsClass.IsReady() ){ 284 228 //継承先が読み取られていないとき 285 pobj_LoopRefCheck->add(this->GetName().c_str()); 286 compiler.GetObjectModule().meta.GetClasses().GetClass_recur(inheritsClass.GetName().c_str()); 287 pobj_LoopRefCheck->del(this->GetName().c_str()); 229 compiler.GetObjectModule().meta.GetClasses().LookaheadClass(inheritsClass.GetName().c_str()); 288 230 } 289 231 … … 355 297 } 356 298 357 bool CClass::Implements( const CClass &interfaceClass, const Jenga::Common::Strings &typeParameters, int nowLine )299 bool CClass::Implements( const CClass &interfaceClass, const Types &actualTypeParameters, int nowLine ) 358 300 { 359 301 if( !interfaceClass.IsInterface() && !interfaceClass.IsComInterface() ) … … 366 308 if( !interfaceClass.IsReady() ){ 367 309 // インターフェイスが未解析のとき 368 pobj_LoopRefCheck->add(this->GetName().c_str()); 369 compiler.GetObjectModule().meta.GetClasses().GetClass_recur(interfaceClass.GetName().c_str()); 370 pobj_LoopRefCheck->del(this->GetName().c_str()); 371 } 372 373 ::Interface *pDestInterface = new ::Interface( &interfaceClass ); 310 compiler.GetObjectModule().meta.GetClasses().LookaheadClass( interfaceClass.GetName().c_str() ); 311 } 312 313 ::Interface *pDestInterface = new ::Interface( &interfaceClass, actualTypeParameters ); 374 314 375 315 interfaces.push_back( pDestInterface ); … … 431 371 { 432 372 char className[VN_SIZE]; 433 Jenga::Common::Strings typeParameters; 434 SplitGenericClassInstance( paramStr.c_str(), className, typeParameters ); 373 Jenga::Common::Strings typeParameterStrings; 374 SplitGenericClassInstance( paramStr.c_str(), className, typeParameterStrings ); 375 376 Types actualTypeParameters; 377 BOOST_FOREACH( const std::string &typeParameterStr, typeParameterStrings ) 378 { 379 Type type; 380 compiler.StringToType( typeParameterStr, type ); 381 actualTypeParameters.push_back( type ); 382 } 435 383 436 384 //継承元クラスを取得 … … 442 390 443 391 // インターフェイスを継承する 444 Implements( *pInterfaceClass, typeParameters, nowLine );392 Implements( *pInterfaceClass, actualTypeParameters, nowLine ); 445 393 } 446 394 … … 578 526 else 579 527 { 528 ts(buffer); 580 529 // インターフェイス メソッドのオーバーライド 581 530 BOOST_FOREACH( ::Interface *pInterface, pobj_c->GetInterfaces() ) … … 1048 997 1049 998 return pClass; 1050 }1051 1052 void Classes::CollectClassesForNameOnly( const BasicSource &source )1053 {1054 int i, i2;1055 char temporary[VN_SIZE];1056 1057 // 名前空間管理1058 NamespaceScopes &namespaceScopes = compiler.GetNamespaceSupporter().GetLivingNamespaceScopes();1059 namespaceScopes.clear();1060 1061 // Importsされた名前空間の管理1062 NamespaceScopesCollection &importedNamespaces = compiler.GetNamespaceSupporter().GetImportedNamespaces();1063 importedNamespaces.clear();1064 1065 for(i=0;;i++){1066 if(source[i]=='\0') break;1067 1068 if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){1069 for(i+=2,i2=0;;i2++,i++){1070 if( IsCommandDelimitation( source[i] ) ){1071 temporary[i2]=0;1072 break;1073 }1074 temporary[i2]=source[i];1075 }1076 namespaceScopes.push_back( temporary );1077 1078 continue;1079 }1080 else if( source[i] == 1 && source[i+1] == ESC_ENDNAMESPACE ){1081 if( namespaceScopes.size() <= 0 ){1082 SmoothieException::Throw(12, "End Namespace", i );1083 }1084 else{1085 namespaceScopes.pop_back();1086 }1087 1088 i += 2;1089 continue;1090 }1091 else if( source[i] == 1 && source[i+1] == ESC_IMPORTS ){1092 for(i+=2,i2=0;;i2++,i++){1093 if( IsCommandDelimitation( source[i] ) ){1094 temporary[i2]=0;1095 break;1096 }1097 temporary[i2]=source[i];1098 }1099 if( !compiler.GetNamespaceSupporter().ImportsNamespace( temporary ) )1100 {1101 SmoothieException::Throw(64,temporary,i );1102 }1103 1104 continue;1105 }1106 else if( source[i] == 1 && source[i+1] == ESC_CLEARNAMESPACEIMPORTED ){1107 importedNamespaces.clear();1108 continue;1109 }1110 1111 if(source[i]==1&&(1112 source[i+1]==ESC_CLASS||1113 source[i+1]==ESC_TYPE||1114 source[i+1]==ESC_INTERFACE1115 ))1116 {1117 int nowLine = i;1118 i += 2;1119 1120 Type blittableType;1121 if(memicmp(source.GetBuffer()+i,"Align(",6)==0){1122 //アラインメント修飾子1123 i+=6;1124 i=JumpStringInPare(source.GetBuffer(),i)+1;1125 }1126 else if( memicmp( source.GetBuffer() + i, "Blittable(", 10 ) == 0 ){1127 // Blittable修飾子1128 i+=10;1129 i+=GetStringInPare_RemovePare(temporary,source.GetBuffer()+i)+1;1130 compiler.StringToType( temporary, blittableType );1131 }1132 1133 bool isEnum = false;1134 bool isDelegate = false;1135 if( source[i] == 1 && source[i+1] == ESC_ENUM ){1136 // 列挙型の場合1137 isEnum = true;1138 1139 i += 2;1140 }1141 else if( source[i] == 1 && source[i+1] == ESC_DELEGATE )1142 {1143 // デリゲートの場合1144 isDelegate = true;1145 1146 i += 2;1147 }1148 1149 for(i2=0;;i++,i2++){1150 if(!IsVariableChar(source[i])){1151 temporary[i2]=0;1152 break;1153 }1154 temporary[i2]=source[i];1155 }1156 1157 //クラスを追加1158 CClass *pClass = this->Add(namespaceScopes, importedNamespaces, temporary,nowLine);1159 if( pClass ){1160 if( source[nowLine+1] == ESC_CLASS ){1161 if( isEnum )1162 {1163 pClass->SetClassType( CClass::Enum );1164 }1165 else if( isDelegate )1166 {1167 pClass->SetClassType( CClass::Delegate );1168 }1169 else{1170 pClass->SetClassType( CClass::Class );1171 }1172 }1173 else if( source[nowLine+1] == ESC_INTERFACE ){1174 pClass->SetClassType( CClass::Interface );1175 }1176 else{1177 pClass->SetClassType( CClass::Structure );1178 }1179 }1180 1181 // Blittable型の場合1182 if( !blittableType.IsNull() ){1183 pClass->SetBlittableType( blittableType );1184 1185 // Blittable型として登録1186 compiler.GetObjectModule().meta.GetBlittableTypes().push_back( BlittableType( blittableType, pClass ) );1187 }1188 }1189 }1190 999 } 1191 1000 … … 1257 1066 cp=back_cp; 1258 1067 } 1259 bool Classes::MemberVar_LoopRefCheck(const CClass &objClass){ 1260 bool result = true; 1261 BOOST_FOREACH( CMember *pMember, objClass.GetDynamicMembers() ){ 1262 if(pMember->GetType().IsStruct()){ 1263 //循環参照でないかをチェック 1264 if(pobj_LoopRefCheck->check(pMember->GetType().GetClass())){ 1265 extern int cp; 1266 SetError(124,pMember->GetType().GetClass().GetName(),cp); 1267 return false; 1268 } 1269 1270 pobj_LoopRefCheck->add(objClass.GetName().c_str()); 1271 1272 bool tempResult = MemberVar_LoopRefCheck(pMember->GetType().GetClass()); 1273 if( result ) 1274 { 1275 result = tempResult; 1276 } 1277 1278 pobj_LoopRefCheck->del(objClass.GetName().c_str()); 1279 } 1280 } 1281 1282 return result; 1283 } 1284 void Classes::GetClass_recur(const char *lpszInheritsClass){ 1285 extern char *basbuf; 1286 int i,i2,i3,sub_address,top_pos; 1287 char temporary[8192]; 1288 1289 // 名前空間管理 1290 NamespaceScopes backupNamespaceScopes = compiler.GetNamespaceSupporter().GetLivingNamespaceScopes(); 1291 NamespaceScopes &namespaceScopes = compiler.GetNamespaceSupporter().GetLivingNamespaceScopes(); 1292 namespaceScopes.clear(); 1293 1294 // Importsされた名前空間の管理 1295 NamespaceScopesCollection backupImportedNamespaces = compiler.GetNamespaceSupporter().GetImportedNamespaces(); 1296 compiler.GetNamespaceSupporter().GetImportedNamespaces().clear(); 1297 1298 // 呼び出し元でコンパイル中のクラスポインタをバックアップ 1299 const CClass *pBackCompilingClass = compiler.pCompilingClass; 1300 1301 for(i=0;;i++){ 1302 if(basbuf[i]=='\0') break; 1303 1304 1305 // 名前空間 1306 if( basbuf[i] == 1 && basbuf[i+1] == ESC_NAMESPACE ){ 1307 for(i+=2,i2=0;;i2++,i++){ 1308 if( IsCommandDelimitation( basbuf[i] ) ){ 1309 temporary[i2]=0; 1310 break; 1311 } 1312 temporary[i2]=basbuf[i]; 1313 } 1314 namespaceScopes.push_back( temporary ); 1315 1316 continue; 1317 } 1318 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_ENDNAMESPACE ){ 1319 if( namespaceScopes.size() <= 0 ){ 1320 SetError(12, "End Namespace", i ); 1321 } 1322 else{ 1323 namespaceScopes.pop_back(); 1324 } 1325 1326 i += 2; 1327 continue; 1328 } 1329 1330 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_IMPORTS ){ 1331 for(i+=2,i2=0;;i2++,i++){ 1332 if( IsCommandDelimitation( basbuf[i] ) ){ 1333 temporary[i2]=0; 1334 break; 1335 } 1336 temporary[i2]=basbuf[i]; 1337 } 1338 if( !compiler.GetNamespaceSupporter().ImportsNamespace( temporary ) ) 1339 { 1340 SmoothieException::Throw(64,temporary,i ); 1341 } 1342 1343 continue; 1344 } 1345 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_CLEARNAMESPACEIMPORTED ){ 1346 compiler.GetNamespaceSupporter().GetImportedNamespaces().clear(); 1347 continue; 1348 } 1349 1350 1351 1352 if(basbuf[i]==1&&basbuf[i+1]==ESC_INTERFACE){ 1353 ////////////////////////// 1354 // インターフェイス 1355 ////////////////////////// 1356 1357 top_pos=i; 1358 1359 i+=2; 1360 1361 //インターフェイス名を取得 1362 GetCommandToken( temporary, basbuf, i ); 1363 1364 char className[VN_SIZE]; 1365 Jenga::Common::Strings typeParameters; 1366 SplitGenericClassInstance( temporary, className, typeParameters ); 1367 1368 CClass *pobj_c = const_cast<CClass *>( this->Find(namespaceScopes, temporary) ); 1369 if(!pobj_c) continue; 1370 1371 if(lpszInheritsClass){ 1372 if(lstrcmp(lpszInheritsClass,pobj_c->GetName().c_str())!=0){ 1373 //継承先先読み用 1374 continue; 1375 } 1376 } 1377 1378 if(pobj_c->IsReady()){ 1379 //既に先読みされているとき 1380 continue; 1381 } 1382 1383 ///////////////////////////////////////////////////////// 1384 // ☆★☆ ジェネリクスサポート ☆★☆ 1385 BOOST_FOREACH( const std::string &typeParameter, typeParameters ) 1386 { 1387 pobj_c->AddFormalGenericType( GenericType( typeParameter, Type(DEF_OBJECT,*GetObjectClassPtr()) ) ); 1388 } 1389 ///////////////////////////////////////////////////////// 1390 1391 pobj_c->Readed(); 1392 1393 pobj_c->SetConstructorMemberSubIndex( -1 ); 1394 pobj_c->SetDestructorMemberSubIndex( -1 ); 1395 1396 if( memcmp( basbuf+i+1, "__COM", 5 ) == 0 && IsCommandDelimitation( basbuf[i+1+5] ) ) 1397 { 1398 // COMインターフェイス 1399 pobj_c->SetClassType( CClass::ComInterface ); 1400 1401 i += 6; 1402 } 1403 1404 if(basbuf[i+1]==1&&basbuf[i+2]==ESC_INHERITS){ 1405 //継承を行う場合 1406 for(i+=3,i2=0;;i++,i2++){ 1407 if(IsCommandDelimitation(basbuf[i])){ 1408 temporary[i2]=0; 1409 break; 1410 } 1411 temporary[i2]=basbuf[i]; 1412 } 1413 1414 if(lstrcmpi(temporary,pobj_c->GetName().c_str())==0){ 1415 SetError(105,temporary,i); 1416 goto Interface_InheritsError; 1417 } 1418 1419 //継承元クラスを取得 1420 const Classes &classes = *this; 1421 const CClass *pInheritsClass = classes.Find(temporary); 1422 if( !pInheritsClass ){ 1423 SetError(106,temporary,i); 1424 goto Interface_InheritsError; 1425 } 1426 1427 //継承させる 1428 if( !pobj_c->InheritsClass( *pInheritsClass, Types(), i ) ){ 1429 goto Interface_InheritsError; 1430 } 1431 } 1432 else{ 1433 //継承無し 1434 if( &pobj_c->GetSuperClass() || pobj_c->GetVtblNum() ) 1435 { 1436 // TODO: ここに来ないことが実証できたらこの分岐は消す 1437 Jenga::Throw( "GetClass_recur内の例外" ); 1438 } 1439 } 1440 Interface_InheritsError: 1441 1442 //メンバ変数、関数を取得 1443 while(1){ 1444 i++; 1445 1446 //エラー 1447 if(basbuf[i]==1&&(basbuf[i+1]==ESC_CLASS||basbuf[i+1]==ESC_TYPE||basbuf[i+1]==ESC_INTERFACE)){ 1448 SetError(22,"Interface",i); 1449 i--; 1450 break; 1451 } 1452 1453 if(basbuf[i]==1&&basbuf[i+1]==ESC_INHERITS){ 1454 SetError(111,NULL,i); 1455 break; 1456 } 1457 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_IMPLEMENTS ) 1458 { 1459 SetError(137, NULL, i ); 1460 break; 1461 } 1462 1463 sub_address=i; 1464 1465 for(i2=0;;i++,i2++){ 1466 if(IsCommandDelimitation(basbuf[i])){ 1467 temporary[i2]=0; 1468 break; 1469 } 1470 temporary[i2]=basbuf[i]; 1471 } 1472 if(temporary[0]=='\0'){ 1473 if(basbuf[i]=='\0'){ 1474 i--; 1475 SetError(22,"Interface",top_pos); 1476 break; 1477 } 1478 continue; 1479 } 1480 1481 //End Interface記述の場合 1482 if(temporary[0]==1&&temporary[1]==ESC_ENDINTERFACE) break; 1483 1484 if(!(temporary[0]==1&&( 1485 temporary[1]==ESC_SUB||temporary[1]==ESC_FUNCTION 1486 ))){ 1487 SetError(1,NULL,i); 1488 break; 1489 } 1490 1491 //メンバ関数を追加 1492 pobj_c->AddMethod(pobj_c, 1493 Prototype::Public, //Publicアクセス権 1494 0, // bStatic 1495 false, // isConst 1496 true, // isAbstract 1497 true, // isVirtual 1498 false, // isOverride 1499 false, // isAutoGeneration 1500 temporary, 1501 sub_address 1502 ); 1503 } 1504 } 1505 1506 if(basbuf[i]==1&&(basbuf[i+1]==ESC_CLASS||basbuf[i+1]==ESC_TYPE)){ 1507 ////////////////////////// 1508 // クラス 1509 ////////////////////////// 1510 1511 top_pos=i; 1512 1513 const DWORD dwClassType=basbuf[i+1]; 1514 1515 i+=2; 1516 1517 int iAlign=0; 1518 if(memicmp(basbuf+i,"Align(",6)==0){ 1519 //アラインメント修飾子 1520 i+=6; 1521 i+=GetStringInPare_RemovePare(temporary,basbuf+i)+1; 1522 iAlign=atoi(temporary); 1523 1524 if(!(iAlign==1||iAlign==2||iAlign==4||iAlign==8||iAlign==16)) 1525 SetError(51,NULL,i); 1526 } 1527 else if( memicmp( basbuf + i, "Blittable(", 10 ) == 0 ){ 1528 // Blittable修飾子 1529 i+=10; 1530 i=JumpStringInPare(basbuf,i)+1; 1531 } 1532 1533 if( basbuf[i] == 1 && basbuf[i+1] == ESC_ENUM ) 1534 { 1535 // 列挙型の場合 1536 i += 2; 1537 } 1538 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_DELEGATE ) 1539 { 1540 // デリゲートの場合 1541 i += 2; 1542 } 1543 1544 //クラス名を取得 1545 GetCommandToken( temporary, basbuf, i ); 1546 1547 char className[VN_SIZE]; 1548 Jenga::Common::Strings typeParameters; 1549 SplitGenericClassInstance( temporary, className, typeParameters ); 1550 1551 CClass *pobj_c = const_cast<CClass *>( this->Find(namespaceScopes, className) ); 1552 if(!pobj_c) continue; 1553 1554 compiler.pCompilingClass = pobj_c; 1555 1556 if(lpszInheritsClass){ 1557 if( pobj_c->GetName() != lpszInheritsClass ){ 1558 //継承先先読み用 1559 continue; 1560 } 1561 } 1562 1563 if(pobj_c->IsReady()){ 1564 //既に先読みされているとき 1565 continue; 1566 } 1567 1568 1569 ///////////////////////////////////////////////////////// 1570 // ☆★☆ ジェネリクスサポート ☆★☆ 1571 BOOST_FOREACH( const std::string &typeParameter, typeParameters ) 1572 { 1573 pobj_c->AddFormalGenericType( GenericType( typeParameter, Type(DEF_OBJECT,*GetObjectClassPtr()) ) ); 1574 } 1575 ///////////////////////////////////////////////////////// 1576 1577 1578 pobj_c->SetFixedAlignment( iAlign ); 1579 1580 pobj_c->Readed(); 1581 1582 pobj_c->SetConstructorMemberSubIndex( -1 ); 1583 pobj_c->SetDestructorMemberSubIndex( -1 ); 1584 1585 //アクセス制限の初期値をセット 1586 Prototype::Accessibility accessibility; 1587 if(dwClassType==ESC_CLASS){ 1588 accessibility = Prototype::Private; 1589 } 1590 else{ 1591 accessibility = Prototype::Public; 1592 } 1593 1594 if( pobj_c->GetName() == "Object" 1595 || dwClassType == ESC_TYPE ) 1596 { 1597 // 何も継承しない 1598 1599 if( &pobj_c->GetSuperClass() || pobj_c->GetVtblNum() ) 1600 { 1601 // TODO: ここに来ないことが実証できたらこの分岐は消す 1602 Jenga::Throw( "GetClass_recur内の例外" ); 1603 } 1604 } 1605 else{ 1606 if(basbuf[i+1]==1&&basbuf[i+2]==ESC_INHERITS) 1607 { 1608 // クラス継承先が指定されているとき 1609 i += 3; 1610 GetCommandToken( temporary, basbuf, i ); 1611 1612 if(lstrcmpi(temporary,pobj_c->GetName().c_str())==0){ 1613 SetError(105,temporary,i); 1614 goto InheritsError; 1615 } 1616 } 1617 else 1618 { 1619 // 何の指定もないときはObjectクラスを継承する 1620 lstrcpy( temporary, "Object" ); 1621 } 1622 pobj_c->Inherits( temporary, i ); 1623 1624 if( basbuf[i+1] == 1 && basbuf[i+2] == ESC_IMPLEMENTS ) 1625 { 1626 // インターフェイス実装を行う場合 1627 i += 3; 1628 GetCommandToken( temporary, basbuf, i ); 1629 1630 pobj_c->Implements( temporary, i ); 1631 } 1632 } 1633 InheritsError: 1634 1635 //メンバとメソッドを取得 1636 while(1){ 1637 i++; 1638 1639 //エラー 1640 if(basbuf[i]==1&&(basbuf[i+1]==ESC_CLASS||basbuf[i+1]==ESC_TYPE)){ 1641 SetError(22,"Class",i); 1642 i--; 1643 break; 1644 } 1645 1646 if(basbuf[i]==1&&basbuf[i+1]==ESC_INHERITS){ 1647 SetError(111,NULL,i); 1648 break; 1649 } 1650 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_IMPLEMENTS ) 1651 { 1652 SetError(137, NULL, i ); 1653 break; 1654 } 1655 1656 //Static修飾子 1657 BOOL bStatic; 1658 if(basbuf[i]==1&&basbuf[i+1]==ESC_STATIC){ 1659 bStatic=1; 1660 i+=2; 1661 } 1662 else bStatic=0; 1663 1664 //Const修飾子 1665 bool isConst = false; 1666 if( basbuf[i] == 1 && basbuf[i + 1] == ESC_CONST ){ 1667 isConst = true; 1668 i += 2; 1669 } 1670 1671 if(basbuf[i]==1&&( 1672 basbuf[i+1]==ESC_ABSTRACT||basbuf[i+1]==ESC_VIRTUAL||basbuf[i+1]==ESC_OVERRIDE|| 1673 basbuf[i+1]==ESC_SUB||basbuf[i+1]==ESC_FUNCTION 1674 )){ 1675 i3=basbuf[i+1]; 1676 sub_address=i; 1677 } 1678 else i3=0; 1679 1680 bool isVirtual = false, isAbstract = false, isOverride = false; 1681 if(i3==ESC_ABSTRACT){ 1682 isAbstract=1; 1683 isVirtual=1; 1684 i+=2; 1685 1686 i3=basbuf[i+1]; 1687 } 1688 else if(i3==ESC_VIRTUAL){ 1689 isAbstract=0; 1690 isVirtual=1; 1691 i+=2; 1692 1693 i3=basbuf[i+1]; 1694 } 1695 else if(i3==ESC_OVERRIDE){ 1696 isOverride=1; 1697 isVirtual=1; 1698 1699 i+=2; 1700 1701 i3=basbuf[i+1]; 1702 } 1703 1704 for(i2=0;;i++,i2++){ 1705 if(IsCommandDelimitation(basbuf[i])){ 1706 temporary[i2]=0; 1707 break; 1708 } 1709 temporary[i2]=basbuf[i]; 1710 } 1711 if(temporary[0]=='\0'){ 1712 if(basbuf[i]=='\0'){ 1713 1714 if(dwClassType==ESC_CLASS) 1715 SetError(22,"Class",top_pos); 1716 else 1717 SetError(22,"Type",top_pos); 1718 1719 i--; 1720 break; 1721 } 1722 continue; 1723 } 1724 1725 //End Class記述の場合 1726 if(temporary[0]==1&&temporary[1]==ESC_ENDCLASS&&dwClassType==ESC_CLASS) break; 1727 if(temporary[0]==1&&temporary[1]==ESC_ENDTYPE&&dwClassType==ESC_TYPE) break; 1728 1729 //アクセスを変更 1730 if(lstrcmpi(temporary,"Private")==0){ 1731 accessibility = Prototype::Private; 1732 continue; 1733 } 1734 if(lstrcmpi(temporary,"Public")==0){ 1735 accessibility = Prototype::Public; 1736 continue; 1737 } 1738 if(lstrcmpi(temporary,"Protected")==0){ 1739 accessibility = Prototype::Protected; 1740 continue; 1741 } 1742 1743 extern int cp; 1744 if(i3==0){ 1745 if(bStatic){ 1746 //静的メンバを追加 1747 cp=i; //エラー用 1748 pobj_c->AddStaticMember( accessibility, isConst, false, temporary, i); 1749 } 1750 else{ 1751 //メンバを追加 1752 cp=i; //エラー用 1753 pobj_c->AddMember( accessibility, isConst, false, temporary, i ); 1754 1755 1756 if(pobj_c->GetDynamicMembers()[pobj_c->GetDynamicMembers().size()-1]->GetType().IsStruct()){ 1757 if( !pobj_c->GetDynamicMembers()[pobj_c->GetDynamicMembers().size()-1]->GetType().GetClass().IsReady() ){ 1758 //参照先が読み取られていないとき 1759 GetClass_recur(pobj_c->GetDynamicMembers()[pobj_c->GetDynamicMembers().size()-1]->GetType().GetClass().GetName().c_str()); 1760 } 1761 } 1762 1763 1764 if(pobj_c->GetDynamicMembers()[pobj_c->GetDynamicMembers().size()-1]->GetType().IsStruct()){ 1765 //循環参照のチェック 1766 pobj_LoopRefCheck->add(pobj_c->GetName().c_str()); 1767 if(!MemberVar_LoopRefCheck(pobj_c->GetDynamicMembers()[pobj_c->GetDynamicMembers().size()-1]->GetType().GetClass())){ 1768 //エラー回避 1769 Type &type = const_cast<Type &>(pobj_c->GetDynamicMembers().back()->GetType()); 1770 type.SetBasicType( DEF_PTR_VOID ); 1771 } 1772 pobj_LoopRefCheck->del(pobj_c->GetName().c_str()); 1773 } 1774 } 1775 } 1776 else{ 1777 //メソッドを追加 1778 cp=i; //エラー用 1779 pobj_c->AddMethod(pobj_c, 1780 accessibility, 1781 bStatic, 1782 isConst, 1783 isAbstract, 1784 isVirtual, 1785 isOverride, 1786 false, 1787 temporary, 1788 sub_address); 1789 1790 if( isAbstract ) continue; 1791 1792 for(;;i++){ 1793 if(basbuf[i]=='\0'){ 1794 i--; 1795 break; 1796 } 1797 if(basbuf[i-1]!='*'&& 1798 basbuf[i]==1&&( 1799 basbuf[i+1]==ESC_SUB|| 1800 basbuf[i+1]==ESC_FUNCTION|| 1801 basbuf[i+1]==ESC_MACRO|| 1802 basbuf[i+1]==ESC_TYPE|| 1803 basbuf[i+1]==ESC_CLASS|| 1804 basbuf[i+1]==ESC_INTERFACE|| 1805 basbuf[i+1]==ESC_ENUM)){ 1806 GetDefaultNameFromES(i3,temporary); 1807 SetError(22,temporary,i); 1808 } 1809 if(basbuf[i]==1&&basbuf[i+1]==GetEndXXXCommand((char)i3)){ 1810 i+=2; 1811 break; 1812 } 1813 } 1814 } 1815 } 1816 } 1817 } 1818 1819 // 呼び出し元でコンパイル中のクラスポインタを元に戻す 1820 compiler.pCompilingClass = pBackCompilingClass; 1821 1822 // 名前空間を元に戻す 1823 compiler.GetNamespaceSupporter().GetLivingNamespaceScopes() = backupNamespaceScopes; 1824 1825 // インポートされた名前空間を元に戻す 1826 compiler.GetNamespaceSupporter().GetImportedNamespaces() = backupImportedNamespaces; 1827 } 1828 void Classes::GetAllClassInfo(void){ 1829 //ループ継承チェック用のクラス 1830 pobj_LoopRefCheck=new CLoopRefCheck(); 1831 1832 //クラスを取得 1833 GetClass_recur(0); 1834 1835 delete pobj_LoopRefCheck; 1836 pobj_LoopRefCheck=0; 1837 1838 // イテレータの準備 1839 this->Iterator_Init(); 1840 } 1068 1841 1069 void Classes::Compile_System_InitializeUserTypes(){ 1842 1070 char temporary[VN_SIZE];
Note:
See TracChangeset
for help on using the changeset viewer.