| 2795 | } |
| 2796 | |
| 2797 | bool HasConstructor(TypeInfo* type, unsigned arguments, bool* callDefault) |
| 2798 | { |
| 2799 | bestFuncList.clear(); |
| 2800 | |
| 2801 | if(type->refLevel || type->arrLevel || type->funcType) |
| 2802 | return false; |
| 2803 | |
| 2804 | unsigned funcHash = type->nameHash; |
| 2805 | funcHash = StringHashContinue(funcHash, "::"); |
| 2806 | funcHash = StringHashContinue(funcHash, FindConstructorName(type)); |
| 2807 | SelectFunctionsForHash(funcHash, 0); |
| 2808 | |
| 2809 | // For a generic type instance, check if base class has a constructor function |
| 2810 | unsigned funcBaseHash = 0; |
| 2811 | if(type->genericBase) |
| 2812 | { |
| 2813 | funcBaseHash = type->genericBase->nameHash; |
| 2814 | funcBaseHash = StringHashContinue(funcBaseHash, "::"); |
| 2815 | funcBaseHash = StringHashContinue(funcBaseHash, FindConstructorName(type)); |
| 2816 | SelectFunctionsForHash(funcBaseHash, 0); |
| 2817 | } |
| 2818 | |
| 2819 | // remove functions with wrong argument count |
| 2820 | for(unsigned i = 0; i < bestFuncList.size(); i++) |
| 2821 | { |
| 2822 | FunctionInfo *curr = bestFuncList[i]; |
| 2823 | |
| 2824 | VariableInfo *param = curr->firstParam; |
| 2825 | for(unsigned int n = 0; n < arguments && param; n++) |
| 2826 | param = param->next; |
| 2827 | |
| 2828 | if(curr->paramCount != arguments && !(param && param->defaultValue)) |
| 2829 | { |
| 2830 | bestFuncList[i] = bestFuncList.back(); |
| 2831 | bestFuncList.pop_back(); |
| 2832 | i--; |
| 2833 | } |
| 2834 | } |
| 2835 | |
| 2836 | if(!bestFuncList.size()) |
| 2837 | { |
| 2838 | if(callDefault) |
| 2839 | *callDefault = true; |
| 2840 | funcHash = StringHashContinue(funcHash, "$"); |
| 2841 | SelectFunctionsForHash(funcHash, 0); |
| 2842 | if(type->genericBase) |
| 2843 | { |
| 2844 | funcBaseHash = StringHashContinue(funcBaseHash, "$"); |
| 2845 | SelectFunctionsForHash(funcBaseHash, 0); |
| 2846 | } |
| 2847 | } |
| 2848 | |
| 2849 | unsigned minRating = ~0u; |
| 2850 | SelectBestFunction(bestFuncList.size(), arguments, minRating, type->genericBase ? type : NULL); |
| 2851 | return minRating != ~0u; |
| 2852 | } |
| 2853 | |
| 2854 | bool defineCoroutine = false; |
no test coverage detected