Changeset 107 in dev for BasicCompiler_Common


Ignore:
Timestamp:
May 6, 2007, 3:17:56 PM (17 years ago)
Author:
dai_9181
Message:

Importsステートメントを導入した。実装は作り途中。

Location:
BasicCompiler_Common
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler_Common/BasicFixed.h

    r99 r107  
    178178#define ESC_NAMESPACE       'o'     // Namespace
    179179#define ESC_ENDNAMESPACE    'p'     // End Namespace
     180#define ESC_IMPORTS         'q'     // Imports
     181#define ESC_CLEARNAMESPACEIMPORTED 'r'  // _ClearNamespaceImported
    180182//EXEファイル用制御エスケープシーケンス
    181 #define ESC_USING           'q'     // Print命令語のUsing
    182 #define ESC_FOR             'r'     // Open命令語のFor
    183 #define ESC_LINENUM         's'     // 行番号を示す
     183#define ESC_USING           's'     // Print命令語のUsing
     184#define ESC_FOR             't'     // Open命令語のFor
     185#define ESC_LINENUM         'u'     // 行番号を示す
    184186
    185187//オブジェクト指向エスケープシーケンス
  • BasicCompiler_Common/Compile.cpp

    r103 r107  
    229229                }
    230230                Smoothie::Lexical::liveingNamespaceScopes.pop_back();
     231                break;
     232            case ESC_IMPORTS:
     233                Smoothie::Meta::importedNamespaces.Imports( Command + 2 );
     234                break;
     235            case ESC_CLEARNAMESPACEIMPORTED:
     236                Smoothie::Meta::importedNamespaces.clear();
    231237                break;
    232238
  • BasicCompiler_Common/Intermediate_Step1.cpp

    r99 r107  
    447447
    448448            switch(temporary[i3]){
     449                case '_':
     450                    if(lstrcmpi(temporary+i3,"_ClearNamespaceImported")==0){
     451                        i2=i3;
     452                        temporary[i2++]=1;
     453                        temporary[i2]=ESC_CLEARNAMESPACEIMPORTED;
     454                    }
     455                    break;
    449456                case 'a':
    450457                case 'A':
     
    755762                        temporary[i2++]=1;
    756763                        temporary[i2]=ESC_IF;
     764                    }
     765                    else if(lstrcmpi(temporary+i3,"Imports")==0){
     766                        i2=i3;
     767                        temporary[i2++]=1;
     768                        temporary[i2]=ESC_IMPORTS;
    757769                    }
    758770                    else if(lstrcmpi(temporary+i3,"Inherits")==0){
  • BasicCompiler_Common/Intermediate_Step2.cpp

    r103 r107  
    462462            case ESC_STATIC:
    463463            case ESC_NAMESPACE:
     464            case ESC_IMPORTS:
    464465                KillStringSpaces(Command+2);
    465466                break;
  • BasicCompiler_Common/common.h

    r100 r107  
    4747
    4848#ifdef _AMD64_
    49 #define VER_INFO        "(x64) β rev.217"
     49#define VER_INFO        "(x64) β rev.228"
    5050#else
    51 #define VER_INFO        "β rev.217"
     51#define VER_INFO        "β rev.228"
    5252#endif
    5353
     
    6161
    6262
    63 #pragma comment(lib, "psapi.lib")
    64 
    65 
    6663#define PTR_SIZE        sizeof(LONG_PTR)
    6764
     
    8481
    8582//未定義の定数情報
    86 #define IMAGE_FILE_MACHINE_AMD64 0x8664
    87 
     83#ifndef IMAGE_FILE_MACHINE_AMD64
     84    #define IMAGE_FILE_MACHINE_AMD64 0x8664
     85#endif
     86
     87#ifdef _AMD64_
     88    #ifndef IMAGE_SIZEOF_NT_OPTIONAL64_HEADER
     89        #define IMAGE_SIZEOF_NT_OPTIONAL64_HEADER    240
     90    #endif
     91#else
     92    #ifndef IMAGE_SIZEOF_NT_OPTIONAL32_HEADER
     93        #define IMAGE_SIZEOF_NT_OPTIONAL32_HEADER    224
     94    #endif
     95#endif
    8896
    8997
  • BasicCompiler_Common/error.cpp

    r103 r107  
    152152    if(num==62) sprintf(msg,"グローバル領域でのReturnは禁止されています。",tempKeyWord);
    153153    if(num==63) lstrcpy(msg,"名前空間が正しく閉じられていません。");
     154    if(num==64) sprintf(msg,"\"%s\" 無効な名前空間です。",tempKeyWord);
    154155
    155156
  • BasicCompiler_Common/include/Namespace.h

    r105 r107  
    7070    }
    7171
    72     bool IsUsing() const
    73     {
    74         // TODO: 実装
    75         return false;
    76     }
     72    bool IsImported() const;
    7773
    7874    bool IsLiving() const;
     
    9894            if( baseNamespaceScopes.size() ){
    9995                // 名前空間の判断が必要なとき
    100                 if( baseNamespaceScopes.IsUsing()
     96                if( baseNamespaceScopes.IsImported()
    10197                    || baseNamespaceScopes.IsLiving() ){
    10298                    // Using指定があるとき
     
    134130    void SplitNamespace( const char *fullName, char *namespaceStr, char *simpleName ) const;
    135131
     132    void Imports( const string &namespaceStr );
     133
    136134    static bool CollectNamespaces( const char *source, NamespaceScopesCollection &namespaceScopesCollection );
    137135};
  • BasicCompiler_Common/include/Smoothie.h

    r105 r107  
    1919#endif
    2020        }
    21         static void Put( const string &text ){
    22 #ifdef _DEBUG
    23             log += text + "\r\n";
    24 
    25             {
    26                 ofstream ofs( ( (string)BasicSystemDir + "Log\\compile.log" ).c_str(), ios_base::app );
    27                 ofs << text << endl;
    28                 ofs.close();
    29             }
    30 #endif
    31         }
     21        static void Put( const string &text );
    3222        static void PutFile( const string &fileName, const string &buffer ){
    3323            ofstream ofs( ( (string)BasicSystemDir + "Log\\" + fileName ).c_str() );
     
    4939        static vector<ProcPointer *> procPointers;
    5040        static NamespaceScopesCollection namespaceScopesCollection;
     41        static NamespaceScopesCollection importedNamespaces;
    5142    };
    5243};
  • BasicCompiler_Common/src/Namespace.cpp

    r105 r107  
    2121}
    2222
     23bool NamespaceScopes::IsImported() const
     24{
     25    BOOST_FOREACH( const NamespaceScopes &namespaceScopes, Smoothie::Meta::importedNamespaces ){
     26        if( this->IsEqual( namespaceScopes ) ){
     27            return true;
     28        }
     29    }
     30    return false;
     31}
    2332bool NamespaceScopes::IsLiving() const
    2433{
     
    9099    lstrcpy( simpleName, fullName + lstrlen( namespaceStr ) + dotLength );
    91100}
     101void NamespaceScopesCollection::Imports( const string &namespaceStr ){
     102    NamespaceScopes namespaceScopes( namespaceStr );
     103    if( !Smoothie::Meta::namespaceScopesCollection.IsExist( namespaceScopes ) ){
     104        SetError(64,namespaceStr.c_str(),cp );
     105        return;
     106    }
     107
     108    this->push_back( namespaceScopes );
     109}
    92110bool NamespaceScopesCollection::CollectNamespaces( const char *source, NamespaceScopesCollection &namespaceScopesCollection )
    93111{
  • BasicCompiler_Common/src/Smoothie.cpp

    r105 r107  
    22
    33string Smoothie::Logger::log = "";
     4
     5void Smoothie::Logger::Put( const string &text )
     6{
     7//#ifdef _DEBUG
     8    log += text + "\r\n";
     9
     10    {
     11        ofstream ofs( ( (string)BasicSystemDir + "Log\\compile.log" ).c_str(), ios_base::app );
     12        ofs << text << endl;
     13        ofs.close();
     14    }
     15//#endif
     16}
    417
    518BasicSource Smoothie::Lexical::source;
     
    922vector<ProcPointer *> Smoothie::Meta::procPointers;
    1023NamespaceScopesCollection Smoothie::Meta::namespaceScopesCollection;
     24NamespaceScopesCollection Smoothie::Meta::importedNamespaces;
Note: See TracChangeset for help on using the changeset viewer.