Changeset 565 in dev


Ignore:
Timestamp:
May 5, 2008, 2:48:41 PM (16 years ago)
Author:
dai_9181
Message:

・ProcedureGeneratorクラスを追加。
・「InitStaticMember、Compile_System_InitializeUserTypes、Compile_System_InitializeUserTypesForBaseType」これらのメソッドをProcedureGeneratorクラスに移動。

Location:
trunk/ab5.0/abdev
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/Class.h

    r564 r565  
    497497    CClass *Add( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine);
    498498
    499     virtual void InitStaticMember();
    500 
    501     virtual void Compile_System_InitializeUserTypes();
    502     virtual void Compile_System_InitializeUserTypesForBaseType();
    503 
    504499    const CClass *Find( const NamespaceScopes &namespaceScopes, const std::string &name ) const;
    505500    const CClass *Find( const std::string &fullName ) const;
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/Class.cpp

    r564 r565  
    648648}
    649649
    650 
    651 void Classes::InitStaticMember(){
    652     //静的メンバをグローバル領域に作成
    653 
    654     //イテレータをリセット
    655 
    656     extern int cp;
    657     int back_cp=cp;
    658 
    659     this->Iterator_Reset();
    660     while(this->Iterator_HasNext()){
    661         CClass &objClass = *this->Iterator_GetNext();
    662         if( objClass.isTargetObjectModule == false )
    663         {
    664             // 静的リンクライブラリの場合は飛ばす(既にインスタンスが定義済みであるため)
    665             continue;
    666         }
    667 
    668         // 名前空間をセット
    669         compiler.GetNamespaceSupporter().GetLivingNamespaceScopes() = objClass.GetNamespaceScopes();
    670 
    671         DWORD dwFlags = 0;
    672         if( objClass.GetName() == "_System_TypeBase" )
    673         {
    674             // _System_TypeBaseクラスはグローバル、スタティック領域を初期化するためのクラスなのでここでの初期化は除外する
    675             dwFlags |= DIMFLAG_NONCALL_CONSTRACTOR;
    676         }
    677 
    678         // コンパイル中クラスとしてセット
    679         compiler.SetCompilingClass( &objClass );
    680 
    681         const EnumInfo *pEnumInfo = NULL;
    682         if( objClass.IsEnum() )
    683         {
    684             pEnumInfo = compiler.enumInfoCollection.Find( objClass );
    685         }
    686 
    687         int i=0;
    688         BOOST_FOREACH( Member *member, objClass.GetStaticMembers() )
    689         {
    690             if( pEnumInfo )
    691             {
    692                 cp = pEnumInfo->GetEnumMember( member->GetName() ).GetSourceIndex();
    693             }
    694 
    695             char temporary[VN_SIZE];
    696             sprintf(temporary,"%s.%s",objClass.GetName().c_str(),member->GetName().c_str());
    697             dim(
    698                 temporary,
    699                 member->GetSubscripts(),
    700                 member->GetType(),
    701                 member->GetInitializeExpression().c_str(),
    702                 member->GetConstructParameter().c_str(),
    703                 dwFlags);
    704 
    705             i++;
    706         }
    707 
    708         compiler.SetCompilingClass( NULL );
    709     }
    710 
    711     compiler.GetNamespaceSupporter().GetLivingNamespaceScopes().clear();
    712 
    713     cp=back_cp;
    714 }
    715 
    716 void Classes::Compile_System_InitializeUserTypes(){
    717     char temporary[VN_SIZE];
    718 
    719     ////////////////////////////////////////////////////////////////////
    720     // クラス登録
    721     ////////////////////////////////////////////////////////////////////
    722 
    723     // イテレータをリセット
    724     Iterator_Reset();
    725 
    726     while( Iterator_HasNext() ){
    727         const CClass &objClass = *Iterator_GetNext();
    728 
    729         if( !objClass.IsUsing() ){
    730             // 未使用のクラスは無視する
    731             continue;
    732         }
    733 
    734         std::string referenceOffsetsBuffer;
    735         int numOfReference = 0;
    736         objClass.GetReferenceOffsetsInitializeBuffer( referenceOffsetsBuffer, numOfReference );
    737 
    738         sprintf( temporary
    739             , "Add(%c%c_System_TypeForClass[strNamespace=\"%s\",name=\"%s\",fullName=\"%s\",referenceOffsets=[%s],numOfReference=%d])"
    740             , 1
    741             , ESC_SYSTEM_STATIC_NEW
    742             , objClass.GetNamespaceScopes().ToString().c_str()      // 名前空間
    743             , objClass.GetName().c_str()                            // クラス名
    744             , objClass.GetFullName().c_str()                        // フルネーム
    745             , referenceOffsetsBuffer.c_str()                        // 参照メンバオフセット配列
    746             , numOfReference                                        // 参照メンバの個数
    747             );
    748 
    749         // コンパイル
    750         ChangeOpcode( temporary );
    751 
    752         objClass.SetTypeInfoDataTableOffset(
    753             compiler.GetObjectModule().dataTable.GetLastMadeConstObjectDataTableOffset()
    754         );
    755     }
    756 }
    757 void Classes::Compile_System_InitializeUserTypesForBaseType()
    758 {
    759     extern int cp;
    760     cp = -1;
    761     ////////////////////////////////////////////////////////////////////
    762     // 基底クラスを登録
    763     ////////////////////////////////////////////////////////////////////
    764 
    765     char temporary[8192];
    766     sprintf(temporary, "%c%ctempType=Nothing%c%c_System_TypeForClass"
    767         , HIBYTE( COM_DIM )
    768         , LOBYTE( COM_DIM )
    769         , 1
    770         , ESC_AS
    771         );
    772     ChangeOpcode( temporary );
    773 
    774     // イテレータをリセット
    775     Iterator_Reset();
    776 
    777     while( Iterator_HasNext() ){
    778         const CClass &objClass = *Iterator_GetNext();
    779 
    780         if( !objClass.IsUsing() ){
    781             // 未使用のクラスは無視する
    782             continue;
    783         }
    784 
    785         if( objClass.HasSuperClass() || objClass.GetDynamicMembers().size() ){
    786             sprintf( temporary
    787                 , "tempType=Search(\"%s\") As ActiveBasic.Core._System_TypeForClass"
    788                 , objClass.GetFullName().c_str()
    789             );
    790 
    791             // コンパイル
    792             MakeMiddleCode( temporary );
    793             ChangeOpcode( temporary );
    794 
    795             sprintf( temporary
    796                 , "tempType.SetClassInfo(%d,_System_GetComVtbl(%s),_System_GetVtblList(%s),_System_GetDefaultConstructor(%s),_System_GetDestructor(%s))"
    797                 , objClass.GetSize()
    798                 , objClass.GetFullName().c_str()
    799                 , objClass.GetFullName().c_str()
    800                 , objClass.GetFullName().c_str()
    801                 , objClass.GetFullName().c_str()
    802                 , objClass.GetName().c_str()
    803             );
    804 
    805             // コンパイル
    806             ChangeOpcode( temporary );
    807 
    808             if( objClass.HasSuperClass() )
    809             {
    810                 sprintf( temporary
    811                     , "tempType.SetBaseType(Search(\"%s\"))"
    812                     , objClass.GetSuperClass().GetFullName().c_str()
    813                 );
    814 
    815                 // コンパイル
    816                 ChangeOpcode( temporary );
    817             }
    818 
    819             if( objClass.GetDynamicMembers().size() )
    820             {
    821                 // メンバの型を示すTypeInfoオブジェクトへのDataOffset配列の静的データ定義文字列を取得
    822                 sprintf(
    823                     temporary,
    824                     "tempType.SetMembers([%s],[%s],[%s],%d)",
    825                     objClass.GetStaticDefiningStringAsMemberNames().c_str(),
    826                     objClass.GetStaticDefiningStringAsMemberTypeInfoNames().c_str(),
    827                     objClass.GetStaticDefiningStringAsMemberOffsets().c_str(),
    828                     objClass.GetDynamicMembers().size()
    829                 );
    830                 ChangeOpcode( temporary );
    831             }
    832         }
    833     }
    834 }
    835 
    836650const CClass *Classes::Find( const NamespaceScopes &namespaceScopes, const std::string &name ) const
    837651{
  • trunk/ab5.0/abdev/compiler_x86/Compile_ProcOp.cpp

    r541 r565  
    5353
    5454        //クラスに属する静的メンバを定義
    55         compiler.GetObjectModule().meta.GetClasses().InitStaticMember();
     55        ActiveBasic::Compiler::ProcedureGenerator::Generate_InitStaticMember(
     56            compiler.GetObjectModule().meta.GetClasses()
     57        );
    5658
    5759        GetGlobalDataForDll();
     
    202204    if( userProc.GetName() == "InitializeUserTypes"
    203205        && userProc.HasParentClass()
    204         && userProc.GetParentClass().GetName() == "_System_TypeBase" ){
    205 
    206             compiler.GetObjectModule().meta.GetClasses().Compile_System_InitializeUserTypes();
     206        && userProc.GetParentClass().GetName() == "_System_TypeBase" )
     207    {
     208        ActiveBasic::Compiler::ProcedureGenerator::Generate_System_InitializeUserTypes(
     209            compiler.GetObjectModule().meta.GetClasses()
     210        );
    207211    }
    208212    else if( userProc.GetName() == "InitializeUserTypesForBaseType"
     
    210214        && userProc.GetParentClass().GetName() == "_System_TypeBase" )
    211215    {
    212         compiler.GetObjectModule().meta.GetClasses().Compile_System_InitializeUserTypesForBaseType();
     216        ActiveBasic::Compiler::ProcedureGenerator::Generate_System_InitializeUserTypesForBaseType(
     217            compiler.GetObjectModule().meta.GetClasses()
     218        );
    213219    }
    214220    else if( userProc.GetName() == "RegisterGlobalRoots"
     
    232238
    233239        //クラスに属する静的メンバを定義
    234         compiler.GetObjectModule().meta.GetClasses().InitStaticMember();
     240        ActiveBasic::Compiler::ProcedureGenerator::Generate_InitStaticMember(
     241            compiler.GetObjectModule().meta.GetClasses()
     242        );
    235243
    236244        //グローバル実行領域をコンパイル開始
  • trunk/ab5.0/abdev/compiler_x86/compiler_x86.vcproj

    r559 r565  
    12891289                </File>
    12901290                <File
     1291                    RelativePath="..\BasicCompiler_Common\src\ProcedureGenerator.cpp"
     1292                    >
     1293                </File>
     1294                <File
    12911295                    RelativePath="..\BasicCompiler_Common\src\VtblGenerator.cpp"
    12921296                    >
     
    14861490                </File>
    14871491                <File
     1492                    RelativePath="..\BasicCompiler_Common\include\ProcedureGenerator.h"
     1493                    >
     1494                </File>
     1495                <File
    14881496                    RelativePath="..\BasicCompiler_Common\include\VtblGenerator.h"
    14891497                    >
  • trunk/ab5.0/abdev/compiler_x86/stdafx.h

    r559 r565  
    7272#include <LexicalAnalyzer.h>
    7373#include <VtblGenerator.h>
     74#include <ProcedureGenerator.h>
Note: See TracChangeset for help on using the changeset viewer.