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

Method m_matchFunction

src/HLSLCompiler.cpp:140–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138 }
139
140 Function HLSLCompiler::m_matchFunction(const char* name, int argCount, M4::HLSLExpression* args)
141 {
142 Function ret;
143 ret.Name = "";
144
145 int match_args = -1;
146
147 int aIndex = 0;
148 std::vector<HLSLCompiler::ExpressionType> paramTypes(argCount);
149 M4::HLSLExpression* arg = args;
150 while (arg) {
151 paramTypes[aIndex] = m_convertType(arg->expressionType);
152
153 aIndex++;
154 arg = arg->nextExpression;
155 }
156
157 //printf("[DEBUG] Trying to find a match with: ");
158 //for (int i = 0; i < paramTypes.size(); i++)
159 // printf("%s, ", paramTypes[i].Name.c_str());
160 //printf("\n");
161
162 for (int i = 0; i < m_func.size(); i++) {
163 if (m_func[i].Name == name) {
164 if (m_func[i].Arguments.size() != argCount)
165 continue;
166
167 int func_matches = 0;
168
169 for (int j = 0; j < m_func[i].Arguments.size(); j++) {
170 // user defined structures
171 if (m_convertType(m_func[i].Arguments[j].Type).Type == ag::Type::Object) {
172 // TODO: check if types match
173 if (m_func[i].Arguments[j].Type == paramTypes[j].Name)
174 func_matches++;
175 }
176 else {
177 if (paramTypes[j] == m_convertType(m_func[i].Arguments[j].Type))
178 func_matches++;
179 }
180 }
181
182 if (func_matches > match_args) {
183 if (func_matches == argCount)
184 return m_func[i];
185 ret = m_func[i];
186 match_args = func_matches;
187 }
188 }
189 }
190 //printf("[DEBUG] Best match: %d\n", match_args);
191 return ret;
192 }
193
194 void HLSLCompiler::m_freeImmediate()
195 {

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected