- 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:
Christoph Oelckers 2016-10-15 20:16:44 +02:00
commit c3e693b507
7 changed files with 83 additions and 114 deletions

View file

@ -39,75 +39,6 @@
// just some rough concepts for now...
//==========================================================================
//
// FindClassMemberFunction
//
// Looks for a name in a class's
//
//==========================================================================
PFunction *FindClassMemberFunction(PClass *cls, FName name, FScriptPosition &sc)
{
PSymbolTable *symtable;
auto symbol = cls->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(), cls->TypeName.GetChars());
}
else if (funcsym->Flags & VARF_Private && symtable != &cls->Symbols)
{
sc.Message(MSG_ERROR, "%s is declared private and not accessible", symbol->SymbolName.GetChars());
}
else if (funcsym->Flags & VARF_Deprecated)
{
sc.Message(MSG_WARNING, "Call to deprecated function %s", symbol->SymbolName.GetChars());
}
}
return funcsym;
}
//==========================================================================
//
// let's save some work down the line by analyzing the type of function
// that's being called right here and create appropriate nodes.
// A simple function call expression must be immediately resolvable in
// the context it gets compiled in, if the function name cannot be
// resolved here, it will never.
//
//==========================================================================
FxExpression *ConvertSimpleFunctionCall(ZCC_ExprID *function, FArgumentList *args, PClass *cls, FScriptPosition &sc)
{
// Priority is as follows:
//1. member functions of the containing class.
//2. action specials.
//3. floating point operations
//4. global builtins
if (cls != nullptr)
{
// There is an action function ACS_NamedExecuteWithResult which must be ignored here for this to work.
if (function->Identifier != NAME_ACS_NamedExecuteWithResult)
{
{
args = ConvertNodeList(fcall->Parameters);
if (args->Size() == 0)
{
delete args;
args = nullptr;
}
return new FxMemberunctionCall(new FxSelf(), new FxInvoker(), func, args, sc, false);
}
}
}
//==========================================================================
//
@ -125,7 +56,7 @@ FxExpression *ConvertFunctionCall(ZCC_Expression *function, FArgumentList *args,
switch(function->NodeType)
{
case AST_ExprID:
return ConvertSimpleFunctionCall(static_cast<ZCC_ExprID *>(function), args, cls, sc);
return new FxFunctionCall( ConvertSimpleFunctionCall(static_cast<ZCC_ExprID *>(function), args, cls, sc);
case AST_ExprMemberAccess:
return ConvertMemberCall(fcall);