Changeset 636 in dev for trunk/ab5.0/abdev


Ignore:
Timestamp:
Jun 10, 2008, 11:40:17 PM (16 years ago)
Author:
dai_9181
Message:

libファイルを跨ったテンプレート展開に対応。

Location:
trunk/ab5.0/abdev
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/abdev/BasicCompiler_Common/BreakPoint.cpp

    r603 r636  
    4242    const IncludedFilesRelation *pIncludedFilesRelation = NULL;
    4343    const BasicSource *pNowSource = NULL;
    44     BOOST_FOREACH( const BasicSource &source, compiler.GetObjectModule().GetSources() )
     44    BOOST_FOREACH( const ObjectModule *pObjectModule, compiler.staticLibraries )
    4545    {
    46         pIncludedFilesRelation = &source.GetIncludedFilesRelation();
     46        const BasicSource *pSource = &pObjectModule->GetSource();
     47
     48        pIncludedFilesRelation = &pSource->GetIncludedFilesRelation();
    4749
    4850        for(FileNum=0;FileNum<pIncludedFilesRelation->GetFileCounts();FileNum++)
     
    5052            if(lstrcmpi(pIncludedFilesRelation->GetFilePathFromFileNumber(FileNum).c_str(),lpszFileName)==0)
    5153            {
    52                 pNowSource = &source;
     54                pNowSource = pSource;
    5355                break;
    5456            }
  • trunk/ab5.0/abdev/BasicCompiler_Common/CDebugThreadInfo.cpp

    r280 r636  
    3737    lplpSpBase=(ULONG_PTR *)HeapAlloc(hHeap,0,(iProcLevel+1)*sizeof(ULONG_PTR));
    3838    lpdwCp=(DWORD *)HeapAlloc(hHeap,0,(iProcLevel+1)*sizeof(DWORD));
    39     lpdwSourceIndex=(DWORD *)HeapAlloc(hHeap,0,(iProcLevel+1)*sizeof(DWORD));
     39    this->relationalObjectModuleIndexes.resize( iProcLevel + 1 );
    4040
    4141    //lplpObp
     
    108108        HeapDefaultFree(lplpSpBase);
    109109        HeapDefaultFree(lpdwCp);
    110         HeapDefaultFree(lpdwSourceIndex);
     110        relationalObjectModuleIndexes.clear();
    111111    }
    112112
  • trunk/ab5.0/abdev/BasicCompiler_Common/Compile.cpp

    r632 r636  
    1818//デバッグ用行番号情報
    1919SourceLines oldSourceLines;
     20
     21// オブジェクトモジュールリストに類似したソースコードリスト
     22BasicSources sourcesLinkRelationalObjectModule;
    2023
    2124
     
    744747            }
    745748
    746             compiler.codeGenerator.NextSourceLine( compiler.GetObjectModule().GetCurrentSourceIndex() );
     749            compiler.codeGenerator.NextSourceLine( compiler.GetCurrentRelationalObjectModuleIndexForSource() );
    747750
    748751            if(Command[0]==1){
  • trunk/ab5.0/abdev/BasicCompiler_Common/Debug.cpp

    r605 r636  
    5858    const IncludedFilesRelation *pIncludedFilesRelation = NULL;
    5959    const BasicSource *pNowSource = NULL;
    60     BOOST_FOREACH( const BasicSource &source, compiler.GetObjectModule().GetSources() )
     60    BOOST_FOREACH( const ObjectModule *pObjectModule, compiler.staticLibraries )
    6161    {
    62         pIncludedFilesRelation = &source.GetIncludedFilesRelation();
     62        const BasicSource *pSource = &pObjectModule->GetSource();
     63
     64        pIncludedFilesRelation = &pSource->GetIncludedFilesRelation();
    6365
    6466        for(FileNum=0;FileNum<pIncludedFilesRelation->GetFileCounts();FileNum++)
     
    6668            if(lstrcmpi(pIncludedFilesRelation->GetFilePathFromFileNumber(FileNum).c_str(),szFilePath)==0)
    6769            {
    68                 pNowSource = &source;
     70                pNowSource = pSource;
    6971                break;
    7072            }
  • trunk/ab5.0/abdev/BasicCompiler_Common/DebugMiddleFile.cpp

    r603 r636  
    9999    }
    100100
     101    // オブジェクトモジュールリストに類似したソースコードリスト
     102    {
     103        // オブジェクトモジュールリストに類似したソースコードリストを作成
     104        BasicSources sources;
     105        BOOST_FOREACH( const ObjectModule *pObjectModule, compiler.staticLibraries )
     106        {
     107            sources.push_back( pObjectModule->GetSource() );
     108        }
     109
     110        // テキストデータにシリアライズ
     111        std::string textString;
     112        sources.WriteBinaryString( textString );
     113
     114        // サイズ
     115        *(long *)(buffer+i2) = (long)textString.size();
     116        i2+=sizeof(long);
     117
     118        //バッファが足りない場合は再確保
     119        if(BufferSize<i2+(int)textString.size()+32768){
     120            while( BufferSize<i2+(int)textString.size()+32768 )
     121            {
     122                BufferSize+=32768;
     123            }
     124
     125            buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);
     126        }
     127
     128        // バッファ
     129        memcpy( buffer+i2, textString.c_str(), textString.size() );
     130        i2 += (int)textString.size();
     131    }
     132
    101133
    102134    ////////////////////////
     
    115147        i2+=sizeof(long);
    116148
    117         *(long *)(buffer+i2) = sourceLine.GetSourceIndex();
     149        *(long *)(buffer+i2) = sourceLine.GetRelationalObjectModuleIndex();
    118150        i2+=sizeof(long);
    119151
     
    192224        this->objectModule.ReadString( textString );
    193225
    194         compiler.SelectObjectModule( this->objectModule );
    195     }
    196 
     226        compiler.SelectObjectModule( &this->objectModule );
     227    }
     228
     229    // オブジェクトモジュールリストに類似したソースコードリスト
     230    {
     231        // サイズ
     232        int size = *(long *)(buffer+i2);
     233        i2 += sizeof(long);
     234
     235        // バッファ
     236        const std::string textString( (const char *)(buffer + i2), size );
     237        i2 += size;
     238
     239        // テキストデータからシリアライズ
     240        this->_sourcesLinkRelationalObjectModule.ReadBinaryString( textString );
     241    }
    197242
    198243    //コードと行番号の関係
     
    246291    //ソースコード
    247292    extern char *basbuf;
    248     basbuf = const_cast<char *>(compiler.GetObjectModule().GetSource(0).GetBuffer());
     293    basbuf = const_cast<char *>(compiler.GetObjectModule().GetSource().GetBuffer());
    249294
    250295
     
    252297    // ブレークポイントを適用
    253298    /////////////////////////////
     299
     300    // オブジェクトモジュールリストに類似したソースコードリスト
     301    extern BasicSources sourcesLinkRelationalObjectModule;
     302    sourcesLinkRelationalObjectModule = this->_sourcesLinkRelationalObjectModule;
    254303
    255304    //コードと行番号の関係
     
    364413
    365414    // オブジェクトモジュール
    366     compiler.SelectObjectModule( this->objectModule );
     415    compiler.SelectObjectModule( &this->objectModule );
    367416
    368417    //コードと行番号の関係
  • trunk/ab5.0/abdev/BasicCompiler_Common/DebugSection.h

    r603 r636  
    2424    // オブジェクトモジュール
    2525    ObjectModule objectModule;
     26
     27    // オブジェクトモジュールリストに類似したソースコードリスト
     28    BasicSources _sourcesLinkRelationalObjectModule;
    2629
    2730    //コードと行番号の関係
  • trunk/ab5.0/abdev/BasicCompiler_Common/MakeExe.cpp

    r622 r636  
    3434
    3535    //最後尾に貼り付け
    36     compiler.GetObjectModule().GetCurrentSource().Addition( temp );
     36    compiler.GetObjectModule().GetSource().Addition( temp );
    3737
    3838    HeapDefaultFree(temp);
     
    6464    TypeOfSubSystem=IMAGE_SUBSYSTEM_WINDOWS_GUI;
    6565
     66    // オブジェクトモジュール名をセットする
     67    compiler.GetObjectModule().SetName( program.GetOutputFileName() );
     68
    6669    //プログラムをファイルから読み込む
    67     compiler.GetObjectModule().SetCurrentSourceIndex( (int)compiler.GetObjectModule().GetSources().size() );
    68     compiler.GetObjectModule().GetSources().push_back( BasicSource() );
    69     bool result = compiler.GetObjectModule().GetCurrentSource().ReadFile(
     70    bool result = compiler.GetObjectModule().GetSource().ReadFile(
    7071        program.GetSourceFilePath(),
    7172        compiler.IsDebug(),
     
    8081        goto EndCompile;
    8182    }
    82     if( !compiler.GetObjectModule().GetCurrentSource().cannotIncludePath.empty() )
     83    if( !compiler.GetCurrentSource().cannotIncludePath.empty() )
    8384    {
    8485        compiler.errorMessenger.Output(
    8586            35,
    86             compiler.GetObjectModule().GetCurrentSource().cannotIncludePath,
    87             compiler.GetObjectModule().GetCurrentSource().cannotIncludeSourcePos
     87            compiler.GetCurrentSource().cannotIncludePath,
     88            compiler.GetCurrentSource().cannotIncludeSourcePos
    8889        );
    8990        goto EndCompile;
     
    145146
    146147    ChangeCommandToCode(basbuf);
    147     compiler.GetObjectModule().GetSources()[0]._ResetLength();
     148    compiler.GetObjectModule().GetSource()._ResetLength();
    148149
    149150    if( compiler.errorMessenger.HasError() || bStopCompile )
  • trunk/ab5.0/abdev/BasicCompiler_Common/VarList.cpp

    r587 r636  
    621621        {
    622622            pobj_dti->lpdwCp[i3]=oldSourceLines[i2].GetSourceCodePos();
    623             pobj_dti->lpdwSourceIndex[i3]=oldSourceLines[i2].GetSourceIndex();
     623            pobj_dti->relationalObjectModuleIndexes[i3]=oldSourceLines[i2].GetRelationalObjectModuleIndex();
    624624        }
    625625    }
     
    631631                pobj_dti->lplpSpBase[i2]=pobj_dti->lplpSpBase[i2+1];
    632632                pobj_dti->lpdwCp[i2]=pobj_dti->lpdwCp[i2+1];
    633                 pobj_dti->lpdwSourceIndex[i2]=pobj_dti->lpdwSourceIndex[i2+1];
     633                pobj_dti->relationalObjectModuleIndexes[i2]=pobj_dti->relationalObjectModuleIndexes[i2+1];
    634634            }
    635635            i3--;
     
    639639
    640640    std::string dummyStr;
    641     if(!compiler.GetObjectModule().GetSource( pobj_dti->lpdwSourceIndex[pobj_dti->iProcLevel] ).GetLineInfo( pobj_dti->lpdwCp[pobj_dti->iProcLevel], i2, dummyStr )){
     641    extern BasicSources sourcesLinkRelationalObjectModule;
     642    if(!sourcesLinkRelationalObjectModule[pobj_dti->relationalObjectModuleIndexes[pobj_dti->iProcLevel]].GetLineInfo( pobj_dti->lpdwCp[pobj_dti->iProcLevel], i2, dummyStr )){
    642643        extern HWND hMainDlg;
    643644        //"デバッグ情報の取得に失敗"
     
    721722
    722723                std::string dummyStr;
    723                 compiler.GetObjectModule().GetSource( pobj_dti->lpdwSourceIndex[pobj_dti->iProcLevel] ).GetLineInfo( pobj_dti->lpdwCp[pobj_dti->iProcLevel-i2], i3, dummyStr );
     724                extern BasicSources sourcesLinkRelationalObjectModule;
     725                sourcesLinkRelationalObjectModule[pobj_dti->relationalObjectModuleIndexes[pobj_dti->iProcLevel]].GetLineInfo( pobj_dti->lpdwCp[pobj_dti->iProcLevel-i2], i3, dummyStr );
    724726                ShowErrorLine(i3,dummyStr.c_str());
    725727
  • trunk/ab5.0/abdev/BasicCompiler_Common/debug.h

    r280 r636  
    44    //ソースコードポインタ
    55    DWORD *lpdwCp;
    6     DWORD *lpdwSourceIndex;
     6    std::vector<int> relationalObjectModuleIndexes;
    77
    88    //ネイティブコードポインタ
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/Compiler.h

    r632 r636  
    2525    const CClass *pCompilingClass;
    2626
    27     // オブジェクトモジュール
    28     ObjectModule *pObjectModule;
    29     ObjectModule *pNowObjectModule;
     27    // 現在参照したいソースコードのオブジェクト モジュール インデックス
     28    int currentRelationalObjectModuleIndexForSource;
     29
     30
    3031
    3132public:
    3233
    33     Compiler()
    34         : isBuildSuccessful( false )
    35         , pObjectModule( new ObjectModule )
    36         , targetModuleType( ActiveBasic::Common::TargetModuleType::Exe )
    37         , isDebug( false )
    38         , isUnicode( false )
    39         , isCore( false )
    40     {
    41         SelectObjectModule( *pObjectModule );
    42         Symbol::RegistNamespaceSupporter( &namespaceSupporter );
    43     }
    44     ~Compiler()
    45     {
    46         delete pObjectModule;
    47         Clear();
    48     }
    49     void Clear()
    50     {
    51         BOOST_FOREACH( ObjectModule *pStaticLibrary, staticLibraries )
    52         {
    53             delete pStaticLibrary;
    54         }
    55         staticLibraries.clear();
    56     }
    57 
     34    Compiler();
     35    ~Compiler();
     36
     37    // 静的リンクの準備を行う(オブジェクトモジュール同士の名前リストの結合など、前処理を行う)
     38    void PreStaticLink( const ObjectModules &staticLibraries );
     39
     40    // 静的リンクを行う
    5841    void StaticLink( ObjectModules &staticLibraries );
    5942
     
    10386    ObjectModules staticLibraries;
    10487
     88    ObjectModule *pSelectedObjectModule;
     89
    10590    // オブジェクトモジュール
    10691    ObjectModule &GetObjectModule()
    10792    {
    108         return *pNowObjectModule;
    109     }
    110     void SelectObjectModule( ObjectModule &objectModule )
    111     {
    112         pNowObjectModule = &objectModule;
    113 
    114         namespaceSupporter.RegistAllNamespaceScopesCollection( &GetObjectModule().meta.GetNamespaces() );
     93        return *pSelectedObjectModule;
     94    }
     95
     96    void SelectObjectModule( ObjectModule *pObjectModule )
     97    {
     98        this->pSelectedObjectModule = pObjectModule;
     99    }
     100
     101    // 現在参照すべきソースコード
     102    const BasicSource &GetCurrentSource()
     103    {
     104        return staticLibraries[currentRelationalObjectModuleIndexForSource]->GetSource();
     105    }
     106
     107    // 現在参照すべきソースコードを格納するオブジェクトモジュールのインデックス
     108    int GetCurrentRelationalObjectModuleIndexForSource() const
     109    {
     110        return currentRelationalObjectModuleIndexForSource;
     111    }
     112    void SetCurrentRelationalObjectModuleIndexForSource( int currentRelationalObjectModuleIndexForSource )
     113    {
     114        this->currentRelationalObjectModuleIndexForSource = currentRelationalObjectModuleIndexForSource;
    115115    }
    116116
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/Program.h

    r522 r636  
    4242    {
    4343        return outputFilePath;
     44    }
     45    const std::string GetOutputFileName() const
     46    {
     47        Jenga::Common::Path path( outputFilePath );
     48        return path.GetFileName() + path.GetExt();
    4449    }
    4550    void SetOutputFilePath( const std::string &outputFilePath )
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/BoostSerializationSupport.cpp

    r603 r636  
    496496#include <logger.h>
    497497#include <Configuration.h>
     498#include <abdev/ab_common/include/Lexical/Source.h>
    498499
    499500template class Jenga::Common::BoostSerializationSupport<LoggerSetting>;
    500501template class Jenga::Common::BoostSerializationSupport<Configuration>;
     502template class Jenga::Common::BoostSerializationSupport<BasicSources>;
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/Compiler.cpp

    r632 r636  
    55Compiler compiler;
    66
     7Compiler::Compiler()
     8    : isBuildSuccessful( false )
     9    , targetModuleType( ActiveBasic::Common::TargetModuleType::Exe )
     10    , isDebug( false )
     11    , isUnicode( false )
     12    , isCore( false )
     13    , currentRelationalObjectModuleIndexForSource( 0 )
     14{
     15    // 生成先のオブジェクトモジュールを登録
     16    ObjectModule *pObjectModule = new ObjectModule();
     17    staticLibraries.push_back( pObjectModule );
     18    SelectObjectModule( pObjectModule );
     19
     20    namespaceSupporter.RegistAllNamespaceScopesCollection( &GetObjectModule().meta.GetNamespaces() );
     21
     22    Symbol::RegistNamespaceSupporter( &namespaceSupporter );
     23}
     24Compiler::~Compiler()
     25{
     26    BOOST_FOREACH( ObjectModule *pStaticLibrary, staticLibraries )
     27    {
     28        delete pStaticLibrary;
     29    }
     30    staticLibraries.clear();
     31}
     32
     33void Compiler::PreStaticLink( const ObjectModules &staticLibraries )
     34{
     35    BOOST_FOREACH( const ObjectModule *pStaticLibrary, staticLibraries )
     36    {
     37        // 関連オブジェクトモジュールの名前リスト
     38        this->GetObjectModule().relationalObjectModuleNames.push_back( pStaticLibrary->GetName() );
     39    }
     40}
    741void Compiler::StaticLink( ObjectModules &staticLibraries )
    842{
    943    BOOST_FOREACH( ObjectModule *pStaticLibrary, staticLibraries )
    1044    {
     45        if( &this->GetObjectModule() == pStaticLibrary )
     46        {
     47            // 自分自身の場合はリンクしない
     48            continue;
     49        }
     50
    1151        // メタ情報
    12         pNowObjectModule->StaticLink( *pStaticLibrary );
     52        this->GetObjectModule().StaticLink( *pStaticLibrary );
    1353    }
    1454}
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/Messenger.cpp

    r628 r636  
    4242    if( sourceIndex != -1 )
    4343    {
    44         compiler.GetObjectModule().GetCurrentSource().GetLineInfo( sourceIndex, sourceLineNum, sourceFilePath );
     44        compiler.GetCurrentSource().GetLineInfo( sourceIndex, sourceLineNum, sourceFilePath );
    4545    }
    4646
  • trunk/ab5.0/abdev/ab_common/include/Lexical/Interface.h

    r603 r636  
    7272    }
    7373
    74     const CClass &GetClass() const{
     74    const CClass &GetClass() const
     75    {
    7576        return *pInterfaceClass;
    7677    }
  • trunk/ab5.0/abdev/ab_common/include/Lexical/Meta.h

    r603 r636  
    6969
    7070    // 静的リンク
    71     void StaticLink( Meta &meta, long dataSectionBaseOffset, int sourceIndexBase );
     71    void StaticLink( Meta &meta, long dataSectionBaseOffset, const std::vector<int> &relationTable );
    7272
    7373    const NamespaceScopesCollection &GetNamespaces() const
  • trunk/ab5.0/abdev/ab_common/include/Lexical/NativeCode.h

    r603 r636  
    125125    int lineNum;
    126126    long nativeCodePos;
    127     int sourceIndex;
     127    int relationalObjectModuleIndex;
    128128    long sourceCodePos;
    129129    DWORD codeType;
     
    138138        ar & BOOST_SERIALIZATION_NVP( lineNum );
    139139        ar & BOOST_SERIALIZATION_NVP( nativeCodePos );
    140         ar & BOOST_SERIALIZATION_NVP( sourceIndex );
     140        ar & BOOST_SERIALIZATION_NVP( relationalObjectModuleIndex );
    141141        ar & BOOST_SERIALIZATION_NVP( sourceCodePos );
    142142        ar & BOOST_SERIALIZATION_NVP( codeType );
     
    144144
    145145public:
    146     SourceLine( int lineNum, int nativeCodePos, int sourceIndex, int sourceCodePos, DWORD codeType )
     146    SourceLine( int lineNum, int nativeCodePos, int relationalObjectModuleIndex, int sourceCodePos, DWORD codeType )
    147147        : lineNum( lineNum )
    148148        , nativeCodePos( nativeCodePos )
    149         , sourceIndex( sourceIndex )
     149        , relationalObjectModuleIndex( relationalObjectModuleIndex )
    150150        , sourceCodePos( sourceCodePos )
    151151        , codeType( codeType )
     
    164164        return nativeCodePos;
    165165    }
    166     int GetSourceIndex() const
    167     {
    168         return sourceIndex;
    169     }
    170     void SetSourceIndex( int sourceIndex )
    171     {
    172         this->sourceIndex = sourceIndex;
     166    int GetRelationalObjectModuleIndex() const
     167    {
     168        return relationalObjectModuleIndex;
     169    }
     170    void SetRelationalObjectModuleIndex( int relationalObjectModuleIndex )
     171    {
     172        this->relationalObjectModuleIndex = relationalObjectModuleIndex;
    173173    }
    174174    long GetSourceCodePos() const
     
    259259
    260260    void ResetDataSectionBaseOffset( long dataSectionBaseOffset );
    261     void ResetSourceIndexes( long sourceIndexBase );
     261    void ResetSourceIndexes( const std::vector<int> &relationTable );
    262262};
  • trunk/ab5.0/abdev/ab_common/include/Lexical/ObjectModule.h

    r632 r636  
    66    // オブジェクトモジュール名
    77    std::string name;
     8
     9    // 関連オブジェクトモジュールの名前リスト
     10    Jenga::Common::Strings relationalObjectModuleNames;
    811
    912    // メタ情報
     
    1821private:
    1922    // ソースコード
    20     int currentSourceIndex;
    21     BasicSources sources;
     23    BasicSource source;
    2224
    2325    // XMLシリアライズ用
     
    3335
    3436        ar & BOOST_SERIALIZATION_NVP( name );
     37        ar & BOOST_SERIALIZATION_NVP( relationalObjectModuleNames );
    3538        ar & BOOST_SERIALIZATION_NVP( meta );
    3639        ar & BOOST_SERIALIZATION_NVP( globalNativeCode );
    3740        ar & BOOST_SERIALIZATION_NVP( dataTable );
    38         ar & BOOST_SERIALIZATION_NVP( currentSourceIndex );
    39         ar & BOOST_SERIALIZATION_NVP( sources );
     41        ar & BOOST_SERIALIZATION_NVP( source );
    4042    }
    4143
     
    5153        this->name = name;
    5254    }
    53     int GetCurrentSourceIndex() const
     55    const BasicSource &GetSource() const
    5456    {
    55         return currentSourceIndex;
     57        return source;
    5658    }
    57     const BasicSource &GetCurrentSource() const
     59    BasicSource &GetSource()
    5860    {
    59         return sources[currentSourceIndex];
     61        return source;
    6062    }
    61     BasicSource &GetCurrentSource()
    62     {
    63         return sources[currentSourceIndex];
    64     }
    65     void SetCurrentSourceIndex( int currentSourceIndex )
    66     {
    67         this->currentSourceIndex = currentSourceIndex;
    68     }
    69     const BasicSource &GetSource( int sourceIndex ) const
    70     {
    71         return sources[sourceIndex];
    72     }
    73     BasicSources &GetSources()
    74     {
    75         return sources;
    76     }
     63
     64    // 下記の関連になるようなテーブルを取得する
     65    // 要素 = 古いインデックス、値 = 新しいインデックス
     66    const std::vector<int> GetRelationTable( const Jenga::Common::Strings &oldRelationalObjectModule );
    7767
    7868    bool Read( const std::string &filePath );
  • trunk/ab5.0/abdev/ab_common/include/Lexical/Source.h

    r632 r636  
    1111    template<class Archive> void serialize(Archive& ar, const unsigned int version)
    1212    {
    13         trace_for_serialize( "serializing - IncludedFilesRelation" );
    14 
    1513        ar & BOOST_SERIALIZATION_NVP( filePaths );
    1614        ar & BOOST_SERIALIZATION_NVP( lineFileNumbers );
     
    119117    template<class Archive> void load(Archive& ar, const unsigned int version)
    120118    {
    121         trace_for_serialize( "serializing(load) - BasicSource" );
    122 
    123119        std::string _buffer;
    124120        ar & BOOST_SERIALIZATION_NVP( _buffer );
     
    139135    template<class Archive> void save(Archive& ar, const unsigned int version) const
    140136    {
    141         trace_for_serialize( "serializing(save) - BasicSource" );
    142 
    143137        // 保存準備
    144138        char *tempCode = (char *)calloc( (length+1) * 3, 1 );
     
    252246    int cannotIncludeSourcePos;
    253247};
    254 typedef std::vector<BasicSource> BasicSources;
     248class BasicSources
     249    : public std::vector<BasicSource>
     250    , public Jenga::Common::BoostSerializationSupport<BasicSources>
     251{
     252    // XMLシリアライズ用
     253private:
     254    virtual const char *RootTagName() const
     255    {
     256        return "basicSources";
     257    }
     258    friend class boost::serialization::access;
     259    template<class Archive> void serialize(Archive& ar, const unsigned int version)
     260    {
     261        ar & boost::serialization::make_nvp("vector_BasicSource", boost::serialization::base_object<std::vector<BasicSource>>(*this));
     262    }
     263};
    255264
    256265class SourceCodePosition
  • trunk/ab5.0/abdev/ab_common/src/Lexical/Class.cpp

    r632 r636  
    677677    }
    678678
     679    _ASSERT( false );
    679680    throw;
    680681}
     
    693694    }
    694695
     696    _ASSERT( false );
    695697    throw;
    696698}
     
    699701    if( vtblMasterListOffset == -1 )
    700702    {
     703        _ASSERT( false );
    701704        throw;
    702705    }
  • trunk/ab5.0/abdev/ab_common/src/Lexical/Meta.cpp

    r632 r636  
    3434}
    3535
    36 void Meta::StaticLink( Meta &meta, long dataSectionBaseOffset, int sourceIndexBase )
     36void Meta::StaticLink( Meta &meta, long dataSectionBaseOffset, const std::vector<int> &relationTable )
    3737{
    3838    // 名前空間
     
    5353
    5454        pUserProc->GetNativeCode().ResetDataSectionBaseOffset( dataSectionBaseOffset );
    55         pUserProc->GetNativeCode().ResetSourceIndexes( sourceIndexBase );
     55        pUserProc->GetNativeCode().ResetSourceIndexes( relationTable );
    5656
    5757        this->userProcs.Put( pUserProc );
     
    7575        CClass *pClass = meta.GetClasses().Iterator_GetNext();
    7676        pClass->isTargetObjectModule = false;
     77        pClass->Readed();
    7778        this->GetClasses().Put( pClass );
    7879    }
  • trunk/ab5.0/abdev/ab_common/src/Lexical/NativeCode.cpp

    r603 r636  
    4545                sourceLine.GetLineNum(),
    4646                baseOffset + sourceLine.GetNativeCodePos(),
    47                 sourceLine.GetSourceIndex(),
     47                sourceLine.GetRelationalObjectModuleIndex(),    // TODO: 複数libの取り込みを想定できていない(ソースコード行番号とネイティブコード位置の対応情報の追加は静的リンクが完了した後に行うべき)
    4848                sourceLine.GetSourceCodePos(),
    4949                sourceLine.GetCodeType()
     
    152152    }
    153153}
    154 void NativeCode::ResetSourceIndexes( long sourceIndexBase )
     154void NativeCode::ResetSourceIndexes( const std::vector<int> &relationTable )
    155155{
    156156    BOOST_FOREACH( SourceLine &sourceLine, sourceLines )
    157157    {
    158         sourceLine.SetSourceIndex( sourceLine.GetSourceIndex() + sourceIndexBase );
     158        sourceLine.SetRelationalObjectModuleIndex( relationTable[sourceLine.GetRelationalObjectModuleIndex()] );
    159159    }
    160160}
  • trunk/ab5.0/abdev/ab_common/src/Lexical/ObjectModule.cpp

    r603 r636  
    5858void ObjectModule::StaticLink( ObjectModule &objectModule )
    5959{
     60    const std::vector<int> relationTable = this->GetRelationTable( objectModule.relationalObjectModuleNames );
     61
    6062    long dataSectionBaseOffset = dataTable.GetSize();
    61     int sourceIndexBase = (int)sources.size();
    6263
    6364    // メタ情報を結合
    64     meta.StaticLink( objectModule.meta, dataSectionBaseOffset, sourceIndexBase );
     65    meta.StaticLink( objectModule.meta, dataSectionBaseOffset, relationTable );
    6566
    6667    // グローバル ネイティブコードを結合
    6768    objectModule.globalNativeCode.ResetDataSectionBaseOffset( dataSectionBaseOffset );
    68     objectModule.globalNativeCode.ResetSourceIndexes( sourceIndexBase );
     69    objectModule.globalNativeCode.ResetSourceIndexes( relationTable );
    6970    globalNativeCode.PutEx( objectModule.globalNativeCode );
    7071
     
    7374    dataTable.Add( objectModule.dataTable );
    7475
    75     // ソースコードを結合
    76     BOOST_FOREACH( const BasicSource &source, objectModule.sources )
    77     {
    78         this->sources.push_back( source );
    79     }
    80 
    8176    // TODO: basbufがいらなくなったら消す
    8277    extern char *basbuf;
    83     basbuf = this->sources[0].GetBuffer();
     78    basbuf = this->source.GetBuffer();
     79}
     80
     81const std::vector<int> ObjectModule::GetRelationTable( const Jenga::Common::Strings &oldRelationalObjectModuleNames )
     82{
     83    // 要素 = 古いインデックス、値 = 新しいインデックス
     84    std::vector<int> relationTable;
     85
     86    // リレーションテーブルを構築
     87    BOOST_FOREACH( const std::string &oldRelationalObjectModuleName, oldRelationalObjectModuleNames )
     88    {
     89        bool isMatch = false;
     90        for( int i=0; i<static_cast<int>(this->relationalObjectModuleNames.size()); i++ )
     91        {
     92            if( oldRelationalObjectModuleName == this->relationalObjectModuleNames[i] )
     93            {
     94                isMatch = true;
     95                relationTable.push_back( i );
     96                break;
     97            }
     98        }
     99
     100        if( !isMatch )
     101        {
     102            // エラー
     103            _ASSERT( false );
     104        }
     105    }
     106
     107    return relationTable;
    84108}
    85109
  • trunk/ab5.0/abdev/compiler_x86/Compile_ProcOp.cpp

    r632 r636  
    328328    }
    329329
     330    char *backupBasbuf = NULL;
     331    int backupCurrentRelationalObjectModuleIndexForSource = compiler.GetCurrentRelationalObjectModuleIndexForSource();
     332
    330333    if( !pUserProc->IsAutoGeneration() )
    331334    {
     335        // テンプレート展開がされている場合、対象のソースコードが現在のオブジェクトモジュールではない場合がある
     336        if( compiler.staticLibraries[compiler.GetCurrentRelationalObjectModuleIndexForSource()]->GetName() != pUserProc->GetSourceCodePosition().GetObjectModuleName() )
     337        {
     338            for( int i=0; i<static_cast<int>(compiler.staticLibraries.size()); i++ )
     339            {
     340                const ObjectModule *pObjectModule = compiler.staticLibraries[i];
     341
     342                if( pObjectModule->GetName() == pUserProc->GetSourceCodePosition().GetObjectModuleName() )
     343                {
     344                    compiler.SetCurrentRelationalObjectModuleIndexForSource( i );
     345                    basbuf = const_cast<char *>(compiler.GetCurrentSource().GetBuffer());
     346                }
     347            }
     348        }
     349
    332350        cp=pUserProc->GetSourceCodePosition().GetPos();
    333351        for(;;cp++){
  • trunk/ab5.0/abdev/compiler_x86/MakePeHdr.cpp

    r632 r636  
    120120
    121121    // 静的リンク
     122    compiler.PreStaticLink( compiler.staticLibraries );
    122123    compiler.StaticLink( compiler.staticLibraries );
    123124
     
    144145    {
    145146        ActiveBasic::Compiler::LexicalAnalyzer::CollectEnums(
    146             compiler.GetObjectModule().GetCurrentSource().GetBuffer(),
     147            compiler.GetCurrentSource().GetBuffer(),
    147148            compiler.enumInfoCollection
    148149        );
     
    157158    // 名前空間情報を取得
    158159    ActiveBasic::Compiler::LexicalAnalyzer::CollectNamespaces(
    159         compiler.GetObjectModule().GetCurrentSource().GetBuffer(),
     160        compiler.GetCurrentSource().GetBuffer(),
    160161        compiler.GetObjectModule().meta.GetNamespaces()
    161162    );
     
    164165    {
    165166        ActiveBasic::Compiler::LexicalAnalyzer::CollectDelegates(
    166             compiler.GetObjectModule().GetCurrentSource().GetBuffer(),
     167            compiler.GetCurrentSource().GetBuffer(),
    167168            compiler.GetObjectModule().meta.GetDelegates()
    168169        );
     
    180181    //     ※オブジェクトの内容までは取得しない
    181182    ActiveBasic::Compiler::LexicalAnalyzer::CollectClassesForNameOnly(
    182         compiler.GetObjectModule().GetCurrentSource().GetBuffer(),
     183        compiler.GetCurrentSource().GetBuffer(),
    183184        compiler.GetObjectModule().meta.GetClasses()
    184185    );
     
    186187    //TypeDef情報を収集
    187188    ActiveBasic::Compiler::LexicalAnalyzer::CollectTypeDefs(
    188         compiler.GetObjectModule().GetCurrentSource().GetBuffer(),
     189        compiler.GetCurrentSource().GetBuffer(),
    189190        compiler.GetObjectModule().meta.GetTypeDefs()
    190191    );
     
    201202    //定数情報を取得
    202203    ActiveBasic::Compiler::LexicalAnalyzer::CollectConsts(
    203         compiler.GetObjectModule().GetCurrentSource().GetBuffer(),
     204        compiler.GetCurrentSource().GetBuffer(),
    204205        compiler.GetObjectModule().meta.GetGlobalConsts(),
    205206        compiler.GetObjectModule().meta.GetGlobalConstMacros()
     
    209210    compiler.SetCompilingClass( NULL );
    210211    ActiveBasic::Compiler::LexicalAnalyzer::CollectProcedures(
    211         compiler.GetObjectModule().GetCurrentSource().GetBuffer(),
     212        compiler.GetCurrentSource().GetBuffer(),
    212213        compiler.GetObjectModule().meta.GetUserProcs(),
    213214        compiler.GetObjectModule().meta.GetDllProcs()
     
    216217    // クラス情報を取得(※注 - CollectProceduresの後に呼び出す)
    217218    ActiveBasic::Compiler::LexicalAnalyzer::CollectClasses(
    218         compiler.GetObjectModule().GetCurrentSource().GetBuffer(),
     219        compiler.GetCurrentSource().GetBuffer(),
    219220        compiler.GetObjectModule().meta.GetClasses()
    220221    );
Note: See TracChangeset for help on using the changeset viewer.