Changeset 128 in dev
- Timestamp:
- May 18, 2007, 4:42:36 AM (18 years ago)
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler32/Compile_Calc.cpp
r116 r128 619 619 620 620 621 if( varType.IsObject() && Smoothie::Meta::blittableTypes.IsExist( calcType ) ){ 622 // Blittable型をオブジェクトとして扱う 623 vector<UserProc *> userProcs; 624 Smoothie::Meta::blittableTypes.GetClass( calcType ).EnumStaticMethod( "_Create", userProcs ); 625 if( userProcs.size() != 1 ){ 626 SetError(); 627 return; 628 } 629 UserProc *pUserProc = userProcs[0]; 630 631 // call System.[TypeClass]._Create 632 op_call( pUserProc ); 633 634 // push eax 635 op_push( REG_EAX ); 636 637 calcType = pUserProc->ReturnType(); 638 } 639 621 640 622 641 ///////////////////////////////// -
BasicCompiler32/Compile_Statement.cpp
r122 r128 90 90 bool isLiteral; 91 91 BOOL bUseHeap; 92 bool result = TermOpe( leftTerm, Type(), resultType, isLiteral, &bUseHeap, NULL, true ); 93 92 bool result = TermOpe( leftTerm, Type(), resultType, isLiteral, &bUseHeap, false, NULL, true ); 94 93 if( result ){ 95 94 -
BasicCompiler32/NumOpe.cpp
r122 r128 227 227 return false; 228 228 } 229 bool TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, BOOL *pbUseHeap, bool *pIsClassName, bool isProcedureCallOnly ){229 bool TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, BOOL *pbUseHeap, bool isWantObject, bool *pIsClassName, bool isProcedureCallOnly ){ 230 230 char parameter[VN_SIZE]; 231 231 … … 255 255 bool isClassName = false; 256 256 Type leftType; 257 if( !TermOpe( termLeft, baseType, leftType, isLiteral, pbUseHeap, &isClassName ) ){ 257 if( GetTermType( termLeft, leftType, isLiteral, &isClassName ) ){ 258 if( isClassName == false && Smoothie::Meta::blittableTypes.IsExist( leftType ) ){ 259 // 左側のオブジェクト部分がBlittable型のとき 260 261 char temporary[VN_SIZE]; 262 lstrcpy( temporary, termLeft ); 263 sprintf( termLeft, "%s(%s)", 264 Smoothie::Meta::blittableTypes.Find( leftType ).GetCreateStaticMethodFullName().c_str(), 265 temporary ); 266 } 267 } 268 269 if( !TermOpe( termLeft, baseType, leftType, isLiteral, pbUseHeap, true, &isClassName ) ){ 258 270 goto globalArea; 259 271 } -
BasicCompiler32/Opcode.h
r122 r128 102 102 //NumOpe.cpp 103 103 void PushReturnValue(int type); 104 bool TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, BOOL *pbUseHeap, bool *pIsClassName = NULL, bool isProcedureCallOnly = false ); 104 bool TermOpe( 105 const char *term, 106 const Type &baseType, 107 Type &resultType, 108 bool &isLiteral, 109 BOOL *pbUseHeap, 110 bool isWantObject = false, 111 bool *pIsClassName = NULL, 112 bool isProcedureCallOnly = false ); 105 113 bool NumOpe( int reg, 106 114 const char *expression, -
BasicCompiler64/BasicCompiler.vcproj
r127 r128 157 157 RuntimeLibrary="1" 158 158 UsePrecompiledHeader="0" 159 PrecompiledHeaderFile=".\ Debug/BasicCompiler.pch"160 AssemblerListingLocation=".\ Debug/"161 ObjectFile=".\ Debug/"162 ProgramDataBaseFileName=".\ Debug/"159 PrecompiledHeaderFile=".\SmallDebug/BasicCompiler.pch" 160 AssemblerListingLocation=".\SmallDebug/" 161 ObjectFile=".\SmallDebug/" 162 ProgramDataBaseFileName=".\SmallDebug/" 163 163 BrowseInformation="0" 164 164 WarningLevel="3" … … 188 188 IgnoreDefaultLibraryNames="" 189 189 GenerateDebugInformation="false" 190 ProgramDatabaseFile=".\ Debug/BasicCompiler64.pdb"190 ProgramDatabaseFile=".\SmallDebug/BasicCompiler64.pdb" 191 191 SubSystem="2" 192 192 TargetMachine="0" -
BasicCompiler64/Compile_Calc.cpp
r116 r128 227 227 } 228 228 229 if( varType.IsObject() && Smoothie::Meta::blittableTypes.IsExist( calcType ) ){ 230 // Blittable型をオブジェクトとして扱う 231 vector<UserProc *> userProcs; 232 Smoothie::Meta::blittableTypes.GetClass( calcType ).EnumStaticMethod( "_Create", userProcs ); 233 if( userProcs.size() != 1 ){ 234 SetError(); 235 return; 236 } 237 UserProc *pUserProc = userProcs[0]; 238 239 // mov rcx, rax 240 op_mov_RR( REG_RCX, REG_RAX ); 241 242 // call System.[TypeClass]._Create 243 op_call( pUserProc ); 244 245 calcType = pUserProc->ReturnType(); 246 } 229 247 230 248 ///////////////////////////////// -
BasicCompiler64/Compile_Statement.cpp
r122 r128 94 94 bool isLiteral; 95 95 BOOL bUseHeap; 96 bool result = TermOpe( leftTerm, Type(), resultType, isLiteral, &bUseHeap, NULL, true );96 bool result = TermOpe( leftTerm, Type(), resultType, isLiteral, &bUseHeap, false, NULL, true ); 97 97 98 98 delete pobj_reg; -
BasicCompiler64/NumOpe.cpp
r122 r128 224 224 return false; 225 225 } 226 bool TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, BOOL *pbUseHeap, bool *pIsClassName, bool isProcedureCallOnly ){226 bool TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, BOOL *pbUseHeap, bool isWantObject, bool *pIsClassName, bool isProcedureCallOnly ){ 227 227 char parameter[VN_SIZE]; 228 228 … … 252 252 bool isClassName = false; 253 253 Type leftType; 254 if( !TermOpe( termLeft, baseType, leftType, isLiteral, pbUseHeap, &isClassName ) ){ 254 if( GetTermType( termLeft, leftType, isLiteral, &isClassName ) ){ 255 if( isClassName == false && Smoothie::Meta::blittableTypes.IsExist( leftType ) ){ 256 // 左側のオブジェクト部分がBlittable型のとき 257 258 char temporary[VN_SIZE]; 259 lstrcpy( temporary, termLeft ); 260 sprintf( termLeft, "%s(%s)", 261 Smoothie::Meta::blittableTypes.Find( leftType ).GetCreateStaticMethodFullName().c_str(), 262 temporary ); 263 } 264 } 265 266 if( !TermOpe( termLeft, baseType, leftType, isLiteral, pbUseHeap, true, &isClassName ) ){ 255 267 goto globalArea; 256 268 } … … 705 717 //型名 706 718 if( Type::StringToType( term, resultType ) ){ 719 720 if( resultType.IsObject() ){ 721 if( resultType.GetClass().IsBlittableType() ){ 722 // Blittable型のときは基本型として扱う 723 // ※ただし、コンパイル中のメソッドがBlittable型クラスに属していないこと 724 if( UserProc::IsLocalAreaCompiling() 725 && UserProc::CompilingUserProc().HasParentClass() 726 && UserProc::CompilingUserProc().GetParentClass().IsBlittableType() ) 727 { 728 // コンパイル中のメソッドがBlittable型クラスに属している 729 } 730 else{ 731 resultType = resultType.GetClass().GetBlittableType(); 732 } 733 } 734 } 735 707 736 resultType.SetBasicType( resultType.GetBasicType() | FLAG_CAST ); 708 737 } -
BasicCompiler64/Opcode.h
r122 r128 251 251 252 252 //NumOpe.cpp 253 bool TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, BOOL *pbUseHeap, bool *pIsClassName = NULL, bool isProcedureCallOnly = false ); 253 bool TermOpe( 254 const char *term, 255 const Type &baseType, 256 Type &resultType, 257 bool &isLiteral, 258 BOOL *pbUseHeap, 259 bool isWantObject = false, 260 bool *pIsClassName = NULL, 261 bool isProcedureCallOnly = false ); 254 262 bool NumOpe( int *pReg, 255 263 const char *Command, -
BasicCompiler_Common/Class.cpp
r127 r128 911 911 char temporary[VN_SIZE]; 912 912 913 // Blittable型管理オブジェクトを初期化 914 Smoothie::Meta::blittableTypes.clear(); 915 913 916 // 名前空間管理 914 917 NamespaceScopes &namespaceScopes = Smoothie::Lexical::liveingNamespaceScopes; … … 971 974 972 975 i+=2; 973 //アラインメント修飾子976 Type blittableType; 974 977 if(memicmp(basbuf+i,"Align(",6)==0){ 978 //アラインメント修飾子 975 979 i+=6; 976 980 i=JumpStringInPare(basbuf,i)+1; 981 } 982 else if( memicmp( basbuf + i, "Blittable(", 10 ) == 0 ){ 983 // Blittable修飾子 984 i+=10; 985 i+=GetStringInPare_RemovePare(temporary,basbuf+i)+1; 986 Type::StringToType( temporary, blittableType ); 977 987 } 978 988 … … 1013 1023 } 1014 1024 } 1025 1026 // Blittable型の場合 1027 if( !blittableType.IsNull() ){ 1028 pClass->SetBlittableType( blittableType ); 1029 1030 // Blittable型として登録 1031 Smoothie::Meta::blittableTypes.push_back( BlittableType( blittableType, pClass ) ); 1032 } 1015 1033 } 1016 1034 } … … 1344 1362 i+=2; 1345 1363 1346 //アラインメント修飾子1347 1364 int iAlign=0; 1348 1365 if(memicmp(basbuf+i,"Align(",6)==0){ 1366 //アラインメント修飾子 1349 1367 i+=6; 1350 1368 i+=GetStringInPare_RemovePare(temporary,basbuf+i)+1; … … 1353 1371 if(!(iAlign==1||iAlign==2||iAlign==4||iAlign==8||iAlign==16)) 1354 1372 SetError(51,NULL,i); 1373 } 1374 else if( memicmp( basbuf + i, "Blittable(", 10 ) == 0 ){ 1375 // Blittable修飾子 1376 i+=10; 1377 i=JumpStringInPare(basbuf,i)+1; 1355 1378 } 1356 1379 … … 1416 1439 goto InheritsError; 1417 1440 } 1418 }1419 else if( memicmp( basbuf + i+1,"Blittable", 9 ) == 0 &&1420 basbuf[i+10] == 1 && basbuf[i+11] == ESC_INHERITS ){1421 // Blittable Inherits1422 1423 for(i+=12,i2=0;;i++,i2++){1424 if(IsCommandDelimitation(basbuf[i])){1425 temporary[i2]=0;1426 break;1427 }1428 temporary[i2]=basbuf[i];1429 }1430 1431 Type type;1432 Type::StringToType( temporary, type );1433 pobj_c->SetBlittableType( type );1434 1435 1441 } 1436 1442 -
BasicCompiler_Common/Class.h
r127 r128 130 130 bool IsBlittableType() const 131 131 { 132 return blittableType.IsNull();132 return !blittableType.IsNull(); 133 133 } 134 134 const Type &GetBlittableType() const -
BasicCompiler_Common/Intermediate_Step2.cpp
r107 r128 418 418 if( Command[i2] == 1 && Command[i2+1] == ESC_ENUM ){ 419 419 i2 += 2; 420 } 421 else if( memicmp( Command + i2, "Blittable(", 10 ) == 0 ){ 422 i2 += 10; 423 i2 = JumpStringInPare(Command,i2)+1; 420 424 } 421 425 -
BasicCompiler_Common/NumOpe_GetType.cpp
r117 r128 294 294 } 295 295 296 bool GetTermType( const char *term, Type &resultType, bool &isLiteral, bool *pIsClassName = NULL){296 bool GetTermType( const char *term, Type &resultType, bool &isLiteral, bool *pIsClassName ){ 297 297 char parameter[VN_SIZE]; 298 298 … … 322 322 bool isClassName = false; 323 323 Type leftType; 324 if( !GetTermType( termLeft, leftType, isLiteral, &isClassName ) ){ 324 if( GetTermType( termLeft, leftType, isLiteral, &isClassName ) ){ 325 if( isClassName == false && Smoothie::Meta::blittableTypes.IsExist( leftType ) ){ 326 // 左側のオブジェクト部分がBlittable型のとき 327 328 char temporary[VN_SIZE]; 329 lstrcpy( temporary, termLeft ); 330 sprintf( termLeft, "%s(%s)", 331 Smoothie::Meta::blittableTypes.Find( leftType ).GetCreateStaticMethodFullName().c_str(), 332 temporary ); 333 334 if( !GetTermType( termLeft, leftType, isLiteral, &isClassName ) ){ 335 goto globalArea; 336 } 337 } 338 } 339 else{ 325 340 goto globalArea; 326 341 } … … 615 630 //型名 616 631 if( Type::StringToType( term, resultType ) ){ 632 633 if( resultType.IsObject() ){ 634 if( resultType.GetClass().IsBlittableType() ){ 635 // Blittable型のときは基本型として扱う 636 // ※ただし、コンパイル中のメソッドがBlittable型クラスに属していないこと 637 if( UserProc::IsLocalAreaCompiling() 638 && UserProc::CompilingUserProc().HasParentClass() 639 && UserProc::CompilingUserProc().GetParentClass().IsBlittableType() ) 640 { 641 // コンパイル中のメソッドがBlittable型クラスに属している 642 } 643 else{ 644 resultType = resultType.GetClass().GetBlittableType(); 645 } 646 } 647 } 648 617 649 resultType.SetBasicType( resultType.GetBasicType() | FLAG_CAST ); 618 650 } … … 656 688 ////////////////// 657 689 // 何らかの識別子 658 659 if( strstr(term,"T.B")){660 int test=0;661 }662 690 663 691 bool isLiteral = true; -
BasicCompiler_Common/Procedure.cpp
r116 r128 105 105 } 106 106 else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){ 107 // As指定 107 108 i+=2; 108 109 … … 131 132 SetError(3,temporary,nowLine); 132 133 type.SetBasicType( DEF_PTR_VOID ); 134 } 135 136 if( type.IsObject() ){ 137 if( type.GetClass().IsBlittableType() ){ 138 // Blittable型のときは基本型として扱う 139 type = type.GetClass().GetBlittableType(); 140 } 133 141 } 134 142 } -
BasicCompiler_Common/Type.cpp
r117 r128 522 522 return Type( DEF_OBJECT, *pobj_DBClass->GetStringClassPtr() ); 523 523 } 524 525 const string BlittableType::GetCreateStaticMethodFullName() const 526 { 527 return pClass->GetNamespaceScopes().ToString() + "." + pClass->GetName() + "._Create"; 528 } -
BasicCompiler_Common/Type.h
r114 r128 130 130 static bool StringToType( const string &typeName, Type &type ); 131 131 }; 132 133 class BlittableType 134 { 135 Type basicType; 136 CClass *pClass; 137 public: 138 BlittableType( const Type &basicType, CClass *pClass ) 139 : basicType( basicType ) 140 , pClass( pClass ) 141 { 142 } 143 BlittableType(){} 144 const Type &GetBasicType() const 145 { 146 return basicType; 147 } 148 const CClass *GetClassPtr() const 149 { 150 return pClass; 151 } 152 const string GetCreateStaticMethodFullName() const; 153 }; 154 class BlittableTypes : public vector<BlittableType> 155 { 156 public: 157 bool IsExist( Type type ) const 158 { 159 const BlittableTypes &blittableTypes = *this; 160 BOOST_FOREACH( const BlittableType &blittableType, blittableTypes ){ 161 if( blittableType.GetBasicType().Equals( type ) ){ 162 return true; 163 } 164 } 165 return false; 166 } 167 const BlittableType &Find( const Type &type ) const 168 { 169 const BlittableTypes &blittableTypes = *this; 170 BOOST_FOREACH( const BlittableType &blittableType, blittableTypes ){ 171 if( blittableType.GetBasicType().Equals( type ) ){ 172 return blittableType; 173 } 174 } 175 throw "Blittable型ではない"; 176 } 177 const CClass *GetClassPtr( const Type &type ) const 178 { 179 const BlittableTypes &blittableTypes = *this; 180 BOOST_FOREACH( const BlittableType &blittableType, blittableTypes ){ 181 if( blittableType.GetBasicType().Equals( type ) ){ 182 return blittableType.GetClassPtr(); 183 } 184 } 185 return NULL; 186 } 187 const CClass &GetClass( const Type &type ) const 188 { 189 return *GetClassPtr( type ); 190 } 191 }; -
BasicCompiler_Common/VariableOpe.cpp
r117 r128 1203 1203 } 1204 1204 1205 if( type.IsObject() ){ 1206 if( type.GetClass().IsBlittableType() ){ 1207 // Blittable型のときは基本型として扱う 1208 // ※ただし、コンパイル中のメソッドがBlittable型クラスに属していないこと 1209 if( UserProc::IsLocalAreaCompiling() 1210 && UserProc::CompilingUserProc().HasParentClass() 1211 && UserProc::CompilingUserProc().GetParentClass().IsBlittableType() ) 1212 { 1213 // コンパイル中のメソッドがBlittable型クラスに属している 1214 } 1215 else{ 1216 type = type.GetClass().GetBlittableType(); 1217 } 1218 } 1219 } 1220 1205 1221 if(dwFlags&DIMFLAG_STATIC){ 1206 1222 if( UserProc::IsGlobalAreaCompiling() ){ -
BasicCompiler_Common/calculation.cpp
r126 r128 698 698 } 699 699 700 if( tempType.IsObject() ){ 701 if( tempType.GetClass().IsBlittableType() ){ 702 // Blittable型のときは基本型として扱う 703 tempType = tempType.GetClass().GetBlittableType(); 704 } 705 } 706 700 707 type[pnum] = tempType.GetBasicType(); 701 708 before_index[pnum] = tempType.GetIndex(); -
BasicCompiler_Common/common.h
r125 r128 47 47 48 48 #ifdef _AMD64_ 49 #define VER_INFO "(x64) β rev.2 48"49 #define VER_INFO "(x64) β rev.255" 50 50 #else 51 #define VER_INFO "β rev.2 48"51 #define VER_INFO "β rev.255" 52 52 #endif 53 53 … … 439 439 int AutoBigCast(int BaseType,int CalcType); 440 440 BOOL CheckCalcType(int idCalc,int *type,int sp); 441 bool GetTermType( const char *term, Type &resultType, bool &isLiteral, bool *pIsClassName = NULL ); 441 442 bool NumOpe_GetType( const char *expression, const Type &baseType, Type &resultType ); 442 443 -
BasicCompiler_Common/include/Smoothie.h
r112 r128 40 40 static NamespaceScopesCollection namespaceScopesCollection; 41 41 static NamespaceScopesCollection importedNamespaces; 42 static BlittableTypes blittableTypes; 42 43 }; 43 44 -
BasicCompiler_Common/src/Smoothie.cpp
r112 r128 23 23 NamespaceScopesCollection Smoothie::Meta::namespaceScopesCollection; 24 24 NamespaceScopesCollection Smoothie::Meta::importedNamespaces; 25 BlittableTypes Smoothie::Meta::blittableTypes; 25 26 26 27 bool Smoothie::isFullCompile = false;
Note:
See TracChangeset
for help on using the changeset viewer.