forked from teamnwah/openmw-tes3coop
added verification for explicit references (check if the given ID exists)
This commit is contained in:
parent
d4ac3b506e
commit
c37b007be0
7 changed files with 43 additions and 4 deletions
|
@ -12,5 +12,10 @@ namespace SACompiler
|
||||||
{
|
{
|
||||||
return ' ';
|
return ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Context::isId (const std::string& name) const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,10 @@ namespace SACompiler
|
||||||
///< Is the compiler allowed to declare local variables?
|
///< Is the compiler allowed to declare local variables?
|
||||||
|
|
||||||
virtual char getGlobalType (const std::string& name) const;
|
virtual char getGlobalType (const std::string& name) const;
|
||||||
///< 'l: long, 's': short, 'f': float, ' ': does not exist.
|
///< 'l: long, 's': short, 'f': float, ' ': does not exist.
|
||||||
|
|
||||||
|
virtual bool isId (const std::string& name) const;
|
||||||
|
///< Does \a name match an ID, that can be referenced?
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,5 +31,30 @@ namespace MWScript
|
||||||
|
|
||||||
return ' ';
|
return ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CompilerContext::isId (const std::string& name) const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
mEnvironment.mWorld->getStore().activators.find (name) ||
|
||||||
|
mEnvironment.mWorld->getStore().potions.find (name) ||
|
||||||
|
mEnvironment.mWorld->getStore().appas.find (name) ||
|
||||||
|
mEnvironment.mWorld->getStore().armors.find (name) ||
|
||||||
|
mEnvironment.mWorld->getStore().books.find (name) ||
|
||||||
|
mEnvironment.mWorld->getStore().clothes.find (name) ||
|
||||||
|
mEnvironment.mWorld->getStore().containers.find (name) ||
|
||||||
|
mEnvironment.mWorld->getStore().creatures.find (name) ||
|
||||||
|
mEnvironment.mWorld->getStore().doors.find (name) ||
|
||||||
|
mEnvironment.mWorld->getStore().ingreds.find (name) ||
|
||||||
|
mEnvironment.mWorld->getStore().creatureLists.find (name) ||
|
||||||
|
mEnvironment.mWorld->getStore().itemLists.find (name) ||
|
||||||
|
mEnvironment.mWorld->getStore().lights.find (name) ||
|
||||||
|
mEnvironment.mWorld->getStore().lockpicks.find (name) ||
|
||||||
|
mEnvironment.mWorld->getStore().miscItems.find (name) ||
|
||||||
|
mEnvironment.mWorld->getStore().npcs.find (name) ||
|
||||||
|
mEnvironment.mWorld->getStore().probes.find (name) ||
|
||||||
|
mEnvironment.mWorld->getStore().repairs.find (name) ||
|
||||||
|
mEnvironment.mWorld->getStore().statics.find (name) ||
|
||||||
|
mEnvironment.mWorld->getStore().weapons.find (name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,9 @@ namespace MWScript
|
||||||
|
|
||||||
/// 'l: long, 's': short, 'f': float, ' ': does not exist.
|
/// 'l: long, 's': short, 'f': float, ' ': does not exist.
|
||||||
virtual char getGlobalType (const std::string& name) const;
|
virtual char getGlobalType (const std::string& name) const;
|
||||||
|
|
||||||
|
virtual bool isId (const std::string& name) const;
|
||||||
|
///< Does \a name match an ID, that can be referenced?
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,10 @@ namespace Compiler
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual char getGlobalType (const std::string& name) const = 0;
|
virtual char getGlobalType (const std::string& name) const = 0;
|
||||||
///< 'l: long, 's': short, 'f': float, ' ': does not exist.
|
///< 'l: long, 's': short, 'f': float, ' ': does not exist.
|
||||||
|
|
||||||
|
virtual bool isId (const std::string& name) const = 0;
|
||||||
|
///< Does \a name match an ID, that can be referenced?
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -275,7 +275,7 @@ namespace Compiler
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mOperands.empty() && mOperators.empty() && mExplicit.empty())
|
if (mExplicit.empty() && getContext().isId (name))
|
||||||
{
|
{
|
||||||
mExplicit = name;
|
mExplicit = name;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -129,7 +129,7 @@ namespace Compiler
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mState==BeginState)
|
if (mState==BeginState && getContext().isId (name))
|
||||||
{
|
{
|
||||||
mState = PotentialExplicitState;
|
mState = PotentialExplicitState;
|
||||||
mExplicit = toLower (name);
|
mExplicit = toLower (name);
|
||||||
|
|
Loading…
Reference in a new issue