Changeset 122 in dev


Ignore:
Timestamp:
May 13, 2007, 1:50:02 PM (17 years ago)
Author:
dai_9181
Message:

(呼び出し単体コードも対応→)関数の戻り値オブジェクトのメンバ・メソッドを一時オブジェクトを介さずに参照できるようにした。

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler32/Compile_Statement.cpp

    r88 r122  
    44void OpcodeOthers(char *Command){
    55    int i,i2;
    6     char buffer[8192];
    76    UserProc *pUserProc;
    87
     8    char leftTerm[8192];
     9    int lastParePos = 0;
    910    for(i=0;;i++){
    10         if(Command[i]=='['){
    11             i2=GetStringInBracket(buffer+i,Command+i);
     11        if(Command[i]=='\"'){
     12            //ダブルクォートは不正なのでエラー扱い
     13            leftTerm[i]=0;
     14            SetError(3,leftTerm,cp);
     15            return;
     16        }
     17
     18        if(Command[i]=='('){
     19            lastParePos = i;
     20            i2=GetStringInPare(leftTerm+i,Command+i);
    1221            i+=i2-1;
    1322            continue;
    1423        }
    15         if(Command[i]==1&&Command[i+1]==ESC_PSMEM){
    16             buffer[i]=Command[i];
    17             i++;
    18             buffer[i]=Command[i];
     24        if(Command[i]=='['){
     25            i2=GetStringInBracket(leftTerm+i,Command+i);
     26            i+=i2-1;
    1927            continue;
    2028        }
    21         if(!IsVariableChar(Command[i])){
    22             buffer[i]=0;
     29        if(Command[i]=='\0'){
     30            leftTerm[i] = 0;
    2331            break;
    2432        }
    25         buffer[i]=Command[i];
    26     }
    27 
     33
     34        if( IsNumCalcMark( Command, i ) ){
     35            leftTerm[i] = 0;
     36            break;
     37        }
     38
     39        leftTerm[i]=Command[i];
     40    }
    2841    if(!(
    29         IsVariableTopChar(buffer[0])||
    30         buffer[0]=='.'||
    31         (buffer[0]==1&&buffer[1]==ESC_PSMEM)
     42        IsVariableTopChar(leftTerm[0])||
     43        leftTerm[0]=='.'||
     44        (leftTerm[0]==1&&leftTerm[1]==ESC_PSMEM)
    3245        )){
    3346        SetError(1,NULL,cp);
     
    3649
    3750
    38     if(Command[i]=='\0'){
     51    if(Command[i]=='\0' && lastParePos == 0){
    3952        //////////////////////////////
    4053        // パラメータ無しのマクロ検索
     
    5871
    5972        if(pUserProc){
    60             if( !pUserProc->IsMacro() ) SetError(10,Command,cp);
     73            if( !pUserProc->IsMacro() ){
     74                SetError(10,Command,cp);
     75            }
    6176
    6277            Opcode_CallProc("",pUserProc,0,"",0);
     
    7186    }
    7287
    73     int idProc;
    74     void *pProc;
    75     idProc=GetProc(buffer,(void **)&pProc);
    76 
    77     int i4;
    78     char temp2[VN_SIZE];
    79     if(idProc){
    80         if(Command[i]!='('){
    81             SetError(10,buffer,cp);
    82             return;
    83         }
    84         i4=GetStringInPare_RemovePare(temp2,Command+i+1);
    85 
    86         //閉じカッコ")"に続く文字がNULLでないときはエラーにする
    87         if(Command[i+1+i4+1]!='\0') SetError(42,NULL,cp);
    88 
    89         ////////////////
    90         // 呼び出し
    91         ////////////////
    92 
    93         Type resultType;
    94         CallProc(idProc,pProc,buffer,temp2,resultType);
    95 
     88
     89    Type resultType;
     90    bool isLiteral;
     91    BOOL bUseHeap;
     92    bool result = TermOpe( leftTerm, Type(), resultType, isLiteral, &bUseHeap, NULL, true );
     93
     94    if( result ){
    9695
    9796        /////////////////////
     
    110109            FreeTempObject(REG_EBX,&resultType.GetClass());
    111110        }
     111
     112        //成功
    112113        return;
    113114    }
    114115
    115 
    116     //////////////////////////
    117     // その他は代入演算を行う
    118     //////////////////////////
    119     OpcodeCalc(Command);
     116    // 失敗
     117    SetError(1, NULL,cp);
    120118}
    121119
  • BasicCompiler32/NumOpe.cpp

    r117 r122  
    227227    return false;
    228228}
    229 bool TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, BOOL *pbUseHeap, bool *pIsClassName = NULL ){
     229bool TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, BOOL *pbUseHeap, bool *pIsClassName, bool isProcedureCallOnly ){
    230230    char parameter[VN_SIZE];
    231231
     
    293293
    294294
    295     if(lstrcmpi(termFull,"This")==0){
     295    if(lstrcmpi(termFull,"This")==0 && isProcedureCallOnly == false ){
    296296        //Thisオブジェクト
    297297        resultType.SetType( DEF_OBJECT, pobj_CompilingClass );
     
    387387            return true;
    388388        }
     389    }
     390    else if( isProcedureCallOnly ){
     391        // 関数呼び出し以外は受け付けない
     392        return false;
    389393    }
    390394
  • BasicCompiler32/Opcode.h

    r111 r122  
    102102//NumOpe.cpp
    103103void PushReturnValue(int type);
     104bool TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, BOOL *pbUseHeap, bool *pIsClassName = NULL, bool isProcedureCallOnly = false );
    104105bool NumOpe( int reg,
    105106            const char *expression,
  • BasicCompiler64/Compile_Statement.cpp

    r97 r122  
    44void OpcodeOthers(char *Command){
    55    int i,i2;
    6     char buffer[8192];
    76    UserProc *pUserProc;
    87
     8    char leftTerm[8192];
     9    int lastParePos = 0;
    910    for(i=0;;i++){
    10         if(Command[i]=='['){
    11             i2=GetStringInBracket(buffer+i,Command+i);
     11        if(Command[i]=='\"'){
     12            //ダブルクォートは不正なのでエラー扱い
     13            leftTerm[i]=0;
     14            SetError(3,leftTerm,cp);
     15            return;
     16        }
     17
     18        if(Command[i]=='('){
     19            lastParePos = i;
     20            i2=GetStringInPare(leftTerm+i,Command+i);
    1221            i+=i2-1;
    1322            continue;
    1423        }
    15         if(Command[i]==1&&Command[i+1]==ESC_PSMEM){
    16             buffer[i]=Command[i];
    17             i++;
    18             buffer[i]=Command[i];
     24        if(Command[i]=='['){
     25            i2=GetStringInBracket(leftTerm+i,Command+i);
     26            i+=i2-1;
    1927            continue;
    2028        }
    21         if(!IsVariableChar(Command[i])){
    22             buffer[i]=0;
     29        if(Command[i]=='\0'){
     30            leftTerm[i] = 0;
    2331            break;
    2432        }
    25         buffer[i]=Command[i];
    26     }
    27 
     33
     34        if( IsNumCalcMark( Command, i ) ){
     35            leftTerm[i] = 0;
     36            break;
     37        }
     38
     39        leftTerm[i]=Command[i];
     40    }
    2841    if(!(
    29         IsVariableTopChar(buffer[0])||
    30         buffer[0]=='.'||
    31         (buffer[0]==1&&buffer[1]==ESC_PSMEM)
     42        IsVariableTopChar(leftTerm[0])||
     43        leftTerm[0]=='.'||
     44        (leftTerm[0]==1&&leftTerm[1]==ESC_PSMEM)
    3245        )){
    3346        SetError(1,NULL,cp);
     
    3649
    3750
    38     if(Command[i]=='\0'){
     51    if(Command[i]=='\0' && lastParePos == 0){
    3952        //////////////////////////////
    4053        // パラメータ無しのマクロ検索
     
    7386    }
    7487
    75     int idProc;
    76     void *pProc;
    77     idProc=GetProc(buffer,(void **)&pProc);
    78 
    79     int i4;
    80     char temp2[VN_SIZE];
    81     if(idProc){
    82         if(Command[i]!='('){
    83             SetError(10,buffer,cp);
    84             return;
    85         }
    86         i4=GetStringInPare_RemovePare(temp2,Command+i+1);
    87 
    88         //閉じカッコ")"に続く文字がNULLでないときはエラーにする
    89         if(Command[i+1+i4+1]!='\0') SetError(42,NULL,cp);
    90 
    91         ////////////////
    92         // 呼び出し
    93         ////////////////
    94 
    95         Type resultType;
    96         CallProc(idProc,pProc,buffer,temp2,resultType);
    97 
     88    if( pobj_reg ){
     89        SetError();
     90    }
     91    pobj_reg=new CRegister(REG_RAX);
     92
     93    Type resultType;
     94    bool isLiteral;
     95    BOOL bUseHeap;
     96    bool result = TermOpe( leftTerm, Type(), resultType, isLiteral, &bUseHeap, NULL, true );
     97
     98    delete pobj_reg;
     99    pobj_reg = NULL;
     100
     101    if( result ){
    98102
    99103        /////////////////////
     
    107111            FreeTempObject(REG_R14,&resultType.GetClass());
    108112        }
    109         return;
    110     }
    111 
    112 
    113     //////////////////////////
    114     // その他は代入演算を行う
    115     //////////////////////////
    116     OpcodeCalc(Command);
     113
     114        //成功
     115        return;
     116    }
     117
     118    // 失敗
     119    SetError(1, NULL,cp);
    117120}
    118121
  • BasicCompiler64/NumOpe.cpp

    r117 r122  
    224224    return false;
    225225}
    226 bool TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, BOOL *pbUseHeap, bool *pIsClassName = NULL ){
     226bool TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, BOOL *pbUseHeap, bool *pIsClassName, bool isProcedureCallOnly ){
    227227    char parameter[VN_SIZE];
    228228
     
    290290
    291291
    292     if(lstrcmpi(termFull,"This")==0){
     292    if(lstrcmpi(termFull,"This")==0 && isProcedureCallOnly == false ){
    293293        //Thisオブジェクト
    294294        resultType.SetType( DEF_OBJECT, pobj_CompilingClass );
     
    386386            return true;
    387387        }
     388    }
     389    else if( isProcedureCallOnly ){
     390        // 関数呼び出し以外は受け付けない
     391        return false;
    388392    }
    389393
     
    775779                    //////////////////
    776780                    // 何らかの識別子
    777 
    778     if( (string)term=="ParentArea.NamespaceEnumTest.x"){
    779         int test=0;
    780     }
    781781
    782782                    bool isLiteral;
  • BasicCompiler64/Opcode.h

    r111 r122  
    251251
    252252//NumOpe.cpp
     253bool TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, BOOL *pbUseHeap, bool *pIsClassName = NULL, bool isProcedureCallOnly = false );
    253254bool NumOpe( int *pReg,
    254255           const char *Command,
     
    297298//increment.cpp
    298299void IncDec(int idCalc, char *lpszLeft, char *lpszRight);
    299 
    300 //calc2.cpp
    301 #define EXP_TYPE_NUMBER 1
    302 #define EXP_TYPE_EAX    2
    303 #define EXP_TYPE_FPU    3
    304 #define EXP_TYPE_VAR    4
    305 int NumOpEx(char *Command,double *pDbl,DWORD *pdwType,RELATIVE_VAR *pRelativeVar);
    306300
    307301//Compile_Calc_PushVar.cpp
Note: See TracChangeset for help on using the changeset viewer.