[206] | 1 | #include "stdafx.h"
|
---|
| 2 |
|
---|
| 3 | const int Type::basicTypeList[] = {
|
---|
| 4 | DEF_BYTE,
|
---|
| 5 | DEF_SBYTE,
|
---|
| 6 | DEF_WORD,
|
---|
| 7 | DEF_INTEGER,
|
---|
| 8 | DEF_DWORD,
|
---|
| 9 | DEF_LONG,
|
---|
| 10 | DEF_QWORD,
|
---|
| 11 | DEF_INT64,
|
---|
| 12 |
|
---|
| 13 | DEF_SINGLE,
|
---|
| 14 | DEF_DOUBLE,
|
---|
| 15 |
|
---|
| 16 | DEF_BOOLEAN,
|
---|
| 17 |
|
---|
| 18 | DEF_PTR_VOID,
|
---|
| 19 |
|
---|
| 20 | DEF_ANY,
|
---|
| 21 |
|
---|
| 22 | DEF_NON
|
---|
| 23 | };
|
---|
| 24 |
|
---|
[523] | 25 | const std::string Type::basicTypeNameList[] = {
|
---|
[206] | 26 | "Byte",
|
---|
| 27 | "SByte",
|
---|
| 28 | "Word",
|
---|
| 29 | "Integer",
|
---|
| 30 | "DWord",
|
---|
| 31 | "Long",
|
---|
| 32 | "QWord",
|
---|
| 33 | "Int64",
|
---|
| 34 |
|
---|
| 35 | "Single",
|
---|
| 36 | "Double",
|
---|
| 37 |
|
---|
| 38 | "Boolean",
|
---|
| 39 |
|
---|
| 40 | "VoidPtr",
|
---|
| 41 |
|
---|
| 42 | "Any",
|
---|
| 43 |
|
---|
| 44 | ""
|
---|
| 45 | };
|
---|
| 46 |
|
---|
[290] | 47 | Type::~Type()
|
---|
| 48 | {
|
---|
| 49 | }
|
---|
| 50 |
|
---|
[523] | 51 | bool Type::StringToBasicType( const std::string &typeName, int &basicType ){
|
---|
[206] | 52 | for( int i=0; ; i++ ){
|
---|
| 53 | if( basicTypeList[i] == DEF_NON ){
|
---|
| 54 | break;
|
---|
| 55 | }
|
---|
| 56 | if( basicTypeNameList[i] == typeName ){
|
---|
| 57 | basicType = basicTypeList[i];
|
---|
| 58 | return true;
|
---|
| 59 | }
|
---|
| 60 | }
|
---|
| 61 | return false;
|
---|
| 62 | }
|
---|
| 63 | const char *Type::BasicTypeToCharPtr( const Type &type )
|
---|
| 64 | {
|
---|
| 65 | for( int i=0; ; i++ ){
|
---|
| 66 | if( basicTypeList[i] == DEF_NON ){
|
---|
| 67 | break;
|
---|
| 68 | }
|
---|
| 69 | if( basicTypeList[i] == type.GetBasicType() ){
|
---|
| 70 | return basicTypeNameList[i].c_str();
|
---|
| 71 | }
|
---|
| 72 | }
|
---|
| 73 | return NULL;
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | int Type::GetBasicSize( int basicType )
|
---|
| 77 | {
|
---|
| 78 |
|
---|
| 79 | // 基本型
|
---|
| 80 | switch( basicType ){
|
---|
| 81 | case DEF_SBYTE:
|
---|
| 82 | case DEF_BYTE:
|
---|
| 83 | case DEF_BOOLEAN:
|
---|
| 84 | return sizeof(BYTE);
|
---|
| 85 |
|
---|
| 86 | case DEF_INTEGER:
|
---|
| 87 | case DEF_WORD:
|
---|
| 88 | return sizeof(WORD);
|
---|
| 89 |
|
---|
| 90 | case DEF_LONG:
|
---|
| 91 | case DEF_DWORD:
|
---|
| 92 | return sizeof(DWORD);
|
---|
| 93 |
|
---|
| 94 | case DEF_INT64:
|
---|
| 95 | case DEF_QWORD:
|
---|
| 96 | return sizeof(_int64);
|
---|
| 97 |
|
---|
| 98 | case DEF_DOUBLE:
|
---|
| 99 | return sizeof(double);
|
---|
| 100 | case DEF_SINGLE:
|
---|
| 101 | return sizeof(float);
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | // ポインタ
|
---|
| 105 | if(IsPointer( basicType )){
|
---|
| 106 | return PTR_SIZE;
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | // オブジェクト
|
---|
| 110 | if(basicType==DEF_OBJECT){
|
---|
| 111 | return PTR_SIZE;
|
---|
| 112 | }
|
---|
| 113 |
|
---|
[556] | 114 | throw;
|
---|
[206] | 115 |
|
---|
| 116 | return 0;
|
---|
| 117 | }
|
---|
| 118 |
|
---|
[290] | 119 | const CClass &Type::GetClass() const
|
---|
| 120 | {
|
---|
| 121 | if( !HasMember() )
|
---|
| 122 | {
|
---|
| 123 | Jenga::Throw( "クラスまたは構造体でない型に対してGetClassを呼び出した" );
|
---|
| 124 | }
|
---|
[206] | 125 |
|
---|
[290] | 126 | return *pClass;
|
---|
| 127 | }
|
---|
| 128 |
|
---|
[206] | 129 | bool Type::Equals( const Type &type ) const
|
---|
| 130 | {
|
---|
[640] | 131 | if( basicType == type.basicType )
|
---|
| 132 | {
|
---|
| 133 | if( NATURAL_TYPE( basicType ) == DEF_OBJECT || NATURAL_TYPE( basicType ) == DEF_STRUCT )
|
---|
| 134 | {
|
---|
| 135 | // ポインタが等しいかどうかを見てみる
|
---|
| 136 | if( this->pClass == type.pClass )
|
---|
| 137 | {
|
---|
| 138 | return true;
|
---|
| 139 | }
|
---|
| 140 | else if( this->pClass->IsNeedResolve() || type.pClass->IsNeedResolve() )
|
---|
| 141 | {
|
---|
| 142 | // 依存関係解決前の状態であれば、パスが等しいかどうかを見てみる
|
---|
| 143 | if( this->pClass->IsDuplication( type.pClass ) )
|
---|
| 144 | {
|
---|
[206] | 145 | return true;
|
---|
| 146 | }
|
---|
[640] | 147 | }
|
---|
[206] | 148 | }
|
---|
[640] | 149 | else
|
---|
| 150 | {
|
---|
[206] | 151 | return true;
|
---|
| 152 | }
|
---|
| 153 | }
|
---|
| 154 | return false;
|
---|
| 155 | }
|
---|
| 156 |
|
---|
[447] | 157 | bool Type::IsCovariant( const Type &type ) const
|
---|
| 158 | {
|
---|
| 159 | if( !this->IsObject() || !type.IsObject() )
|
---|
| 160 | {
|
---|
| 161 | // 共変性の判別はクラス型のみ
|
---|
| 162 | return false;
|
---|
| 163 | }
|
---|
| 164 |
|
---|
| 165 | return this->GetClass().IsSubClass( &type.GetClass() );
|
---|
| 166 | }
|
---|
[448] | 167 | bool Type::IsContravariant( const Type &type ) const
|
---|
| 168 | {
|
---|
| 169 | if( !this->IsObject() || !type.IsObject() )
|
---|
| 170 | {
|
---|
| 171 | // 反変性の判別はクラス型のみ
|
---|
| 172 | return false;
|
---|
| 173 | }
|
---|
[447] | 174 |
|
---|
[448] | 175 | return type.GetClass().IsSubClass( &this->GetClass() );
|
---|
| 176 | }
|
---|
| 177 |
|
---|
[206] | 178 | int Type::GetBasicSize() const
|
---|
| 179 | {
|
---|
| 180 | return GetBasicSize( basicType );
|
---|
| 181 | }
|
---|
| 182 | int Type::GetSize() const
|
---|
| 183 | {
|
---|
| 184 |
|
---|
| 185 | // 基本型
|
---|
| 186 | switch( basicType ){
|
---|
| 187 | case DEF_LONG:
|
---|
| 188 | if(index==LITERAL_NULL||index==LITERAL_M128_0||index==LITERAL_0_255){
|
---|
| 189 | return sizeof(BYTE);
|
---|
| 190 | }
|
---|
| 191 | else if(index==LITERAL_M32768_0||index==LITERAL_0_65535){
|
---|
| 192 | return sizeof(WORD);
|
---|
| 193 | }
|
---|
| 194 | return sizeof(DWORD);
|
---|
| 195 |
|
---|
| 196 | case DEF_SBYTE:
|
---|
| 197 | case DEF_BYTE:
|
---|
| 198 | case DEF_BOOLEAN:
|
---|
| 199 | return sizeof(BYTE);
|
---|
| 200 |
|
---|
| 201 | case DEF_INTEGER:
|
---|
| 202 | case DEF_WORD:
|
---|
| 203 | return sizeof(WORD);
|
---|
| 204 |
|
---|
| 205 | case DEF_DWORD:
|
---|
| 206 | return sizeof(DWORD);
|
---|
| 207 |
|
---|
| 208 | case DEF_INT64:
|
---|
| 209 | case DEF_QWORD:
|
---|
| 210 | return sizeof(_int64);
|
---|
| 211 |
|
---|
| 212 | case DEF_DOUBLE:
|
---|
| 213 | return sizeof(double);
|
---|
| 214 | case DEF_SINGLE:
|
---|
| 215 | return sizeof(float);
|
---|
| 216 | }
|
---|
| 217 |
|
---|
| 218 | // ポインタ
|
---|
| 219 | if(IsPointer()){
|
---|
| 220 | return PTR_SIZE;
|
---|
| 221 | }
|
---|
| 222 |
|
---|
| 223 | // 構造体
|
---|
[290] | 224 | if( IsStruct() )
|
---|
| 225 | {
|
---|
[206] | 226 | if( !pClass ){
|
---|
[556] | 227 | throw;
|
---|
[206] | 228 | }
|
---|
| 229 |
|
---|
| 230 | return pClass->GetSize();
|
---|
| 231 | }
|
---|
| 232 |
|
---|
| 233 | // オブジェクト
|
---|
[290] | 234 | if( IsObject() )
|
---|
| 235 | {
|
---|
[206] | 236 | return PTR_SIZE;
|
---|
| 237 | }
|
---|
| 238 |
|
---|
[556] | 239 | throw;
|
---|
[206] | 240 | }
|
---|
| 241 |
|
---|
| 242 | bool Type::IsNull() const{
|
---|
| 243 | if( basicType == DEF_NON ){
|
---|
| 244 | return true;
|
---|
| 245 | }
|
---|
| 246 | return false;
|
---|
| 247 | }
|
---|
| 248 |
|
---|
| 249 | bool Type::IsByte() const{
|
---|
| 250 | if( basicType == DEF_BYTE ){
|
---|
| 251 | return true;
|
---|
| 252 | }
|
---|
| 253 | return false;
|
---|
| 254 | }
|
---|
| 255 | bool Type::IsSByte() const{
|
---|
| 256 | if( basicType == DEF_SBYTE ){
|
---|
| 257 | return true;
|
---|
| 258 | }
|
---|
| 259 | return false;
|
---|
| 260 | }
|
---|
| 261 | bool Type::IsWord() const{
|
---|
| 262 | if( basicType == DEF_WORD ){
|
---|
| 263 | return true;
|
---|
| 264 | }
|
---|
| 265 | return false;
|
---|
| 266 | }
|
---|
| 267 | bool Type::IsInteger() const{
|
---|
| 268 | if( basicType == DEF_INTEGER ){
|
---|
| 269 | return true;
|
---|
| 270 | }
|
---|
| 271 | return false;
|
---|
| 272 | }
|
---|
| 273 | bool Type::IsDWord() const{
|
---|
| 274 | if( basicType == DEF_DWORD ){
|
---|
| 275 | return true;
|
---|
| 276 | }
|
---|
| 277 | return false;
|
---|
| 278 | }
|
---|
| 279 | bool Type::IsLong() const{
|
---|
| 280 | if( basicType == DEF_LONG ){
|
---|
| 281 | return true;
|
---|
| 282 | }
|
---|
| 283 | return false;
|
---|
| 284 | }
|
---|
| 285 | bool Type::IsQWord() const{
|
---|
| 286 | if( basicType == DEF_QWORD ){
|
---|
| 287 | return true;
|
---|
| 288 | }
|
---|
| 289 | return false;
|
---|
| 290 | }
|
---|
| 291 | bool Type::IsInt64() const{
|
---|
| 292 | if( basicType == DEF_INT64 ){
|
---|
| 293 | return true;
|
---|
| 294 | }
|
---|
| 295 | return false;
|
---|
| 296 | }
|
---|
| 297 | bool Type::IsSingle() const{
|
---|
| 298 | if( basicType == DEF_SINGLE ){
|
---|
| 299 | return true;
|
---|
| 300 | }
|
---|
| 301 | return false;
|
---|
| 302 | }
|
---|
| 303 | bool Type::IsDouble() const{
|
---|
| 304 | if( basicType == DEF_DOUBLE ){
|
---|
| 305 | return true;
|
---|
| 306 | }
|
---|
| 307 | return false;
|
---|
| 308 | }
|
---|
| 309 | bool Type::IsBoolean() const{
|
---|
| 310 | if( basicType == DEF_BOOLEAN ){
|
---|
| 311 | return true;
|
---|
| 312 | }
|
---|
| 313 | return false;
|
---|
| 314 | }
|
---|
| 315 |
|
---|
| 316 | bool Type::IsPointer( int basicType )
|
---|
| 317 | {
|
---|
[350] | 318 | if( basicType == DEF_NON )
|
---|
| 319 | {
|
---|
| 320 | return false;
|
---|
| 321 | }
|
---|
| 322 |
|
---|
[206] | 323 | if(PTR_LEVEL( basicType )|| basicType == DEF_PTR_VOID || basicType == DEF_PTR_PROC
|
---|
| 324 | || ( basicType & FLAG_PTR ) ){
|
---|
| 325 | return true;
|
---|
| 326 | }
|
---|
| 327 |
|
---|
| 328 | return false;
|
---|
| 329 | }
|
---|
| 330 | bool Type::IsPointer() const
|
---|
| 331 | {
|
---|
| 332 | return IsPointer( basicType );
|
---|
| 333 | }
|
---|
| 334 | bool Type::IsSigned() const
|
---|
| 335 | {
|
---|
| 336 | switch( basicType ){
|
---|
| 337 | case DEF_SBYTE:
|
---|
| 338 | case DEF_INTEGER:
|
---|
| 339 | case DEF_LONG:
|
---|
| 340 | case DEF_INT64:
|
---|
| 341 | case DEF_SINGLE:
|
---|
| 342 | case DEF_DOUBLE:
|
---|
| 343 | return true;
|
---|
| 344 | default:
|
---|
| 345 | break;
|
---|
| 346 | }
|
---|
| 347 | return false;
|
---|
| 348 | }
|
---|
| 349 | bool Type::IsNaturalWhole() const
|
---|
| 350 | {
|
---|
| 351 | switch( basicType ){
|
---|
| 352 | case DEF_SBYTE:
|
---|
| 353 | case DEF_BYTE:
|
---|
| 354 | case DEF_INTEGER:
|
---|
| 355 | case DEF_WORD:
|
---|
| 356 | case DEF_LONG:
|
---|
| 357 | case DEF_DWORD:
|
---|
| 358 | case DEF_INT64:
|
---|
| 359 | case DEF_QWORD:
|
---|
| 360 | return true;
|
---|
| 361 | default:
|
---|
| 362 | break;
|
---|
| 363 | }
|
---|
| 364 | return false;
|
---|
| 365 | }
|
---|
| 366 | bool Type::IsWhole() const
|
---|
| 367 | {
|
---|
| 368 | return (
|
---|
| 369 | IsNaturalWhole()
|
---|
| 370 | || IsPointer( basicType )
|
---|
| 371 | || basicType == DEF_BOOLEAN
|
---|
| 372 | );
|
---|
| 373 | }
|
---|
| 374 | bool Type::IsReal() const
|
---|
| 375 | {
|
---|
| 376 | switch( basicType ){
|
---|
| 377 | case DEF_SINGLE:
|
---|
| 378 | case DEF_DOUBLE:
|
---|
| 379 | return true;
|
---|
| 380 | default:
|
---|
| 381 | break;
|
---|
| 382 | }
|
---|
| 383 | return false;
|
---|
| 384 | }
|
---|
| 385 | bool Type::Is64() const
|
---|
| 386 | {
|
---|
| 387 | switch( basicType ){
|
---|
| 388 | case DEF_QWORD:
|
---|
| 389 | case DEF_INT64:
|
---|
| 390 | return true;
|
---|
| 391 | default:
|
---|
| 392 | break;
|
---|
| 393 | }
|
---|
| 394 | return false;
|
---|
| 395 | }
|
---|
[632] | 396 |
|
---|
| 397 | bool Type::IsValueType() const
|
---|
| 398 | {
|
---|
| 399 | return ( IsWhole() || IsReal() );
|
---|
| 400 | }
|
---|
| 401 |
|
---|
[206] | 402 | bool Type::IsProcPtr() const
|
---|
| 403 | {
|
---|
| 404 | if( basicType == DEF_PTR_PROC ){
|
---|
| 405 | return true;
|
---|
| 406 | }
|
---|
| 407 | return false;
|
---|
| 408 | }
|
---|
| 409 | bool Type::IsStruct() const
|
---|
| 410 | {
|
---|
| 411 | if( basicType == DEF_STRUCT ){
|
---|
| 412 | return true;
|
---|
| 413 | }
|
---|
| 414 | return false;
|
---|
| 415 | }
|
---|
| 416 | bool Type::IsStructPtr() const
|
---|
| 417 | {
|
---|
| 418 | if( basicType == DEF_PTR_STRUCT ){
|
---|
| 419 | return true;
|
---|
| 420 | }
|
---|
| 421 | return false;
|
---|
| 422 | }
|
---|
| 423 | bool Type::IsObject() const
|
---|
| 424 | {
|
---|
[290] | 425 | return (
|
---|
| 426 | basicType == DEF_OBJECT
|
---|
[316] | 427 | || basicType == DEF_TYPE_PARAMETER
|
---|
[290] | 428 | );
|
---|
[206] | 429 | }
|
---|
| 430 | bool Type::IsObjectPtr() const
|
---|
| 431 | {
|
---|
| 432 | if( basicType == DEF_PTR_OBJECT ){
|
---|
| 433 | return true;
|
---|
| 434 | }
|
---|
| 435 | return false;
|
---|
| 436 | }
|
---|
[290] | 437 | bool Type::IsTypeParameter() const
|
---|
| 438 | {
|
---|
[292] | 439 | return ( NATURAL_TYPE(basicType) == DEF_TYPE_PARAMETER );
|
---|
[290] | 440 | }
|
---|
[206] | 441 | bool Type::IsObjectClass() const
|
---|
| 442 | {
|
---|
| 443 | if( basicType == DEF_OBJECT ){
|
---|
| 444 | if( pClass->GetName() == "Object" ){
|
---|
| 445 | return true;
|
---|
| 446 | }
|
---|
| 447 | }
|
---|
| 448 | return false;
|
---|
| 449 | }
|
---|
| 450 | bool Type::IsStringClass() const
|
---|
| 451 | {
|
---|
| 452 | if( basicType == DEF_OBJECT ){
|
---|
| 453 | if( pClass->GetName() == "String" ){
|
---|
| 454 | return true;
|
---|
| 455 | }
|
---|
| 456 | }
|
---|
| 457 | return false;
|
---|
| 458 | }
|
---|
| 459 | bool Type::IsVoidPtr() const
|
---|
| 460 | {
|
---|
| 461 | if( basicType == DEF_PTR_VOID ){
|
---|
| 462 | return true;
|
---|
| 463 | }
|
---|
| 464 | return false;
|
---|
| 465 | }
|
---|
| 466 |
|
---|
| 467 | bool Type::IsAny() const
|
---|
| 468 | {
|
---|
| 469 | if( basicType == DEF_ANY ){
|
---|
| 470 | return true;
|
---|
| 471 | }
|
---|
| 472 | return false;
|
---|
| 473 | }
|
---|
| 474 |
|
---|
[332] | 475 | bool Type::IsDelegate() const
|
---|
| 476 | {
|
---|
| 477 | return ( IsObject() && GetClass().IsDelegate() );
|
---|
| 478 | }
|
---|
[350] | 479 | bool Type::IsInterface() const
|
---|
| 480 | {
|
---|
| 481 | return ( IsObject() && GetClass().IsInterface() );
|
---|
| 482 | }
|
---|
[370] | 483 | bool Type::IsComInterface() const
|
---|
| 484 | {
|
---|
| 485 | return ( IsObject() && GetClass().IsComInterface() );
|
---|
| 486 | }
|
---|
[332] | 487 |
|
---|
[350] | 488 |
|
---|
[206] | 489 | bool Type::HasMember() const
|
---|
| 490 | {
|
---|
| 491 | if( NATURAL_TYPE( basicType ) == DEF_OBJECT
|
---|
[290] | 492 | || NATURAL_TYPE( basicType ) == DEF_STRUCT
|
---|
| 493 | || NATURAL_TYPE( basicType ) == DEF_TYPE_PARAMETER
|
---|
| 494 | ){
|
---|
| 495 | return true;
|
---|
[206] | 496 | }
|
---|
| 497 | return false;
|
---|
| 498 | }
|
---|
| 499 |
|
---|
[301] | 500 | const Type &Type::GetActualGenericType( int index ) const
|
---|
[290] | 501 | {
|
---|
[301] | 502 | return actualGenericTypes[index].GetType();
|
---|
[290] | 503 | }
|
---|
| 504 | bool Type::HasActualGenericType() const
|
---|
| 505 | {
|
---|
| 506 | return ( actualGenericTypes.size() > 0 );
|
---|
| 507 | }
|
---|
| 508 |
|
---|
[378] | 509 | std::string Type::ToString() const
|
---|
| 510 | {
|
---|
| 511 | const char *basicTypeName = BasicTypeToCharPtr( *this );
|
---|
| 512 | if( basicTypeName )
|
---|
| 513 | {
|
---|
| 514 | return basicTypeName;
|
---|
| 515 | }
|
---|
| 516 |
|
---|
| 517 | if( IsTypeParameter() )
|
---|
| 518 | {
|
---|
| 519 | return GetFormalTypeName();
|
---|
| 520 | }
|
---|
| 521 |
|
---|
| 522 | std::string typeName = GetClass().GetFullName();
|
---|
| 523 | if( HasActualGenericType() )
|
---|
| 524 | {
|
---|
| 525 | std::string actualGenericTypesName;
|
---|
| 526 | BOOST_FOREACH( const GenericType &actualGenericType, actualGenericTypes )
|
---|
| 527 | {
|
---|
| 528 | if( actualGenericTypesName.size() )
|
---|
| 529 | {
|
---|
| 530 | actualGenericTypesName += ",";
|
---|
| 531 | }
|
---|
| 532 | actualGenericTypesName += actualGenericType.GetName();
|
---|
| 533 | }
|
---|
| 534 |
|
---|
| 535 | typeName += "<" + actualGenericTypesName + ">";
|
---|
| 536 | }
|
---|
| 537 | return typeName;
|
---|
| 538 | }
|
---|
| 539 |
|
---|
[206] | 540 | int Type::GetBasicTypeFromSimpleName( const char *variable ){
|
---|
| 541 | extern char DefIntVari[26],DefSngVari[26],DefStrVari[26],divNum,dsvNum,dStrvNum;
|
---|
| 542 | int i;
|
---|
| 543 | char name[VN_SIZE];
|
---|
| 544 |
|
---|
| 545 | //構造体メンバの場合を考慮
|
---|
| 546 | for(i=lstrlen(variable);i>0;i--){
|
---|
| 547 | if(variable[i]=='.'){
|
---|
| 548 | i++;
|
---|
| 549 | break;
|
---|
| 550 | }
|
---|
| 551 | }
|
---|
| 552 |
|
---|
| 553 | for(;;i++){
|
---|
| 554 | if(variable[i]=='('||variable[i]=='\0'){
|
---|
| 555 | name[i]=0;
|
---|
| 556 | break;
|
---|
| 557 | }
|
---|
| 558 | name[i]=variable[i];
|
---|
| 559 | }
|
---|
| 560 | //変数名から選択
|
---|
| 561 | i--;
|
---|
| 562 | if(name[i]=='#') return DEF_DOUBLE;
|
---|
| 563 | if(name[i]=='!') return DEF_SINGLE;
|
---|
| 564 | if(name[i]=='%') return DEF_INTEGER;
|
---|
| 565 | return DEF_DOUBLE;
|
---|
| 566 | }
|
---|
| 567 |
|
---|
[640] | 568 | bool Type::Resolve( const ObjectModule &resolver, ResolveErrors &resolveErrors )
|
---|
[639] | 569 | {
|
---|
| 570 | if( this->HasMember() )
|
---|
| 571 | {
|
---|
| 572 | if( this->pClass->IsNeedResolve() )
|
---|
| 573 | {
|
---|
[640] | 574 | const CClass *pTempClass = resolver.meta.GetClasses().FindLike( this->pClass );
|
---|
| 575 | if( pTempClass )
|
---|
| 576 | {
|
---|
| 577 | this->pClass = pTempClass;
|
---|
| 578 | }
|
---|
| 579 | else
|
---|
| 580 | {
|
---|
| 581 | resolveErrors.Add( ResolveError( this->pClass->GetRelationalObjectModuleIndex(), this->pClass->GetFullName() ) );
|
---|
| 582 | }
|
---|
[639] | 583 | }
|
---|
| 584 |
|
---|
| 585 | BOOST_FOREACH( GenericType &actualGenericType, actualGenericTypes )
|
---|
| 586 | {
|
---|
[640] | 587 | actualGenericType.GetType().Resolve( resolver, resolveErrors );
|
---|
[639] | 588 | }
|
---|
| 589 | }
|
---|
| 590 | return true;
|
---|
| 591 | }
|
---|
| 592 |
|
---|
[632] | 593 | bool Types::IsEquals( const Types &types ) const
|
---|
| 594 | {
|
---|
| 595 | if( this->size() != types.size() )
|
---|
| 596 | {
|
---|
| 597 | // アイテム数が違う
|
---|
| 598 | return false;
|
---|
| 599 | }
|
---|
[206] | 600 |
|
---|
[632] | 601 | const Types &thisTypes = *this;
|
---|
| 602 | for( int i=0; i<static_cast<int>(this->size()); i++ )
|
---|
| 603 | {
|
---|
| 604 | if( !thisTypes[i].Equals( types[i] ) )
|
---|
| 605 | {
|
---|
| 606 | return false;
|
---|
| 607 | }
|
---|
| 608 | }
|
---|
| 609 |
|
---|
| 610 | return true;
|
---|
| 611 | }
|
---|
| 612 |
|
---|
[299] | 613 | void ResolveFormalGenericTypeParameter( Type &typeParameter, const Type &classType, const UserProc *pUserProc )
|
---|
| 614 | {
|
---|
[424] | 615 | if( !typeParameter.IsTypeParameter() )
|
---|
| 616 | {
|
---|
| 617 | // ジェネリックな型ではなかったとき
|
---|
| 618 | return;
|
---|
| 619 | }
|
---|
| 620 |
|
---|
[299] | 621 | /////////////////////////////////////////////////////////
|
---|
| 622 | // ☆★☆ ジェネリクスサポート ☆★☆
|
---|
| 623 |
|
---|
[424] | 624 | // ポインタレベルを抽出
|
---|
| 625 | int ptrLevel = PTR_LEVEL( typeParameter.GetBasicType() );
|
---|
| 626 |
|
---|
| 627 | if( pUserProc )
|
---|
[299] | 628 | {
|
---|
[424] | 629 | if( classType.IsObject() )
|
---|
[299] | 630 | {
|
---|
[424] | 631 | // 基底クラスでの自己解決
|
---|
| 632 | const CClass *pClass = &classType.GetClass();
|
---|
| 633 | while( pClass->HasSuperClass() )
|
---|
[299] | 634 | {
|
---|
[424] | 635 | if( pUserProc->GetParentClassPtr() == &pClass->GetSuperClass() )
|
---|
[299] | 636 | {
|
---|
[424] | 637 | if( pClass->GetSuperClassActualTypeParameters().size() )
|
---|
[299] | 638 | {
|
---|
[424] | 639 | // TODO: 適切な形に実装し直す(暫定的にトップの型を持ってきている)
|
---|
| 640 | typeParameter = pClass->GetSuperClassActualTypeParameters()[0];
|
---|
[299] | 641 | }
|
---|
| 642 | }
|
---|
[424] | 643 | pClass = &pClass->GetSuperClass();
|
---|
[299] | 644 | }
|
---|
| 645 | }
|
---|
[424] | 646 | }
|
---|
[299] | 647 |
|
---|
[424] | 648 | if( typeParameter.IsTypeParameter() )
|
---|
| 649 | {
|
---|
| 650 | if( classType.HasActualGenericType() )
|
---|
[299] | 651 | {
|
---|
[424] | 652 | typeParameter = classType.GetActualGenericType( typeParameter.GetFormalTypeIndex() );
|
---|
[299] | 653 | }
|
---|
[424] | 654 | else
|
---|
[299] | 655 | {
|
---|
[424] | 656 | // 制約クラス(指定されていないときはObjectクラス)にセットする
|
---|
| 657 | typeParameter.SetBasicType( DEF_OBJECT );
|
---|
[299] | 658 | }
|
---|
| 659 | }
|
---|
| 660 |
|
---|
[424] | 661 | for( int i=0; i<ptrLevel; i++ )
|
---|
| 662 | {
|
---|
| 663 | typeParameter.PtrLevelUp();
|
---|
| 664 | }
|
---|
| 665 |
|
---|
[299] | 666 | //
|
---|
| 667 | /////////////////////////////////////////////////////////
|
---|
| 668 | }
|
---|
| 669 |
|
---|
| 670 |
|
---|
[523] | 671 | const std::string BlittableType::GetCreateStaticMethodFullName() const
|
---|
[206] | 672 | {
|
---|
| 673 | return pClass->GetNamespaceScopes().ToString() + "." + pClass->GetName() + "._Create";
|
---|
| 674 | }
|
---|
[640] | 675 |
|
---|
| 676 | bool BlittableType::Resolve( const ObjectModule &resolver, ResolveErrors &resolveErrors )
|
---|
| 677 | {
|
---|
| 678 | basicType.Resolve( resolver, resolveErrors );
|
---|
| 679 |
|
---|
| 680 | if( this->pClass->IsNeedResolve() )
|
---|
| 681 | {
|
---|
| 682 | const CClass *pTempClass = resolver.meta.GetClasses().FindLike( this->pClass );
|
---|
| 683 | if( pTempClass )
|
---|
| 684 | {
|
---|
| 685 | this->pClass = pTempClass;
|
---|
| 686 | }
|
---|
| 687 | else
|
---|
| 688 | {
|
---|
| 689 | resolveErrors.Add( ResolveError( this->pClass->GetRelationalObjectModuleIndex(), this->pClass->GetFullName() ) );
|
---|
| 690 | }
|
---|
| 691 | }
|
---|
| 692 |
|
---|
| 693 | return true;
|
---|
| 694 | }
|
---|