Changeset 579 in dev


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

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

Location:
trunk/ab5.0/abdev
Files:
7 edited

Legend:

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

    r578 r579  
    534534        else
    535535        {
    536             ConstMacro *pConstMacro = compiler.GetObjectModule().meta.GetGlobalConstMacros().Find( procName );
     536            ConstMacro *pConstMacro = compiler.GetObjectModule().meta.GetGlobalConstMacros().Find(
     537                ActiveBasic::Compiler::LexicalAnalyzer::FullNameToSymbol( procName )
     538            );
    537539            if( pConstMacro )
    538540            {
     
    843845                    //////////////
    844846
    845                     i3 = compiler.GetObjectModule().meta.GetGlobalConsts().GetBasicType(term);
     847                    i3 = compiler.GetObjectModule().meta.GetGlobalConsts().GetBasicType(
     848                        ActiveBasic::Compiler::LexicalAnalyzer::FullNameToSymbol( term )
     849                    );
    846850                    if(i3){
    847                         if( compiler.GetObjectModule().meta.GetGlobalConsts().IsStringPtr( term ) ){
     851                        if( compiler.GetObjectModule().meta.GetGlobalConsts().IsStringPtr( ActiveBasic::Compiler::LexicalAnalyzer::FullNameToSymbol( term ) ) ){
    848852                            //リテラル文字列
    849853                            goto StrLiteral;
  • trunk/ab5.0/abdev/BasicCompiler_Common/VariableOpe.cpp

    r570 r579  
    10511051
    10521052        //定数と2重定義されていないる場合は抜け出す
    1053         if(compiler.GetObjectModule().meta.GetGlobalConsts().GetBasicType(VarName)){
     1053        if(compiler.GetObjectModule().meta.GetGlobalConsts().GetBasicType( ActiveBasic::Compiler::LexicalAnalyzer::FullNameToSymbol( VarName ) )){
    10541054            return;
    10551055        }
     
    10731073
    10741074    //定数と2重定義されていないかを調べる
    1075     if(compiler.GetObjectModule().meta.GetGlobalConsts().GetBasicType(VarName)){
     1075    if(compiler.GetObjectModule().meta.GetGlobalConsts().GetBasicType( ActiveBasic::Compiler::LexicalAnalyzer::FullNameToSymbol( VarName ) )){
    10761076        compiler.errorMessenger.Output(15,VarName,cp);
    10771077        return;
  • trunk/ab5.0/abdev/BasicCompiler_Common/calculation.cpp

    r578 r579  
    498498                        //定数関数
    499499
    500                         ConstMacro *pConstMacro = compiler.GetObjectModule().meta.GetGlobalConstMacros().Find( temporary );
     500                        ConstMacro *pConstMacro = compiler.GetObjectModule().meta.GetGlobalConstMacros().Find(
     501                            ActiveBasic::Compiler::LexicalAnalyzer::FullNameToSymbol( temporary )
     502                        );
    501503                        if( !pConstMacro )
    502504                        {
     
    663665                        /////////
    664666                        StrPtr[pnum]=0;
    665                         type[pnum] = compiler.GetObjectModule().meta.GetGlobalConsts().GetBasicType(Parms);
     667                        type[pnum] = compiler.GetObjectModule().meta.GetGlobalConsts().GetBasicType(
     668                            ActiveBasic::Compiler::LexicalAnalyzer::FullNameToSymbol( Parms )
     669                        );
    666670                        if(type[pnum]){
    667671                            if(IsRealNumberType(type[pnum])){
    668672                                //実数型
    669                                 nums[pnum] = compiler.GetObjectModule().meta.GetGlobalConsts().GetDoubleData(Parms);
     673                                nums[pnum] = compiler.GetObjectModule().meta.GetGlobalConsts().GetDoubleData(
     674                                    ActiveBasic::Compiler::LexicalAnalyzer::FullNameToSymbol( Parms )
     675                                );
    670676                            }
    671677                            else if(IsWholeNumberType(type[pnum])){
    672678                                //整数
    673                                 i64nums[pnum] = compiler.GetObjectModule().meta.GetGlobalConsts().GetWholeData(Parms);
     679                                i64nums[pnum] = compiler.GetObjectModule().meta.GetGlobalConsts().GetWholeData(
     680                                    ActiveBasic::Compiler::LexicalAnalyzer::FullNameToSymbol( Parms )
     681                                );
    674682                            }
    675683/*                          else if(type[pnum]==DEF_STRING){
     
    12231231
    12241232                    //定数
    1225                     ConstMacro *pConstMacro = compiler.GetObjectModule().meta.GetGlobalConstMacros().Find( temporary );
     1233                    ConstMacro *pConstMacro = compiler.GetObjectModule().meta.GetGlobalConstMacros().Find(
     1234                        ActiveBasic::Compiler::LexicalAnalyzer::FullNameToSymbol( temporary )
     1235                    );
    12261236                    if(pConstMacro){
    12271237                        //マクロ関数の場合
     
    12331243
    12341244                //定数
    1235                 i3 = compiler.GetObjectModule().meta.GetGlobalConsts().GetBasicType(Command+i2);
     1245                i3 = compiler.GetObjectModule().meta.GetGlobalConsts().GetBasicType(
     1246                    ActiveBasic::Compiler::LexicalAnalyzer::FullNameToSymbol( Command+i2 )
     1247                );
    12361248                if(i3==DEF_STRING) return 1;    //文字列
    12371249                if(i3) return 0;            //数値
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/Const.h

    r578 r579  
    7373
    7474private:
    75     CConst *GetObjectPtr( const std::string &name );
     75    CConst *GetObjectPtr( const Symbol &symbol );
    7676public:
    7777
    78     int GetBasicType(const char *Name);
    79     _int64 GetWholeData(const char *Name);
    80     double GetDoubleData(const char *Name);
    81     bool IsStringPtr(const char *Name);
     78    int GetBasicType( const Symbol &symbol );
     79    _int64 GetWholeData( const Symbol &symbol );
     80    double GetDoubleData( const Symbol &symbol );
     81    bool IsStringPtr( const Symbol &symbol );
    8282};
    8383
     
    142142
    143143public:
    144     void Add( const NamespaceScopes &namespaceScopes, const std::string &name, const char *parameterStr );
    145     ConstMacro *Find( const std::string &name );
     144    bool Add( const NamespaceScopes &namespaceScopes, const std::string &name, const char *parameterStr );
     145    ConstMacro *Find( const Symbol &name );
    146146};
  • 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
  • trunk/ab5.0/abdev/compiler_x86/NumOpe.cpp

    r578 r579  
    515515        }
    516516
    517         ConstMacro *pConstMacro = compiler.GetObjectModule().meta.GetGlobalConstMacros().Find( procName );
     517        ConstMacro *pConstMacro = compiler.GetObjectModule().meta.GetGlobalConstMacros().Find(
     518            ActiveBasic::Compiler::LexicalAnalyzer::FullNameToSymbol( procName )
     519        );
    518520        if( pConstMacro )
    519521        {
     
    10431045                    //////////////
    10441046
    1045                     i3 = compiler.GetObjectModule().meta.GetGlobalConsts().GetBasicType(term);
     1047                    i3 = compiler.GetObjectModule().meta.GetGlobalConsts().GetBasicType(
     1048                        ActiveBasic::Compiler::LexicalAnalyzer::FullNameToSymbol( term )
     1049                    );
    10461050                    if(i3){
    1047                         if( compiler.GetObjectModule().meta.GetGlobalConsts().IsStringPtr( term ) ){
     1051                        if( compiler.GetObjectModule().meta.GetGlobalConsts().IsStringPtr( ActiveBasic::Compiler::LexicalAnalyzer::FullNameToSymbol( term ) ) ){
    10481052                            //リテラル文字列
    10491053
     
    10631067                            }
    10641068
    1065                             double dbl = compiler.GetObjectModule().meta.GetGlobalConsts().GetDoubleData(term);
     1069                            double dbl = compiler.GetObjectModule().meta.GetGlobalConsts().GetDoubleData(
     1070                                ActiveBasic::Compiler::LexicalAnalyzer::FullNameToSymbol( term )
     1071                            );
    10661072                            memcpy(&i64data,&dbl,sizeof(double));
    10671073
     
    10771083                        if(IsRealNumberType(i3)){
    10781084                            //実数
    1079                             double dbl = compiler.GetObjectModule().meta.GetGlobalConsts().GetDoubleData(term);
     1085                            double dbl = compiler.GetObjectModule().meta.GetGlobalConsts().GetDoubleData(
     1086                                ActiveBasic::Compiler::LexicalAnalyzer::FullNameToSymbol( term )
     1087                            );
    10801088                            memcpy(&i64data,&dbl,sizeof(double));
    10811089                            goto Literal;
     
    10831091                        else if(IsWholeNumberType(i3)){
    10841092                            //整数
    1085                             i64data = compiler.GetObjectModule().meta.GetGlobalConsts().GetWholeData(term);
     1093                            i64data = compiler.GetObjectModule().meta.GetGlobalConsts().GetWholeData(
     1094                                ActiveBasic::Compiler::LexicalAnalyzer::FullNameToSymbol( term )
     1095                            );
    10861096                            goto Literal;
    10871097                        }
Note: See TracChangeset for help on using the changeset viewer.