Changeset 381 in dev


Ignore:
Timestamp:
Dec 19, 2007, 3:31:03 AM (16 years ago)
Author:
dai_9181
Message:

Foreach文のパラメータをInで区切るようにした。

Location:
trunk/abdev
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/abdev/BasicCompiler32/Compile_Statement.cpp

    r380 r381  
    596596{
    597597    Type resultType;
    598     int i;
    599     char temporary[VN_SIZE],collectionVar[VN_SIZE];
     598    char temporary[VN_SIZE],variable[VN_SIZE],collectionVar[VN_SIZE];
    600599    bool isError = false;
    601600
     601    //レキシカルスコープをレベルアップ
     602    compiler.codeGenerator.lexicalScopes.Start( compiler.codeGenerator.GetNativeCodeSize(), LexicalScope::SCOPE_TYPE_FOR );
     603
    602604    //第1パラメータを取得
    603     char variable[VN_SIZE];
    604     i=GetOneParameter(Parameter,0,variable);
     605    int i = 0;
     606    GetCustomToken( variable, Parameter, i, ESC_IN, true );
    605607    if(!Parameter[i]){
    606608        SetError(12,"Foreach",cp);
     
    608610        goto ErrorStep;
    609611    }
     612    i++;
    610613
    611614    //第2パラメータを取得(in~)
    612     i=GetOneParameter(Parameter,i,collectionVar);
    613 
    614     //レキシカルスコープをレベルアップ
    615     compiler.codeGenerator.lexicalScopes.Start( compiler.codeGenerator.GetNativeCodeSize(), LexicalScope::SCOPE_TYPE_FOR );
     615    lstrcpy( collectionVar, Parameter + i );
    616616
    617617    if( !GetVarType( variable, resultType, false ) )
     
    651651    const PertialSchedule *pTempPertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(long), true );
    652652
    653     // Currentプロパティから現在の値を取得
    654     sprintf( temporary, "%s=%s.Current", variable, collectionVar );
    655     Compile( temporary );
     653    if( !isError )
     654    {
     655        // Currentプロパティから現在の値を取得
     656        sprintf( temporary, "%s=%s.Current", variable, collectionVar );
     657        Compile( temporary );
     658    }
    656659
    657660    //For内をコンパイル
     
    666669    }
    667670
    668     //jmp ...
    669     compiler.codeGenerator.op_jmp_continue();
     671    if( !isError )
     672    {
     673        //jmp ...
     674        compiler.codeGenerator.op_jmp_continue();
     675    }
    670676
    671677    //レキシカルスコープをレベルダウン
  • trunk/abdev/BasicCompiler64/Compile_Statement.cpp

    r380 r381  
    473473{
    474474    Type resultType;
    475     int i;
    476475    char temporary[VN_SIZE],variable[VN_SIZE],collectionVar[VN_SIZE];
    477476    bool isError = false;
    478477
     478    //レキシカルスコープをレベルアップ
     479    compiler.codeGenerator.lexicalScopes.Start( compiler.codeGenerator.GetNativeCodeSize(), LexicalScope::SCOPE_TYPE_FOR );
     480
    479481    //第1パラメータを取得
    480     i=GetOneParameter(Parameter,0,temporary);
     482    int i = 0;
     483    GetCustomToken( variable, Parameter, i, ESC_IN, true );
    481484    if(!Parameter[i]){
    482485        SetError(12,"Foreach",cp);
     
    484487        goto ErrorStep;
    485488    }
    486 
    487     lstrcpy( variable, temporary );
     489    i++;
    488490
    489491    //第2パラメータを取得(in~)
    490     i=GetOneParameter(Parameter,i,collectionVar);
    491 
    492     //レキシカルスコープをレベルアップ
    493     compiler.codeGenerator.lexicalScopes.Start( compiler.codeGenerator.GetNativeCodeSize(), LexicalScope::SCOPE_TYPE_FOR );
     492    lstrcpy( collectionVar, Parameter + i );
    494493
    495494    if( !GetVarType( variable, resultType, false ) )
     
    527526    const PertialSchedule *pTempPertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(long), true );
    528527
    529     // Currentプロパティから現在の値を取得
    530     sprintf( temporary, "%s=%s.Current", variable, collectionVar );
    531     Compile( temporary );
     528    if( !isError )
     529    {
     530        // Currentプロパティから現在の値を取得
     531        sprintf( temporary, "%s=%s.Current", variable, collectionVar );
     532        Compile( temporary );
     533    }
    532534
    533535    //For内をコンパイル
     
    542544    }
    543545
    544     //jmp ...
    545     compiler.codeGenerator.op_jmp_continue();
     546    if( !isError )
     547    {
     548        //jmp ...
     549        compiler.codeGenerator.op_jmp_continue();
     550    }
    546551
    547552    //レキシカルスコープをレベルダウン
  • trunk/abdev/BasicCompiler_Common/Compile.cpp

    r372 r381  
    4949        }
    5050        token[i] = source[pos];
     51    }
     52}
     53void GetCustomToken( char *token, const char *source, int &pos, char delimitation, bool isEscapeSequence )
     54{
     55    for( int i=0; ; i++, pos++ ){
     56        if( isEscapeSequence )
     57        {
     58            if( source[pos] == 1 && source[pos+1] == delimitation )
     59            {
     60                token[i] = 0;
     61                pos++;
     62                break;
     63            }
     64        }
     65        else
     66        {
     67            if( source[pos] == delimitation )
     68            {
     69                token[i] = 0;
     70                break;
     71            }
     72        }
     73
     74        token[i] = source[pos];
     75
     76        if( source[pos] == '\0' )
     77        {
     78            break;
     79        }
    5180    }
    5281}
  • trunk/abdev/BasicCompiler_Common/Intermediate_Step2.cpp

    r372 r381  
    451451        ComNum=COM_FOR;
    452452    }
    453     else if(lstrcmpi(com,"Foreach")==0){
    454         KillSpaces(Command+i,pam);
     453    else if(lstrcmpi(com,"Foreach")==0)
     454    {
     455        for(i2=0,IsStr=0;;i++,i2++)
     456        {
     457            while(Command[i]==' '||Command[i]=='\t') i++;
     458            if(Command[i]=='\"') IsStr^=1;
     459            if((Command[i-1]==' '||Command[i-1]=='\t')&&(Command[i]=='i'||Command[i]=='I')&&(Command[i+1]=='n'||Command[i+1]=='N')&&(Command[i+2]==' '||Command[i+2]=='\t')&&IsStr==0){
     460                pam[i2++] = 1;
     461                pam[i2] = ESC_IN;
     462                break;
     463            }
     464            pam[i2]=Command[i];
     465            if(Command[i]=='\0') break;
     466        }
     467        if(Command[i])
     468        {
     469            lstrcpy( pam + i2 + 1, Command + i + 3 );
     470        }
    455471        ComNum=COM_FOREACH;
    456472    }
  • trunk/abdev/BasicCompiler_Common/common.h

    r350 r381  
    377377void GetIdentifierToken( char *token, const char *source, int &pos );
    378378void GetCommandToken( char *token, const char *source, int &pos );
     379void GetCustomToken( char *token, const char *source, int &pos, char delimitation, bool isEscapeSequence );
    379380void SplitGenericClassInstance( const char *fullName, char *className, Jenga::Common::Strings &typeParameters );
    380381int JumpStatement(const char *source, int &pos);
  • trunk/abdev/ProjectEditor/SubOperation.cpp

    r380 r381  
    524524        if(lstrcmpi(str,"Imports")==0) return -1;
    525525        if(lstrcmpi(str,"Implements")==0) return -1;
     526        if(lstrcmpi(str,"In")==0) return -1;
    526527        if(lstrcmpi(str,"Inherits")==0) return COM_INHERITS;
    527528        if(lstrcmpi(str,"Input")==0) return COM_INPUT;
     
    580581        if(lstrcmpi(str,"Sleep")==0) return COM_SLEEP;
    581582        if(lstrcmp(str,"Static")==0) return -1;
     583        if(lstrcmpi(str,"Step")==0) return -1;
    582584        if(lstrcmp(str,"String")==0) return -1;
    583585        if(lstrcmpi(str,"Sub")==0) return COM_SUB;
     
    588590        if(lstrcmpi(str,"This")==0) return -1;
    589591        if(lstrcmpi(str,"Throw")==0) return -1;
     592        if(lstrcmpi(str,"To")==0) return -1;
    590593        if(lstrcmp(str,"True")==0) return -1;
    591594        if(lstrcmp(str,"Try")==0) return COM_TRY;
Note: See TracChangeset for help on using the changeset viewer.