Changeset 90 in dev
- Timestamp:
- Apr 7, 2007, 3:02:29 PM (18 years ago)
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler32/Compile_Object.cpp
r75 r90 48 48 PROCFLAG_NEW,"",0); 49 49 50 { 51 // 動的型情報をセットする 52 // obj._System_SetType( _System_TypeBase.Search( strNamespace, name ) ) 53 subs.clear(); 54 pobj_c->EnumMethod( "_System_SetType", subs ); 55 if( subs.size() == 1 ){ 56 char temporary[VN_SIZE]; 57 sprintf( temporary, "_System_TypeBase.Search(\"\",\"%s\"))", pobj_c->name ); 58 59 Opcode_CallProc(temporary, 60 subs[0], 61 PROCFLAG_NEW,"",0); 62 } 63 else{ 64 SetError(); 65 } 66 } 67 50 68 51 69 -
BasicCompiler32/Compile_ProcOp.cpp
r89 r90 204 204 obp+=31; 205 205 } 206 else if( userProc.GetName() == "InitializeUserTypes" 206 else{ 207 SetError(); 208 } 209 } 210 void AutoGeneration(UserProc &userProc){ 211 if( userProc.GetName() == "InitializeUserTypes" 207 212 && userProc.HasParentClass() 208 213 && (string)userProc.GetParentClass().name == "_System_TypeBase" ){ … … 540 545 ////////////////////////////////////////// 541 546 ////// プロシージャ内をコンパイル //////// 542 if(pUserProc->IsMacro()) CompileBuffer(ESC_ENDMACRO,0); 547 if( pUserProc->IsAutoGeneration() ){ 548 AutoGeneration( *pUserProc ); 549 } 543 550 else{ 544 if(pUserProc->IsSub()) CompileBuffer(ESC_ENDSUB,0); 545 else if(pUserProc->IsFunction()) CompileBuffer(ESC_ENDFUNCTION,0); 551 if(pUserProc->IsMacro()){ 552 CompileBuffer(ESC_ENDMACRO,0); 553 } 554 else{ 555 if(pUserProc->IsSub()){ 556 CompileBuffer(ESC_ENDSUB,0); 557 } 558 else if(pUserProc->IsFunction()){ 559 CompileBuffer(ESC_ENDFUNCTION,0); 560 } 561 } 546 562 } 547 563 ////////////////////////////////////////// -
BasicCompiler32/MakePeHdr.cpp
r88 r90 249 249 if( pSubStaticMethod_System_TypeBase_InitializeUserTypes = GetSubHash( "_System_TypeBase.InitializeUserTypes",1 ) ){ 250 250 pSubStaticMethod_System_TypeBase_InitializeUserTypes->Using(); 251 pSubStaticMethod_System_TypeBase_InitializeUserTypes->ThisIs SystemProc();251 pSubStaticMethod_System_TypeBase_InitializeUserTypes->ThisIsAutoGenerationProc(); 252 252 } 253 253 -
BasicCompiler64/Compile_Object.cpp
r75 r90 48 48 pUserProc, 49 49 PROCFLAG_NEW,"",0); 50 51 { 52 // 動的型情報をセットする 53 // obj._System_SetType( _System_TypeBase.Search( strNamespace, name ) ) 54 subs.clear(); 55 pobj_c->EnumMethod( "_System_SetType", subs ); 56 if( subs.size() == 1 ){ 57 char temporary[VN_SIZE]; 58 sprintf( temporary, "_System_TypeBase.Search(\"\",\"%s\"))", pobj_c->name ); 59 60 Opcode_CallProc(temporary, 61 subs[0], 62 PROCFLAG_NEW,"",0); 63 } 64 else{ 65 SetError(); 66 } 67 } 50 68 51 69 if(bSomeObjects){ -
BasicCompiler64/Compile_ProcOp.cpp
r89 r90 195 195 obp+=31; 196 196 } 197 else if( userProc.GetName() == "InitializeUserTypes" 197 else{ 198 SetError(); 199 } 200 } 201 void AutoGeneration(UserProc &userProc){ 202 if( userProc.GetName() == "InitializeUserTypes" 198 203 && userProc.HasParentClass() 199 204 && (string)userProc.GetParentClass().name == "_System_TypeBase" ){ … … 591 596 ////////////////////////////////////////// 592 597 ////// プロシージャ内をコンパイル //////// 593 if(pUserProc->IsMacro()) CompileBuffer(ESC_ENDMACRO,0); 598 if( pUserProc->IsAutoGeneration() ){ 599 AutoGeneration( *pUserProc ); 600 } 594 601 else{ 595 if(pUserProc->IsSub()) CompileBuffer(ESC_ENDSUB,0); 596 else if(pUserProc->IsFunction()) CompileBuffer(ESC_ENDFUNCTION,0); 602 if(pUserProc->IsMacro()){ 603 CompileBuffer(ESC_ENDMACRO,0); 604 } 605 else{ 606 if(pUserProc->IsSub()){ 607 CompileBuffer(ESC_ENDSUB,0); 608 } 609 else if(pUserProc->IsFunction()){ 610 CompileBuffer(ESC_ENDFUNCTION,0); 611 } 612 } 597 613 } 598 614 ////////////////////////////////////////// -
BasicCompiler64/MakePeHdr.cpp
r89 r90 230 230 if( pSubStaticMethod_System_TypeBase_InitializeUserTypes = GetSubHash( "_System_TypeBase.InitializeUserTypes",1 ) ){ 231 231 pSubStaticMethod_System_TypeBase_InitializeUserTypes->Using(); 232 pSubStaticMethod_System_TypeBase_InitializeUserTypes->ThisIs SystemProc();232 pSubStaticMethod_System_TypeBase_InitializeUserTypes->ThisIsAutoGenerationProc(); 233 233 } 234 234 -
BasicCompiler_Common/Class.cpp
r89 r90 146 146 147 147 148 149 CClass::CClass(const char *name){ 150 memset(this,0,sizeof(CClass)); 151 152 vtbl_offset=-1; 153 148 CClass::CClass(const char *name): 149 ConstructorMemberSubIndex( 0 ), 150 DestructorMemberSubIndex( 0 ), 151 classType( Class ), 152 pobj_InheritsClass( NULL ), 153 ppobj_Member( NULL ), 154 iMemberNum( 0 ), 155 vtbl_num( 0 ), 156 iAlign( 0 ), 157 vtbl_offset( -1 ), 158 isCompilingConstructor( false ), 159 isCompilingDestructor( false ), 160 pobj_NextClass( NULL ) 161 { 154 162 this->name=(char *)HeapAlloc(hHeap,0,lstrlen(name)+1); 155 163 lstrcpy(this->name,name); 156 157 isCompilingConstructor = false;158 isCompilingDestructor = false;159 164 } 160 165 CClass::~CClass(){ … … 189 194 } 190 195 196 bool CClass::IsClass() const 197 { 198 return classType == CClass::Class; 199 } 200 bool CClass::IsInterface() const 201 { 202 return classType == CClass::Interface; 203 } 204 bool CClass::IsEnum() const 205 { 206 return classType == CClass::Enum; 207 } 208 bool CClass::IsDelegate() const 209 { 210 return classType == CClass::Delegate; 211 } 191 212 bool CClass::IsStructure() const 192 213 { … … 194 215 } 195 216 196 void CClass::Inherits( CClass *pInheritsClass ){ 217 bool CClass::Inherits( CClass &inheritsClass, int nowLine ){ 218 219 //ループ継承でないかをチェック 220 if(pobj_LoopRefCheck->check(inheritsClass)){ 221 SetError(123,inheritsClass.name,nowLine); 222 return false; 223 } 224 225 if( inheritsClass.ppobj_Member == 0 ){ 226 //継承先が読み取られていないとき 227 pobj_LoopRefCheck->add(this->name); 228 pobj_DBClass->GetClass_recur(inheritsClass.name); 229 pobj_LoopRefCheck->del(this->name); 230 } 197 231 198 232 //メンバをコピー … … 201 235 0, 202 236 ppobj_Member, 203 pInheritsClass->iMemberNum*sizeof(CMember *)); 204 iMemberNum=pInheritsClass->iMemberNum; 205 for(int i3=0;i3<pInheritsClass->iMemberNum;i3++){ 206 ppobj_Member[i3]=new CMember( *pInheritsClass->ppobj_Member[i3] ); 237 ( iMemberNum + inheritsClass.iMemberNum )*sizeof(CMember *)); 238 for(int i3=0;i3<inheritsClass.iMemberNum;i3++){ 239 ppobj_Member[iMemberNum]=new CMember( *inheritsClass.ppobj_Member[i3] ); 207 240 208 241 //dwAccess 209 if(pInheritsClass->ppobj_Member[i3]->dwAccess==ACCESS_PRIVATE) 210 ppobj_Member[i3]->dwAccess=ACCESS_NON; 211 else ppobj_Member[i3]->dwAccess=pInheritsClass->ppobj_Member[i3]->dwAccess; 242 if(inheritsClass.ppobj_Member[i3]->dwAccess==ACCESS_PRIVATE) 243 ppobj_Member[iMemberNum]->dwAccess=ACCESS_NON; 244 else ppobj_Member[iMemberNum]->dwAccess=inheritsClass.ppobj_Member[i3]->dwAccess; 245 246 iMemberNum++; 212 247 } 213 248 214 249 //メソッドをコピー 215 foreach( CMethod *baseMethod, pInheritsClass->methods ){250 foreach( CMethod *baseMethod, inheritsClass.methods ){ 216 251 CMethod *method = new CMethod( baseMethod ); 217 252 … … 224 259 // ※継承元のClassIndexをセット(入れ子継承を考慮する) 225 260 if(baseMethod->pobj_InheritsClass==0) 226 method->pobj_InheritsClass= pInheritsClass;261 method->pobj_InheritsClass=&inheritsClass; 227 262 else 228 263 method->pobj_InheritsClass= … … 233 268 234 269 //仮想関数の数 235 vtbl_num =pInheritsClass->vtbl_num;270 vtbl_num += inheritsClass.vtbl_num; 236 271 237 272 //継承先のクラスをメンバとして保持する 238 pobj_InheritsClass = pInheritsClass; 273 pobj_InheritsClass = &inheritsClass; 274 275 return true; 276 } 277 bool CClass::InheritsInterface( CClass &inheritsInterface, int nowLine ){ 278 279 //ループ継承でないかをチェック 280 if(pobj_LoopRefCheck->check(inheritsInterface)){ 281 SetError(123,inheritsInterface.name,nowLine); 282 return false; 283 } 284 285 if( inheritsInterface.ppobj_Member == 0 ){ 286 //継承先が読み取られていないとき 287 pobj_LoopRefCheck->add(this->name); 288 pobj_DBClass->GetClass_recur(inheritsInterface.name); 289 pobj_LoopRefCheck->del(this->name); 290 } 291 292 //メソッドをコピー 293 foreach( CMethod *baseMethod, inheritsInterface.methods ){ 294 CMethod *method = new CMethod( baseMethod ); 295 296 //dwAccess 297 if(baseMethod->dwAccess==ACCESS_PRIVATE) 298 method->dwAccess=ACCESS_NON; 299 else method->dwAccess=baseMethod->dwAccess; 300 301 //pobj_Inherits 302 // ※継承元のClassIndexをセット(入れ子継承を考慮する) 303 if(baseMethod->pobj_InheritsClass==0) 304 method->pobj_InheritsClass=&inheritsInterface; 305 else 306 method->pobj_InheritsClass= 307 baseMethod->pobj_InheritsClass; 308 309 methods.push_back( method ); 310 } 311 312 //仮想関数の数 313 vtbl_num += inheritsInterface.vtbl_num; 314 315 /* 316 TODO: インターフェイス向けの機構を作る 317 //継承先のクラスをメンバとして保持する 318 pobj_InheritsClass = &inheritsInterface; 319 */ 320 321 return true; 239 322 } 240 323 void CClass::AddMember( DWORD dwAccess, bool isConst, bool isRef, char *buffer ){ … … 950 1033 if(pMember->IsStruct()){ 951 1034 //循環参照でないかをチェック 952 if(pobj_LoopRefCheck->check(pMember->GetClass() .name)){1035 if(pobj_LoopRefCheck->check(pMember->GetClass())){ 953 1036 extern int cp; 954 1037 SetError(124,pMember->GetClass().name,cp); … … 1035 1118 } 1036 1119 1037 //ループ継承でないかをチェック 1038 if(pobj_LoopRefCheck->check(temporary)){ 1039 SetError(123,temporary,i); 1120 //継承させる 1121 if( !pobj_c->InheritsInterface( *pInheritsClass, i ) ){ 1040 1122 goto Interface_InheritsError; 1041 1123 } 1042 1043 if( pInheritsClass->ppobj_Member == 0 ){1044 //継承先が読み取られていないとき1045 pobj_LoopRefCheck->add(pobj_c->name);1046 GetClass_recur(temporary);1047 pobj_LoopRefCheck->del(pobj_c->name);1048 }1049 1050 //継承させる1051 pobj_c->Inherits( pInheritsClass );1052 1124 } 1053 1125 else{ … … 1207 1279 } 1208 1280 1209 //ループ継承でないかをチェック 1210 if(pobj_LoopRefCheck->check(temporary)){ 1211 SetError(123,temporary,i); 1281 if( pInheritsClass->IsInterface() ){ 1282 // クラスを継承していないとき 1283 CClass *pObjectClass = check("Object"); 1284 if( !pObjectClass ){ 1285 SetError(106,"Object",i); 1286 goto InheritsError; 1287 } 1288 1289 if( !pobj_c->Inherits( *pObjectClass, i ) ){ 1290 goto InheritsError; 1291 } 1292 } 1293 1294 //継承させる 1295 if( !pobj_c->Inherits( *pInheritsClass, i ) ){ 1212 1296 goto InheritsError; 1213 1297 } 1214 1215 if( pInheritsClass->ppobj_Member == 0 ){1216 //継承先が読み取られていないとき1217 pobj_LoopRefCheck->add(pobj_c->name);1218 GetClass_recur(temporary);1219 pobj_LoopRefCheck->del(pobj_c->name);1220 }1221 1222 //継承させる1223 pobj_c->Inherits( pInheritsClass );1224 1298 } 1225 1299 InheritsError: … … 1425 1499 1426 1500 void CDBClass::Compile_System_InitializeUserTypes(){ 1501 char temporary[VN_SIZE]; 1427 1502 1428 1503 //////////////////////////////////////////////////////////////////// … … 1436 1511 CClass *pClass = Iterator_GetNext(); 1437 1512 1438 char temporary[VN_SIZE];1439 1513 sprintf( temporary 1440 1514 , "Add(%c%c_System_TypeForClass(\"%s\",\"%s\"))" … … 1451 1525 ReallocNativeCodeBuffer(); 1452 1526 } 1527 1528 1529 //////////////////////////////////////////////////////////////////// 1530 // 基底クラスを登録 1531 //////////////////////////////////////////////////////////////////// 1532 1533 sprintf(temporary, "%c%ctempType=Nothing%c%cTypeBaseImpl" 1534 , HIBYTE( COM_DIM ) 1535 , LOBYTE( COM_DIM ) 1536 , 1 1537 , ESC_AS 1538 ); 1539 ChangeOpcode( temporary ); 1540 1541 // イテレータをリセット 1542 Iterator_Reset(); 1543 1544 while( Iterator_HasNext() ){ 1545 CClass *pClass = Iterator_GetNext(); 1546 1547 if( pClass->pobj_InheritsClass ){ 1548 sprintf( temporary 1549 , "tempType=Search(\"%s\",\"%s\")" 1550 , "" // 名前空間 (TODO: 実装) 1551 , pClass->name // クラス名 1552 ); 1553 1554 // コンパイル 1555 ChangeOpcode( temporary ); 1556 1557 sprintf( temporary 1558 , "tempType.SetBaseType(Search(\"%s\",\"%s\"))" 1559 , "" // 名前空間 (TODO: 実装) 1560 , pClass->pobj_InheritsClass->name // 基底クラス名 1561 ); 1562 1563 // コンパイル 1564 ChangeOpcode( temporary ); 1565 } 1566 1567 // ネイティブコードバッファの再確保 1568 ReallocNativeCodeBuffer(); 1569 } 1570 1453 1571 1454 1572 -
BasicCompiler_Common/Class.h
r89 r90 71 71 enum ClassType{ 72 72 Class, 73 Interface, 74 Enum, 75 Delegate, 73 76 Structure, 74 Interface,75 77 }; 76 78 … … 99 101 ~CClass(); 100 102 103 bool IsClass() const; 104 bool IsInterface() const; 105 bool IsEnum() const; 106 bool IsDelegate() const; 101 107 bool IsStructure() const; 102 108 103 109 //継承させる 104 void Inherits( CClass *pInheritsClass ); 110 bool Inherits( CClass &inheritsClass, int nowLine ); 111 bool InheritsInterface( CClass &inheritsClass, int nowLine ); 105 112 106 113 //メンバ、メソッドの追加 -
BasicCompiler_Common/LoopRefCheck.cpp
r4 r90 45 45 } 46 46 } 47 BOOL CLoopRefCheck::check(char *lpszInheritsClass){ 47 BOOL CLoopRefCheck::check(const CClass &inheritsClass) const 48 { 48 49 //ループ継承チェック 49 50 int i; 50 51 for(i=0;i<num;i++){ 51 if(lstrcmp(names[i], lpszInheritsClass)==0) return 1;52 if(lstrcmp(names[i],inheritsClass.name)==0) return 1; 52 53 } 53 54 return 0; -
BasicCompiler_Common/ParamImpl.cpp
r84 r90 10 10 #define OVERLOAD_MAX_LEVEL 4 11 11 #define OVERLOAD_LEVEL0 0 // 型調整なし。厳密に等しい 12 #define OVERLOAD_LEVEL1 1 // 型調整なし。整数型/実数型レベルでの同一性チェック 13 #define OVERLOAD_LEVEL2 2 // 型調整あり。厳密に等しい 14 #define OVERLOAD_LEVEL3 3 // 型調整あり。整数型/実数型レベルでの同一性チェック 15 #define OVERLOAD_LEVEL4 4 // 型調整あり。数値型/クラス型レベルでの同一性チェック 12 #define OVERLOAD_LEVEL1 1 // 型調整なし。レベル1以上はオブジェクトの場合は派生関係を考慮 13 #define OVERLOAD_LEVEL2 2 // 型調整なし。整数型/実数型レベルでの同一性チェック 14 #define OVERLOAD_LEVEL3 3 // 型調整あり。厳密に等しい 15 #define OVERLOAD_LEVEL4 4 // 型調整あり。整数型/実数型レベルでの同一性チェック 16 #define OVERLOAD_LEVEL5 5 // 型調整あり。数値型/クラス型レベルでの同一性チェック 16 17 17 18 ParamImpl::ParamImpl(const char *buffer): … … 127 128 128 129 NumOpe_GetType(Parms[i], 129 ( level==OVERLOAD_LEVEL0 || level == OVERLOAD_LEVEL1)? nullParam : param,130 ( level <= OVERLOAD_LEVEL2 )? nullParam : param, 130 131 argType); 131 132 } … … 135 136 136 137 if(argType.GetBasicType()!=param.GetBasicType()){ 137 if( level == OVERLOAD_LEVEL0 || level ==OVERLOAD_LEVEL2){138 if( level == OVERLOAD_LEVEL0 || level == OVERLOAD_LEVEL1 || level==OVERLOAD_LEVEL3 ){ 138 139 return false; 139 140 } 140 else if( level == OVERLOAD_LEVEL 1 || level==OVERLOAD_LEVEL3){141 else if( level == OVERLOAD_LEVEL2 || level==OVERLOAD_LEVEL4){ 141 142 if(!( 142 143 argType.IsWhole()&¶m.IsWhole()|| … … 146 147 } 147 148 } 148 else if(level==OVERLOAD_LEVEL 4){149 else if(level==OVERLOAD_LEVEL5){ 149 150 if(argType.IsObject()||param.IsObject()) return false; 150 151 } … … 158 159 } 159 160 else if( NATURAL_TYPE(argType.GetBasicType())==DEF_OBJECT ){ 160 if( !param.GetClass().IsEqualsOrSubClass( &argType.GetClass() ) ){ 161 return false; 161 if( level == OVERLOAD_LEVEL0 ){ 162 if( !param.GetClass().IsEquals( &argType.GetClass() ) ){ 163 return false; 164 } 165 } 166 else{ 167 if( !param.GetClass().IsEqualsOrSubClass( &argType.GetClass() ) ){ 168 return false; 169 } 162 170 } 163 171 } … … 191 199 192 200 pUserProc = pTempUserProc; 193 break;194 201 } 195 202 } -
BasicCompiler_Common/Procedure.h
r89 r90 101 101 bool isExport; 102 102 bool isSystem; 103 bool isAutoGeneration; 103 104 bool isCompiled; 104 105 … … 114 115 isExport( isExport ), 115 116 isSystem( false ), 117 isAutoGeneration( false ), 116 118 isCompiled( false ), 117 119 pNextData( NULL ) … … 176 178 { 177 179 return isSystem; 180 } 181 void ThisIsAutoGenerationProc(){ 182 isAutoGeneration = true; 183 } 184 bool IsAutoGeneration(){ 185 return isAutoGeneration; 178 186 } 179 187 void CompleteCompile(){ -
BasicCompiler_Common/common.h
r89 r90 47 47 48 48 #ifdef _AMD64_ 49 #define VER_INFO "(x64) β rev. 194"49 #define VER_INFO "(x64) β rev.206" 50 50 #else 51 #define VER_INFO "β rev. 194"51 #define VER_INFO "β rev.206" 52 52 #endif 53 53 … … 460 460 void add(char *lpszInheritsClass); 461 461 void del(char *lpszInheritsClass); 462 BOOL check(c har *lpszInheritsClass);462 BOOL check(const CClass &inheritsClass) const; 463 463 }; 464 464 extern CLoopRefCheck *pobj_LoopRefCheck;
Note:
See TracChangeset
for help on using the changeset viewer.