Changeset 628 in dev for trunk


Ignore:
Timestamp:
May 29, 2008, 1:36:02 AM (16 years ago)
Author:
dai_9181
Message:

ジェネリクス型の型解決ができない場合のエラーメッセージを実装した。

Location:
trunk/ab5.0/abdev
Files:
1 added
8 edited

Legend:

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

    r603 r628  
    849849        }
    850850
    851         if( !compiler.StringToType( temporary, type ) ){
    852             compiler.errorMessenger.Output(3,temporary,cp);
     851        ActiveBasic::Compiler::Error::StringToTypeErrorCode::EnumType result = compiler.StringToTypeEx( temporary, type, true );
     852        if( result != ActiveBasic::Compiler::Error::StringToTypeErrorCode::Successful )
     853        {
     854            if( result == ActiveBasic::Compiler::Error::StringToTypeErrorCode::FailedResolveGenericType )
     855            {
     856                compiler.errorMessenger.Output(143,temporary,cp);
     857            }
     858            else
     859            {
     860                compiler.errorMessenger.Output(3,temporary,cp);
     861            }
    853862            return false;
    854863        }
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/Compiler.h

    r622 r628  
    184184
    185185
     186    ActiveBasic::Compiler::Error::StringToTypeErrorCode::EnumType StringToTypeEx( const std::string &typeName, Type &type, bool isResolveGenerics = false );
    186187    bool StringToType( const std::string &typeName, Type &type );
    187188    const std::string TypeToString( const Type &type );
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/Compiler.cpp

    r603 r628  
    1414}
    1515
    16 bool Compiler::StringToType( const std::string &typeName, Type &type ){
     16ActiveBasic::Compiler::Error::StringToTypeErrorCode::EnumType Compiler::StringToTypeEx( const std::string &typeName, Type &type, bool isResolveGenerics )
     17{
    1718    type.SetIndex( -1 );
    1819
     
    3536        if( !pGenericClass )
    3637        {
    37             return false;
     38            return ActiveBasic::Compiler::Error::StringToTypeErrorCode::NotfoundGenericClass;
    3839        }
    3940
     
    7071        type.SetActualGenericTypes( genericTypes );
    7172
    72         return true;
     73        return ActiveBasic::Compiler::Error::StringToTypeErrorCode::Successful;
    7374    }
    7475
     
    102103            type.SetBasicType( DEF_PTR_PROC );
    103104            type.SetIndex( this->GetObjectModule().meta.GetProcPointers().size() - 1 );
    104             return true;
     105            return ActiveBasic::Compiler::Error::StringToTypeErrorCode::Successful;
    105106        }
    106107
    107108        const std::string &nextTypeName = typeName.substr( 1 );
    108109
    109         if( !StringToType( nextTypeName, type ) ){
    110             return false;
     110        ActiveBasic::Compiler::Error::StringToTypeErrorCode::EnumType result = StringToTypeEx( nextTypeName, type, isResolveGenerics );
     111        if( result != ActiveBasic::Compiler::Error::StringToTypeErrorCode::Successful )
     112        {
     113            return result;
    111114        }
    112115
    113116        type.PtrLevelUp();
    114117
    115         return true;
     118        return ActiveBasic::Compiler::Error::StringToTypeErrorCode::Successful;
    116119    }
    117120
    118121    {
    119122        int basicType;
    120         if( Type::StringToBasicType( typeName, basicType ) ){
     123        if( Type::StringToBasicType( typeName, basicType ) )
     124        {
    121125            // 基本型だったとき
    122126            type.SetBasicType( basicType );
    123             return true;
     127            return ActiveBasic::Compiler::Error::StringToTypeErrorCode::Successful;
    124128        }
    125129    }
    126130
    127131    // Object型だったとき
    128     if( typeName == "Object" ){
     132    if( typeName == "Object" )
     133    {
    129134        type.SetType( DEF_OBJECT, this->GetObjectModule().meta.GetClasses().GetObjectClassPtr() );
    130         return true;
     135        return ActiveBasic::Compiler::Error::StringToTypeErrorCode::Successful;
    131136    }
    132137
    133138    // String型だったとき
    134     if( typeName == "String" ){
     139    if( typeName == "String" )
     140    {
    135141        type.SetType( DEF_OBJECT, this->GetObjectModule().meta.GetClasses().GetStringClassPtr() );
    136         return true;
     142        return ActiveBasic::Compiler::Error::StringToTypeErrorCode::Successful;
    137143    }
    138144
     
    142148    ////////////////////
    143149    int i=this->GetObjectModule().meta.GetTypeDefs().GetIndex( LexicalAnalyzer::FullNameToSymbol( typeName ) );
    144     if(i!=-1){
     150    if(i!=-1)
     151    {
    145152        type = this->GetObjectModule().meta.GetTypeDefs()[i].GetBaseType();
    146         return true;
     153        return ActiveBasic::Compiler::Error::StringToTypeErrorCode::Successful;
    147154    }
    148155
    149156    //クラス
    150157    const CClass *pobj_c = this->GetObjectModule().meta.GetClasses().FindEx( LexicalAnalyzer::FullNameToSymbol( typeName ) );
    151     if(pobj_c){
    152         if( pobj_c->IsStructure() ){
     158    if(pobj_c)
     159    {
     160        if( isResolveGenerics )
     161        {
     162            if( pobj_c->IsGeneric() )
     163            {
     164                // ジェネリッククラスの場合
     165                trace( "型解決されていない" );
     166                return ActiveBasic::Compiler::Error::StringToTypeErrorCode::FailedResolveGenericType;
     167            }
     168        }
     169
     170        if( pobj_c->IsStructure() )
     171        {
    153172            type.SetBasicType( DEF_STRUCT );
    154173        }
    155         else{
     174        else
     175        {
    156176            type.SetBasicType( DEF_OBJECT );
    157177        }
    158178        type.SetClassPtr( pobj_c );
    159         return true;
     179        return ActiveBasic::Compiler::Error::StringToTypeErrorCode::Successful;
    160180    }
    161181
     
    176196            type.SetFormalTypeName( typeName );
    177197            type.SetFormalTypeIndex( formalTypeIndex );
    178             return true;
     198            return ActiveBasic::Compiler::Error::StringToTypeErrorCode::Successful;
    179199        }
    180200    }
     
    183203    /////////////////////////////////////////////////////////
    184204
    185     return false;
     205    return ActiveBasic::Compiler::Error::StringToTypeErrorCode::NotfoundType;
     206}
     207
     208bool Compiler::StringToType( const std::string &typeName, Type &type )
     209{
     210    return ( StringToTypeEx( typeName, type, false ) == ActiveBasic::Compiler::Error::StringToTypeErrorCode::Successful );
    186211}
    187212
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/Messenger.cpp

    r587 r628  
    7676        for( int i3=0; ; i3++ )
    7777        {
    78             if( !IsVariableChar( tempKeyWord[i3] ) || tempKeyWord[i3] == '.' )
     78            if( !IsVariableChar( tempKeyWord[i3] ) )
    7979            {
    8080                temporary[i3] = 0;
     
    249249    if(errorCode==141) lstrcpy(msg,"Blittable修飾子をクラス以外の型に指定することはできません。");
    250250    if(errorCode==142) lstrcpy(msg,"不正なThis参照です。");
     251    if(errorCode==143) sprintf(msg,"\"%s\" ジェネリクス型に型パラメータが指定されていません。",tempKeyWord);
    251252
    252253    //Enum関連
  • trunk/ab5.0/abdev/compiler_x64/compiler_x64.vcproj

    r627 r628  
    326326                </File>
    327327                <File
     328                    RelativePath="..\BasicCompiler_Common\include\ErrorCode.h"
     329                    >
     330                </File>
     331                <File
    328332                    RelativePath="..\BasicCompiler_Common\include\LexicalAnalyzer.h"
    329333                    >
  • trunk/ab5.0/abdev/compiler_x64/stdafx.h

    r603 r628  
    4848#include <CodeGenerator.h>
    4949#include <Messenger.h>
     50#include <ErrorCode.h>
    5051#include <Linker.h>
    5152#include <Compiler.h>
  • trunk/ab5.0/abdev/compiler_x86/compiler_x86.vcproj

    r622 r628  
    13821382                </File>
    13831383                <File
     1384                    RelativePath="..\BasicCompiler_Common\include\ErrorCode.h"
     1385                    >
     1386                </File>
     1387                <File
    13841388                    RelativePath="..\BasicCompiler_Common\include\LexicalAnalyzer.h"
    13851389                    >
  • trunk/ab5.0/abdev/compiler_x86/stdafx.h

    r603 r628  
    4848#include <CodeGenerator.h>
    4949#include <Messenger.h>
     50#include <ErrorCode.h>
    5051#include <Linker.h>
    5152#include <Compiler.h>
Note: See TracChangeset for help on using the changeset viewer.