Script: Functions in constant proplists can access their properties

liquid_container
Günther Brammer 2015-12-24 02:00:23 +01:00
parent f757706e68
commit 2ebd1a98ad
1 changed files with 24 additions and 2 deletions

View File

@ -2127,6 +2127,13 @@ void C4AulParse::Parse_ForEach()
AddBCC(AB_STACK, -2);
}
static bool GetPropertyByS(const C4PropList * p, const char * s, C4Value & v)
{
C4String * k = Strings.FindString(s);
if (!k) return false;
return p->GetPropertyByS(k, &v);
}
void C4AulParse::Parse_Expression(int iParentPrio)
{
int ndx;
@ -2164,10 +2171,25 @@ void C4AulParse::Parse_Expression(int iParentPrio)
else if (Host && Host->GetPropList() == Fn->Parent && Host->LocalNamed.GetItemNr(Idtf) != -1)
{
// insert variable by id
C4String * pKey = Strings.RegString(Idtf);
AddBCC(AB_LOCALN, (intptr_t) pKey);
AddBCC(AB_LOCALN, (intptr_t) Strings.RegString(Idtf));
Shift();
}
else if ((!Host || Host->GetPropList() != Fn->Parent) && GetPropertyByS(Fn->Parent, Idtf, val))
{
if (FoundFn = val.getFunction())
{
if (Config.Developer.ExtraWarnings && !FoundFn->GetPublic())
Warn("using deprecated function %s", Idtf);
Shift();
Parse_Params(FoundFn->GetParCount(), FoundFn->GetName(), FoundFn);
AddBCC(AB_FUNC, (intptr_t) FoundFn);
}
else
{
AddBCC(AB_LOCALN, (intptr_t) Strings.RegString(Idtf));
Shift();
}
}
else if (SEqual(Idtf, C4AUL_True))
{
AddBCC(AB_BOOL, 1);