Changeset 128 in dev for BasicCompiler_Common


Ignore:
Timestamp:
May 18, 2007, 4:42:36 AM (17 years ago)
Author:
dai_9181
Message:

Blittable型を導入した。

Location:
BasicCompiler_Common
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler_Common/Class.cpp

    r127 r128  
    911911    char temporary[VN_SIZE];
    912912
     913    // Blittable型管理オブジェクトを初期化
     914    Smoothie::Meta::blittableTypes.clear();
     915
    913916    // 名前空間管理
    914917    NamespaceScopes &namespaceScopes = Smoothie::Lexical::liveingNamespaceScopes;
     
    971974
    972975                i+=2;
    973                 //アラインメント修飾子
     976                Type blittableType;
    974977                if(memicmp(basbuf+i,"Align(",6)==0){
     978                    //アラインメント修飾子
    975979                    i+=6;
    976980                    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 );
    977987                }
    978988
     
    10131023                    }
    10141024                }
     1025
     1026                // Blittable型の場合
     1027                if( !blittableType.IsNull() ){
     1028                    pClass->SetBlittableType( blittableType );
     1029
     1030                    // Blittable型として登録
     1031                    Smoothie::Meta::blittableTypes.push_back( BlittableType( blittableType, pClass ) );
     1032                }
    10151033        }
    10161034    }
     
    13441362            i+=2;
    13451363
    1346             //アラインメント修飾子
    13471364            int iAlign=0;
    13481365            if(memicmp(basbuf+i,"Align(",6)==0){
     1366                //アラインメント修飾子
    13491367                i+=6;
    13501368                i+=GetStringInPare_RemovePare(temporary,basbuf+i)+1;
     
    13531371                if(!(iAlign==1||iAlign==2||iAlign==4||iAlign==8||iAlign==16))
    13541372                    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;
    13551378            }
    13561379
     
    14161439                        goto InheritsError;
    14171440                    }
    1418                 }
    1419                 else if( memicmp( basbuf + i+1,"Blittable", 9 ) == 0 &&
    1420                     basbuf[i+10] == 1 && basbuf[i+11] == ESC_INHERITS ){
    1421                         // Blittable Inherits
    1422 
    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 
    14351441                }
    14361442
  • BasicCompiler_Common/Class.h

    r127 r128  
    130130    bool IsBlittableType() const
    131131    {
    132         return blittableType.IsNull();
     132        return !blittableType.IsNull();
    133133    }
    134134    const Type &GetBlittableType() const
  • BasicCompiler_Common/Intermediate_Step2.cpp

    r107 r128  
    418418                if( Command[i2] == 1 && Command[i2+1] == ESC_ENUM ){
    419419                    i2 += 2;
     420                }
     421                else if( memicmp( Command + i2, "Blittable(", 10 ) == 0 ){
     422                    i2 += 10;
     423                    i2 = JumpStringInPare(Command,i2)+1;
    420424                }
    421425
  • BasicCompiler_Common/NumOpe_GetType.cpp

    r117 r128  
    294294}
    295295
    296 bool GetTermType( const char *term, Type &resultType, bool &isLiteral, bool *pIsClassName = NULL ){
     296bool GetTermType( const char *term, Type &resultType, bool &isLiteral, bool *pIsClassName ){
    297297    char parameter[VN_SIZE];
    298298
     
    322322        bool isClassName = false;
    323323        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{
    325340            goto globalArea;
    326341        }
     
    615630                    //型名
    616631                    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
    617649                        resultType.SetBasicType( resultType.GetBasicType() | FLAG_CAST );
    618650                    }
     
    656688                    //////////////////
    657689                    // 何らかの識別子
    658 
    659                         if( strstr(term,"T.B")){
    660                             int test=0;
    661                         }
    662690
    663691                    bool isLiteral = true;
  • BasicCompiler_Common/Procedure.cpp

    r116 r128  
    105105        }
    106106        else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){
     107            // As指定
    107108            i+=2;
    108109
     
    131132                SetError(3,temporary,nowLine);
    132133                type.SetBasicType( DEF_PTR_VOID );
     134            }
     135
     136            if( type.IsObject() ){
     137                if( type.GetClass().IsBlittableType() ){
     138                    // Blittable型のときは基本型として扱う
     139                    type = type.GetClass().GetBlittableType();
     140                }
    133141            }
    134142        }
  • BasicCompiler_Common/Type.cpp

    r117 r128  
    522522    return Type( DEF_OBJECT, *pobj_DBClass->GetStringClassPtr() );
    523523}
     524
     525const string BlittableType::GetCreateStaticMethodFullName() const
     526{
     527    return pClass->GetNamespaceScopes().ToString() + "." + pClass->GetName() + "._Create";
     528}
  • BasicCompiler_Common/Type.h

    r114 r128  
    130130    static bool StringToType( const string &typeName, Type &type );
    131131};
     132
     133class BlittableType
     134{
     135    Type basicType;
     136    CClass *pClass;
     137public:
     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};
     154class BlittableTypes : public vector<BlittableType>
     155{
     156public:
     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  
    12031203    }
    12041204
     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
    12051221    if(dwFlags&DIMFLAG_STATIC){
    12061222        if( UserProc::IsGlobalAreaCompiling() ){
  • BasicCompiler_Common/calculation.cpp

    r126 r128  
    698698                            }
    699699
     700                            if( tempType.IsObject() ){
     701                                if( tempType.GetClass().IsBlittableType() ){
     702                                    // Blittable型のときは基本型として扱う
     703                                    tempType = tempType.GetClass().GetBlittableType();
     704                                }
     705                            }
     706
    700707                            type[pnum] = tempType.GetBasicType();
    701708                            before_index[pnum] = tempType.GetIndex();
  • BasicCompiler_Common/common.h

    r125 r128  
    4747
    4848#ifdef _AMD64_
    49 #define VER_INFO        "(x64) β rev.248"
     49#define VER_INFO        "(x64) β rev.255"
    5050#else
    51 #define VER_INFO        "β rev.248"
     51#define VER_INFO        "β rev.255"
    5252#endif
    5353
     
    439439int AutoBigCast(int BaseType,int CalcType);
    440440BOOL CheckCalcType(int idCalc,int *type,int sp);
     441bool GetTermType( const char *term, Type &resultType, bool &isLiteral, bool *pIsClassName = NULL );
    441442bool NumOpe_GetType( const char *expression, const Type &baseType, Type &resultType );
    442443
  • BasicCompiler_Common/include/Smoothie.h

    r112 r128  
    4040        static NamespaceScopesCollection namespaceScopesCollection;
    4141        static NamespaceScopesCollection importedNamespaces;
     42        static BlittableTypes blittableTypes;
    4243    };
    4344
  • BasicCompiler_Common/src/Smoothie.cpp

    r112 r128  
    2323NamespaceScopesCollection Smoothie::Meta::namespaceScopesCollection;
    2424NamespaceScopesCollection Smoothie::Meta::importedNamespaces;
     25BlittableTypes Smoothie::Meta::blittableTypes;
    2526
    2627bool Smoothie::isFullCompile = false;
Note: See TracChangeset for help on using the changeset viewer.