Ignore:
Timestamp:
May 8, 2008, 3:27:32 PM (16 years ago)
Author:
dai_9181
Message:

Consts/ConstMacrosクラスのLexicalAnalyzerクラスへの依存性をなくした。

Location:
trunk/ab5.0/abdev/BasicCompiler_Common/src
Files:
2 edited

Legend:

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

    r578 r579  
    3636}
    3737
    38 CConst *Consts::GetObjectPtr( const std::string &name ){
    39     char ObjName[VN_SIZE];      //オブジェクト変数
    40     char NestMember[VN_SIZE];   //入れ子メンバ
    41     bool isObjectMember = SplitMemberName( name.c_str(), ObjName, NestMember );
    42 
    43     CConst *pConst = GetHashArrayElement( NestMember );
     38CConst *Consts::GetObjectPtr( const Symbol &symbol )
     39{
     40    CConst *pConst = GetHashArrayElement( symbol.GetName().c_str() );
    4441    while( pConst )
    4542    {
    46         if( pConst->IsEqualSymbol( LexicalAnalyzer::FullNameToSymbol( name ) ) )
     43        if( pConst->IsEqualSymbol( symbol ) )
    4744        {
    4845            break;
     
    5552
    5653
    57 int Consts::GetBasicType(const char *Name){
    58     CConst *pConst = GetObjectPtr(Name);
     54int Consts::GetBasicType( const Symbol &symbol ){
     55    CConst *pConst = GetObjectPtr( symbol );
    5956
    6057    if(!pConst) return 0;
     
    6259    return pConst->GetType().GetBasicType();
    6360}
    64 _int64 Consts::GetWholeData(const char *Name){
    65     CConst *pConst = GetObjectPtr(Name);
     61_int64 Consts::GetWholeData( const Symbol &symbol ){
     62    CConst *pConst = GetObjectPtr( symbol );
    6663
    6764    if(!pConst) return 0;
     
    6966    return pConst->GetWholeData();
    7067}
    71 double Consts::GetDoubleData(const char *Name){
    72     CConst *pConst = GetObjectPtr(Name);
     68double Consts::GetDoubleData( const Symbol &symbol ){
     69    CConst *pConst = GetObjectPtr( symbol );
    7370
    7471    if(!pConst) return 0;
     
    7673    return pConst->GetDoubleData();
    7774}
    78 bool Consts::IsStringPtr( const char *Name ){
    79     CConst *pConst = GetObjectPtr(Name);
     75bool Consts::IsStringPtr( const Symbol &symbol ){
     76    CConst *pConst = GetObjectPtr( symbol );
    8077
    8178    if(!pConst) return false;
     
    8784
    8885// マクロ定数を追加するための関数
    89 void ConstMacros::Add( const NamespaceScopes &namespaceScopes, const std::string &name, const char *parameterStr )
     86bool ConstMacros::Add( const NamespaceScopes &namespaceScopes, const std::string &name, const char *parameterStr )
    9087{
    9188    std::vector<std::string> parameters;
     
    9491    if(parameterStr[i]!='(')
    9592    {
    96         compiler.errorMessenger.OutputFatalError();
    97         return;
     93        return false;
    9894    }
    9995
     
    10197    int i2;
    10298    for(i++,i2=0;;i++,i2++){
    103         if(parameterStr[i]=='\0'){
    104             compiler.errorMessenger.Output(1,NULL,cp);
    105             return;
     99        if(parameterStr[i]=='\0')
     100        {
     101            return false;
    106102        }
    107103        if(parameterStr[i]==','||parameterStr[i]==')'){
     
    112108            if(parameterStr[i]==')'){
    113109                i++;
    114                 if(parameterStr[i]!='='){
    115                     extern int cp;
    116                     compiler.errorMessenger.Output(1,NULL,cp);
    117                     return;
     110                if(parameterStr[i]!='=')
     111                {
     112                    return false;
    118113                }
    119114                break;
     
    129124    lstrcpy(temporary,parameterStr+i+1);
    130125
    131     Put( new ConstMacro( namespaceScopes, name, parameters, temporary ) );
     126    this->Put( new ConstMacro( namespaceScopes, name, parameters, temporary ) );
     127
     128    return true;
    132129}
    133 ConstMacro *ConstMacros::Find( const std::string &name ){
    134     char ObjName[VN_SIZE];      //オブジェクト変数
    135     char NestMember[VN_SIZE];   //入れ子メンバ
    136     bool isObjectMember = SplitMemberName( name.c_str(), ObjName, NestMember );
    137 
    138     ConstMacro *pConstMacro = GetHashArrayElement( NestMember );
     130ConstMacro *ConstMacros::Find( const Symbol &symbol )
     131{
     132    ConstMacro *pConstMacro = GetHashArrayElement( symbol.GetName().c_str() );
    139133    while( pConstMacro )
    140134    {
    141         if( pConstMacro->IsEqualSymbol( LexicalAnalyzer::FullNameToSymbol( name ) ) )
     135        if( pConstMacro->IsEqualSymbol( symbol ) )
    142136        {
    143137            break;
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Const.cpp

    r578 r579  
    179179                    // 定数マクロ
    180180                    const char *params = temporary + i2;
    181                     constMacros.Add( namespaceScopes, name, params );
     181                    if( !constMacros.Add( namespaceScopes, name, params ) )
     182                    {
     183                        compiler.errorMessenger.Output( 1, NULL, i );
     184                    }
    182185                }
    183186
Note: See TracChangeset for help on using the changeset viewer.