Changeset 11 in dev for BasicCompiler64


Ignore:
Timestamp:
Dec 8, 2006, 3:25:27 AM (17 years ago)
Author:
dai_9181
Message:

Const変数の書き込み規制を有効化(グローバル/ローカル変数のみ)
定数オブジェクトと定数メンバは未実装。

Location:
BasicCompiler64
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler64/BasicCompiler.vcproj

    r6 r11  
    13861386                    >
    13871387                </File>
    1388                 <File
    1389                     RelativePath="..\BasicCompiler_Common\Variable.cpp"
    1390                     >
    1391                 </File>
    13921388                <Filter
    13931389                    Name="Intermediate"
     
    15111507                    <File
    15121508                        RelativePath="..\BasicCompiler_Common\Const.h"
     1509                        >
     1510                    </File>
     1511                </Filter>
     1512                <Filter
     1513                    Name="Variable"
     1514                    >
     1515                    <File
     1516                        RelativePath="..\BasicCompiler_Common\Variable.cpp"
     1517                        >
     1518                    </File>
     1519                    <File
     1520                        RelativePath="..\BasicCompiler_Common\Variable.h"
    15131521                        >
    15141522                    </File>
  • BasicCompiler64/CParameter.cpp

    r3 r11  
    616616                int VarType;
    617617                LONG_PTR lpVarIndex;
    618                 if(!GetVarOffset(1,Parms[i2],&VarType,&RelativeVar,&lpVarIndex)) continue;
     618                if(!GetVarOffsetReadOnly(
     619                    Parms[i2],
     620                    &VarType,
     621                    &RelativeVar,
     622                    &lpVarIndex)) continue;
    619623
    620624                if(DummyTypeInfo.type!=DEF_ANY){
  • BasicCompiler64/Compile_Calc.cpp

    r3 r11  
    535535    //変数アドレスを取得
    536536    RELATIVE_VAR VarRelativeVar;
    537     if(!GetVarOffset(
    538         1,
     537    if(!GetVarOffsetReadWrite(
    539538        variable,
    540539        &VarType,
  • BasicCompiler64/Compile_CallProc.cpp

    r3 r11  
    187187    RELATIVE_VAR RelativeVar;
    188188    LONG_PTR lp;
    189     GetVarOffset(1,variable,&i,&RelativeVar,&lp);
     189    GetVarOffsetReadOnly(variable,&i,&RelativeVar,&lp);
    190190    SetVarPtrToReg(REG_RAX,&RelativeVar);
    191191
     
    408408            else{
    409409                RELATIVE_VAR RelativeVar;
    410                 if(!GetVarOffset(1,ObjectName,&i2,&RelativeVar,0)) return -1;
     410                if(!GetVarOffsetReadOnly(ObjectName,&i2,&RelativeVar,0)) return -1;
    411411                SetVarPtrToReg(REG_RCX,&RelativeVar);
    412412
  • BasicCompiler64/Compile_Func.cpp

    r3 r11  
    7474    int SubScripts[MAX_ARRAYDIM];
    7575    RELATIVE_VAR RelativeVar;
    76     if(!GetVarOffset(1,tempParm,&type,&RelativeVar,&lpIndex,SubScripts)) return;
     76    if(!GetVarOffsetReadOnly(tempParm,&type,&RelativeVar,&lpIndex,SubScripts)) return;
    7777
    7878
     
    147147                RELATIVE_VAR RelativeVar;
    148148                int type;
    149                 if(!GetVarOffset(1,ObjectName,&type,&RelativeVar,(LONG_PTR *)&pobj_c)) return;
     149                if(!GetVarOffsetReadOnly(ObjectName,&type,&RelativeVar,(LONG_PTR *)&pobj_c)) return;
    150150                SetVarPtrToReg(REG_RCX,&RelativeVar);
    151151
     
    217217
    218218    //変数のアドレスを取得
    219     if(!GetVarOffset(1,Parameter,&type,&RelativeVar,0)) return;
     219    if(!GetVarOffsetReadOnly(Parameter,&type,&RelativeVar,0)) return;
    220220
    221221    SetVarPtrToReg(REG_RAX,&RelativeVar);
  • BasicCompiler64/Compile_ProcOp.cpp

    r3 r11  
    326326
    327327        lstrcpy(LocalVar[MaxLocalVarNum].name,psi->pRealParmInfo[i3].name);
     328
     329        // TODO: パラメータのConst定義の指定が未完成
     330        LocalVar[MaxLocalVarNum].bConst=false;
    328331
    329332        LocalVar[MaxLocalVarNum].bArray=psi->pRealParmInfo[i3].bArray;
     
    736739            temp="_System_ReturnValue";
    737740        else temp=psi->name;
    738         GetVarOffset(1,temp,&i3,&RelativeVar,&lpIndex);
     741        GetVarOffsetReadWrite(temp,&i3,&RelativeVar,&lpIndex);
    739742
    740743        i3=psi->ReturnType;
  • BasicCompiler64/Compile_Statement.cpp

    r3 r11  
    11791179
    11801180        LONG_PTR lpIndex;
    1181         RELATIVE_VAR RelativeVar;
    1182         GetVarOffset(1,temporary,&type,&RelativeVar,&lpIndex);
     1181        type = GetVarType(temporary, &lpIndex, 1);
    11831182
    11841183        sprintf(temp2,"_System_InputDataPtr[%d]=VarPtr(%s)",i4,temporary);
  • BasicCompiler64/Compile_Var.cpp

    r9 r11  
    179179    return 1;
    180180}
    181 BOOL GetMemberOffset(BOOL bError,CClass *pobj_c,char *member,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpNestIndex,BOOL bPrivateAccess){
     181BOOL GetMemberOffset(bool ErrorEnabled,CClass *pobj_c,char *member,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpNestIndex,BOOL bPrivateAccess){
    182182    int i,offset;
    183183
     
    202202    offset=GetSizeOfClassMember(pobj_c,VarName,&i);
    203203    if(i==pobj_c->iMemberNum){
    204         if(bError) SetError(103,VarName,cp);
     204        if(ErrorEnabled) SetError(103,VarName,cp);
    205205        return 0;
    206206    }
     
    211211        //同一クラスオブジェクトの場合はプライベートアクセスを容認する
    212212        if(pobj_c->ppobj_Member[i]->dwAccess==ACCESS_NON){
    213             if(bError) SetError(107,VarName,cp);
     213            if(ErrorEnabled) SetError(107,VarName,cp);
    214214            return 0;
    215215        }
     
    218218        if((bPrivateAccess==0&&pobj_c->ppobj_Member[i]->dwAccess==ACCESS_PRIVATE)||
    219219            pobj_c->ppobj_Member[i]->dwAccess==ACCESS_NON){
    220             if(bError) SetError(107,VarName,cp);
     220            if(ErrorEnabled) SetError(107,VarName,cp);
    221221            return 0;
    222222        }
    223223        else if(bPrivateAccess==0&&pobj_c->ppobj_Member[i]->dwAccess==ACCESS_PROTECTED){
    224             if(bError) SetError(108,VarName,cp);
     224            if(ErrorEnabled) SetError(108,VarName,cp);
    225225            return 0;
    226226        }
     
    239239    else{
    240240        if(lpPtrOffset[0]){
    241             if(bError) SetError(16,member,cp);
     241            if(ErrorEnabled) SetError(16,member,cp);
    242242            return 0;
    243243        }
     
    256256        //配列オフセット
    257257        if(!GetArrayOffset(pobj_c->ppobj_Member[i]->SubScripts,array,*pType,pobj_c->ppobj_Member[i]->TypeInfo.u.lpIndex)){
    258             if(bError) SetError(14,member,cp);
     258            if(ErrorEnabled) SetError(14,member,cp);
    259259        }
    260260    }
     
    268268        if(*pType==DEF_OBJECT){
    269269            if(RefType!=DEF_OBJECT){
    270                 if(bError) SetError(104,member,cp);
     270                if(ErrorEnabled) SetError(104,member,cp);
    271271                return 0;
    272272            }
     
    278278                //pObj[n].member
    279279                if(RefType!=DEF_OBJECT){
    280                     if(bError) SetError(104,member,cp);
     280                    if(ErrorEnabled) SetError(104,member,cp);
    281281                    return 0;
    282282                }
     
    291291                //pObj->member
    292292                if(RefType!=DEF_PTR_OBJECT){
    293                     if(bError) SetError(104,member,cp);
     293                    if(ErrorEnabled) SetError(104,member,cp);
    294294                    return 0;
    295295                }
     
    315315                //ppObj[n]->member
    316316                if(RefType!=DEF_PTR_OBJECT){
    317                     if(bError) SetError(104,member,cp);
     317                    if(ErrorEnabled) SetError(104,member,cp);
    318318                    return 0;
    319319                }
     
    329329            }
    330330            else{
    331                 if(bError) SetError(104,member,cp);
     331                if(ErrorEnabled) SetError(104,member,cp);
    332332                return 0;
    333333            }
    334334        }
    335335
    336         if(!GetMemberOffset(bError,
     336        if(!GetMemberOffset(ErrorEnabled,
    337337            pobj_c->ppobj_Member[i]->TypeInfo.u.pobj_Class,
    338338            NestMember,
     
    371371    SetReg_WholeVariable(DEF_PTR_VOID,&RelativeVar,reg);
    372372}
    373 BOOL GetVarOffset(BOOL bError,char *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss){
     373BOOL GetVarOffset(bool ErrorEnabled,bool WriteAccess,char *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss){
    374374    extern BOOL bCompilingGlobal;
    375375    int i,RefType;
     
    387387    LONG_PTR lpIndex;
    388388    int *pSubScripts;
     389    bool bConst = false;
    389390
    390391
     
    423424            if(plpIndex) *plpIndex=lpIndex;
    424425            pSubScripts=LocalVar[i].SubScripts;
     426            bConst = LocalVar[i].bConst;
    425427
    426428            goto ok;
     
    463465
    464466        pRelativeVar->dwKind=VAR_DIRECTMEM;
    465         if(!GetMemberOffset(bError,pobj_CompilingClass,variable,pType,pRelativeVar,&lpIndex,1)) return 0;
     467        if(!GetMemberOffset(ErrorEnabled,pobj_CompilingClass,variable,pType,pRelativeVar,&lpIndex,1)) return 0;
    466468        if(plpIndex) *plpIndex=lpIndex;
    467469        return 1;
     
    534536    }
    535537
    536     if(bError) SetError(3,variable,cp);
     538    if(ErrorEnabled) SetError(3,variable,cp);
    537539    pRelativeVar->dwKind=NON_VAR;
    538540    return 0;
     
    563565    if(plpIndex) *plpIndex=lpIndex;
    564566    pSubScripts=GlobalVar[i].SubScripts;
     567    bConst = GlobalVar[i].bConst;
    565568
    566569
     
    568571ok:
    569572
     573    if(bConst && WriteAccess){
     574        //Const定義の変数に書き込みアクセスをしようとした場合
     575        SetError(61,VarName,cp);
     576    }
    570577
    571578    if(array[0]==0&&pSubScripts[0]!=-1){
     
    600607
    601608            LONG_PTR lp2;
    602             if(!GetMemberOffset(bError,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
     609            if(!GetMemberOffset(ErrorEnabled,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
    603610            if(plpIndex) *plpIndex=lp2;
    604611        }
     
    616623
    617624                LONG_PTR lp2;
    618                 if(!GetMemberOffset(bError,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
     625                if(!GetMemberOffset(ErrorEnabled,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
    619626                if(plpIndex) *plpIndex=lp2;
    620627            }
     
    634641
    635642                LONG_PTR lp2;
    636                 if(!GetMemberOffset(bError,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
     643                if(!GetMemberOffset(ErrorEnabled,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
    637644                if(plpIndex) *plpIndex=lp2;
    638645            }
     
    658665
    659666                LONG_PTR lp2;
    660                 if(!GetMemberOffset(bError,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
     667                if(!GetMemberOffset(ErrorEnabled,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
    661668                if(plpIndex) *plpIndex=lp2;
    662669            }
     
    11091116            lstrcpy(pVar->name,VarName);
    11101117            pVar->fRef=0;
    1111             if(dwFlag & DIMFLAG_CONST) pVar->bConst = 1;
    1112             else pVar->bConst = 0;
     1118            if(dwFlag & DIMFLAG_CONST) pVar->bConst = true;
     1119            else pVar->bConst = false;
    11131120            if(SubScripts[0]==-1) pVar->bArray=0;
    11141121            else pVar->bArray=1;
     
    11241131
    11251132            if(InitBuf[0]){
     1133                //初期代入時のみ、書き込みアクセスを許可する
     1134                bool bConstBack = pVar->bConst;
     1135                pVar->bConst = false;
     1136
    11261137                int result = InitLocalVar(-pVar->offset,
    11271138                    pVar->type,
     
    11361147                    OpcodeCalc(temporary);
    11371148                }
     1149
     1150                pVar->bConst = bConstBack;
    11381151            }
    11391152            else{
  • BasicCompiler64/NumOpe.cpp

    r9 r11  
    423423
    424424                    RELATIVE_VAR RelativeVar;
    425                     if(GetVarOffset(0,term,&i2,&RelativeVar,&index_stack[sp])){
     425                    if(GetVarOffset(
     426                        false,  //エラー表示あり
     427                        false,  //読み込み専用
     428                        term,
     429                        &i2,&RelativeVar,&index_stack[sp])){
    426430                        //////////
    427431                        // 変数
  • BasicCompiler64/Opcode.h

    r9 r11  
    317317void GetWithName(char *buffer);
    318318void SetThisPtrToReg(int reg);
    319 BOOL GetVarOffset(BOOL bError,char *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss=0);
     319BOOL GetVarOffset(bool ErrorEnabled,bool WriteAccess,char *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss=0);
    320320BOOL SetInitGlobalData(int offset,int type,LONG_PTR lpIndex,int *SubScripts,char *InitBuf);
    321321#define DIMFLAG_INITDEBUGVAR            1
  • BasicCompiler64/OperatorProc.cpp

    r3 r11  
    325325            int VarType;
    326326            LONG_PTR lpVarIndex;
    327             if(!GetVarOffset(
    328                 1,
     327            if(!GetVarOffsetReadOnly(
    329328                szTempVarName,
    330329                &VarType,
  • BasicCompiler64/increment.cpp

    r3 r11  
    1212    ///////////////////////////
    1313
    14     if(!GetVarOffset(
    15         1,
     14    if(!GetVarOffsetReadWrite(
    1615        lpszLeft,
    1716        &VarType,
Note: See TracChangeset for help on using the changeset viewer.