Changeset 422 in dev for trunk


Ignore:
Timestamp:
Mar 8, 2008, 10:38:39 PM (16 years ago)
Author:
dai_9181
Message:

デリゲートのパラメータや戻り値にクラス型を指定できない不具合を修正。

Location:
trunk/abdev
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/abdev/BasicCompiler32/MakePeHdr.cpp

    r415 r422  
    178178    //TypeDef情報を初期化
    179179    compiler.GetObjectModule().meta.GetTypeDefs().CollectTypeDefs();
     180
     181    /*
     182    デリゲートのパラメータを再取得
     183    クラス/TypeDefなどの型名前情報がすべて揃ってからでないと
     184    型情報に依存するパラメータ情報を取得できないため、ここでの再取得が必要
     185    */
     186    compiler.GetObjectModule().meta.GetDelegates().RefleshParameterAndReturnType();
    180187
    181188    //定数情報を取得
  • trunk/abdev/BasicCompiler_Common/include/Delegate.h

    r339 r422  
    44#include <Procedure.h>
    55
    6 class Delegate : public Procedure, public Jenga::Common::ObjectInHashmap<Delegate>
     6class Delegates;
     7
     8class Delegate
     9    : public Procedure
     10    , public Jenga::Common::ObjectInHashmap<Delegate>
    711{
     12    friend Delegates;
     13
     14    std::string paramStr;
     15    std::string returnTypeName;
     16    int sourceIndex;
     17
    818    Parameters dynamicParams;
    919
     20    // XMLシリアライズ用
     21private:
     22    friend class boost::serialization::access;
     23    template<class Archive> void serialize(Archive& ar, const unsigned int version)
     24    {
     25        trace_for_serialize( "serializing - Delegate" );
     26
     27        ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Procedure );
     28        ar & BOOST_SERIALIZATION_NVP( dynamicParams );
     29    }
     30
    1031public:
    11     Delegate( const NamespaceScopes &namespaceScopes, const std::string &name, Procedure::Kind procKind, const char *paramStr, const Type &returnType, int nowLine );
     32    Delegate( const NamespaceScopes &namespaceScopes, const std::string &name, Procedure::Kind procKind, const char *paramStr, const std::string &returnTypeName, int sourceIndex )
     33        : Procedure( namespaceScopes, name, procKind, false )
     34        , paramStr( paramStr )
     35        , returnTypeName( returnTypeName )
     36        , sourceIndex( sourceIndex )
     37    {
     38    }
    1239    Delegate()
    1340    {
    1441    }
     42
     43    void RefleshParameterAndReturnType();
    1544
    1645    virtual const std::string &GetKeyName() const
     
    3059    void Collect( const BasicSource &source );
    3160    void GenerateSourceCode( std::string &destSource );
     61    void RefleshParameterAndReturnType();
    3262};
  • trunk/abdev/BasicCompiler_Common/src/Delegate.cpp

    r339 r422  
    33#include <Delegate.h>
    44
    5 Delegate::Delegate( const NamespaceScopes &namespaceScopes, const std::string &name, Procedure::Kind procKind, const char *paramStr, const Type &returnType, int nowLine )
    6     : Procedure( namespaceScopes, name, procKind, false )
    7 {
    8     this->returnType = returnType;
    9     params.Analyze( paramStr, nowLine );
    10 
     5void Delegate::RefleshParameterAndReturnType()
     6{
     7    // パラメータを解析
     8    params.Analyze( paramStr.c_str(), sourceIndex );
     9
     10    // 動的パラメータを作る
    1111    dynamicParams = params;
    1212    dynamicParams.insert( dynamicParams.begin(), new Parameter( "_System_LocalThis", Type( DEF_PTR_VOID ) ) );
     13
     14    if( IsFunction() )
     15    {
     16        // 戻り値を取得
     17        if( !compiler.StringToType( returnTypeName, returnType ) )
     18        {
     19            SetError(3,returnTypeName,sourceIndex);
     20        }
     21    }
    1322}
    1423
     
    93102            GetIdentifierToken( name, source.GetBuffer(), i );
    94103
     104            if( source[i] != '(' )
     105            {
     106                SetError(1,NULL,nowLine);
     107                continue;
     108            }
     109
     110            // パラメータ文字列
    95111            char paramStr[8192];
    96             i += GetStringInPare( paramStr, source.GetBuffer() + i );
    97 
    98             // 戻り値
    99             Type returnType;
     112            i += GetStringInPare( paramStr, source.GetBuffer() + i, true );
     113
     114            // 戻り値の型の文字列
     115            char returnTypeName[VN_SIZE] = "";
    100116            if( source[i] == 1 && source[i+1] == ESC_AS )
    101117            {
    102118                i += 2;
    103                 char typeName[VN_SIZE];
    104                 GetCommandToken( typeName, source.GetBuffer(), i );
    105                 compiler.StringToType( typeName, returnType );
    106             }
    107 
    108             this->Put( new Delegate( namespaceScopes, name, procKind, paramStr, returnType, nowLine ) );
     119                GetCommandToken( returnTypeName, source.GetBuffer(), i );
     120
     121                if( procKind != Procedure::Function )
     122                {
     123                    SetError(38,name,nowLine);
     124                }
     125            }
     126            else
     127            {
     128                if( procKind == Procedure::Function )
     129                {
     130                    SetError(-104,name,nowLine);
     131                    lstrcpy( returnTypeName, "Double" );
     132                }
     133            }
     134
     135            this->Put( new Delegate( namespaceScopes, name, procKind, paramStr, returnTypeName, nowLine ) );
    109136        }
    110137    }
     
    156183        values.insert( std::map<std::string,std::string>::value_type( "#name#", dg.GetName() ) );
    157184
    158         std::string paramsStr = dg.Params().GetString();
    159 
    160185        if( dg.IsFunction() )
    161186        {
    162187            values.insert( std::map<std::string,std::string>::value_type(
    163188                "#call_method_begin#",
    164                 (string)"Function Call(" + paramsStr + ") As " + compiler.TypeToString( dg.ReturnType() )
     189                (string)"Function Call(" + dg.paramStr + ") As " + dg.returnTypeName
    165190            ) );
    166191
     
    176201            values.insert( std::map<std::string,std::string>::value_type(
    177202                "#call_method_begin#",
    178                 (string)"Sub Call(" + paramsStr + ")"
     203                (string)"Sub Call(" + dg.paramStr + ")"
    179204            ) );
    180205
     
    187212        }
    188213
    189         values.insert( std::map<std::string,std::string>::value_type( "#params#", paramsStr ) );
     214        values.insert( std::map<std::string,std::string>::value_type( "#params#", dg.paramStr ) );
    190215
    191216        destSource += sourceTemplate.GetResult( values );
     
    197222    */
    198223}
     224
     225void Delegates::RefleshParameterAndReturnType()
     226{
     227    this->Iterator_Reset();
     228    while( this->Iterator_HasNext() )
     229    {
     230        Delegate &dg = *this->Iterator_GetNext();
     231        dg.RefleshParameterAndReturnType();
     232    }
     233}
  • trunk/abdev/BasicCompiler_Common/src/Parameter.cpp

    r383 r422  
    8585    //パラメータ
    8686    int i = 0;
    87     if(sourceOfParams[i]!='('){
    88         SetError(1,NULL,nowLine);
    89         return 0;
    90     }
    91     i++;
    9287    while(1){
    93         if(sourceOfParams[i]==')') break;
     88        if( sourceOfParams[i] == '\0' )
     89        {
     90            break;
     91        }
    9492
    9593        //ByRef
     
    222220        this->push_back( pParam );
    223221
    224         if(sourceOfParams[i]==','){
     222        if( sourceOfParams[i] == ',' )
     223        {
    225224            i++;
    226225            continue;
    227226        }
    228         else if(sourceOfParams[i]==')') continue;
     227        else if( sourceOfParams[i] == '\0' )
     228        {
     229            break;
     230        }
    229231        else{
    230232            SetError(1,NULL,nowLine);
Note: See TracChangeset for help on using the changeset viewer.