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

Method matchFunction

src/GLSLCompiler.cpp:649–695  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

647 }
648
649 Function GLSLCompiler::matchFunction(const char* name, const std::vector<glsl::astConstantExpression*>& params)
650 {
651 Function ret;
652 ret.Name = "";
653
654 int match_args = -1;
655
656 std::vector<GLSLCompiler::ExpressionType> paramTypes(params.size());
657 for (int i = 0; i < paramTypes.size(); i++)
658 paramTypes[i] = evaluateExpressionType(params[i]);
659
660 //printf("[DEBUG] Trying to find a match with: ");
661 //for (int i = 0; i < paramTypes.size(); i++)
662 // printf("%s, ", paramTypes[i].Name.c_str());
663 //printf("\n");
664
665 for (int i = 0; i < m_func.size(); i++) {
666 if (m_func[i].Name == name) {
667 if (m_func[i].Arguments.size() != params.size())
668 continue;
669
670 int func_matches = 0;
671
672 for (int j = 0; j < m_func[i].Arguments.size(); j++) {
673 // user defined structures
674 if (m_convertExprType(m_func[i].Arguments[j].Type).Type == ag::Type::Object) {
675 // TODO: check if types match
676 if (m_func[i].Arguments[j].Type == paramTypes[j].Name)
677 func_matches++;
678 }
679 else {
680 if (paramTypes[j] == m_convertExprType(m_func[i].Arguments[j].Type))
681 func_matches++;
682 }
683 }
684
685 if (func_matches > match_args) {
686 if (func_matches == params.size())
687 return m_func[i];
688 ret = m_func[i];
689 match_args = func_matches;
690 }
691 }
692 }
693 //printf("[DEBUG] Best match: %d\n", match_args);
694 return ret;
695 }
696 std::string GLSLCompiler::getReturnType(const char* name, const std::vector<glsl::astConstantExpression*>& params)
697 {
698 // a v hacky way to do this, but since glsl-parser doesn't do it...

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected