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

Method translateDeclarationVariable

src/GLSLCompiler.cpp:484–534  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

482 }
483
484 void GLSLCompiler::translateDeclarationVariable(glsl::astFunctionVariable *variable) {
485 m_exportLine(variable);
486
487 glsl::astVariable* vdata = (glsl::astVariable*)variable;
488
489 m_locals[m_currentFunction].push_back(vdata->name);
490
491 if (!vdata->baseType->builtin)
492 m_localTypes[m_currentFunction][vdata->name] = ((glsl::astStruct*)vdata->baseType)->name;
493 else
494 m_localTypes[m_currentFunction][vdata->name] = kTypes[((glsl::astBuiltin*)vdata->baseType)->type];
495
496 GLSLCompiler::ExpressionType lType = m_convertExprType(kTypes[((glsl::astBuiltin*)vdata->baseType)->type]);
497
498 if (variable->initialValue) {
499 translateExpression(variable->initialValue);
500
501 GLSLCompiler::ExpressionType rType = evaluateExpressionType(variable->initialValue);
502 if (lType != rType)
503 generateConvert(lType);
504
505 m_gen.Function.SetLocal(m_locals[m_currentFunction].size() - 1);
506 }
507
508
509 if (!vdata->baseType->builtin) {
510 std::string structName = ((glsl::astStruct*)vdata->baseType)->name;
511
512 if (!variable->initialValue) {
513 m_gen.Function.NewObjectByName(structName);
514 m_gen.Function.SetLocal(m_locals[m_currentFunction].size() - 1);
515 }
516
517 // printf("[DEBUG] Declaring variable %s with type %s\n", vdata->name, structName.c_str());
518 }
519 else {
520 std::string structName = kTypes[((glsl::astBuiltin*)vdata->baseType)->type];
521
522 if (!variable->initialValue) {
523 if (isTypeActuallyStruct(structName)) {
524 m_gen.Function.NewObjectByName(structName, 0);
525 m_gen.Function.SetLocal(m_locals[m_currentFunction].size() - 1);
526 }
527 else {
528 m_gen.Function.PushStack(0);
529 generateConvert(lType);
530 m_gen.Function.SetLocal(m_locals[m_currentFunction].size() - 1);
531 }
532 }
533 }
534 }
535
536 void GLSLCompiler::translatePostIncrement(glsl::astPostIncrementExpression *expression) {
537 m_exportLine(expression);

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected