MCPcopy Create free account
hub / github.com/crosire/reshade / parse_function

Method parse_function

source/effect_parser_stmt.cpp:1241–1507  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1239}
1240
1241bool reshadefx::parser::parse_function(type type, std::string name, shader_type stype, int num_threads[3])
1242{
1243 const location function_location = std::move(_token.location);
1244
1245 if (!expect('(')) // Functions always have a parameter list
1246 return false;
1247
1248 if (type.qualifiers != 0)
1249 {
1250 error(function_location, 3047, '\'' + name + "': function return type cannot have any qualifiers");
1251 return false;
1252 }
1253
1254 function info;
1255 info.name = name;
1256 info.unique_name = 'F' + current_scope().name + name;
1257 std::replace(info.unique_name.begin(), info.unique_name.end(), ':', '_');
1258
1259 info.return_type = type;
1260 info.type = stype;
1261 info.num_threads[0] = num_threads[0];
1262 info.num_threads[1] = num_threads[1];
1263 info.num_threads[2] = num_threads[2];
1264
1265 _codegen->_current_function = &info;
1266
1267 bool parse_success = true;
1268 bool expect_parenthesis = true;
1269
1270 // Enter function scope (and leave it again when parsing this function finished)
1271 scope_guard _(
1272 [this]() {
1273 enter_scope();
1274 },
1275 [this]() {
1276 leave_scope();
1277 _codegen->_current_function = nullptr;
1278 });
1279
1280 while (!peek(')'))
1281 {
1282 if (!info.parameter_list.empty() && !expect(','))
1283 {
1284 parse_success = false;
1285 expect_parenthesis = false;
1286 consume_until(')');
1287 break;
1288 }
1289
1290 member_type param;
1291
1292 if (!parse_type(param.type))
1293 {
1294 error(_token_next.location, 3000, "syntax error: unexpected '" + token::id_to_name(_token_next.id) + "', expected parameter type");
1295 parse_success = false;
1296 expect_parenthesis = false;
1297 consume_until(')');
1298 break;

Callers

nothing calls this directly

Calls 9

id_to_nameFunction · 0.85
is_voidMethod · 0.80
is_unbounded_arrayMethod · 0.80
is_integralMethod · 0.80
add_cast_operationMethod · 0.80
create_blockMethod · 0.80
is_in_blockMethod · 0.80
hasMethod · 0.45
define_functionMethod · 0.45

Tested by

no test coverage detected