MCPcopy Create free account
hub / github.com/carbonengine/trinity / ComputeMemberType

Function ComputeMemberType

shadercompiler/ParserUtils.cpp:294–478  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292}
293
294bool ComputeMemberType( const Type& leftType, const InlineString& member, Type& type, Symbol*& symbol )
295{
296 symbol = nullptr;
297 if( leftType.symbol )
298 {
299 ASTNode* structDef = leftType.symbol->definition;
300 if( structDef )
301 {
302 for( unsigned i = 0; i < structDef->GetChildrenCount(); ++i )
303 {
304 if( structDef->GetChild( i ) == nullptr )
305 {
306 continue;
307 }
308 for( unsigned j = 0; j < structDef->GetChild( i )->GetChildrenCount(); ++j )
309 {
310 if( structDef->GetChild( i )->GetChild( j ) == nullptr ||
311 structDef->GetChild( i )->GetChild( j )->GetSymbol() == nullptr )
312 {
313 continue;
314 }
315 if( member == structDef->GetChild( i )->GetChild( j )->GetSymbol()->name )
316 {
317 type = structDef->GetChild( i )->GetChild( j )->GetType();
318 symbol = structDef->GetChild( i )->GetChild( j )->GetSymbol();
319 return true;
320 }
321 }
322 }
323 }
324 return false;
325 }
326 else
327 {
328 if( leftType.builtInType == OP_RAY_DESC )
329 {
330 if( member == MakeInlineString( "Origin" ) || member == MakeInlineString( "Direction" ) )
331 {
332 type.FromTokenType( OP_FLOAT );
333 type.width = 3;
334 return true;
335 }
336 if( member == MakeInlineString( "TMin" ) || member == MakeInlineString( "TMax" ) )
337 {
338 type.FromTokenType( OP_FLOAT );
339 return true;
340 }
341 return false;
342 }
343 if( ( leftType.builtInType == OP_INPUTPATCH || leftType.builtInType == OP_OUTPUTPATCH ) && member == MakeInlineString( "Length" ) )
344 {
345 type.FromTokenType( OP_UINT );
346 return true;
347 }
348 if( !leftType.IsScalarOrVector() )
349 {
350 return false;
351 }

Callers 1

NewDotFunction · 0.85

Calls 7

MakeInlineStringFunction · 0.85
GetChildrenCountMethod · 0.80
GetSymbolMethod · 0.80
IsScalarOrVectorMethod · 0.80
GetChildMethod · 0.45
GetTypeMethod · 0.45
FromTokenTypeMethod · 0.45

Tested by

no test coverage detected