Changeset 108 in dev


Ignore:
Timestamp:
May 6, 2007, 6:52:10 PM (17 years ago)
Author:
dai_9181
Message:

関数、クラスメソッドにImports機構を適用。

Files:
10 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler32/BasicCompiler.vcproj

    r107 r108  
    7575            <Tool
    7676                Name="VCLinkerTool"
    77                 AdditionalDependencies="odbc32.lib odbccp32.lib comctl32.lib"
     77                AdditionalDependencies="comctl32.lib psapi.lib"
    7878                OutputFile="../ActiveBasic/BasicCompiler32.exe"
    7979                LinkIncremental="2"
  • BasicCompiler32/Compile_ProcOp.cpp

    r101 r108  
    269269    // コンパイル中の関数が属する名前空間
    270270    Smoothie::Lexical::liveingNamespaceScopes = pUserProc->GetNamespaceScopes();
     271
     272    // コンパイル中の関数でImportsされている名前空間
     273    Smoothie::Meta::importedNamespaces = pUserProc->GetImportedNamespaces();
    271274
    272275    if(pUserProc->IsSystem()){
  • BasicCompiler64/Compile_ProcOp.cpp

    r101 r108  
    259259    // コンパイル中の関数が属する名前空間
    260260    Smoothie::Lexical::liveingNamespaceScopes = pUserProc->GetNamespaceScopes();
     261
     262    // コンパイル中の関数でImportsされている名前空間
     263    Smoothie::Meta::importedNamespaces = pUserProc->GetImportedNamespaces();
    261264
    262265    if(pUserProc->IsSystem()){
  • BasicCompiler_Common/Class.cpp

    r106 r108  
    148148
    149149
    150 CClass::CClass( const NamespaceScopes &namespaceScopes, const char *name ):
    151     namespaceScopes( namespaceScopes ),
    152     ConstructorMemberSubIndex( 0 ),
    153     DestructorMemberSubIndex( 0 ),
    154     classType( Class ),
    155     isUsing( false ),
    156     pobj_InheritsClass( NULL ),
    157     ppobj_Member( NULL ),
    158     iMemberNum( 0 ),
    159     vtbl_num( 0 ),
    160     iAlign( 0 ),
    161     vtbl_offset( -1 ),
    162     isCompilingConstructor( false ),
    163     isCompilingDestructor( false ),
    164     pobj_NextClass( NULL )
     150CClass::CClass( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name )
     151    : namespaceScopes( namespaceScopes )
     152    , importedNamespaces( importedNamespaces )
     153    , ConstructorMemberSubIndex( 0 )
     154    , DestructorMemberSubIndex( 0 )
     155    , classType( Class )
     156    , isUsing( false )
     157    , pobj_InheritsClass( NULL )
     158    , ppobj_Member( NULL )
     159    , iMemberNum( 0 )
     160    , vtbl_num( 0 )
     161    , iAlign( 0 )
     162    , vtbl_offset( -1 )
     163    , isCompilingConstructor( false )
     164    , isCompilingDestructor( false )
     165    , pobj_NextClass( NULL )
    165166{
    166167    this->name=(char *)HeapAlloc(hHeap,0,lstrlen(name)+1);
     
    854855}
    855856
    856 CClass *CDBClass::AddClass( const NamespaceScopes &namespaceScopes, const char *name,int nowLine){
     857CClass *CDBClass::AddClass( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine){
    857858    //////////////////////////////////////////////////////////////////////////
    858859    // クラスを追加
     
    861862
    862863    CClass *pobj_c;
    863     pobj_c=new CClass(namespaceScopes, name);
     864    pobj_c=new CClass(namespaceScopes, importedNamespaces, name);
    864865
    865866    if(lstrcmp(name,"String")==0){
     
    910911    namespaceScopes.clear();
    911912
     913    // Importsされた名前空間の管理
     914    NamespaceScopesCollection &importedNamespaces = Smoothie::Meta::importedNamespaces;
     915    importedNamespaces.clear();
     916
    912917    for(i=0;;i++){
    913918        if(basbuf[i]=='\0') break;
     
    934939
    935940            i += 2;
     941            continue;
     942        }
     943        else if( basbuf[i] == 1 && basbuf[i+1] == ESC_IMPORTS ){
     944            for(i+=2,i2=0;;i2++,i++){
     945                if( IsCommandDelimitation( basbuf[i] ) ){
     946                    temporary[i2]=0;
     947                    break;
     948                }
     949                temporary[i2]=basbuf[i];
     950            }
     951            importedNamespaces.Imports( temporary );
     952
     953            continue;
     954        }
     955        else if( basbuf[i] == 1 && basbuf[i+1] == ESC_CLEARNAMESPACEIMPORTED ){
     956            importedNamespaces.clear();
    936957            continue;
    937958        }
     
    971992
    972993                //クラスを追加
    973                 CClass *pClass = pobj_DBClass->AddClass(namespaceScopes, temporary,nowLine);
     994                CClass *pClass = pobj_DBClass->AddClass(namespaceScopes, importedNamespaces, temporary,nowLine);
    974995                if( pClass ){
    975996                    if( basbuf[nowLine+1] == ESC_CLASS ){
     
    10101031    //関数ハッシュへ登録
    10111032    GlobalProc *pUserProc;
    1012     pUserProc=AddSubData( NamespaceScopes(), buffer,nowLine,bVirtual,pobj_c, (bStatic!=0) );
     1033    pUserProc=AddSubData( NamespaceScopes(), NamespaceScopesCollection(), buffer,nowLine,bVirtual,pobj_c, (bStatic!=0) );
    10131034    if(!pUserProc) return;
    10141035
  • BasicCompiler_Common/Class.h

    r102 r108  
    6464    // 名前空間
    6565    NamespaceScopes namespaceScopes;
     66    NamespaceScopesCollection importedNamespaces;
    6667
    6768    //静的メンバ情報
     
    107108
    108109public:
    109     CClass( const NamespaceScopes &namespaceScopes, const char *name );
     110    CClass( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name );
    110111    ~CClass();
    111112
    112     virtual const NamespaceScopes &GetNamespaceScopes() const
     113    const NamespaceScopes &GetNamespaceScopes() const
    113114    {
    114115        return namespaceScopes;
     116    }
     117    const NamespaceScopesCollection &GetImportedNamespaces() const
     118    {
     119        return importedNamespaces;
    115120    }
    116121
     
    250255    CClass *Find( const NamespaceScopes &namespaceScopes, const string &name ) const;
    251256
    252     CClass *AddClass( const NamespaceScopes &namespaceScopes, const char *name,int nowLine);
     257    CClass *AddClass( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine);
    253258
    254259    void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);
  • BasicCompiler_Common/DebugMiddleFile.cpp

    r102 r108  
    487487        //クラス名
    488488        // TODO: 名前空間が未完成
    489         pobj_DBClass->AddClass(NamespaceScopes(),buffer+i2,0);
     489        pobj_DBClass->AddClass(NamespaceScopes(),NamespaceScopesCollection(),buffer+i2,0);
    490490        i2+=lstrlen(buffer+i2)+1;
    491491    }
     
    598598        // オブジェクトを生成
    599599        // TODO: 名前空間が未完成
    600         pUserProc = new GlobalProc( NamespaceScopes(), name, Procedure::Function, false, false, false );
     600        pUserProc = new GlobalProc( NamespaceScopes(), NamespaceScopesCollection(), name, Procedure::Function, false, false, false );
    601601        pUserProc->pNextData=0;
    602602        pUserProc->id=id;
  • BasicCompiler_Common/Procedure.cpp

    r102 r108  
    377377    return pParentClass->GetNamespaceScopes();
    378378}
     379const NamespaceScopesCollection &UserProc::GetImportedNamespaces() const
     380{
     381    if( !pParentClass ){
     382        SetError();
     383    }
     384    return pParentClass->GetImportedNamespaces();
     385}
    379386bool UserProc::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const
    380387{
     
    383390}
    384391
     392/*
    385393GlobalProc *GlobalProc::Create( const NamespaceScopes &namespaceScopes, char *buffer,int nowLine ){
    386394    int i2;
     
    509517
    510518    return true;
    511 }
     519}*/
    512520bool GlobalProc::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const
    513521{
  • BasicCompiler_Common/Procedure.h

    r101 r108  
    222222
    223223    virtual const NamespaceScopes &GetNamespaceScopes() const;
     224    virtual const NamespaceScopesCollection &GetImportedNamespaces() const;
    224225    virtual bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const;
    225226
     
    257258{
    258259    const NamespaceScopes namespaceScopes;
     260    const NamespaceScopesCollection importedNamespaces;
    259261public:
    260262    // ハッシュリスト用
    261263    GlobalProc *pNextData;
    262264
    263     GlobalProc( const NamespaceScopes &namespaceScopes, const string &name, Kind kind, bool isMacro, bool isCdecl, bool isExport ):
     265    GlobalProc( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const string &name, Kind kind, bool isMacro, bool isCdecl, bool isExport ):
    264266      UserProc( name, kind, isMacro, isCdecl, isExport ),
    265267      namespaceScopes( namespaceScopes ),
     268      importedNamespaces( importedNamespaces ),
    266269      pNextData( NULL )
    267270    {}
    268271    ~GlobalProc(){}
    269 
     272/*
    270273    GlobalProc *Create( const NamespaceScopes &namespaceScopes, char *buffer,int nowLine );
    271274    bool AddGlobalProc( const NamespaceScopes &namespaceScopes, char *buffer,int nowLine );
    272 
     275*/
    273276    virtual const NamespaceScopes &GetNamespaceScopes() const
    274277    {
    275278        return namespaceScopes;
     279    }
     280    virtual const NamespaceScopesCollection &GetImportedNamespaces() const
     281    {
     282        return importedNamespaces;
    276283    }
    277284
  • BasicCompiler_Common/Subroutine.cpp

    r101 r108  
    463463}
    464464
    465 GlobalProc *AddSubData( const NamespaceScopes &namespaceScopes, char *buffer,int nowLine,BOOL bVirtual,CClass *pobj_c, bool isStatic){
     465GlobalProc *AddSubData( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,BOOL bVirtual,CClass *pobj_c, bool isStatic){
    466466    int i2,i3;
    467467    char temporary[8192];
     
    584584    SubNum++;
    585585
    586     GlobalProc *pUserProc = new GlobalProc( namespaceScopes, temporary, kind, isMacro, isCdecl, isExport );
     586    GlobalProc *pUserProc = new GlobalProc( namespaceScopes, importedNamespaces, temporary, kind, isMacro, isCdecl, isExport );
    587587    pUserProc->SetParentClass( pobj_c );
    588588
     
    664664    namespaceScopes.clear();
    665665
     666    // Importsされた名前空間の管理
     667    NamespaceScopesCollection &importedNamespaces = Smoothie::Meta::importedNamespaces;
     668    importedNamespaces.clear();
     669
    666670    i=-1;
    667671    while(1){
     
    707711            continue;
    708712        }
     713        else if( basbuf[i] == 1 && basbuf[i+1] == ESC_IMPORTS ){
     714            for(i+=2,i2=0;;i2++,i++){
     715                if( IsCommandDelimitation( basbuf[i] ) ){
     716                    temporary[i2]=0;
     717                    break;
     718                }
     719                temporary[i2]=basbuf[i];
     720            }
     721            importedNamespaces.Imports( temporary );
     722
     723            continue;
     724        }
     725        else if( basbuf[i] == 1 && basbuf[i+1] == ESC_CLEARNAMESPACEIMPORTED ){
     726            importedNamespaces.clear();
     727            continue;
     728        }
    709729
    710730        if(basbuf[i]==1&&basbuf[i+1]==ESC_DECLARE){
     
    722742        }
    723743        if(basbuf[i]==1&&(basbuf[i+1]==ESC_SUB||basbuf[i+1]==ESC_FUNCTION||basbuf[i+1]==ESC_MACRO)){
     744            char statementChar = basbuf[i+1];
     745
    724746            for(i2=0;;i2++,i++){
    725747                if(IsCommandDelimitation(basbuf[i])){
     
    730752                if(basbuf[i]=='\0') break;
    731753            }
    732             AddSubData(namespaceScopes,temporary,i,0,0);
    733 
     754            AddSubData(namespaceScopes, importedNamespaces, temporary,i,0,0);
     755
     756            /*  Sub ~ End Sub
     757                Function ~ End Function
     758                Macro ~ End Macro
     759                を飛び越す           */
     760            char endStatementChar = GetEndXXXCommand( statementChar );
     761            for(i2=0;;i++,i2++){
     762                if( basbuf[i] == '\0' ) break;
     763                if( basbuf[i] == 1 && basbuf[i+1] == endStatementChar ){
     764                    i++;
     765                    break;
     766                }
     767            }
     768            if(basbuf[i]=='\0') break;
    734769            continue;
    735770        }
     
    746781    ////////////
    747782    namespaceScopes.clear();
     783    importedNamespaces.clear();
    748784
    749785    sprintf(temporary,"%c%c_allrem()",1,ESC_SUB);
    750     AddSubData( namespaceScopes, temporary,0,0,0);
     786    AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
    751787
    752788    sprintf(temporary,"%c%c_aullrem()",1,ESC_SUB);
    753     AddSubData( namespaceScopes, temporary,0,0,0);
     789    AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
    754790
    755791    sprintf(temporary,"%c%c_allmul()",1,ESC_SUB);
    756     AddSubData( namespaceScopes, temporary,0,0,0);
     792    AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
    757793
    758794    sprintf(temporary,"%c%c_alldiv()",1,ESC_SUB);
    759     AddSubData( namespaceScopes, temporary,0,0,0);
     795    AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
    760796
    761797    sprintf(temporary,"%c%c_aulldiv()",1,ESC_SUB);
    762     AddSubData( namespaceScopes, temporary,0,0,0);
     798    AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
    763799
    764800    sprintf(temporary,"%c%c_allshl()",1,ESC_SUB);
    765     AddSubData( namespaceScopes, temporary,0,0,0);
     801    AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
    766802
    767803    sprintf(temporary,"%c%c_allshr()",1,ESC_SUB);
    768     AddSubData( namespaceScopes, temporary,0,0,0);
     804    AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
    769805
    770806    sprintf(temporary,"%c%c_aullshr()",1,ESC_SUB);
    771     AddSubData( namespaceScopes, temporary,0,0,0);
     807    AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
    772808
    773809    sprintf(temporary,"%c%c_System_InitStaticLocalVariables()",1,ESC_SUB);
    774     AddSubData( namespaceScopes, temporary,0,0,0);
     810    AddSubData( namespaceScopes, importedNamespaces, temporary,0,0,0);
    775811}
    776812void Delete_si(GlobalProc *pUserProc){
  • BasicCompiler_Common/common.h

    r107 r108  
    450450bool GetReturnTypeOfPropertyMethod( const char *variable, const char *rightSide, Type &resultType );
    451451bool GetReturnTypeOfIndexerGetterProc( const CClass &objClass, Type &resultType );
    452 GlobalProc *AddSubData( const NamespaceScopes &namespaceScopes, char *buffer,int nowLine,BOOL bVirtual,CClass *pobj_c, bool isStatic = false );
     452GlobalProc *AddSubData( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,BOOL bVirtual,CClass *pobj_c, bool isStatic = false );
    453453void GetSubInfo(void);
    454454void DeleteSubInfo(GlobalProc **ppSubHash,char **ppMacroNames,int MacroNum);
Note: See TracChangeset for help on using the changeset viewer.