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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.