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

Method parse_statement

source/effect_parser_stmt.cpp:266–920  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

264}
265
266bool reshadefx::parser::parse_statement(bool scoped)
267{
268 if (!_codegen->is_in_block())
269 {
270 error(_token_next.location, 0, "unreachable code");
271 return false;
272 }
273
274 unsigned int loop_control = 0;
275 unsigned int selection_control = 0;
276
277 // Read any loop and branch control attributes first
278 while (accept('['))
279 {
280 enum control_mask
281 {
282 unroll = 0x1,
283 dont_unroll = 0x2,
284 flatten = (0x1 << 4),
285 dont_flatten = (0x2 << 4),
286 switch_force_case = (0x4 << 4),
287 switch_call = (0x8 << 4)
288 };
289
290 const std::string attribute = std::move(_token_next.literal_as_string);
291
292 if (!expect(tokenid::identifier) || !expect(']'))
293 return false;
294
295 if (attribute == "unroll")
296 loop_control |= unroll;
297 else if (attribute == "loop" || attribute == "fastopt")
298 loop_control |= dont_unroll;
299 else if (attribute == "flatten")
300 selection_control |= flatten;
301 else if (attribute == "branch")
302 selection_control |= dont_flatten;
303 else if (attribute == "forcecase")
304 selection_control |= switch_force_case;
305 else if (attribute == "call")
306 selection_control |= switch_call;
307 else
308 warning(_token.location, 0, "unknown attribute '" + attribute + "'");
309
310 if ((loop_control & (unroll | dont_unroll)) == (unroll | dont_unroll))
311 {
312 error(_token.location, 3524, "can't use loop and unroll attributes together");
313 return false;
314 }
315 if ((selection_control & (flatten | dont_flatten)) == (flatten | dont_flatten))
316 {
317 error(_token.location, 3524, "can't use branch and flatten attributes together");
318 return false;
319 }
320 }
321
322 // Shift by two so that the possible values are 0x01 for 'flatten' and 0x02 for 'dont_flatten', equivalent to 'unroll' and 'dont_unroll'
323 selection_control >>= 4;

Callers

nothing calls this directly

Calls 12

to_stringFunction · 0.85
is_in_blockMethod · 0.80
is_in_functionMethod · 0.80
create_blockMethod · 0.80
is_scalarMethod · 0.80
add_cast_operationMethod · 0.80
is_integralMethod · 0.80
is_voidMethod · 0.80
is_arrayMethod · 0.80
descriptionMethod · 0.80
componentsMethod · 0.80
emit_loadMethod · 0.45

Tested by

no test coverage detected