Changeset 11 in dev


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

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

Files:
29 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler32/BasicCompiler.vcproj

    r3 r11  
    736736                    </FileConfiguration>
    737737                </File>
    738                 <File
    739                     RelativePath="..\BasicCompiler_Common\Variable.cpp"
    740                     >
    741                     <FileConfiguration
    742                         Name="Debug|Win32"
    743                         >
    744                         <Tool
    745                             Name="VCCLCompilerTool"
    746                             PreprocessorDefinitions=""
    747                         />
    748                     </FileConfiguration>
    749                     <FileConfiguration
    750                         Name="Release|Win32"
    751                         >
    752                         <Tool
    753                             Name="VCCLCompilerTool"
    754                             PreprocessorDefinitions=""
    755                         />
    756                     </FileConfiguration>
    757                     <FileConfiguration
    758                         Name="English_Rel|Win32"
    759                         >
    760                         <Tool
    761                             Name="VCCLCompilerTool"
    762                             PreprocessorDefinitions=""
    763                         />
    764                     </FileConfiguration>
    765                 </File>
    766738                <Filter
    767739                    Name="Intermediate"
     
    12691241                    <File
    12701242                        RelativePath="..\BasicCompiler_Common\Const.h"
     1243                        >
     1244                    </File>
     1245                </Filter>
     1246                <Filter
     1247                    Name="Variable"
     1248                    >
     1249                    <File
     1250                        RelativePath="..\BasicCompiler_Common\Variable.cpp"
     1251                        >
     1252                        <FileConfiguration
     1253                            Name="Debug|Win32"
     1254                            >
     1255                            <Tool
     1256                                Name="VCCLCompilerTool"
     1257                                PreprocessorDefinitions=""
     1258                            />
     1259                        </FileConfiguration>
     1260                        <FileConfiguration
     1261                            Name="Release|Win32"
     1262                            >
     1263                            <Tool
     1264                                Name="VCCLCompilerTool"
     1265                                PreprocessorDefinitions=""
     1266                            />
     1267                        </FileConfiguration>
     1268                        <FileConfiguration
     1269                            Name="English_Rel|Win32"
     1270                            >
     1271                            <Tool
     1272                                Name="VCCLCompilerTool"
     1273                                PreprocessorDefinitions=""
     1274                            />
     1275                        </FileConfiguration>
     1276                    </File>
     1277                    <File
     1278                        RelativePath="..\BasicCompiler_Common\Variable.h"
    12711279                        >
    12721280                    </File>
  • BasicCompiler32/CParameter.cpp

    r3 r11  
    556556                int VarType;
    557557                LONG_PTR lpVarIndex;
    558                 if(!GetVarOffset(1,Parms[i2],&VarType,&RelativeVar,&lpVarIndex)) continue;
     558                if(!GetVarOffsetReadOnly(Parms[i2],&VarType,&RelativeVar,&lpVarIndex)) continue;
    559559
    560560                if(DummyTypeInfo.type!=DEF_ANY){
  • BasicCompiler32/Compile_Calc.cpp

    r3 r11  
    516516
    517517        //変数アドレスを取得
    518         if(!GetVarOffset(
    519             1,
     518        if(!GetVarOffsetReadWrite(
    520519            variable,
    521520            &VarType,
     
    535534
    536535    //変数アドレスを取得
    537     if(!GetVarOffset(
    538         1,
     536    if(!GetVarOffsetReadWrite(
    539537        variable,
    540538        &VarType,
  • BasicCompiler32/Compile_CallProc.cpp

    r3 r11  
    185185    RELATIVE_VAR RelativeVar;
    186186    LONG_PTR lp;
    187     GetVarOffset(1,variable,&i,&RelativeVar,&lp);
     187    GetVarOffsetReadOnly(variable,&i,&RelativeVar,&lp);
    188188    SetVarPtrToEax(&RelativeVar);
    189189
     
    382382
    383383            RELATIVE_VAR RelativeVar;
    384             if(!GetVarOffset(1,ObjectName,&i2,&RelativeVar,0)) return -1;
     384            if(!GetVarOffsetReadOnly(ObjectName,&i2,&RelativeVar,0)) return -1;
    385385            SetVarPtrToEax(&RelativeVar);
    386386
  • BasicCompiler32/Compile_Func.cpp

    r3 r11  
    223223    int SubScripts[MAX_ARRAYDIM];
    224224    RELATIVE_VAR RelativeVar;
    225     if(!GetVarOffset(1,tempParm,&type,&RelativeVar,&lpIndex,SubScripts)) return;
     225    if(!GetVarOffsetReadOnly(tempParm,&type,&RelativeVar,&lpIndex,SubScripts)) return;
    226226
    227227    if(type&FLAG_PTR){
     
    295295                RELATIVE_VAR RelativeVar;
    296296                int type;
    297                 if(!GetVarOffset(1,ObjectName,&type,&RelativeVar,(LONG_PTR *)&pobj_c)) return;
     297                if(!GetVarOffsetReadOnly(ObjectName,&type,&RelativeVar,(LONG_PTR *)&pobj_c)) return;
    298298                SetVarPtrToEax(&RelativeVar);
    299299
     
    375375
    376376    //変数のアドレスを取得
    377     if(!GetVarOffset(1,Parameter,&type,&RelativeVar,0)) return;
     377    if(!GetVarOffsetReadOnly(Parameter,&type,&RelativeVar,0)) return;
    378378
    379379    SetVarPtrToEax(&RelativeVar);
  • BasicCompiler32/Compile_ProcOp.cpp

    r3 r11  
    282282
    283283        lstrcpy(LocalVar[MaxLocalVarNum].name,psi->pRealParmInfo[i3].name);
     284
     285        // TODO: パラメータのConst定義の指定が未完成
     286        LocalVar[MaxLocalVarNum].bConst=false;
    284287
    285288        LocalVar[MaxLocalVarNum].bArray=psi->pRealParmInfo[i3].bArray;
     
    696699            temp="_System_ReturnValue";
    697700        else temp=psi->name;
    698         GetVarOffset(1,temp,&i3,&RelativeVar,&lpIndex);
     701        GetVarOffsetReadWrite(temp,&i3,&RelativeVar,&lpIndex);
    699702
    700703        i3=psi->ReturnType;
  • BasicCompiler32/Compile_Statement.cpp

    r3 r11  
    15731573
    15741574        LONG_PTR lpIndex;
    1575         RELATIVE_VAR RelativeVar;
    1576         GetVarOffset(1,temporary,&type,&RelativeVar,&lpIndex);
     1575        type = GetVarType(temporary,&lpIndex,1);
    15771576
    15781577        sprintf(temp2,"_System_InputDataPtr[%d]=VarPtr(%s)",i4,temporary);
  • BasicCompiler32/Compile_Var.cpp

    r8 r11  
    157157    return 1;
    158158}
    159 BOOL GetMemberOffset(BOOL bError,CClass *pobj_c,char *member,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpNestIndex,BOOL bPrivateAccess){
     159BOOL GetMemberOffset(bool ErrorEnabled,CClass *pobj_c,char *member,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpNestIndex,BOOL bPrivateAccess){
    160160    int i,offset;
    161161
     
    175175    offset=GetSizeOfClassMember(pobj_c,VarName,&i);
    176176    if(i==pobj_c->iMemberNum){
    177         if(bError) SetError(103,VarName,cp);
     177        if(ErrorEnabled) SetError(103,VarName,cp);
    178178        return 0;
    179179    }
     
    183183        //同一クラスオブジェクトの場合はプライベートアクセスを容認する
    184184        if(pobj_c->ppobj_Member[i]->dwAccess==ACCESS_NON){
    185             if(bError) SetError(107,VarName,cp);
     185            if(ErrorEnabled) SetError(107,VarName,cp);
    186186            return 0;
    187187        }
     
    190190        if((bPrivateAccess==0&&pobj_c->ppobj_Member[i]->dwAccess==ACCESS_PRIVATE)||
    191191            pobj_c->ppobj_Member[i]->dwAccess==ACCESS_NON){
    192             if(bError) SetError(107,VarName,cp);
     192            if(ErrorEnabled) SetError(107,VarName,cp);
    193193            return 0;
    194194        }
    195195        else if(bPrivateAccess==0&&pobj_c->ppobj_Member[i]->dwAccess==ACCESS_PROTECTED){
    196             if(bError) SetError(108,VarName,cp);
     196            if(ErrorEnabled) SetError(108,VarName,cp);
    197197            return 0;
    198198        }
     
    211211    else{
    212212        if(lpPtrOffset[0]){
    213             if(bError) SetError(16,member,cp);
     213            if(ErrorEnabled) SetError(16,member,cp);
    214214            return 0;
    215215        }
     
    227227        //配列オフセット
    228228        if(!GetArrayOffset(pobj_c->ppobj_Member[i]->SubScripts,array,*pType,pobj_c->ppobj_Member[i]->TypeInfo.u.lpIndex))
    229             if(bError) SetError(14,member,cp);
     229            if(ErrorEnabled) SetError(14,member,cp);
    230230    }
    231231    else if(pobj_c->ppobj_Member[i]->SubScripts[0]!=-1){
     
    238238        if(*pType==DEF_OBJECT){
    239239            if(RefType!=DEF_OBJECT){
    240                 if(bError) SetError(104,member,cp);
     240                if(ErrorEnabled) SetError(104,member,cp);
    241241                return 0;
    242242            }
     
    248248                //pObj[n].member
    249249                if(RefType!=DEF_OBJECT){
    250                     if(bError) SetError(104,member,cp);
     250                    if(ErrorEnabled) SetError(104,member,cp);
    251251                    return 0;
    252252                }
     
    261261                //pObj->member
    262262                if(RefType!=DEF_PTR_OBJECT){
    263                     if(bError) SetError(104,member,cp);
     263                    if(ErrorEnabled) SetError(104,member,cp);
    264264                    return 0;
    265265                }
     
    287287                //ppObj[n]->member
    288288                if(RefType!=DEF_PTR_OBJECT){
    289                     if(bError) SetError(104,member,cp);
     289                    if(ErrorEnabled) SetError(104,member,cp);
    290290                    return 0;
    291291                }
     
    302302            }
    303303            else{
    304                 if(bError) SetError(104,member,cp);
     304                if(ErrorEnabled) SetError(104,member,cp);
    305305                return 0;
    306306            }
    307307        }
    308308
    309         if(!GetMemberOffset(bError,pobj_c->ppobj_Member[i]->TypeInfo.u.pobj_Class,
     309        if(!GetMemberOffset(ErrorEnabled,pobj_c->ppobj_Member[i]->TypeInfo.u.pobj_Class,
    310310            NestMember,
    311311            pType,
     
    344344}
    345345
    346 BOOL GetVarOffset(BOOL bError,char *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss){
     346BOOL GetVarOffset(bool ErrorEnabled,bool WriteAccess,char *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss){
    347347    extern BOOL bCompilingGlobal;
    348348    int i,RefType;
     
    360360    LONG_PTR lpIndex;
    361361    int *pSubScripts;
     362    bool bConst;
    362363
    363364    if(bCompilingGlobal==0){
     
    395396            if(plpIndex) *plpIndex=lpIndex;
    396397            pSubScripts=LocalVar[i].SubScripts;
     398            bConst = LocalVar[i].bConst;
    397399
    398400            goto ok;
     
    439441
    440442        pRelativeVar->dwKind=VAR_DIRECTMEM;
    441         if(!GetMemberOffset(bError,pobj_CompilingClass,variable,pType,pRelativeVar,&lpIndex,1)) return 0;
     443        if(!GetMemberOffset(ErrorEnabled,pobj_CompilingClass,variable,pType,pRelativeVar,&lpIndex,1)) return 0;
    442444        if(plpIndex) *plpIndex=lpIndex;
    443445        return 1;
     
    511513    }
    512514
    513     if(bError) SetError(3,variable,cp);
     515    if(ErrorEnabled) SetError(3,variable,cp);
    514516    pRelativeVar->dwKind=NON_VAR;
    515517    return 0;
     
    540542    if(plpIndex) *plpIndex=lpIndex;
    541543    pSubScripts=GlobalVar[i].SubScripts;
     544    bConst = GlobalVar[i].bConst;
    542545
    543546
    544547ok:
    545548
     549    if(bConst && WriteAccess){
     550        //Const定義の変数に書き込みアクセスをしようとした場合
     551        SetError(61,VarName,cp);
     552    }
    546553
    547554    if(array[0]==0&&pSubScripts[0]!=-1){
     
    576583
    577584            LONG_PTR lp2;
    578             if(!GetMemberOffset(bError,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
     585            if(!GetMemberOffset(ErrorEnabled,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
    579586            if(plpIndex) *plpIndex=lp2;
    580587        }
     
    592599
    593600                LONG_PTR lp2;
    594                 if(!GetMemberOffset(bError,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
     601                if(!GetMemberOffset(ErrorEnabled,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
    595602                if(plpIndex) *plpIndex=lp2;
    596603            }
     
    611618
    612619                LONG_PTR lp2;
    613                 if(!GetMemberOffset(bError,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
     620                if(!GetMemberOffset(ErrorEnabled,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
    614621                if(plpIndex) *plpIndex=lp2;
    615622            }
     
    636643
    637644                LONG_PTR lp2;
    638                 if(!GetMemberOffset(bError,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
     645                if(!GetMemberOffset(ErrorEnabled,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
    639646                if(plpIndex) *plpIndex=lp2;
    640647            }
     
    11171124            lstrcpy(pVar->name,VarName);
    11181125            pVar->fRef=0;
    1119             if(dwFlag & DIMFLAG_CONST) pVar->bConst = 1;
    1120             else pVar->bConst = 0;
     1126            if(dwFlag & DIMFLAG_CONST) pVar->bConst = true;
     1127            else pVar->bConst = false;
    11211128            if(SubScripts[0]==-1) pVar->bArray=0;
    11221129            else pVar->bArray=1;
     
    11321139
    11331140            if(InitBuf[0]){
     1141                //初期代入時のみ、書き込みアクセスを許可する
     1142                bool bConstBack = pVar->bConst;
     1143                pVar->bConst = false;
     1144
    11341145                int result = InitLocalVar(-pVar->offset,
    11351146                    pVar->type,
     
    11441155                    OpcodeCalc(temporary);
    11451156                }
     1157
     1158                pVar->bConst = bConstBack;
    11461159            }
    11471160            else{
  • BasicCompiler32/NumOpe.cpp

    r8 r11  
    375375
    376376                    RELATIVE_VAR RelativeVar;
    377                     if(GetVarOffset(0,term,&i2,&RelativeVar,&index_stack[sp])){
     377                    if(GetVarOffset(
     378                        false,  //エラー表示あり
     379                        false,  //読み込み専用
     380                        term,&i2,&RelativeVar,&index_stack[sp])){
    378381                        //////////
    379382                        // 変数
  • BasicCompiler32/Opcode.h

    r8 r11  
    172172void GetWithName(char *buffer);
    173173void SetThisPtrToReg(int reg);
    174 BOOL GetVarOffset(BOOL bError,char *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss=0);
     174BOOL GetVarOffset(bool ErrorEnabled,bool WriteAccess,char *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss=0);
    175175BOOL SetInitGlobalData(int offset,int type,LONG_PTR lpIndex,int *SubScripts,char *InitBuf);
    176176#define DIMFLAG_INITDEBUGVAR            1
  • BasicCompiler32/increment.cpp

    r3 r11  
    235235    ///////////////////////////
    236236
    237     if(!GetVarOffset(
    238         1,
     237    if(!GetVarOffsetReadWrite(
    239238        lpszLeft,
    240239        &VarType,
  • 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,
  • BasicCompiler_Common/NumOpe_GetType.cpp

    r7 r11  
    301301    BOOL bLiteralCalculation=1;
    302302
    303     double dbl;
    304303    int sp;
    305304    int type[255];
  • BasicCompiler_Common/Variable.cpp

    r7 r11  
    815815}
    816816
     817BOOL GetVarOffsetReadOnly(char *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss){
     818    //読み取り専用で変数へアクセス
     819    return GetVarOffset(
     820        true,       //エラー表示有効
     821        false,      //書き込みアクセスは無し
     822        NameBuffer,
     823        pType,
     824        pRelativeVar,
     825        plpIndex,
     826        pss);
     827}
     828BOOL GetVarOffsetReadWrite(char *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss){
     829    //読み書き両用で変数へアクセス
     830    return GetVarOffset(
     831        true,       //エラー表示有効
     832        true,       //書き込みアクセス
     833        NameBuffer,
     834        pType,
     835        pRelativeVar,
     836        plpIndex,
     837        pss);
     838}
     839
    817840
    818841
     
    10171040
    10181041    lstrcpy(pVar->name,name);
    1019     if(dwFlag & DIMFLAG_CONST) pVar->bConst = 1;
    1020     else pVar->bConst = 0;
     1042    if(dwFlag & DIMFLAG_CONST) pVar->bConst = true;
     1043    else pVar->bConst = false;
    10211044    if(SubScripts[0]==-1) pVar->bArray=0;
    10221045    else pVar->bArray=1;
     
    10541077        AllInitGlobalVarSize);
    10551078    if(InitBuf[0]){
     1079        //初期代入時のみ、書き込みアクセスを許可する
     1080        bool bConstBack = pVar->bConst;
     1081        pVar->bConst = false;
     1082
    10561083        int result = SetInitGlobalData(pVar->offset,
    10571084            pVar->type,
     
    10661093            OpcodeCalc(temporary);
    10671094        }
     1095
     1096        pVar->bConst = bConstBack;
    10681097    }
    10691098
  • BasicCompiler_Common/calculation.cpp

    r7 r11  
    12991299
    13001300                //変数
    1301                 RELATIVE_VAR RelativeVar;
    13021301                CClass *pobj_Class;
    1303                 if(!GetVarOffset(1,Command+i2,&type,&RelativeVar,(LONG_PTR *)&pobj_Class)){
     1302                type = GetVarType(Command+i2,(LONG_PTR *)&pobj_Class,1);
     1303                if(type==-1 || type ==0){
    13041304                    //エラー
    13051305                    return -1;
  • BasicCompiler_Common/common.h

    r7 r11  
    166166
    167167    //定数変数かどうか
    168     BOOL bConst;
     168    bool bConst;
    169169
    170170    BOOL bArray;
     
    386386#include "../BasicCompiler_Common/DebugSection.h"
    387387#include "../BasicCompiler_Common/LexicalScoping.h"
     388#include "../BasicCompiler_Common/Variable.h"
    388389
    389390
     
    413414SUBINFO **GetOverloadObjectSubHash(char *name,CClass *pobj_c, int *pNum);
    414415SUBINFO **GetOverloadSubHash(char *name,int *pNum);
    415 
    416 //Variable.cpp
    417 BOOL IsVariableTopChar(char c);
    418 BOOL IsVariableChar(char c);
    419 BOOL IsPtrType(int type);
    420 BOOL IsSignedType(int type);
    421 BOOL IsNaturalWholeNumberType(int type);
    422 BOOL IsWholeNumberType(int type);
    423 BOOL IsRealNumberType(int type);
    424 BOOL Is64Type(int type);
    425 int GetSignedType(int type);
    426 int GetUnsignedType(int type);
    427 int GetTypeSize(int type,LONG_PTR lpIndex);
    428 int GetPtrType(int type,LONG_PTR lpIndex);
    429 int GetTypeFixed(char *TypeName,LONG_PTR *lpNum);
    430 void GetOriginalTypeName(char *buffer);
    431 BOOL GetTypeName(int type,LONG_PTR lpIndex,char *name);
    432 BOOL GetVarFormatString(char *buffer,char *array,char *array2,char *NestMember,int *pRefType);
    433 void GetArrayElement(char *buffer,char *variable,char *array_element);
    434 BOOL CheckVarNameError(char *name,int NowLine);
    435 int JumpSubScripts(int *ss);
    436 void GetArrange(char *variable,char *variAnswer,int *SubScripts);
    437 int GetTypeFromSimpleName(char *variable);
    438 int GetVarType(char *NameBuffer,LONG_PTR *plpIndex,BOOL bError);
    439 BOOL GetDimentionFormat(char *buffer,char *VarName,int *SubScripts,TYPEINFO *pTypeInfo,char *InitBuf,char *ConstractParameter);
    440 BOOL GetNowStaticVarFullName(char *VarName,char *FullName);
    441 void AddGlobalVariable(char *name,int *SubScripts,TYPEINFO *pTypeInfo,int TypeSize,char *InitBuf,char *ConstractParameter,DWORD dwFlag);
    442416
    443417//Object.cpp
  • BasicCompiler_Common/error.cpp

    r4 r11  
    142142    if(num==59) sprintf(msg,"マニフェスト ファイル \"%s\" の読み込みに失敗。",KeyWord);
    143143    if(num==60) lstrcpy(msg,"Staticステートメントはグローバル領域では使用できません。");
     144    if(num==61) sprintf(msg,"\"%s\" Const定義の変数には書き込めません。",KeyWord);
    144145
    145146
  • BasicCompiler_Common/gc.cpp

    r5 r11  
    2424    OpcodeDim(temporary,0);
    2525
    26     GetVarOffset(1,"_System_gc_GlobalRoot_StartPtr",&type,&RelativeVar,&lpIndex);
     26    GetVarOffsetReadWrite("_System_gc_GlobalRoot_StartPtr",&type,&RelativeVar,&lpIndex);
    2727
    2828    //mov rax,ptr
     
    4444    OpcodeDim(temporary,0);
    4545
    46     GetVarOffset(1,"_System_gc_GlobalRoot_Size",&type,&RelativeVar,&lpIndex);
     46    GetVarOffsetReadWrite("_System_gc_GlobalRoot_Size",&type,&RelativeVar,&lpIndex);
    4747
    4848    //mov rax,ptr
     
    6565    OpcodeDim(temporary,0);
    6666
    67     GetVarOffset(1,"_System_gc_StackRoot_StartPtr",&type,&RelativeVar,&lpIndex);
     67    GetVarOffsetReadWrite("_System_gc_StackRoot_StartPtr",&type,&RelativeVar,&lpIndex);
    6868
    6969    //mov rax,rsp
Note: See TracChangeset for help on using the changeset viewer.