Update CBotFieldExpr::ProtectionError docs
parent
81aae35565
commit
ca548e2902
|
@ -110,7 +110,7 @@ CBotInstr* CBotExprRetVar::Compile(CBotToken*& p, CBotCStack* pStack, bool bMeth
|
|||
if (var != nullptr)
|
||||
{
|
||||
i->SetUniqNum(var->GetUniqNum());
|
||||
if (CBotFieldExpr::ProtectionError(pStk, preVar, var))
|
||||
if (CBotFieldExpr::CheckProtectionError(pStk, preVar, var))
|
||||
{
|
||||
pStk->SetError(CBotErrPrivate, pp);
|
||||
goto err;
|
||||
|
|
|
@ -67,7 +67,7 @@ CBotInstr* CBotExprVar::Compile(CBotToken*& p, CBotCStack* pStack, CBotVar::Prot
|
|||
|
||||
if (ident > 0 && ident < 9000)
|
||||
{
|
||||
if (CBotFieldExpr::ProtectionError(pStk, nullptr, var, privat))
|
||||
if (CBotFieldExpr::CheckProtectionError(pStk, nullptr, var, privat))
|
||||
{
|
||||
pStk->SetError(CBotErrPrivate, p);
|
||||
goto err;
|
||||
|
@ -137,7 +137,7 @@ CBotInstr* CBotExprVar::Compile(CBotToken*& p, CBotCStack* pStack, CBotVar::Prot
|
|||
if (var != nullptr)
|
||||
{
|
||||
i->SetUniqNum(var->GetUniqNum());
|
||||
if (CBotFieldExpr::ProtectionError(pStk, preVar, var, privat))
|
||||
if (CBotFieldExpr::CheckProtectionError(pStk, preVar, var, privat))
|
||||
{
|
||||
pStk->SetError(CBotErrPrivate, pp);
|
||||
goto err;
|
||||
|
|
|
@ -135,8 +135,8 @@ std::string CBotFieldExpr::GetDebugData()
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool CBotFieldExpr::ProtectionError(CBotCStack* pStack, CBotVar* pPrev, CBotVar* pVar,
|
||||
CBotVar::ProtectionLevel privat)
|
||||
bool CBotFieldExpr::CheckProtectionError(CBotCStack* pStack, CBotVar* pPrev, CBotVar* pVar,
|
||||
CBotVar::ProtectionLevel privat)
|
||||
{
|
||||
CBotVar::ProtectionLevel varPriv = pVar->GetPrivate();
|
||||
|
||||
|
|
|
@ -66,15 +66,19 @@ public:
|
|||
void RestoreStateVar(CBotStack* &pj, bool bMain) override;
|
||||
|
||||
/*!
|
||||
* \brief ProtectionError Test if access to a variable is not allowed.
|
||||
* \param pStack
|
||||
* \param pPrev
|
||||
* \param pVar
|
||||
* \param privat
|
||||
* \return True if pVar is protected in the current context.
|
||||
* \brief Check if access to a variable is allowed or not depending on public/private/protected setting
|
||||
*
|
||||
* If this function returns true, the caller is responsible for failing the compilation with ::CBotErrPrivate error.
|
||||
* This function doesn't set the error flag itself.
|
||||
*
|
||||
* \param pStack Current compilation stack frame
|
||||
* \param pPrev Class instance which variable to check is part of, or nullptr if not part of a class
|
||||
* \param pVar Variable to check
|
||||
* \param privat CBotVar::ProtectionLevel::ReadOnly if requesting read-only access, anything else otherwise
|
||||
* \return true if pVar is inaccessible in the current context, false if access should be allowed
|
||||
*/
|
||||
static bool ProtectionError(CBotCStack* pStack, CBotVar* pPrev, CBotVar* pVar,
|
||||
CBotVar::ProtectionLevel privat = CBotVar::ProtectionLevel::Protected);
|
||||
static bool CheckProtectionError(CBotCStack* pStack, CBotVar* pPrev, CBotVar* pVar,
|
||||
CBotVar::ProtectionLevel privat = CBotVar::ProtectionLevel::Protected);
|
||||
|
||||
protected:
|
||||
virtual const std::string GetDebugName() override { return "CBotFieldExpr"; }
|
||||
|
|
|
@ -64,7 +64,7 @@ CBotLeftExpr* CBotLeftExpr::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
inst->m_nIdent = var->GetUniqNum();
|
||||
if (inst->m_nIdent > 0 && inst->m_nIdent < 9000)
|
||||
{
|
||||
if (CBotFieldExpr::ProtectionError(pStk, nullptr, var, CBotVar::ProtectionLevel::ReadOnly))
|
||||
if (CBotFieldExpr::CheckProtectionError(pStk, nullptr, var, CBotVar::ProtectionLevel::ReadOnly))
|
||||
{
|
||||
pStk->SetError(CBotErrPrivate, p);
|
||||
goto err;
|
||||
|
@ -128,7 +128,8 @@ CBotLeftExpr* CBotLeftExpr::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
var = var->GetItem(p->GetString()); // get item correspondent
|
||||
if (var != nullptr)
|
||||
{
|
||||
if (CBotFieldExpr::ProtectionError(pStk, preVar, var, CBotVar::ProtectionLevel::ReadOnly))
|
||||
if (CBotFieldExpr::CheckProtectionError(pStk, preVar, var,
|
||||
CBotVar::ProtectionLevel::ReadOnly))
|
||||
{
|
||||
pStk->SetError(CBotErrPrivate, pp);
|
||||
goto err;
|
||||
|
|
|
@ -106,7 +106,7 @@ public:
|
|||
|
||||
/**
|
||||
* \brief Returns ::CBotType or ::CBotError stored in this object
|
||||
* \param mode Mode, see ::GetTypeMode enum
|
||||
* \param mode Mode, see GetTypeMode enum
|
||||
*/
|
||||
int GetType(GetTypeMode mode = GetTypeMode::NORMAL) const;
|
||||
|
||||
|
|
Loading…
Reference in New Issue