- added FindClassMemberFunction which retrieves a function symbol and performs some verification.
- removed Self parameter from FxFunctionCall. Actual member function calls through an object require quite different handling so lumping these two together makes no sense. - added a workaround to deal with ACS_NamedExecuteWithResult to both the compiler and FindClassMemberFunction. The way the ZScript compiler sets this up means that it will call the builtin, not the actual action function, so the parser needs to do some explicit check to get past the same-named action function. - pass a proper self pointer to FxActionSpecial. Although it's still not being used, propagating design shortcuts through several function levels is a very, very bad idea.
This commit is contained in:
parent
cbb990a79e
commit
c3e693b507
7 changed files with 83 additions and 114 deletions
|
|
@ -147,6 +147,43 @@ PFunction *CreateAnonymousFunction(PClass *containingclass, PType *returntype, i
|
|||
return sym;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FindClassMemberFunction
|
||||
//
|
||||
// Looks for a name in a class's symbol table and outputs appropriate messages
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
PFunction *FindClassMemberFunction(PClass *selfcls, PClass *funccls, FName name, FScriptPosition &sc)
|
||||
{
|
||||
// Skip ACS_NamedExecuteWithResult. Anything calling this should use the builtin instead.
|
||||
if (name == NAME_ACS_NamedExecuteWithResult) return nullptr;
|
||||
|
||||
PSymbolTable *symtable;
|
||||
auto symbol = selfcls->Symbols.FindSymbolInTable(name, symtable);
|
||||
auto funcsym = dyn_cast<PFunction>(symbol);
|
||||
|
||||
if (symbol != nullptr)
|
||||
{
|
||||
if (funcsym == nullptr)
|
||||
{
|
||||
sc.Message(MSG_ERROR, "%s is not a member function of %s", name.GetChars(), selfcls->TypeName.GetChars());
|
||||
}
|
||||
else if (funcsym->Variants[0].Flags & VARF_Private && symtable != &funccls->Symbols)
|
||||
{
|
||||
// private access is only allowed if the symbol table belongs to the class in which the current function is being defined.
|
||||
sc.Message(MSG_ERROR, "%s is declared private and not accessible", symbol->SymbolName.GetChars());
|
||||
}
|
||||
else if (funcsym->Variants[0].Flags & VARF_Deprecated)
|
||||
{
|
||||
sc.Message(MSG_WARNING, "Call to deprecated function %s", symbol->SymbolName.GetChars());
|
||||
}
|
||||
}
|
||||
// return nullptr if the name cannot be found in the symbol table so that the calling code can do other checks.
|
||||
return funcsym;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// LoadActors
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue