diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-07-09 18:38:46 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-07-09 18:38:46 -0700 |
| commit | 8aa0dcff397a6dbb1c262588e45110a6f673f6f9 (patch) | |
| tree | e116eb29c9c842778d9d053198e8faa4398cc9f7 /source | |
| parent | 064c28f58e845be67a31283cb885b22f32118f49 (diff) | |
Fix up scoping for cross-compiled `main()` body
The earier changes to add sequence statements and change how the `isBuildingStmt` logic in lowering works doesn't work for this logic, which assumes it can just set `isBuildingStmt` and be sure that decls will go into the right place.
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/lower.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/source/slang/lower.cpp b/source/slang/lower.cpp index 55dabb826..60f86ad17 100644 --- a/source/slang/lower.cpp +++ b/source/slang/lower.cpp @@ -1714,10 +1714,14 @@ struct LoweringVisitor if (loweredEntryPointFunc->getName() == "main") loweredEntryPointFunc->Name.Content = "main_"; + RefPtr<BlockStmt> bodyStmt = new BlockStmt(); + bodyStmt->scopeDecl = new ScopeDecl(); + // We will want to generate declarations into the body of our new `main()` LoweringVisitor subVisitor = *this; subVisitor.isBuildingStmt = true; subVisitor.stmtBeingBuilt = nullptr; + subVisitor.parentDecl = bodyStmt->scopeDecl; // The parameters of the entry-point function will be translated to // both a local variable (for passing to/from the entry point func), @@ -1839,7 +1843,9 @@ struct LoweringVisitor VaryingParameterDirection::Output); } - mainDecl->Body = subVisitor.stmtBeingBuilt; + bodyStmt->body = subVisitor.stmtBeingBuilt; + + mainDecl->Body = bodyStmt; // Once we are done building the body, we append our new declaration to the program. |
