diff options
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/emit.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp index 938d54d36..8483caefc 100644 --- a/source/slang/emit.cpp +++ b/source/slang/emit.cpp @@ -3291,7 +3291,8 @@ struct EmitVisitor } // Shared emit logic for variable declarations (used for parameters, locals, globals, fields) - void EmitVarDeclCommon(DeclRef<VarDeclBase> declRef) + + void emitVarDeclHead(DeclRef<VarDeclBase> declRef) { EmitModifiers(declRef.getDecl()); @@ -3306,7 +3307,10 @@ struct EmitVisitor } EmitSemantics(declRef.getDecl()); + } + void emitVarDeclInit(DeclRef<VarDeclBase> declRef) + { // TODO(tfoley): technically have to apply substitution here too... if (auto initExpr = declRef.getDecl()->initExpr) { @@ -3323,6 +3327,12 @@ struct EmitVisitor } } + void EmitVarDeclCommon(DeclRef<VarDeclBase> declRef) + { + emitVarDeclHead(declRef); + emitVarDeclInit(declRef); + } + // Shared emit logic for variable declarations (used for parameters, locals, globals, fields) void EmitVarDeclCommon(RefPtr<VarDeclBase> decl) { @@ -3532,7 +3542,7 @@ struct EmitVisitor { int fieldIndex = fieldCounter++; - EmitVarDeclCommon(field); + emitVarDeclHead(field); RefPtr<VarLayout> fieldLayout = structTypeLayout->fields[fieldIndex]; SLANG_RELEASE_ASSERT(fieldLayout->varDecl.GetName() == field.GetName()); @@ -3540,6 +3550,8 @@ struct EmitVisitor // Emit explicit layout annotations for every field emitHLSLParameterBlockFieldLayoutSemantics(layout, fieldLayout); + emitVarDeclInit(field); + Emit(";\n"); } } @@ -3809,9 +3821,9 @@ struct EmitVisitor } } - EmitVarDeclCommon(decl); - + emitVarDeclHead(makeDeclRef(decl.Ptr())); emitHLSLRegisterSemantics(layout); + emitVarDeclInit(makeDeclRef(decl.Ptr())); Emit(";\n"); } |
