public static FuncDef OverloadFunction(Context ctx, FuncDef def, int argsLength, Expr expr) { // Check to see the left operand is a column in a virtual table if (C._NEVER(expr == null)) { return(def); } if (expr.OP != TK.COLUMN) { return(def); } Table table = expr.Table; if (C._NEVER(table == null)) { return(def); } if ((table.TabFlags & TF.Virtual) == 0) { return(def); } IVTable ivtable = GetVTable(ctx, table).IVTable; Debug.Assert(ivtable != null); Debug.Assert(ivtable.IModule != null); ITableModule imodule = (ITableModule)ivtable.IModule; if (imodule.FindFunction == null) { return(def); } // Call the xFindFunction method on the virtual table implementation to see if the implementation wants to overload this function string lowerName = def.Name; RC rc = RC.OK; Action <FuncContext, int, Mem[]> func = null; object[] args = null; if (lowerName != null) { lowerName = lowerName.ToLowerInvariant(); rc = imodule.FindFunction(ivtable, argsLength, lowerName, func, args); C._tagfree(ctx, ref lowerName); } if (rc == RC.OK) { return(def); } // Create a new ephemeral function definition for the overloaded function FuncDef newFunc = new FuncDef();//: (FuncDef*)_tagalloc(ctx, sizeof(FuncDef) + _strlen30(def->Name) + 1, true); if (newFunc == null) { return(def); } newFunc = def._memcpy(); newFunc.Name = def.Name; newFunc.Func = func; newFunc.UserData = args; newFunc.Flags |= FUNC.EPHEM; return(newFunc); }