summaryrefslogtreecommitdiffstats
path: root/source/slang/emit.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-07-18 13:32:56 -0700
committerGitHub <noreply@github.com>2017-07-18 13:32:56 -0700
commit3d313d963f29f6ca6a8d12bd5c403a70c49aca2a (patch)
treed4a5f0cefd50c96aaf22921f9fef715b6359c0c5 /source/slang/emit.cpp
parentac310e2d848f3174cfb88ca6166676afc2cbe3cd (diff)
parent1c022e2c3654de868c45658683f9e04cf4d68cc0 (diff)
Merge pull request #118 from tfoleyNV/falcor-shadow-fixes
Falcor shadow fixes
Diffstat (limited to 'source/slang/emit.cpp')
-rw-r--r--source/slang/emit.cpp55
1 files changed, 41 insertions, 14 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp
index ef922c418..76dc9c75f 100644
--- a/source/slang/emit.cpp
+++ b/source/slang/emit.cpp
@@ -1991,7 +1991,25 @@ struct EmitVisitor
emitSimpleCallExpr(callExpr, outerPrec);
}
+ void visitAggTypeCtorExpr(AggTypeCtorExpr* expr, ExprEmitArg const& arg)
+ {
+ auto prec = kEOp_Postfix;
+ auto outerPrec = arg.outerPrec;
+ bool needClose = MaybeEmitParens(outerPrec, prec);
+ emitTypeExp(expr->base);
+ Emit("(");
+ bool first = true;
+ for (auto aa : expr->Arguments)
+ {
+ if (!first) Emit(", ");
+ EmitExpr(aa);
+ first = false;
+ }
+ Emit(")");
+
+ if(needClose) Emit(")");
+ }
void visitMemberExpressionSyntaxNode(MemberExpressionSyntaxNode* memberExpr, ExprEmitArg const& arg)
{
@@ -3245,17 +3263,23 @@ struct EmitVisitor
auto declRefType = dataType->As<DeclRefType>();
assert(declRefType);
- // We expect to always have layout information
- assert(layout);
+ // We expect the layout, if present, to be for a structured type...
+ RefPtr<StructTypeLayout> structTypeLayout;
+ if (layout)
+ {
- // We expect the layout to be for a structured type...
- RefPtr<ParameterBlockTypeLayout> bufferLayout = layout->typeLayout.As<ParameterBlockTypeLayout>();
- assert(bufferLayout);
+ auto typeLayout = layout->typeLayout;
+ if (auto bufferLayout = typeLayout.As<ParameterBlockTypeLayout>())
+ {
+ typeLayout = bufferLayout->elementTypeLayout;
+ }
- RefPtr<StructTypeLayout> structTypeLayout = bufferLayout->elementTypeLayout.As<StructTypeLayout>();
- assert(structTypeLayout);
+ structTypeLayout = typeLayout.As<StructTypeLayout>();
+ assert(structTypeLayout);
+
+ emitGLSLLayoutQualifiers(layout);
+ }
- emitGLSLLayoutQualifiers(layout);
EmitModifiers(varDecl);
@@ -3293,13 +3317,16 @@ struct EmitVisitor
{
for (auto field : getMembersOfType<StructField>(structRef))
{
- RefPtr<VarLayout> fieldLayout;
- structTypeLayout->mapVarToLayout.TryGetValue(field.getDecl(), fieldLayout);
- // assert(fieldLayout);
+ if (structTypeLayout)
+ {
+ RefPtr<VarLayout> fieldLayout;
+ structTypeLayout->mapVarToLayout.TryGetValue(field.getDecl(), fieldLayout);
+ // assert(fieldLayout);
- // TODO(tfoley): We may want to emit *some* of these,
- // some of the time...
- // emitGLSLLayoutQualifiers(fieldLayout);
+ // TODO(tfoley): We may want to emit *some* of these,
+ // some of the time...
+ // emitGLSLLayoutQualifiers(fieldLayout);
+ }
EmitVarDeclCommon(field);