Changeset 97 in dev


Ignore:
Timestamp:
Apr 16, 2007, 3:52:40 AM (17 years ago)
Author:
dai_9181
Message:

関数の戻り値オブジェクトのメンバ・メソッドを一時オブジェクトを介さずに参照できるようにした。

Files:
31 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler32/Compile_Calc_PushVar.cpp

    r66 r97  
    6565    }
    6666}
    67 void SetReg_WholeVariable(int type,RELATIVE_VAR *pRelativeVar,int reg){
     67void SetReg_WholeVariable(int type,RELATIVE_VAR *pRelativeVar,int reg, bool is64Head){
    6868    int varSize;
    6969
     
    8181
    8282        //上位32ビットをedxにロード
    83         pRelativeVar->offset+=sizeof(long);
    84         SetReg_WholeVariable(DEF_LONG,pRelativeVar,REG_EDX);
    85         pRelativeVar->offset-=sizeof(long);
     83        SetReg_WholeVariable(DEF_LONG,pRelativeVar,REG_EDX, true);
    8684
    8785        return;
    8886    }
    8987
     88    int offsetOf64Head = 0;
     89    if( is64Head ){
     90        offsetOf64Head = sizeof(long);
     91    }
     92
    9093    if(pRelativeVar->dwKind==VAR_GLOBAL){
    9194        if(pRelativeVar->bOffsetOffset){
    9295            //mov reg, ptr[ecx+offset]
    93             op_mov_RM(varSize,reg,REG_ECX,(int)pRelativeVar->offset,MOD_BASE_DISP32);
     96            op_mov_RM(varSize,reg,REG_ECX,(int)pRelativeVar->offset + offsetOf64Head,MOD_BASE_DISP32);
    9497        }
    9598        else{
    9699            //mov reg, ptr[offset]
    97             op_mov_RM(varSize,reg,0,(int)pRelativeVar->offset,MOD_DISP32);
     100            op_mov_RM(varSize,reg,0,(int)pRelativeVar->offset + offsetOf64Head,MOD_DISP32);
    98101        }
    99102        obp-=sizeof(long);
     
    119122        if(pRelativeVar->bOffsetOffset){
    120123            //mov reg, ptr[ebp+ecx+offset]
    121             op_mov_RM_ex(varSize,reg,REG_EBP,REG_ECX,(int)pRelativeVar->offset,USE_OFFSET);
     124            op_mov_RM_ex(varSize,reg,REG_EBP,REG_ECX,(int)pRelativeVar->offset + offsetOf64Head,USE_OFFSET);
    122125        }
    123126        else{
    124127            //mov reg, ptr[ebp+offset]
    125             op_mov_RM(varSize,reg,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32);
     128            op_mov_RM(varSize,reg,REG_EBP,(int)pRelativeVar->offset + offsetOf64Head,MOD_BASE_DISP32);
    126129        }
    127130        obp-=sizeof(long);
     
    146149    else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
    147150directmem:
    148         //mov reg, ptr[ecx]
    149         op_mov_RM(varSize,reg,REG_ECX,0,MOD_BASE);
     151        if( is64Head ){
     152            //mov reg, ptr[ecx]
     153            op_mov_RM(varSize,reg,REG_ECX,offsetOf64Head,MOD_BASE_DISP8);
     154        }
     155        else{
     156            //mov reg, ptr[ecx]
     157            op_mov_RM(varSize,reg,REG_ECX,0,MOD_BASE);
     158        }
    150159    }
    151160}
  • BasicCompiler32/Compile_CallProc.cpp

    r77 r97  
    116116    if( pUserProc->GetParentClassPtr() ){
    117117        //クラスのメンバ関数を呼び出す場合はアクセスチェックを行う
    118         if(ObjectName[0]){
     118        if(ObjectName[0] && (dwFlags&PROCFLAG_NEW)==0){
    119119            if(lstrcmpi(ObjectName,"Super")==0){
    120120                //クラスメンバ関数内から基底クラスの呼び出し
     
    272272        //////////////////////////////////////////////////////
    273273
    274         if(ObjectName[0]){
     274        if(ObjectName[0] && (dwFlags&PROCFLAG_NEW)==0){
    275275            if(lstrcmpi(ObjectName,"Super")==0) goto InClassMember;
    276276            else{
  • BasicCompiler32/Compile_Func.cpp

    r88 r97  
    205205    }
    206206
    207     if( type.IsStringObject() ){
     207    if( type.IsStringClass() ){
    208208        //Stringオブジェクトの場合
    209209        sprintf(temporary,"%s.Length",tempParm);
  • BasicCompiler32/Compile_Var.cpp

    r96 r97  
    336336
    337337    return true;
    338 }
    339 void GetWithName(char *buffer){
    340     extern WITHINFO WithInfo;
    341     int i;
    342 
    343     buffer[0]=0;
    344     for(i=0;i<WithInfo.num;i++)
    345         lstrcat(buffer,WithInfo.ppName[i]);
    346338}
    347339
     
    836828    }
    837829    else if( type.IsLong() || type.IsDWord() || type.IsPointer() ){
    838         if(type.GetBasicType()==typeOfPtrChar&&calcType.GetIndex()==LITERAL_STRING){
     830        if(type.GetBasicType()==typeOfPtrChar){
    839831            //文字列定数のとき
    840832
     
    10221014    }
    10231015    else if( type.IsDWord() || type.IsLong() || type.IsPointer() ){
    1024         if(type.GetBasicType()==typeOfPtrChar&&calcType.GetIndex()==LITERAL_STRING){
     1016        if(type.GetBasicType()==typeOfPtrChar){
    10251017            //文字列定数のとき
    10261018
     
    13071299    }
    13081300}
     1301void SetVarPtrToReg(int reg,RELATIVE_VAR *pRelativeVar){
     1302    if( reg != REG_EAX ){
     1303        SetError();
     1304        //TODO: 未完成
     1305    }
     1306    SetVarPtrToEax( pRelativeVar );
     1307}
    13091308
    13101309bool Compile_AddGlobalRootsForGc(){
  • BasicCompiler32/NumOpe.cpp

    r94 r97  
    8383}
    8484
    85 
     85void ExtendRegToBigType( int reg, int bigBasicType, int baseBasicType ){
     86    if( reg != REG_EAX ){
     87        SetError();
     88    }
     89    switch( Type::GetBasicSize( bigBasicType ) ){
     90        case sizeof(_int64):
     91            ExtendTypeTo64(baseBasicType);
     92            break;
     93        case sizeof(long):
     94            ExtendTypeTo32(baseBasicType,reg);
     95            break;
     96        case sizeof(short):
     97            ExtendTypeTo16(baseBasicType,reg);
     98            break;
     99    }
     100}
     101
     102
     103
     104bool VarToReg( RELATIVE_VAR &relativeVar, const Type &baseType, Type &resultType ){
     105    const int useReg = REG_EAX;
     106
     107    //大きな型への暗黙の変換
     108    int bigType = AutoBigCast(baseType.GetBasicType(),resultType.GetBasicType());
     109
     110    if(resultType.GetBasicType()&FLAG_PTR){
     111        //配列ポインタ
     112        resultType.SetBasicType( GetPtrType(resultType.GetBasicType()^FLAG_PTR) );
     113
     114        SetVarPtrToReg(useReg, &relativeVar);
     115    }
     116    else if( resultType.IsStruct() ){
     117        //構造体ポインタをeaxへ格納(構造体は値型)
     118        SetVarPtrToReg(useReg, &relativeVar);
     119    }
     120    else if( resultType.IsReal() ){
     121        // 実数
     122        SetReg_RealVariable( resultType.GetBasicType(), &relativeVar );
     123    }
     124    else if( resultType.IsWhole() || resultType.IsObject()){
     125        //整数型
     126        SetReg_WholeVariable(resultType.GetBasicType(),&relativeVar,useReg);
     127    }
     128    else if( resultType.IsStruct() ){
     129        //構造体ポインタをUseRegへ格納(構造体は値型)
     130        SetVarPtrToReg(useReg,&relativeVar);
     131    }
     132    else{
     133        return false;
     134    }
     135
     136    if( resultType.GetBasicType() != bigType ){
     137        // 大きな型へ変換された場合
     138        // ※レジスタの値をキャストする
     139        ExtendRegToBigType( useReg, bigType, resultType.GetBasicType() );
     140
     141        resultType.SetBasicType( bigType );
     142    }
     143
     144    return true;
     145}
     146bool TermMemberOpe( const CClass &objClass, const Type &baseType, Type &resultType, const char *termFull, const char *termLeft, const char *member ){
     147    const int useReg = REG_EAX;
     148
     149    if( GetMemberType( objClass, member, resultType, 0, false ) ){
     150        // メンバが見つかったとき
     151
     152        //オブジェクトポインタをecxにコピー
     153        op_mov_RR( REG_ECX, useReg );
     154
     155        RELATIVE_VAR relativeVar;
     156        relativeVar.dwKind=VAR_DIRECTMEM;
     157
     158        if( !_member_offset(
     159            true,   //エラー表示あり
     160            false,  //読み込み専用
     161            objClass,
     162            member,&relativeVar,resultType,0)){
     163                return false;
     164        }
     165
     166        if( !VarToReg( relativeVar, baseType, resultType ) ){
     167            SetError(11,termFull,cp);
     168        }
     169
     170        return true;
     171    }
     172
     173
     174    ///////////////////////////////////////////////////////////////////
     175    // 動的メソッドを検索
     176    ///////////////////////////////////////////////////////////////////
     177    vector<UserProc *> userProcs;
     178
     179    char methodName[VN_SIZE], lpPtrOffset[VN_SIZE], parameter[VN_SIZE], dummy[1];
     180    CClass::RefType refType;
     181    lstrcpy( methodName, member );
     182    GetVarFormatString(methodName,parameter,lpPtrOffset,dummy,refType);
     183
     184    objClass.EnumMethod( methodName, userProcs );
     185    UserProc *pUserProc;
     186    if(userProcs.size()){
     187        //オーバーロードを解決
     188        pUserProc=OverloadSolutionWithStrParam(termFull,userProcs,parameter,termLeft);
     189
     190        if( pUserProc ){
     191
     192            resultType = pUserProc->ReturnType();
     193
     194            {
     195                //オブジェクトポインタをスタックに入れておく
     196                //push reg
     197                op_push( useReg );
     198
     199                if( !Opcode_CallProc(parameter,pUserProc,PROCFLAG_NEW,termLeft,0 ) ){
     200
     201                    return false;
     202                }
     203
     204                op_pop();
     205
     206                /////////////////////
     207                // 戻り値の処理
     208                /////////////////////
     209
     210                //大きな型への暗黙の変換
     211                int bigType = AutoBigCast(baseType.GetBasicType(), resultType.GetBasicType() );
     212
     213                if( resultType.GetBasicType() != bigType ){
     214                    // 大きな型へ変換された場合
     215                    // ※レジスタの値をキャストする
     216                    ExtendRegToBigType( REG_EAX, bigType, resultType.GetBasicType() );
     217
     218                    resultType.SetBasicType( bigType );
     219                }
     220
     221                //SetUseRegFromRax(resultType.GetBasicType(),UseReg,XmmReg);
     222            }
     223           
     224            return true;
     225        }
     226    }
     227
     228    return false;
     229}
     230bool TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, BOOL *pbUseHeap, bool *pIsClassName = NULL ){
     231    char parameter[VN_SIZE];
     232
     233    // Withを解決
     234    char termFull[VN_SIZE];
     235    if(term[0]=='.'){
     236        GetWithName(termFull);
     237        lstrcat(termFull,term);
     238    }
     239    else lstrcpy(termFull,term);
     240
     241    char termLeft[VN_SIZE];
     242    lstrcpy(termLeft,termFull);
     243
     244    // パース
     245    char member[VN_SIZE];
     246    CClass::RefType refType;
     247    if( SplitMemberName( termFull, termLeft, member, refType ) ){
     248        ///////////////////////////////////////////////////////////////////
     249        // オブジェクトとメンバに分解できるとき
     250        // termLeft.member
     251        ///////////////////////////////////////////////////////////////////
     252
     253        isLiteral = false;
     254
     255        // オブジェクト側の型を取得
     256        bool isClassName = false;
     257        Type leftType;
     258        if( !TermOpe( termLeft, baseType, leftType, isLiteral, pbUseHeap, &isClassName ) ){
     259            return false;
     260        }
     261
     262        if( isClassName ){
     263            // 静的メンバ/メソッドの場合
     264            goto globalArea;
     265        }
     266
     267        if( !leftType.HasMember() ){
     268            // メンバを持たない型の場合
     269            return false;
     270        }
     271
     272        return TermMemberOpe( leftType.GetClass(), baseType, resultType, termFull, termLeft, member );
     273    }
     274
     275
     276    //////////////////////////////////////////////
     277    // クラス名かどうかをチェック(静的メンバ用)
     278    //////////////////////////////////////////////
     279
     280    if( pIsClassName ){
     281        if( pobj_DBClass->check( termFull ) ){
     282            *pIsClassName = true;
     283            return true;
     284        }
     285    }
     286
     287
     288    /////////////////////////////////////////////////////////////////
     289    // グローバル属性エリア
     290    /////////////////////////////////////////////////////////////////
     291globalArea:
     292
     293    const int useReg = REG_EAX;
     294
     295
     296    if(lstrcmpi(termFull,"This")==0){
     297        //Thisオブジェクト
     298        resultType.SetType( DEF_OBJECT, pobj_CompilingClass );
     299
     300        SetThisPtrToReg( useReg );
     301
     302        isLiteral = false;
     303
     304        return true;
     305    }
     306
     307
     308    //////////////////////////////////////
     309    // 関数(DLL、ユーザー定義、組み込み)
     310    //////////////////////////////////////
     311    char procName[VN_SIZE];
     312    char temporary[8192];
     313
     314    int i2=GetCallProcName(termFull,procName);
     315    if(termFull[i2]=='('){
     316        int i4=GetStringInPare_RemovePare(parameter,termFull+i2+1);
     317
     318        void *pInfo;
     319        int idProc=GetProc(procName,(void **)&pInfo);
     320
     321        if(idProc){
     322            //閉じカッコ")"に続く文字がNULLでないとき
     323            if(termFull[i2+1+i4+1]!='\0'){
     324                SetError(42,NULL,cp);
     325            }
     326
     327
     328            {
     329                ////////////////
     330                // 呼び出し
     331                ////////////////
     332
     333                CallProc(idProc,pInfo,procName,parameter,resultType);
     334
     335
     336                /////////////////////
     337                // 戻り値の処理
     338                /////////////////////
     339
     340                //大きな型への暗黙の変換
     341                int bigType = AutoBigCast(baseType.GetBasicType(), resultType.GetBasicType() );
     342
     343                /*
     344                ※後でNumOpe内でプッシュする
     345                //スタックへプッシュ
     346                PushReturnValue( resultType.GetBasicType() );
     347                */
     348
     349                if( resultType.GetBasicType() != bigType ){
     350                    // 大きな型へ変換された場合
     351                    // ※レジスタの値をキャストする
     352                    ExtendRegToBigType( useReg, bigType, resultType.GetBasicType() );
     353
     354                    resultType.SetBasicType( bigType );
     355                }
     356
     357                //SetUseRegFromRax(resultType.GetBasicType(),UseReg,XmmReg);
     358            }
     359
     360
     361            if(resultType.IsStruct()){
     362                //構造体が戻ったときはヒープ領域にインスタンスが格納されている
     363                //※後にfreeする必要あり
     364                // TODO: 解放はGCに任せる
     365                *pbUseHeap = 1;
     366            }
     367
     368            isLiteral = false;
     369
     370            return true;
     371        }
     372        else if(GetConstCalcBuffer(procName,parameter,temporary)){
     373            /////////////////////////
     374            // マクロ関数
     375            /////////////////////////
     376
     377            //閉じカッコ")"に続く文字がNULLでないときはエラーにする
     378            if(termFull[i2+1+i4+1]!='\0') SetError(42,NULL,cp);
     379
     380            //マクロ関数の場合
     381            NumOpe(useReg, temporary,Type(),resultType);
     382
     383            if(!IS_LITERAL(resultType.GetIndex())){
     384                //リテラル値ではなかったとき
     385                isLiteral = false;
     386            }
     387
     388            return true;
     389        }
     390    }
     391
     392
     393    ////////////////////////////////
     394    // インデクサ(getアクセサ)
     395    ////////////////////////////////
     396
     397    char VarName[VN_SIZE],ArrayElements[VN_SIZE];
     398    GetArrayElement(termFull,VarName,ArrayElements);
     399    if(ArrayElements[0]){
     400        GetVarType(VarName,resultType,false);
     401        if( resultType.IsObject() ){
     402            CallIndexerGetterProc(/*UseReg,*/&resultType.GetClass(),VarName,ArrayElements,resultType);
     403
     404            isLiteral = false;
     405
     406            return true;
     407        }
     408    }
     409
     410
     411    ////////////////////////////////
     412    // 変数
     413    ////////////////////////////////
     414
     415    RELATIVE_VAR relativeVar;
     416    if(GetVarOffset(
     417        false,  //エラー表示なし
     418        false,  //読み込み専用
     419        termFull,
     420        &relativeVar,resultType)){
     421        //////////
     422        // 変数
     423        //////////
     424
     425        if( !VarToReg( relativeVar, baseType, resultType ) ){
     426            SetError(11,termFull,cp);
     427        }
     428
     429        isLiteral = false;
     430
     431        return true;
     432    }
     433
     434
     435    /////////////////////////////////
     436    // プロパティ用のメソッド
     437    /////////////////////////////////
     438
     439    //配列要素を排除
     440    GetArrayElement(termFull,VarName,ArrayElements);
     441
     442    if(GetSubHash(VarName,0)){
     443
     444        {
     445            CallPropertyMethod(termFull,NULL,resultType);
     446
     447            //大きな型への暗黙の変換
     448            int bigType = AutoBigCast(baseType.GetBasicType(), resultType.GetBasicType() );
     449
     450            if( resultType.GetBasicType() != bigType ){
     451                // 大きな型へ変換された場合
     452                // ※レジスタの値をキャストする
     453                ExtendRegToBigType( REG_EAX, bigType, resultType.GetBasicType() );
     454
     455                resultType.SetBasicType( bigType );
     456            }
     457
     458            //SetUseRegFromRax(resultType.GetBasicType(),UseReg,XmmReg);
     459        }
     460
     461
     462        if(resultType.IsStruct()){
     463            //構造体が戻ったときはヒープ領域にインスタンスが格納されている
     464            //※後にfreeする必要あり
     465            // TODO: 解放はGCに任せる
     466            *pbUseHeap = 1;
     467        }
     468
     469        isLiteral = false;
     470
     471        return true;
     472    }
     473
     474
     475    return false;
     476}
     477
     478
     479bool NumOpe( int reg,
     480            const char *expression,
     481            const Type &baseType,
     482            Type &resultType,
     483            BOOL *pbUseHeap ){
     484
     485    if( !NumOpe( expression, baseType, resultType, pbUseHeap ) ){
     486        return false;
     487    }
     488
     489    if( reg != REG_EAX ){
     490        // TODO: 未実装
     491        SetError();
     492    }
     493
     494    if( resultType.IsReal() ){
     495        //fld ptr[esp]
     496        op_fld_ptr_esp( resultType.GetBasicType() );
     497
     498        //add esp,size
     499        op_add_esp( resultType.GetBasicSize() );
     500    }
     501    else{
     502        //pop eax
     503        op_pop(REG_EAX);
     504
     505        if( resultType.Is64() ){
     506            //pop edx
     507            op_pop(REG_EDX);
     508        }
     509    }
     510    return true;
     511}
    86512bool NumOpe( const char *expression,
    87513            const Type &baseType,
     
    89515            BOOL *pbUseHeap ){
    90516
    91     int i,i2,i3,i4;
    92     char temporary[1024],temp2[1024],temp3[1024];
     517    int i,i2,i3;
     518    char temporary[1024],temp2[1024];
    93519
    94520    if(expression[0]=='\0'){
     
    260686                term=values[i];
    261687
     688                if( calc[i+1]%100 == CALC_AS ){
     689                    // As演算子の右辺値
     690                    //型名
     691                    if( Type::StringToType( term, resultType ) ){
     692                        resultType.SetBasicType( resultType.GetBasicType() | FLAG_CAST );
     693                    }
     694                    else{
     695                        SetError(3, term, cp );
     696                        goto error;
     697                    }
     698
     699                    type_stack[sp] = resultType.GetBasicType();
     700                    index_stack[sp] = resultType.GetIndex();
     701                    sp++;
     702
     703                    break;
     704                }
     705
    262706                if(term[0]=='\"'){
    263707                    //リテラル文字列
     
    269713StrLiteral:
    270714
    271                     if( baseType.IsObject() ){
    272                         if( baseType.IsStringObject() ){
    273                             //要求タイプがStringのとき
    274 
    275                             //String型オブジェクトを生成
    276                             NewStringObject(term);
    277 
    278                             extern CClass *pobj_StringClass;
    279                             type_stack[sp]=DEF_OBJECT;
    280                             index_stack[sp]=(LONG_PTR)pobj_StringClass;
    281                             bLiteralCalculation=0;
    282 
    283                             sp++;
    284                             break;
    285                         }
     715                    if( baseType.IsObject() || baseType.IsNull() ){
     716                        //要求タイプがオブジェクト、または未定のとき
     717
     718                        //String型オブジェクトを生成
     719                        NewStringObject(term);
     720
     721                        extern CClass *pobj_StringClass;
     722                        type_stack[sp]=DEF_OBJECT;
     723                        index_stack[sp]=(LONG_PTR)pobj_StringClass;
     724                        bLiteralCalculation=0;
     725
     726                        sp++;
     727                        break;
    286728                    }
    287729
     
    317759                    // 何らかの識別子
    318760
    319                     //////////////////////////////////////
    320                     // 関数(DLL、ユーザー定義、組み込み)
    321                     //////////////////////////////////////
    322 
    323                     i2=GetCallProcName(term,temporary);
    324                     if(term[i2]=='('){
    325                         i4=GetStringInPare_RemovePare(temp2,term+i2+1);
    326 
    327                         void *pInfo;
    328                         int idProc=GetProc(temporary,(void **)&pInfo);
    329 
    330                         Type resultType;
    331                         if(idProc){
    332                             //閉じカッコ")"に続く文字がNULLでないとき
    333                             if(term[i2+1+i4+1]!='\0'){
    334                                 if( term[i2+1+i4+1] == '.'
    335                                     || term[i2+1+i4+1] == 1 && term[i2+1+i4+2] == ESC_PSMEM ){
    336                                         goto NonProc;
     761                    bool isLiteral;
     762                    if( TermOpe( term, baseType, resultType, isLiteral, &bUseHeap[sp] ) ){
     763                        if(resultType.IsNull()){
     764                            //戻り値が存在しないとき
     765                            for(i2=0;;i2++){
     766                                if(term[i2]=='('||term[i2]=='\0'){
     767                                    term[i2]=0;
     768                                    break;
     769                                }
     770                            }
     771                            SetError(38,term,cp);
     772
     773                            goto error;
     774                        }
     775
     776                        type_stack[sp] = resultType.GetBasicType();
     777                        index_stack[sp] = resultType.GetIndex();
     778
     779                        if( !isLiteral ){
     780                            bLiteralCalculation=0;
     781                        }
     782
     783                        if( resultType.GetBasicType() & FLAG_CAST ){
     784                            // 型名のみ
     785                            SetError();
     786                        }
     787                        else{
     788                            if( resultType.IsReal() ){
     789                                //sub esp,size
     790                                //fstp ptr[esp]
     791                                op_fstp_push( resultType );
     792                            }
     793                            else{
     794                                if( resultType.Is64() ){
     795                                    //push edx
     796                                    op_push( REG_EDX );
    337797                                }
    338798                                else{
    339                                     SetError(42,NULL,cp);
     799                                    ExtendTypeTo32( resultType.GetBasicType(), REG_EAX );
    340800                                }
     801
     802                                //push eax
     803                                op_push( REG_EAX );
    341804                            }
    342 
    343                             ////////////////
    344                             // 呼び出し
    345                             ////////////////
    346 
    347                             CallProc(idProc,pInfo,temporary,temp2,resultType);
    348                             if(resultType.IsNull()){
    349                                 //戻り値が存在しないとき
    350                                 for(i2=2;;i2++){
    351                                     if(term[i2]=='('||term[i2]=='\0'){
    352                                         term[i2]=0;
    353                                         break;
    354                                     }
    355                                 }
    356                                 SetError(38,term,cp);
    357 
    358                                 goto error;
    359                             }
    360 
    361 
    362                             /////////////////////
    363                             // 戻り値の処理
    364                             /////////////////////
    365 
    366                             //大きな型への暗黙の変換
    367                             type_stack[sp]=AutoBigCast(baseType.GetBasicType(),resultType.GetBasicType());
    368                             index_stack[sp] = resultType.GetIndex();
    369                             bLiteralCalculation=0;
    370 
    371                             //スタックへプッシュ
    372                             PushReturnValue( resultType.GetBasicType() );
    373 
    374                             if( Is64Type(type_stack[sp])
    375                                 && resultType.IsWhole()
    376                                 && resultType.GetBasicSize() <= sizeof(long) ){
    377                                     //必要に応じて64ビット拡張
    378                                     ExtendStackTo64( resultType.GetBasicType() );
    379                             }
    380 
    381                             if( resultType.IsStruct() ){
    382                                 //構造体が戻ったときはヒープ領域にインスタンスが格納されている
    383                                 //※後にfreeする必要あり
    384                                 bUseHeap[sp]=1;
    385                             }
    386 
    387                             sp++;
    388                             break;
    389805                        }
    390                         else if(GetConstCalcBuffer(temporary,temp2,temp3)){
    391                             /////////////////////////
    392                             // マクロ関数
    393                             /////////////////////////
    394 
    395                             //閉じカッコ")"に続く文字がNULLでないときはエラーにする
    396                             if(term[i2+1+i4+1]!='\0') SetError(42,NULL,cp);
    397 
    398                             //マクロ関数の場合
    399                             NumOpe(temp3,Type(),resultType);
    400 
    401                             if(!IS_LITERAL(resultType.GetIndex())){
    402                                 //リテラル値ではなかったとき
    403                                 bLiteralCalculation=0;
    404                             }
    405 
    406                             type_stack[sp] = resultType.GetBasicType();
    407                             index_stack[sp] = resultType.GetIndex();
    408 
    409                             sp++;
    410                             break;
    411                         }
    412                     }
    413 NonProc:
    414 
    415 
    416                     //インデクサ(getアクセサ)
    417                     char variable[VN_SIZE],array_element[VN_SIZE];
    418                     GetArrayElement(term,variable,array_element);
    419                     if(array_element[0]){
    420                         Type resultType;
    421                         GetVarType(variable,resultType,0);
    422                         if( resultType.IsObject() ){
    423                             CallIndexerGetterProc(&resultType.GetClass(),variable,array_element,resultType);
    424                             type_stack[sp]=resultType.GetBasicType();
    425                             index_stack[sp]=resultType.GetIndex();
    426                             bLiteralCalculation=0;
    427 
    428                             //push eax
    429                             op_push(REG_EAX);
    430 
    431                             sp++;
    432                             break;
    433                         }
     806
     807                        sp++;
     808                        break;
    434809                    }
    435810
     
    451826                        //push 0
    452827                        op_push_V( 0 );
    453 
    454                         sp++;
    455                         break;
    456                     }
    457 
    458                     RELATIVE_VAR RelativeVar;
    459                     Type varType;
    460                     if(GetVarOffset(
    461                         false,  //エラー表示あり
    462                         false,  //読み込み専用
    463                         term,
    464                         &RelativeVar,varType)){
    465                         //////////
    466                         // 変数
    467                         //////////
    468 
    469                         //大きな型への暗黙の変換
    470                         type_stack[sp]=AutoBigCast(baseType.GetBasicType(),varType.GetBasicType());
    471                         index_stack[sp] = varType.GetIndex();
    472                         bLiteralCalculation=0;
    473 
    474                         if(varType.GetBasicType()&FLAG_PTR){
    475                             //配列ポインタ
    476                             type_stack[sp]=GetPtrType(varType.GetBasicType()^FLAG_PTR);
    477 
    478                             SetVarPtrToEax(&RelativeVar);
    479 
    480                             //push eax
    481                             op_push(REG_EAX);
    482                         }
    483                         else if( varType.IsStruct() ){
    484                             //構造体ポインタをeaxへ格納(構造体は値型)
    485                             SetVarPtrToEax(&RelativeVar);
    486 
    487                             //push eax
    488                             op_push(REG_EAX);
    489                         }
    490                         else if( varType.GetBasicSize() == sizeof(_int64) ){
    491                             //64ビット型
    492                             PushDoubleVariable(&RelativeVar);
    493                         }
    494                         else if( varType.GetBasicSize() == sizeof(long) ){
    495                             //32ビット型
    496                             PushLongVariable(&RelativeVar);
    497                         }
    498                         else if( varType.IsInteger() ){
    499                             PushIntegerVariable(&RelativeVar);
    500                         }
    501                         else if( varType.IsWord() ){
    502                             PushWordVariable(&RelativeVar);
    503                         }
    504                         else if( varType.IsSByte() ){
    505                             PushCharVariable(&RelativeVar);
    506                         }
    507                         else if( varType.IsByte() || varType.IsBoolean() ){
    508                             PushByteVariable(&RelativeVar);
    509                         }
    510                         else SetError(11,term,cp);
    511 
    512                         if( Is64Type(type_stack[sp])
    513                             && varType.IsWhole()
    514                             && varType.GetBasicSize()<=sizeof(long)){
    515                             //必要に応じて64ビット拡張
    516                                 ExtendStackTo64( varType.GetBasicType() );
    517                         }
    518828
    519829                        sp++;
     
    556866
    557867
    558                     //////////////
    559                     // 型名の場合
    560                     //////////////
    561                     Type tempType;
    562                     if( Type::StringToType( term, tempType ) ){
    563                         type_stack[sp] = tempType.GetBasicType() | FLAG_CAST;
    564                         index_stack[sp] = tempType.GetIndex();
    565                         sp++;
    566                         break;
    567                     }
    568 
    569 
    570                     /////////////////////////////////
    571                     // プロパティ用のメソッド
    572                     /////////////////////////////////
    573 
    574                     //配列要素を排除
    575                     char VarName[VN_SIZE],ArrayElements[VN_SIZE];
    576                     GetArrayElement(term,VarName,ArrayElements);
    577 
    578                     if(GetSubHash(VarName,0)){
    579                         Type resultType;
    580                         CallPropertyMethod(term,NULL,resultType);
    581 
    582                         //大きな型への暗黙の変換
    583                         type_stack[sp]=AutoBigCast(baseType.GetBasicType(),resultType.GetBasicType());
    584                         index_stack[sp]=resultType.GetIndex();
    585                         bLiteralCalculation=0;
    586 
    587                         //スタックへプッシュ
    588                         PushReturnValue( resultType.GetBasicType() );
    589 
    590                         if(type_stack[sp]==DEF_STRUCT){
    591                             //構造体が戻ったときはヒープ領域にインスタンスが格納されている
    592                             //※後にfreeする必要あり
    593                             bUseHeap[sp]=1;
    594                         }
    595 
    596                         sp++;
    597                         break;
    598                     }
    599 
    600 
    601 
    602868                    //該当する識別子が見当たらないときはエラー扱いにする
    603869                    bError=1;
  • BasicCompiler32/NumOpe_Relation.cpp

    r64 r97  
    11#include "../BasicCompiler_Common/common.h"
    22#include "Opcode.h"
     3
     4void AutoExtendToBigType( int *type_stack,int sp, int reg1, int reg2 ){
     5    /*
     6    int bigSize = GetTypeSize( type_stack[sp-1], -1 );
     7    if( bigSize != GetTypeSize( type_stack[sp-2], -1 ) ){
     8        int extReg = reg2;
     9        int oldType = type_stack[sp-2];
     10        if( bigSize < GetTypeSize( type_stack[sp-2], -1 ) ){
     11            bigSize = GetTypeSize( type_stack[sp-2], -1 );
     12            extReg = reg1;
     13            oldType = type_stack[sp-1];
     14        }
     15        if( bigSize == 2 ){
     16            ExtendTypeTo16( oldType, extReg );
     17        }
     18        else if( bigSize == 4 ){
     19            ExtendTypeTo32( oldType, extReg );
     20        }
     21        else{
     22            SetError();
     23        }
     24    }*/
     25}
     26
    327
    428BOOL Calc_Relation_PE(int *type_stack,LONG_PTR *index_stack,int *pStackPointer){
     
    195219        //pop eax
    196220        op_pop(REG_EAX);
     221
     222        // どちらかのサイズが足りない場合は自動拡張する
     223        AutoExtendToBigType( type_stack, sp, REG_EAX, REG_EBX );
    197224
    198225        //sub esp,4
     
    434461        op_pop(REG_EAX);
    435462
     463        // どちらかのサイズが足りない場合は自動拡張する
     464        AutoExtendToBigType( type_stack, sp, REG_EAX, REG_EBX );
     465
    436466        //sub esp,4
    437467        op_sub_esp(4);
     
    675705        op_pop(REG_EAX);
    676706
     707        // どちらかのサイズが足りない場合は自動拡張する
     708        AutoExtendToBigType( type_stack, sp, REG_EAX, REG_EBX );
     709
    677710        //sub esp,4
    678711        op_sub_esp(4);
     
    911944        //pop eax
    912945        op_pop(REG_EAX);
     946
     947        // どちらかのサイズが足りない場合は自動拡張する
     948        AutoExtendToBigType( type_stack, sp, REG_EAX, REG_EBX );
    913949
    914950        //sub esp,4
     
    11151151        op_pop(REG_EBX);
    11161152
     1153        // どちらかのサイズが足りない場合は自動拡張する
     1154        AutoExtendToBigType( type, sp, REG_EAX, REG_EBX );
     1155
    11171156        //sub esp,4
    11181157        op_sub_esp(4);
     
    13061345        op_pop(REG_EBX);
    13071346
     1347        // どちらかのサイズが足りない場合は自動拡張する
     1348        AutoExtendToBigType( type, sp, REG_EAX, REG_EBX );
     1349
    13081350        //sub esp,4
    13091351        op_sub_esp(4);
  • BasicCompiler32/Opcode.h

    r95 r97  
    102102//NumOpe.cpp
    103103void PushReturnValue(int type);
     104bool NumOpe( int reg,
     105            const char *expression,
     106            const Type &baseType,
     107            Type &resultType,
     108            BOOL *pbUseHeap = NULL );
    104109bool NumOpe( const char *Command,
    105110           const Type &baseType,
     
    151156void Set8Variable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
    152157void SetBooleanVariable(int type,RELATIVE_VAR *pRelative);
     158void ExtendTypeTo64(int type);
     159void ExtendTypeTo32(int type,int reg);
     160void ExtendTypeTo16(int type,int reg);
    153161
    154162//increment.cpp
     
    168176//Compile_Calc_PushVar.cpp
    169177void SetReg_RealVariable(int type,RELATIVE_VAR *pRelativeVar);
    170 void SetReg_WholeVariable(int type,RELATIVE_VAR *pRelativeVar,int reg);
     178void SetReg_WholeVariable(int type,RELATIVE_VAR *pRelativeVar,int reg, bool is64Head = false);
    171179void PushDoubleVariable(RELATIVE_VAR *pRelativeVar);
    172180void PushLongVariable(RELATIVE_VAR *pRelativeVar);
     
    182190//Compile_Var.cpp
    183191void SetRelativeOffset( RELATIVE_VAR &relativeVar );
    184 void GetWithName(char *buffer);
     192bool _member_offset(bool isErrorEnabled, bool isWriteAccess, const CClass &objClass, const char *member, RELATIVE_VAR *pRelativeVar, Type &resultType, BOOL bPrivateAccess);
    185193void SetThisPtrToReg(int reg);
    186194bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType,int *pss = 0);
     
    192200void dim( char *VarName,int *SubScripts,Type &type,char *InitBuf,char *ConstractParameter,DWORD dwFlags);
    193201void SetVarPtrToEax(RELATIVE_VAR *pRelativeVar);
     202void SetVarPtrToReg(int reg,RELATIVE_VAR *pRelativeVar);
    194203bool Compile_AddGlobalRootsForGc();
    195204
     
    314323void op_push(int reg);
    315324void op_push_V(long data);
    316 void op_pop(int reg);
     325void op_pop(int reg = REG_NON);
    317326void op_add_esp(int num);
    318327void op_sub_esp(int num);
     
    328337void op_fstp_base_offset    (int type,int base_reg,int offset);
    329338void op_fstp_base_offset_ex (int type,int base_reg1,int base_reg2,int offset,BOOL bUseOffset);
     339void op_fstp_push           ( Type &type );
    330340void op_fistp_ptr_esp       ( int typeSize );
    331341void op_zero_reg(int reg);
  • BasicCompiler32/op32_main.cpp

    r75 r97  
    864864        SetError();
    865865    }
     866}
     867void op_fstp_push( Type &type ){
     868    //sub esp,size
     869    op_sub_esp( type.GetBasicSize() );
     870
     871    op_fstp_basereg( type.GetBasicType(), REG_ESP );
    866872}
    867873
  • BasicCompiler64/BasicCompiler.vcproj

    r91 r97  
    385385                IgnoreDefaultLibraryNames="libcpmtd"
    386386                GenerateDebugInformation="false"
     387                ProgramDatabaseFile=".\Release/BasicCompiler64.pdb"
     388                SubSystem="2"
     389                TargetMachine="0"
     390            />
     391            <Tool
     392                Name="VCALinkTool"
     393            />
     394            <Tool
     395                Name="VCManifestTool"
     396                AdditionalManifestFiles="$(ProjectDir)\manifest.xml"
     397            />
     398            <Tool
     399                Name="VCXDCMakeTool"
     400            />
     401            <Tool
     402                Name="VCBscMakeTool"
     403                SuppressStartupBanner="true"
     404                OutputFile="$(OutDir)/$(ProjectName).bsc"
     405            />
     406            <Tool
     407                Name="VCFxCopTool"
     408            />
     409            <Tool
     410                Name="VCAppVerifierTool"
     411            />
     412            <Tool
     413                Name="VCWebDeploymentTool"
     414            />
     415            <Tool
     416                Name="VCPostBuildEventTool"
     417            />
     418        </Configuration>
     419        <Configuration
     420            Name="test_release|Win32"
     421            OutputDirectory="$(ConfigurationName)"
     422            IntermediateDirectory="$(ConfigurationName)"
     423            ConfigurationType="1"
     424            UseOfMFC="0"
     425            ATLMinimizesCRunTimeLibraryUsage="false"
     426            CharacterSet="2"
     427            >
     428            <Tool
     429                Name="VCPreBuildEventTool"
     430            />
     431            <Tool
     432                Name="VCCustomBuildTool"
     433            />
     434            <Tool
     435                Name="VCXMLDataGeneratorTool"
     436            />
     437            <Tool
     438                Name="VCWebServiceProxyGeneratorTool"
     439            />
     440            <Tool
     441                Name="VCMIDLTool"
     442                PreprocessorDefinitions="_DEBUG"
     443                MkTypLibCompatible="true"
     444                SuppressStartupBanner="true"
     445                TargetEnvironment="1"
     446                TypeLibraryName=".\Debug/BasicCompiler.tlb"
     447                HeaderFileName=""
     448            />
     449            <Tool
     450                Name="VCCLCompilerTool"
     451                Optimization="0"
     452                AdditionalIncludeDirectories="..\cpplibs\boost;..\BasicCompiler_Common\include"
     453                PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;JPN;_AMD64_;_WIN64"
     454                MinimalRebuild="false"
     455                BasicRuntimeChecks="0"
     456                RuntimeLibrary="2"
     457                UsePrecompiledHeader="0"
     458                PrecompiledHeaderFile=".\Release/BasicCompiler.pch"
     459                AssemblerListingLocation=".\Release/"
     460                ObjectFile=".\Release/"
     461                ProgramDataBaseFileName=".\Release/"
     462                BrowseInformation="0"
     463                WarningLevel="3"
     464                SuppressStartupBanner="true"
     465                Detect64BitPortabilityProblems="true"
     466                DebugInformationFormat="3"
     467                CallingConvention="0"
     468            />
     469            <Tool
     470                Name="VCManagedResourceCompilerTool"
     471            />
     472            <Tool
     473                Name="VCResourceCompilerTool"
     474                PreprocessorDefinitions="_DEBUG,JPN"
     475                Culture="1041"
     476            />
     477            <Tool
     478                Name="VCPreLinkEventTool"
     479            />
     480            <Tool
     481                Name="VCLinkerTool"
     482                AdditionalOptions="/MACHINE:AMD64"
     483                AdditionalDependencies="odbc32.lib odbccp32.lib comctl32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib bufferoverflowu.lib"
     484                OutputFile="../ActiveBasic/BasicCompiler64.exe"
     485                LinkIncremental="2"
     486                SuppressStartupBanner="true"
     487                IgnoreDefaultLibraryNames="libcpmtd"
     488                GenerateDebugInformation="true"
    387489                ProgramDatabaseFile=".\Release/BasicCompiler64.pdb"
    388490                SubSystem="2"
     
    578680                    />
    579681                </FileConfiguration>
     682                <FileConfiguration
     683                    Name="test_release|Win32"
     684                    >
     685                    <Tool
     686                        Name="VCResourceCompilerTool"
     687                        PreprocessorDefinitions="_DEBUG;JPN;$(NoInherit)"
     688                    />
     689                </FileConfiguration>
    580690            </File>
    581691            <Filter
     
    624734                        />
    625735                    </FileConfiguration>
     736                    <FileConfiguration
     737                        Name="test_release|Win32"
     738                        >
     739                        <Tool
     740                            Name="VCCLCompilerTool"
     741                            PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;JPN;$(NoInherit)"
     742                            UsePrecompiledHeader="0"
     743                            BrowseInformation="0"
     744                        />
     745                    </FileConfiguration>
    626746                </File>
    627747                <File
     
    667787                        />
    668788                    </FileConfiguration>
     789                    <FileConfiguration
     790                        Name="test_release|Win32"
     791                        >
     792                        <Tool
     793                            Name="VCCLCompilerTool"
     794                            PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;JPN;$(NoInherit)"
     795                            UsePrecompiledHeader="0"
     796                            BrowseInformation="0"
     797                        />
     798                    </FileConfiguration>
    669799                </File>
    670800                <File
     
    710840                        />
    711841                    </FileConfiguration>
     842                    <FileConfiguration
     843                        Name="test_release|Win32"
     844                        >
     845                        <Tool
     846                            Name="VCCLCompilerTool"
     847                            PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;JPN;$(NoInherit)"
     848                            UsePrecompiledHeader="0"
     849                            BrowseInformation="0"
     850                        />
     851                    </FileConfiguration>
    712852                </File>
    713853                <File
     
    745885                    <FileConfiguration
    746886                        Name="Release2|Win32"
     887                        >
     888                        <Tool
     889                            Name="VCCLCompilerTool"
     890                            PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;JPN;$(NoInherit)"
     891                            UsePrecompiledHeader="0"
     892                            BrowseInformation="0"
     893                        />
     894                    </FileConfiguration>
     895                    <FileConfiguration
     896                        Name="test_release|Win32"
    747897                        >
    748898                        <Tool
     
    800950                            />
    801951                        </FileConfiguration>
     952                        <FileConfiguration
     953                            Name="test_release|Win32"
     954                            >
     955                            <Tool
     956                                Name="VCCLCompilerTool"
     957                                PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;JPN;$(NoInherit)"
     958                                UsePrecompiledHeader="0"
     959                                BrowseInformation="0"
     960                            />
     961                        </FileConfiguration>
    802962                    </File>
    803963                    <File
     
    8431003                            />
    8441004                        </FileConfiguration>
     1005                        <FileConfiguration
     1006                            Name="test_release|Win32"
     1007                            >
     1008                            <Tool
     1009                                Name="VCCLCompilerTool"
     1010                                PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;JPN;$(NoInherit)"
     1011                                UsePrecompiledHeader="0"
     1012                                BrowseInformation="0"
     1013                            />
     1014                        </FileConfiguration>
    8451015                    </File>
    8461016                    <File
     
    8861056                            />
    8871057                        </FileConfiguration>
     1058                        <FileConfiguration
     1059                            Name="test_release|Win32"
     1060                            >
     1061                            <Tool
     1062                                Name="VCCLCompilerTool"
     1063                                PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;JPN;$(NoInherit)"
     1064                                UsePrecompiledHeader="0"
     1065                                BrowseInformation="0"
     1066                            />
     1067                        </FileConfiguration>
    8881068                    </File>
    8891069                    <File
     
    9331113                            />
    9341114                        </FileConfiguration>
     1115                        <FileConfiguration
     1116                            Name="test_release|Win32"
     1117                            >
     1118                            <Tool
     1119                                Name="VCCLCompilerTool"
     1120                                PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;JPN;$(NoInherit)"
     1121                                UsePrecompiledHeader="0"
     1122                                BrowseInformation="0"
     1123                            />
     1124                        </FileConfiguration>
    9351125                    </File>
    9361126                    <File
     
    9761166                            />
    9771167                        </FileConfiguration>
     1168                        <FileConfiguration
     1169                            Name="test_release|Win32"
     1170                            >
     1171                            <Tool
     1172                                Name="VCCLCompilerTool"
     1173                                PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;JPN;$(NoInherit)"
     1174                                UsePrecompiledHeader="0"
     1175                                BrowseInformation="0"
     1176                            />
     1177                        </FileConfiguration>
    9781178                    </File>
    9791179                    <File
     
    10191219                            />
    10201220                        </FileConfiguration>
     1221                        <FileConfiguration
     1222                            Name="test_release|Win32"
     1223                            >
     1224                            <Tool
     1225                                Name="VCCLCompilerTool"
     1226                                PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;JPN;$(NoInherit)"
     1227                                UsePrecompiledHeader="0"
     1228                                BrowseInformation="0"
     1229                            />
     1230                        </FileConfiguration>
    10211231                    </File>
    10221232                    <File
     
    10621272                            />
    10631273                        </FileConfiguration>
     1274                        <FileConfiguration
     1275                            Name="test_release|Win32"
     1276                            >
     1277                            <Tool
     1278                                Name="VCCLCompilerTool"
     1279                                PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;JPN;$(NoInherit)"
     1280                                UsePrecompiledHeader="0"
     1281                                BrowseInformation="0"
     1282                            />
     1283                        </FileConfiguration>
    10641284                    </File>
    10651285                    <File
     
    10971317                        <FileConfiguration
    10981318                            Name="Release2|Win32"
     1319                            >
     1320                            <Tool
     1321                                Name="VCCLCompilerTool"
     1322                                PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;JPN;$(NoInherit)"
     1323                                UsePrecompiledHeader="0"
     1324                                BrowseInformation="0"
     1325                            />
     1326                        </FileConfiguration>
     1327                        <FileConfiguration
     1328                            Name="test_release|Win32"
    10991329                            >
    11001330                            <Tool
     
    11601390                            />
    11611391                        </FileConfiguration>
     1392                        <FileConfiguration
     1393                            Name="test_release|Win32"
     1394                            >
     1395                            <Tool
     1396                                Name="VCCLCompilerTool"
     1397                                PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;JPN;$(NoInherit)"
     1398                                UsePrecompiledHeader="0"
     1399                                BrowseInformation="0"
     1400                            />
     1401                        </FileConfiguration>
    11621402                    </File>
    11631403                    <File
     
    12191459                            />
    12201460                        </FileConfiguration>
     1461                        <FileConfiguration
     1462                            Name="test_release|Win32"
     1463                            >
     1464                            <Tool
     1465                                Name="VCCLCompilerTool"
     1466                                PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;JPN;$(NoInherit)"
     1467                                UsePrecompiledHeader="0"
     1468                                BrowseInformation="0"
     1469                            />
     1470                        </FileConfiguration>
    12211471                    </File>
    12221472                    <File
     
    12541504                        <FileConfiguration
    12551505                            Name="Release2|Win32"
     1506                            >
     1507                            <Tool
     1508                                Name="VCCLCompilerTool"
     1509                                PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;JPN;$(NoInherit)"
     1510                                UsePrecompiledHeader="0"
     1511                                BrowseInformation="0"
     1512                            />
     1513                        </FileConfiguration>
     1514                        <FileConfiguration
     1515                            Name="test_release|Win32"
    12561516                            >
    12571517                            <Tool
     
    14351695                        <FileConfiguration
    14361696                            Name="Release2|Win32"
     1697                            >
     1698                            <Tool
     1699                                Name="VCCLCompilerTool"
     1700                                ObjectFile="$(IntDir)\$(InputName)1.obj"
     1701                                XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
     1702                            />
     1703                        </FileConfiguration>
     1704                        <FileConfiguration
     1705                            Name="test_release|Win32"
    14371706                            >
    14381707                            <Tool
  • BasicCompiler64/BasicCompiler64.sln

    r3 r97  
    99        English_Rel|Win32 = English_Rel|Win32
    1010        Release|Win32 = Release|Win32
     11        test_release|Win32 = test_release|Win32
    1112    EndGlobalSection
    1213    GlobalSection(ProjectConfigurationPlatforms) = postSolution
     
    1718        {864B921B-423B-4F9E-9E6B-31B15968EDF9}.Release|Win32.ActiveCfg = Release2|Win32
    1819        {864B921B-423B-4F9E-9E6B-31B15968EDF9}.Release|Win32.Build.0 = Release2|Win32
     20        {864B921B-423B-4F9E-9E6B-31B15968EDF9}.test_release|Win32.ActiveCfg = test_release|Win32
     21        {864B921B-423B-4F9E-9E6B-31B15968EDF9}.test_release|Win32.Build.0 = test_release|Win32
    1922    EndGlobalSection
    2023    GlobalSection(SolutionProperties) = preSolution
  • BasicCompiler64/Compile_CallProc.cpp

    r77 r97  
    9696
    9797bool Opcode_CallProc(const char *Parameter,UserProc *pUserProc,DWORD dwFlags,const char *ObjectName,int RefType){
     98    // TODO: RefTypeは不必要なので削除する
    9899    int i2;
    99100
     
    120121    if( pUserProc->GetParentClassPtr() ){
    121122        //クラスのメンバ関数を呼び出す場合はアクセスチェックを行う
    122         if(ObjectName[0]){
     123        if(ObjectName[0] && (dwFlags&PROCFLAG_NEW)==0){
    123124            if(lstrcmpi(ObjectName,"Super")==0){
    124125                //クラスメンバ関数内から基底クラスの呼び出し
     
    303304        ///////////////////////////////
    304305
    305         if(ObjectName[0]){
     306        if(ObjectName[0] && (dwFlags&PROCFLAG_NEW)==0){
    306307            if(lstrcmpi(ObjectName,"Super")==0) goto InClassMember;
    307308            else{
  • BasicCompiler64/Compile_Func.cpp

    r88 r97  
    5757    }
    5858
    59     if( type.IsStringObject() ){
     59    if( type.IsStringClass() ){
    6060        //Stringオブジェクトの場合
    6161        sprintf(temporary,"%s.Length",tempParm);
  • BasicCompiler64/Compile_Statement.cpp

    r88 r97  
    5858
    5959        if(pUserProc){
    60             if( !pUserProc->IsMacro() ) SetError(10,Command,cp);
     60            if( !pUserProc->IsMacro() ){
     61                SetError(10,Command,cp);
     62            }
    6163
    6264            Opcode_CallProc("",pUserProc,0,"",0);
  • BasicCompiler64/Compile_Var.cpp

    r96 r97  
    366366    return true;
    367367}
    368 void GetWithName(char *buffer){
    369     extern WITHINFO WithInfo;
    370     int i;
    371 
    372     buffer[0]=0;
    373     for(i=0;i<WithInfo.num;i++)
    374         lstrcat(buffer,WithInfo.ppName[i]);
    375 }
    376368
    377369int LocalVar_ThisPtrOffset;
     
    401393        //例: func().member
    402394
     395        // TODO: 消す
     396        SetError();
     397        return false;
     398        /*
    403399        void *pInfo;
    404400        int idProc=GetProc(VarName,(void **)&pInfo);
     
    435431
    436432            return true;
    437         }
     433        }*/
    438434    }
    439435
     
    864860    }
    865861    else if( type.Is64() || type.IsPointer() ){
    866         if(type.GetBasicType()==typeOfPtrChar && type.GetIndex()==LITERAL_STRING){
     862        if(type.GetBasicType()==typeOfPtrChar){
    867863            //文字列定数のとき
    868864
     
    10101006    }
    10111007    else if( type.Is64() || type.IsPointer() ){
    1012         if(type.GetBasicType()==typeOfPtrChar && type.GetIndex()==LITERAL_STRING){
     1008        if(type.GetBasicType()==typeOfPtrChar ){
    10131009            //文字列定数のとき
    10141010
  • BasicCompiler64/NumOpe.cpp

    r94 r97  
    8383}
    8484
     85
     86bool VarToReg( RELATIVE_VAR &relativeVar, const Type &baseType, Type &resultType ){
     87    int UseReg=pobj_reg->GetNextReg();
     88    int XmmReg=pobj_reg->GetNextXmmReg();
     89
     90    //大きな型への暗黙の変換
     91    int bigType = AutoBigCast(baseType.GetBasicType(),resultType.GetBasicType());
     92
     93    if(resultType.GetBasicType()&FLAG_PTR){
     94        //配列ポインタ
     95        resultType.SetBasicType( GetPtrType(resultType.GetBasicType()^FLAG_PTR) );
     96
     97        SetVarPtrToReg(UseReg,&relativeVar);
     98    }
     99    else if(resultType.IsReal()){
     100        //実数型
     101        if( resultType.IsDouble() )
     102            SetXmmReg_DoubleVariable(&relativeVar,XmmReg);
     103        if( resultType.IsSingle() )
     104            SetXmmReg_SingleVariable(&relativeVar,XmmReg);
     105    }
     106    else if( resultType.IsWhole() || resultType.IsObject()){
     107        //整数型
     108        SetReg_WholeVariable(resultType.GetBasicType(),&relativeVar,UseReg);
     109    }
     110    else if( resultType.IsStruct() ){
     111        //構造体ポインタをUseRegへ格納(構造体は値型)
     112        SetVarPtrToReg(UseReg,&relativeVar);
     113    }
     114    else{
     115        return false;
     116    }
     117
     118    if( resultType.GetBasicType() != bigType ){
     119        // 大きな型へ変換された場合
     120        // ※レジスタの値をキャストする
     121        ExtendRegToBigType( UseReg, bigType, resultType.GetBasicType() );
     122
     123        resultType.SetBasicType( bigType );
     124    }
     125
     126    return true;
     127}
     128bool TermMemberOpe( const CClass &objClass, const Type &baseType, Type &resultType, const char *termFull, const char *termLeft, const char *member ){
     129
     130    int UseReg=pobj_reg->GetNextReg();
     131    int XmmReg=pobj_reg->GetNextXmmReg();
     132
     133
     134    if( GetMemberType( objClass, member, resultType, 0, false ) ){
     135        // メンバが見つかったとき
     136
     137        //オブジェクトポインタをr11にコピー
     138        op_mov_RR( REG_R11, UseReg );
     139
     140        RELATIVE_VAR relativeVar;
     141        relativeVar.dwKind=VAR_DIRECTMEM;
     142
     143        if( !_member_offset(
     144            true,   //エラー表示あり
     145            false,  //読み込み専用
     146            objClass,
     147            member,&relativeVar,resultType,0)){
     148                return false;
     149        }
     150
     151        if( !VarToReg( relativeVar, baseType, resultType ) ){
     152            SetError(11,termFull,cp);
     153        }
     154
     155        return true;
     156    }
     157
     158
     159    ///////////////////////////////////////////////////////////////////
     160    // 動的メソッドを検索
     161    ///////////////////////////////////////////////////////////////////
     162    vector<UserProc *> userProcs;
     163
     164    char methodName[VN_SIZE], lpPtrOffset[VN_SIZE], parameter[VN_SIZE], dummy[1];
     165    CClass::RefType refType;
     166    lstrcpy( methodName, member );
     167    GetVarFormatString(methodName,parameter,lpPtrOffset,dummy,refType);
     168
     169    objClass.EnumMethod( methodName, userProcs );
     170    UserProc *pUserProc;
     171    if(userProcs.size()){
     172        //オーバーロードを解決
     173        pUserProc=OverloadSolutionWithStrParam(termFull,userProcs,parameter,termLeft);
     174
     175        if( pUserProc ){
     176
     177            resultType = pUserProc->ReturnType();
     178
     179
     180            //////////////////////////////////////////////////////
     181            /////    レジスタ資源のバックアップ
     182            {   BACKUP_REGISTER_RESOURCE
     183            //////////////////////////////////////////////////////
     184
     185                //オブジェクトポインタをスタックに入れておく
     186                //mov qword ptr[rsp+offset],reg     ※スタックフレームを利用
     187                pobj_sf->push( UseReg );
     188
     189                if( !Opcode_CallProc(parameter,pUserProc,PROCFLAG_NEW,termLeft,0 ) ){
     190                    //レジスタ資源を復元
     191                    RESTORE_REGISTER_RESOURCE
     192
     193                    return false;
     194                }
     195
     196                pobj_sf->pop();
     197
     198                /////////////////////
     199                // 戻り値の処理
     200                /////////////////////
     201
     202                //大きな型への暗黙の変換
     203                int bigType = AutoBigCast(baseType.GetBasicType(), resultType.GetBasicType() );
     204
     205                if( resultType.GetBasicType() != bigType ){
     206                    // 大きな型へ変換された場合
     207                    // ※レジスタの値をキャストする
     208                    ExtendRegToBigType( REG_RAX, bigType, resultType.GetBasicType() );
     209
     210                    resultType.SetBasicType( bigType );
     211                }
     212
     213                SetUseRegFromRax(resultType.GetBasicType(),UseReg,XmmReg);
     214
     215
     216            /////////////////////////////////////////////
     217            //////   レジスタ資源を復元
     218                RESTORE_REGISTER_RESOURCE
     219            }////////////////////////////////////////////
     220           
     221            return true;
     222        }
     223    }
     224
     225    return false;
     226}
     227bool TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, BOOL *pbUseHeap, bool *pIsClassName = NULL ){
     228    char parameter[VN_SIZE];
     229
     230    // Withを解決
     231    char termFull[VN_SIZE];
     232    if(term[0]=='.'){
     233        GetWithName(termFull);
     234        lstrcat(termFull,term);
     235    }
     236    else lstrcpy(termFull,term);
     237
     238    char termLeft[VN_SIZE];
     239    lstrcpy(termLeft,termFull);
     240
     241    if( (string)term=="DayOfWeek"){
     242        int test=0;
     243    }
     244
     245    // パース
     246    char member[VN_SIZE];
     247    CClass::RefType refType;
     248    if( SplitMemberName( termFull, termLeft, member, refType ) ){
     249        ///////////////////////////////////////////////////////////////////
     250        // オブジェクトとメンバに分解できるとき
     251        // termLeft.member
     252        ///////////////////////////////////////////////////////////////////
     253
     254        isLiteral = false;
     255
     256        // オブジェクト側の型を取得
     257        bool isClassName = false;
     258        Type leftType;
     259        if( !TermOpe( termLeft, baseType, leftType, isLiteral, pbUseHeap, &isClassName ) ){
     260            return false;
     261        }
     262
     263        if( isClassName ){
     264            // 静的メンバ/メソッドの場合
     265            goto globalArea;
     266        }
     267
     268        if( !leftType.HasMember() ){
     269            // メンバを持たない型の場合
     270            return false;
     271        }
     272
     273        return TermMemberOpe( leftType.GetClass(), baseType, resultType, termFull, termLeft, member );
     274    }
     275
     276
     277    //////////////////////////////////////////////
     278    // クラス名かどうかをチェック(静的メンバ用)
     279    //////////////////////////////////////////////
     280
     281    if( pIsClassName ){
     282        if( pobj_DBClass->check( termFull ) ){
     283            *pIsClassName = true;
     284            return true;
     285        }
     286    }
     287
     288
     289    /////////////////////////////////////////////////////////////////
     290    // グローバル属性エリア
     291    /////////////////////////////////////////////////////////////////
     292globalArea:
     293
     294    int UseReg=pobj_reg->GetNextReg();
     295    int XmmReg=pobj_reg->GetNextXmmReg();
     296
     297
     298    if(lstrcmpi(termFull,"This")==0){
     299        //Thisオブジェクト
     300        resultType.SetType( DEF_OBJECT, pobj_CompilingClass );
     301
     302        SetThisPtrToReg( UseReg );
     303
     304        isLiteral = false;
     305
     306        return true;
     307    }
     308
     309
     310    //////////////////////////////////////
     311    // 関数(DLL、ユーザー定義、組み込み)
     312    //////////////////////////////////////
     313    char procName[VN_SIZE];
     314    char temporary[8192];
     315
     316    int i2=GetCallProcName(termFull,procName);
     317    if(termFull[i2]=='('){
     318        int i4=GetStringInPare_RemovePare(parameter,termFull+i2+1);
     319
     320        void *pInfo;
     321        int idProc=GetProc(procName,(void **)&pInfo);
     322
     323        if(idProc){
     324            //閉じカッコ")"に続く文字がNULLでないとき
     325            if(termFull[i2+1+i4+1]!='\0'){
     326                SetError(42,NULL,cp);
     327            }
     328
     329
     330            //////////////////////////////////////////////////////
     331            /////    レジスタ資源のバックアップ
     332            {   BACKUP_REGISTER_RESOURCE
     333            //////////////////////////////////////////////////////
     334
     335
     336                ////////////////
     337                // 呼び出し
     338                ////////////////
     339
     340                CallProc(idProc,pInfo,procName,parameter,resultType);
     341
     342
     343                /////////////////////
     344                // 戻り値の処理
     345                /////////////////////
     346
     347                //大きな型への暗黙の変換
     348                int bigType = AutoBigCast(baseType.GetBasicType(), resultType.GetBasicType() );
     349
     350                if( resultType.GetBasicType() != bigType ){
     351                    // 大きな型へ変換された場合
     352                    // ※レジスタの値をキャストする
     353                    ExtendRegToBigType( REG_RAX, bigType, resultType.GetBasicType() );
     354
     355                    resultType.SetBasicType( bigType );
     356                }
     357
     358                SetUseRegFromRax(resultType.GetBasicType(),UseReg,XmmReg);
     359
     360            /////////////////////////////////////////////
     361            //////   レジスタ資源を復元
     362                RESTORE_REGISTER_RESOURCE
     363            }////////////////////////////////////////////
     364
     365            if(resultType.IsStruct()){
     366                //構造体が戻ったときはヒープ領域にインスタンスが格納されている
     367                //※後にfreeする必要あり
     368                // TODO: 解放はGCに任せる
     369                *pbUseHeap = 1;
     370            }
     371
     372            isLiteral = false;
     373
     374            return true;
     375        }
     376        else if(GetConstCalcBuffer(procName,parameter,temporary)){
     377            /////////////////////////
     378            // マクロ関数
     379            /////////////////////////
     380
     381            //閉じカッコ")"に続く文字がNULLでないときはエラーにする
     382            if(termFull[i2+1+i4+1]!='\0') SetError(42,NULL,cp);
     383
     384            //マクロ関数の場合
     385            NumOpe(&UseReg,temporary,Type(),resultType);
     386
     387            if(!IS_LITERAL(resultType.GetIndex())){
     388                //リテラル値ではなかったとき
     389                isLiteral = false;
     390            }
     391
     392            return true;
     393        }
     394    }
     395
     396
     397    ////////////////////////////////
     398    // インデクサ(getアクセサ)
     399    ////////////////////////////////
     400
     401    char VarName[VN_SIZE],ArrayElements[VN_SIZE];
     402    GetArrayElement(termFull,VarName,ArrayElements);
     403    if(ArrayElements[0]){
     404        GetVarType(VarName,resultType,false);
     405        if( resultType.IsObject() ){
     406            CallIndexerGetterProc(UseReg,&resultType.GetClass(),VarName,ArrayElements,resultType);
     407
     408            isLiteral = false;
     409
     410            return true;
     411        }
     412    }
     413
     414
     415    ////////////////////////////////
     416    // 変数
     417    ////////////////////////////////
     418
     419    RELATIVE_VAR relativeVar;
     420    if(GetVarOffset(
     421        false,  //エラー表示なし
     422        false,  //読み込み専用
     423        termFull,
     424        &relativeVar,resultType)){
     425        //////////
     426        // 変数
     427        //////////
     428
     429        if( !VarToReg( relativeVar, baseType, resultType ) ){
     430            SetError(11,termFull,cp);
     431        }
     432
     433        isLiteral = false;
     434
     435        return true;
     436    }
     437
     438/*
     439    ////////////////////////////////
     440    // 型名
     441    ////////////////////////////////
     442
     443    if( Type::StringToType( termFull, resultType ) ){
     444        resultType.SetBasicType( resultType.GetBasicType() | FLAG_CAST );
     445        return true;
     446    }*/
     447
     448
     449    /////////////////////////////////
     450    // プロパティ用のメソッド
     451    /////////////////////////////////
     452
     453    //配列要素を排除
     454    GetArrayElement(termFull,VarName,ArrayElements);
     455
     456    if(GetSubHash(VarName,0)){
     457
     458        //////////////////////////////////////////////////////
     459        /////    レジスタ資源のバックアップ
     460        {   BACKUP_REGISTER_RESOURCE
     461        //////////////////////////////////////////////////////
     462
     463            CallPropertyMethod(termFull,NULL,resultType);
     464
     465            //大きな型への暗黙の変換
     466            int bigType = AutoBigCast(baseType.GetBasicType(), resultType.GetBasicType() );
     467
     468            if( resultType.GetBasicType() != bigType ){
     469                // 大きな型へ変換された場合
     470                // ※レジスタの値をキャストする
     471                ExtendRegToBigType( REG_RAX, bigType, resultType.GetBasicType() );
     472
     473                resultType.SetBasicType( bigType );
     474            }
     475
     476            SetUseRegFromRax(resultType.GetBasicType(),UseReg,XmmReg);
     477
     478        /////////////////////////////////////////////
     479        //////   レジスタ資源を復元
     480            RESTORE_REGISTER_RESOURCE
     481        }////////////////////////////////////////////
     482
     483        if(resultType.IsStruct()){
     484            //構造体が戻ったときはヒープ領域にインスタンスが格納されている
     485            //※後にfreeする必要あり
     486            // TODO: 解放はGCに任せる
     487            *pbUseHeap = 1;
     488        }
     489
     490        isLiteral = false;
     491
     492        return true;
     493    }
     494
     495
     496    return false;
     497}
     498
    85499bool NumOpe( int *pReg,
    86500            const char *expression,
     
    89503            BOOL *pbUseHeap ){
    90504
    91     int i,i2,i3,i4;
    92     char temporary[1024],temp2[1024],temp3[1024];
     505    int i,i2,i3;
     506    char temporary[1024],temp2[1024];
    93507
    94508    if(expression[0]=='\0'){
     
    289703                term=values[i];
    290704
     705                if( calc[i+1]%100 == CALC_AS ){
     706                    // As演算子の右辺値
     707                    //型名
     708                    if( Type::StringToType( term, resultType ) ){
     709                        resultType.SetBasicType( resultType.GetBasicType() | FLAG_CAST );
     710                    }
     711                    else{
     712                        SetError(3, term, cp );
     713                        goto error;
     714                    }
     715
     716                    type_stack[sp] = resultType.GetBasicType();
     717                    index_stack[sp] = resultType.GetIndex();
     718                    sp++;
     719
     720                    break;
     721                }
     722
    291723                if(term[0]=='\"'){
    292724                    //リテラル文字列
     
    298730StrLiteral:
    299731
    300                     if( baseType.IsObject() ){
    301                         if( baseType.IsStringObject() ){
    302                             //要求タイプがStringのとき
    303 
    304                             //String型オブジェクトを生成
    305                             NewStringObject(UseReg,term);
    306 
    307                             extern CClass *pobj_StringClass;
    308                             type_stack[sp]=DEF_OBJECT;
    309                             index_stack[sp]=(LONG_PTR)pobj_StringClass;
    310                             bLiteralCalculation=0;
    311 
    312                             if(bXmm) pobj_reg->LockXmmReg();
    313                             else pobj_reg->LockReg();
    314 
    315                             sp++;
    316                             break;
    317                         }
     732                    if( baseType.IsObject() || baseType.IsNull() ){
     733                        //要求タイプがオブジェクト、または未定のとき
     734
     735                        //String型オブジェクトを生成
     736                        NewStringObject(UseReg,term);
     737
     738                        extern CClass *pobj_StringClass;
     739                        type_stack[sp]=DEF_OBJECT;
     740                        index_stack[sp]=(LONG_PTR)pobj_StringClass;
     741                        bLiteralCalculation=0;
     742
     743                        if(bXmm) pobj_reg->LockXmmReg();
     744                        else pobj_reg->LockReg();
     745
     746                        sp++;
     747                        break;
    318748                    }
    319749
     
    353783                    // 何らかの識別子
    354784
    355                     //////////////////////////////////////
    356                     // 関数(DLL、ユーザー定義、組み込み)
    357                     //////////////////////////////////////
    358 
    359                     i2=GetCallProcName(term,temporary);
    360                     if(term[i2]=='('){
    361                         i4=GetStringInPare_RemovePare(temp2,term+i2+1);
    362 
    363                         void *pInfo;
    364                         int idProc=GetProc(temporary,(void **)&pInfo);
    365 
    366                         Type resultType;
    367                         if(idProc){
    368                             //閉じカッコ")"に続く文字がNULLでないとき
    369                             if(term[i2+1+i4+1]!='\0'){
    370                                 if( term[i2+1+i4+1] == '.'
    371                                     || term[i2+1+i4+1] == 1 && term[i2+1+i4+2] == ESC_PSMEM ){
    372                                         goto NonProc;
    373                                 }
    374                                 else{
    375                                     SetError(42,NULL,cp);
     785                    bool isLiteral;
     786                    if( TermOpe( term, baseType, resultType, isLiteral, &bUseHeap[sp] ) ){
     787                        if(resultType.IsNull()){
     788                            //戻り値が存在しないとき
     789                            for(i2=0;;i2++){
     790                                if(term[i2]=='('||term[i2]=='\0'){
     791                                    term[i2]=0;
     792                                    break;
    376793                                }
    377794                            }
    378 
    379 
    380                             //////////////////////////////////////////////////////
    381                             /////    レジスタ資源のバックアップ
    382                             {   BACKUP_REGISTER_RESOURCE
    383                             //////////////////////////////////////////////////////
    384 
    385 
    386                                 ////////////////
    387                                 // 呼び出し
    388                                 ////////////////
    389 
    390                                 CallProc(idProc,pInfo,temporary,temp2,resultType);
    391                                 if(resultType.IsNull()){
    392                                     //戻り値が存在しないとき
    393                                     for(i2=2;;i2++){
    394                                         if(term[i2]=='('||term[i2]=='\0'){
    395                                             term[i2]=0;
    396                                             break;
    397                                         }
    398                                     }
    399                                     SetError(38,term,cp);
    400 
    401                                     //レジスタ資源を復元
    402                                     RESTORE_REGISTER_RESOURCE
    403 
    404                                     goto error;
     795                            SetError(38,term,cp);
     796
     797                            goto error;
     798                        }
     799
     800                        type_stack[sp] = resultType.GetBasicType();
     801                        index_stack[sp] = resultType.GetIndex();
     802
     803                        if( !isLiteral ){
     804                            bLiteralCalculation=0;
     805                        }
     806
     807                        if( resultType.GetBasicType() & FLAG_CAST ){
     808                            // 型名のみ
     809                            SetError();
     810                        }
     811                        else{
     812                            if( resultType.IsReal() == false && UseReg==REG_R14 ){
     813                                //mov qword ptr[rsp+offset],r14     ※スタックフレームを利用
     814                                pobj_sf->push(REG_R14);
     815                            }
     816                            if( resultType.IsReal() && XmmReg==REG_XMM4 ){
     817                                if(resultType.IsDouble()){
     818                                    //movsd qword ptr[rsp+offset],xmm4  ※スタックフレームを利用
     819                                    pobj_sf->push(REG_XMM4,sizeof(double));
    405820                                }
    406 
    407 
    408                                 /////////////////////
    409                                 // 戻り値の処理
    410                                 /////////////////////
    411 
    412                                 //大きな型への暗黙の変換
    413                                 type_stack[sp]=AutoBigCast(baseType.GetBasicType(),resultType.GetBasicType());
    414                                 index_stack[sp] = resultType.GetIndex();
    415                                 bLiteralCalculation=0;
    416 
    417                                 if( type_stack[sp] != resultType.GetBasicType() ){
    418                                     // 大きな型へ変換された場合
    419                                     // ※レジスタの値をキャストする
    420                                     ExtendRegToBigType( REG_RAX, type_stack[sp], resultType.GetBasicType() );
     821                                if(resultType.IsSingle()){
     822                                    //movss dword ptr[rsp+offset],xmm4  ※スタックフレームを利用
     823                                    pobj_sf->push(REG_XMM4,sizeof(float));
    421824                                }
    422 
    423                                 SetUseRegFromRax(resultType.GetBasicType(),UseReg,XmmReg);
    424 
    425                                 if(resultType.IsReal()) bXmm=1;
    426                                 else bXmm=0;
    427 
    428                             /////////////////////////////////////////////
    429                             //////   レジスタ資源を復元
    430                                 RESTORE_REGISTER_RESOURCE
    431                             }////////////////////////////////////////////
    432 
    433 
    434                             if(bXmm) pobj_reg->LockXmmReg();
    435                             else pobj_reg->LockReg();
    436 
    437                             if(resultType.IsStruct()){
    438                                 //構造体が戻ったときはヒープ領域にインスタンスが格納されている
    439                                 //※後にfreeする必要あり
    440                                 bUseHeap[sp]=1;
    441825                            }
    442826
    443                             sp++;
    444                             break;
    445                         }
    446                         else if(GetConstCalcBuffer(temporary,temp2,temp3)){
    447                             /////////////////////////
    448                             // マクロ関数
    449                             /////////////////////////
    450 
    451                             //閉じカッコ")"に続く文字がNULLでないときはエラーにする
    452                             if(term[i2+1+i4+1]!='\0') SetError(42,NULL,cp);
    453 
    454                             //マクロ関数の場合
    455                             NumOpe(&UseReg,temp3,Type(),resultType);
    456 
    457                             if(!IS_LITERAL(resultType.GetIndex())){
    458                                 //リテラル値ではなかったとき
    459                                 bLiteralCalculation=0;
     827                            if( resultType.IsReal() ){
     828                                pobj_reg->LockXmmReg();
    460829                            }
    461 
    462                             type_stack[sp] = resultType.GetBasicType();
    463                             index_stack[sp] = resultType.GetIndex();
    464 
    465                             if(resultType.IsReal()) pobj_reg->LockXmmReg();
    466                             else pobj_reg->LockReg();
    467 
    468                             sp++;
    469                             break;
    470                         }
    471                     }
    472 NonProc:
    473 
    474 
    475                     //インデクサ(getアクセサ)
    476                     char variable[VN_SIZE],array_element[VN_SIZE];
    477                     GetArrayElement(term,variable,array_element);
    478                     if(array_element[0]){
    479                         Type resultType;
    480                         GetVarType(variable,resultType,0);
    481                         if( resultType.IsObject() ){
    482                             CallIndexerGetterProc(UseReg,&resultType.GetClass(),variable,array_element,resultType);
    483                             type_stack[sp]=resultType.GetBasicType();
    484                             index_stack[sp]=resultType.GetIndex();
    485                             bLiteralCalculation=0;
    486 
    487                             if(resultType.IsReal()) pobj_reg->LockXmmReg();
    488                             else pobj_reg->LockReg();
    489                             sp++;
    490                             break;
    491                         }
     830                            else{
     831                                pobj_reg->LockReg();
     832                            }
     833                        }
     834
     835                        sp++;
     836                        break;
    492837                    }
    493838
     
    516861
    517862                        pobj_reg->LockReg();
    518                         sp++;
    519                         break;
    520                     }
    521 
    522 
    523                     RELATIVE_VAR RelativeVar;
    524                     Type varType;
    525                     if(GetVarOffset(
    526                         false,  //エラー表示あり
    527                         false,  //読み込み専用
    528                         term,
    529                         &RelativeVar,varType)){
    530                         //////////
    531                         // 変数
    532                         //////////
    533 
    534                         //大きな型への暗黙の変換
    535                         type_stack[sp]=AutoBigCast(baseType.GetBasicType(),varType.GetBasicType());
    536                         index_stack[sp] = varType.GetIndex();
    537                         bLiteralCalculation=0;
    538 
    539                         if(varType.GetBasicType()&FLAG_PTR){
    540                             //配列ポインタ
    541                             type_stack[sp]=GetPtrType(varType.GetBasicType()^FLAG_PTR);
    542 
    543                             SetVarPtrToReg(UseReg,&RelativeVar);
    544                         }
    545                         else if(varType.IsReal()){
    546                             //実数型
    547                             bXmm=1;
    548 
    549                             if( varType.IsDouble() )
    550                                 SetXmmReg_DoubleVariable(&RelativeVar,XmmReg);
    551                             if( varType.IsSingle() )
    552                                 SetXmmReg_SingleVariable(&RelativeVar,XmmReg);
    553                         }
    554                         else if( varType.IsWhole() || varType.IsObject()){
    555                             //整数型
    556                             SetReg_WholeVariable(varType.GetBasicType(),&RelativeVar,UseReg);
    557                         }
    558                         else if( varType.IsStruct() ){
    559                             //構造体ポインタをUseRegへ格納(構造体は値型)
    560                             SetVarPtrToReg(UseReg,&RelativeVar);
    561                         }
    562                         else SetError(11,term,cp);
    563 
    564                         if( type_stack[sp] != varType.GetBasicType() ){
    565                             // 大きな型へ変換された場合
    566                             // ※レジスタの値をキャストする
    567                             ExtendRegToBigType( UseReg, type_stack[sp], varType.GetBasicType() );
    568                         }
    569 
    570                         if(bXmm==0&&UseReg==REG_R14){
    571                             //mov qword ptr[rsp+offset],r14     ※スタックフレームを利用
    572                             pobj_sf->push(REG_R14);
    573                         }
    574                         if(bXmm&&XmmReg==REG_XMM4){
    575                             if(varType.IsDouble()){
    576                                 //movsd qword ptr[rsp+offset],xmm4  ※スタックフレームを利用
    577                                 pobj_sf->push(REG_XMM4,sizeof(double));
    578                             }
    579                             if(varType.IsSingle()){
    580                                 //movss dword ptr[rsp+offset],xmm4  ※スタックフレームを利用
    581                                 pobj_sf->push(REG_XMM4,sizeof(float));
    582                             }
    583                         }
    584 
    585                         if(bXmm) pobj_reg->LockXmmReg();
    586                         else pobj_reg->LockReg();
    587863                        sp++;
    588864                        break;
     
    622898                        }
    623899                    }
    624 
    625 
    626                     //////////////
    627                     // 型名の場合
    628                     //////////////
    629                     Type tempType;
    630                     if( Type::StringToType( term, tempType ) ){
    631                         type_stack[sp] = tempType.GetBasicType() | FLAG_CAST;
    632                         index_stack[sp] = tempType.GetIndex();
    633                         sp++;
    634                         break;
    635                     }
    636 
    637 
    638                     /////////////////////////////////
    639                     // プロパティ用のメソッド
    640                     /////////////////////////////////
    641 
    642                     //配列要素を排除
    643                     char VarName[VN_SIZE],ArrayElements[VN_SIZE];
    644                     GetArrayElement(term,VarName,ArrayElements);
    645 
    646                     if(GetSubHash(VarName,0)){
    647 
    648                         //////////////////////////////////////////////////////
    649                         /////    レジスタ資源のバックアップ
    650                         {   BACKUP_REGISTER_RESOURCE
    651                         //////////////////////////////////////////////////////
    652 
    653                             Type resultType;
    654                             CallPropertyMethod(term,NULL,resultType);
    655 
    656                             //大きな型への暗黙の変換
    657                             type_stack[sp]=AutoBigCast(baseType.GetBasicType(),resultType.GetBasicType());
    658                             index_stack[sp]=resultType.GetIndex();
    659                             bLiteralCalculation=0;
    660 
    661                             if( type_stack[sp] != resultType.GetBasicType() ){
    662                                 // 大きな型へ変換された場合
    663                                 // ※レジスタの値をキャストする
    664                                 ExtendRegToBigType( REG_RAX, type_stack[sp], resultType.GetBasicType() );
    665                             }
    666 
    667                             SetUseRegFromRax(resultType.GetBasicType(),UseReg,XmmReg);
    668 
    669                             if(IsRealNumberType(type_stack[sp])) bXmm=1;
    670                             else bXmm=0;
    671 
    672                         /////////////////////////////////////////////
    673                         //////   レジスタ資源を復元
    674                             RESTORE_REGISTER_RESOURCE
    675                         }////////////////////////////////////////////
    676 
    677                         if(type_stack[sp]==DEF_STRUCT){
    678                             //構造体が戻ったときはヒープ領域にインスタンスが格納されている
    679                             //※後にfreeする必要あり
    680                             bUseHeap[sp]=1;
    681                         }
    682 
    683                         if(bXmm) pobj_reg->LockXmmReg();
    684                         else pobj_reg->LockReg();
    685                         sp++;
    686                         break;
    687                     }
    688 
    689900
    690901
     
    735946
    736947                        if(XmmReg==REG_XMM4){
     948                            SetError();     // TODO: 未実装
    737949                            //push term
    738950                            op_push_value(i32data);
  • BasicCompiler64/Opcode.h

    r95 r97  
    315315
    316316//Compile_Var.cpp
    317 void GetWithName(char *buffer);
     317bool _member_offset(bool isErrorEnabled, bool isWriteAccess, const CClass &objClass, const char *member, RELATIVE_VAR *pRelativeVar, Type &resultType, BOOL bPrivateAccess);
    318318void SetThisPtrToReg(int reg);
    319319bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType,int *pss = NULL);
  • BasicCompiler_Common/BasicCompiler.cpp

    r92 r97  
    697697            isUnicode = true;
    698698            typeOfPtrChar = MAKE_PTR_TYPE(DEF_WORD,1);
     699            typeOfPtrUChar = MAKE_PTR_TYPE(DEF_WORD,1);
    699700        }
    700701
  • BasicCompiler_Common/BasicCompiler.h

    r88 r97  
    8181bool isUnicode = false;
    8282int typeOfPtrChar = MAKE_PTR_TYPE(DEF_SBYTE,1);
     83int typeOfPtrUChar = MAKE_PTR_TYPE(DEF_BYTE,1);
    8384
    8485char *basbuf;
  • BasicCompiler_Common/Class.cpp

    r96 r97  
    15281528        if( !objClass.IsUsing() ){
    15291529            // 未使用のクラスは無視する
    1530             if( (string)objClass.name == "CTest"){
    1531                 int test=0;
    1532             }
    15331530            continue;
    15341531        }
  • BasicCompiler_Common/Class.h

    r94 r97  
    210210    //メンバの参照方法
    211211    enum RefType{
     212        Non = 0,        // no reference member
    212213        Dot,            // obj.member
    213214        Pointer,        // obj->member
    214         Non,            // no reference member
    215215    };
    216216};
  • BasicCompiler_Common/NumOpe_GetType.cpp

    r96 r97  
    294294}
    295295
     296bool GetTermType( const char *term, Type &resultType, bool &isLiteral, bool *pIsClassName = NULL ){
     297    char parameter[VN_SIZE];
     298
     299    // Withを解決
     300    char termFull[VN_SIZE];
     301    if(term[0]=='.'){
     302        GetWithName(termFull);
     303        lstrcat(termFull,term);
     304    }
     305    else lstrcpy(termFull,term);
     306
     307    char termLeft[VN_SIZE];
     308    lstrcpy(termLeft,termFull);
     309
     310    // パース
     311    char member[VN_SIZE];
     312    CClass::RefType refType;
     313    if( SplitMemberName( termFull, termLeft, member, refType ) ){
     314        ///////////////////////////////////////////////////////////////////
     315        // オブジェクトとメンバに分解できるとき
     316        // termLeft.member
     317        ///////////////////////////////////////////////////////////////////
     318
     319        isLiteral = false;
     320
     321        // オブジェクト側の型を取得
     322        bool isClassName = false;
     323        Type leftType;
     324        if( !GetTermType( termLeft, leftType, isLiteral, &isClassName ) ){
     325            return false;
     326        }
     327
     328        if( isClassName ){
     329            // 静的メンバ/メソッドの場合
     330            goto globalArea;
     331        }
     332
     333        if( !leftType.HasMember() ){
     334            // メンバを持たない型の場合
     335            return false;
     336        }
     337
     338        const CClass &objClass = leftType.GetClass();
     339
     340
     341        ///////////////////////////////////////////////////////////////////
     342        // メンバを検索
     343        ///////////////////////////////////////////////////////////////////
     344        if( GetMemberType( objClass, member, resultType, 0, false ) ){
     345            // メンバが見つかったとき
     346            return true;
     347        }
     348
     349
     350        ///////////////////////////////////////////////////////////////////
     351        // 動的メソッドを検索
     352        ///////////////////////////////////////////////////////////////////
     353        vector<UserProc *> userProcs;
     354
     355        char methodName[VN_SIZE] ,lpPtrOffset[VN_SIZE];
     356        lstrcpy( methodName, member );
     357        GetVarFormatString(methodName,parameter,lpPtrOffset,member,refType);
     358
     359        objClass.EnumMethod( methodName, userProcs );
     360        UserProc *pUserProc;
     361        if(userProcs.size()){
     362            //オーバーロードを解決
     363            pUserProc=OverloadSolutionWithStrParam(termFull,userProcs,parameter,termLeft);
     364
     365            if( pUserProc ){
     366                resultType = pUserProc->ReturnType();
     367                return true;
     368            }
     369        }
     370
     371        return false;
     372    }
     373
     374
     375    //////////////////////////////////////////////
     376    // クラス名かどうかをチェック(静的メンバ用)
     377    //////////////////////////////////////////////
     378
     379    if( pIsClassName ){
     380        if( pobj_DBClass->check( termFull ) ){
     381            *pIsClassName = true;
     382            return true;
     383        }
     384    }
     385
     386
     387    /////////////////////////////////////////////////////////////////
     388    // グローバル属性
     389    /////////////////////////////////////////////////////////////////
     390globalArea:
     391
     392
     393    if(lstrcmpi(termFull,"This")==0){
     394        //Thisオブジェクト
     395        resultType.SetType( DEF_OBJECT, pobj_CompilingClass );
     396        return true;
     397    }
     398
     399
     400    //////////////////////////////////////
     401    // 関数(DLL、ユーザー定義、組み込み)
     402    //////////////////////////////////////
     403    char procName[VN_SIZE];
     404    char temporary[8192];
     405
     406    int i2=GetCallProcName(termFull,procName);
     407    if(termFull[i2]=='('){
     408        int i4=GetStringInPare_RemovePare(parameter,termFull+i2+1);
     409
     410        void *pProc;
     411        int idProc=GetProc(procName,(void **)&pProc);
     412
     413        if(idProc){
     414            //閉じカッコ")"に続く文字がNULLでないとき
     415            if(termFull[i2+1+i4+1]!='\0'){
     416                SetError(42,NULL,cp);
     417            }
     418
     419
     420            ////////////////
     421            // 呼び出し
     422            ////////////////
     423
     424            if( !CallProc(idProc,pProc,procName,parameter, resultType, false ) ){
     425                return false;
     426            }
     427            if( resultType.IsNull() ){
     428                //戻り値が存在しないとき
     429                return false;
     430            }
     431
     432            isLiteral = false;
     433
     434            return true;
     435        }
     436        else if(GetConstCalcBuffer(procName,parameter,temporary)){
     437            /////////////////////////
     438            // マクロ関数
     439            /////////////////////////
     440
     441            //閉じカッコ")"に続く文字がNULLでないときはエラーにする
     442            if(termFull[i2+1+i4+1]!='\0') SetError(42,NULL,cp);
     443
     444            //マクロ関数の場合
     445            if( !NumOpe_GetType(temporary,Type(),resultType) ){
     446                return false;
     447            }
     448
     449            if( !IS_LITERAL( resultType.GetIndex() ) ){
     450                //リテラル値ではなかったとき
     451                isLiteral = false;
     452            }
     453
     454            return true;
     455        }
     456    }
     457
     458
     459    ////////////////////////////////
     460    // インデクサ(getアクセサ)
     461    ////////////////////////////////
     462
     463    char VarName[VN_SIZE],ArrayElements[VN_SIZE];
     464    GetArrayElement(termFull,VarName,ArrayElements);
     465    if(ArrayElements[0]){
     466        GetVarType(VarName,resultType,false);
     467        if( resultType.IsObject() ){
     468            if( !GetReturnTypeOfIndexerGetterProc( resultType.GetClass(),resultType) ){
     469                SetError(1,NULL,cp);
     470                return false;
     471            }
     472
     473            isLiteral = false;
     474
     475            return true;
     476        }
     477    }
     478
     479
     480    ////////////////////////////////
     481    // 変数
     482    ////////////////////////////////
     483
     484    if( GetVarType( termFull, resultType, false ) ){
     485        if( resultType.GetBasicType() & FLAG_PTR ){
     486            //配列ポインタ
     487            resultType.SetBasicType( GetPtrType( resultType.GetBasicType()^FLAG_PTR ) );
     488        }
     489
     490        isLiteral = false;
     491
     492        return true;
     493    }
     494
     495
     496    /////////////////////////////////
     497    // プロパティ用のメソッド
     498    /////////////////////////////////
     499
     500    //配列要素を排除
     501    GetArrayElement(termFull,VarName,ArrayElements);
     502
     503    if(GetSubHash(VarName,0)){
     504        GetReturnTypeOfPropertyMethod(termFull,NULL,resultType);
     505
     506        isLiteral = false;
     507
     508        return true;
     509    }
     510
     511
     512    return false;
     513}
     514
    296515bool NumOpe_GetType( const char *expression, const Type &baseType, Type &resultType ){
    297516    extern int cp;
    298     int i,i2,i3,i4;
    299     char temporary[1024],temp2[1024],temp3[1024];
     517    int i,i3;
    300518
    301519    if(expression[0]=='\0'){
     
    392610                term = values[i];
    393611
     612                if( calc[i+1]%100 == CALC_AS ){
     613                    // As演算子の右辺値
     614                    //型名
     615                    if( Type::StringToType( term, resultType ) ){
     616                        resultType.SetBasicType( resultType.GetBasicType() | FLAG_CAST );
     617                    }
     618                    else{
     619                        SetError(3, term, cp );
     620                        goto error;
     621                    }
     622
     623                    type_stack[sp] = resultType.GetBasicType();
     624                    index_stack[sp] = resultType.GetIndex();
     625                    sp++;
     626
     627                    break;
     628                }
     629
    394630                if(term[0]=='\"'){
    395631StrLiteral:
    396632
    397                     if( baseType.IsStringObject() ){
    398                         //要求タイプがオブジェクトであり、Stringの受け入れが可能な場合
     633                    if( baseType.IsObject() || baseType.IsNull() ){
     634                        //要求タイプがオブジェクト、または未定のとき
    399635                        extern CClass *pobj_StringClass;
    400636                        type_stack[sp]=DEF_OBJECT;
     
    421657                    // 何らかの識別子
    422658
    423                     //////////////////////////////////////
    424                     // 関数(DLL、ユーザー定義、組み込み)
    425                     //////////////////////////////////////
    426 
    427                     i2=GetCallProcName(term,temporary);
    428                     if(term[i2]=='('){
    429                         i4=GetStringInPare_RemovePare(temp2,term+i2+1);
    430 
    431                         int idProc;
    432                         void *pProc;
    433                         idProc=GetProc(temporary,(void **)&pProc);
    434 
    435                         if(idProc){
    436                             //閉じカッコ")"に続く文字がNULLでないとき
    437                             if(term[i2+1+i4+1]!='\0'){
    438                                 if( term[i2+1+i4+1] == '.'
    439                                     || term[i2+1+i4+1] == 1 && term[i2+1+i4+2] == ESC_PSMEM ){
    440                                         goto NonProc;
    441                                 }
    442                                 else{
    443                                     SetError(42,NULL,cp);
    444                                 }
    445                             }
    446 
    447 
    448                             ////////////////
    449                             // 呼び出し
    450                             ////////////////
    451 
    452                             Type resultType;
    453                             if( !CallProc(idProc,pProc,temporary,temp2, resultType, false ) ){
    454                                 goto error;
    455                             }
    456                             if( resultType.IsNull() ){
    457                                 //戻り値が存在しないとき
    458                                 goto error;
    459                             }
    460 
    461                             type_stack[sp] = resultType.GetBasicType();
    462                             index_stack[sp] = resultType.GetIndex();
    463 
     659                    bool isLiteral = true;
     660                    if( GetTermType( term, resultType, isLiteral ) ){
     661                        type_stack[sp] = resultType.GetBasicType();
     662                        index_stack[sp] = resultType.GetIndex();
     663
     664                        if( !isLiteral ){
    464665                            bLiteralCalculation=0;
    465 
    466                             sp++;
    467                             break;
    468666                        }
    469                         else if(GetConstCalcBuffer(temporary,temp2,temp3)){
    470                             /////////////////////////
    471                             // マクロ関数
    472                             /////////////////////////
    473 
    474                             //閉じカッコ")"に続く文字がNULLでないときはエラーにする
    475                             if(term[i2+1+i4+1]!='\0') SetError(42,NULL,cp);
    476 
    477                             //マクロ関数の場合
    478                             Type tempType;
    479                             NumOpe_GetType(temp3,Type(),tempType);
    480 
    481                             if(!IS_LITERAL(tempType.GetIndex())){
    482                                 //リテラル値ではなかったとき
    483                                 bLiteralCalculation=0;
    484                             }
    485 
    486                             type_stack[sp] = tempType.GetBasicType();
    487                             index_stack[sp] = tempType.GetIndex();
    488 
    489                             sp++;
    490                             break;
    491                         }
    492                     }
    493 NonProc:
    494 
    495                     //インデクサ(getアクセサ)
    496                     char VarName[VN_SIZE],ArrayElements[VN_SIZE];
    497                     GetArrayElement(term,VarName,ArrayElements);
    498                     if(ArrayElements[0]){
    499                         Type type;
    500                         GetVarType(VarName,type,false);
    501                         if( type.IsObject() ){
    502                             if( !GetReturnTypeOfIndexerGetterProc( type.GetClass(),type) ){
    503                                 SetError(1,NULL,cp);
    504                                 goto error;
    505                             }
    506                             type_stack[sp]=type.GetBasicType();
    507                             index_stack[sp]=type.GetIndex();
    508                             bLiteralCalculation=0;
    509 
    510                             sp++;
    511                             break;
    512                         }
     667
     668                        sp++;
     669                        break;
    513670                    }
    514671
     
    526683                        }
    527684                        bLiteralCalculation = 0;
    528                         sp++;
    529                         break;
    530                     }
    531 
    532                     if( (string)term == "s.GetType().Name" ){
    533                         int test=0;
    534                     }
    535 
    536 
    537                     Type varType;
    538                     if( GetVarType(term,varType,0) ){
    539                         //////////
    540                         // 変数
    541                         //////////
    542 
    543                         if( varType.GetBasicType() & FLAG_PTR ){
    544                             //配列ポインタ
    545                             type_stack[sp]=GetPtrType( varType.GetBasicType()^FLAG_PTR );
    546                         }
    547                         else{
    548                             type_stack[sp]=varType.GetBasicType();
    549                         }
    550                         index_stack[sp] = varType.GetIndex();
    551 
    552                         bLiteralCalculation=0;
    553685                        sp++;
    554686                        break;
     
    586718
    587719
    588                     //////////////
    589                     // 型名の場合
    590                     //////////////
    591 
    592                     Type tempType;
    593                     if( Type::StringToType( term, tempType ) ){
    594                         type_stack[sp] = tempType.GetBasicType() | FLAG_CAST;
    595                         index_stack[sp] = tempType.GetIndex();
    596                         sp++;
    597                         break;
    598                     }
    599 
    600 
    601720                    /////////////////////////////////
    602721                    // プロパティ用のメソッド
     
    604723
    605724                    //配列要素を排除
     725                    char VarName[VN_SIZE],ArrayElements[VN_SIZE];
    606726                    GetArrayElement(term,VarName,ArrayElements);
    607727
    608728                    if(GetSubHash(VarName,0)){
     729                        SetError();
    609730                        Type tempType;
    610731                        GetReturnTypeOfPropertyMethod(term,NULL,tempType);
  • BasicCompiler_Common/OldStatement.cpp

    r76 r97  
    103103        else if(varType.IsObject()){
    104104            varType.SetBasicType( DEF_OBJECT );
    105             if( varType.IsStringObject() ){
     105            if( varType.IsStringClass() ){
    106106                varType.SetBasicType( DEF_STRING );
    107107            }
  • BasicCompiler_Common/Procedure.h

    r92 r97  
    8585class UserProc : public Procedure
    8686{
     87#ifdef _DEBUG
     88public:
     89    string _paramStr;
     90#endif
    8791
    8892private:
  • BasicCompiler_Common/Subroutine.cpp

    r94 r97  
    8383    }
    8484}
     85bool SplitMemberName( const char *desc, char *object, char *member, CClass::RefType &refType ){
     86    int lastIndex = -1;
     87    for( int i=0; desc[i]; i++ ){
     88        if( desc[i] == '(' ){
     89            i=JumpStringInPare(desc,i+1);
     90            continue;
     91        }
     92        else if( desc[i] == '[' ){
     93            i=JumpStringInBracket(desc,i+1);
     94            continue;
     95        }
     96        else if(desc[i]=='.'||(desc[i]==1&&desc[i+1]==ESC_PSMEM)){
     97            lastIndex = i;
     98        }
     99    }
     100    if( lastIndex == -1 ){
     101        return false;
     102    }
     103
     104    if(desc[lastIndex]=='.'){
     105        lstrcpy(member,desc+lastIndex+1);
     106        refType = CClass::Dot;
     107    }
     108    else{
     109        lstrcpy(member,desc+lastIndex+2);
     110        refType = CClass::Pointer;
     111    }
     112
     113    if( object ){
     114        lstrcpy( object, desc );
     115        object[lastIndex]=0;
     116    }
     117
     118    return true;
     119}
    85120bool SplitMemberName( const char *desc, char *object, char *member ){
    86     int i;
    87     for(i=lstrlen(desc)-1;i>=0;i--){
    88         if(desc[i]=='.'||(desc[i]==1&&desc[i+1]==ESC_PSMEM))
    89             break;
    90     }
    91     if(i==-1) return false;
    92     else{
    93         if(desc[i]=='.')
    94             lstrcpy(member,desc+i+1);
    95         else
    96             lstrcpy(member,desc+i+2);
    97 
    98         if( object ){
    99             lstrcpy( object, desc );
    100             object[i]=0;
    101         }
    102     }
    103 
    104     return true;
     121    CClass::RefType dummyRefType;
     122    return SplitMemberName( desc, object, member, dummyRefType );
    105123}
    106124
     
    565583    SubNum++;
    566584
    567 
    568585    UserProc *pUserProc = new UserProc( temporary, kind, isMacro, isCdecl, isExport );
    569586    pUserProc->SetParentClass( pobj_c );
     
    580597    // ※第1パラメータにに指定するデータの例:"( s As String ) As String"
    581598    pUserProc->SetParamsAndReturnType( buffer + i, nowLine, isStatic );
     599
     600#ifdef _DEBUG
     601    pUserProc->_paramStr = buffer + i;
     602#endif
    582603
    583604
  • BasicCompiler_Common/Type.cpp

    r88 r97  
    417417    return false;
    418418}
    419 bool Type::IsStringObject() const
     419bool Type::IsObjectClass() const
     420{
     421    if( basicType == DEF_OBJECT ){
     422        if( lstrcmp( pClass->name,"Object")==0){
     423            return true;
     424        }
     425    }
     426    return false;
     427}
     428bool Type::IsStringClass() const
    420429{
    421430    if( basicType == DEF_OBJECT ){
     
    438447    if( basicType == DEF_ANY ){
    439448        return true;
     449    }
     450    return false;
     451}
     452
     453bool Type::HasMember() const
     454{
     455    if( NATURAL_TYPE( basicType ) == DEF_OBJECT
     456        || NATURAL_TYPE( basicType ) == DEF_STRUCT ){
     457            return true;
    440458    }
    441459    return false;
  • BasicCompiler_Common/Type.h

    r79 r97  
    105105    bool IsObject() const;
    106106    bool IsObjectPtr() const;
    107     bool IsStringObject() const;
     107    bool IsObjectClass() const;
     108    bool IsStringClass() const;
    108109    bool IsVoidPtr() const;
    109110    bool IsAny() const;
     111
     112    // オブジェクトや構造体など、メンバを持つ型かどうかを判別する
     113    bool HasMember() const;
    110114
    111115    const string ToString() const;
  • BasicCompiler_Common/VariableOpe.cpp

    r88 r97  
    240240}
    241241
     242void GetWithName(char *buffer){
     243    extern WITHINFO WithInfo;
     244    int i;
     245
     246    buffer[0]=0;
     247    for(i=0;i<WithInfo.num;i++)
     248        lstrcat(buffer,WithInfo.ppName[i]);
     249}
     250
    242251bool FormatUseProcReturnObject( const char *term, char *procName, char *parameter, CClass::RefType &refType, char *member ){
    243252    int p1 = 0, p2 = 0;
     
    11731182    }
    11741183
    1175 
    11761184    //構文を解析
    11771185    int SubScripts[MAX_ARRAYDIM];
  • BasicCompiler_Common/VariableOpe.h

    r79 r97  
    1414int GetPtrType(int type);
    1515BOOL GetTypeName(int type,LONG_PTR lpIndex,char *name);
     16void GetWithName(char *buffer);
    1617bool FormatUseProcReturnObject( const char *term, char *procName, char *parameter, CClass::RefType &refType, char *member );
    1718BOOL GetVarFormatString(char *buffer,char *array,char *array2,char *NestMember, CClass::RefType &refType );
     
    2122void GetArrange(char *variable,char *variAnswer,int *SubScripts);
    2223int GetTypeFromSimpleName(char *variable);
     24bool GetMemberType( const CClass &objClass, const char *lpszMember, Type &resultType, BOOL bPrivateAccess, bool isErrorEnabled);
    2325bool GetVarType( const char *nameBuffer, Type &resultType, bool isError);
    2426bool GetVarOffsetReadOnly(const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType,int *pss = NULL );
  • BasicCompiler_Common/calculation.cpp

    r79 r97  
    820820    for(i=0,sp=0;i<pnum;i++){
    821821
    822         //型チェック(正常でない場合はエラーにする)
    823         TypeErrorCheck(stack,sp,calc[i]%100);
     822        if( enableerror ){
     823            //型チェック(正常でない場合はエラーにする)
     824            TypeErrorCheck(stack,sp,calc[i]%100);
     825        }
    824826
    825827        idCalc=calc[i]%100;
     
    10881090#pragma optimize("", on)
    10891091
    1090 BOOL GetConstCalcBuffer(char *name,char *Parameter,char *pCalcBuffer){
     1092BOOL GetConstCalcBuffer(const char *name,const char *Parameter,char *pCalcBuffer){
    10911093    extern HANDLE hHeap;
    10921094    int i2,i3,i4,num;
     
    12561258                    pDllProc=GetDeclareHash(temporary);
    12571259                    if(pDllProc){
    1258                         if( pDllProc->ReturnType().IsStringObject() ){
     1260                        if( pDllProc->ReturnType().IsStringClass() ){
    12591261                            return 1;
    12601262                        }
     
    12661268                    pUserProc=GetSubHash(temporary);
    12671269                    if(pUserProc){
    1268                         if( pUserProc->ReturnType().IsStringObject() ){
     1270                        if( pUserProc->ReturnType().IsStringClass() ){
    12691271                            return 1;
    12701272                        }
     
    13071309                    return -1;
    13081310                }
    1309                 if( varType.IsStringObject() ){
     1311                if( varType.IsStringClass() ){
    13101312                    return 1;
    13111313                }
     
    15261528    }
    15271529
     1530    calc[*pnum]=0;
     1531
    15281532    return 1;
    15291533}
  • BasicCompiler_Common/common.h

    r96 r97  
    9494extern bool isUnicode;
    9595extern int typeOfPtrChar;
     96extern int typeOfPtrUChar;
    9697
    9798
     
    294295//hash.cpp
    295296int hash_default(const char *name);
    296 CONSTINFO *GetConstHash(char *name);
     297CONSTINFO *GetConstHash(const char *name);
    297298DllProc *GetDeclareHash(char *name);
    298299void GetOverloadSubHash( const char *lpszName, std::vector<UserProc *> &subs );
     
    418419int NeutralizationType(int type1,LONG_PTR index1,int type2,LONG_PTR index2);
    419420DWORD GetLiteralValue(char *value,_int64 *pi64,int BaseType);
    420 BOOL GetConstCalcBuffer(char *name,char *Parameter,char *pCalcBuffer);
     421BOOL GetConstCalcBuffer(const char *name,const char *Parameter,char *pCalcBuffer);
    421422DWORD GetConstValue(char *name,double *dbl,char *buffer,LONG_PTR *plpIndex);
    422423bool IsStringObjectType(const Type &TypeInfo);
     
    435436int GetProc(char *name,void **ppInfo);
    436437void SplitObjectName(const char *name,char *ObjectName,int *pRefType);
     438bool SplitMemberName( const char *desc, char *object, char *member, CClass::RefType &refType );
    437439bool SplitMemberName( const char *desc, char *object, char *member );
    438440bool CallProc( int kind, const void *pProc, const char *fullCallName, const char *lpszParms, Type &resultType, bool isCallOn = true );
  • BasicCompiler_Common/hash.cpp

    r95 r97  
    1717}
    1818
    19 CONSTINFO *GetConstHash(char *name){
     19CONSTINFO *GetConstHash(const char *name){
    2020    //ハッシュ値を取得
    2121    int key;
Note: See TracChangeset for help on using the changeset viewer.