Ignore:
Timestamp:
May 4, 2008, 9:36:46 PM (16 years ago)
Author:
dai_9181
Message:

LexicalAnalyzerのソースコードの記述位置を整理。

File:
1 edited

Legend:

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

    r536 r546  
    1313
    1414using namespace ActiveBasic::Compiler;
     15
     16
     17void LexicalAnalyzer::CollectClassesForNameOnly( const char *source, Classes &classes )
     18{
     19    int i, i2;
     20    char temporary[VN_SIZE];
     21
     22    // 名前空間管理
     23    NamespaceScopes &namespaceScopes = compiler.GetNamespaceSupporter().GetLivingNamespaceScopes();
     24    namespaceScopes.clear();
     25
     26    // Importsされた名前空間の管理
     27    NamespaceScopesCollection &importedNamespaces = compiler.GetNamespaceSupporter().GetImportedNamespaces();
     28    importedNamespaces.clear();
     29
     30    for(i=0;;i++){
     31        if(source[i]=='\0') break;
     32
     33        if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){
     34            for(i+=2,i2=0;;i2++,i++){
     35                if( IsCommandDelimitation( source[i] ) ){
     36                    temporary[i2]=0;
     37                    break;
     38                }
     39                temporary[i2]=source[i];
     40            }
     41            namespaceScopes.push_back( temporary );
     42
     43            continue;
     44        }
     45        else if( source[i] == 1 && source[i+1] == ESC_ENDNAMESPACE ){
     46            if( namespaceScopes.size() <= 0 ){
     47                compiler.errorMessenger.Output(12, "End Namespace", i );
     48            }
     49            else{
     50                namespaceScopes.pop_back();
     51            }
     52
     53            i += 2;
     54            continue;
     55        }
     56        else if( source[i] == 1 && source[i+1] == ESC_IMPORTS ){
     57            for(i+=2,i2=0;;i2++,i++){
     58                if( IsCommandDelimitation( source[i] ) ){
     59                    temporary[i2]=0;
     60                    break;
     61                }
     62                temporary[i2]=source[i];
     63            }
     64            if( !compiler.GetNamespaceSupporter().ImportsNamespace( temporary ) )
     65            {
     66                compiler.errorMessenger.Output(64,temporary,i );
     67            }
     68
     69            continue;
     70        }
     71        else if( source[i] == 1 && source[i+1] == ESC_CLEARNAMESPACEIMPORTED ){
     72            importedNamespaces.clear();
     73            continue;
     74        }
     75
     76        if(source[i]==1&&(
     77            source[i+1]==ESC_CLASS||
     78            source[i+1]==ESC_TYPE||
     79            source[i+1]==ESC_INTERFACE
     80            ))
     81        {
     82            int nowLine = i;
     83            i += 2;
     84
     85            Type blittableType;
     86            if(memicmp(source+i,"Align(",6)==0){
     87                //アラインメント修飾子
     88                i+=6;
     89                i=JumpStringInPare(source,i)+1;
     90            }
     91            else if( memicmp( source + i, "Blittable(", 10 ) == 0 ){
     92                // Blittable修飾子
     93                i+=10;
     94                i+=GetStringInPare_RemovePare(temporary,source+i)+1;
     95                compiler.StringToType( temporary, blittableType );
     96            }
     97
     98            bool isEnum = false;
     99            bool isDelegate = false;
     100            if( source[i] == 1 && source[i+1] == ESC_ENUM ){
     101                // 列挙型の場合
     102                isEnum = true;
     103
     104                i += 2;
     105            }
     106            else if( source[i] == 1 && source[i+1] == ESC_DELEGATE )
     107            {
     108                // デリゲートの場合
     109                isDelegate = true;
     110
     111                i += 2;
     112            }
     113
     114            for(i2=0;;i++,i2++){
     115                if(!IsVariableChar(source[i])){
     116                    temporary[i2]=0;
     117                    break;
     118                }
     119                temporary[i2]=source[i];
     120            }
     121
     122            //クラスを追加
     123            CClass *pClass = classes.Add(namespaceScopes, importedNamespaces, temporary,nowLine);
     124            if( pClass ){
     125                if( source[nowLine+1] == ESC_CLASS ){
     126                    if( isEnum )
     127                    {
     128                        pClass->SetClassType( CClass::Enum );
     129                    }
     130                    else if( isDelegate )
     131                    {
     132                        pClass->SetClassType( CClass::Delegate );
     133                    }
     134                    else{
     135                        pClass->SetClassType( CClass::Class );
     136                    }
     137                }
     138                else if( source[nowLine+1] == ESC_INTERFACE ){
     139                    pClass->SetClassType( CClass::Interface );
     140                }
     141                else{
     142                    pClass->SetClassType( CClass::Structure );
     143                }
     144            }
     145
     146            // Blittable型の場合
     147            if( !blittableType.IsNull() ){
     148                pClass->SetBlittableType( blittableType );
     149
     150                // Blittable型として登録
     151                compiler.GetObjectModule().meta.GetBlittableTypes().push_back( BlittableType( blittableType, pClass ) );
     152            }
     153        }
     154    }
     155}
    15156
    16157
Note: See TracChangeset for help on using the changeset viewer.