Ignore:
Timestamp:
Mar 6, 2008, 11:19:38 PM (16 years ago)
Author:
dai_9181
Message:

代入演算時の左辺に関数呼び出しの戻り値を評価してメンバを取得するようなコードが存在するとき、エラーになってしまっていたので改修した。(32bit版のみ対応)

File:
1 edited

Legend:

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

    r412 r415  
    140140    return true;
    141141}
    142 bool TermMemberOpe( const Type &leftType, const Type &baseType, Type &resultType, const char *termFull, const char *termLeft, const char *member )
     142bool TermMemberOpe( const Type &leftType, const Type &baseType, Type &resultType, const char *termFull, const char *termLeft, const char *member, bool &isVariable, RELATIVE_VAR &relativeVar )
    143143{
    144144    const CClass &objClass = leftType.GetClass();
     
    179179                compiler.codeGenerator.op_mov_RR( REG_ECX, useReg );
    180180
    181                 RELATIVE_VAR relativeVar;
    182                 relativeVar.dwKind=VAR_DIRECTMEM;
     181                RELATIVE_VAR tempRelativeVar;
     182                tempRelativeVar.dwKind=VAR_DIRECTMEM;
    183183
    184184                if( !_member_offset(
     
    186186                    false,  //読み込み専用
    187187                    leftType,
    188                     VarName,&relativeVar,classType,0)){
     188                    VarName,&tempRelativeVar,classType,0)){
    189189                        return false;
    190190                }
    191191
    192192                // オブジェクトメンバのポインタをeaxにコピー
    193                 if( !VarToReg( relativeVar, baseType, resultType ) ){
     193                if( !VarToReg( tempRelativeVar, baseType, resultType ) ){
    194194                    SetError(11,termFull,cp);
    195195                }
     
    225225        compiler.codeGenerator.op_mov_RR( REG_ECX, useReg );
    226226
    227         RELATIVE_VAR relativeVar;
    228227        relativeVar.dwKind=VAR_DIRECTMEM;
    229228
     
    236235        }
    237236
    238         if( !VarToReg( relativeVar, baseType, resultType ) ){
    239             SetError(11,termFull,cp);
    240         }
     237        // 変数として扱う
     238        isVariable = true;
    241239
    242240        return true;
     
    271269
    272270                // まずはプロパティ値を取得
    273                 TermMemberOpe( leftType, baseType, resultType, termFull, termLeft, methodName );
     271                bool dummyIsVariable;
     272                RELATIVE_VAR dummyRelativeVar;
     273                TermMemberOpe( leftType, baseType, resultType, termFull, termLeft, methodName, dummyIsVariable, dummyRelativeVar );
    274274
    275275                // 戻り値のオブジェクトインスタンスのインデクサを呼び出す
     
    278278                sprintf( temp2, "%s.%s", termLeft, methodName );
    279279                Type classType = resultType;
    280                 return TermMemberOpe( classType, baseType, resultType, termFull, temp2, temporary );
     280                return TermMemberOpe( classType, baseType, resultType, termFull, temp2, temporary, isVariable, relativeVar );
    281281            }
    282282
     
    324324    return false;
    325325}
    326 bool TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, BOOL *pbUseHeap, bool isWantObject, bool *pIsClassName, bool isProcedureCallOnly ){
     326bool _TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, BOOL *pbUseHeap, bool *pIsClassName, bool isProcedureCallOnly, bool &isVariable, RELATIVE_VAR &relativeVar, bool isWriteAccess )
     327{
    327328    char parameter[VN_SIZE];
    328329
     
    364365        }
    365366
    366         if( !TermOpe( termLeft, baseType, leftType, isLiteral, pbUseHeap, true, &isClassName ) ){
     367        if( !TermOpe( termLeft, baseType, leftType, isLiteral, pbUseHeap, &isClassName ) ){
    367368            goto globalArea;
    368369        }
     
    382383        }
    383384
    384         return TermMemberOpe( leftType, baseType, resultType, termFull, termLeft, member );
     385        return TermMemberOpe( leftType, baseType, resultType, termFull, termLeft, member, isVariable, relativeVar );
    385386    }
    386387globalArea:
     
    545546    ////////////////////////////////
    546547
    547     RELATIVE_VAR relativeVar;
    548548    if(GetVarOffset(
    549549        false,  //エラー表示なし
    550         false,  //読み込み専用
     550        isWriteAccess,
    551551        termFull,
    552552        &relativeVar,resultType)){
     
    555555        //////////
    556556
    557         if( !VarToReg( relativeVar, baseType, resultType ) ){
    558             SetError(11,termFull,cp);
    559         }
     557        // 変数として扱う
     558        isVariable = true;
    560559
    561560        isLiteral = false;
     
    610609
    611610    return false;
     611}
     612
     613bool TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, BOOL *pbUseHeap, bool *pIsClassName, bool isProcedureCallOnly, bool isWriteAccess )
     614{
     615    RELATIVE_VAR relativeVar;
     616    bool isVariable = false;
     617    bool result = _TermOpe( term, baseType, resultType, isLiteral, pbUseHeap, pIsClassName, isProcedureCallOnly, isVariable, relativeVar, isWriteAccess );
     618
     619    if( isVariable )
     620    {
     621        // 変数の場合はeaxに変数ポインタを格納する
     622        if( !VarToReg( relativeVar, baseType, resultType ) ){
     623            SetError(11,term,cp);
     624        }
     625    }
     626
     627    return result;
     628}
     629bool TermOpeOnlyVariable( const char *term, Type &resultType, RELATIVE_VAR &relativeVar, bool isWriteAccess )
     630{
     631    bool isLiteral, isVariable = false;
     632    bool result = _TermOpe( term, Type(), resultType, isLiteral, NULL, NULL, false, isVariable, relativeVar, isWriteAccess );
     633
     634    if( !isVariable )
     635    {
     636        SetError();
     637    }
     638
     639    return result;
    612640}
    613641
Note: See TracChangeset for help on using the changeset viewer.