| 893 | } |
| 894 | |
| 895 | bool ParseFunctionCall(Lexeme** str, bool memberFunctionCall) |
| 896 | { |
| 897 | if((*str)->type != lex_string || (*str)[1].type != lex_oparen) |
| 898 | return false; |
| 899 | |
| 900 | if((*str)->length >= NULLC_MAX_VARIABLE_NAME_LENGTH) |
| 901 | ThrowError((*str)->pos, "ERROR: function name length is limited to 2048 symbols"); |
| 902 | char *functionName = (char*)stringPool.Allocate((*str)->length+1); |
| 903 | memcpy(functionName, (*str)->pos, (*str)->length); |
| 904 | functionName[(*str)->length] = 0; |
| 905 | (*str) += 2; |
| 906 | |
| 907 | // PrepareMemberCall may signal that this is not actually a member function call |
| 908 | bool wasMemberCall = memberFunctionCall; |
| 909 | // Prepare member function call |
| 910 | if(memberFunctionCall) |
| 911 | memberFunctionCall = PrepareMemberCall((*str)->pos, functionName); |
| 912 | |
| 913 | TypeInfo *lValue = memberFunctionCall ? CodeInfo::nodeList.back()->typeInfo->subType : NULL; |
| 914 | |
| 915 | // If it was a member function call, but isn't now, then we should take function pointer from the top of node list |
| 916 | NodeZeroOP *fAddress = NULL; |
| 917 | if(!memberFunctionCall && wasMemberCall) |
| 918 | { |
| 919 | fAddress = CodeInfo::nodeList.back(); |
| 920 | CodeInfo::nodeList.pop_back(); |
| 921 | } |
| 922 | const char *last = SetCurrentFunction(memberFunctionCall ? GetClassFunctionName(lValue, InplaceStr(functionName)) : functionName); |
| 923 | // Parse function arguments |
| 924 | NamespaceInfo *lastNS = GetCurrentNamespace(); |
| 925 | unsigned int callArgCount = ParseFunctionArguments(str); |
| 926 | SetCurrentNamespace(lastNS); |
| 927 | if(!ParseLexem(str, lex_cparen)) |
| 928 | ThrowError((*str)->pos, "ERROR: ')' not found after function parameter list"); |
| 929 | SetCurrentFunction(last); |
| 930 | |
| 931 | if(memberFunctionCall) |
| 932 | { |
| 933 | AddMemberFunctionCall((*str)->pos, functionName, callArgCount); |
| 934 | }else{ |
| 935 | // If it was a member function call, but isn't now, push node that calculates function pointer |
| 936 | if(wasMemberCall) |
| 937 | CodeInfo::nodeList.push_back(fAddress); |
| 938 | AddFunctionCallNode((*str)->pos, wasMemberCall ? NULL : functionName, callArgCount); |
| 939 | } |
| 940 | |
| 941 | return true; |
| 942 | } |
| 943 | |
| 944 | bool ParseFunctionVariables(Lexeme** str, unsigned nodeOffset) |
| 945 | { |
no test coverage detected