MCPcopy Create free account
hub / github.com/dfranx/ShaderDebugger / translateFunctionCall

Method translateFunctionCall

src/HLSLCompiler.cpp:919–973  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

917 m_gen.Function.GetArrayElement();
918 }
919 void HLSLCompiler::translateFunctionCall(M4::HLSLFunctionCall* expr)
920 {
921 // mul(a,b)
922 if (strcmp(expr->function->name, "mul") == 0 && expr->numArguments == 2) {
923 // handle mul() with * operator
924
925 HLSLCompiler::ExpressionType lType = m_convertType(expr->argument->expressionType);
926 HLSLCompiler::ExpressionType rType = m_convertType(expr->argument->nextExpression->expressionType);
927
928 translateExpression(expr->argument);
929 if (rType.Columns * rType.Rows > 1 && lType.Columns * lType.Rows == 1)
930 m_generateConvert(rType);
931
932 translateExpression(expr->argument->nextExpression);
933 if (lType.Columns * lType.Rows > 1 && rType.Columns * rType.Rows == 1)
934 m_generateConvert(lType);
935
936 translateOperator(M4::HLSLBinaryOp_Mul);
937 }
938 // other functions
939 else {
940 Function data = m_matchFunction(expr->function->name, expr->numArguments, expr->argument);
941 std::vector<HLSLCompiler::ExpressionType> paramTypes(expr->numArguments);
942 for (int i = 0; i < data.Arguments.size(); i++)
943 paramTypes[i] = m_convertType(data.Arguments[i].Type);
944
945 for (int i = expr->numArguments - 1; i >= 0; i--) {
946 bool temp_usePointer = m_usePointer;
947
948 // built-in funcs with 'out' keyword
949 if (data.Name.empty()) {
950 if (m_builtInFuncsPtrs.count(expr->function->name) > 0)
951 if (std::count(m_builtInFuncsPtrs[expr->function->name].begin(), m_builtInFuncsPtrs[expr->function->name].end(), i) > 0)
952 m_usePointer = true;
953 }
954 // user defined funcs with 'out' keyword
955 else if (data.Arguments[i].Storage == sd::Variable::StorageType::Out)
956 m_usePointer = true;
957
958
959 M4::HLSLExpression* arg = expr->argument;
960 for (int j = 0; j < i; j++)
961 arg = arg->nextExpression;
962 translateExpression(arg);
963
964 m_usePointer = temp_usePointer;
965
966 if (!data.Name.empty() && paramTypes[i] != m_convertType(arg->expressionType))
967 m_generateConvert(paramTypes[i]);
968 }
969
970
971 m_gen.Function.CallReturn(expr->function->name, expr->numArguments);
972 }
973 }
974
975 void HLSLCompiler::translateStatements(M4::HLSLStatement* statement)
976 {

Callers

nothing calls this directly

Calls 3

sizeMethod · 0.80
beginMethod · 0.80
endMethod · 0.80

Tested by

no test coverage detected